#include "chrome/browser/devtools/protocol/page_handler.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "components/custom_handlers/protocol_handler_registry.h"
#include "components/payments/content/payment_request_web_contents_manager.h"
#include "components/subresource_filter/content/browser/devtools_interaction_tracker.h"
#include "third_party/blink/public/common/manifest/manifest_util.h"
#include "ui/gfx/image/image.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "components/printing/browser/print_to_pdf/pdf_print_utils.h"
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_view_manager.h"
#else
#include "chrome/browser/printing/print_view_manager_basic.h"
#endif
#endif
#if BUILDFLAG(ENABLE_PRINTING)
template <typename T>
std::optional<T> OptionalFromMaybe(const protocol::Maybe<T>& maybe) { … }
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
ActivePrintManager;
#else
using ActivePrintManager = printing::PrintViewManagerBasic;
#endif
#endif
PageHandler::PageHandler(scoped_refptr<content::DevToolsAgentHost> agent_host,
content::WebContents* web_contents,
protocol::UberDispatcher* dispatcher)
: … { … }
PageHandler::~PageHandler() { … }
void PageHandler::ToggleAdBlocking(bool enabled) { … }
protocol::Response PageHandler::Enable() { … }
protocol::Response PageHandler::Disable() { … }
protocol::Response PageHandler::SetAdBlockingEnabled(bool enabled) { … }
protocol::Response PageHandler::SetSPCTransactionMode(
const protocol::String& mode) { … }
protocol::Response PageHandler::SetRPHRegistrationMode(
const protocol::String& mode) { … }
void PageHandler::GetInstallabilityErrors(
std::unique_ptr<GetInstallabilityErrorsCallback> callback) { … }
void PageHandler::GotInstallabilityErrors(
std::unique_ptr<GetInstallabilityErrorsCallback> callback,
std::vector<content::InstallabilityError> installability_errors) { … }
void PageHandler::GetManifestIcons(
std::unique_ptr<GetManifestIconsCallback> callback) { … }
void PageHandler::GotManifestIcons(
std::unique_ptr<GetManifestIconsCallback> callback,
const SkBitmap* primary_icon) { … }
void PageHandler::PrintToPDF(protocol::Maybe<bool> landscape,
protocol::Maybe<bool> display_header_footer,
protocol::Maybe<bool> print_background,
protocol::Maybe<double> scale,
protocol::Maybe<double> paper_width,
protocol::Maybe<double> paper_height,
protocol::Maybe<double> margin_top,
protocol::Maybe<double> margin_bottom,
protocol::Maybe<double> margin_left,
protocol::Maybe<double> margin_right,
protocol::Maybe<protocol::String> page_ranges,
protocol::Maybe<protocol::String> header_template,
protocol::Maybe<protocol::String> footer_template,
protocol::Maybe<bool> prefer_css_page_size,
protocol::Maybe<protocol::String> transfer_mode,
protocol::Maybe<bool> generate_tagged_pdf,
protocol::Maybe<bool> generate_document_outline,
std::unique_ptr<PrintToPDFCallback> callback) { … }
void PageHandler::GetAppId(std::unique_ptr<GetAppIdCallback> callback) { … }
void PageHandler::OnDidGetManifest(std::unique_ptr<GetAppIdCallback> callback,
const webapps::InstallableData& data) { … }
#if BUILDFLAG(ENABLE_PRINTING)
void PageHandler::OnPDFCreated(bool return_as_stream,
std::unique_ptr<PrintToPDFCallback> callback,
print_to_pdf::PdfPrintResult print_result,
scoped_refptr<base::RefCountedMemory> data) { … }
#endif