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:
Marshall Greenblatt
2024-04-17 12:01:26 -04:00
parent 62c93f01f4
commit dca0435d2f
216 changed files with 3388 additions and 1565 deletions

View File

@@ -6,7 +6,6 @@
#include <utility>
#include "include/views/cef_window.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/views/browser_view_impl.h"
#include "libcef/browser/views/menu_runner_views.h"
@@ -15,43 +14,6 @@
#include "content/public/browser/render_widget_host.h"
#include "ui/views/widget/widget.h"
namespace {
// Default popup window delegate implementation.
class PopupWindowDelegate : public CefWindowDelegate {
public:
explicit PopupWindowDelegate(CefRefPtr<CefBrowserView> browser_view)
: browser_view_(browser_view) {}
PopupWindowDelegate(const PopupWindowDelegate&) = delete;
PopupWindowDelegate& operator=(const PopupWindowDelegate&) = delete;
void OnWindowCreated(CefRefPtr<CefWindow> window) override {
window->AddChildView(browser_view_);
window->Show();
browser_view_->RequestFocus();
}
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override {
browser_view_ = nullptr;
}
bool CanClose(CefRefPtr<CefWindow> window) override {
CefRefPtr<CefBrowser> browser = browser_view_->GetBrowser();
if (browser) {
return browser->GetHost()->TryCloseBrowser();
}
return true;
}
private:
CefRefPtr<CefBrowserView> browser_view_;
IMPLEMENT_REFCOUNTING(PopupWindowDelegate);
};
} // namespace
CefBrowserPlatformDelegateViews::CefBrowserPlatformDelegateViews(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate,
CefRefPtr<CefBrowserViewImpl> browser_view)
@@ -63,10 +25,10 @@ CefBrowserPlatformDelegateViews::CefBrowserPlatformDelegateViews(
}
void CefBrowserPlatformDelegateViews::SetBrowserView(
CefRefPtr<CefBrowserViewImpl> browser_view) {
CefRefPtr<CefBrowserView> browser_view) {
DCHECK(!browser_view_);
DCHECK(browser_view);
browser_view_ = browser_view;
browser_view_ = static_cast<CefBrowserViewImpl*>(browser_view.get());
}
void CefBrowserPlatformDelegateViews::WebContentsCreated(
@@ -145,49 +107,6 @@ CefRefPtr<CefBrowserView> CefBrowserPlatformDelegateViews::GetBrowserView()
return browser_view_.get();
}
void CefBrowserPlatformDelegateViews::PopupWebContentsCreated(
const CefBrowserSettings& settings,
CefRefPtr<CefClient> client,
content::WebContents* new_web_contents,
CefBrowserPlatformDelegate* new_platform_delegate,
bool is_devtools) {
DCHECK(new_platform_delegate->IsViewsHosted());
CefBrowserPlatformDelegateViews* new_platform_delegate_impl =
static_cast<CefBrowserPlatformDelegateViews*>(new_platform_delegate);
CefRefPtr<CefBrowserViewDelegate> new_delegate;
if (browser_view_->delegate()) {
new_delegate = browser_view_->delegate()->GetDelegateForPopupBrowserView(
browser_view_.get(), settings, client, is_devtools);
}
// Create a new BrowserView for the popup.
CefRefPtr<CefBrowserViewImpl> new_browser_view =
CefBrowserViewImpl::CreateForPopup(settings, new_delegate);
// Associate the PlatformDelegate with the new BrowserView.
new_platform_delegate_impl->SetBrowserView(new_browser_view);
}
void CefBrowserPlatformDelegateViews::PopupBrowserCreated(
CefBrowserHostBase* new_browser,
bool is_devtools) {
CefRefPtr<CefBrowserView> new_browser_view =
CefBrowserView::GetForBrowser(new_browser);
DCHECK(new_browser_view);
bool popup_handled = false;
if (browser_view_->delegate()) {
popup_handled = browser_view_->delegate()->OnPopupBrowserViewCreated(
browser_view_.get(), new_browser_view.get(), is_devtools);
}
if (!popup_handled) {
CefWindow::CreateTopLevelWindow(
new PopupWindowDelegate(new_browser_view.get()));
}
}
SkColor CefBrowserPlatformDelegateViews::GetBackgroundColor() const {
return native_delegate_->GetBackgroundColor();
}

