chrome: Add Views API integration (see issue #2969)

The Chrome browser can now be hosted in a Views-based application on Windows
and Linux.

To launch a fully-featured Chrome window using cefsimple:
$ cefsimple --enable-chrome-runtime

To launch a minimally-styled Views-hosted window using cefsimple:
$ cefsimple --enable-chrome-runtime --use-views

To launch a fully-styled Views-hosted window using cefclient:
$ cefclient --enable-chrome-runtime --use-views

Views unit tests also now pass with the Chrome runtime enabled:
$ ceftests --gtest_filter=Views* --enable-chrome-runtime

Known issues:
- Popup browsers cannot be intercepted and reparented.
This commit is contained in:
Marshall Greenblatt
2021-02-17 20:58:25 -05:00
parent 8f5fdc1f9a
commit 8733cb89c7
31 changed files with 839 additions and 107 deletions

View File

@@ -378,7 +378,7 @@ void AlloyBrowserHostImpl::SetFocusInternal(bool focus) {
}
CefWindowHandle AlloyBrowserHostImpl::GetWindowHandle() {
if (IsViewsHosted() && CEF_CURRENTLY_ON_UIT()) {
if (is_views_hosted_ && CEF_CURRENTLY_ON_UIT()) {
// Always return the most up-to-date window handle for a views-hosted
// browser since it may change if the view is re-parented.
if (platform_delegate_)
@@ -391,10 +391,6 @@ CefWindowHandle AlloyBrowserHostImpl::GetOpenerWindowHandle() {
return opener_;
}
bool AlloyBrowserHostImpl::HasView() {
return IsViewsHosted();
}
double AlloyBrowserHostImpl::GetZoomLevel() {
// Verify that this method is being called on the UI thread.
if (!CEF_CURRENTLY_ON_UIT()) {
@@ -803,10 +799,6 @@ bool AlloyBrowserHostImpl::IsWindowless() const {
return is_windowless_;
}
bool AlloyBrowserHostImpl::IsViewsHosted() const {
return is_views_hosted_;
}
bool AlloyBrowserHostImpl::IsPictureInPictureSupported() const {
// Not currently supported with OSR.
return !IsWindowless();
@@ -870,22 +862,6 @@ void AlloyBrowserHostImpl::DestroyBrowser() {
CefBrowserHostBase::DestroyBrowser();
}
#if defined(USE_AURA)
views::Widget* AlloyBrowserHostImpl::GetWindowWidget() const {
CEF_REQUIRE_UIT();
if (!platform_delegate_)
return nullptr;
return platform_delegate_->GetWindowWidget();
}
CefRefPtr<CefBrowserView> AlloyBrowserHostImpl::GetBrowserView() const {
CEF_REQUIRE_UIT();
if (IsViewsHosted() && platform_delegate_)
return platform_delegate_->GetBrowserView();
return nullptr;
}
#endif
void AlloyBrowserHostImpl::CancelContextMenu() {
CEF_REQUIRE_UIT();
if (menu_manager_)
@@ -1684,11 +1660,10 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
content::WebContentsObserver(web_contents),
opener_(kNullWindowHandle),
is_windowless_(platform_delegate_->IsWindowless()),
is_views_hosted_(platform_delegate_->IsViewsHosted()),
extension_(extension) {
contents_delegate_->ObserveWebContents(web_contents);
if (opener.get() && !platform_delegate_->IsViewsHosted()) {
if (opener.get() && !is_views_hosted_) {
// GetOpenerWindowHandle() only returns a value for non-views-hosted
// popup browsers.
opener_ = opener->GetWindowHandle();
@@ -1707,7 +1682,7 @@ bool AlloyBrowserHostImpl::CreateHostWindow() {
bool success = true;
if (!IsWindowless())
success = platform_delegate_->CreateHostWindow();
if (success && !IsViewsHosted())
if (success && !is_views_hosted_)
host_window_handle_ = platform_delegate_->GetHostWindowHandle();
return success;
}