cef/patch/patches/chrome_renderer_print_previ...

89 lines
3.5 KiB
Diff
Raw Normal View History

chrome: Add support for Alloy style browsers and windows (see #3681) Split the Alloy runtime into bootstrap and style components. Support creation of Alloy style browsers and windows with the Chrome runtime. Chrome runtime (`--enable-chrome-runtime`) + Alloy style (`--use-alloy-style`) supports Views (`--use-views`), native parent (`--use-native`) and windowless rendering (`--off-screen-rendering-enabled`). Print preview is supported in all cases except with windowless rendering on all platforms and native parent on MacOS. It is disabled by default with Alloy style for legacy compatibility. Where supported it can be enabled or disabled globally using `--[enable|disable]-print-preview` or configured on a per-RequestContext basis using the `printing.print_preview_disabled` preference. It also behaves as expected when triggered via the PDF viewer print button. Chrome runtime + Alloy style behavior differs from Alloy runtime in the following significant ways: - Supports Chrome error pages by default. - DevTools popups are Chrome style only (cannot be windowless). - The Alloy extension API will not supported. Chrome runtime + Alloy style passes all expected Alloy ceftests except the following: - `DisplayTest.AutoResize` (Alloy extension API not supported) - `DownloadTest.*` (Download API not yet supported) - `ExtensionTest.*` (Alloy extension API not supported) This change also adds Chrome runtime support for CefContextMenuHandler::RunContextMenu (see #3293). This change also explicitly blocks (and doesn't retry) FrameAttached requests from PDF viewer and print preview excluded frames (see #3664). Known issues specific to Chrome runtime + Alloy style: - DevTools popup with windowless rendering doesn't load successfully. Use windowed rendering or remote debugging as a workaround. - Chrome style Window with Alloy style BrowserView (`--use-alloy-style --use-chrome-style-window`) does not show Chrome theme changes. To test: - Run `ceftests --enable-chrome-runtime --use-alloy-style [--use-chrome-style-window] [--use-views|--use-native] --gtest_filter=...` - Run `cefclient --enable-chrome-runtime --use-alloy-style [--use-chrome-style-window] [--use-views|--use-native|--off-screen-rendering-enabled]` - Run `cefsimple --enable-chrome-runtime --use-alloy-style [--use-views]`
2024-04-17 18:01:26 +02:00
diff --git chrome/renderer/printing/chrome_print_render_frame_helper_delegate.cc chrome/renderer/printing/chrome_print_render_frame_helper_delegate.cc
index 631a01a21a562..33e318e251aa2 100644
chrome: Add support for Alloy style browsers and windows (see #3681) Split the Alloy runtime into bootstrap and style components. Support creation of Alloy style browsers and windows with the Chrome runtime. Chrome runtime (`--enable-chrome-runtime`) + Alloy style (`--use-alloy-style`) supports Views (`--use-views`), native parent (`--use-native`) and windowless rendering (`--off-screen-rendering-enabled`). Print preview is supported in all cases except with windowless rendering on all platforms and native parent on MacOS. It is disabled by default with Alloy style for legacy compatibility. Where supported it can be enabled or disabled globally using `--[enable|disable]-print-preview` or configured on a per-RequestContext basis using the `printing.print_preview_disabled` preference. It also behaves as expected when triggered via the PDF viewer print button. Chrome runtime + Alloy style behavior differs from Alloy runtime in the following significant ways: - Supports Chrome error pages by default. - DevTools popups are Chrome style only (cannot be windowless). - The Alloy extension API will not supported. Chrome runtime + Alloy style passes all expected Alloy ceftests except the following: - `DisplayTest.AutoResize` (Alloy extension API not supported) - `DownloadTest.*` (Download API not yet supported) - `ExtensionTest.*` (Alloy extension API not supported) This change also adds Chrome runtime support for CefContextMenuHandler::RunContextMenu (see #3293). This change also explicitly blocks (and doesn't retry) FrameAttached requests from PDF viewer and print preview excluded frames (see #3664). Known issues specific to Chrome runtime + Alloy style: - DevTools popup with windowless rendering doesn't load successfully. Use windowed rendering or remote debugging as a workaround. - Chrome style Window with Alloy style BrowserView (`--use-alloy-style --use-chrome-style-window`) does not show Chrome theme changes. To test: - Run `ceftests --enable-chrome-runtime --use-alloy-style [--use-chrome-style-window] [--use-views|--use-native] --gtest_filter=...` - Run `cefclient --enable-chrome-runtime --use-alloy-style [--use-chrome-style-window] [--use-views|--use-native|--off-screen-rendering-enabled]` - Run `cefsimple --enable-chrome-runtime --use-alloy-style [--use-views]`
2024-04-17 18:01:26 +02:00
--- chrome/renderer/printing/chrome_print_render_frame_helper_delegate.cc
+++ chrome/renderer/printing/chrome_print_render_frame_helper_delegate.cc
@@ -25,12 +25,31 @@
#include "extensions/renderer/guest_view/mime_handler_view/post_message_support.h"
#endif // BUILDFLAG(ENABLE_PDF)
-ChromePrintRenderFrameHelperDelegate::ChromePrintRenderFrameHelperDelegate() =
- default;
+namespace {
+
+std::optional<bool> g_next_print_preview_enabled;
+
+} // namespace
+
+ChromePrintRenderFrameHelperDelegate::ChromePrintRenderFrameHelperDelegate(
+ std::optional<bool> print_preview_enabled)
+ : print_preview_enabled_(print_preview_enabled.has_value()
+ ? print_preview_enabled
+ : g_next_print_preview_enabled) {
+ if (g_next_print_preview_enabled.has_value()) {
+ g_next_print_preview_enabled = std::nullopt;
+ }
+}
ChromePrintRenderFrameHelperDelegate::~ChromePrintRenderFrameHelperDelegate() =
default;
+// static
+void ChromePrintRenderFrameHelperDelegate::SetNextPrintPreviewEnabled(
+ std::optional<bool> enabled) {
+ g_next_print_preview_enabled = enabled;
+}
+
// Return the PDF object element if `frame` is the out of process PDF extension
// or its child frame.
blink::WebElement ChromePrintRenderFrameHelperDelegate::GetPdfElement(
@@ -47,6 +66,10 @@ blink::WebElement ChromePrintRenderFrameHelperDelegate::GetPdfElement(
}
bool ChromePrintRenderFrameHelperDelegate::IsPrintPreviewEnabled() {
+ if (print_preview_enabled_.has_value()) {
+ return *print_preview_enabled_;
+ }
+
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
return !command_line->HasSwitch(switches::kDisablePrintPreview);
}
diff --git chrome/renderer/printing/chrome_print_render_frame_helper_delegate.h chrome/renderer/printing/chrome_print_render_frame_helper_delegate.h
index ab12b010c13d9..48850a94ae255 100644
--- chrome/renderer/printing/chrome_print_render_frame_helper_delegate.h
+++ chrome/renderer/printing/chrome_print_render_frame_helper_delegate.h
@@ -5,12 +5,15 @@
#ifndef CHROME_RENDERER_PRINTING_CHROME_PRINT_RENDER_FRAME_HELPER_DELEGATE_H_
#define CHROME_RENDERER_PRINTING_CHROME_PRINT_RENDER_FRAME_HELPER_DELEGATE_H_
+#include <optional>
+
#include "components/printing/renderer/print_render_frame_helper.h"
class ChromePrintRenderFrameHelperDelegate
: public printing::PrintRenderFrameHelper::Delegate {
public:
- ChromePrintRenderFrameHelperDelegate();
+ explicit ChromePrintRenderFrameHelperDelegate(
+ std::optional<bool> print_preview_enabled = std::nullopt);
ChromePrintRenderFrameHelperDelegate(
const ChromePrintRenderFrameHelperDelegate&) = delete;
@@ -19,12 +22,17 @@ class ChromePrintRenderFrameHelperDelegate
~ChromePrintRenderFrameHelperDelegate() override;
+ // Set the value for the next instance of this object that is created.
+ static void SetNextPrintPreviewEnabled(std::optional<bool> enabled);
+
private:
// printing::PrintRenderFrameHelper::Delegate:
blink::WebElement GetPdfElement(blink::WebLocalFrame* frame) override;
bool IsPrintPreviewEnabled() override;
bool OverridePrint(blink::WebLocalFrame* frame) override;
bool ShouldGenerateTaggedPDF() override;
+
+ const std::optional<bool> print_preview_enabled_;
};
#endif // CHROME_RENDERER_PRINTING_CHROME_PRINT_RENDER_FRAME_HELPER_DELEGATE_H_