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:
@ -58,6 +58,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(
|
||||
bool is_popup,
|
||||
bool is_windowless,
|
||||
bool print_preview_enabled,
|
||||
CefRefPtr<CefDictionaryValue> extra_info);
|
||||
|
||||
// Called from WebContentsDelegate::WebContentsCreated when a new browser is
|
||||
@ -67,6 +68,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
scoped_refptr<CefBrowserInfo> CreatePopupBrowserInfo(
|
||||
content::WebContents* new_contents,
|
||||
bool is_windowless,
|
||||
bool print_preview_enabled,
|
||||
CefRefPtr<CefDictionaryValue> extra_info);
|
||||
|
||||
// Called from ContentBrowserClient::CanCreateWindow. See comments on
|
||||
@ -124,10 +126,10 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
|
||||
// Returns the CefBrowserInfo matching the specified ID/token or nullptr if no
|
||||
// match is found. It is allowed to add new callers of this method but
|
||||
// consider using CefBrowserHostBase::GetBrowserForGlobalId/Token() or
|
||||
// extensions::GetOwnerBrowserForGlobalId() instead. If |is_guest_view| is
|
||||
// non-nullptr it will be set to true if the ID/token matches a guest view
|
||||
// associated with the returned browser info instead of the browser itself.
|
||||
// consider using CefBrowserHostBase::GetBrowserForGlobalId/Token() instead.
|
||||
// If |is_guest_view| is non-nullptr it will be set to true if the ID/token
|
||||
// matches a guest view associated with the returned browser info instead of
|
||||
// the browser itself.
|
||||
scoped_refptr<CefBrowserInfo> GetBrowserInfo(
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool* is_guest_view = nullptr);
|
||||
@ -149,6 +151,15 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
static bool ShouldCreateViewsHostedPopup(CefRefPtr<CefBrowserHostBase> opener,
|
||||
bool use_default_browser_creation);
|
||||
|
||||
// Returns the FrameHost associated with |rfh|, if any. |browser_info| and
|
||||
// |excluded_type| will be populated if non-nullptr. An excluded type will not
|
||||
// have a FrameHost but |browser_info| may still be populated if the
|
||||
// association is known.
|
||||
static CefRefPtr<CefFrameHostImpl> GetFrameHost(content::RenderFrameHost* rfh,
|
||||
bool prefer_speculative,
|
||||
CefBrowserInfo** browser_info,
|
||||
bool* excluded_type);
|
||||
|
||||
private:
|
||||
// RenderProcessHostObserver methods:
|
||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
@ -179,6 +190,9 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
WEB_CONTENTS_CREATED,
|
||||
} step;
|
||||
|
||||
// True if this popup is Alloy style, otherwise Chrome style.
|
||||
bool alloy_style;
|
||||
|
||||
// Initial state from ViewHostMsg_CreateWindow.
|
||||
// |target_url| will be empty if a popup is created via window.open() and
|
||||
// never navigated. For example: javascript:window.open();
|
||||
@ -195,7 +209,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate;
|
||||
|
||||
// True if default Browser or tab creation should proceed from
|
||||
// AddWebContents (chrome runtime only).
|
||||
// AddWebContents (Chrome style only).
|
||||
bool use_default_browser_creation = false;
|
||||
|
||||
// The newly created WebContents (set in WebContentsCreated).
|
||||
@ -207,13 +221,15 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
|
||||
// Used after CanCreateWindow is called.
|
||||
std::unique_ptr<PendingPopup> PopPendingPopup(
|
||||
PendingPopup::Step previous_step,
|
||||
PendingPopup::Step previous_step_alloy,
|
||||
PendingPopup::Step previous_step_chrome,
|
||||
const content::GlobalRenderFrameHostId& opener_global_id,
|
||||
const GURL& target_url);
|
||||
|
||||
// Used after WebContentsCreated is called.
|
||||
std::unique_ptr<PendingPopup> PopPendingPopup(
|
||||
PendingPopup::Step previous_step,
|
||||
PendingPopup::Step previous_step_alloy,
|
||||
PendingPopup::Step previous_step_chrome,
|
||||
content::WebContents* new_contents);
|
||||
|
||||
// Retrieves the BrowserInfo matching the specified ID/token.
|
||||
@ -224,6 +240,15 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
const content::GlobalRenderFrameHostToken& global_token,
|
||||
bool* is_guest_view);
|
||||
|
||||
// Check for excluded frames that can be responded to immediately.
|
||||
static void CheckExcludedNewBrowserInfoOnUIThread(
|
||||
const content::GlobalRenderFrameHostToken& global_token);
|
||||
|
||||
void ContinueNewBrowserInfo(
|
||||
const content::GlobalRenderFrameHostToken& global_token,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
bool is_guest_view);
|
||||
|
||||
// Send the response for a pending OnGetNewBrowserInfo request.
|
||||
static void SendNewBrowserInfoResponse(
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
|
Reference in New Issue
Block a user