diff --git a/BUILD.gn b/BUILD.gn index 63cf58e85..af0da1377 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -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", diff --git a/libcef/browser/alloy/alloy_browser_main.cc b/libcef/browser/alloy/alloy_browser_main.cc index aea468c96..af60641c5 100644 --- a/libcef/browser/alloy/alloy_browser_main.cc +++ b/libcef/browser/alloy/alloy_browser_main.cc @@ -8,7 +8,6 @@ #include -#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) diff --git a/libcef/browser/alloy/alloy_content_browser_client.cc b/libcef/browser/alloy/alloy_content_browser_client.cc index b52b4d2c1..a43949809 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.cc +++ b/libcef/browser/alloy/alloy_content_browser_client.cc @@ -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( - AlloyContentClient::Get()->browser()); -} - std::unique_ptr 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 app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app.get()) { CefRefPtr 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(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; diff --git a/libcef/browser/alloy/alloy_content_browser_client.h b/libcef/browser/alloy/alloy_content_browser_client.h index f3762c2a1..e6335abd2 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.h +++ b/libcef/browser/alloy/alloy_content_browser_client.h @@ -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 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 diff --git a/libcef/browser/alloy/chrome_profile_manager_alloy.cc b/libcef/browser/alloy/chrome_profile_manager_alloy.cc index af3427b05..99e16a8cb 100644 --- a/libcef/browser/alloy/chrome_profile_manager_alloy.cc +++ b/libcef/browser/alloy/chrome_profile_manager_alloy.cc @@ -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( - AlloyContentBrowserClient::Get()->request_context()->GetBrowserContext()); + auto request_context = static_cast( + CefAppManager::Get()->GetGlobalRequestContext().get()); + return static_cast(request_context->GetBrowserContext()); } } // namespace diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index 0d1a80295..73b55ac1b 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -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 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"; diff --git a/libcef/browser/browser_message_filter.cc b/libcef/browser/browser_message_filter.cc index 1a2519fad..e83bba703 100644 --- a/libcef/browser/browser_message_filter.cc +++ b/libcef/browser/browser_message_filter.cc @@ -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(¶ms->cross_origin_whitelist_entries); - CefRefPtr app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app.get()) { CefRefPtr handler = app->GetBrowserProcessHandler(); diff --git a/libcef/browser/browser_message_loop.cc b/libcef/browser/browser_message_loop.cc index 8eb3b7120..b5b3db724 100644 --- a/libcef/browser/browser_message_loop.cc +++ b/libcef/browser/browser_message_loop.cc @@ -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 GetBrowserProcessHandler() { - CefRefPtr app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app) return app->GetBrowserProcessHandler(); return nullptr; diff --git a/libcef/browser/devtools/devtools_frontend.cc b/libcef/browser/devtools/devtools_frontend.cc index aafd3e2d9..81fb90801 100644 --- a/libcef/browser/devtools/devtools_frontend.cc +++ b/libcef/browser/devtools/devtools_frontend.cc @@ -9,11 +9,11 @@ #include #include -#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))); diff --git a/libcef/browser/main_runner.cc b/libcef/browser/main_runner.cc index 4954bc83d..1dec785c8 100644 --- a/libcef/browser/main_runner.cc +++ b/libcef/browser/main_runner.cc @@ -59,7 +59,7 @@ std::unique_ptr MakeDelegate( application); } else { g_runtime_type = RuntimeType::CHROME; - return std::make_unique(runner); + return std::make_unique(runner, application); } } diff --git a/libcef/browser/menu_manager.cc b/libcef/browser/menu_manager.cc index e541b912b..7890d39e5 100644 --- a/libcef/browser/menu_manager.cc +++ b/libcef/browser/menu_manager.cc @@ -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; } diff --git a/libcef/browser/net/chrome_scheme_handler.cc b/libcef/browser/net/chrome_scheme_handler.cc index d2c61034f..78ec6a84c 100644 --- a/libcef/browser/net/chrome_scheme_handler.cc +++ b/libcef/browser/net/chrome_scheme_handler.cc @@ -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())); diff --git a/libcef/browser/net/internal_scheme_handler.cc b/libcef/browser/net/internal_scheme_handler.cc index 91bffdd5e..6498d62de 100644 --- a/libcef/browser/net/internal_scheme_handler.cc +++ b/libcef/browser/net/internal_scheme_handler.cc @@ -8,7 +8,7 @@ #include #include -#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(); diff --git a/libcef/browser/net_service/resource_request_handler_wrapper.cc b/libcef/browser/net_service/resource_request_handler_wrapper.cc index 76f0e5701..f002662e5 100644 --- a/libcef/browser/net_service/resource_request_handler_wrapper.cc +++ b/libcef/browser/net_service/resource_request_handler_wrapper.cc @@ -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()); } diff --git a/libcef/browser/net_service/url_loader_factory_getter.cc b/libcef/browser/net_service/url_loader_factory_getter.cc index 9c6bbcccb..8fff1a6b8 100644 --- a/libcef/browser/net_service/url_loader_factory_getter.cc +++ b/libcef/browser/net_service/url_loader_factory_getter.cc @@ -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::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 */, diff --git a/libcef/browser/osr/render_widget_host_view_osr_win.cc b/libcef/browser/osr/render_widget_host_view_osr_win.cc index b54f25c71..46ac0eb1e 100644 --- a/libcef/browser/osr/render_widget_host_view_osr_win.cc +++ b/libcef/browser/osr/render_widget_host_view_osr_win.cc @@ -7,8 +7,8 @@ #include -#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); } diff --git a/libcef/browser/printing/print_dialog_linux.cc b/libcef/browser/printing/print_dialog_linux.cc index 42925388c..2296ead3f 100644 --- a/libcef/browser/printing/print_dialog_linux.cc +++ b/libcef/browser/printing/print_dialog_linux.cc @@ -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 app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app.get()) { CefRefPtr browser_handler = app->GetBrowserProcessHandler(); @@ -136,7 +136,7 @@ void CefPrintDialogLinux::OnPrintStart(int render_process_id, return; } - CefRefPtr app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (!app.get()) return; @@ -251,7 +251,7 @@ void CefPrintDialogLinux::SetHandler() { if (handler_.get()) return; - CefRefPtr app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app.get()) { CefRefPtr browser_handler = app->GetBrowserProcessHandler(); diff --git a/libcef/browser/request_context_impl.cc b/libcef/browser/request_context_impl.cc index 092caa795..029a41c82 100644 --- a/libcef/browser/request_context_impl.cc +++ b/libcef/browser/request_context_impl.cc @@ -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::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( + CefAppManager::Get()->GetGlobalRequestContext().get()); } // The new context will be initialized later by EnsureBrowserContext(). diff --git a/libcef/browser/views/browser_view_impl.cc b/libcef/browser/views/browser_view_impl.cc index 4cb3f7dee..64fd7821b 100644 --- a/libcef/browser/views/browser_view_impl.cc +++ b/libcef/browser/views/browser_view_impl.cc @@ -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::Create( CefRefPtr extra_info, CefRefPtr request_context, CefRefPtr delegate) { + // TODO(chrome-runtime): Add support for this method. + REQUIRE_ALLOY_RUNTIME(); + CEF_REQUIRE_UIT_RETURN(nullptr); CefRefPtr browser_view = new CefBrowserViewImpl(delegate); browser_view->SetPendingBrowserCreateParams(client, url, settings, extra_info, diff --git a/libcef/common/alloy/alloy_content_client.cc b/libcef/common/alloy/alloy_content_client.cc index f317084b1..c572aacfc 100644 --- a/libcef/common/alloy/alloy_content_client.cc +++ b/libcef/common/alloy/alloy_content_client.cc @@ -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 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* 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, diff --git a/libcef/common/alloy/alloy_content_client.h b/libcef/common/alloy/alloy_content_client.h index 6bd24d898..5c0d5d4e9 100644 --- a/libcef/common/alloy/alloy_content_client.h +++ b/libcef/common/alloy/alloy_content_client.h @@ -7,29 +7,18 @@ #define CEF_LIBCEF_COMMON_ALLOY_ALLOY_CONTENT_CLIENT_H_ #pragma once -#include -#include -#include - -#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 application); + AlloyContentClient(); ~AlloyContentClient() override; - // Returns the singleton AlloyContentClient instance. - static AlloyContentClient* Get(); - - // content::ContentClient methods. + // content::ContentClient overrides. void AddPepperPlugins( std::vector* 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 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 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 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_ diff --git a/libcef/common/alloy/alloy_main_delegate.cc b/libcef/common/alloy/alloy_main_delegate.cc index bba4426b3..4a97185e5 100644 --- a/libcef/common/alloy/alloy_main_delegate.cc +++ b/libcef/common/alloy/alloy_main_delegate.cc @@ -321,7 +321,7 @@ void OverrideAssetPath() { AlloyMainDelegate::AlloyMainDelegate(CefMainRunnerHandler* runner, CefSettings* settings, CefRefPtr 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 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 AlloyMainDelegate::GetGlobalRequestContext() { + if (!browser_client_) + return nullptr; + return browser_client_->request_context(); +} + scoped_refptr 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); } } diff --git a/libcef/common/alloy/alloy_main_delegate.h b/libcef/common/alloy/alloy_main_delegate.h index 9ab9bb084..8cf8e1972 100644 --- a/libcef/common/alloy/alloy_main_delegate.h +++ b/libcef/common/alloy/alloy_main_delegate.h @@ -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 GetApplication() override { return application_; } + content::ContentClient* GetContentClient() override { + return &content_client_; + } + CefRefPtr GetGlobalRequestContext() override; + // CefTaskRunnerManager overrides. scoped_refptr GetBackgroundTaskRunner() override; @@ -70,12 +77,15 @@ class AlloyMainDelegate : public content::ContentMainDelegate, CefMainRunnerHandler* const runner_; CefSettings* const settings_; + CefRefPtr application_; std::unique_ptr browser_client_; std::unique_ptr renderer_client_; std::unique_ptr utility_client_; AlloyContentClient content_client_; + CefResourceBundleDelegate resource_bundle_delegate_; + DISALLOW_COPY_AND_ASSIGN(AlloyMainDelegate); }; diff --git a/libcef/common/app_manager.cc b/libcef/common/app_manager.cc new file mode 100644 index 000000000..bca198a87 --- /dev/null +++ b/libcef/common/app_manager.cc @@ -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 +#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(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(); +} diff --git a/libcef/common/app_manager.h b/libcef/common/app_manager.h new file mode 100644 index 000000000..033c4eb9d --- /dev/null +++ b/libcef/common/app_manager.h @@ -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 + +#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 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; + 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 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 default_url_loader_factory_; + + DISALLOW_COPY_AND_ASSIGN(CefAppManager); +}; + +#endif // CEF_LIBCEF_COMMON_APP_MANAGER_H_ diff --git a/libcef/common/chrome/chrome_content_client_cef.cc b/libcef/common/chrome/chrome_content_client_cef.cc new file mode 100644 index 000000000..acdf115de --- /dev/null +++ b/libcef/common/chrome/chrome_content_client_cef.cc @@ -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); +} diff --git a/libcef/common/chrome/chrome_content_client_cef.h b/libcef/common/chrome/chrome_content_client_cef.h new file mode 100644 index 000000000..4076aca58 --- /dev/null +++ b/libcef/common/chrome/chrome_content_client_cef.h @@ -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_ diff --git a/libcef/common/chrome/chrome_main_delegate_cef.cc b/libcef/common/chrome/chrome_main_delegate_cef.cc index c136551bb..ac71cc5cd 100644 --- a/libcef/common/chrome/chrome_main_delegate_cef.cc +++ b/libcef/common/chrome/chrome_main_delegate_cef.cc @@ -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 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 ChromeMainDelegateCef::GetGlobalRequestContext() { + // TODO(chrome-runtime): Implement this method. + NOTIMPLEMENTED(); + return nullptr; +} + scoped_refptr ChromeMainDelegateCef::GetBackgroundTaskRunner() { auto browser_client = content_browser_client(); diff --git a/libcef/common/chrome/chrome_main_delegate_cef.h b/libcef/common/chrome/chrome_main_delegate_cef.h index 7fc540d02..933669b39 100644 --- a/libcef/common/chrome/chrome_main_delegate_cef.h +++ b/libcef/common/chrome/chrome_main_delegate_cef.h @@ -8,7 +8,9 @@ #include -#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 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 GetApplication() override { return application_; } + content::ContentClient* GetContentClient() override { + return &chrome_content_client_cef_; + } + CefRefPtr GetGlobalRequestContext() override; + // CefTaskRunnerManager overrides. scoped_refptr GetBackgroundTaskRunner() override; @@ -48,6 +60,10 @@ class ChromeMainDelegateCef : public ChromeMainDelegate, ChromeContentBrowserClientCef* content_browser_client() const; CefMainRunnerHandler* const runner_; + CefRefPtr application_; + + // We use this instead of ChromeMainDelegate::chrome_content_client_. + ChromeContentClientCef chrome_content_client_cef_; DISALLOW_COPY_AND_ASSIGN(ChromeMainDelegateCef); }; diff --git a/libcef/common/chrome/chrome_main_runner_delegate.cc b/libcef/common/chrome/chrome_main_runner_delegate.cc index 835fc7517..420762b94 100644 --- a/libcef/common/chrome/chrome_main_runner_delegate.cc +++ b/libcef/common/chrome/chrome_main_runner_delegate.cc @@ -18,14 +18,17 @@ #include "chrome/app/chrome_main_mac.h" #endif -ChromeMainRunnerDelegate::ChromeMainRunnerDelegate(CefMainRunnerHandler* runner) - : runner_(runner) {} +ChromeMainRunnerDelegate::ChromeMainRunnerDelegate( + CefMainRunnerHandler* runner, + CefRefPtr application) + : runner_(runner), application_(application) {} ChromeMainRunnerDelegate::~ChromeMainRunnerDelegate() = default; content::ContentMainDelegate* ChromeMainRunnerDelegate::GetContentMainDelegate() { if (!main_delegate_) { - main_delegate_ = std::make_unique(runner_); + main_delegate_ = + std::make_unique(runner_, application_); } return main_delegate_.get(); } diff --git a/libcef/common/chrome/chrome_main_runner_delegate.h b/libcef/common/chrome/chrome_main_runner_delegate.h index f950c6ba2..20124f8de 100644 --- a/libcef/common/chrome/chrome_main_runner_delegate.h +++ b/libcef/common/chrome/chrome_main_runner_delegate.h @@ -8,7 +8,7 @@ #include -#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 application); ~ChromeMainRunnerDelegate() override; protected: @@ -40,6 +41,7 @@ class ChromeMainRunnerDelegate : public CefMainRunnerDelegate { std::unique_ptr keep_alive_; CefMainRunnerHandler* const runner_; + CefRefPtr application_; DISALLOW_COPY_AND_ASSIGN(ChromeMainRunnerDelegate); }; diff --git a/libcef/common/net/scheme_info.h b/libcef/common/net/scheme_info.h new file mode 100644 index 000000000..4730d00e6 --- /dev/null +++ b/libcef/common/net/scheme_info.h @@ -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 + +// 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_ diff --git a/libcef/common/net/scheme_registration.cc b/libcef/common/net/scheme_registration.cc index 4145c5e16..cd67ae05c 100644 --- a/libcef/common/net/scheme_registration.cc +++ b/libcef/common/net/scheme_registration.cc @@ -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]); } } diff --git a/libcef/common/resource_bundle_delegate.cc b/libcef/common/resource_bundle_delegate.cc index 4351f164c..0fa929731 100644 --- a/libcef/common/resource_bundle_delegate.cc +++ b/libcef/common/resource_bundle_delegate.cc @@ -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 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 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()); } diff --git a/libcef/common/resource_bundle_delegate.h b/libcef/common/resource_bundle_delegate.h index 0084dbde1..c5670b196 100644 --- a/libcef/common/resource_bundle_delegate.h +++ b/libcef/common/resource_bundle_delegate.h @@ -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_ diff --git a/libcef/common/scheme_registrar_impl.cc b/libcef/common/scheme_registrar_impl.cc index 167e3cf2c..bd8f762fe 100644 --- a/libcef/common/scheme_registrar_impl.cc +++ b/libcef/common/scheme_registrar_impl.cc @@ -6,7 +6,8 @@ #include -#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; } diff --git a/libcef/common/urlrequest_impl.cc b/libcef/common/urlrequest_impl.cc index 643f719ec..d38a688f4 100644 --- a/libcef/common/urlrequest_impl.cc +++ b/libcef/common/urlrequest_impl.cc @@ -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::Create( CefRefPtr request, CefRefPtr client, CefRefPtr 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::Create( return nullptr; } - if (AlloyContentClient::Get()->browser()) { + auto content_client = CefAppManager::Get()->GetContentClient(); + if (content_client->browser()) { // In the browser process. CefRefPtr 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 impl = new CefRenderURLRequest(nullptr, request, client); diff --git a/libcef/features/runtime_checks.h b/libcef/features/runtime_checks.h new file mode 100644 index 000000000..be7327ac7 --- /dev/null +++ b/libcef/features/runtime_checks.h @@ -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_ diff --git a/libcef/renderer/alloy/alloy_content_renderer_client.cc b/libcef/renderer/alloy/alloy_content_renderer_client.cc index 66fdb5aee..85952a6c5 100644 --- a/libcef/renderer/alloy/alloy_content_renderer_client.cc +++ b/libcef/renderer/alloy/alloy_content_renderer_client.cc @@ -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( - AlloyContentClient::Get()->renderer()); + CefAppManager::Get()->GetContentClient()->renderer()); } CefRefPtr 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 application = AlloyContentClient::Get()->application(); + CefRefPtr application = CefAppManager::Get()->GetApplication(); if (application.get()) { CefRefPtr 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 application = AlloyContentClient::Get()->application(); + CefRefPtr application = CefAppManager::Get()->GetApplication(); if (application.get()) { CefRefPtr handler = application->GetRenderProcessHandler(); @@ -778,7 +772,7 @@ CefRefPtr AlloyContentRendererClient::MaybeCreateBrowser( browsers_.insert(std::make_pair(render_view, browser)); // Notify the render process handler. - CefRefPtr application = AlloyContentClient::Get()->application(); + CefRefPtr application = CefAppManager::Get()->GetApplication(); if (application.get()) { CefRefPtr handler = application->GetRenderProcessHandler(); diff --git a/libcef/renderer/alloy/alloy_content_renderer_client.h b/libcef/renderer/alloy/alloy_content_renderer_client.h index 3decbadd1..f803b2f88 100644 --- a/libcef/renderer/alloy/alloy_content_renderer_client.h +++ b/libcef/renderer/alloy/alloy_content_renderer_client.h @@ -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_; std::unique_ptr visited_link_slave_; - std::unique_ptr default_url_loader_factory_; - // Map of RenderView pointers to CefBrowserImpl references. typedef std::map> BrowserMap; BrowserMap browsers_; diff --git a/libcef/renderer/browser_impl.cc b/libcef/renderer/browser_impl.cc index 07d3fb51f..e2d3ddd94 100644 --- a/libcef/renderer/browser_impl.cc +++ b/libcef/renderer/browser_impl.cc @@ -8,7 +8,7 @@ #include #include -#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 app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app.get()) { CefRefPtr handler = app->GetRenderProcessHandler(); if (handler.get()) @@ -373,7 +373,7 @@ void CefBrowserImpl::FrameDetached(int64_t frame_id) { } void CefBrowserImpl::OnLoadingStateChange(bool isLoading) { - CefRefPtr app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app.get()) { CefRefPtr handler = app->GetRenderProcessHandler(); if (handler.get()) { diff --git a/libcef/renderer/frame_impl.cc b/libcef/renderer/frame_impl.cc index 63c22a16e..e382786cd 100644 --- a/libcef/renderer/frame_impl.cc +++ b/libcef/renderer/frame_impl.cc @@ -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 app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app) { CefRefPtr 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 app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app.get()) { CefRefPtr handler = app->GetRenderProcessHandler(); diff --git a/libcef/renderer/render_frame_observer.cc b/libcef/renderer/render_frame_observer.cc index 988d5d5c9..02cce72db 100644 --- a/libcef/renderer/render_frame_observer.cc +++ b/libcef/renderer/render_frame_observer.cc @@ -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 handler; - CefRefPtr application = AlloyContentClient::Get()->application(); + CefRefPtr application = CefAppManager::Get()->GetApplication(); if (application) handler = application->GetRenderProcessHandler(); if (!handler) @@ -138,7 +138,7 @@ void CefRenderFrameObserver::DidCreateScriptContext( return; CefRefPtr handler; - CefRefPtr application = AlloyContentClient::Get()->application(); + CefRefPtr application = CefAppManager::Get()->GetApplication(); if (application) handler = application->GetRenderProcessHandler(); if (!handler) @@ -164,7 +164,7 @@ void CefRenderFrameObserver::WillReleaseScriptContext( CefRefPtr browserPtr = CefBrowserImpl::GetBrowserForMainFrame(frame->Top()); if (browserPtr) { - CefRefPtr application = AlloyContentClient::Get()->application(); + CefRefPtr application = CefAppManager::Get()->GetApplication(); if (application) { CefRefPtr handler = application->GetRenderProcessHandler(); @@ -210,7 +210,7 @@ void CefRenderFrameObserver::AttachFrame(CefFrameImpl* frame) { } void CefRenderFrameObserver::OnLoadStart() { - CefRefPtr app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app.get()) { CefRefPtr handler = app->GetRenderProcessHandler(); if (handler.get()) { @@ -226,7 +226,7 @@ void CefRenderFrameObserver::OnLoadStart() { } void CefRenderFrameObserver::OnLoadError() { - CefRefPtr app = AlloyContentClient::Get()->application(); + CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app.get()) { CefRefPtr handler = app->GetRenderProcessHandler(); if (handler.get()) { diff --git a/libcef/renderer/render_urlrequest_impl.cc b/libcef/renderer/render_urlrequest_impl.cc index ffa436ecc..4749d644f 100644 --- a/libcef/renderer/render_urlrequest_impl.cc +++ b/libcef/renderer/render_urlrequest_impl.cc @@ -6,16 +6,18 @@ #include +#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( diff --git a/libcef/renderer/v8_impl.cc b/libcef/renderer/v8_impl.cc index 1c3939164..278da211e 100644 --- a/libcef/renderer/v8_impl.cc +++ b/libcef/renderer/v8_impl.cc @@ -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 message, v8::Handle data) { - CefRefPtr application = AlloyContentClient::Get()->application(); + CefRefPtr application = CefAppManager::Get()->GetApplication(); if (!application.get()) return;