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

@@ -93,6 +93,16 @@ MainContextImpl::MainContextImpl(CefRefPtr<CefCommandLine> command_line,
#endif
}
// Enable experimental Chrome runtime. See issue #2969 for details.
use_chrome_runtime_ =
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;
}
#if defined(OS_WIN) || defined(OS_LINUX)
// Whether the Views framework will be used.
use_views_ = command_line_->HasSwitch(switches::kUseViews);
@@ -103,6 +113,14 @@ MainContextImpl::MainContextImpl(CefRefPtr<CefCommandLine> command_line,
use_views_ = false;
}
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;
}
if (use_views_ && command_line->HasSwitch(switches::kHideFrame) &&
!command_line_->HasSwitch(switches::kUrl)) {
// Use the draggable regions test as the default URL for frameless windows.
@@ -178,6 +196,9 @@ void MainContextImpl::PopulateSettings(CefSettings* settings) {
command_line_->HasSwitch(switches::kExternalMessagePump);
}
if (use_chrome_runtime_)
settings->chrome_runtime = true;
CefString(&settings->cache_path) =
command_line_->GetSwitchValue(switches::kCachePath);