Move chrome members to BrowserProcess and add ProfileManager support (issue #1947)

This commit is contained in:
Marshall Greenblatt 2016-07-18 17:22:22 -04:00
parent 3cc539b506
commit f4425a9a0c
15 changed files with 178 additions and 350 deletions

View File

@ -221,6 +221,8 @@ static_library("libcef_static") {
"libcef/browser/browser_util.h",
"libcef/browser/chrome_browser_process_stub.cc",
"libcef/browser/chrome_browser_process_stub.h",
"libcef/browser/chrome_profile_manager_stub.cc",
"libcef/browser/chrome_profile_manager_stub.h",
"libcef/browser/chrome_profile_stub.cc",
"libcef/browser/chrome_profile_stub.h",
"libcef/browser/component_updater/cef_component_updater_configurator.cc",
@ -249,8 +251,6 @@ static_library("libcef_static") {
"libcef/browser/extensions/browser_extensions_util.h",
"libcef/browser/extensions/component_extension_resource_manager.cc",
"libcef/browser/extensions/component_extension_resource_manager.h",
"libcef/browser/extensions/event_router_forwarder.cc",
"libcef/browser/extensions/event_router_forwarder.h",
"libcef/browser/extensions/extensions_api_client.cc",
"libcef/browser/extensions/extensions_api_client.h",
"libcef/browser/extensions/extensions_browser_client.cc",

View File

@ -1040,6 +1040,8 @@
'libcef/browser/browser_util.h',
'libcef/browser/chrome_browser_process_stub.cc',
'libcef/browser/chrome_browser_process_stub.h',
'libcef/browser/chrome_profile_manager_stub.cc',
'libcef/browser/chrome_profile_manager_stub.h',
'libcef/browser/chrome_profile_stub.cc',
'libcef/browser/chrome_profile_stub.h',
'libcef/browser/component_updater/cef_component_updater_configurator.cc',
@ -1068,8 +1070,6 @@
'libcef/browser/extensions/browser_extensions_util.h',
'libcef/browser/extensions/component_extension_resource_manager.cc',
'libcef/browser/extensions/component_extension_resource_manager.h',
'libcef/browser/extensions/event_router_forwarder.cc',
'libcef/browser/extensions/event_router_forwarder.h',
'libcef/browser/extensions/extensions_api_client.cc',
'libcef/browser/extensions/extensions_api_client.h',
'libcef/browser/extensions/extensions_browser_client.cc',

View File

@ -4,18 +4,92 @@
// found in the LICENSE file.
#include "libcef/browser/chrome_browser_process_stub.h"
#include "libcef/browser/context.h"
#include "libcef/browser/chrome_profile_manager_stub.h"
#include "libcef/browser/component_updater/cef_component_updater_configurator.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "base/command_line.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "components/component_updater/component_updater_service.h"
#include "components/update_client/configurator.h"
#include "ui/message_center/message_center.h"
namespace {
void RegisterComponentsForUpdate(
component_updater::ComponentUpdateService* cus) {
base::ThreadRestrictions::ScopedAllowIO scoped_allow_io;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableWidevineCdm)) {
RegisterWidevineCdmComponent(cus);
}
}
} // namespace
ChromeBrowserProcessStub::ChromeBrowserProcessStub()
: locale_("en-US") {
: initialized_(false),
shutdown_(false),
locale_("en-US") {
}
ChromeBrowserProcessStub::~ChromeBrowserProcessStub() {
DCHECK(!initialized_ || shutdown_);
g_browser_process = NULL;
}
void ChromeBrowserProcessStub::Initialize() {
CEF_REQUIRE_UIT();
DCHECK(!initialized_);
DCHECK(!shutdown_);
// Must be created after the NotificationService.
print_job_manager_.reset(new printing::PrintJobManager());
profile_manager_.reset(new ChromeProfileManagerStub());
event_router_forwarder_ = new extensions::EventRouterForwarder();
// Creating the component updater does not do anything initially. Components
// need to be registered and Start() needs to be called.
scoped_refptr<CefBrowserContextImpl> browser_context =
CefContentBrowserClient::Get()->browser_context();
scoped_refptr<update_client::Configurator> configurator =
component_updater::MakeCefComponentUpdaterConfigurator(
base::CommandLine::ForCurrentProcess(),
browser_context->request_context().get(),
browser_context->GetPrefs());
component_updater_.reset(component_updater::ComponentUpdateServiceFactory(
configurator).release());
RegisterComponentsForUpdate(component_updater_.get());
initialized_ = true;
}
void ChromeBrowserProcessStub::Shutdown() {
CEF_REQUIRE_UIT();
DCHECK(initialized_);
DCHECK(!shutdown_);
// Wait for the pending print jobs to finish. Don't do this later, since
// this might cause a nested message loop to run, and we don't want pending
// tasks to run once teardown has started.
print_job_manager_->Shutdown();
print_job_manager_.reset(NULL);
profile_manager_.reset();
event_router_forwarder_ = nullptr;
if (component_updater_.get())
component_updater_.reset(NULL);
shutdown_ = true;
}
void ChromeBrowserProcessStub::ResourceDispatcherHostCreated() {
NOTIMPLEMENTED();
};
@ -51,8 +125,7 @@ WatchDogThread* ChromeBrowserProcessStub::watchdog_thread() {
}
ProfileManager* ChromeBrowserProcessStub::profile_manager() {
NOTIMPLEMENTED();
return NULL;
return profile_manager_.get();
}
PrefService* ChromeBrowserProcessStub::local_state() {
@ -79,8 +152,7 @@ BrowserProcessPlatformPart* ChromeBrowserProcessStub::platform_part() {
extensions::EventRouterForwarder*
ChromeBrowserProcessStub::extension_event_router_forwarder() {
NOTIMPLEMENTED();
return NULL;
return event_router_forwarder_.get();
}
NotificationUIManager* ChromeBrowserProcessStub::notification_ui_manager() {
@ -141,7 +213,7 @@ bool ChromeBrowserProcessStub::IsShuttingDown() {
}
printing::PrintJobManager* ChromeBrowserProcessStub::print_job_manager() {
return CefContext::Get()->print_job_manager();
return print_job_manager_.get();
}
printing::PrintPreviewDialogController*
@ -226,7 +298,7 @@ net_log::ChromeNetLog* ChromeBrowserProcessStub::net_log() {
component_updater::ComponentUpdateService*
ChromeBrowserProcessStub::component_updater() {
return CefContext::Get()->component_updater();
return component_updater_.get();
}
CRLSetFetcher* ChromeBrowserProcessStub::crl_set_fetcher() {

View File

@ -3,16 +3,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file provides a stub implementation of Chrome's BrowserProcess object
// for use as an interop layer between CEF and files that live in chrome/.
#ifndef CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_
#include <memory>
#include <string>
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "base/compiler_specific.h"
// This file provides a stub implementation of Chrome's BrowserProcess object
// for use as an interop layer between CEF and files that live in chrome/.
namespace component_updater {
class ComponentUpdateService;
}
class ChromeProfileManagerStub;
class BackgroundModeManager {
public:
@ -27,6 +35,9 @@ class ChromeBrowserProcessStub : public BrowserProcess {
ChromeBrowserProcessStub();
~ChromeBrowserProcessStub() override;
void Initialize();
void Shutdown();
// BrowserProcess implementation.
void ResourceDispatcherHostCreated() override;
void EndSession() override;
@ -100,7 +111,14 @@ class ChromeBrowserProcessStub : public BrowserProcess {
memory::TabManager* GetTabManager() override;
private:
bool initialized_;
bool shutdown_;
std::string locale_;
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
std::unique_ptr<ChromeProfileManagerStub> profile_manager_;
scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
std::unique_ptr<component_updater::ComponentUpdateService> component_updater_;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProcessStub);
};

View File

@ -0,0 +1,23 @@
// Copyright (c) 2016 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium 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_profile_manager_stub.h"
#include "libcef/browser/browser_context_impl.h"
ChromeProfileManagerStub::ChromeProfileManagerStub()
: ProfileManager(base::FilePath()) {
}
ChromeProfileManagerStub::~ChromeProfileManagerStub() {
}
bool ChromeProfileManagerStub::IsValidProfile(const void* profile) {
if (!profile)
return false;
return !!CefBrowserContextImpl::GetForContext(
reinterpret_cast<content::BrowserContext*>(
const_cast<void*>(profile))).get();
}

View File

@ -0,0 +1,25 @@
// Copyright (c) 2016 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file provides a stub implementation of Chrome's ProfileManager object
// for use as an interop layer between CEF and files that live in chrome/.
#ifndef CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_
#define CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_
#include "chrome/browser/profiles/profile_manager.h"
class ChromeProfileManagerStub : public ProfileManager {
public:
ChromeProfileManagerStub();
~ChromeProfileManagerStub() override;
bool IsValidProfile(const void* profile) override;
private:
DISALLOW_COPY_AND_ASSIGN(ChromeProfileManagerStub);
};
#endif // CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_

View File

@ -45,7 +45,6 @@ Profile* ChromeProfileStub::GetOriginalProfile() {
}
bool ChromeProfileStub::IsSupervised() const {
NOTIMPLEMENTED();
return false;
}

View File

@ -3,15 +3,12 @@
// be found in the LICENSE file.
#include "libcef/browser/context.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_main.h"
#include "libcef/browser/browser_message_loop.h"
#include "libcef/browser/chrome_browser_process_stub.h"
#include "libcef/browser/component_updater/cef_component_updater_configurator.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/trace_subscriber.h"
#include "libcef/common/cef_switches.h"
@ -24,12 +21,7 @@
#include "base/debug/debugger.h"
#include "base/files/file_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "components/component_updater/component_updater_service.h"
#include "components/network_session_configurator/switches.h"
#include "components/update_client/configurator.h"
#include "content/public/app/content_main.h"
#include "content/public/app/content_main_runner.h"
#include "content/public/browser/notification_service.h"
@ -362,25 +354,6 @@ CefTraceSubscriber* CefContext::GetTraceSubscriber() {
return trace_subscriber_.get();
}
component_updater::ComponentUpdateService*
CefContext::component_updater() {
if (!component_updater_.get()) {
CEF_REQUIRE_UIT_RETURN(NULL);
scoped_refptr<CefBrowserContextImpl> browser_context =
CefContentBrowserClient::Get()->browser_context();
scoped_refptr<update_client::Configurator> configurator =
component_updater::MakeCefComponentUpdaterConfigurator(
base::CommandLine::ForCurrentProcess(),
browser_context->request_context().get(),
browser_context->GetPrefs());
// Creating the component updater does not do anything, components
// need to be registered and Start() needs to be called.
component_updater_.reset(component_updater::ComponentUpdateServiceFactory(
configurator).release());
}
return component_updater_.get();
}
void CefContext::PopulateRequestContextSettings(
CefRequestContextSettings* settings) {
CefRefPtr<CefCommandLine> command_line =
@ -399,30 +372,10 @@ void CefContext::PopulateRequestContextSettings(
CefString(&settings_.accept_language_list);
}
void RegisterComponentsForUpdate() {
component_updater::ComponentUpdateService* cus =
CefContext::Get()->component_updater();
// Registration can be before or after cus->Start() so it is ok to post
// a task to the UI thread to do registration once you done the necessary
// file IO to know you existing component version.
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableWidevineCdm)) {
RegisterWidevineCdmComponent(cus);
}
#endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
}
void CefContext::OnContextInitialized() {
CEF_REQUIRE_UIT();
// Must be created after the NotificationService.
print_job_manager_.reset(new printing::PrintJobManager());
bool io_was_allowed = base::ThreadRestrictions::SetIOAllowed(true);
RegisterComponentsForUpdate();
base::ThreadRestrictions::SetIOAllowed(io_was_allowed);
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Initialize();
// Notify the handler.
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
@ -438,19 +391,12 @@ void CefContext::FinishShutdownOnUIThread(
base::WaitableEvent* uithread_shutdown_event) {
CEF_REQUIRE_UIT();
// Wait for the pending print jobs to finish. Don't do this later, since
// this might cause a nested message loop to run, and we don't want pending
// tasks to run once teardown has started.
print_job_manager_->Shutdown();
print_job_manager_.reset(NULL);
browser_info_manager_->DestroyAllBrowsers();
if (trace_subscriber_.get())
trace_subscriber_.reset(NULL);
if (component_updater_.get())
component_updater_.reset(NULL);
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Shutdown();
if (uithread_shutdown_event)
uithread_shutdown_event->Signal();

View File

@ -18,18 +18,10 @@ namespace base {
class WaitableEvent;
}
namespace component_updater {
class ComponentUpdateService;
}
namespace content {
class ContentMainRunner;
}
namespace printing {
class PrintJobManager;
}
class CefBrowserHostImpl;
class CefBrowserInfoManager;
class CefMainDelegate;
@ -63,12 +55,6 @@ class CefContext {
const CefSettings& settings() const { return settings_; }
printing::PrintJobManager* print_job_manager() const {
return print_job_manager_.get();
}
component_updater::ComponentUpdateService* component_updater();
CefTraceSubscriber* GetTraceSubscriber();
// Populate the request context settings based on CefSettings and command-
@ -98,12 +84,6 @@ class CefContext {
std::unique_ptr<content::ContentMainRunner> main_runner_;
std::unique_ptr<CefTraceSubscriber> trace_subscriber_;
std::unique_ptr<CefBrowserInfoManager> browser_info_manager_;
// Only accessed on the UI Thread.
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
// Initially only for Widevine components.
std::unique_ptr<component_updater::ComponentUpdateService> component_updater_;
};
// Helper macro that returns true if the global context is in a valid state.

View File

@ -1,136 +0,0 @@
// Copyright (c) 2012 The Chromium 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/extensions/event_router_forwarder.h"
#include <stddef.h>
#include <utility>
#include "libcef/browser/browser_context_impl.h"
#include "base/bind.h"
#include "base/values.h"
#include "build/build_config.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/event_router.h"
#include "url/gurl.h"
using content::BrowserThread;
namespace extensions {
CefEventRouterForwarder::CefEventRouterForwarder() {
}
CefEventRouterForwarder::~CefEventRouterForwarder() {
}
void CefEventRouterForwarder::BroadcastEventToRenderers(
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
const GURL& event_url) {
HandleEvent(std::string(), histogram_value, event_name, std::move(event_args),
0, true, event_url);
}
void CefEventRouterForwarder::DispatchEventToRenderers(
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url) {
if (!profile)
return;
HandleEvent(std::string(), histogram_value, event_name, std::move(event_args),
profile, use_profile_to_restrict_events, event_url);
}
void CefEventRouterForwarder::BroadcastEventToExtension(
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
const GURL& event_url) {
HandleEvent(extension_id, histogram_value, event_name, std::move(event_args),
0, true, event_url);
}
void CefEventRouterForwarder::DispatchEventToExtension(
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url) {
if (!profile)
return;
HandleEvent(extension_id, histogram_value, event_name, std::move(event_args),
profile, use_profile_to_restrict_events, event_url);
}
void CefEventRouterForwarder::HandleEvent(
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
void* profile_ptr,
bool use_profile_to_restrict_events,
const GURL& event_url) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&CefEventRouterForwarder::HandleEvent, this, extension_id,
histogram_value, event_name, base::Passed(&event_args),
profile_ptr, use_profile_to_restrict_events, event_url));
return;
}
content::BrowserContext* profile = NULL;
if (profile_ptr) {
profile = reinterpret_cast<content::BrowserContext*>(profile_ptr);
if (CefBrowserContextImpl::GetForContext(profile) == NULL)
return;
}
if (profile) {
CallEventRouter(profile, extension_id, histogram_value, event_name,
std::move(event_args),
use_profile_to_restrict_events ? profile : NULL, event_url);
} else {
std::vector<CefBrowserContextImpl*> profiles(
CefBrowserContextImpl::GetAll());
for (size_t i = 0; i < profiles.size(); ++i) {
std::unique_ptr<base::ListValue> per_profile_event_args(
event_args->DeepCopy());
CallEventRouter(profiles[i], extension_id, histogram_value, event_name,
std::move(per_profile_event_args),
use_profile_to_restrict_events ? profiles[i] : NULL,
event_url);
}
}
}
void CefEventRouterForwarder::CallEventRouter(
content::BrowserContext* profile,
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
content::BrowserContext* restrict_to_profile,
const GURL& event_url) {
std::unique_ptr<Event> event(
new Event(histogram_value, event_name, std::move(event_args)));
event->restrict_to_browser_context = restrict_to_profile;
event->event_url = event_url;
if (extension_id.empty()) {
extensions::EventRouter::Get(profile)->BroadcastEvent(std::move(event));
} else {
extensions::EventRouter::Get(profile)
->DispatchEventToExtension(extension_id, std::move(event));
}
}
} // namespace extensions

View File

@ -1,115 +0,0 @@
// Copyright (c) 2012 The Chromium 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_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/values.h"
#include "extensions/browser/extension_event_histogram_value.h"
class GURL;
namespace content {
class BrowserContext;
}
namespace extensions {
// This class forwards events to EventRouters.
// The advantages of this class over direct usage of EventRouters are:
// - this class is thread-safe, you can call the functions from UI and IO
// thread.
// - the class can handle if a profile is deleted between the time of sending
// the event from the IO thread to the UI thread.
// - this class can be used in contexts that are not governed by a profile, e.g.
// by system URLRequestContexts. In these cases the |restrict_to_profile|
// parameter remains NULL and events are broadcasted to all profiles.
// TODO(cef/chrome): Unfork this class once CEF supports ProfileManager.
class CefEventRouterForwarder
: public base::RefCountedThreadSafe<CefEventRouterForwarder> {
public:
CefEventRouterForwarder();
// Calls
// DispatchEventToRenderers(event_name, event_args, profile, event_url)
// on all (original) profiles' EventRouters.
// May be called on any thread.
void BroadcastEventToRenderers(events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
const GURL& event_url);
// Calls
// DispatchEventToExtension(extension_id, event_name, event_args,
// profile, event_url)
// on all (original) profiles' EventRouters.
// May be called on any thread.
void BroadcastEventToExtension(const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
const GURL& event_url);
// Calls
// DispatchEventToRenderers(event_name, event_args,
// use_profile_to_restrict_events ? profile : NULL, event_url)
// on |profile|'s EventRouter. May be called on any thread.
void DispatchEventToRenderers(events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url);
// Calls
// DispatchEventToExtension(extension_id, event_name, event_args,
// use_profile_to_restrict_events ? profile : NULL, event_url)
// on |profile|'s EventRouter. May be called on any thread.
void DispatchEventToExtension(const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url);
protected:
// Protected for testing.
virtual ~CefEventRouterForwarder();
// Helper function for {Broadcast,Dispatch}EventTo{Extension,Renderers}.
// Virtual for testing.
virtual void HandleEvent(const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url);
// Calls DispatchEventToRenderers or DispatchEventToExtension (depending on
// whether extension_id == "" or not) of |profile|'s EventRouter.
// |profile| may never be NULL.
// Virtual for testing.
virtual void CallEventRouter(content::BrowserContext* profile,
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> event_args,
content::BrowserContext* restrict_to_profile,
const GURL& event_url);
private:
friend class base::RefCountedThreadSafe<CefEventRouterForwarder>;
DISALLOW_COPY_AND_ASSIGN(CefEventRouterForwarder);
};
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_

View File

@ -15,6 +15,8 @@
#include "libcef/browser/extensions/url_request_util.h"
#include "cef/libcef/browser/extensions/api/generated_api_registration.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
@ -36,8 +38,7 @@ namespace extensions {
CefExtensionsBrowserClient::CefExtensionsBrowserClient()
: api_client_(new CefExtensionsAPIClient),
resource_manager_(new CefComponentExtensionResourceManager),
event_router_forwarder_(new CefEventRouterForwarder) {
resource_manager_(new CefComponentExtensionResourceManager) {
}
CefExtensionsBrowserClient::~CefExtensionsBrowserClient() {
@ -207,8 +208,9 @@ void CefExtensionsBrowserClient::BroadcastEventToRenderers(
events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::ListValue> args) {
event_router_forwarder_->BroadcastEventToRenderers(
histogram_value, event_name, std::move(args), GURL());
g_browser_process->extension_event_router_forwarder()->
BroadcastEventToRenderers(histogram_value, event_name, std::move(args),
GURL());
}
net::NetLog* CefExtensionsBrowserClient::GetNetLog() {

View File

@ -6,8 +6,6 @@
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSIONS_BROWSER_CLIENT_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSIONS_BROWSER_CLIENT_H_
#include "libcef/browser/extensions/event_router_forwarder.h"
#include "base/compiler_specific.h"
#include "extensions/browser/extensions_browser_client.h"
@ -93,8 +91,6 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
// Resource manager used to supply resources from pak files.
std::unique_ptr<ComponentExtensionResourceManager> resource_manager_;
scoped_refptr<CefEventRouterForwarder> event_router_forwarder_;
DISALLOW_COPY_AND_ASSIGN(CefExtensionsBrowserClient);
};

View File

@ -281,4 +281,9 @@ patches = [
'name': 'chrome_crashpad_mac',
'path': '../',
},
{
# Make some methods of ProfileManager virtual.
'name': 'chrome_profile',
'path': '../',
},
]

View File

@ -0,0 +1,13 @@
diff --git chrome/browser/profiles/profile_manager.h chrome/browser/profiles/profile_manager.h
index e3e742c..aabe932 100644
--- chrome/browser/profiles/profile_manager.h
+++ chrome/browser/profiles/profile_manager.h
@@ -117,7 +117,7 @@ class ProfileManager : public base::NonThreadSafe,
// Returns true if the profile pointer is known to point to an existing
// profile.
- bool IsValidProfile(const void* profile);
+ virtual bool IsValidProfile(const void* profile);
// Returns the directory where the first created profile is stored,
// relative to the user data directory currently in use.