mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Move chrome members to BrowserProcess and add ProfileManager support (issue #1947)
This commit is contained in:
4
BUILD.gn
4
BUILD.gn
@@ -221,6 +221,8 @@ static_library("libcef_static") {
|
|||||||
"libcef/browser/browser_util.h",
|
"libcef/browser/browser_util.h",
|
||||||
"libcef/browser/chrome_browser_process_stub.cc",
|
"libcef/browser/chrome_browser_process_stub.cc",
|
||||||
"libcef/browser/chrome_browser_process_stub.h",
|
"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.cc",
|
||||||
"libcef/browser/chrome_profile_stub.h",
|
"libcef/browser/chrome_profile_stub.h",
|
||||||
"libcef/browser/component_updater/cef_component_updater_configurator.cc",
|
"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/browser_extensions_util.h",
|
||||||
"libcef/browser/extensions/component_extension_resource_manager.cc",
|
"libcef/browser/extensions/component_extension_resource_manager.cc",
|
||||||
"libcef/browser/extensions/component_extension_resource_manager.h",
|
"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.cc",
|
||||||
"libcef/browser/extensions/extensions_api_client.h",
|
"libcef/browser/extensions/extensions_api_client.h",
|
||||||
"libcef/browser/extensions/extensions_browser_client.cc",
|
"libcef/browser/extensions/extensions_browser_client.cc",
|
||||||
|
4
cef.gyp
4
cef.gyp
@@ -1040,6 +1040,8 @@
|
|||||||
'libcef/browser/browser_util.h',
|
'libcef/browser/browser_util.h',
|
||||||
'libcef/browser/chrome_browser_process_stub.cc',
|
'libcef/browser/chrome_browser_process_stub.cc',
|
||||||
'libcef/browser/chrome_browser_process_stub.h',
|
'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.cc',
|
||||||
'libcef/browser/chrome_profile_stub.h',
|
'libcef/browser/chrome_profile_stub.h',
|
||||||
'libcef/browser/component_updater/cef_component_updater_configurator.cc',
|
'libcef/browser/component_updater/cef_component_updater_configurator.cc',
|
||||||
@@ -1068,8 +1070,6 @@
|
|||||||
'libcef/browser/extensions/browser_extensions_util.h',
|
'libcef/browser/extensions/browser_extensions_util.h',
|
||||||
'libcef/browser/extensions/component_extension_resource_manager.cc',
|
'libcef/browser/extensions/component_extension_resource_manager.cc',
|
||||||
'libcef/browser/extensions/component_extension_resource_manager.h',
|
'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.cc',
|
||||||
'libcef/browser/extensions/extensions_api_client.h',
|
'libcef/browser/extensions/extensions_api_client.h',
|
||||||
'libcef/browser/extensions/extensions_browser_client.cc',
|
'libcef/browser/extensions/extensions_browser_client.cc',
|
||||||
|
@@ -4,18 +4,92 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "libcef/browser/chrome_browser_process_stub.h"
|
#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"
|
#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()
|
ChromeBrowserProcessStub::ChromeBrowserProcessStub()
|
||||||
: locale_("en-US") {
|
: initialized_(false),
|
||||||
|
shutdown_(false),
|
||||||
|
locale_("en-US") {
|
||||||
}
|
}
|
||||||
|
|
||||||
ChromeBrowserProcessStub::~ChromeBrowserProcessStub() {
|
ChromeBrowserProcessStub::~ChromeBrowserProcessStub() {
|
||||||
|
DCHECK(!initialized_ || shutdown_);
|
||||||
g_browser_process = NULL;
|
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() {
|
void ChromeBrowserProcessStub::ResourceDispatcherHostCreated() {
|
||||||
NOTIMPLEMENTED();
|
NOTIMPLEMENTED();
|
||||||
};
|
};
|
||||||
@@ -51,8 +125,7 @@ WatchDogThread* ChromeBrowserProcessStub::watchdog_thread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProfileManager* ChromeBrowserProcessStub::profile_manager() {
|
ProfileManager* ChromeBrowserProcessStub::profile_manager() {
|
||||||
NOTIMPLEMENTED();
|
return profile_manager_.get();
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrefService* ChromeBrowserProcessStub::local_state() {
|
PrefService* ChromeBrowserProcessStub::local_state() {
|
||||||
@@ -79,8 +152,7 @@ BrowserProcessPlatformPart* ChromeBrowserProcessStub::platform_part() {
|
|||||||
|
|
||||||
extensions::EventRouterForwarder*
|
extensions::EventRouterForwarder*
|
||||||
ChromeBrowserProcessStub::extension_event_router_forwarder() {
|
ChromeBrowserProcessStub::extension_event_router_forwarder() {
|
||||||
NOTIMPLEMENTED();
|
return event_router_forwarder_.get();
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationUIManager* ChromeBrowserProcessStub::notification_ui_manager() {
|
NotificationUIManager* ChromeBrowserProcessStub::notification_ui_manager() {
|
||||||
@@ -141,7 +213,7 @@ bool ChromeBrowserProcessStub::IsShuttingDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
printing::PrintJobManager* ChromeBrowserProcessStub::print_job_manager() {
|
printing::PrintJobManager* ChromeBrowserProcessStub::print_job_manager() {
|
||||||
return CefContext::Get()->print_job_manager();
|
return print_job_manager_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
printing::PrintPreviewDialogController*
|
printing::PrintPreviewDialogController*
|
||||||
@@ -226,7 +298,7 @@ net_log::ChromeNetLog* ChromeBrowserProcessStub::net_log() {
|
|||||||
|
|
||||||
component_updater::ComponentUpdateService*
|
component_updater::ComponentUpdateService*
|
||||||
ChromeBrowserProcessStub::component_updater() {
|
ChromeBrowserProcessStub::component_updater() {
|
||||||
return CefContext::Get()->component_updater();
|
return component_updater_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
CRLSetFetcher* ChromeBrowserProcessStub::crl_set_fetcher() {
|
CRLSetFetcher* ChromeBrowserProcessStub::crl_set_fetcher() {
|
||||||
|
@@ -3,16 +3,24 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// 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_
|
#ifndef CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_
|
||||||
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_
|
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "chrome/browser/browser_process.h"
|
#include "chrome/browser/browser_process.h"
|
||||||
|
#include "chrome/browser/extensions/event_router_forwarder.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
|
|
||||||
// This file provides a stub implementation of Chrome's BrowserProcess object
|
namespace component_updater {
|
||||||
// for use as an interop layer between CEF and files that live in chrome/.
|
class ComponentUpdateService;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChromeProfileManagerStub;
|
||||||
|
|
||||||
class BackgroundModeManager {
|
class BackgroundModeManager {
|
||||||
public:
|
public:
|
||||||
@@ -27,6 +35,9 @@ class ChromeBrowserProcessStub : public BrowserProcess {
|
|||||||
ChromeBrowserProcessStub();
|
ChromeBrowserProcessStub();
|
||||||
~ChromeBrowserProcessStub() override;
|
~ChromeBrowserProcessStub() override;
|
||||||
|
|
||||||
|
void Initialize();
|
||||||
|
void Shutdown();
|
||||||
|
|
||||||
// BrowserProcess implementation.
|
// BrowserProcess implementation.
|
||||||
void ResourceDispatcherHostCreated() override;
|
void ResourceDispatcherHostCreated() override;
|
||||||
void EndSession() override;
|
void EndSession() override;
|
||||||
@@ -100,7 +111,14 @@ class ChromeBrowserProcessStub : public BrowserProcess {
|
|||||||
memory::TabManager* GetTabManager() override;
|
memory::TabManager* GetTabManager() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool initialized_;
|
||||||
|
bool shutdown_;
|
||||||
|
|
||||||
std::string locale_;
|
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);
|
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProcessStub);
|
||||||
};
|
};
|
||||||
|
23
libcef/browser/chrome_profile_manager_stub.cc
Normal file
23
libcef/browser/chrome_profile_manager_stub.cc
Normal 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();
|
||||||
|
}
|
25
libcef/browser/chrome_profile_manager_stub.h
Normal file
25
libcef/browser/chrome_profile_manager_stub.h
Normal 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_
|
@@ -45,7 +45,6 @@ Profile* ChromeProfileStub::GetOriginalProfile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ChromeProfileStub::IsSupervised() const {
|
bool ChromeProfileStub::IsSupervised() const {
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,15 +3,12 @@
|
|||||||
// be found in the LICENSE file.
|
// be found in the LICENSE file.
|
||||||
|
|
||||||
#include "libcef/browser/context.h"
|
#include "libcef/browser/context.h"
|
||||||
#include "libcef/browser/browser_context.h"
|
|
||||||
#include "libcef/browser/browser_host_impl.h"
|
#include "libcef/browser/browser_host_impl.h"
|
||||||
#include "libcef/browser/browser_info.h"
|
#include "libcef/browser/browser_info.h"
|
||||||
#include "libcef/browser/browser_info_manager.h"
|
#include "libcef/browser/browser_info_manager.h"
|
||||||
#include "libcef/browser/browser_main.h"
|
#include "libcef/browser/browser_main.h"
|
||||||
#include "libcef/browser/browser_message_loop.h"
|
#include "libcef/browser/browser_message_loop.h"
|
||||||
#include "libcef/browser/chrome_browser_process_stub.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/thread_util.h"
|
||||||
#include "libcef/browser/trace_subscriber.h"
|
#include "libcef/browser/trace_subscriber.h"
|
||||||
#include "libcef/common/cef_switches.h"
|
#include "libcef/common/cef_switches.h"
|
||||||
@@ -24,12 +21,7 @@
|
|||||||
#include "base/debug/debugger.h"
|
#include "base/debug/debugger.h"
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "base/synchronization/waitable_event.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/network_session_configurator/switches.h"
|
||||||
#include "components/update_client/configurator.h"
|
|
||||||
#include "content/public/app/content_main.h"
|
#include "content/public/app/content_main.h"
|
||||||
#include "content/public/app/content_main_runner.h"
|
#include "content/public/app/content_main_runner.h"
|
||||||
#include "content/public/browser/notification_service.h"
|
#include "content/public/browser/notification_service.h"
|
||||||
@@ -362,25 +354,6 @@ CefTraceSubscriber* CefContext::GetTraceSubscriber() {
|
|||||||
return trace_subscriber_.get();
|
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(
|
void CefContext::PopulateRequestContextSettings(
|
||||||
CefRequestContextSettings* settings) {
|
CefRequestContextSettings* settings) {
|
||||||
CefRefPtr<CefCommandLine> command_line =
|
CefRefPtr<CefCommandLine> command_line =
|
||||||
@@ -399,30 +372,10 @@ void CefContext::PopulateRequestContextSettings(
|
|||||||
CefString(&settings_.accept_language_list);
|
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() {
|
void CefContext::OnContextInitialized() {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
// Must be created after the NotificationService.
|
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Initialize();
|
||||||
print_job_manager_.reset(new printing::PrintJobManager());
|
|
||||||
|
|
||||||
bool io_was_allowed = base::ThreadRestrictions::SetIOAllowed(true);
|
|
||||||
RegisterComponentsForUpdate();
|
|
||||||
base::ThreadRestrictions::SetIOAllowed(io_was_allowed);
|
|
||||||
|
|
||||||
// Notify the handler.
|
// Notify the handler.
|
||||||
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
|
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
|
||||||
@@ -438,19 +391,12 @@ void CefContext::FinishShutdownOnUIThread(
|
|||||||
base::WaitableEvent* uithread_shutdown_event) {
|
base::WaitableEvent* uithread_shutdown_event) {
|
||||||
CEF_REQUIRE_UIT();
|
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();
|
browser_info_manager_->DestroyAllBrowsers();
|
||||||
|
|
||||||
if (trace_subscriber_.get())
|
if (trace_subscriber_.get())
|
||||||
trace_subscriber_.reset(NULL);
|
trace_subscriber_.reset(NULL);
|
||||||
|
|
||||||
if (component_updater_.get())
|
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Shutdown();
|
||||||
component_updater_.reset(NULL);
|
|
||||||
|
|
||||||
if (uithread_shutdown_event)
|
if (uithread_shutdown_event)
|
||||||
uithread_shutdown_event->Signal();
|
uithread_shutdown_event->Signal();
|
||||||
|
@@ -18,18 +18,10 @@ namespace base {
|
|||||||
class WaitableEvent;
|
class WaitableEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace component_updater {
|
|
||||||
class ComponentUpdateService;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class ContentMainRunner;
|
class ContentMainRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace printing {
|
|
||||||
class PrintJobManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CefBrowserHostImpl;
|
class CefBrowserHostImpl;
|
||||||
class CefBrowserInfoManager;
|
class CefBrowserInfoManager;
|
||||||
class CefMainDelegate;
|
class CefMainDelegate;
|
||||||
@@ -63,12 +55,6 @@ class CefContext {
|
|||||||
|
|
||||||
const CefSettings& settings() const { return settings_; }
|
const CefSettings& settings() const { return settings_; }
|
||||||
|
|
||||||
printing::PrintJobManager* print_job_manager() const {
|
|
||||||
return print_job_manager_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
component_updater::ComponentUpdateService* component_updater();
|
|
||||||
|
|
||||||
CefTraceSubscriber* GetTraceSubscriber();
|
CefTraceSubscriber* GetTraceSubscriber();
|
||||||
|
|
||||||
// Populate the request context settings based on CefSettings and command-
|
// 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<content::ContentMainRunner> main_runner_;
|
||||||
std::unique_ptr<CefTraceSubscriber> trace_subscriber_;
|
std::unique_ptr<CefTraceSubscriber> trace_subscriber_;
|
||||||
std::unique_ptr<CefBrowserInfoManager> browser_info_manager_;
|
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.
|
// Helper macro that returns true if the global context is in a valid state.
|
||||||
|
@@ -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
|
|
@@ -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_
|
|
@@ -15,6 +15,8 @@
|
|||||||
#include "libcef/browser/extensions/url_request_util.h"
|
#include "libcef/browser/extensions/url_request_util.h"
|
||||||
|
|
||||||
#include "cef/libcef/browser/extensions/api/generated_api_registration.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_context.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
@@ -36,8 +38,7 @@ namespace extensions {
|
|||||||
|
|
||||||
CefExtensionsBrowserClient::CefExtensionsBrowserClient()
|
CefExtensionsBrowserClient::CefExtensionsBrowserClient()
|
||||||
: api_client_(new CefExtensionsAPIClient),
|
: api_client_(new CefExtensionsAPIClient),
|
||||||
resource_manager_(new CefComponentExtensionResourceManager),
|
resource_manager_(new CefComponentExtensionResourceManager) {
|
||||||
event_router_forwarder_(new CefEventRouterForwarder) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CefExtensionsBrowserClient::~CefExtensionsBrowserClient() {
|
CefExtensionsBrowserClient::~CefExtensionsBrowserClient() {
|
||||||
@@ -207,8 +208,9 @@ void CefExtensionsBrowserClient::BroadcastEventToRenderers(
|
|||||||
events::HistogramValue histogram_value,
|
events::HistogramValue histogram_value,
|
||||||
const std::string& event_name,
|
const std::string& event_name,
|
||||||
std::unique_ptr<base::ListValue> args) {
|
std::unique_ptr<base::ListValue> args) {
|
||||||
event_router_forwarder_->BroadcastEventToRenderers(
|
g_browser_process->extension_event_router_forwarder()->
|
||||||
histogram_value, event_name, std::move(args), GURL());
|
BroadcastEventToRenderers(histogram_value, event_name, std::move(args),
|
||||||
|
GURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
net::NetLog* CefExtensionsBrowserClient::GetNetLog() {
|
net::NetLog* CefExtensionsBrowserClient::GetNetLog() {
|
||||||
|
@@ -6,8 +6,6 @@
|
|||||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSIONS_BROWSER_CLIENT_H_
|
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSIONS_BROWSER_CLIENT_H_
|
||||||
#define 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 "base/compiler_specific.h"
|
||||||
#include "extensions/browser/extensions_browser_client.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.
|
// Resource manager used to supply resources from pak files.
|
||||||
std::unique_ptr<ComponentExtensionResourceManager> resource_manager_;
|
std::unique_ptr<ComponentExtensionResourceManager> resource_manager_;
|
||||||
|
|
||||||
scoped_refptr<CefEventRouterForwarder> event_router_forwarder_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefExtensionsBrowserClient);
|
DISALLOW_COPY_AND_ASSIGN(CefExtensionsBrowserClient);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -281,4 +281,9 @@ patches = [
|
|||||||
'name': 'chrome_crashpad_mac',
|
'name': 'chrome_crashpad_mac',
|
||||||
'path': '../',
|
'path': '../',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
# Make some methods of ProfileManager virtual.
|
||||||
|
'name': 'chrome_profile',
|
||||||
|
'path': '../',
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
13
patch/patches/chrome_profile.patch
Normal file
13
patch/patches/chrome_profile.patch
Normal 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.
|
Reference in New Issue
Block a user