Add CefAppManager and remove global ContentClient accessors (see issue #2969)

This is the first pass in removing direct dependencies on the Alloy
runtime from code that can potentially be shared between runtimes.

CefBrowserHost and CefRequestContext APIs (including CefCookieManager,
CefURLRequest, etc.) are not yet implemented for the Chrome runtime.
Assert early if these API methods are called while the Chrome runtime
is enabled.
This commit is contained in:
Marshall Greenblatt 2020-06-28 17:05:36 -04:00
parent 84f3ff2afd
commit b3a8da9b25
45 changed files with 522 additions and 312 deletions

View File

@ -648,6 +648,8 @@ static_library("libcef_static") {
"libcef/common/alloy/alloy_main_delegate.h",
"libcef/common/alloy/alloy_main_runner_delegate.cc",
"libcef/common/alloy/alloy_main_runner_delegate.h",
"libcef/common/app_manager.cc",
"libcef/common/app_manager.h",
"libcef/common/base_impl.cc",
"libcef/common/cef_message_generator.cc",
"libcef/common/cef_message_generator.h",
@ -655,6 +657,8 @@ static_library("libcef_static") {
"libcef/common/cef_messages.h",
"libcef/common/cef_switches.cc",
"libcef/common/cef_switches.h",
"libcef/common/chrome/chrome_content_client_cef.cc",
"libcef/common/chrome/chrome_content_client_cef.h",
"libcef/common/chrome/chrome_main_delegate_cef.cc",
"libcef/common/chrome/chrome_main_delegate_cef.h",
"libcef/common/chrome/chrome_main_runner_delegate.cc",
@ -734,6 +738,7 @@ static_library("libcef_static") {
"libcef/common/widevine_loader.cc",
"libcef/common/widevine_loader.h",
"libcef/features/runtime.h",
"libcef/features/runtime_checks.h",
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
"libcef/renderer/alloy/alloy_content_renderer_client.h",
"libcef/renderer/browser_impl.cc",

View File

@ -8,7 +8,6 @@
#include <string>
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_context_keyed_service_factories.h"
#include "libcef/browser/context.h"
@ -19,6 +18,7 @@
#include "libcef/browser/printing/constrained_window_views_client.h"
#include "libcef/browser/printing/printing_message_filter.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/extensions/extensions_client.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net/net_resource_provider.h"
@ -101,7 +101,7 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
#if defined(OS_WIN)
ui::CursorLoaderWin::SetCursorResourceModule(
AlloyContentBrowserClient::Get()->GetResourceDllName());
CefAppManager::Get()->GetResourceDllName());
#endif
#endif // defined(USE_AURA)

View File

@ -32,6 +32,7 @@
#include "libcef/browser/thread_util.h"
#include "libcef/browser/x509_certificate_impl.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/command_line_impl.h"
@ -541,14 +542,6 @@ AlloyContentBrowserClient::AlloyContentBrowserClient() {
AlloyContentBrowserClient::~AlloyContentBrowserClient() {}
// static
AlloyContentBrowserClient* AlloyContentBrowserClient::Get() {
if (!AlloyContentClient::Get())
return nullptr;
return static_cast<AlloyContentBrowserClient*>(
AlloyContentClient::Get()->browser());
}
std::unique_ptr<content::BrowserMainParts>
AlloyContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
@ -672,7 +665,7 @@ bool AlloyContentBrowserClient::IsHandledURL(const GURL& url) {
if (scheme::IsInternalHandledScheme(scheme))
return true;
return AlloyContentClient::Get()->HasCustomScheme(scheme);
return CefAppManager::Get()->HasCustomScheme(scheme);
}
void AlloyContentBrowserClient::SiteInstanceGotProcess(
@ -867,7 +860,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
}
#endif // defined(OS_LINUX)
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> handler =
app->GetBrowserProcessHandler();
@ -1148,22 +1141,6 @@ void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
#endif // defined(OS_LINUX)
#if defined(OS_WIN)
const wchar_t* AlloyContentBrowserClient::GetResourceDllName() {
static wchar_t file_path[MAX_PATH + 1] = {0};
if (file_path[0] == 0) {
// Retrieve the module path (usually libcef.dll).
base::FilePath module;
base::PathService::Get(base::FILE_MODULE, &module);
const std::wstring wstr = module.value();
size_t count = std::min(static_cast<size_t>(MAX_PATH), wstr.size());
wcsncpy(file_path, wstr.c_str(), count);
file_path[count] = 0;
}
return file_path;
}
bool AlloyContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) {
return true;

View File

@ -35,9 +35,6 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
AlloyContentBrowserClient();
~AlloyContentBrowserClient() override;
// Returns the singleton AlloyContentBrowserClient instance.
static AlloyContentBrowserClient* Get();
// ContentBrowserClient implementation.
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
const content::MainFunctionParams& parameters) override;
@ -131,7 +128,6 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
#endif
#if defined(OS_WIN)
const wchar_t* GetResourceDllName();
bool PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) override;
#endif

View File

@ -5,8 +5,9 @@
#include "libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/common/app_manager.h"
namespace {
@ -21,8 +22,9 @@ namespace {
// Return the main context for now since we don't currently have a good way to
// determine that.
CefBrowserContext* GetActiveBrowserContext() {
return static_cast<CefBrowserContext*>(
AlloyContentBrowserClient::Get()->request_context()->GetBrowserContext());
auto request_context = static_cast<CefRequestContextImpl*>(
CefAppManager::Get()->GetGlobalRequestContext().get());
return static_cast<CefBrowserContext*>(request_context->GetBrowserContext());
}
} // namespace

View File

@ -37,6 +37,7 @@
#include "libcef/common/extensions/extensions_util.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"
@ -257,6 +258,9 @@ 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";
@ -299,6 +303,9 @@ 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";

View File

@ -7,7 +7,7 @@
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/origin_whitelist_impl.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/values_impl.h"
@ -43,7 +43,7 @@ void CefBrowserMessageFilter::OnGetNewRenderThreadInfo(
CefProcessHostMsg_GetNewRenderThreadInfo_Params* params) {
GetCrossOriginWhitelistEntries(&params->cross_origin_whitelist_entries);
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> handler =
app->GetBrowserProcessHandler();

View File

@ -3,7 +3,7 @@
// be found in the LICENSE file.
#include "libcef/browser/browser_message_loop.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_pump.h"
@ -91,7 +91,7 @@ class MessagePumpExternal : public base::MessagePumpForUI {
};
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app)
return app->GetBrowserProcessHandler();
return nullptr;

View File

@ -9,11 +9,11 @@
#include <iomanip>
#include <utility>
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/net/devtools_scheme_handler.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/task_runner_manager.h"
#include "base/base64.h"
#include "base/command_line.h"
@ -606,7 +606,7 @@ void CefDevToolsFrontend::LogProtocolMessage(ProtocolMessageType type,
std::string to_log = message.substr(0, kMaxLogLineLength).as_string();
// Execute in an ordered context that allows blocking.
auto task_runner = AlloyContentBrowserClient::Get()->background_task_runner();
auto task_runner = CefTaskRunnerManager::Get()->GetBackgroundTaskRunner();
task_runner->PostTask(
FROM_HERE, base::BindOnce(::LogProtocolMessage, protocol_log_file_, type,
std::move(to_log)));

View File

@ -59,7 +59,7 @@ std::unique_ptr<CefMainRunnerDelegate> MakeDelegate(
application);
} else {
g_runtime_type = RuntimeType::CHROME;
return std::make_unique<ChromeMainRunnerDelegate>(runner);
return std::make_unique<ChromeMainRunnerDelegate>(runner, application);
}
}

View File

@ -10,7 +10,7 @@
#include "libcef/browser/context_menu_params_impl.h"
#include "libcef/browser/menu_runner.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
@ -24,7 +24,7 @@ namespace {
CefString GetLabel(int message_id) {
base::string16 label =
AlloyContentClient::Get()->GetLocalizedString(message_id);
CefAppManager::Get()->GetContentClient()->GetLocalizedString(message_id);
DCHECK(!label.empty());
return label;
}

View File

@ -12,12 +12,11 @@
#include "include/cef_version.h"
#include "include/cef_web_plugin.h"
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/extensions/chrome_api_registration.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/net/internal_scheme_handler.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
@ -31,12 +30,14 @@
#include "base/values.h"
#include "cef/grit/cef_resources.h"
#include "chrome/browser/browser_about_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/url_constants.h"
#include "content/browser/frame_host/debug_urls.h"
#include "content/browser/webui/content_web_ui_controller_factory.h"
#include "content/public/browser/browser_url_handler.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/common/url_constants.h"
@ -341,8 +342,9 @@ bool OnExtensionsSupportUI(std::string* mime_type, std::string* output) {
}
bool OnLicenseUI(std::string* mime_type, std::string* output) {
base::StringPiece piece = AlloyContentClient::Get()->GetDataResource(
IDR_CEF_LICENSE_TXT, ui::SCALE_FACTOR_NONE);
base::StringPiece piece =
CefAppManager::Get()->GetContentClient()->GetDataResource(
IDR_CEF_LICENSE_TXT, ui::SCALE_FACTOR_NONE);
if (piece.empty()) {
NOTREACHED() << "Failed to load license txt resource.";
return false;
@ -358,8 +360,9 @@ bool OnLicenseUI(std::string* mime_type, std::string* output) {
bool OnVersionUI(Profile* profile,
std::string* mime_type,
std::string* output) {
base::StringPiece piece = AlloyContentClient::Get()->GetDataResource(
IDR_CEF_VERSION_HTML, ui::SCALE_FACTOR_NONE);
base::StringPiece piece =
CefAppManager::Get()->GetContentClient()->GetDataResource(
IDR_CEF_VERSION_HTML, ui::SCALE_FACTOR_NONE);
if (piece.empty()) {
NOTREACHED() << "Failed to load version html resource.";
return false;
@ -376,7 +379,9 @@ bool OnVersionUI(Profile* profile,
parser.Add("WEBKIT", content::GetWebKitVersion());
parser.Add("JAVASCRIPT", v8::V8::GetVersion());
parser.Add("FLASH", std::string()); // Value populated asynchronously.
parser.Add("USERAGENT", AlloyContentClient::Get()->browser()->GetUserAgent());
parser.Add(
"USERAGENT",
CefAppManager::Get()->GetContentClient()->browser()->GetUserAgent());
parser.Add("COMMANDLINE", GetCommandLine());
parser.Add("MODULEPATH", GetModulePath());
parser.Add("CACHEPATH", CefString(profile->GetPath().value()));

View File

@ -8,7 +8,7 @@
#include <string>
#include <utility>
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@ -159,7 +159,8 @@ class InternalHandlerFactory : public CefSchemeHandlerFactory {
if (!action.bytes && action.resource_id >= 0) {
action.bytes =
AlloyContentClient::Get()->GetDataResourceBytes(action.resource_id);
CefAppManager::Get()->GetContentClient()->GetDataResourceBytes(
action.resource_id);
if (!action.bytes) {
NOTREACHED() << "Failed to load internal resource for id: "
<< action.resource_id << " URL: " << url.spec().c_str();

View File

@ -4,7 +4,6 @@
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
@ -14,7 +13,7 @@
#include "libcef/browser/net_service/response_filter_wrapper.h"
#include "libcef/browser/resource_context.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/net/scheme_registration.h"
#include "libcef/common/net_service/net_service_util.h"
#include "libcef/common/request_impl.h"
@ -290,7 +289,8 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
accept_language_ = ComputeAcceptLanguageFromPref(
GetAcceptLanguageList(browser_context, browser));
DCHECK(!accept_language_.empty());
user_agent_ = AlloyContentClient::Get()->browser()->GetUserAgent();
user_agent_ =
CefAppManager::Get()->GetContentClient()->browser()->GetUserAgent();
DCHECK(!user_agent_.empty());
}

View File

@ -5,12 +5,13 @@
#include "libcef/browser/net_service/url_loader_factory_getter.h"
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/app_manager.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/browser/devtools/devtools_instrumentation.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_client.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
@ -58,8 +59,10 @@ scoped_refptr<URLLoaderFactoryGetter> URLLoaderFactoryGetter::Create(
&maybe_proxy_factory_request, nullptr /* factory_override */);
}
auto browser_client = CefAppManager::Get()->GetContentClient()->browser();
// Allow the Content embedder to inject itself if it wants to.
should_proxy |= AlloyContentBrowserClient::Get()->WillCreateURLLoaderFactory(
should_proxy |= browser_client->WillCreateURLLoaderFactory(
browser_context, render_frame_host, render_process_id,
content::ContentBrowserClient::URLLoaderFactoryType::kDocumentSubResource,
url::Origin(), base::nullopt /* navigation_id */,

View File

@ -7,8 +7,8 @@
#include <windows.h>
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/common/app_manager.h"
#include "ui/resources/grit/ui_unscaled_resources.h"
@ -165,8 +165,8 @@ ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor(
HMODULE module_handle = NULL;
const wchar_t* cursor_id = ToCursorID(type);
if (!IsSystemCursorID(cursor_id)) {
module_handle = ::GetModuleHandle(
AlloyContentBrowserClient::Get()->GetResourceDllName());
module_handle =
::GetModuleHandle(CefAppManager::Get()->GetResourceDllName());
if (!module_handle)
module_handle = ::GetModuleHandle(NULL);
}

View File

@ -11,7 +11,7 @@
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/print_settings_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "base/bind.h"
#include "base/files/file_util.h"
@ -105,7 +105,7 @@ gfx::Size CefPrintDialogLinux::GetPdfPaperSize(
gfx::Size size;
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> browser_handler =
app->GetBrowserProcessHandler();
@ -136,7 +136,7 @@ void CefPrintDialogLinux::OnPrintStart(int render_process_id,
return;
}
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (!app.get())
return;
@ -251,7 +251,7 @@ void CefPrintDialogLinux::SetHandler() {
if (handler_.get())
return;
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> browser_handler =
app->GetBrowserProcessHandler();

View File

@ -3,14 +3,15 @@
// can be found in the LICENSE file.
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/context.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/extensions/extensions_util.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"
@ -622,10 +623,14 @@ void CefRequestContextImpl::OnRenderFrameDeleted(int render_process_id,
// static
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.
return AlloyContentBrowserClient::Get()->request_context();
return static_cast<CefRequestContextImpl*>(
CefAppManager::Get()->GetGlobalRequestContext().get());
}
// The new context will be initialized later by EnsureBrowserContext().

View File

@ -9,6 +9,7 @@
#include "libcef/browser/context.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/views/window_impl.h"
#include "libcef/features/runtime_checks.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "ui/content_accelerators/accelerator_util.h"
@ -44,6 +45,9 @@ CefRefPtr<CefBrowserViewImpl> CefBrowserViewImpl::Create(
CefRefPtr<CefDictionaryValue> extra_info,
CefRefPtr<CefRequestContext> request_context,
CefRefPtr<CefBrowserViewDelegate> delegate) {
// TODO(chrome-runtime): Add support for this method.
REQUIRE_ALLOY_RUNTIME();
CEF_REQUIRE_UIT_RETURN(nullptr);
CefRefPtr<CefBrowserViewImpl> browser_view = new CefBrowserViewImpl(delegate);
browser_view->SetPendingBrowserCreateParams(client, url, settings, extra_info,

View File

@ -10,10 +10,9 @@
#include "include/cef_stream.h"
#include "include/cef_version.h"
#include "libcef/browser/extensions/pdf_extension_util.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net/scheme_registration.h"
#include "libcef/common/scheme_registrar_impl.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
@ -29,7 +28,6 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pepper_flash.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/pepper_plugin_info.h"
@ -44,8 +42,6 @@
namespace {
AlloyContentClient* g_content_client = nullptr;
// The following plugin-related methods are from
// chrome/common/chrome_content_client.cc
@ -184,24 +180,8 @@ bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) {
const char AlloyContentClient::kPDFPluginPath[] = "internal-pdf-viewer";
AlloyContentClient::AlloyContentClient(CefRefPtr<CefApp> application)
: application_(application),
pack_loading_disabled_(false),
allow_pack_file_load_(false),
scheme_info_list_locked_(false),
resource_bundle_delegate_(this) {
DCHECK(!g_content_client);
g_content_client = this;
}
AlloyContentClient::~AlloyContentClient() {
g_content_client = nullptr;
}
// static
AlloyContentClient* AlloyContentClient::Get() {
return g_content_client;
}
AlloyContentClient::AlloyContentClient() = default;
AlloyContentClient::~AlloyContentClient() = default;
void AlloyContentClient::AddPepperPlugins(
std::vector<content::PepperPluginInfo>* plugins) {
@ -224,17 +204,7 @@ void AlloyContentClient::AddContentDecryptionModules(
}
void AlloyContentClient::AddAdditionalSchemes(Schemes* schemes) {
DCHECK(!scheme_info_list_locked_);
if (application_.get()) {
CefSchemeRegistrarImpl schemeRegistrar;
application_->OnRegisterCustomSchemes(&schemeRegistrar);
schemeRegistrar.GetSchemes(schemes);
}
scheme::AddInternalSchemes(schemes);
scheme_info_list_locked_ = true;
CefAppManager::Get()->AddAdditionalSchemes(schemes);
}
base::string16 AlloyContentClient::GetLocalizedString(int message_id) {
@ -288,42 +258,6 @@ gfx::Image& AlloyContentClient::GetNativeImageNamed(int resource_id) {
return value;
}
void AlloyContentClient::AddCustomScheme(const SchemeInfo& scheme_info) {
DCHECK(!scheme_info_list_locked_);
scheme_info_list_.push_back(scheme_info);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kProcessType)) {
// Register as a Web-safe scheme in the browser process so that requests for
// the scheme from a render process will be allowed in
// resource_dispatcher_host_impl.cc ShouldServiceRequest.
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
if (!policy->IsWebSafeScheme(scheme_info.scheme_name))
policy->RegisterWebSafeScheme(scheme_info.scheme_name);
}
}
const AlloyContentClient::SchemeInfoList*
AlloyContentClient::GetCustomSchemes() {
DCHECK(scheme_info_list_locked_);
return &scheme_info_list_;
}
bool AlloyContentClient::HasCustomScheme(const std::string& scheme_name) {
DCHECK(scheme_info_list_locked_);
if (scheme_info_list_.empty())
return false;
SchemeInfoList::const_iterator it = scheme_info_list_.begin();
for (; it != scheme_info_list_.end(); ++it) {
if (it->scheme_name == scheme_name)
return true;
}
return false;
}
// static
void AlloyContentClient::SetPDFEntryFunctions(
content::PepperPluginInfo::GetInterfaceFunc get_interface,

View File

@ -7,29 +7,18 @@
#define CEF_LIBCEF_COMMON_ALLOY_ALLOY_CONTENT_CLIENT_H_
#pragma once
#include <list>
#include <string>
#include <vector>
#include "include/cef_app.h"
#include "libcef/common/resource_bundle_delegate.h"
#include "base/compiler_specific.h"
#include "content/public/common/content_client.h"
#include "content/public/common/pepper_plugin_info.h"
#include "url/url_util.h"
class AlloyContentClient : public content::ContentClient {
public:
static const char kPDFPluginPath[];
explicit AlloyContentClient(CefRefPtr<CefApp> application);
AlloyContentClient();
~AlloyContentClient() override;
// Returns the singleton AlloyContentClient instance.
static AlloyContentClient* Get();
// content::ContentClient methods.
// content::ContentClient overrides.
void AddPepperPlugins(
std::vector<content::PepperPluginInfo>* plugins) override;
void AddContentDecryptionModules(
@ -44,83 +33,10 @@ class AlloyContentClient : public content::ContentClient {
base::RefCountedMemory* GetDataResourceBytes(int resource_id) override;
gfx::Image& GetNativeImageNamed(int resource_id) override;
// Values are registered with all processes (url/url_util.h) and with Blink
// (SchemeRegistry) unless otherwise indicated.
struct SchemeInfo {
// Lower-case ASCII scheme name.
std::string scheme_name;
// A scheme that is subject to URL canonicalization and parsing rules as
// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1
// available at http://www.ietf.org/rfc/rfc1738.txt.
// This value is not registered with Blink.
bool is_standard;
// A scheme that will be treated the same as "file". For example, normal
// pages cannot link to or access URLs of this scheme.
bool is_local;
// A scheme that can only be displayed from other content hosted with the
// same scheme. For example, pages in other origins cannot create iframes or
// hyperlinks to URLs with the scheme. For schemes that must be accessible
// from other schemes set this value to false, set |is_cors_enabled| to
// true, and use CORS "Access-Control-Allow-Origin" headers to further
// restrict access.
// This value is registered with Blink only.
bool is_display_isolated;
// A scheme that will be treated the same as "https". For example, loading
// this scheme from other secure schemes will not trigger mixed content
// warnings.
bool is_secure;
// A scheme that can be sent CORS requests. This value should be true in
// most cases where |is_standard| is true.
bool is_cors_enabled;
// A scheme that can bypass Content-Security-Policy (CSP) checks. This value
// should be false in most cases where |is_standard| is true.
bool is_csp_bypassing;
// A scheme that can perform fetch request.
bool is_fetch_enabled;
};
typedef std::list<SchemeInfo> SchemeInfoList;
// Custom scheme information will be registered first with all processes
// (url/url_util.h) via AlloyContentClient::AddAdditionalSchemes which calls
// AddCustomScheme, and second with Blink (SchemeRegistry) via
// AlloyContentRendererClient::WebKitInitialized which calls GetCustomSchemes.
void AddCustomScheme(const SchemeInfo& scheme_info);
const SchemeInfoList* GetCustomSchemes();
bool HasCustomScheme(const std::string& scheme_name);
CefRefPtr<CefApp> application() const { return application_; }
void set_pack_loading_disabled(bool val) { pack_loading_disabled_ = val; }
bool pack_loading_disabled() const { return pack_loading_disabled_; }
void set_allow_pack_file_load(bool val) { allow_pack_file_load_ = val; }
bool allow_pack_file_load() { return allow_pack_file_load_; }
static void SetPDFEntryFunctions(
content::PepperPluginInfo::GetInterfaceFunc get_interface,
content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module,
content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module);
CefResourceBundleDelegate* GetCefResourceBundleDelegate() {
return &resource_bundle_delegate_;
}
private:
CefRefPtr<CefApp> application_;
bool pack_loading_disabled_;
bool allow_pack_file_load_;
// Custom schemes handled by the client.
SchemeInfoList scheme_info_list_;
bool scheme_info_list_locked_;
CefResourceBundleDelegate resource_bundle_delegate_;
};
#endif // CEF_LIBCEF_COMMON_ALLOY_ALLOY_CONTENT_CLIENT_H_

View File

@ -321,7 +321,7 @@ void OverrideAssetPath() {
AlloyMainDelegate::AlloyMainDelegate(CefMainRunnerHandler* runner,
CefSettings* settings,
CefRefPtr<CefApp> application)
: runner_(runner), settings_(settings), content_client_(application) {
: runner_(runner), settings_(settings), application_(application) {
// Necessary so that exported functions from base_impl.cc will be included
// in the binary.
extern void base_impl_stub();
@ -551,12 +551,12 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
}
}
if (content_client_.application().get()) {
if (application_) {
// Give the application a chance to view/modify the command line.
CefRefPtr<CefCommandLineImpl> commandLinePtr(
new CefCommandLineImpl(command_line, false, false));
content_client_.application()->OnBeforeCommandLineProcessing(
CefString(process_type), commandLinePtr.get());
application_->OnBeforeCommandLineProcessing(CefString(process_type),
commandLinePtr.get());
commandLinePtr->Detach(nullptr);
}
@ -661,7 +661,7 @@ void AlloyMainDelegate::PreSandboxStartup() {
}
if (command_line->HasSwitch(switches::kDisablePackLoading))
content_client_.set_pack_loading_disabled(true);
resource_bundle_delegate_.set_pack_loading_disabled(true);
// Initialize crash reporting state for this process/module.
// chrome::DIR_CRASH_DUMPS must be configured before calling this function.
@ -717,6 +717,12 @@ content::ContentUtilityClient* AlloyMainDelegate::CreateContentUtilityClient() {
return utility_client_.get();
}
CefRefPtr<CefRequestContext> AlloyMainDelegate::GetGlobalRequestContext() {
if (!browser_client_)
return nullptr;
return browser_client_->request_context();
}
scoped_refptr<base::SingleThreadTaskRunner>
AlloyMainDelegate::GetBackgroundTaskRunner() {
if (browser_client_)
@ -769,7 +775,7 @@ void AlloyMainDelegate::InitializeResourceBundle() {
if (!resources_dir.empty())
base::PathService::Override(chrome::DIR_RESOURCES, resources_dir);
if (!content_client_.pack_loading_disabled()) {
if (!resource_bundle_delegate_.pack_loading_disabled()) {
if (!resources_dir.empty()) {
CHECK(resources_dir.IsAbsolute());
cef_pak_file = resources_dir.Append(FILE_PATH_LITERAL("cef.pak"));
@ -795,18 +801,18 @@ void AlloyMainDelegate::InitializeResourceBundle() {
const std::string loaded_locale =
ui::ResourceBundle::InitSharedInstanceWithLocale(
locale, content_client_.GetCefResourceBundleDelegate(),
locale, &resource_bundle_delegate_,
ui::ResourceBundle::LOAD_COMMON_RESOURCES);
if (!loaded_locale.empty() && g_browser_process)
g_browser_process->SetApplicationLocale(loaded_locale);
ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
if (!content_client_.pack_loading_disabled()) {
if (!resource_bundle_delegate_.pack_loading_disabled()) {
if (loaded_locale.empty())
LOG(ERROR) << "Could not load locale pak for " << locale;
content_client_.set_allow_pack_file_load(true);
resource_bundle_delegate_.set_allow_pack_file_load(true);
if (base::PathExists(cef_pak_file)) {
resource_bundle.AddDataPackFromPath(cef_pak_file, ui::SCALE_FACTOR_NONE);
@ -856,6 +862,6 @@ void AlloyMainDelegate::InitializeResourceBundle() {
ui::SCALE_FACTOR_NONE);
}
content_client_.set_allow_pack_file_load(false);
resource_bundle_delegate_.set_allow_pack_file_load(false);
}
}

View File

@ -10,7 +10,9 @@
#include "include/cef_app.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/main_runner_handler.h"
#include "libcef/common/resource_bundle_delegate.h"
#include "libcef/common/task_runner_manager.h"
#include "base/compiler_specific.h"
@ -26,6 +28,7 @@ class ChromeContentUtilityClient;
// Manages state specific to the CEF runtime.
class AlloyMainDelegate : public content::ContentMainDelegate,
public CefAppManager,
public CefTaskRunnerManager {
public:
// |runner| and |settings| will be non-nullptr for the main process only,
@ -51,10 +54,14 @@ class AlloyMainDelegate : public content::ContentMainDelegate,
content::ContentRendererClient* CreateContentRendererClient() override;
content::ContentUtilityClient* CreateContentUtilityClient() override;
AlloyContentBrowserClient* browser_client() { return browser_client_.get(); }
AlloyContentClient* content_client() { return &content_client_; }
protected:
// CefAppManager overrides.
CefRefPtr<CefApp> GetApplication() override { return application_; }
content::ContentClient* GetContentClient() override {
return &content_client_;
}
CefRefPtr<CefRequestContext> GetGlobalRequestContext() override;
// CefTaskRunnerManager overrides.
scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner()
override;
@ -70,12 +77,15 @@ class AlloyMainDelegate : public content::ContentMainDelegate,
CefMainRunnerHandler* const runner_;
CefSettings* const settings_;
CefRefPtr<CefApp> application_;
std::unique_ptr<AlloyContentBrowserClient> browser_client_;
std::unique_ptr<AlloyContentRendererClient> renderer_client_;
std::unique_ptr<ChromeContentUtilityClient> utility_client_;
AlloyContentClient content_client_;
CefResourceBundleDelegate resource_bundle_delegate_;
DISALLOW_COPY_AND_ASSIGN(AlloyMainDelegate);
};

View File

@ -0,0 +1,118 @@
// 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/common/app_manager.h"
#include "libcef/common/net/scheme_info.h"
#include "libcef/common/net/scheme_registration.h"
#include "libcef/common/scheme_registrar_impl.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/common/content_switches.h"
#include "third_party/blink/public/platform/platform.h"
#if defined(OS_WIN)
#include <windows.h>
#include "base/path_service.h"
#endif
namespace {
CefAppManager* g_manager = nullptr;
} // namespace
// static
CefAppManager* CefAppManager::Get() {
return g_manager;
}
CefAppManager::CefAppManager() {
// Only a single instance should exist.
DCHECK(!g_manager);
g_manager = this;
}
CefAppManager::~CefAppManager() {
g_manager = nullptr;
}
void CefAppManager::AddCustomScheme(CefSchemeInfo* scheme_info) {
DCHECK(!scheme_info_list_locked_);
scheme_info_list_.push_back(*scheme_info);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kProcessType)) {
// Register as a Web-safe scheme in the browser process so that requests for
// the scheme from a render process will be allowed in
// resource_dispatcher_host_impl.cc ShouldServiceRequest.
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
if (!policy->IsWebSafeScheme(scheme_info->scheme_name))
policy->RegisterWebSafeScheme(scheme_info->scheme_name);
}
}
bool CefAppManager::HasCustomScheme(const std::string& scheme_name) {
DCHECK(scheme_info_list_locked_);
if (scheme_info_list_.empty())
return false;
SchemeInfoList::const_iterator it = scheme_info_list_.begin();
for (; it != scheme_info_list_.end(); ++it) {
if (it->scheme_name == scheme_name)
return true;
}
return false;
}
const CefAppManager::SchemeInfoList* CefAppManager::GetCustomSchemes() {
DCHECK(scheme_info_list_locked_);
return &scheme_info_list_;
}
void CefAppManager::AddAdditionalSchemes(
content::ContentClient::Schemes* schemes) {
DCHECK(!scheme_info_list_locked_);
auto application = GetApplication();
if (application) {
CefSchemeRegistrarImpl schemeRegistrar;
application->OnRegisterCustomSchemes(&schemeRegistrar);
schemeRegistrar.GetSchemes(schemes);
}
scheme::AddInternalSchemes(schemes);
scheme_info_list_locked_ = true;
}
#if defined(OS_WIN)
const wchar_t* CefAppManager::GetResourceDllName() {
static wchar_t file_path[MAX_PATH + 1] = {0};
if (file_path[0] == 0) {
// Retrieve the module path (usually libcef.dll).
base::FilePath module;
base::PathService::Get(base::FILE_MODULE, &module);
const std::wstring wstr = module.value();
size_t count = std::min(static_cast<size_t>(MAX_PATH), wstr.size());
wcsncpy(file_path, wstr.c_str(), count);
file_path[count] = 0;
}
return file_path;
}
#endif // defined(OS_WIN)
blink::WebURLLoaderFactory* CefAppManager::GetDefaultURLLoaderFactory() {
if (!default_url_loader_factory_) {
default_url_loader_factory_ =
blink::Platform::Current()->CreateDefaultURLLoaderFactory();
}
return default_url_loader_factory_.get();
}

View File

@ -0,0 +1,77 @@
// 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_COMMON_APP_MANAGER_H_
#define CEF_LIBCEF_COMMON_APP_MANAGER_H_
#pragma once
#include <list>
#include "include/cef_app.h"
#include "include/cef_request_context.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "content/public/common/content_client.h"
namespace blink {
class WebURLLoaderFactory;
}
struct CefSchemeInfo;
// Exposes global application state in the main and render processes.
class CefAppManager {
public:
// Returns the singleton instance that is scoped to CEF lifespan.
static CefAppManager* Get();
// The following methods are available in both processes.
virtual CefRefPtr<CefApp> GetApplication() = 0;
virtual content::ContentClient* GetContentClient() = 0;
// Custom scheme information will be registered first with all processes
// (url/url_util.h) via ContentClient::AddAdditionalSchemes which calls
// AddCustomScheme, and second with Blink (SchemeRegistry) via
// ContentRendererClient::WebKitInitialized which calls GetCustomSchemes.
void AddCustomScheme(CefSchemeInfo* scheme_info);
bool HasCustomScheme(const std::string& scheme_name);
using SchemeInfoList = std::list<CefSchemeInfo>;
const SchemeInfoList* GetCustomSchemes();
// Called from ContentClient::AddAdditionalSchemes.
void AddAdditionalSchemes(content::ContentClient::Schemes* schemes);
// The following methods are only available in the main (browser) process.
virtual CefRefPtr<CefRequestContext> GetGlobalRequestContext() = 0;
#if defined(OS_WIN)
// Returns the module name (usually libcef.dll).
const wchar_t* GetResourceDllName();
#endif
// The following methods are only available in the render process.
// Returns a factory that only supports unintercepted http(s) and blob
// requests. Used by CefRenderURLRequest.
blink::WebURLLoaderFactory* GetDefaultURLLoaderFactory();
protected:
CefAppManager();
virtual ~CefAppManager();
private:
// Custom schemes handled by the client.
SchemeInfoList scheme_info_list_;
bool scheme_info_list_locked_ = false;
std::unique_ptr<blink::WebURLLoaderFactory> default_url_loader_factory_;
DISALLOW_COPY_AND_ASSIGN(CefAppManager);
};
#endif // CEF_LIBCEF_COMMON_APP_MANAGER_H_

View File

@ -0,0 +1,16 @@
// Copyright 2015 The Chromium Embedded Framework Authors.
// Portions copyright 2014 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/common/chrome/chrome_content_client_cef.h"
#include "libcef/common/app_manager.h"
ChromeContentClientCef::ChromeContentClientCef() = default;
ChromeContentClientCef::~ChromeContentClientCef() = default;
void ChromeContentClientCef::AddAdditionalSchemes(Schemes* schemes) {
ChromeContentClient::AddAdditionalSchemes(schemes);
CefAppManager::Get()->AddAdditionalSchemes(schemes);
}

View File

@ -0,0 +1,20 @@
// Copyright 2015 The Chromium Embedded Framework Authors.
// Portions copyright 2014 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_COMMON_CHROME_CHROME_CONTENT_CLIENT_CEF_H_
#define CEF_LIBCEF_COMMON_CHROME_CHROME_CONTENT_CLIENT_CEF_H_
#include "chrome/common/chrome_content_client.h"
class ChromeContentClientCef : public ChromeContentClient {
public:
ChromeContentClientCef();
~ChromeContentClientCef() override;
// content::ContentClient overrides.
void AddAdditionalSchemes(Schemes* schemes) override;
};
#endif // CEF_LIBCEF_COMMON_CHROME_CHROME_CONTENT_CLIENT_CEF_H_

View File

@ -7,8 +7,11 @@
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
ChromeMainDelegateCef::ChromeMainDelegateCef(CefMainRunnerHandler* runner)
: ChromeMainDelegate(base::TimeTicks::Now()), runner_(runner) {}
ChromeMainDelegateCef::ChromeMainDelegateCef(CefMainRunnerHandler* runner,
CefRefPtr<CefApp> application)
: ChromeMainDelegate(base::TimeTicks::Now()),
runner_(runner),
application_(application) {}
ChromeMainDelegateCef::~ChromeMainDelegateCef() = default;
void ChromeMainDelegateCef::PreCreateMainMessageLoop() {
@ -27,6 +30,10 @@ int ChromeMainDelegateCef::RunProcess(
return ChromeMainDelegate::RunProcess(process_type, main_function_params);
}
content::ContentClient* ChromeMainDelegateCef::CreateContentClient() {
return &chrome_content_client_cef_;
}
content::ContentBrowserClient*
ChromeMainDelegateCef::CreateContentBrowserClient() {
// Match the logic in the parent ChromeMainDelegate implementation, but create
@ -41,6 +48,12 @@ ChromeMainDelegateCef::CreateContentBrowserClient() {
return chrome_content_browser_client_.get();
}
CefRefPtr<CefRequestContext> ChromeMainDelegateCef::GetGlobalRequestContext() {
// TODO(chrome-runtime): Implement this method.
NOTIMPLEMENTED();
return nullptr;
}
scoped_refptr<base::SingleThreadTaskRunner>
ChromeMainDelegateCef::GetBackgroundTaskRunner() {
auto browser_client = content_browser_client();

View File

@ -8,7 +8,9 @@
#include <memory>
#include "include/cef_base.h"
#include "include/cef_app.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/chrome/chrome_content_client_cef.h"
#include "libcef/common/main_runner_handler.h"
#include "libcef/common/task_runner_manager.h"
@ -19,11 +21,13 @@ class ChromeContentBrowserClientCef;
// CEF override of ChromeMainDelegate
class ChromeMainDelegateCef : public ChromeMainDelegate,
public CefAppManager,
public CefTaskRunnerManager {
public:
// |runner| will be non-nullptr for the main process only, and will outlive
// this object.
explicit ChromeMainDelegateCef(CefMainRunnerHandler* runner);
ChromeMainDelegateCef(CefMainRunnerHandler* runner,
CefRefPtr<CefApp> application);
~ChromeMainDelegateCef() override;
// ChromeMainDelegate overrides.
@ -31,9 +35,17 @@ class ChromeMainDelegateCef : public ChromeMainDelegate,
int RunProcess(
const std::string& process_type,
const content::MainFunctionParams& main_function_params) override;
content::ContentClient* CreateContentClient() override;
content::ContentBrowserClient* CreateContentBrowserClient() override;
protected:
// CefAppManager overrides.
CefRefPtr<CefApp> GetApplication() override { return application_; }
content::ContentClient* GetContentClient() override {
return &chrome_content_client_cef_;
}
CefRefPtr<CefRequestContext> GetGlobalRequestContext() override;
// CefTaskRunnerManager overrides.
scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner()
override;
@ -48,6 +60,10 @@ class ChromeMainDelegateCef : public ChromeMainDelegate,
ChromeContentBrowserClientCef* content_browser_client() const;
CefMainRunnerHandler* const runner_;
CefRefPtr<CefApp> application_;
// We use this instead of ChromeMainDelegate::chrome_content_client_.
ChromeContentClientCef chrome_content_client_cef_;
DISALLOW_COPY_AND_ASSIGN(ChromeMainDelegateCef);
};

View File

@ -18,14 +18,17 @@
#include "chrome/app/chrome_main_mac.h"
#endif
ChromeMainRunnerDelegate::ChromeMainRunnerDelegate(CefMainRunnerHandler* runner)
: runner_(runner) {}
ChromeMainRunnerDelegate::ChromeMainRunnerDelegate(
CefMainRunnerHandler* runner,
CefRefPtr<CefApp> application)
: runner_(runner), application_(application) {}
ChromeMainRunnerDelegate::~ChromeMainRunnerDelegate() = default;
content::ContentMainDelegate*
ChromeMainRunnerDelegate::GetContentMainDelegate() {
if (!main_delegate_) {
main_delegate_ = std::make_unique<ChromeMainDelegateCef>(runner_);
main_delegate_ =
std::make_unique<ChromeMainDelegateCef>(runner_, application_);
}
return main_delegate_.get();
}

View File

@ -8,7 +8,7 @@
#include <memory>
#include "include/cef_base.h"
#include "include/cef_app.h"
#include "libcef/common/main_runner_delegate.h"
#include "libcef/common/main_runner_handler.h"
@ -20,7 +20,8 @@ class ChromeMainRunnerDelegate : public CefMainRunnerDelegate {
public:
// |runner| will be non-nullptr for the main process only, and will outlive
// this object.
explicit ChromeMainRunnerDelegate(CefMainRunnerHandler* runner);
ChromeMainRunnerDelegate(CefMainRunnerHandler* runner,
CefRefPtr<CefApp> application);
~ChromeMainRunnerDelegate() override;
protected:
@ -40,6 +41,7 @@ class ChromeMainRunnerDelegate : public CefMainRunnerDelegate {
std::unique_ptr<ScopedKeepAlive> keep_alive_;
CefMainRunnerHandler* const runner_;
CefRefPtr<CefApp> application_;
DISALLOW_COPY_AND_ASSIGN(ChromeMainRunnerDelegate);
};

View File

@ -0,0 +1,53 @@
// Copyright (c) 2013 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_COMMON_NET_SCHEME_INFO_H_
#define CEF_LIBCEF_COMMON_NET_SCHEME_INFO_H_
#pragma once
#include <string>
// Values are registered with all processes (url/url_util.h) and with Blink
// (SchemeRegistry) unless otherwise indicated.
struct CefSchemeInfo {
// Lower-case ASCII scheme name.
std::string scheme_name;
// A scheme that is subject to URL canonicalization and parsing rules as
// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1
// available at http://www.ietf.org/rfc/rfc1738.txt.
// This value is not registered with Blink.
bool is_standard;
// A scheme that will be treated the same as "file". For example, normal
// pages cannot link to or access URLs of this scheme.
bool is_local;
// A scheme that can only be displayed from other content hosted with the
// same scheme. For example, pages in other origins cannot create iframes or
// hyperlinks to URLs with the scheme. For schemes that must be accessible
// from other schemes set this value to false, set |is_cors_enabled| to
// true, and use CORS "Access-Control-Allow-Origin" headers to further
// restrict access.
// This value is registered with Blink only.
bool is_display_isolated;
// A scheme that will be treated the same as "https". For example, loading
// this scheme from other secure schemes will not trigger mixed content
// warnings.
bool is_secure;
// A scheme that can be sent CORS requests. This value should be true in
// most cases where |is_standard| is true.
bool is_cors_enabled;
// A scheme that can bypass Content-Security-Policy (CSP) checks. This value
// should be false in most cases where |is_standard| is true.
bool is_csp_bypassing;
// A scheme that can perform fetch request.
bool is_fetch_enabled;
};
#endif // CEF_LIBCEF_COMMON_NET_SCHEME_INFO_H_

View File

@ -4,7 +4,9 @@
#include "libcef/common/net/scheme_registration.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/net/scheme_info.h"
#include "libcef/features/runtime.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
@ -15,11 +17,14 @@
namespace scheme {
void AddInternalSchemes(content::ContentClient::Schemes* schemes) {
if (!cef::IsAlloyRuntimeEnabled())
return;
// chrome: and chrome-devtools: schemes are registered in
// RenderThreadImpl::RegisterSchemes().
// Access restrictions for chrome-extension: and chrome-extension-resource:
// schemes will be applied in AlloyContentRendererClient::WillSendRequest().
static AlloyContentClient::SchemeInfo internal_schemes[] = {
static CefSchemeInfo internal_schemes[] = {
{
extensions::kExtensionScheme, true, /* is_standard */
false, /* is_local */
@ -32,7 +37,6 @@ void AddInternalSchemes(content::ContentClient::Schemes* schemes) {
// The |is_display_isolated| value is excluded here because it's registered
// with Blink only.
AlloyContentClient* client = AlloyContentClient::Get();
for (size_t i = 0; i < sizeof(internal_schemes) / sizeof(internal_schemes[0]);
++i) {
if (internal_schemes[i].is_standard)
@ -45,7 +49,7 @@ void AddInternalSchemes(content::ContentClient::Schemes* schemes) {
schemes->cors_enabled_schemes.push_back(internal_schemes[i].scheme_name);
if (internal_schemes[i].is_csp_bypassing)
schemes->csp_bypassing_schemes.push_back(internal_schemes[i].scheme_name);
client->AddCustomScheme(internal_schemes[i]);
CefAppManager::Get()->AddCustomScheme(&internal_schemes[i]);
}
}

View File

@ -1,13 +1,12 @@
#include "libcef/common/resource_bundle_delegate.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
base::FilePath CefResourceBundleDelegate::GetPathForResourcePack(
const base::FilePath& pack_path,
ui::ScaleFactor scale_factor) {
// Only allow the cef pack file to load.
if (!content_client_->pack_loading_disabled() &&
content_client_->allow_pack_file_load()) {
if (!pack_loading_disabled_ && allow_pack_file_load_) {
return pack_path;
}
return base::FilePath();
@ -16,7 +15,7 @@ base::FilePath CefResourceBundleDelegate::GetPathForResourcePack(
base::FilePath CefResourceBundleDelegate::GetPathForLocalePack(
const base::FilePath& pack_path,
const std::string& locale) {
if (!content_client_->pack_loading_disabled())
if (!pack_loading_disabled_)
return pack_path;
return base::FilePath();
}
@ -38,9 +37,10 @@ base::RefCountedStaticMemory* CefResourceBundleDelegate::LoadDataResourceBytes(
bool CefResourceBundleDelegate::GetRawDataResource(int resource_id,
ui::ScaleFactor scale_factor,
base::StringPiece* value) {
if (content_client_->application().get()) {
auto application = CefAppManager::Get()->GetApplication();
if (application) {
CefRefPtr<CefResourceBundleHandler> handler =
content_client_->application()->GetResourceBundleHandler();
application->GetResourceBundleHandler();
if (handler.get()) {
void* data = nullptr;
size_t data_size = 0;
@ -56,14 +56,15 @@ bool CefResourceBundleDelegate::GetRawDataResource(int resource_id,
}
}
return (content_client_->pack_loading_disabled() || !value->empty());
return (pack_loading_disabled_ || !value->empty());
}
bool CefResourceBundleDelegate::GetLocalizedString(int message_id,
base::string16* value) {
if (content_client_->application().get()) {
auto application = CefAppManager::Get()->GetApplication();
if (application) {
CefRefPtr<CefResourceBundleHandler> handler =
content_client_->application()->GetResourceBundleHandler();
application->GetResourceBundleHandler();
if (handler.get()) {
CefString cef_str;
if (handler->GetLocalizedString(message_id, cef_str))
@ -71,5 +72,5 @@ bool CefResourceBundleDelegate::GetLocalizedString(int message_id,
}
}
return (content_client_->pack_loading_disabled() || !value->empty());
return (pack_loading_disabled_ || !value->empty());
}

View File

@ -13,8 +13,12 @@ class AlloyContentClient;
class CefResourceBundleDelegate : public ui::ResourceBundle::Delegate {
public:
CefResourceBundleDelegate(AlloyContentClient* content_client)
: content_client_(content_client) {}
CefResourceBundleDelegate() {}
void set_pack_loading_disabled(bool val) { pack_loading_disabled_ = val; }
bool pack_loading_disabled() const { return pack_loading_disabled_; }
void set_allow_pack_file_load(bool val) { allow_pack_file_load_ = val; }
bool allow_pack_file_load() const { return allow_pack_file_load_; }
private:
// ui::ResourceBundle::Delegate methods.
@ -33,7 +37,8 @@ class CefResourceBundleDelegate : public ui::ResourceBundle::Delegate {
bool GetLocalizedString(int message_id, base::string16* value) override;
private:
AlloyContentClient* content_client_;
bool pack_loading_disabled_ = false;
bool allow_pack_file_load_ = false;
};
#endif // CEF_LIBCEF_COMMON_RESOURCE_BUNDLE_DELEGATE_H_

View File

@ -6,7 +6,8 @@
#include <string>
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/net/scheme_info.h"
#include "libcef/common/net/scheme_registration.h"
#include "base/bind.h"
@ -56,10 +57,10 @@ bool CefSchemeRegistrarImpl::AddCustomScheme(const CefString& scheme_name,
if (is_csp_bypassing)
schemes_.csp_bypassing_schemes.push_back(scheme);
AlloyContentClient::SchemeInfo scheme_info = {
CefSchemeInfo scheme_info = {
scheme, is_standard, is_local, is_display_isolated,
is_secure, is_cors_enabled, is_csp_bypassing, is_fetch_enabled};
AlloyContentClient::Get()->AddCustomScheme(scheme_info);
CefAppManager::Get()->AddCustomScheme(&scheme_info);
return true;
}

View File

@ -4,9 +4,10 @@
#include "include/cef_urlrequest.h"
#include "libcef/browser/net_service/browser_urlrequest_impl.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/task_runner_impl.h"
#include "libcef/renderer/render_urlrequest_impl.h"
#include "libcef/features/runtime_checks.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
@ -17,6 +18,9 @@ CefRefPtr<CefURLRequest> CefURLRequest::Create(
CefRefPtr<CefRequest> request,
CefRefPtr<CefURLRequestClient> client,
CefRefPtr<CefRequestContext> request_context) {
// TODO(chrome-runtime): Add support for this method.
REQUIRE_ALLOY_RUNTIME();
if (!request.get() || !client.get()) {
NOTREACHED() << "called with invalid parameters";
return nullptr;
@ -27,14 +31,15 @@ CefRefPtr<CefURLRequest> CefURLRequest::Create(
return nullptr;
}
if (AlloyContentClient::Get()->browser()) {
auto content_client = CefAppManager::Get()->GetContentClient();
if (content_client->browser()) {
// In the browser process.
CefRefPtr<CefBrowserURLRequest> impl =
new CefBrowserURLRequest(nullptr, request, client, request_context);
if (impl->Start())
return impl.get();
return nullptr;
} else if (AlloyContentClient::Get()->renderer()) {
} else if (content_client->renderer()) {
// In the render process.
CefRefPtr<CefRenderURLRequest> impl =
new CefRenderURLRequest(nullptr, request, client);

View File

@ -0,0 +1,18 @@
// 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_FEATURES_RUNTIME_CHECKS_H_
#define CEF_LIBCEF_FEATURES_RUNTIME_CHECKS_H_
#pragma once
#include "base/logging.h"
#include "cef/libcef/features/runtime.h"
#define REQUIRE_ALLOY_RUNTIME() \
CHECK(cef::IsAlloyRuntimeEnabled()) << "Alloy runtime is required"
#define REQUIRE_CHROME_RUNTIME() \
CHECK(cef::IsChrimeRuntimeEnabled()) << "Chrome runtime is required"
#endif // CEF_LIBCEF_FEATURES_RUNTIME_CHECKS_H_

View File

@ -23,12 +23,15 @@
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_client.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net/scheme_info.h"
#include "libcef/common/request_impl.h"
#include "libcef/common/values_impl.h"
#include "libcef/features/runtime_checks.h"
#include "libcef/renderer/blink_glue.h"
#include "libcef/renderer/browser_impl.h"
#include "libcef/renderer/extensions/extensions_renderer_client.h"
@ -92,7 +95,6 @@
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/scheduler/web_renderer_process_type.h"
#include "third_party/blink/public/platform/url_conversion.h"
#include "third_party/blink/public/platform/web_runtime_features.h"
@ -179,8 +181,9 @@ AlloyContentRendererClient::~AlloyContentRendererClient() {}
// static
AlloyContentRendererClient* AlloyContentRendererClient::Get() {
REQUIRE_ALLOY_RUNTIME();
return static_cast<AlloyContentRendererClient*>(
AlloyContentClient::Get()->renderer());
CefAppManager::Get()->GetContentClient()->renderer());
}
CefRefPtr<CefBrowserImpl> AlloyContentRendererClient::GetBrowserForView(
@ -246,15 +249,6 @@ void AlloyContentRendererClient::OnGuestViewDestroyed(
NOTREACHED();
}
blink::WebURLLoaderFactory*
AlloyContentRendererClient::GetDefaultURLLoaderFactory() {
if (!default_url_loader_factory_) {
default_url_loader_factory_ =
blink::Platform::Current()->CreateDefaultURLLoaderFactory();
}
return default_url_loader_factory_.get();
}
void AlloyContentRendererClient::WebKitInitialized() {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
@ -265,14 +259,14 @@ void AlloyContentRendererClient::WebKitInitialized() {
// TODO(cef): Enable these once the implementation supports it.
blink::WebRuntimeFeatures::EnableNotifications(false);
const AlloyContentClient::SchemeInfoList* schemes =
AlloyContentClient::Get()->GetCustomSchemes();
const CefAppManager::SchemeInfoList* schemes =
CefAppManager::Get()->GetCustomSchemes();
if (!schemes->empty()) {
// Register the custom schemes. The |is_standard| value is excluded here
// because it's not explicitly registered with Blink.
AlloyContentClient::SchemeInfoList::const_iterator it = schemes->begin();
CefAppManager::SchemeInfoList::const_iterator it = schemes->begin();
for (; it != schemes->end(); ++it) {
const AlloyContentClient::SchemeInfo& info = *it;
const CefSchemeInfo& info = *it;
const blink::WebString& scheme =
blink::WebString::FromUTF8(info.scheme_name);
if (info.is_local)
@ -319,7 +313,7 @@ void AlloyContentRendererClient::WebKitInitialized() {
}
// Notify the render process handler.
CefRefPtr<CefApp> application = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
if (application.get()) {
CefRefPtr<CefRenderProcessHandler> handler =
application->GetRenderProcessHandler();
@ -459,7 +453,7 @@ void AlloyContentRendererClient::RenderThreadConnected() {
cross_origin_whitelist_entries_ = params.cross_origin_whitelist_entries;
// Notify the render process handler.
CefRefPtr<CefApp> application = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
if (application.get()) {
CefRefPtr<CefRenderProcessHandler> handler =
application->GetRenderProcessHandler();
@ -778,7 +772,7 @@ CefRefPtr<CefBrowserImpl> AlloyContentRendererClient::MaybeCreateBrowser(
browsers_.insert(std::make_pair(render_view, browser));
// Notify the render process handler.
CefRefPtr<CefApp> application = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
if (application.get()) {
CefRefPtr<CefRenderProcessHandler> handler =
application->GetRenderProcessHandler();

View File

@ -25,10 +25,6 @@
#include "mojo/public/cpp/bindings/generic_pending_receiver.h"
#include "services/service_manager/public/cpp/local_interface_provider.h"
namespace blink {
class WebURLLoaderFactory;
}
namespace extensions {
class CefExtensionsRendererClient;
class Dispatcher;
@ -62,6 +58,7 @@ class AlloyContentRendererClient
~AlloyContentRendererClient() override;
// Returns the singleton AlloyContentRendererClient instance.
// This method is deprecated and should not be used in new callsites.
static AlloyContentRendererClient* Get();
// Returns the browser associated with the specified RenderView.
@ -88,10 +85,6 @@ class AlloyContentRendererClient
return uncaught_exception_stack_size_;
}
// Returns a factory that only supports unintercepted http(s) and blob
// requests. Used by CefRenderURLRequest.
blink::WebURLLoaderFactory* GetDefaultURLLoaderFactory();
void WebKitInitialized();
// Returns the task runner for the current thread. Returns NULL if the current
@ -171,8 +164,6 @@ class AlloyContentRendererClient
std::unique_ptr<SpellCheck> spellcheck_;
std::unique_ptr<visitedlink::VisitedLinkReader> visited_link_slave_;
std::unique_ptr<blink::WebURLLoaderFactory> default_url_loader_factory_;
// Map of RenderView pointers to CefBrowserImpl references.
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl>> BrowserMap;
BrowserMap browsers_;

View File

@ -8,7 +8,7 @@
#include <string>
#include <vector>
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_messages.h"
#include "libcef/renderer/alloy/alloy_content_renderer_client.h"
#include "libcef/renderer/blink_glue.h"
@ -345,7 +345,7 @@ void CefBrowserImpl::AddFrameObject(int64_t frame_id,
void CefBrowserImpl::OnDestruct() {
// Notify that the browser window has been destroyed.
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app.get()) {
CefRefPtr<CefRenderProcessHandler> handler = app->GetRenderProcessHandler();
if (handler.get())
@ -373,7 +373,7 @@ void CefBrowserImpl::FrameDetached(int64_t frame_id) {
}
void CefBrowserImpl::OnLoadingStateChange(bool isLoading) {
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app.get()) {
CefRefPtr<CefRenderProcessHandler> handler = app->GetRenderProcessHandler();
if (handler.get()) {

View File

@ -17,7 +17,7 @@
#endif
#endif
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/net/http_header_utils.h"
#include "libcef/common/process_message_impl.h"
@ -325,7 +325,7 @@ void CefFrameImpl::OnDidFinishLoad() {
Send(new CefHostMsg_DidFinishLoad(MSG_ROUTING_NONE, dl->GetUrl(),
http_status_code));
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app) {
CefRefPtr<CefRenderProcessHandler> handler = app->GetRenderProcessHandler();
if (handler) {
@ -417,7 +417,7 @@ void CefFrameImpl::OnRequest(const Cef_Request_Params& params) {
if (params.user_initiated) {
// Give the user a chance to handle the request.
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app.get()) {
CefRefPtr<CefRenderProcessHandler> handler =
app->GetRenderProcessHandler();

View File

@ -17,7 +17,7 @@
#include "libcef/renderer/render_frame_observer.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/renderer/blink_glue.h"
#include "libcef/renderer/browser_impl.h"
#include "libcef/renderer/dom_document_impl.h"
@ -96,7 +96,7 @@ void CefRenderFrameObserver::FocusedElementChanged(
return;
CefRefPtr<CefRenderProcessHandler> handler;
CefRefPtr<CefApp> application = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
if (application)
handler = application->GetRenderProcessHandler();
if (!handler)
@ -138,7 +138,7 @@ void CefRenderFrameObserver::DidCreateScriptContext(
return;
CefRefPtr<CefRenderProcessHandler> handler;
CefRefPtr<CefApp> application = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
if (application)
handler = application->GetRenderProcessHandler();
if (!handler)
@ -164,7 +164,7 @@ void CefRenderFrameObserver::WillReleaseScriptContext(
CefRefPtr<CefBrowserImpl> browserPtr =
CefBrowserImpl::GetBrowserForMainFrame(frame->Top());
if (browserPtr) {
CefRefPtr<CefApp> application = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
if (application) {
CefRefPtr<CefRenderProcessHandler> handler =
application->GetRenderProcessHandler();
@ -210,7 +210,7 @@ void CefRenderFrameObserver::AttachFrame(CefFrameImpl* frame) {
}
void CefRenderFrameObserver::OnLoadStart() {
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app.get()) {
CefRefPtr<CefRenderProcessHandler> handler = app->GetRenderProcessHandler();
if (handler.get()) {
@ -226,7 +226,7 @@ void CefRenderFrameObserver::OnLoadStart() {
}
void CefRenderFrameObserver::OnLoadError() {
CefRefPtr<CefApp> app = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app.get()) {
CefRefPtr<CefRenderProcessHandler> handler = app->GetRenderProcessHandler();
if (handler.get()) {

View File

@ -6,16 +6,18 @@
#include <stdint.h>
#include "libcef/common/app_manager.h"
#include "libcef/common/request_impl.h"
#include "libcef/common/response_impl.h"
#include "libcef/common/task_runner_impl.h"
#include "libcef/renderer/alloy/alloy_content_renderer_client.h"
#include "libcef/renderer/blink_glue.h"
#include "libcef/renderer/frame_impl.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "net/base/request_priority.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom.h"
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h"
@ -155,7 +157,7 @@ class CefRenderURLRequest::Context
}
if (!factory) {
// This factory only supports unintercepted http(s) and blob requests.
factory = AlloyContentRendererClient::Get()->GetDefaultURLLoaderFactory();
factory = CefAppManager::Get()->GetDefaultURLLoaderFactory();
}
loader_ = factory->CreateURLLoader(

View File

@ -25,7 +25,7 @@
#include "libcef/renderer/v8_impl.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/task_runner_impl.h"
#include "libcef/common/tracker.h"
@ -783,7 +783,7 @@ class CefV8ExceptionImpl : public CefV8Exception {
void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
v8::Handle<v8::Value> data) {
CefRefPtr<CefApp> application = AlloyContentClient::Get()->application();
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
if (!application.get())
return;