View File

@@ -33,14 +33,7 @@ class CefBrowserPlatformDelegateViews
CefWindowHandle GetHostWindowHandle() const override;
views::Widget* GetWindowWidget() const override;
CefRefPtr<CefBrowserView> GetBrowserView() const override;
void PopupWebContentsCreated(
const CefBrowserSettings& settings,
CefRefPtr<CefClient> client,
content::WebContents* new_web_contents,
CefBrowserPlatformDelegate* new_platform_delegate,
bool is_devtools) override;
void PopupBrowserCreated(CefBrowserHostBase* new_browser,
bool is_devtools) override;
void SetBrowserView(CefRefPtr<CefBrowserView> browser_view) override;
SkColor GetBackgroundColor() const override;
void WasResized() override;
void SendKeyEvent(const CefKeyEvent& event) override;
@@ -72,8 +65,6 @@ class CefBrowserPlatformDelegateViews
bool want_dip_coords) const override;
private:
void SetBrowserView(CefRefPtr<CefBrowserViewImpl> browser_view);
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate_;
CefRefPtr<CefBrowserViewImpl> browser_view_;
};

View File

@@ -15,6 +15,7 @@
#include "libcef/browser/thread_util.h"
#include "libcef/browser/views/widget.h"
#include "libcef/browser/views/window_impl.h"
#include "libcef/features/runtime.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/common/input/native_web_keyboard_event.h"
@@ -36,6 +37,40 @@ std::optional<cef_gesture_command_t> GetGestureCommand(
return std::nullopt;
}
bool ComputeAlloyStyle(CefBrowserViewDelegate* cef_delegate,
bool is_devtools_popup) {
// Alloy style is not supported with Chrome DevTools popups.
const bool supports_alloy_style =
cef::IsAlloyRuntimeEnabled() || !is_devtools_popup;
const bool supports_chrome_style = cef::IsChromeRuntimeEnabled();
const auto default_style = cef::IsAlloyRuntimeEnabled()
? CEF_RUNTIME_STYLE_ALLOY
: CEF_RUNTIME_STYLE_CHROME;
auto result_style = default_style;
if (cef_delegate) {
auto requested_style = cef_delegate->GetBrowserRuntimeStyle();
if (requested_style == CEF_RUNTIME_STYLE_ALLOY) {
if (supports_alloy_style) {
result_style = requested_style;
} else {
LOG(ERROR) << "GetBrowserRuntimeStyle() requested Alloy style; only "
"Chrome style is supported";
}
} else if (requested_style == CEF_RUNTIME_STYLE_CHROME) {
if (supports_chrome_style) {
result_style = requested_style;
} else {
LOG(ERROR) << "GetBrowserRuntimeStyle() requested Chrome style; only "
"Alloy style is supported";
}
}
}
return result_style == CEF_RUNTIME_STYLE_ALLOY;
}
} // namespace
// static
@@ -55,8 +90,7 @@ CefRefPtr<CefBrowserView> CefBrowserView::GetForBrowser(
CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UIT_RETURN(nullptr);
CefBrowserHostBase* browser_impl =
static_cast<CefBrowserHostBase*>(browser.get());
auto browser_impl = CefBrowserHostBase::FromBrowser(browser);
if (browser_impl && browser_impl->is_views_hosted()) {
return browser_impl->GetBrowserView();
}
@@ -86,7 +120,8 @@ CefRefPtr<CefBrowserViewImpl> CefBrowserViewImpl::Create(
return nullptr;
}
CefRefPtr<CefBrowserViewImpl> browser_view = new CefBrowserViewImpl(delegate);
CefRefPtr<CefBrowserViewImpl> browser_view =
new CefBrowserViewImpl(delegate, /*is_devtools_popup=*/false);
browser_view->SetPendingBrowserCreateParams(
window_info, client, url, settings, extra_info, request_context);
browser_view->Initialize();
@@ -97,10 +132,12 @@ CefRefPtr<CefBrowserViewImpl> CefBrowserViewImpl::Create(
// static
CefRefPtr<CefBrowserViewImpl> CefBrowserViewImpl::CreateForPopup(
const CefBrowserSettings& settings,
CefRefPtr<CefBrowserViewDelegate> delegate) {
CefRefPtr<CefBrowserViewDelegate> delegate,
bool is_devtools) {
CEF_REQUIRE_UIT_RETURN(nullptr);
CefRefPtr<CefBrowserViewImpl> browser_view = new CefBrowserViewImpl(delegate);
CefRefPtr<CefBrowserViewImpl> browser_view =
new CefBrowserViewImpl(delegate, is_devtools);
browser_view->Initialize();
browser_view->SetDefaults(settings);
return browser_view;
@@ -175,7 +212,7 @@ CefRefPtr<CefBrowser> CefBrowserViewImpl::GetBrowser() {
CefRefPtr<CefView> CefBrowserViewImpl::GetChromeToolbar() {
CEF_REQUIRE_VALID_RETURN(nullptr);
if (cef::IsChromeRuntimeEnabled()) {
if (!is_alloy_style_) {
return chrome_browser_view()->cef_toolbar();
}
@@ -189,6 +226,11 @@ void CefBrowserViewImpl::SetPreferAccelerators(bool prefer_accelerators) {
}
}
cef_runtime_style_t CefBrowserViewImpl::GetRuntimeStyle() {
CEF_REQUIRE_VALID_RETURN(CEF_RUNTIME_STYLE_DEFAULT);
return IsAlloyStyle() ? CEF_RUNTIME_STYLE_ALLOY : CEF_RUNTIME_STYLE_CHROME;
}
void CefBrowserViewImpl::RequestFocus() {
CEF_REQUIRE_VALID_RETURN_VOID();
// Always execute asynchronously to work around issue #3040.
@@ -229,7 +271,26 @@ void CefBrowserViewImpl::GetDebugInfo(base::Value::Dict* info,
}
}
void CefBrowserViewImpl::OnBrowserViewAdded() {
void CefBrowserViewImpl::AddedToWidget() {
DCHECK(!cef_widget_);
views::Widget* widget = root_view()->GetWidget();
DCHECK(widget);
CefWidget* cef_widget = CefWidget::GetForWidget(widget);
DCHECK(cef_widget);
if (!browser_) {
if (cef_widget->IsAlloyStyle() && !is_alloy_style_) {
LOG(ERROR) << "Cannot add Chrome style BrowserView to Alloy style Window";
return;
}
if (cef_widget->IsChromeStyle() && cef_widget->GetThemeProfile()) {
LOG(ERROR) << "Cannot add multiple Chrome style BrowserViews";
return;
}
}
if (!browser_ && pending_browser_create_params_) {
// Top-level browsers will be created when this view is added to the views
// hierarchy.
@@ -240,17 +301,8 @@ void CefBrowserViewImpl::OnBrowserViewAdded() {
pending_browser_create_params_.reset(nullptr);
}
}
void CefBrowserViewImpl::AddedToWidget() {
DCHECK(!cef_widget_);
DCHECK(browser_);
views::Widget* widget = root_view()->GetWidget();
DCHECK(widget);
cef_widget_ = CefWidget::GetForWidget(widget);
DCHECK(cef_widget_);
cef_widget_ = cef_widget;
profile_ = Profile::FromBrowserContext(browser_->GetBrowserContext());
DCHECK(profile_);
@@ -276,7 +328,7 @@ bool CefBrowserViewImpl::OnGestureEvent(ui::GestureEvent* event) {
return true;
}
if (!cef::IsChromeRuntimeEnabled() && browser_) {
if (is_alloy_style_ && browser_) {
// Default handling for the Alloy runtime.
switch (*command) {
case CEF_GESTURE_COMMAND_BACK:
@@ -294,8 +346,11 @@ bool CefBrowserViewImpl::OnGestureEvent(ui::GestureEvent* event) {
}
CefBrowserViewImpl::CefBrowserViewImpl(
CefRefPtr<CefBrowserViewDelegate> delegate)
: ParentClass(delegate), weak_ptr_factory_(this) {}
CefRefPtr<CefBrowserViewDelegate> delegate,
bool is_devtools_popup)
: ParentClass(delegate),
is_alloy_style_(ComputeAlloyStyle(delegate.get(), is_devtools_popup)),
weak_ptr_factory_(this) {}
void CefBrowserViewImpl::SetPendingBrowserCreateParams(
const CefWindowInfo& window_info,
@@ -306,7 +361,8 @@ void CefBrowserViewImpl::SetPendingBrowserCreateParams(
CefRefPtr<CefRequestContext> request_context) {
DCHECK(!pending_browser_create_params_);
pending_browser_create_params_ = std::make_unique<CefBrowserCreateParams>();
pending_browser_create_params_->MaybeSetWindowInfo(window_info);
pending_browser_create_params_->MaybeSetWindowInfo(
window_info, /*allow_alloy_style=*/true, /*allow_chrome_style=*/true);
pending_browser_create_params_->client = client;
pending_browser_create_params_->url = url;
pending_browser_create_params_->settings = settings;
@@ -320,7 +376,7 @@ void CefBrowserViewImpl::SetDefaults(const CefBrowserSettings& settings) {
}
views::View* CefBrowserViewImpl::CreateRootView() {
if (cef::IsChromeRuntimeEnabled()) {
if (!is_alloy_style_) {
return new ChromeBrowserView(this);
}
@@ -328,7 +384,7 @@ views::View* CefBrowserViewImpl::CreateRootView() {
}
void CefBrowserViewImpl::InitializeRootView() {
if (cef::IsChromeRuntimeEnabled()) {
if (!is_alloy_style_) {
chrome_browser_view()->Initialize();
} else {
static_cast<CefBrowserViewView*>(root_view())->Initialize();
@@ -340,7 +396,7 @@ views::WebView* CefBrowserViewImpl::web_view() const {
return nullptr;
}
if (cef::IsChromeRuntimeEnabled()) {
if (!is_alloy_style_) {
return chrome_browser_view()->contents_web_view();
}
@@ -348,7 +404,7 @@ views::WebView* CefBrowserViewImpl::web_view() const {
}
ChromeBrowserView* CefBrowserViewImpl::chrome_browser_view() const {
CHECK(cef::IsChromeRuntimeEnabled());
CHECK(!is_alloy_style_);
return static_cast<ChromeBrowserView*>(root_view());
}

View File

@@ -48,7 +48,8 @@ class CefBrowserViewImpl
// nullptr.
static CefRefPtr<CefBrowserViewImpl> CreateForPopup(
const CefBrowserSettings& settings,
CefRefPtr<CefBrowserViewDelegate> delegate);
CefRefPtr<CefBrowserViewDelegate> delegate,
bool is_devtools);
// Called from CefBrowserPlatformDelegate[Chrome]Views.
void WebContentsCreated(content::WebContents* web_contents);
@@ -65,6 +66,7 @@ class CefBrowserViewImpl
CefRefPtr<CefBrowser> GetBrowser() override;
CefRefPtr<CefView> GetChromeToolbar() override;
void SetPreferAccelerators(bool prefer_accelerators) override;
cef_runtime_style_t GetRuntimeStyle() override;
// CefView methods:
CefRefPtr<CefBrowserView> AsBrowserView() override { return this; }
@@ -77,7 +79,6 @@ class CefBrowserViewImpl
void GetDebugInfo(base::Value::Dict* info, bool include_children) override;
// CefBrowserViewView::Delegate methods:
void OnBrowserViewAdded() override;
void AddedToWidget() override;
void RemovedFromWidget() override;
void OnBoundsChanged() override;
@@ -92,11 +93,15 @@ class CefBrowserViewImpl
// Return the CefWindowImpl hosting this object.
CefWindowImpl* cef_window_impl() const;
bool IsAlloyStyle() const { return is_alloy_style_; }
bool IsChromeStyle() const { return !is_alloy_style_; }
private:
// Create a new implementation object.
// Always call Initialize() after creation.
// |delegate| may be nullptr.
explicit CefBrowserViewImpl(CefRefPtr<CefBrowserViewDelegate> delegate);
CefBrowserViewImpl(CefRefPtr<CefBrowserViewDelegate> delegate,
bool is_devtools_popup);
void SetPendingBrowserCreateParams(
const CefWindowInfo& window_info,
@@ -122,6 +127,9 @@ class CefBrowserViewImpl
void DisassociateFromWidget();
// True if the browser is Alloy style, otherwise Chrome style.
const bool is_alloy_style_;
std::unique_ptr<CefBrowserCreateParams> pending_browser_create_params_;
CefRefPtr<CefBrowserHostBase> browser_;

View File

@@ -29,8 +29,6 @@ void CefBrowserViewView::ViewHierarchyChanged(
SetSize(size);
}
}
browser_view_delegate_->OnBrowserViewAdded();
}
}

View File

@@ -35,9 +35,6 @@ class CefBrowserViewView
class Delegate {
public:
// Called when the BrowserView has been added to a parent view.
virtual void OnBrowserViewAdded() = 0;
// Called when the BrowserView is added or removed from a Widget.
virtual void AddedToWidget() = 0;
virtual void RemovedFromWidget() = 0;

View File

@@ -218,7 +218,7 @@ void CefOverlayViewHost::Init(views::View* host_view,
RegisterDeleteDelegateCallback(
base::BindOnce(&CefOverlayViewHost::Cleanup, base::Unretained(this)));
if (cef::IsChromeRuntimeEnabled()) {
if (window_view_->IsChromeStyle()) {
// Some attributes associated with a Chrome toolbar are located via the
// Widget. See matching logic in BrowserView::AddedToWidget.
auto browser_view = BrowserView::GetBrowserViewForNativeWindow(

View File

@@ -5,11 +5,13 @@
#include "libcef/browser/views/widget.h"
#include "libcef/browser/chrome/views/chrome_browser_frame.h"
#include "libcef/browser/views/view_util.h"
#include "libcef/browser/views/widget_impl.h"
#include "libcef/browser/views/window_impl.h"
// static
CefWidget* CefWidget::Create(CefWindowView* window_view) {
if (cef::IsChromeRuntimeEnabled()) {
if (window_view->IsChromeStyle()) {
return new ChromeBrowserFrame(window_view);
}
return new CefWidgetImpl(window_view);
@@ -17,8 +19,14 @@ CefWidget* CefWidget::Create(CefWindowView* window_view) {
// static
CefWidget* CefWidget::GetForWidget(views::Widget* widget) {
if (cef::IsChromeRuntimeEnabled()) {
return static_cast<ChromeBrowserFrame*>(widget);
if (auto window = view_util::GetWindowFor(widget)) {
if (auto* window_view =
static_cast<CefWindowImpl*>(window.get())->cef_window_view()) {
if (window_view->IsChromeStyle()) {
return static_cast<ChromeBrowserFrame*>(widget);
}
return static_cast<CefWidgetImpl*>(widget);
}
}
return static_cast<CefWidgetImpl*>(widget);
return nullptr;
}

View File

@@ -25,6 +25,10 @@ class CefWidget {
// Returns the CefWidget for |widget|, which must be Views-hosted.
static CefWidget* GetForWidget(views::Widget* widget);
// Returns the Widget runtime style.
virtual bool IsAlloyStyle() const = 0;
bool IsChromeStyle() const { return !IsAlloyStyle(); }
// Returns the Widget associated with this object.
virtual views::Widget* GetWidget() = 0;
virtual const views::Widget* GetWidget() const = 0;

View File

@@ -49,6 +49,7 @@ class CefWidgetImpl : public views::Widget,
CefWidgetImpl& operator=(const CefWidgetImpl&) = delete;
// CefWidget methods:
bool IsAlloyStyle() const override { return true; }
views::Widget* GetWidget() override { return this; }
const views::Widget* GetWidget() const override { return this; }
void Initialized() override;

View File

@@ -749,6 +749,15 @@ void CefWindowImpl::ThemeChanged() {
}
}
cef_runtime_style_t CefWindowImpl::GetRuntimeStyle() {
CEF_REQUIRE_VALID_RETURN(CEF_RUNTIME_STYLE_DEFAULT);
if (auto* window_view = cef_window_view()) {
return window_view->IsAlloyStyle() ? CEF_RUNTIME_STYLE_ALLOY
: CEF_RUNTIME_STYLE_CHROME;
}
return CEF_RUNTIME_STYLE_DEFAULT;
}
CefWindowView* CefWindowImpl::cef_window_view() const {
return static_cast<CefWindowView*>(root_view());
}

View File

@@ -93,6 +93,7 @@ class CefWindowImpl
void RemoveAllAccelerators() override;
void SetThemeColor(int color_id, cef_color_t color) override;
void ThemeChanged() override;
cef_runtime_style_t GetRuntimeStyle() override;
// CefViewAdapter methods:
void Detach() override;

View File

@@ -18,6 +18,7 @@
#include "libcef/browser/image_impl.h"
#include "libcef/browser/views/widget.h"
#include "libcef/browser/views/window_impl.h"
#include "libcef/features/runtime.h"
#include "base/ranges/algorithm.h"
#include "ui/base/hit_test.h"
@@ -354,11 +355,39 @@ void UpdateModalDialogPosition(views::Widget* widget,
widget->SetBounds(gfx::Rect(position, size));
}
bool ComputeAlloyStyle(CefWindowDelegate* cef_delegate) {
const bool supports_chrome_style = cef::IsChromeRuntimeEnabled();
const auto default_style = cef::IsAlloyRuntimeEnabled()
? CEF_RUNTIME_STYLE_ALLOY
: CEF_RUNTIME_STYLE_CHROME;
auto result_style = default_style;
if (cef_delegate) {
auto requested_style = cef_delegate->GetWindowRuntimeStyle();
if (requested_style == CEF_RUNTIME_STYLE_ALLOY) {
// Alloy style is always supported.
result_style = requested_style;
} else if (requested_style == CEF_RUNTIME_STYLE_CHROME) {
if (supports_chrome_style) {
result_style = requested_style;
} else {
LOG(ERROR) << "GetWindowRuntimeStyle() requested Chrome style; only "
"Alloy style is supported";
}
}
}
return result_style == CEF_RUNTIME_STYLE_ALLOY;
}
} // namespace
CefWindowView::CefWindowView(CefWindowDelegate* cef_delegate,
Delegate* window_delegate)
: ParentClass(cef_delegate), window_delegate_(window_delegate) {
: ParentClass(cef_delegate),
window_delegate_(window_delegate),
is_alloy_style_(ComputeAlloyStyle(cef_delegate)) {
DCHECK(window_delegate_);
}

View File

@@ -139,6 +139,9 @@ class CefWindowView
// during initialization and destruction.
views::Widget* host_widget() const;
bool IsAlloyStyle() const { return is_alloy_style_; }
bool IsChromeStyle() const { return !is_alloy_style_; }
private:
// Called after Widget teardown starts, before |this| is deleted.
void DeleteDelegate();
@@ -151,6 +154,9 @@ class CefWindowView
// Not owned by this object.
Delegate* window_delegate_;
// True if the window is Alloy style, otherwise Chrome style.
const bool is_alloy_style_;
// True if the window is frameless. It might still be resizable and draggable.
bool is_frameless_ = false;