blob: 696ff6cbcf835f828cf1a735527e4a6d5c46aba8 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2017 The Chromium Authors
Sadrul Habib Chowdhury33770462017-09-26 20:36:192// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_
6#define CHROME_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_
7
Peter Kvitek802b2be2021-08-20 20:46:118#include <memory>
9
Avi Drissman20f92412021-08-15 00:09:2010#include "base/memory/weak_ptr.h"
Sadrul Habib Chowdhury33770462017-09-26 20:36:1911#include "chrome/browser/devtools/protocol/page.h"
Wolfgang Beyerf5489332021-08-23 09:51:4112#include "components/webapps/browser/installable/installable_manager.h"
Peter Kvitek07e00302021-08-27 21:53:4213#include "content/public/browser/devtools_agent_host.h"
Wolfgang Beyerf5489332021-08-23 09:51:4114#include "content/public/browser/web_contents_observer.h"
Peter Kvitek07e00302021-08-27 21:53:4215#include "printing/buildflags/buildflags.h"
Wolfgang Beyerf5489332021-08-23 09:51:4116#include "third_party/blink/public/common/manifest/manifest.h"
Sadrul Habib Chowdhury33770462017-09-26 20:36:1917
Peter Kvitek07e00302021-08-27 21:53:4218#if BUILDFLAG(ENABLE_PRINTING)
Peter Kvitek9d9c4ef2022-07-21 18:48:5219#include "components/printing/browser/headless/headless_print_manager.h"
20#include "components/printing/browser/print_to_pdf/pdf_print_result.h"
Peter Kvitek07e00302021-08-27 21:53:4221#endif // BUILDFLAG(ENABLE_PRINTING)
22
Sadrul Habib Chowdhury33770462017-09-26 20:36:1923namespace content {
Mandy Chen290780142020-01-23 03:21:5624struct InstallabilityError;
Sadrul Habib Chowdhury33770462017-09-26 20:36:1925class WebContents;
Peter Kvitek802b2be2021-08-20 20:46:1126} // namespace content
Sadrul Habib Chowdhury33770462017-09-26 20:36:1927
Jan Scheffler2a81b322019-12-14 09:09:0028class SkBitmap;
29
Avi Drissman20f92412021-08-15 00:09:2030class PageHandler : public protocol::Page::Backend {
Sadrul Habib Chowdhury33770462017-09-26 20:36:1931 public:
Peter Kvitek07e00302021-08-27 21:53:4232 PageHandler(scoped_refptr<content::DevToolsAgentHost> agent_host,
33 content::WebContents* web_contents,
Sadrul Habib Chowdhury33770462017-09-26 20:36:1934 protocol::UberDispatcher* dispatcher);
Peter Boström53c6c5952021-09-17 09:41:2635
36 PageHandler(const PageHandler&) = delete;
37 PageHandler& operator=(const PageHandler&) = delete;
38
Sadrul Habib Chowdhury33770462017-09-26 20:36:1939 ~PageHandler() override;
40
41 void ToggleAdBlocking(bool enabled);
42
43 // Page::Backend:
44 protocol::Response Enable() override;
45 protocol::Response Disable() override;
46 protocol::Response SetAdBlockingEnabled(bool enabled) override;
Stephen McGruera3d64f2c42021-11-04 21:22:5547 protocol::Response SetSPCTransactionMode(
48 const protocol::String& mode) override;
Pavel Feldmanc94653622019-04-11 03:02:1749 void GetInstallabilityErrors(
50 std::unique_ptr<GetInstallabilityErrorsCallback> callback) override;
Sadrul Habib Chowdhury33770462017-09-26 20:36:1951
Jan Scheffler2a81b322019-12-14 09:09:0052 void GetManifestIcons(
53 std::unique_ptr<GetManifestIconsCallback> callback) override;
54
Peter Kvitek802b2be2021-08-20 20:46:1155 void PrintToPDF(protocol::Maybe<bool> landscape,
56 protocol::Maybe<bool> display_header_footer,
57 protocol::Maybe<bool> print_background,
58 protocol::Maybe<double> scale,
59 protocol::Maybe<double> paper_width,
60 protocol::Maybe<double> paper_height,
61 protocol::Maybe<double> margin_top,
62 protocol::Maybe<double> margin_bottom,
63 protocol::Maybe<double> margin_left,
64 protocol::Maybe<double> margin_right,
65 protocol::Maybe<protocol::String> page_ranges,
Peter Kvitek802b2be2021-08-20 20:46:1166 protocol::Maybe<protocol::String> header_template,
67 protocol::Maybe<protocol::String> footer_template,
68 protocol::Maybe<bool> prefer_css_page_size,
69 protocol::Maybe<protocol::String> transfer_mode,
70 std::unique_ptr<PrintToPDFCallback> callback) override;
71
Wolfgang Beyerf5489332021-08-23 09:51:4172 void GetAppId(std::unique_ptr<GetAppIdCallback> callback) override;
73
Sadrul Habib Chowdhury33770462017-09-26 20:36:1974 private:
Pavel Feldmanc94653622019-04-11 03:02:1775 static void GotInstallabilityErrors(
76 std::unique_ptr<GetInstallabilityErrorsCallback> callback,
Mandy Chen