mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
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]`
This commit is contained in:
@@ -84,16 +84,10 @@ MainContextImpl::MainContextImpl(CefRefPtr<CefCommandLine> command_line,
|
||||
#endif
|
||||
}
|
||||
|
||||
// Enable experimental Chrome runtime. See issue #2969 for details.
|
||||
use_chrome_runtime_ =
|
||||
// Enable Chrome runtime bootstrap. See issue #2969 for details.
|
||||
use_chrome_bootstrap_ =
|
||||
command_line_->HasSwitch(switches::kEnableChromeRuntime);
|
||||
|
||||
if (use_windowless_rendering_ && use_chrome_runtime_) {
|
||||
LOG(ERROR)
|
||||
<< "Windowless rendering is not supported with the Chrome runtime.";
|
||||
use_chrome_runtime_ = false;
|
||||
}
|
||||
|
||||
// Whether the Views framework will be used.
|
||||
use_views_ = command_line_->HasSwitch(switches::kUseViews);
|
||||
|
||||
@@ -103,22 +97,32 @@ MainContextImpl::MainContextImpl(CefRefPtr<CefCommandLine> command_line,
|
||||
use_views_ = false;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN) || defined(OS_LINUX)
|
||||
use_chrome_runtime_native_ =
|
||||
use_chrome_runtime_ && command_line->HasSwitch(switches::kUseNative);
|
||||
if (use_chrome_runtime_ && !use_views_ && !use_chrome_runtime_native_) {
|
||||
// Whether Alloy style will be used.
|
||||
use_alloy_style_ = !use_chrome_bootstrap_ ||
|
||||
command_line_->HasSwitch(switches::kUseAlloyStyle);
|
||||
|
||||
if (use_windowless_rendering_ && !use_alloy_style_) {
|
||||
LOG(WARNING) << "Windowless rendering requires Alloy style.";
|
||||
use_alloy_style_ = true;
|
||||
}
|
||||
|
||||
// Whether to use a native parent window with Chrome runtime.
|
||||
const bool use_chrome_native_parent =
|
||||
use_chrome_bootstrap_ && command_line->HasSwitch(switches::kUseNative);
|
||||
|
||||
#if defined(OS_MAC)
|
||||
if (use_chrome_native_parent && !use_alloy_style_) {
|
||||
// MacOS does not support Chrome style with native parent. See issue #3294.
|
||||
LOG(WARNING) << "Native parent on MacOS requires Alloy style";
|
||||
use_alloy_style_ = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (use_chrome_bootstrap_ && !use_views_ && !use_chrome_native_parent &&
|
||||
!use_windowless_rendering_) {
|
||||
LOG(WARNING) << "Chrome runtime defaults to the Views framework.";
|
||||
use_views_ = true;
|
||||
}
|
||||
#else // !(defined(OS_WIN) || defined(OS_LINUX))
|
||||
if (use_chrome_runtime_ && !use_views_) {
|
||||
// TODO(chrome): Add support for this runtime configuration (e.g. a fully
|
||||
// styled Chrome window with cefclient menu customizations). In the mean
|
||||
// time this can be demo'd with "cefsimple --enable-chrome-runtime".
|
||||
LOG(WARNING) << "Chrome runtime requires the Views framework.";
|
||||
use_views_ = true;
|
||||
}
|
||||
#endif // !(defined(OS_WIN) || defined(OS_LINUX))
|
||||
|
||||
if (command_line_->HasSwitch(switches::kBackgroundColor)) {
|
||||
// Parse the background color value.
|
||||
@@ -135,6 +139,14 @@ MainContextImpl::MainContextImpl(CefRefPtr<CefCommandLine> command_line,
|
||||
if (!use_transparent_painting) {
|
||||
browser_background_color_ = background_color_;
|
||||
}
|
||||
|
||||
// Log the current configuration.
|
||||
LOG(WARNING) << "Using " << (use_chrome_bootstrap_ ? "Chrome" : "Alloy")
|
||||
<< " bootstrap; " << (use_alloy_style_ ? "Alloy" : "Chrome")
|
||||
<< " style; " << (use_views_ ? "Views" : "Native")
|
||||
<< "-hosted window; "
|
||||
<< (use_windowless_rendering_ ? "Windowless" : "Windowed")
|
||||
<< " rendering (not a warning)";
|
||||
}
|
||||
|
||||
MainContextImpl::~MainContextImpl() {
|
||||
@@ -171,20 +183,16 @@ cef_color_t MainContextImpl::GetBackgroundColor() {
|
||||
return background_color_;
|
||||
}
|
||||
|
||||
bool MainContextImpl::UseChromeRuntime() {
|
||||
return use_chrome_runtime_;
|
||||
bool MainContextImpl::UseChromeBootstrap() {
|
||||
return use_chrome_bootstrap_;
|
||||
}
|
||||
|
||||
bool MainContextImpl::UseChromeRuntimeNative() {
|
||||
return use_chrome_runtime_native_;
|
||||
}
|
||||
|
||||
bool MainContextImpl::UseViews() {
|
||||
bool MainContextImpl::UseViewsGlobal() {
|
||||
return use_views_;
|
||||
}
|
||||
|
||||
bool MainContextImpl::UseWindowlessRendering() {
|
||||
return use_windowless_rendering_;
|
||||
bool MainContextImpl::UseAlloyStyleGlobal() {
|
||||
return use_alloy_style_;
|
||||
}
|
||||
|
||||
bool MainContextImpl::TouchEventsEnabled() {
|
||||
@@ -199,7 +207,7 @@ bool MainContextImpl::UseDefaultPopup() {
|
||||
void MainContextImpl::PopulateSettings(CefSettings* settings) {
|
||||
client::ClientAppBrowser::PopulateSettings(command_line_, *settings);
|
||||
|
||||
if (use_chrome_runtime_) {
|
||||
if (use_chrome_bootstrap_) {
|
||||
settings->chrome_runtime = true;
|
||||
}
|
||||
|
||||
@@ -245,7 +253,7 @@ void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) {
|
||||
settings->background_color = browser_background_color_;
|
||||
}
|
||||
|
||||
if (use_chrome_runtime_ &&
|
||||
if (use_chrome_bootstrap_ &&
|
||||
command_line_->HasSwitch(switches::kHideChromeBubbles)) {
|
||||
settings->chrome_status_bubble = STATE_DISABLED;
|
||||
settings->chrome_zoom_bubble = STATE_DISABLED;
|
||||
|
Reference in New Issue
Block a user