Add initial Chrome runtime support for browser APIs (see issue #2969)

This change adds basic Chrome runtime implementations for CefBrowserContext
and CefBrowserPlatformDelegate. A Chrome browser window with default frame
and styling can now be created using CefBrowserHost::CreateBrowser and some
CefClient callbacks will be triggered via the WebContentsObserver
implementation in CefBrowserHostImpl.

Any additional browser windows created via the Chrome UI will be unmanaged
by CEF. The application message loop will block until all browser windows
have been closed by the user.
This commit is contained in:
Marshall Greenblatt 2020-07-03 22:51:17 -04:00
parent 6cb9f0c695
commit e9bf3cdb98
25 changed files with 384 additions and 51 deletions

View File

@ -440,6 +440,10 @@ static_library("libcef_static") {
"libcef/browser/browser_platform_delegate_create.cc",
"libcef/browser/browser_util.cc",
"libcef/browser/browser_util.h",
"libcef/browser/chrome/browser_platform_delegate_chrome.cc",
"libcef/browser/chrome/browser_platform_delegate_chrome.h",
"libcef/browser/chrome/chrome_browser_context.cc",
"libcef/browser/chrome/chrome_browser_context.h",
"libcef/browser/chrome/chrome_browser_main_extra_parts_cef.cc",
"libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h",
"libcef/browser/chrome/chrome_content_browser_client_cef.cc",

View File

@ -28,7 +28,6 @@
#include "libcef/common/drag_data_impl.h"
#include "libcef/common/request_impl.h"
#include "libcef/common/values_impl.h"
#include "libcef/features/runtime_checks.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
@ -246,9 +245,6 @@ bool CefBrowserHost::CreateBrowser(
return false;
}
// TODO(chrome-runtime): Add support for this method.
REQUIRE_ALLOY_RUNTIME();
// Verify that the settings structure is a valid size.
if (settings.size != sizeof(cef_browser_settings_t)) {
NOTREACHED() << "invalid CefBrowserSettings structure size";
@ -291,9 +287,6 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
return nullptr;
}
// TODO(chrome-runtime): Add support for this method.
REQUIRE_ALLOY_RUNTIME();
// Verify that the settings structure is a valid size.
if (settings.size != sizeof(cef_browser_settings_t)) {
NOTREACHED() << "invalid CefBrowserSettings structure size";
@ -1515,11 +1508,16 @@ void CefBrowserHostImpl::DestroyBrowser() {
for (auto& observer : observers_)
observer.OnBrowserDestroyed(this);
// If the WebContents still exists at this point, signal destruction before
// browser destruction.
if (web_contents()) {
WebContentsDestroyed();
}
// Disassociate the platform delegate from this browser.
platform_delegate_->BrowserDestroyed(this);
registrar_.reset(nullptr);
content::WebContentsObserver::Observe(nullptr);
// Delete objects created by the platform delegate that may be referenced by
// the WebContents.
@ -2740,6 +2738,13 @@ void CefBrowserHostImpl::OnWebContentsFocused(
}
}
void CefBrowserHostImpl::WebContentsDestroyed() {
auto wc = web_contents();
content::WebContentsObserver::Observe(nullptr);
if (platform_delegate_)
platform_delegate_->WebContentsDestroyed(wc);
}
void CefBrowserHostImpl::AddObserver(Observer* observer) {
CEF_REQUIRE_UIT();
observers_.AddObserver(observer);

View File

@ -499,6 +499,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
override;
void OnWebContentsFocused(
content::RenderWidgetHost* render_widget_host) override;
void WebContentsDestroyed() override;
// Manage observer objects. The observer must either outlive this object or
// remove itself before destruction. These methods can only be called on the

View File

@ -140,6 +140,12 @@ void CefBrowserPlatformDelegate::AddNewContents(
}
}
void CefBrowserPlatformDelegate::WebContentsDestroyed(
content::WebContents* web_contents) {
DCHECK(web_contents_ && web_contents_ == web_contents);
web_contents_ = nullptr;
}
bool CefBrowserPlatformDelegate::ShouldTransferNavigation(
bool is_main_frame_navigation) {
if (extension_host_) {
@ -219,9 +225,11 @@ void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostImpl* browser) {
// WebContentsDestroyed should already be called.
DCHECK(!web_contents_);
DestroyExtensionHost();
owned_web_contents_.reset();
web_contents_ = nullptr;
DCHECK(browser_ && browser_ == browser);
browser_ = nullptr;

View File

@ -93,6 +93,10 @@ class CefBrowserPlatformDelegate {
bool user_gesture,
bool* was_blocked);
// Called when the WebContents is destroyed. This will be called before
// BrowserDestroyed(). Will only be called a single time per instance.
virtual void WebContentsDestroyed(content::WebContents* web_contents);
// See WebContentsDelegate documentation.
virtual bool ShouldTransferNavigation(bool is_main_frame_navigation);

View File

@ -11,7 +11,9 @@
#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
#include "libcef/browser/extensions/browser_platform_delegate_background.h"
#include "libcef/features/runtime_checks.h"
#if defined(OS_WIN)
#include "libcef/browser/native/browser_platform_delegate_native_win.h"
@ -80,6 +82,8 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
bool use_external_begin_frame = false;
if (is_windowless) {
REQUIRE_ALLOY_RUNTIME();
use_shared_texture = create_params.window_info &&
create_params.window_info->shared_texture_enabled;
@ -88,6 +92,10 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
create_params.window_info->external_begin_frame_enabled;
}
if (cef::IsChromeRuntimeEnabled()) {
return std::make_unique<CefBrowserPlatformDelegateChrome>(background_color);
}
if (create_params.window_info) {
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(*create_params.window_info.get(), background_color,

View File

@ -0,0 +1,144 @@
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
CefBrowserPlatformDelegateChrome::CefBrowserPlatformDelegateChrome(
SkColor background_color)
: background_color_(background_color) {}
content::WebContents* CefBrowserPlatformDelegateChrome::CreateWebContents(
CefBrowserHostImpl::CreateParams& create_params,
bool& own_web_contents) {
// Get or create the request context and profile.
CefRefPtr<CefRequestContextImpl> request_context_impl =
CefRequestContextImpl::GetOrCreateForRequestContext(
create_params.request_context);
CHECK(request_context_impl);
auto cef_browser_context = request_context_impl->GetBrowserContext();
CHECK(cef_browser_context);
auto profile = cef_browser_context->AsProfile();
if (!create_params.request_context) {
// Using the global request context.
create_params.request_context = request_context_impl.get();
}
// Create a Browser.
Browser::CreateParams params =
Browser::CreateParams(profile, /*user_gesture=*/false);
chrome_browser_ = new Browser(params);
chrome::AddTabAt(chrome_browser_, create_params.url, /*idx=*/-1,
/*foreground=*/true);
auto web_contents =
chrome_browser_->tab_strip_model()->GetActiveWebContents();
CHECK(web_contents);
own_web_contents = false;
return web_contents;
}
void CefBrowserPlatformDelegateChrome::WebContentsDestroyed(
content::WebContents* web_contents) {
CefBrowserPlatformDelegate::WebContentsDestroyed(web_contents);
// TODO(chrome-runtime): Find a better way to be notified of Browser
// destruction.
browser_->WindowDestroyed();
}
void CefBrowserPlatformDelegateChrome::BrowserDestroyed(
CefBrowserHostImpl* browser) {
CefBrowserPlatformDelegate::BrowserDestroyed(browser);
// Release the reference added in CreateHostWindow.
browser->Release();
}
bool CefBrowserPlatformDelegateChrome::CreateHostWindow() {
// Keep a reference to the CEF browser.
browser_->AddRef();
chrome_browser_->window()->Show();
return true;
}
void CefBrowserPlatformDelegateChrome::CloseHostWindow() {}
CefWindowHandle CefBrowserPlatformDelegateChrome::GetHostWindowHandle() const {
return kNullWindowHandle;
}
SkColor CefBrowserPlatformDelegateChrome::GetBackgroundColor() const {
return background_color_;
}
bool CefBrowserPlatformDelegateChrome::CanUseSharedTexture() const {
return false;
}
bool CefBrowserPlatformDelegateChrome::CanUseExternalBeginFrame() const {
return false;
}
void CefBrowserPlatformDelegateChrome::WasResized() {}
void CefBrowserPlatformDelegateChrome::SendKeyEvent(const CefKeyEvent& event) {}
void CefBrowserPlatformDelegateChrome::SendMouseClickEvent(
const CefMouseEvent& event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) {}
void CefBrowserPlatformDelegateChrome::SendMouseMoveEvent(
const CefMouseEvent& event,
bool mouseLeave) {}
void CefBrowserPlatformDelegateChrome::SendMouseWheelEvent(
const CefMouseEvent& event,
int deltaX,
int deltaY) {}
void CefBrowserPlatformDelegateChrome::SendTouchEvent(
const CefTouchEvent& event) {}
void CefBrowserPlatformDelegateChrome::SendFocusEvent(bool setFocus) {}
gfx::Point CefBrowserPlatformDelegateChrome::GetScreenPoint(
const gfx::Point& view) const {
return view;
}
void CefBrowserPlatformDelegateChrome::ViewText(const std::string& text) {}
bool CefBrowserPlatformDelegateChrome::HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
return false;
}
CefEventHandle CefBrowserPlatformDelegateChrome::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const {
return kNullEventHandle;
}
std::unique_ptr<CefMenuRunner>
CefBrowserPlatformDelegateChrome::CreateMenuRunner() {
return nullptr;
}
bool CefBrowserPlatformDelegateChrome::IsWindowless() const {
return false;
}
bool CefBrowserPlatformDelegateChrome::IsViewsHosted() const {
return false;
}

View File

@ -0,0 +1,57 @@
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_
#include "libcef/browser/browser_platform_delegate.h"
class Browser;
// Implementation of Chrome-based browser functionality.
class CefBrowserPlatformDelegateChrome : public CefBrowserPlatformDelegate {
public:
explicit CefBrowserPlatformDelegateChrome(SkColor background_color);
// CefBrowserPlatformDelegate overrides.
content::WebContents* CreateWebContents(
CefBrowserHostImpl::CreateParams& create_params,
bool& own_web_contents) override;
void WebContentsDestroyed(content::WebContents* web_contents) override;
void BrowserDestroyed(CefBrowserHostImpl* browser) override;
bool CreateHostWindow() override;
void CloseHostWindow() override;
CefWindowHandle GetHostWindowHandle() const override;
SkColor GetBackgroundColor() const override;
bool CanUseSharedTexture() const override;
bool CanUseExternalBeginFrame() const override;
void WasResized() override;
void SendKeyEvent(const CefKeyEvent& event) override;
void SendMouseClickEvent(const CefMouseEvent& event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) override;
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
void SendMouseWheelEvent(const CefMouseEvent& event,
int deltaX,
int deltaY) override;
void SendTouchEvent(const CefTouchEvent& event) override;
void SendFocusEvent(bool setFocus) override;
gfx::Point GetScreenPoint(const gfx::Point& view) const override;
void ViewText(const std::string& text) override;
bool HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override;
CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override;
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
bool IsWindowless() const override;
bool IsViewsHosted() const override;
private:
const SkColor background_color_;
Browser* chrome_browser_;
};
#endif // CEF_LIBCEF_BROWSER_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_

View File

@ -0,0 +1,36 @@
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/chrome/chrome_browser_context.h"
#include "chrome/browser/profiles/profile_manager.h"
ChromeBrowserContext::ChromeBrowserContext(
const CefRequestContextSettings& settings)
: CefBrowserContext(settings) {}
ChromeBrowserContext::~ChromeBrowserContext() = default;
content::BrowserContext* ChromeBrowserContext::AsBrowserContext() {
return profile_;
}
Profile* ChromeBrowserContext::AsProfile() {
return profile_;
}
void ChromeBrowserContext::Initialize() {
CefBrowserContext::Initialize();
// TODO(chrome-runtime): ProfileManager can create new profiles relative to
// the user-data-dir, but it should be done asynchronously.
// The global ProfileManager instance can be retrieved via
// |g_browser_process->profile_manager()|.
profile_ = ProfileManager::GetLastUsedProfileAllowedByPolicy();
}
void ChromeBrowserContext::Shutdown() {
CefBrowserContext::Shutdown();
profile_ = nullptr;
}

View File

@ -0,0 +1,31 @@
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_
#pragma once
#include "libcef/browser/browser_context.h"
// See CefBrowserContext documentation for usage. Only accessed on the UI thread
// unless otherwise indicated.
class ChromeBrowserContext : public CefBrowserContext {
public:
explicit ChromeBrowserContext(const CefRequestContextSettings& settings);
// CefBrowserContext overrides.
content::BrowserContext* AsBrowserContext() override;
Profile* AsProfile() override;
void Initialize() override;
void Shutdown() override;
private:
~ChromeBrowserContext() override;
Profile* profile_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserContext);
};
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_

View File

@ -4,12 +4,23 @@
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
#include "libcef/browser/context.h"
#include "base/task/post_task.h"
ChromeBrowserMainExtraPartsCef::ChromeBrowserMainExtraPartsCef() = default;
ChromeBrowserMainExtraPartsCef::~ChromeBrowserMainExtraPartsCef() = default;
void ChromeBrowserMainExtraPartsCef::PostProfileInit() {
CefRequestContextSettings settings;
CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
// Create the global RequestContext.
global_request_context_ =
CefRequestContextImpl::CreateGlobalRequestContext(settings);
}
void ChromeBrowserMainExtraPartsCef::PostMainMessageLoopRun() {
background_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,

View File

@ -7,6 +7,8 @@
#include <memory>
#include "libcef/browser/request_context_impl.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
@ -17,6 +19,10 @@ class ChromeBrowserMainExtraPartsCef : public ChromeBrowserMainExtraParts {
ChromeBrowserMainExtraPartsCef();
~ChromeBrowserMainExtraPartsCef() override;
CefRefPtr<CefRequestContextImpl> request_context() const {
return global_request_context_;
}
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const {
return background_task_runner_;
}
@ -30,8 +36,11 @@ class ChromeBrowserMainExtraPartsCef : public ChromeBrowserMainExtraParts {
private:
// ChromeBrowserMainExtraParts overrides.
void PostProfileInit() override;
void PostMainMessageLoopRun() override;
CefRefPtr<CefRequestContextImpl> global_request_context_;
// Blocking task runners exposed via CefTaskRunner. For consistency with
// previous named thread behavior always execute all pending tasks before
// shutdown (e.g. to make sure critical data is saved to disk).

View File

@ -37,6 +37,11 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
command_line->AppendSwitch(switches::kEnableChromeRuntime);
}
CefRefPtr<CefRequestContextImpl>
ChromeContentBrowserClientCef::request_context() const {
return browser_main_parts_->request_context();
}
scoped_refptr<base::SingleThreadTaskRunner>
ChromeContentBrowserClientCef::background_task_runner() const {
return browser_main_parts_->background_task_runner();

View File

@ -8,6 +8,8 @@
#include <memory>
#include "libcef/browser/request_context_impl.h"
#include "base/macros.h"
#include "chrome/browser/chrome_content_browser_client.h"
@ -25,6 +27,8 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override;
CefRefPtr<CefRequestContextImpl> request_context() const;
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const;
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const;
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner() const;

View File

@ -287,7 +287,8 @@ void CefMainRunner::RunMessageLoop() {
void CefMainRunner::QuitMessageLoop() {
if (!quit_when_idle_callback_.is_null()) {
main_delegate_->BeforeMainMessageLoopQuit();
if (main_delegate_->HandleMainMessageLoopQuit())
return;
std::move(quit_when_idle_callback_).Run();
}
}

View File

@ -9,7 +9,6 @@
#include "libcef/common/app_manager.h"
#include "libcef/common/task_runner_impl.h"
#include "libcef/common/values_impl.h"
#include "libcef/features/runtime_checks.h"
#include "base/atomic_sequence_num.h"
#include "base/logging.h"
@ -604,8 +603,6 @@ void CefRequestContextImpl::OnRenderFrameDeleted(int render_process_id,
CefRefPtr<CefRequestContextImpl>
CefRequestContextImpl::GetOrCreateRequestContext(const Config& config) {
// TODO(chrome-runtime): Add support for this method.
REQUIRE_ALLOY_RUNTIME();
if (config.is_global ||
(config.other && config.other->IsGlobal() && !config.handler)) {
// Return the singleton global context.

View File

@ -5,6 +5,7 @@
#include "libcef/common/chrome/chrome_main_delegate_cef.h"
#include "libcef/browser/chrome/chrome_browser_context.h"
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
ChromeMainDelegateCef::ChromeMainDelegateCef(CefMainRunnerHandler* runner,
@ -49,16 +50,17 @@ ChromeMainDelegateCef::CreateContentBrowserClient() {
}
CefRefPtr<CefRequestContext> ChromeMainDelegateCef::GetGlobalRequestContext() {
// TODO(chrome-runtime): Implement this method.
NOTIMPLEMENTED();
auto browser_client = content_browser_client();
if (browser_client)
return browser_client->request_context();
return nullptr;
}
CefBrowserContext* ChromeMainDelegateCef::CreateNewBrowserContext(
const CefRequestContextSettings& settings) {
// TODO(chrome-runtime): Implement this method.
NOTIMPLEMENTED();
return nullptr;
auto context = new ChromeBrowserContext(settings);
context->Initialize();
return context;
}
scoped_refptr<base::SingleThreadTaskRunner>

View File

@ -53,13 +53,8 @@ void ChromeMainRunnerDelegate::BeforeMainMessageLoopRun(
// The ScopedKeepAlive instance triggers shutdown logic when released on the
// UI thread before terminating the message loop (e.g. from CefQuitMessageLoop
// or FinishShutdownOnUIThread when running with multi-threaded message loop).
// TODO(chrome-runtime): Enable this once browser life-span notifications are
// in place. In the mean time, closing the last Chrome browser instance will
// exit the app.
/*
keep_alive_ = std::make_unique<ScopedKeepAlive>(
KeepAliveOrigin::APP_CONTROLLER, KeepAliveRestartOption::DISABLED);
*/
// The idle callback will be executed from BrowserProcessImpl::Unpin() via
// KeepAliveRegistry when the last ScopedKeepAlive is released.
@ -69,9 +64,14 @@ void ChromeMainRunnerDelegate::BeforeMainMessageLoopRun(
->SetQuitClosure(run_loop->QuitWhenIdleClosure());
}
void ChromeMainRunnerDelegate::BeforeMainMessageLoopQuit() {
bool ChromeMainRunnerDelegate::HandleMainMessageLoopQuit() {
// May be called multiple times. See comments in RunMainMessageLoopBefore.
keep_alive_.reset();
// Cancel direct execution of the QuitWhenIdleClosure() in
// CefMainRunner::QuitMessageLoop. We instead wait for all Chrome browser
// windows to exit.
return true;
}
void ChromeMainRunnerDelegate::AfterMainThreadShutdown() {

View File

@ -29,7 +29,7 @@ class ChromeMainRunnerDelegate : public CefMainRunnerDelegate {
content::ContentMainDelegate* GetContentMainDelegate() override;
void BeforeMainThreadInitialize(const CefMainArgs& args) override;
void BeforeMainMessageLoopRun(base::RunLoop* run_loop) override;
void BeforeMainMessageLoopQuit() override;
bool HandleMainMessageLoopQuit() override;
void AfterMainThreadShutdown() override;
void BeforeExecuteProcess(const CefMainArgs& args) override;
void AfterExecuteProcess() override;

View File

@ -23,7 +23,7 @@ class CefMainRunnerDelegate {
virtual void BeforeMainThreadInitialize(const CefMainArgs& args) {}
virtual void BeforeMainThreadRun() {}
virtual void BeforeMainMessageLoopRun(base::RunLoop* run_loop) {}
virtual void BeforeMainMessageLoopQuit() {}
virtual bool HandleMainMessageLoopQuit() { return false; }
virtual void AfterUIThreadInitialize() {}
virtual void AfterUIThreadShutdown() {}
virtual void BeforeMainThreadShutdown() {}

View File

@ -43,14 +43,14 @@ index 3e1e28ea7d0e..b70f718c8e94 100644
// Get the path of the last used profile, or if that's undefined, the default
// profile.
diff --git chrome/browser/profiles/renderer_updater.cc chrome/browser/profiles/renderer_updater.cc
index c1792eccd997..6c34846b7947 100644
index c1792eccd997..d7434ff76a88 100644
--- chrome/browser/profiles/renderer_updater.cc
+++ chrome/browser/profiles/renderer_updater.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/bind.h"
+#include "cef/libcef/features/features.h"
+#include "cef/libcef/features/runtime.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
@ -58,12 +58,14 @@ index c1792eccd997..6c34846b7947 100644
RendererUpdater::RendererUpdater(Profile* profile)
: profile_(profile), identity_manager_observer_(this) {
+#if !BUILDFLAG(ENABLE_CEF)
identity_manager_ = IdentityManagerFactory::GetForProfile(profile);
identity_manager_observer_.Add(identity_manager_);
+#else
+ identity_manager_ = nullptr;
+#endif
- identity_manager_ = IdentityManagerFactory::GetForProfile(profile);
- identity_manager_observer_.Add(identity_manager_);
+ if (cef::IsAlloyRuntimeEnabled()) {
+ identity_manager_ = nullptr;
+ } else {
+ identity_manager_ = IdentityManagerFactory::GetForProfile(profile);
+ identity_manager_observer_.Add(identity_manager_);
+ }
#if defined(OS_CHROMEOS)
oauth2_login_manager_ =
chromeos::OAuth2LoginManagerFactory::GetForProfile(profile_);

View File

@ -1,5 +1,5 @@
diff --git chrome/browser/chrome_browser_main.cc chrome/browser/chrome_browser_main.cc
index c06585b15b8f..b5ed3518c0fd 100644
index c06585b15b8f..763212a575ce 100644
--- chrome/browser/chrome_browser_main.cc
+++ chrome/browser/chrome_browser_main.cc
@@ -49,6 +49,7 @@
@ -22,17 +22,21 @@ index c06585b15b8f..b5ed3518c0fd 100644
// These members must be initialized before returning from this function.
// Android doesn't use StartupBrowserCreator.
@@ -1613,7 +1616,9 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#endif // defined(OS_MACOSX)
// Transfer ownership of the browser's lifetime to the BrowserProcess.
- browser_process_->SetQuitClosure(g_run_loop->QuitWhenIdleClosure());
+ // CEF with the Chrome runtime will create and manage its own RunLoop.
+ if (g_run_loop)
+ browser_process_->SetQuitClosure(g_run_loop->QuitWhenIdleClosure());
DCHECK(!run_message_loop_);
run_message_loop_ = true;
}
@@ -1580,11 +1583,13 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// This step is costly and is already measured in
// Startup.StartupBrowserCreator_Start.
// See the comment above for an explanation of |process_command_line|.
+ // Bypass StartupBrowserCreator with CEF where |g_run_loop| is nullptr.
const bool started =
+ !g_run_loop ||
!process_command_line ||
browser_creator_->Start(parsed_command_line(), base::FilePath(), profile_,
last_opened_profiles);
- if (started) {
+ if (started && g_run_loop) {
#if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
// Initialize autoupdate timer. Timer callback costs basically nothing
// when browser is not in persistent mode, so it's OK to let it ride on
diff --git ui/gtk/select_file_dialog_impl_kde.cc ui/gtk/select_file_dialog_impl_kde.cc
index f09501d6cd8e..edfc2a4c9bb5 100644
--- ui/gtk/select_file_dialog_impl_kde.cc

View File

@ -87,8 +87,6 @@ void SimpleApp::OnContextInitialized() {
const bool enable_chrome_runtime =
command_line->HasSwitch("enable-chrome-runtime");
if (enable_chrome_runtime)
return;
#if defined(OS_WIN) || defined(OS_LINUX)
// Create the browser using the Views framework if "--use-views" is specified
@ -114,7 +112,7 @@ void SimpleApp::OnContextInitialized() {
if (url.empty())
url = "http://www.google.com";
if (use_views) {
if (use_views && !enable_chrome_runtime) {
// Create the BrowserView.
CefRefPtr<CefBrowserView> browser_view = CefBrowserView::CreateBrowserView(
handler, url, browser_settings, nullptr, nullptr,

View File

@ -25,7 +25,8 @@ void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
// Retrieve the X11 window handle for the browser.
::Window window = browser->GetHost()->GetWindowHandle();
DCHECK(window != kNullWindowHandle);
if (window == kNullWindowHandle)
return;
// Retrieve the atoms required by the below XChangeProperty call.
const char* kAtoms[] = {"_NET_WM_NAME", "UTF8_STRING"};

View File

@ -12,5 +12,6 @@
void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle();
SetWindowText(hwnd, std::wstring(title).c_str());
if (hwnd)
SetWindowText(hwnd, std::wstring(title).c_str());
}