Compare commits

..

30 Commits
4240 ... 4147

Author SHA1 Message Date
Cristian Amarie
fdc7504631 Add limit on request redirects (fixes issue #3001) 2020-08-13 15:03:41 -04:00
Marshall Greenblatt
304e015509 Update API hash to include enums (see issue #3000) 2020-08-07 13:17:46 -04:00
Dmitry Azaraev
6c81b2125f Include enum declarations into API hash calculation (fixes issue #3000) 2020-08-07 13:17:07 -04:00
Marshall Greenblatt
a46056b1eb Fix automate-git.py argument error 2020-08-03 15:02:39 -04:00
Marshall Greenblatt
7efb1099d9 Add --distrib-subdir-suffix option to make_distrib 2020-08-03 14:43:15 -04:00
Marshall Greenblatt
c8a556f173 Update to Chromium version 84.0.4147.105 2020-07-29 13:09:37 -04:00
Marshall Greenblatt
97011bca14 Fix DCHECK when showing print preview dialog (see issue #2952) 2020-07-23 15:54:55 -04:00
Marshall Greenblatt
83f4983b73 Fix link navigation from PDF files (fixes issue #2952)
Navigations initiated from a guest view will now be routed to the
OpenURLFromTab callback.
2020-07-23 15:54:55 -04:00
Marshall Greenblatt
d246bb6967 Windows: cmake: Simplify the MSVC version check 2020-07-23 12:32:26 -04:00
Czarek Tomczak
1058991018 MacOS: Update target SDK to 10.10 for cmake and tests 2020-07-23 12:32:21 -04:00
Marshall Greenblatt
ffc2f0ea62 cmake: Update documentation of build requirements and examples 2020-07-21 16:14:58 -04:00
Marshall Greenblatt
1a795a1b4b Fix crash in ThemeService with --disable-extensions (fixes issue #2852) 2020-07-21 13:28:56 -04:00
Masako Toda
7448470392 Fix excessive CPU usage with external and multi-threaded message loops (fixes issue #2809, fixes issue #2970). 2020-07-21 12:31:21 -04:00
Mike Wiedenbauer
a8731e7501 Return decompressed values from CefResourceBundle (fixes issue #2976) 2020-07-21 12:02:33 -04:00
Masako Toda
eeda28cdc8 Fix timing of InstallTransparency for OSR + gpu-disabled (see issue #2938) 2020-07-20 16:05:37 -04:00
Marshall Greenblatt
3dd2e2902a cefclient: Fix rendering of example background for OSR transparency (see issue #2938) 2020-07-20 15:44:57 -04:00
Andrei Kurushin
d9aa1a58ec Fix crash when closing an OSR browser (fixes issue #2919)
Release the Compositor before the WebContents is destroyed to match
the behavior in non-OSR code.
2020-07-20 14:55:05 -04:00
Cristian Amarie
7c5e746ea4 Properly disable the notification and push APIs (fixes issue #2951) 2020-07-20 14:53:45 -04:00
Marshall Greenblatt
149ccf946f Fix shutdown crash in InitNetworkContext with multi-threaded message loop (fixes issue #2985) 2020-07-20 14:03:15 -04:00
Marshall Greenblatt
3f2c37255f Update to Chromium version 84.0.4147.89 2020-07-17 19:12:13 -04:00
Marshall Greenblatt
7077b0efe1 Expose MediaSink device ip/port and model name (see issue #2900) 2020-07-14 17:04:39 -04:00
Marshall Greenblatt
1812f94ebd Windows: Explicitly specify the SDK version in setup_toolchain.py
Avoid building with a new and untested SDK version. See
https://crbug.com/1089996 for background.
2020-07-13 16:23:44 -04:00
Marshall Greenblatt
c551bc2695 Make chrome://chrome-urls an alias for chrome://webui-hosts (fixes issue #2977) 2020-07-02 15:45:50 -04:00
Marshall Greenblatt
f7c90a6bb2 Fix decoding of resources (fixes issue #2966)
Use LoadDataResourceString instead of GetDataResource. It will perform
decoding if necessary.
2020-07-02 14:50:25 -04:00
lwttai.lu
08c49aa624 Windows: File dialog add filter with all supported extensions as default (see issue #860) 2020-06-30 14:48:19 -04:00
Cristian Amarie
2fef70b664 Fix crash when reading malformed Flash manifest file (fixes issue #2948) 2020-06-30 14:48:13 -04:00
Marshall Greenblatt
48637c687c Windows: Fix CefCookieVisitor crash on invalid date (fixes issue #2927) 2020-06-30 14:35:41 -04:00
Mike Wiedenbauer
d808850d4e Fix decoding of the DevTools remote debugging discovery page (fixes issue #2974) 2020-06-30 10:45:41 -04:00
Marshall Greenblatt
0fb8a5f1ea Add support for direct DevTools protocol messaging (fixes issue #2961).
This change allows the client to directly send and receive DevTools
protocol messages (send method calls, and receive method results and
events) without requiring a DevTools front-end or remote-debugging
session.

This change includes additional supporting changes:
- Add a new CefRequestHandler::OnDocumentAvailableInMainFrame
  callback (see issue #1454).
- Add a CefParseJSON variant that accepts a UTF8-encoded buffer.
- Add a `--devtools-protocol-log-file=<path>` command-line flag for
  logging protocol messages sent to/from the DevTools front-end
  while it is displayed. This is useful for understanding existing
  DevTools protocol usage.
- Add a new "libcef_static_unittests" executable target to support
  light-weight unit tests of libcef_static internals (e.g. without
  requiring exposure via the CEF API). Files to be unittested are
  placed in the new "libcef_static_unittested" source_set which is
  then included by both the existing libcef_static library and the
  new unittests executable target.
- Linux: Remove use_bundled_fontconfig=false, which is no longer
  required and causes unittest build errors (see issue #2424).

This change also adds a cefclient demo for configuring offline mode
using the DevTools protocol (fixes issue #245). This is controlled
by the "Offline mode" context menu option and the `--offline`
command-line switch which will launch cefclient in offline mode. When
cefclient is offline all network requests will fail with
ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when
called from JavaScript in any frame. This mode is per-browser so
newly created browser windows will have the default mode. Note that
configuring offline mode in this way will not update the Network tab
UI ("Throtting" option) in a displayed DevTools front-end instance.
2020-06-19 22:17:11 -04:00
Marshall Greenblatt
98e6450272 Update to Chromium version 84.0.4147.38 2020-06-11 16:44:33 -04:00
409 changed files with 6180 additions and 11885 deletions

170
BUILD.gn
View File

@@ -122,8 +122,8 @@ if (is_linux) {
import("//third_party/fontconfig/fontconfig.gni")
}
if (is_mac) {
import("//build/apple/tweak_info_plist.gni")
import("//build/config/mac/rules.gni")
import("//build/mac/tweak_info_plist.gni")
import("//build/util/version.gni")
import("//media/cdm/library_cdm/cdm_paths.gni")
import("//build/config/mac/base_rules.gni")
@@ -407,20 +407,6 @@ test("libcef_static_unittests") {
static_library("libcef_static") {
sources = includes_common +
gypi_paths.autogen_cpp_includes + [
"libcef/browser/alloy/alloy_browser_context.cc",
"libcef/browser/alloy/alloy_browser_context.h",
"libcef/browser/alloy/alloy_browser_main.cc",
"libcef/browser/alloy/alloy_browser_main.h",
"libcef/browser/alloy/browser_platform_delegate_alloy.cc",
"libcef/browser/alloy/browser_platform_delegate_alloy.h",
"libcef/browser/alloy/chrome_browser_process_alloy.cc",
"libcef/browser/alloy/chrome_browser_process_alloy.h",
"libcef/browser/alloy/chrome_profile_manager_alloy.cc",
"libcef/browser/alloy/chrome_profile_manager_alloy.h",
"libcef/browser/alloy/chrome_profile_alloy.cc",
"libcef/browser/alloy/chrome_profile_alloy.h",
"libcef/browser/alloy/alloy_content_browser_client.cc",
"libcef/browser/alloy/alloy_content_browser_client.h",
"libcef/browser/audio_capturer.cc",
"libcef/browser/audio_capturer.h",
"libcef/browser/browser_context.cc",
@@ -433,6 +419,8 @@ static_library("libcef_static") {
"libcef/browser/browser_info.h",
"libcef/browser/browser_info_manager.cc",
"libcef/browser/browser_info_manager.h",
"libcef/browser/browser_main.cc",
"libcef/browser/browser_main.h",
"libcef/browser/browser_message_filter.cc",
"libcef/browser/browser_message_filter.h",
"libcef/browser/browser_message_loop.cc",
@@ -442,15 +430,15 @@ static_library("libcef_static") {
"libcef/browser/browser_platform_delegate_create.cc",
"libcef/browser/browser_util.cc",
"libcef/browser/browser_util.h",
"libcef/browser/chrome/browser_platform_delegate_chrome.cc",
"libcef/browser/chrome/browser_platform_delegate_chrome.h",
"libcef/browser/chrome/chrome_browser_context.cc",
"libcef/browser/chrome/chrome_browser_context.h",
"libcef/browser/chrome/chrome_browser_main_extra_parts_cef.cc",
"libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h",
"libcef/browser/chrome/chrome_content_browser_client_cef.cc",
"libcef/browser/chrome/chrome_content_browser_client_cef.h",
"libcef/browser/chrome_browser_process_stub.cc",
"libcef/browser/chrome_browser_process_stub.h",
"libcef/browser/chrome_crash_reporter_client_stub.cc",
"libcef/browser/chrome_profile_manager_stub.cc",
"libcef/browser/chrome_profile_manager_stub.h",
"libcef/browser/chrome_profile_stub.cc",
"libcef/browser/chrome_profile_stub.h",
"libcef/browser/content_browser_client.cc",
"libcef/browser/content_browser_client.h",
"libcef/browser/context.cc",
"libcef/browser/context.h",
"libcef/browser/context_menu_params_impl.cc",
@@ -520,13 +508,9 @@ static_library("libcef_static") {
"libcef/browser/frame_host_impl.h",
"libcef/browser/image_impl.cc",
"libcef/browser/image_impl.h",
"libcef/browser/iothread_state.cc",
"libcef/browser/iothread_state.h",
"libcef/browser/javascript_dialog_runner.h",
"libcef/browser/javascript_dialog_manager.cc",
"libcef/browser/javascript_dialog_manager.h",
"libcef/browser/main_runner.cc",
"libcef/browser/main_runner.h",
"libcef/browser/media_capture_devices_dispatcher.cc",
"libcef/browser/media_capture_devices_dispatcher.h",
"libcef/browser/media_router/media_route_impl.cc",
@@ -617,6 +601,8 @@ static_library("libcef_static") {
"libcef/browser/printing/print_view_manager.cc",
"libcef/browser/printing/print_view_manager.h",
"libcef/browser/process_util_impl.cc",
"libcef/browser/resource_context.cc",
"libcef/browser/resource_context.h",
"libcef/browser/request_context_handler_map.cc",
"libcef/browser/request_context_handler_map.h",
"libcef/browser/request_context_impl.cc",
@@ -650,14 +636,6 @@ static_library("libcef_static") {
"libcef/browser/xml_reader_impl.h",
"libcef/browser/zip_reader_impl.cc",
"libcef/browser/zip_reader_impl.h",
"libcef/common/alloy/alloy_content_client.cc",
"libcef/common/alloy/alloy_content_client.h",
"libcef/common/alloy/alloy_main_delegate.cc",
"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",
@@ -665,14 +643,10 @@ 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",
"libcef/common/chrome/chrome_main_runner_delegate.h",
"libcef/common/command_line_impl.cc",
"libcef/common/command_line_impl.h",
"libcef/common/content_client.cc",
"libcef/common/content_client.h",
"libcef/common/crash_reporter_client.cc",
"libcef/common/crash_reporter_client.h",
"libcef/common/crash_reporting.cc",
@@ -691,8 +665,8 @@ static_library("libcef_static") {
"libcef/common/frame_util.cc",
"libcef/common/frame_util.h",
"libcef/common/json_impl.cc",
"libcef/common/main_runner_delegate.h",
"libcef/common/main_runner_handler.h",
"libcef/common/main_delegate.cc",
"libcef/common/main_delegate.h",
"libcef/common/net/http_header_utils.cc",
"libcef/common/net/http_header_utils.h",
"libcef/common/net/net_resource_provider.cc",
@@ -714,8 +688,6 @@ static_library("libcef_static") {
"libcef/common/resource_bundle_delegate.h",
"libcef/common/resource_bundle_impl.cc",
"libcef/common/resource_bundle_impl.h",
"libcef/common/resource_util.cc",
"libcef/common/resource_util.h",
"libcef/common/response_impl.cc",
"libcef/common/response_impl.h",
"libcef/common/response_manager.cc",
@@ -729,8 +701,6 @@ static_library("libcef_static") {
"libcef/common/task_impl.cc",
"libcef/common/task_runner_impl.cc",
"libcef/common/task_runner_impl.h",
"libcef/common/task_runner_manager.cc",
"libcef/common/task_runner_manager.h",
"libcef/common/test/translator_test_impl.cc",
"libcef/common/thread_impl.cc",
"libcef/common/thread_impl.h",
@@ -747,12 +717,10 @@ static_library("libcef_static") {
"libcef/common/waitable_event_impl.h",
"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",
"libcef/renderer/browser_impl.h",
"libcef/renderer/content_renderer_client.cc",
"libcef/renderer/content_renderer_client.h",
"libcef/renderer/dom_document_impl.cc",
"libcef/renderer/dom_document_impl.h",
"libcef/renderer/dom_node_impl.cc",
@@ -778,10 +746,6 @@ static_library("libcef_static") {
"libcef/renderer/url_loader_throttle_provider_impl.h",
"libcef/renderer/v8_impl.cc",
"libcef/renderer/v8_impl.h",
# For Chrome runtime support.
"//chrome/app/chrome_main_delegate.cc",
"//chrome/app/chrome_main_delegate.h",
]
configs += [
@@ -808,6 +772,7 @@ static_library("libcef_static") {
deps = [
":cef_make_headers",
":cef_service_manifests",
":libcef_static_unittested",
@@ -823,13 +788,12 @@ static_library("libcef_static") {
"//base:base_static",
"//base/third_party/dynamic_annotations",
"//cc",
"//chrome:browser_dependencies",
"//chrome:child_dependencies",
"//chrome:packed_resources",
"//chrome:resources",
"//chrome:strings",
"//chrome/common:buildflags",
"//chrome/browser",
"//chrome/child",
"//chrome/common",
"//chrome/renderer",
"//chrome/services/printing:lib",
"//chrome/utility",
"//components/cdm/renderer",
"//components/certificate_transparency",
"//components/content_settings/core/browser",
@@ -840,7 +804,7 @@ static_library("libcef_static") {
"//components/keyed_service/content:content",
"//components/keyed_service/core:core",
"//components/navigation_interception",
"//components/network_session_configurator/common",
"//components/network_session_configurator/browser",
"//components/pdf/browser",
"//components/pdf/renderer",
"//components/plugins/renderer",
@@ -915,7 +879,7 @@ static_library("libcef_static") {
if (is_win) {
sources += includes_win + [
"libcef/browser/alloy/alloy_browser_main_win.cc",
"libcef/browser/browser_main_win.cc",
"libcef/browser/native/browser_platform_delegate_native_win.cc",
"libcef/browser/native/browser_platform_delegate_native_win.h",
"libcef/browser/native/file_dialog_runner_win.cc",
@@ -1004,10 +968,6 @@ static_library("libcef_static") {
"libcef/browser/osr/browser_platform_delegate_osr_mac.mm",
"libcef/common/util_mac.h",
"libcef/common/util_mac.mm",
# For Chrome runtime support.
"//chrome/app/chrome_main_mac.h",
"//chrome/app/chrome_main_mac.mm",
]
}
@@ -1166,6 +1126,7 @@ static_library("libcef_static") {
sources += [
# Support for UI input events.
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/ui_controls_factory_aurax11.cc",
"//ui/aura/test/x11_event_sender.cc",
"//ui/aura/test/x11_event_sender.h",
# Part of //ui/views:test_support which is testingonly.
@@ -1237,7 +1198,7 @@ if (is_win) {
sources = [ "libcef_dll/sandbox/sandbox_win.cc" ]
# CEF sources use include paths relative to the CEF root directory.
include_dirs = [ "." ]
deps = [ "libcef/features", "//sandbox" ]
deps = [ "//sandbox" ]
}
}
@@ -1250,6 +1211,56 @@ if (is_mac) {
}
}
#
# Service manifests.
#
source_set("cef_content_browser_overlay_manifest") {
sources = [
"libcef/common/service_manifests/cef_content_browser_overlay_manifest.cc",
"libcef/common/service_manifests/cef_content_browser_overlay_manifest.h",
]
configs += [
"libcef/features:config"
]
deps = [
"//base",
"//extensions/buildflags",
"//extensions/common:mojom",
"//extensions/common/api:mojom",
"//services/service_manager/public/cpp",
"//third_party/blink/public/common",
]
}
source_set("cef_content_renderer_overlay_manifest") {
sources = [
"libcef/common/service_manifests/cef_content_renderer_overlay_manifest.h",
]
configs += [
"libcef/features:config"
]
deps = [
"//base",
"//components/subresource_filter/content/mojom",
"//extensions/buildflags",
"//extensions/common:mojom",
"//services/service_manager/public/cpp",
"//third_party/blink/public/common",
]
}
source_set("cef_service_manifests") {
public_deps = [
":cef_content_browser_overlay_manifest",
":cef_content_renderer_overlay_manifest",
]
}
#
# Resource grit/pack targets.
#
@@ -1318,15 +1329,13 @@ repack("pak_devtools") {
# Add associated .h files in the make_pack_header("resources") target.
sources = [
"$root_gen_dir/content/browser/devtools/devtools_resources.pak",
"$root_gen_dir/third_party/blink/public/resources/inspector_overlay_resources.pak",
]
# Use public_deps so that generated grit headers are discoverable from
# the libcef_static target. Grit deps that generate .cc files must be
# listed both here and in the libcef_static target.
public_deps = [
"//content/browser/devtools:devtools_resources",
"//third_party/blink/public:devtools_inspector_resources",
"//content/browser/devtools:resources",
]
output = "$root_out_dir/devtools_resources.pak"
@@ -1410,7 +1419,6 @@ repack("pak") {
"$root_gen_dir/chrome/browser_resources.pak",
"$root_gen_dir/chrome/dev_ui_browser_resources.pak",
"$root_gen_dir/chrome/net_internals_resources.pak",
"$root_gen_dir/chrome/print_preview_pdf_resources.pak",
"$root_gen_dir/chrome/print_preview_resources.pak",
"$root_gen_dir/chrome/common_resources.pak",
"$root_gen_dir/components/components_resources.pak",
@@ -1430,7 +1438,6 @@ repack("pak") {
"//chrome/browser:dev_ui_browser_resources",
"//chrome/browser:resources",
"//chrome/browser/resources/net_internals:net_internals_resources",
"//chrome/browser/resources:print_preview_pdf_resources",
"//chrome/browser/resources:print_preview_resources",
"//chrome/common:resources",
"//components/resources:components_resources",
@@ -1483,8 +1490,6 @@ make_pack_header("resources") {
"$root_gen_dir/chrome/grit/component_extension_resources.h",
"$root_gen_dir/chrome/grit/dev_ui_browser_resources.h",
"$root_gen_dir/chrome/grit/net_internals_resources.h",
"$root_gen_dir/chrome/grit/print_preview_pdf_resources.h",
"$root_gen_dir/chrome/grit/print_preview_resources.h",
"$root_gen_dir/chrome/grit/renderer_resources.h",
"$root_gen_dir/components/grit/components_resources.h",
"$root_gen_dir/components/grit/dev_ui_components_resources.h",
@@ -1512,7 +1517,6 @@ make_pack_header("strings") {
"$root_gen_dir/chrome/grit/generated_resources.h",
"$root_gen_dir/chrome/grit/locale_settings.h",
"$root_gen_dir/chrome/grit/platform_locale_settings.h",
"$root_gen_dir/components/strings/grit/components_chromium_strings.h",
"$root_gen_dir/components/strings/grit/components_strings.h",
"$root_gen_dir/extensions/strings/grit/extensions_strings.h",
"$root_gen_dir/services/strings/grit/services_strings.h",
@@ -1687,6 +1691,10 @@ if (is_mac) {
gypi_paths2.libcef_sources_common +
gypi_paths.autogen_library_side
# TODO(rsesek): Handle these missing pieces:
# - crash_inspector
# - crash_report_sender.app
deps = [
":cef_framework_angle_library",
":cef_framework_locales",
@@ -1887,8 +1895,8 @@ if (is_mac) {
deps += invoker.deps
}
if (defined(invoker.frameworks)) {
frameworks = invoker.frameworks
if (defined(invoker.libs)) {
libs = invoker.libs
}
if (defined(invoker.defines)) {
@@ -1972,7 +1980,7 @@ if (is_mac) {
":cefclient_resources_bundle_data_english",
":cefclient_xibs",
]
frameworks = [
libs = [
"AppKit.framework",
"OpenGL.framework",
]
@@ -2036,7 +2044,7 @@ if (is_mac) {
":cefsimple_resources_bundle_data_english",
":cefsimple_xibs",
]
frameworks = [
libs = [
"AppKit.framework",
]
defines = [
@@ -2107,7 +2115,7 @@ if (is_mac) {
":ceftests_xibs",
"//testing/gtest",
]
frameworks = [
libs = [
"AppKit.framework",
]
defines = [

View File

@@ -7,6 +7,6 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/86.0.4240.198',
'depot_tools_checkout': '5dba9c97fb'
'chromium_checkout': 'refs/tags/84.0.4147.105',
'depot_tools_checkout': '233589f2e7'
}

View File

@@ -27,6 +27,8 @@
# Files in the chromium/src directory that should be evaluated for changes.
# Similar changes may need to be applied to the CEF source code.
'files': [
'chrome/app/chrome_*_manifest.*',
'chrome/app/chrome_*_manifests.*',
'chrome/browser/browser_process.h',
'chrome/browser/extensions/api/tabs/tabs_api.*',
'chrome/browser/extensions/chrome_component_extension_resource_manager.*',

View File

@@ -470,7 +470,6 @@
'tests/ceftests/browser_info_map_unittest.cc',
'tests/ceftests/command_line_unittest.cc',
'tests/ceftests/cookie_unittest.cc',
'tests/ceftests/cors_unittest.cc',
'tests/ceftests/devtools_message_unittest.cc',
'tests/ceftests/dialog_unittest.cc',
'tests/ceftests/display_unittest.cc',
@@ -521,11 +520,6 @@
'tests/ceftests/task_unittest.cc',
'tests/ceftests/test_handler.cc',
'tests/ceftests/test_handler.h',
'tests/ceftests/test_request.cc',
'tests/ceftests/test_request.h',
'tests/ceftests/test_server.cc',
'tests/ceftests/test_server.h',
'tests/ceftests/test_server_unittest.cc',
'tests/ceftests/test_suite.cc',
'tests/ceftests/test_suite.h',
'tests/ceftests/test_util.cc',
@@ -534,7 +528,6 @@
'tests/ceftests/thread_helper.h',
'tests/ceftests/thread_unittest.cc',
'tests/ceftests/tracing_unittest.cc',
'tests/ceftests/track_callback.h',
'tests/ceftests/translator_unittest.cc',
'tests/ceftests/urlrequest_unittest.cc',
'tests/ceftests/v8_unittest.cc',
@@ -594,15 +587,10 @@
'tests/ceftests/urlrequest_unittest.cc',
'tests/ceftests/test_handler.cc',
'tests/ceftests/test_handler.h',
'tests/ceftests/test_request.cc',
'tests/ceftests/test_request.h',
'tests/ceftests/test_server.cc',
'tests/ceftests/test_server.h',
'tests/ceftests/test_suite.cc',
'tests/ceftests/test_suite.h',
'tests/ceftests/test_util.cc',
'tests/ceftests/test_util.h',
'tests/ceftests/track_callback.h',
'tests/ceftests/thread_helper.cc',
'tests/ceftests/thread_helper.h',
'tests/ceftests/thread_unittest.cc',

View File

@@ -34,7 +34,6 @@ template("_repack_one_locale") {
"${root_gen_dir}/chrome/generated_resources_${locale}.pak",
"${root_gen_dir}/chrome/locale_settings_${locale}.pak",
"${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak",
"${root_gen_dir}/components/strings/components_chromium_strings_${locale}.pak",
"${root_gen_dir}/components/strings/components_locale_settings_${locale}.pak",
"${root_gen_dir}/components/strings/components_strings_${locale}.pak",
"${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak",
@@ -53,7 +52,6 @@ template("_repack_one_locale") {
"//chrome/app:generated_resources",
"//chrome/app/resources:locale_settings",
"//chrome/app/resources:platform_locale_settings",
"//components/strings:components_chromium_strings",
"//components/strings:components_locale_settings",
"//components/strings:components_strings",
"//extensions/strings",

View File

@@ -25,7 +25,7 @@ macro(PRINT_CEF_CONFIG)
message(STATUS "Binary distribution root: ${_CEF_ROOT}")
if(OS_MAC)
if(OS_MACOSX)
message(STATUS "Base SDK: ${CMAKE_OSX_SYSROOT}")
message(STATUS "Target SDK: ${CEF_TARGET_SDK}")
endif()
@@ -75,8 +75,8 @@ macro(APPEND_PLATFORM_SOURCES name_of_list)
if(OS_WINDOWS AND ${name_of_list}_WINDOWS)
list(APPEND ${name_of_list} ${${name_of_list}_WINDOWS})
endif()
if(OS_MAC AND ${name_of_list}_MAC)
list(APPEND ${name_of_list} ${${name_of_list}_MAC})
if(OS_MACOSX AND ${name_of_list}_MACOSX)
list(APPEND ${name_of_list} ${${name_of_list}_MACOSX})
endif()
endmacro()
@@ -184,10 +184,10 @@ endif(OS_LINUX)
# Mac OS X macros.
#
if(OS_MAC)
if(OS_MACOSX)
# Manually process and copy over resource files.
macro(COPY_MAC_RESOURCES resource_list prefix_list target source_dir app_path)
macro(COPY_MACOSX_RESOURCES resource_list prefix_list target source_dir app_path)
foreach(FILENAME ${resource_list})
# Remove one or more prefixes from the source paths.
set(TARGET_FILENAME "${FILENAME}")
@@ -229,7 +229,7 @@ macro(COPY_MAC_RESOURCES resource_list prefix_list target source_dir app_path)
endforeach()
endmacro()
endif(OS_MAC)
endif(OS_MACOSX)
#
@@ -298,7 +298,7 @@ macro(SET_COMMON_TARGET_PROPERTIES target)
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
endif()
if(OS_MAC)
if(OS_MACOSX)
# Set Xcode target properties.
set_target_properties(${target} PROPERTIES
XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO

View File

@@ -14,8 +14,7 @@ endif()
# Determine the platform.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(OS_MAC 1)
set(OS_MACOSX 1) # For backwards compatibility.
set(OS_MACOSX 1)
set(OS_POSIX 1)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(OS_LINUX 1)
@@ -32,7 +31,7 @@ if(NOT DEFINED PROJECT_ARCH)
set(PROJECT_ARCH "x86")
endif()
if(OS_MAC)
if(OS_MACOSX)
# PROJECT_ARCH should be specified on Mac OS X.
message(WARNING "No PROJECT_ARCH value specified, using ${PROJECT_ARCH}")
endif()
@@ -247,7 +246,7 @@ endif()
# Mac OS X configuration.
#
if(OS_MAC)
if(OS_MACOSX)
# Platform-specific compiler/linker flags.
# See also Xcode target properties in cef_macros.cmake.
set(CEF_LIBTYPE SHARED)

View File

@@ -180,7 +180,7 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
#include "include/base/internal/cef_atomicops_x86_msvc.h"
#elif defined(OS_WIN) && (defined(__ARM_ARCH_ISA_A64) || defined(_M_ARM64))
#include "include/base/internal/cef_atomicops_arm64_msvc.h"
#elif defined(OS_MAC)
#elif defined(OS_MACOSX)
#include "include/base/internal/cef_atomicops_mac.h"
#elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)
#include "include/base/internal/cef_atomicops_x86_gcc.h"
@@ -194,7 +194,7 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
// On some platforms we need additional declarations to make
// AtomicWord compatible with our other Atomic* types.
#if defined(OS_MAC) || defined(OS_OPENBSD)
#if defined(OS_MACOSX) || defined(OS_OPENBSD)
#include "include/base/internal/cef_atomicops_atomicword_compat.h"
#endif

View File

@@ -42,7 +42,7 @@
//
// On Mac OS X, |long long| is used for 64-bit types for compatibility with
// <inttypes.h> format macros even in the LP64 model.
#if defined(__LP64__) && !defined(OS_MAC) && !defined(OS_OPENBSD)
#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
typedef long int64;
typedef unsigned long uint64;
#else

View File

@@ -44,14 +44,6 @@
#define OS_WIN 1
#endif
#elif defined(__APPLE__)
// New platform defines after https://crbug.com/1105907.
#ifndef OS_MAC
#define OS_MAC 1
#endif
#ifndef OS_APPLE
#define OS_APPLE 1
#endif
// Old platform defines retained for backwards compatibility.
#ifndef OS_MACOSX
#define OS_MACOSX 1
#endif
@@ -65,7 +57,7 @@
// For access to standard POSIXish features, use OS_POSIX instead of a
// more specific macro.
#if defined(OS_MAC) || defined(OS_LINUX)
#if defined(OS_MACOSX) || defined(OS_LINUX)
#ifndef OS_POSIX
#define OS_POSIX 1
#endif

View File

@@ -136,11 +136,7 @@
#define CEF_INCLUDE_BASE_CEF_LOGGING_H_
#pragma once
#if defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "base/logging.h"
#include "base/notreached.h"
#elif defined(DCHECK)
#if defined(DCHECK)
// Do nothing if the macros provided by this header already exist.
// This can happen in cases where Chromium code is used directly by the
// client application. When using Chromium code directly always include
@@ -153,7 +149,10 @@
#define DCHECK_IS_ON() true
#endif
#else // !defined(DCHECK)
#elif defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "base/logging.h"
#else // !USING_CHROMIUM_INCLUDES
// The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be
// updated to match.

View File

@@ -250,11 +250,11 @@ class WeakPtr : public cef_internal::WeakPtrBase {
T* get() const { return ref_.is_valid() ? ptr_ : NULL; }
T& operator*() const {
CHECK(ref_.is_valid());
DCHECK(get() != NULL);
return *get();
}
T* operator->() const {
CHECK(ref_.is_valid());
DCHECK(get() != NULL);
return get();
}

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=306236316b35037523ca566068d133755bce48fd$
// $hash=b15ba2c750f5227b6b40fea59965817ba4431ee0$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
@@ -78,6 +78,17 @@ typedef struct _cef_browser_process_handler_t {
struct _cef_browser_process_handler_t* self,
struct _cef_command_line_t* command_line);
///
// Called on the browser process IO thread after the main thread has been
// created for a new render process. Provides an opportunity to specify extra
// information that will be passed to
// cef_render_process_handler_t::on_render_thread_created() in the render
// process. Do not keep a reference to |extra_info| outside of this function.
///
void(CEF_CALLBACK* on_render_process_thread_created)(
struct _cef_browser_process_handler_t* self,
struct _cef_list_value_t* extra_info);
///
// Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform.

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=4f4a0d76efaf87055ebf5e784f5d1b69fafdabc2$
// $hash=9d5077fdb3fe7fa0ff1141f839988ac821eba4bf$
//
#ifndef CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
@@ -247,6 +247,11 @@ typedef struct _cef_media_sink_t {
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_sink_t* self);
///
// Returns true (1) if this sink is valid.
///
int(CEF_CALLBACK* is_valid)(struct _cef_media_sink_t* self);
///
// Returns the name of this sink.
///
@@ -327,6 +332,11 @@ typedef struct _cef_media_source_t {
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_source_t* self);
///
// Returns true (1) if this source is valid.
///
int(CEF_CALLBACK* is_valid)(struct _cef_media_source_t* self);
///
// Returns true (1) if this source outputs its content via Cast.
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=8419eb3eba9dd372b019bd367d4f195433b21c9b$
// $hash=3630a82a4ea731b43ed4ba468a57c5dfe15f8679$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_
@@ -64,6 +64,16 @@ typedef struct _cef_render_process_handler_t {
///
cef_base_ref_counted_t base;
///
// Called after the render process main thread has been created. |extra_info|
// is a read-only value originating from
// cef_browser_process_handler_t::on_render_process_thread_created(). Do not
// keep a reference to |extra_info| outside of this function.
///
void(CEF_CALLBACK* on_render_thread_created)(
struct _cef_render_process_handler_t* self,
struct _cef_list_value_t* extra_info);
///
// Called after WebKit has been initialized.
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=75f4f7a9ff628a6ae699a697722caa5d49546784$
// $hash=63d875f5a922dd2c2e1efaaf0ddaa20475f79ef8$
//
#ifndef CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_
@@ -115,13 +115,20 @@ typedef struct _cef_urlrequest_t {
// Create a new URL request that is not associated with a specific browser or
// frame. Use cef_frame_t::CreateURLRequest instead if you want the request to
// have this association, in which case it may be handled differently (see
// documentation on that function). A request created with this function may
// only originate from the browser process, and will behave as follows:
// documentation on that function). Requests may originate from the both browser
// process and the render process.
//
// For requests originating from the browser process:
// - It may be intercepted by the client via CefResourceRequestHandler or
// CefSchemeHandlerFactory.
// - POST data may only contain only a single element of type PDE_TYPE_FILE
// or PDE_TYPE_BYTES.
// - If |request_context| is empty the global request context will be used.
// For requests originating from the render process:
// - It cannot be intercepted by the client so only http(s) and blob schemes
// are supported.
// - POST data may only contain a single element of type PDE_TYPE_BYTES.
// - The |request_context| parameter must be NULL.
//
// The |request| object will be marked as read-only after calling this function.
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=652ac7a90c6cd10b1cbc6ae99a549c03f36c794e$
// $hash=422243fda6e1404222aca7bdd4e7b84b961a9626$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_DISPLAY_CAPI_H_
@@ -50,9 +50,9 @@ extern "C" {
// This structure typically, but not always, corresponds to a physical display
// connected to the system. A fake Display may exist on a headless system, or a
// Display may correspond to a remote, virtual display. All size and position
// values are in density independent pixel (DIP) coordinates unless otherwise
// indicated. Methods must be called on the browser process UI thread unless
// otherwise indicated.
// values are in density independent pixels (DIP) unless otherwise indicated.
// Methods must be called on the browser process UI thread unless otherwise
// indicated.
///
typedef struct _cef_display_t {
///
@@ -74,28 +74,27 @@ typedef struct _cef_display_t {
float(CEF_CALLBACK* get_device_scale_factor)(struct _cef_display_t* self);
///
// Convert |point| from DIP coordinates to pixel coordinates using this
// Display's device scale factor.
// Convert |point| from density independent pixels (DIP) to pixel coordinates
// using this Display's device scale factor.
///
void(CEF_CALLBACK* convert_point_to_pixels)(struct _cef_display_t* self,
cef_point_t* point);
///
// Convert |point| from pixel coordinates to DIP coordinates using this
// Display's device scale factor.
// Convert |point| from pixel coordinates to density independent pixels (DIP)
// using this Display's device scale factor.
///
void(CEF_CALLBACK* convert_point_from_pixels)(struct _cef_display_t* self,
cef_point_t* point);
///
// Returns this Display's bounds in DIP screen coordinates. This is the full
// size of the display.
// Returns this Display's bounds. This is the full size of the display.
///
cef_rect_t(CEF_CALLBACK* get_bounds)(struct _cef_display_t* self);
///
// Returns this Display's work area in DIP screen coordinates. This excludes
// areas of the display that are occupied with window manager toolbars, etc.
// Returns this Display's work area. This excludes areas of the display that
// are occupied for window manager toolbars, etc.
///
cef_rect_t(CEF_CALLBACK* get_work_area)(struct _cef_display_t* self);
@@ -112,7 +111,7 @@ CEF_EXPORT cef_display_t* cef_display_get_primary();
///
// Returns the Display nearest |point|. Set |input_pixel_coords| to true (1) if
// |point| is in pixel screen coordinates instead of DIP screen coordinates.
// |point| is in pixel coordinates instead of density independent pixels (DIP).
///
CEF_EXPORT cef_display_t* cef_display_get_nearest_point(
const cef_point_t* point,
@@ -120,8 +119,8 @@ CEF_EXPORT cef_display_t* cef_display_get_nearest_point(
///
// Returns the Display that most closely intersects |bounds|. Set
// |input_pixel_coords| to true (1) if |bounds| is in pixel screen coordinates
// instead of DIP screen coordinates.
// |input_pixel_coords| to true (1) if |bounds| is in pixel coordinates instead
// of density independent pixels (DIP).
///
CEF_EXPORT cef_display_t* cef_display_get_matching_bounds(
const cef_rect_t* bounds,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=55be3e44016d9861bb8e9270b52f2bf45c8a53f5$
// $hash=45b421dfcf8ee7cf61b1991a336bc65d33fbe10a$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_
@@ -176,72 +176,64 @@ typedef struct _cef_view_t {
int id);
///
// Sets the bounds (size and position) of this View. |bounds| is in parent
// coordinates, or DIP screen coordinates if there is no parent.
// Sets the bounds (size and position) of this View. Position is in parent
// coordinates.
///
void(CEF_CALLBACK* set_bounds)(struct _cef_view_t* self,
const cef_rect_t* bounds);
///
// Returns the bounds (size and position) of this View in parent coordinates,
// or DIP screen coordinates if there is no parent.
// Returns the bounds (size and position) of this View. Position is in parent
// coordinates.
///
cef_rect_t(CEF_CALLBACK* get_bounds)(struct _cef_view_t* self);
///
// Returns the bounds (size and position) of this View in DIP screen
// Returns the bounds (size and position) of this View. Position is in screen
// coordinates.
///
cef_rect_t(CEF_CALLBACK* get_bounds_in_screen)(struct _cef_view_t* self);
///
// Sets the size of this View without changing the position. |size| in parent
// coordinates, or DIP screen coordinates if there is no parent.
// Sets the size of this View without changing the position.
///
void(CEF_CALLBACK* set_size)(struct _cef_view_t* self,
const cef_size_t* size);
///
// Returns the size of this View in parent coordinates, or DIP screen
// coordinates if there is no parent.
// Returns the size of this View.
///
cef_size_t(CEF_CALLBACK* get_size)(struct _cef_view_t* self);
///
// Sets the position of this View without changing the size. |position| is in
// parent coordinates, or DIP screen coordinates if there is no parent.
// parent coordinates.
///
void(CEF_CALLBACK* set_position)(struct _cef_view_t* self,
const cef_point_t* position);
///
// Returns the position of this View. Position is in parent coordinates, or
// DIP screen coordinates if there is no parent.
// Returns the position of this View. Position is in parent coordinates.
///
cef_point_t(CEF_CALLBACK* get_position)(struct _cef_view_t* self);
///
// Returns the size this View would like to be if enough space is available.
// Size is in parent coordinates, or DIP screen coordinates if there is no
// parent.
///
cef_size_t(CEF_CALLBACK* get_preferred_size)(struct _cef_view_t* self);
///
// Size this View to its preferred size. Size is in parent coordinates, or DIP
// screen coordinates if there is no parent.
// Size this View to its preferred size.
///
void(CEF_CALLBACK* size_to_preferred_size)(struct _cef_view_t* self);
///
// Returns the minimum size for this View. Size is in parent coordinates, or
// DIP screen coordinates if there is no parent.
// Returns the minimum size for this View.
///
cef_size_t(CEF_CALLBACK* get_minimum_size)(struct _cef_view_t* self);
///
// Returns the maximum size for this View. Size is in parent coordinates, or
// DIP screen coordinates if there is no parent.
// Returns the maximum size for this View.
///
cef_size_t(CEF_CALLBACK* get_maximum_size)(struct _cef_view_t* self);
@@ -335,21 +327,21 @@ typedef struct _cef_view_t {
cef_color_t(CEF_CALLBACK* get_background_color)(struct _cef_view_t* self);
///
// Convert |point| from this View's coordinate system to DIP screen
// coordinates. This View must belong to a Window when calling this function.
// Returns true (1) if the conversion is successful or false (0) otherwise.
// Use cef_display_t::convert_point_to_pixels() after calling this function if
// Convert |point| from this View's coordinate system to that of the screen.
// This View must belong to a Window when calling this function. Returns true
// (1) if the conversion is successful or false (0) otherwise. Use
// cef_display_t::convert_point_to_pixels() after calling this function if
// further conversion to display-specific pixel coordinates is desired.
///
int(CEF_CALLBACK* convert_point_to_screen)(struct _cef_view_t* self,
cef_point_t* point);
///
// Convert |point| to this View's coordinate system from DIP screen
// coordinates. This View must belong to a Window when calling this function.
// Returns true (1) if the conversion is successful or false (0) otherwise.
// Use cef_display_t::convert_point_from_pixels() before calling this function
// if conversion from display-specific pixel coordinates is necessary.
// Convert |point| to this View's coordinate system from that of the screen.
// This View must belong to a Window when calling this function. Returns true
// (1) if the conversion is successful or false (0) otherwise. Use
// cef_display_t::convert_point_from_pixels() before calling this function if
// conversion from display-specific pixel coordinates is necessary.
///
int(CEF_CALLBACK* convert_point_from_screen)(struct _cef_view_t* self,
cef_point_t* point);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=fee25d300df47c6143b935d0f99d543ea888f55c$
// $hash=a0cec778fbaf0b1f5c9b3ef75dc7bbeeba777a44$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
@@ -87,18 +87,6 @@ typedef struct _cef_window_delegate_t {
int* is_menu,
int* can_activate_menu);
///
// Return the initial bounds for |window| in density independent pixel (DIP)
// coordinates. If this function returns an NULL CefRect then
// get_preferred_size() will be called to retrieve the size, and the window
// will be placed on the screen with origin (0,0). This function can be used
// in combination with cef_view_t::get_bounds_in_screen() to restore the
// previous window bounds.
///
cef_rect_t(CEF_CALLBACK* get_initial_bounds)(
struct _cef_window_delegate_t* self,
struct _cef_window_t* window);
///
// Return true (1) if |window| should be created without a frame or title bar.
// The window will be resizable if can_resize() returns true (1). Use

View File

@@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "09d3d4f08869644fe3baa7a751de537f3446525b"
#define CEF_API_HASH_UNIVERSAL "63365efe2e93a4e7cc789cbb8f618d61c92c1b6d"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "3022db6736af26cc38158d38e22f74a51312a5c9"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "13e2e2451c2320f0d16b35ba53b3295409888dd8"
#define CEF_API_HASH_PLATFORM "726d42ca7d92188542b433d88d17a87af5b53c05"
#elif defined(OS_MACOSX)
#define CEF_API_HASH_PLATFORM "1c8a413434b592d388446e66b54a3f0bfc0d6fff"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "d781b815150795b0bce95d72ce967b508c9a04d5"
#define CEF_API_HASH_PLATFORM "13f7e0e86daab3b1a08d8a31103fc93e45cc508f"
#endif
#ifdef __cplusplus

View File

@@ -35,7 +35,7 @@
#include "include/cef_base.h"
#endif // __cplusplus
#if defined(OS_MAC) && defined(__OBJC__)
#if defined(OS_MACOSX) && defined(__OBJC__)
#ifdef USING_CHROMIUM_INCLUDES
@@ -105,6 +105,6 @@ class CefScopedSendingEvent {
#endif // __cplusplus
#endif // defined(OS_MAC) && defined(__OBJC__)
#endif // defined(OS_MACOSX) && defined(__OBJC__)
#endif // CEF_INCLUDE_CEF_APPLICATION_MAC_H_

View File

@@ -40,7 +40,7 @@
#include "include/internal/cef_types_wrappers.h"
#if defined(OS_WIN)
#include "include/internal/cef_win.h"
#elif defined(OS_MAC)
#elif defined(OS_MACOSX)
#include "include/internal/cef_mac.h"
#elif defined(OS_LINUX)
#include "include/internal/cef_linux.h"

View File

@@ -68,6 +68,17 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
virtual void OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line) {}
///
// Called on the browser process IO thread after the main thread has been
// created for a new render process. Provides an opportunity to specify extra
// information that will be passed to
// CefRenderProcessHandler::OnRenderThreadCreated() in the render process. Do
// not keep a reference to |extra_info| outside of this method.
///
/*--cef()--*/
virtual void OnRenderProcessThreadCreated(
CefRefPtr<CefListValue> extra_info) {}
///
// Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform.

View File

@@ -230,6 +230,12 @@ class CefMediaSink : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns true if this sink is valid.
///
/*--cef()--*/
virtual bool IsValid() = 0;
///
// Returns the name of this sink.
///
@@ -304,6 +310,12 @@ class CefMediaSource : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns true if this source is valid.
///
/*--cef()--*/
virtual bool IsValid() = 0;
///
// Returns true if this source outputs its content via Cast.
///

View File

@@ -57,6 +57,15 @@ class CefRenderProcessHandler : public virtual CefBaseRefCounted {
public:
typedef cef_navigation_type_t NavigationType;
///
// Called after the render process main thread has been created. |extra_info|
// is a read-only value originating from
// CefBrowserProcessHandler::OnRenderProcessThreadCreated(). Do not keep a
// reference to |extra_info| outside of this method.
///
/*--cef()--*/
virtual void OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info) {}
///
// Called after WebKit has been initialized.
///

View File

@@ -34,7 +34,7 @@
#include "include/base/cef_build.h"
#include "include/internal/cef_export.h"
#if defined(OS_MAC)
#if defined(OS_MACOSX)
#ifdef __cplusplus
extern "C" {
@@ -83,6 +83,6 @@ class CEF_EXPORT CefScopedSandboxContext {
};
#endif // __cplusplus
#endif // defined(OS_MAC)
#endif // defined(OS_MACOSX)
#endif // CEF_INCLUDE_CEF_SANDBOX_MAC_H_

View File

@@ -63,13 +63,20 @@ class CefURLRequest : public virtual CefBaseRefCounted {
// Create a new URL request that is not associated with a specific browser or
// frame. Use CefFrame::CreateURLRequest instead if you want the request to
// have this association, in which case it may be handled differently (see
// documentation on that method). A request created with this method may only
// originate from the browser process, and will behave as follows:
// documentation on that method). Requests may originate from the both browser
// process and the render process.
//
// For requests originating from the browser process:
// - It may be intercepted by the client via CefResourceRequestHandler or
// CefSchemeHandlerFactory.
// - POST data may only contain only a single element of type PDE_TYPE_FILE
// or PDE_TYPE_BYTES.
// - If |request_context| is empty the global request context will be used.
// For requests originating from the render process:
// - It cannot be intercepted by the client so only http(s) and blob schemes
// are supported.
// - POST data may only contain a single element of type PDE_TYPE_BYTES.
// - The |request_context| parameter must be NULL.
//
// The |request| object will be marked as read-only after calling this method.
///

View File

@@ -39,7 +39,7 @@
// Bring in platform-specific definitions.
#if defined(OS_WIN)
#include "include/internal/cef_types_win.h"
#elif defined(OS_MAC)
#elif defined(OS_MACOSX)
#include "include/internal/cef_types_mac.h"
#elif defined(OS_LINUX)
#include "include/internal/cef_types_linux.h"
@@ -192,13 +192,6 @@ typedef struct _cef_settings_t {
///
cef_string_t main_bundle_path;
///
// Set to true (1) to enable use of the Chrome runtime in CEF. This feature is
// considered experimental and is not recommended for most users at this time.
// See issue #2969 for details.
///
int chrome_runtime;
///
// Set to true (1) to have the browser process message loop run in a separate
// thread. If false (0) than the CefDoMessageLoopWork() function must be
@@ -1479,7 +1472,7 @@ typedef enum {
///
// The main thread in the renderer. Used for all WebKit and V8 interaction.
// Tasks may be posted to this thread after
// CefRenderProcessHandler::OnWebKitInitialized but are not guaranteed to
// CefRenderProcessHandler::OnRenderThreadCreated but are not guaranteed to
// run before sub-process termination (sub-processes may be killed at any time
// without warning).
///

View File

@@ -33,7 +33,7 @@
#include "include/base/cef_build.h"
#if defined(OS_MAC)
#if defined(OS_MACOSX)
#include "include/internal/cef_string.h"
// Handle types.
@@ -137,6 +137,6 @@ typedef struct _cef_window_info_t {
}
#endif
#endif // OS_MAC
#endif // OS_MACOSX
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_

View File

@@ -569,7 +569,6 @@ struct CefSettingsTraits {
&target->framework_dir_path, copy);
cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length,
&target->main_bundle_path, copy);
target->chrome_runtime = src->chrome_runtime;
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
target->external_message_pump = src->external_message_pump;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;

View File

@@ -46,9 +46,9 @@
// This class typically, but not always, corresponds to a physical display
// connected to the system. A fake Display may exist on a headless system, or a
// Display may correspond to a remote, virtual display. All size and position
// values are in density independent pixel (DIP) coordinates unless otherwise
// indicated. Methods must be called on the browser process UI thread unless
// otherwise indicated.
// values are in density independent pixels (DIP) unless otherwise indicated.
// Methods must be called on the browser process UI thread unless otherwise
// indicated.
///
/*--cef(source=library)--*/
class CefDisplay : public CefBaseRefCounted {
@@ -61,7 +61,8 @@ class CefDisplay : public CefBaseRefCounted {
///
// Returns the Display nearest |point|. Set |input_pixel_coords| to true if
// |point| is in pixel screen coordinates instead of DIP screen coordinates.
// |point| is in pixel coordinates instead of density independent pixels
// (DIP).
///
/*--cef()--*/
static CefRefPtr<CefDisplay> GetDisplayNearestPoint(const CefPoint& point,
@@ -69,8 +70,8 @@ class CefDisplay : public CefBaseRefCounted {
///
// Returns the Display that most closely intersects |bounds|. Set
// |input_pixel_coords| to true if |bounds| is in pixel screen coordinates
// instead of DIP screen coordinates.
// |input_pixel_coords| to true if |bounds| is in pixel coordinates instead of
// density independent pixels (DIP).
///
/*--cef()--*/
static CefRefPtr<CefDisplay> GetDisplayMatchingBounds(
@@ -107,29 +108,28 @@ class CefDisplay : public CefBaseRefCounted {
virtual float GetDeviceScaleFactor() = 0;
///
// Convert |point| from DIP coordinates to pixel coordinates using this
// Display's device scale factor.
// Convert |point| from density independent pixels (DIP) to pixel coordinates
// using this Display's device scale factor.
///
/*--cef()--*/
virtual void ConvertPointToPixels(CefPoint& point) = 0;
///
// Convert |point| from pixel coordinates to DIP coordinates using this
// Display's device scale factor.
// Convert |point| from pixel coordinates to density independent pixels (DIP)
// using this Display's device scale factor.
///
/*--cef()--*/
virtual void ConvertPointFromPixels(CefPoint& point) = 0;
///
// Returns this Display's bounds in DIP screen coordinates. This is the full
// size of the display.
// Returns this Display's bounds. This is the full size of the display.
///
/*--cef()--*/
virtual CefRect GetBounds() = 0;
///
// Returns this Display's work area in DIP screen coordinates. This excludes
// areas of the display that are occupied with window manager toolbars, etc.
// Returns this Display's work area. This excludes areas of the display that
// are occupied for window manager toolbars, etc.
///
/*--cef()--*/
virtual CefRect GetWorkArea() = 0;

View File

@@ -174,79 +174,71 @@ class CefView : public CefBaseRefCounted {
virtual CefRefPtr<CefView> GetViewForID(int id) = 0;
///
// Sets the bounds (size and position) of this View. |bounds| is in parent
// coordinates, or DIP screen coordinates if there is no parent.
// Sets the bounds (size and position) of this View. Position is in parent
// coordinates.
///
/*--cef()--*/
virtual void SetBounds(const CefRect& bounds) = 0;
///
// Returns the bounds (size and position) of this View in parent coordinates,
// or DIP screen coordinates if there is no parent.
// Returns the bounds (size and position) of this View. Position is in parent
// coordinates.
///
/*--cef()--*/
virtual CefRect GetBounds() = 0;
///
// Returns the bounds (size and position) of this View in DIP screen
// Returns the bounds (size and position) of this View. Position is in screen
// coordinates.
///
/*--cef()--*/
virtual CefRect GetBoundsInScreen() = 0;
///
// Sets the size of this View without changing the position. |size| in
// parent coordinates, or DIP screen coordinates if there is no parent.
// Sets the size of this View without changing the position.
///
/*--cef()--*/
virtual void SetSize(const CefSize& size) = 0;
///
// Returns the size of this View in parent coordinates, or DIP screen
// coordinates if there is no parent.
// Returns the size of this View.
///
/*--cef()--*/
virtual CefSize GetSize() = 0;
///
// Sets the position of this View without changing the size. |position| is in
// parent coordinates, or DIP screen coordinates if there is no parent.
// parent coordinates.
///
/*--cef()--*/
virtual void SetPosition(const CefPoint& position) = 0;
///
// Returns the position of this View. Position is in parent coordinates, or
// DIP screen coordinates if there is no parent.
// Returns the position of this View. Position is in parent coordinates.
///
/*--cef()--*/
virtual CefPoint GetPosition() = 0;
///
// Returns the size this View would like to be if enough space is available.
// Size is in parent coordinates, or DIP screen coordinates if there is no
// parent.
///
/*--cef()--*/
virtual CefSize GetPreferredSize() = 0;
///
// Size this View to its preferred size. Size is in parent coordinates, or
// DIP screen coordinates if there is no parent.
// Size this View to its preferred size.
///
/*--cef()--*/
virtual void SizeToPreferredSize() = 0;
///
// Returns the minimum size for this View. Size is in parent coordinates, or
// DIP screen coordinates if there is no parent.
// Returns the minimum size for this View.
///
/*--cef()--*/
virtual CefSize GetMinimumSize() = 0;
///
// Returns the maximum size for this View. Size is in parent coordinates, or
// DIP screen coordinates if there is no parent.
// Returns the maximum size for this View.
///
/*--cef()--*/
virtual CefSize GetMaximumSize() = 0;
@@ -353,9 +345,9 @@ class CefView : public CefBaseRefCounted {
virtual cef_color_t GetBackgroundColor() = 0;
///
// Convert |point| from this View's coordinate system to DIP screen
// coordinates. This View must belong to a Window when calling this method.
// Returns true if the conversion is successful or false otherwise. Use
// Convert |point| from this View's coordinate system to that of the screen.
// This View must belong to a Window when calling this method. Returns true
// if the conversion is successful or false otherwise. Use
// CefDisplay::ConvertPointToPixels() after calling this method if further
// conversion to display-specific pixel coordinates is desired.
///
@@ -363,9 +355,9 @@ class CefView : public CefBaseRefCounted {
virtual bool ConvertPointToScreen(CefPoint& point) = 0;
///
// Convert |point| to this View's coordinate system from DIP screen
// coordinates. This View must belong to a Window when calling this method.
// Returns true if the conversion is successful or false otherwise. Use
// Convert |point| to this View's coordinate system from that of the screen.
// This View must belong to a Window when calling this method. Returns true if
// the conversion is successful or false otherwise. Use
// CefDisplay::ConvertPointFromPixels() before calling this method if
// conversion from display-specific pixel coordinates is necessary.
///

View File

@@ -78,19 +78,6 @@ class CefWindowDelegate : public CefPanelDelegate {
return nullptr;
}
///
// Return the initial bounds for |window| in density independent pixel (DIP)
// coordinates. If this method returns an empty CefRect then
// GetPreferredSize() will be called to retrieve the size, and the window will
// be placed on the screen with origin (0,0). This method can be used in
// combination with CefView::GetBoundsInScreen() to restore the previous
// window bounds.
///
/*--cef()--*/
virtual CefRect GetInitialBounds(CefRefPtr<CefWindow> window) {
return CefRect();
}
///
// Return true if |window| should be created without a frame or title bar. The
// window will be resizable if CanResize() returns true. Use

View File

@@ -89,32 +89,6 @@ struct CefDeleteOnIOThread : public CefDeleteOnThread<TID_IO> {};
struct CefDeleteOnFileThread : public CefDeleteOnThread<TID_FILE> {};
struct CefDeleteOnRendererThread : public CefDeleteOnThread<TID_RENDERER> {};
// Same as IMPLEMENT_REFCOUNTING() but using the specified Destructor.
#define IMPLEMENT_REFCOUNTING_EX(ClassName, Destructor) \
public: \
void AddRef() const OVERRIDE { ref_count_.AddRef(); } \
bool Release() const OVERRIDE { \
if (ref_count_.Release()) { \
Destructor::Destruct(this); \
return true; \
} \
return false; \
} \
bool HasOneRef() const OVERRIDE { return ref_count_.HasOneRef(); } \
bool HasAtLeastOneRef() const OVERRIDE { \
return ref_count_.HasAtLeastOneRef(); \
} \
\
private: \
CefRefCount ref_count_
#define IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(ClassName) \
IMPLEMENT_REFCOUNTING_EX(ClassName, CefDeleteOnUIThread)
#define IMPLEMENT_REFCOUNTING_DELETE_ON_IOT(ClassName) \
IMPLEMENT_REFCOUNTING_EX(ClassName, CefDeleteOnIOThread)
///
// Helper class to manage a scoped copy of |argv|.
///

View File

@@ -56,7 +56,7 @@ int cef_unload_library();
#ifdef __cplusplus
}
#if defined(OS_MAC)
#if defined(OS_MACOSX)
///
// Scoped helper for loading and unloading the CEF framework library at
@@ -122,7 +122,7 @@ class CefScopedLibraryLoader {
DISALLOW_COPY_AND_ASSIGN(CefScopedLibraryLoader);
};
#endif // defined(OS_MAC)
#endif // defined(OS_MACOSX)
#endif // __cplusplus
#endif // CEF_INCLUDE_WRAPPER_CEF_LIBRARY_LOADER_H_

View File

@@ -1,456 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/alloy_browser_context.h"
#include <map>
#include <utility>
#include "libcef/browser/download_manager_delegate.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/ssl_host_state_delegate.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "chrome/browser/font_family_cache.h"
#include "chrome/browser/media/media_device_id_salt.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
#include "chrome/common/pref_names.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/core/simple_dependency_manager.h"
#include "components/keyed_service/core/simple_key_map.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/user_prefs/user_prefs.h"
#include "components/visitedlink/browser/visitedlink_event_listener.h"
#include "components/visitedlink/browser/visitedlink_writer.h"
#include "components/zoom/zoom_event_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/constants.h"
#include "net/proxy_resolution/proxy_config_service.h"
#include "services/network/public/mojom/cors_origin_pattern.mojom.h"
using content::BrowserThread;
// Creates and manages VisitedLinkEventListener objects for each
// AlloyBrowserContext sharing the same VisitedLinkWriter.
class CefVisitedLinkListener : public visitedlink::VisitedLinkWriter::Listener {
public:
CefVisitedLinkListener() { DCHECK(listener_map_.empty()); }
void CreateListenerForContext(content::BrowserContext* context) {
CEF_REQUIRE_UIT();
auto listener =
std::make_unique<visitedlink::VisitedLinkEventListener>(context);
listener_map_.insert(std::make_pair(context, std::move(listener)));
}
void RemoveListenerForContext(content::BrowserContext* context) {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.find(context);
DCHECK(it != listener_map_.end());
listener_map_.erase(it);
}
// visitedlink::VisitedLinkWriter::Listener methods.
void NewTable(base::ReadOnlySharedMemoryRegion* table_region) override {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.begin();
for (; it != listener_map_.end(); ++it)
it->second->NewTable(table_region);
}
void Add(visitedlink::VisitedLinkCommon::Fingerprint fingerprint) override {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.begin();
for (; it != listener_map_.end(); ++it)
it->second->Add(fingerprint);
}
void Reset(bool invalidate_hashes) override {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.begin();
for (; it != listener_map_.end(); ++it)
it->second->Reset(invalidate_hashes);
}
private:
// Map of AlloyBrowserContext to the associated VisitedLinkEventListener.
typedef std::map<const content::BrowserContext*,
std::unique_ptr<visitedlink::VisitedLinkEventListener>>
ListenerMap;
ListenerMap listener_map_;
DISALLOW_COPY_AND_ASSIGN(CefVisitedLinkListener);
};
AlloyBrowserContext::AlloyBrowserContext(
const CefRequestContextSettings& settings)
: CefBrowserContext(settings) {}
AlloyBrowserContext::~AlloyBrowserContext() {
if (resource_context_) {
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
resource_context_.release());
}
}
void AlloyBrowserContext::Initialize() {
CefBrowserContext::Initialize();
key_ = std::make_unique<ProfileKey>(cache_path_);
SimpleKeyMap::GetInstance()->Associate(this, key_.get());
// Initialize the PrefService object.
pref_service_ = browser_prefs::CreatePrefService(
this, cache_path_, !!settings_.persist_user_preferences);
// This must be called before creating any services to avoid hitting
// DependencyManager::AssertContextWasntDestroyed when creating/destroying
// multiple browser contexts (due to pointer address reuse).
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
this);
const bool extensions_enabled = extensions::ExtensionsEnabled();
if (extensions_enabled) {
// Create the custom ExtensionSystem first because other KeyedServices
// depend on it.
extension_system_ = static_cast<extensions::CefExtensionSystem*>(
extensions::ExtensionSystem::Get(this));
extension_system_->InitForRegularProfile(true);
// Make sure the ProcessManager is created so that it receives extension
// load notifications. This is necessary for the proper initialization of
// background/event pages.
extensions::ProcessManager::Get(this);
}
// Initialize visited links management.
base::FilePath visited_link_path;
if (!cache_path_.empty())
visited_link_path = cache_path_.Append(FILE_PATH_LITERAL("Visited Links"));
visitedlink_listener_ = new CefVisitedLinkListener;
visitedlink_master_.reset(new visitedlink::VisitedLinkWriter(
visitedlink_listener_, this, !visited_link_path.empty(), false,
visited_link_path, 0));
visitedlink_listener_->CreateListenerForContext(this);
visitedlink_master_->Init();
// Initialize proxy configuration tracker.
pref_proxy_config_tracker_.reset(new PrefProxyConfigTrackerImpl(
GetPrefs(), content::GetIOThreadTaskRunner({})));
// Spell checking support and possibly other subsystems retrieve the
// PrefService associated with a BrowserContext via UserPrefs::Get().
PrefService* pref_service = GetPrefs();
DCHECK(pref_service);
user_prefs::UserPrefs::Set(this, pref_service);
key_->SetPrefs(pref_service);
if (extensions_enabled)
extension_system_->Init();
ChromePluginServiceFilter::GetInstance()->RegisterProfile(this);
media_device_id_salt_ = new MediaDeviceIDSalt(pref_service);
}
void AlloyBrowserContext::Shutdown() {
CefBrowserContext::Shutdown();
// Send notifications to clean up objects associated with this Profile.
MaybeSendDestroyedNotification();
ChromePluginServiceFilter::GetInstance()->UnregisterProfile(this);
// Remove any BrowserContextKeyedServiceFactory associations. This must be
// called before the ProxyService owned by AlloyBrowserContext is destroyed.
// The SimpleDependencyManager should always be passed after the
// BrowserContextDependencyManager. This is because the KeyedService instances
// in the BrowserContextDependencyManager's dependency graph can depend on the
// ones in the SimpleDependencyManager's graph.
DependencyManager::PerformInterlockedTwoPhaseShutdown(
BrowserContextDependencyManager::GetInstance(), this,
SimpleDependencyManager::GetInstance(), key_.get());
key_.reset();
SimpleKeyMap::GetInstance()->Dissociate(this);
// Shuts down the storage partitions associated with this browser context.
// This must be called before the browser context is actually destroyed
// and before a clean-up task for its corresponding IO thread residents
// (e.g. ResourceContext) is posted, so that the classes that hung on
// StoragePartition can have time to do necessary cleanups on IO thread.
ShutdownStoragePartitions();
visitedlink_listener_->RemoveListenerForContext(this);
// The FontFamilyCache references the ProxyService so delete it before the
// ProxyService is deleted.
SetUserData(&kFontFamilyCacheKey, nullptr);
pref_proxy_config_tracker_->DetachFromPrefService();
// Delete the download manager delegate here because otherwise we'll crash
// when it's accessed from the content::BrowserContext destructor.
if (download_manager_delegate_)
download_manager_delegate_.reset(nullptr);
}
void AlloyBrowserContext::RemoveCefRequestContext(
CefRequestContextImpl* context) {
CEF_REQUIRE_UIT();
if (extensions::ExtensionsEnabled()) {
extension_system()->OnRequestContextDeleted(context);
}
// May result in |this| being deleted.
CefBrowserContext::RemoveCefRequestContext(context);
}
void AlloyBrowserContext::LoadExtension(
const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler,
CefRefPtr<CefRequestContext> loader_context) {
if (!extensions::ExtensionsEnabled()) {
if (handler)
handler->OnExtensionLoadFailed(ERR_ABORTED);
return;
}
if (manifest && manifest->GetSize() > 0) {
CefDictionaryValueImpl* value_impl =
static_cast<CefDictionaryValueImpl*>(manifest.get());
extension_system()->LoadExtension(base::WrapUnique(value_impl->CopyValue()),
root_directory, false /* builtin */,
loader_context, handler);
} else {
extension_system()->LoadExtension(root_directory, false /* builtin */,
loader_context, handler);
}
}
bool AlloyBrowserContext::GetExtensions(std::vector<CefString>& extension_ids) {
if (!extensions::ExtensionsEnabled())
return false;
extensions::CefExtensionSystem::ExtensionMap extension_map =
extension_system()->GetExtensions();
extensions::CefExtensionSystem::ExtensionMap::const_iterator it =
extension_map.begin();
for (; it != extension_map.end(); ++it)
extension_ids.push_back(it->second->GetIdentifier());
return true;
}
CefRefPtr<CefExtension> AlloyBrowserContext::GetExtension(
const CefString& extension_id) {
if (!extensions::ExtensionsEnabled())
return nullptr;
return extension_system()->GetExtension(extension_id);
}
bool AlloyBrowserContext::UnloadExtension(const CefString& extension_id) {
DCHECK(extensions::ExtensionsEnabled());
return extension_system()->UnloadExtension(extension_id);
}
bool AlloyBrowserContext::IsPrintPreviewSupported() const {
CEF_REQUIRE_UIT();
if (!extensions::PrintPreviewEnabled())
return false;
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
}
void AlloyBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
visitedlink_master_->AddURLs(urls);
}
content::ResourceContext* AlloyBrowserContext::GetResourceContext() {
if (!resource_context_) {
resource_context_ = std::make_unique<content::ResourceContext>();
}
return resource_context_.get();
}
content::ClientHintsControllerDelegate*
AlloyBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;
}
void AlloyBrowserContext::SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) {
// This method is called for Extension support.
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, std::move(closure));
}
ChromeZoomLevelPrefs* AlloyBrowserContext::GetZoomLevelPrefs() {
return static_cast<ChromeZoomLevelPrefs*>(
GetStoragePartition(this, nullptr)->GetZoomLevelDelegate());
}
scoped_refptr<network::SharedURLLoaderFactory>
AlloyBrowserContext::GetURLLoaderFactory() {
return GetDefaultStoragePartition(this)
->GetURLLoaderFactoryForBrowserProcess();
}
base::FilePath AlloyBrowserContext::GetPath() {
return cache_path_;
}
base::FilePath AlloyBrowserContext::GetPath() const {
return cache_path_;
}
std::unique_ptr<content::ZoomLevelDelegate>
AlloyBrowserContext::CreateZoomLevelDelegate(
const base::FilePath& partition_path) {
if (cache_path_.empty())
return std::unique_ptr<content::ZoomLevelDelegate>();
return base::WrapUnique(new ChromeZoomLevelPrefs(
GetPrefs(), cache_path_, partition_path,
zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
}
bool AlloyBrowserContext::IsOffTheRecord() const {
// Alloy contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false;
}
content::DownloadManagerDelegate*
AlloyBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_) {
content::DownloadManager* manager =
BrowserContext::GetDownloadManager(this);
download_manager_delegate_.reset(new CefDownloadManagerDelegate(manager));
}
return download_manager_delegate_.get();
}
content::BrowserPluginGuestManager* AlloyBrowserContext::GetGuestManager() {
DCHECK(extensions::ExtensionsEnabled());
return guest_view::GuestViewManager::FromBrowserContext(this);
}
storage::SpecialStoragePolicy* AlloyBrowserContext::GetSpecialStoragePolicy() {
return nullptr;
}
content::PushMessagingService* AlloyBrowserContext::GetPushMessagingService() {
return nullptr;
}
content::StorageNotificationService*
AlloyBrowserContext::GetStorageNotificationService() {
return nullptr;
}
content::SSLHostStateDelegate* AlloyBrowserContext::GetSSLHostStateDelegate() {
if (!ssl_host_state_delegate_)
ssl_host_state_delegate_.reset(new CefSSLHostStateDelegate());
return ssl_host_state_delegate_.get();
}
content::PermissionControllerDelegate*
AlloyBrowserContext::GetPermissionControllerDelegate() {
return nullptr;
}
content::BackgroundFetchDelegate*
AlloyBrowserContext::GetBackgroundFetchDelegate() {
return nullptr;
}
content::BackgroundSyncController*
AlloyBrowserContext::GetBackgroundSyncController() {
return nullptr;
}
content::BrowsingDataRemoverDelegate*
AlloyBrowserContext::GetBrowsingDataRemoverDelegate() {
return nullptr;
}
std::string AlloyBrowserContext::GetMediaDeviceIDSalt() {
return media_device_id_salt_->GetSalt();
}
PrefService* AlloyBrowserContext::GetPrefs() {
return pref_service_.get();
}
const PrefService* AlloyBrowserContext::GetPrefs() const {
return pref_service_.get();
}
ProfileKey* AlloyBrowserContext::GetProfileKey() const {
DCHECK(key_);
return key_.get();
}
policy::SchemaRegistryService*
AlloyBrowserContext::GetPolicySchemaRegistryService() {
NOTREACHED();
return nullptr;
}
policy::UserCloudPolicyManager*
AlloyBrowserContext::GetUserCloudPolicyManager() {
NOTREACHED();
return nullptr;
}
policy::ProfilePolicyConnector*
AlloyBrowserContext::GetProfilePolicyConnector() {
NOTREACHED();
return nullptr;
}
const policy::ProfilePolicyConnector*
AlloyBrowserContext::GetProfilePolicyConnector() const {
NOTREACHED();
return nullptr;
}
void AlloyBrowserContext::RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) {
// Called when visited links will not or cannot be loaded from disk.
enumerator->OnComplete(true);
}
DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() {
CEF_REQUIRE_UIT();
if (!download_prefs_) {
download_prefs_.reset(new DownloadPrefs(this));
}
return download_prefs_.get();
}

View File

@@ -1,150 +0,0 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_
#pragma once
#include "include/cef_request_context_handler.h"
#include "libcef/browser/alloy/chrome_profile_alloy.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/request_context_handler_map.h"
#include "chrome/browser/download/download_prefs.h"
#include "components/proxy_config/pref_proxy_config_tracker.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
class CefDownloadManagerDelegate;
class CefSSLHostStateDelegate;
class CefVisitedLinkListener;
class MediaDeviceIDSalt;
class PrefService;
namespace extensions {
class CefExtensionSystem;
}
namespace visitedlink {
class VisitedLinkWriter;
}
// See CefBrowserContext documentation for usage. Only accessed on the UI thread
// unless otherwise indicated. ChromeProfileAlloy must be the first listed base
// class to avoid issues when casting between void* and content::BrowserContext*
// in Chromium code.
class AlloyBrowserContext : public ChromeProfileAlloy,
public CefBrowserContext,
public visitedlink::VisitedLinkDelegate {
public:
explicit AlloyBrowserContext(const CefRequestContextSettings& settings);
// CefBrowserContext overrides.
content::BrowserContext* AsBrowserContext() override { return this; }
Profile* AsProfile() override { return this; }
void Initialize() override;
void Shutdown() override;
void RemoveCefRequestContext(CefRequestContextImpl* context) override;
void LoadExtension(const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler,
CefRefPtr<CefRequestContext> loader_context) override;
bool GetExtensions(std::vector<CefString>& extension_ids) override;
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
bool UnloadExtension(const CefString& extension_id) override;
bool IsPrintPreviewSupported() const override;
void AddVisitedURLs(const std::vector<GURL>& urls) override;
// content::BrowserContext overrides.
content::ResourceContext* GetResourceContext() override;
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
void SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) override;
base::FilePath GetPath() override;
base::FilePath GetPath() const override;
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath& partition_path) override;
bool IsOffTheRecord() const override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::PushMessagingService* GetPushMessagingService() override;
content::StorageNotificationService* GetStorageNotificationService() override;
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::PermissionControllerDelegate* GetPermissionControllerDelegate()
override;
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
content::BackgroundSyncController* GetBackgroundSyncController() override;
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()
override;
std::string GetMediaDeviceIDSalt() override;
// Profile overrides.
ChromeZoomLevelPrefs* GetZoomLevelPrefs() override;
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
PrefService* GetPrefs() override;
bool AllowsBrowserWindows() const override { return false; }
const PrefService* GetPrefs() const override;
ProfileKey* GetProfileKey() const override;
policy::SchemaRegistryService* GetPolicySchemaRegistryService() override;
policy::UserCloudPolicyManager* GetUserCloudPolicyManager() override;
policy::ProfilePolicyConnector* GetProfilePolicyConnector() override;
const policy::ProfilePolicyConnector* GetProfilePolicyConnector()
const override;
// Values checked in ProfileNetworkContextService::CreateNetworkContextParams
// when creating the NetworkContext.
bool ShouldRestoreOldSessionCookies() const override {
return ShouldPersistSessionCookies();
}
bool ShouldPersistSessionCookies() const override {
return !!settings_.persist_session_cookies;
}
base::Optional<std::vector<std::string>> GetCookieableSchemes() override {
return cookieable_schemes();
}
// visitedlink::VisitedLinkDelegate methods.
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
// Manages extensions.
extensions::CefExtensionSystem* extension_system() const {
return extension_system_;
}
// Called from DownloadPrefs::FromBrowserContext.
DownloadPrefs* GetDownloadPrefs();
private:
~AlloyBrowserContext() override;
std::unique_ptr<PrefService> pref_service_;
std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_master_;
// |visitedlink_listener_| is owned by visitedlink_master_.
CefVisitedLinkListener* visitedlink_listener_ = nullptr;
// Owned by the KeyedService system.
extensions::CefExtensionSystem* extension_system_ = nullptr;
// The key to index KeyedService instances created by
// SimpleKeyedServiceFactory.
std::unique_ptr<ProfileKey> key_;
std::unique_ptr<DownloadPrefs> download_prefs_;
std::unique_ptr<content::ResourceContext> resource_context_;
scoped_refptr<MediaDeviceIDSalt> media_device_id_salt_;
DISALLOW_COPY_AND_ASSIGN(AlloyBrowserContext);
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_

View File

@@ -1,436 +0,0 @@
// Copyright 2015 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/browser_platform_delegate_alloy.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/extensions/extension_background_host.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/extensions/extension_view_host.h"
#include "libcef/browser/extensions/extension_web_contents_observer.h"
#include "libcef/browser/printing/print_view_manager.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/logging.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "components/zoom/zoom_controller.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "extensions/browser/process_manager.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
CefBrowserPlatformDelegateAlloy::CefBrowserPlatformDelegateAlloy()
: weak_ptr_factory_(this) {}
content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
CefBrowserHostImpl::CreateParams& create_params,
bool& own_web_contents) {
// Get or create the request context and browser context.
CefRefPtr<CefRequestContextImpl> request_context_impl =
CefRequestContextImpl::GetOrCreateForRequestContext(
create_params.request_context);
CHECK(request_context_impl);
auto cef_browser_context = request_context_impl->GetBrowserContext();
CHECK(cef_browser_context);
auto browser_context = cef_browser_context->AsBrowserContext();
if (!create_params.request_context) {
// Using the global request context.
create_params.request_context = request_context_impl.get();
}
scoped_refptr<content::SiteInstance> site_instance;
if (extensions::ExtensionsEnabled() && !create_params.url.is_empty()) {
if (!create_params.extension) {
// We might be loading an extension app view where the extension URL is
// provided by the client.
create_params.extension =
extensions::GetExtensionForUrl(browser_context, create_params.url);
}
if (create_params.extension) {
if (create_params.extension_host_type == extensions::VIEW_TYPE_INVALID) {
// Default to dialog behavior.
create_params.extension_host_type =
extensions::VIEW_TYPE_EXTENSION_DIALOG;
}
// Extension resources will fail to load if we don't use a SiteInstance
// associated with the extension.
// (AlloyContentBrowserClient::SiteInstanceGotProcess won't find the
// extension to register with InfoMap, and AllowExtensionResourceLoad in
// ExtensionProtocolHandler::MaybeCreateJob will return false resulting in
// ERR_BLOCKED_BY_CLIENT).
site_instance = extensions::ProcessManager::Get(browser_context)
->GetSiteInstanceForURL(create_params.url);
DCHECK(site_instance);
}
}
content::WebContents::CreateParams wc_create_params(browser_context,
site_instance);
if (IsWindowless()) {
// Create the OSR view for the WebContents.
CreateViewForWebContents(&wc_create_params.view,
&wc_create_params.delegate_view);
}
auto web_contents = content::WebContents::Create(wc_create_params);
CHECK(web_contents);
own_web_contents = true;
return web_contents.release();
}
void CefBrowserPlatformDelegateAlloy::WebContentsCreated(
content::WebContents* web_contents,
bool owned) {
CefBrowserPlatformDelegate::WebContentsCreated(web_contents, owned);
if (owned) {
SetOwnedWebContents(web_contents);
}
}
void CefBrowserPlatformDelegateAlloy::AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
CefRefPtr<CefBrowserHostImpl> owner =
CefBrowserHostImpl::GetBrowserForContents(new_contents.get());
if (owner) {
// Taking ownership of |new_contents|.
static_cast<CefBrowserPlatformDelegateAlloy*>(
owner->platform_delegate_.get())
->SetOwnedWebContents(new_contents.release());
return;
}
if (extension_host_) {
extension_host_->AddNewContents(source, std::move(new_contents), target_url,
disposition, initial_rect, user_gesture,
was_blocked);
}
}
bool CefBrowserPlatformDelegateAlloy::ShouldTransferNavigation(
bool is_main_frame_navigation) {
if (extension_host_) {
return extension_host_->ShouldTransferNavigation(is_main_frame_navigation);
}
return true;
}
void CefBrowserPlatformDelegateAlloy::RenderViewCreated(
content::RenderViewHost* render_view_host) {
// Indicate that the view has an external parent (namely us). This changes the
// default view behavior in some cases (e.g. focus handling on Linux).
if (!IsViewsHosted() && render_view_host->GetWidget()->GetView())
render_view_host->GetWidget()->GetView()->SetHasExternalParent(true);
}
void CefBrowserPlatformDelegateAlloy::RenderViewReady() {
ConfigureAutoResize();
}
void CefBrowserPlatformDelegateAlloy::BrowserCreated(
CefBrowserHostImpl* browser) {
CefBrowserPlatformDelegate::BrowserCreated(browser);
web_contents_->SetDelegate(browser);
PrefsTabHelper::CreateForWebContents(web_contents_);
printing::CefPrintViewManager::CreateForWebContents(web_contents_);
if (extensions::ExtensionsEnabled()) {
extensions::CefExtensionWebContentsObserver::CreateForWebContents(
web_contents_);
// Used by the tabs extension API.
zoom::ZoomController::CreateForWebContents(web_contents_);
}
if (IsPrintPreviewSupported()) {
web_contents_dialog_helper_.reset(
new CefWebContentsDialogHelper(web_contents_, this));
}
}
void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
const extensions::Extension* extension,
const GURL& url,
extensions::ViewType host_type) {
// Should get WebContentsCreated and BrowserCreated calls first.
DCHECK(web_contents_);
DCHECK(browser_);
DCHECK(!extension_host_);
if (host_type == extensions::VIEW_TYPE_EXTENSION_DIALOG ||
host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) {
// Create an extension host that we own.
extension_host_ = new extensions::CefExtensionViewHost(
browser_, extension, web_contents_, url, host_type);
// Trigger load of the extension URL.
extension_host_->CreateRenderViewSoon();
} else if (host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
is_background_host_ = true;
browser_->is_background_host_ = true;
// Create an extension host that will be owned by ProcessManager.
extension_host_ = new extensions::CefExtensionBackgroundHost(
browser_,
base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted,
weak_ptr_factory_.GetWeakPtr()),
extension, web_contents_, url, host_type);
// Load will be triggered by ProcessManager::CreateBackgroundHost.
} else {
NOTREACHED() << " Unsupported extension host type: " << host_type;
}
}
extensions::ExtensionHost* CefBrowserPlatformDelegateAlloy::GetExtensionHost()
const {
return extension_host_;
}
void CefBrowserPlatformDelegateAlloy::BrowserDestroyed(
CefBrowserHostImpl* browser) {
DestroyExtensionHost();
owned_web_contents_.reset();
CefBrowserPlatformDelegate::BrowserDestroyed(browser);
}
void CefBrowserPlatformDelegateAlloy::SendCaptureLostEvent() {
if (!web_contents_)
return;
content::RenderViewHost* host = web_contents_->GetRenderViewHost();
if (!host)
return;
content::RenderWidgetHostImpl* widget =
content::RenderWidgetHostImpl::From(host->GetWidget());
if (widget)
widget->LostCapture();
}
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
void CefBrowserPlatformDelegateAlloy::NotifyMoveOrResizeStarted() {
if (!web_contents_)
return;
// Dismiss any existing popups.
content::RenderViewHost* host = web_contents_->GetRenderViewHost();
if (host)
host->NotifyMoveOrResizeStarted();
}
#endif
bool CefBrowserPlatformDelegateAlloy::PreHandleGestureEvent(
content::WebContents* source,
const blink::WebGestureEvent& event) {
if (extension_host_)
return extension_host_->PreHandleGestureEvent(source, event);
return false;
}
bool CefBrowserPlatformDelegateAlloy::IsNeverComposited(
content::WebContents* web_contents) {
if (extension_host_)
return extension_host_->IsNeverComposited(web_contents);
return false;
}
void CefBrowserPlatformDelegateAlloy::SetAutoResizeEnabled(
bool enabled,
const CefSize& min_size,
const CefSize& max_size) {
if (enabled == auto_resize_enabled_)
return;
auto_resize_enabled_ = enabled;
if (enabled) {
auto_resize_min_ = gfx::Size(min_size.width, min_size.height);
auto_resize_max_ = gfx::Size(max_size.width, max_size.height);
} else {
auto_resize_min_ = auto_resize_max_ = gfx::Size();
}
ConfigureAutoResize();
}
void CefBrowserPlatformDelegateAlloy::ConfigureAutoResize() {
if (!web_contents_ || !web_contents_->GetRenderWidgetHostView()) {
return;
}
if (auto_resize_enabled_) {
web_contents_->GetRenderWidgetHostView()->EnableAutoResize(
auto_resize_min_, auto_resize_max_);
} else {
web_contents_->GetRenderWidgetHostView()->DisableAutoResize(gfx::Size());
}
}
void CefBrowserPlatformDelegateAlloy::SetAccessibilityState(
cef_state_t accessibility_state) {
// Do nothing if state is set to default. It'll be disabled by default and
// controlled by the commmand-line flags "force-renderer-accessibility" and
// "disable-renderer-accessibility".
if (accessibility_state == STATE_DEFAULT)
return;
content::WebContentsImpl* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
if (!web_contents_impl)
return;
ui::AXMode accMode;
// In windowless mode set accessibility to TreeOnly mode. Else native
// accessibility APIs, specific to each platform, are also created.
if (accessibility_state == STATE_ENABLED) {
accMode = IsWindowless() ? ui::kAXModeWebContentsOnly : ui::kAXModeComplete;
}
web_contents_impl->SetAccessibilityMode(accMode);
}
bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const {
auto actionable_contents = GetActionableWebContents();
if (!actionable_contents)
return false;
auto cef_browser_context = CefBrowserContext::FromBrowserContext(
actionable_contents->GetBrowserContext());
if (!cef_browser_context->IsPrintPreviewSupported()) {
return false;
}
// Print preview is not currently supported with OSR.
return !IsWindowless();
}
void CefBrowserPlatformDelegateAlloy::Print() {
auto actionable_contents = GetActionableWebContents();
if (!actionable_contents)
return;
auto rfh = actionable_contents->GetMainFrame();
if (IsPrintPreviewSupported()) {
printing::CefPrintViewManager::FromWebContents(actionable_contents)
->PrintPreviewNow(rfh, false);
} else {
printing::PrintViewManager::FromWebContents(actionable_contents)
->PrintNow(rfh);
}
}
void CefBrowserPlatformDelegateAlloy::PrintToPDF(
const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback) {
content::WebContents* actionable_contents = GetActionableWebContents();
if (!actionable_contents)
return;
printing::CefPrintViewManager::PdfPrintCallback pdf_callback;
if (callback.get()) {
pdf_callback = base::Bind(&CefPdfPrintCallback::OnPdfPrintFinished,
callback.get(), path);
}
printing::CefPrintViewManager::FromWebContents(actionable_contents)
->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path),
settings, pdf_callback);
}
void CefBrowserPlatformDelegateAlloy::Find(int identifier,
const CefString& searchText,
bool forward,
bool matchCase,
bool findNext) {
if (!web_contents_)
return;
// Every find request must have a unique ID and these IDs must strictly
// increase so that newer requests always have greater IDs than older
// requests.
if (identifier <= find_request_id_counter_)
identifier = ++find_request_id_counter_;
else
find_request_id_counter_ = identifier;
auto options = blink::mojom::FindOptions::New();
options->forward = forward;
options->match_case = matchCase;
options->find_next_if_selection_matches = findNext;
web_contents_->Find(identifier, searchText, std::move(options));
}
void CefBrowserPlatformDelegateAlloy::StopFinding(bool clearSelection) {
if (!web_contents_)
return;
content::StopFindAction action =
clearSelection ? content::STOP_FIND_ACTION_CLEAR_SELECTION
: content::STOP_FIND_ACTION_KEEP_SELECTION;
web_contents_->StopFinding(action);
}
base::RepeatingClosure
CefBrowserPlatformDelegateAlloy::GetBoundsChangedCallback() {
if (web_contents_dialog_helper_) {
return web_contents_dialog_helper_->GetBoundsChangedCallback();
}
return base::RepeatingClosure();
}
content::WebContents*
CefBrowserPlatformDelegateAlloy::GetActionableWebContents() const {
if (web_contents_ && extensions::ExtensionsEnabled()) {
content::WebContents* guest_contents =
extensions::GetFullPageGuestForOwnerContents(web_contents_);
if (guest_contents)
return guest_contents;
}
return web_contents_;
}
void CefBrowserPlatformDelegateAlloy::SetOwnedWebContents(
content::WebContents* owned_contents) {
// Should not currently own a WebContents.
CHECK(!owned_web_contents_);
owned_web_contents_.reset(owned_contents);
}
void CefBrowserPlatformDelegateAlloy::DestroyExtensionHost() {
if (!extension_host_)
return;
if (extension_host_->extension_host_type() ==
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
DCHECK(is_background_host_);
// Close notification for background pages arrives via CloseContents.
// The extension host will be deleted by
// ProcessManager::CloseBackgroundHost and OnExtensionHostDeleted will be
// called to notify us.
extension_host_->Close();
} else {
DCHECK(!is_background_host_);
// We own the extension host and must delete it.
delete extension_host_;
extension_host_ = nullptr;
}
}
void CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted() {
DCHECK(is_background_host_);
DCHECK(extension_host_);
extension_host_ = nullptr;
}

View File

@@ -1,106 +0,0 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
#define CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/web_contents_dialog_helper.h"
#include "base/memory/weak_ptr.h"
// Implementation of Alloy-based browser functionality.
class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
public:
content::WebContents* CreateWebContents(
CefBrowserHostImpl::CreateParams& create_params,
bool& own_web_contents) override;
void WebContentsCreated(content::WebContents* web_contents,
bool owned) override;
void AddNewContents(content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) override;
bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
void RenderViewReady() override;
void BrowserCreated(CefBrowserHostImpl* browser) override;
void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::ViewType host_type) override;
extensions::ExtensionHost* GetExtensionHost() const override;
void BrowserDestroyed(CefBrowserHostImpl* browser) override;
void SendCaptureLostEvent() override;
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
void NotifyMoveOrResizeStarted() override;
#endif
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) override;
bool IsNeverComposited(content::WebContents* web_contents) override;
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;
void SetAccessibilityState(cef_state_t accessibility_state) override;
bool IsPrintPreviewSupported() const override;
void Print() override;
void PrintToPDF(const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback) override;
void Find(int identifier,
const CefString& searchText,
bool forward,
bool matchCase,
bool findNext) override;
void StopFinding(bool clearSelection) override;
protected:
CefBrowserPlatformDelegateAlloy();
base::RepeatingClosure GetBoundsChangedCallback();
// Returns the WebContents most likely to handle an action. If extensions are
// enabled and this browser has a full-page guest (for example, a full-page
// PDF viewer extension) then the guest's WebContents will be returned.
// Otherwise, the browser's WebContents will be returned.
content::WebContents* GetActionableWebContents() const;
private:
void SetOwnedWebContents(content::WebContents* owned_contents);
void DestroyExtensionHost();
void OnExtensionHostDeleted();
void ConfigureAutoResize();
// Non-nullptr if this object owns the WebContents. Will be nullptr for popup
// browsers between the calls to WebContentsCreated() and AddNewContents(),
// and may never be set if the parent browser is destroyed during popup
// creation.
std::unique_ptr<content::WebContents> owned_web_contents_;
// Used for the print preview dialog.
std::unique_ptr<CefWebContentsDialogHelper> web_contents_dialog_helper_;
// Used to provide unique incremental IDs for each find request.
int find_request_id_counter_ = 0;
// Used when the browser is hosting an extension.
extensions::ExtensionHost* extension_host_ = nullptr;
bool is_background_host_ = false;
// Used with auto-resize.
bool auto_resize_enabled_ = false;
gfx::Size auto_resize_min_;
gfx::Size auto_resize_max_;
base::WeakPtrFactory<CefBrowserPlatformDelegateAlloy> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegateAlloy);
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_

View File

@@ -1,173 +0,0 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/chrome_profile_alloy.h"
#include "base/no_destructor.h"
#include "components/variations/variations_client.h"
#include "components/variations/variations_ids_provider.h"
#include "net/url_request/url_request_context.h"
namespace {
class CefVariationsClient : public variations::VariationsClient {
public:
explicit CefVariationsClient(content::BrowserContext* browser_context)
: browser_context_(browser_context) {}
~CefVariationsClient() override = default;
bool IsOffTheRecord() const override {
return browser_context_->IsOffTheRecord();
}
std::string GetVariationsHeader() const override {
return variations::VariationsIdsProvider::GetInstance()
->GetClientDataHeader(false /* is_signed_in */);
}
private:
content::BrowserContext* browser_context_;
};
} // namespace
ChromeProfileAlloy::ChromeProfileAlloy() {}
ChromeProfileAlloy::~ChromeProfileAlloy() {}
bool ChromeProfileAlloy::IsOffTheRecord() {
return false;
}
bool ChromeProfileAlloy::IsOffTheRecord() const {
return false;
}
const Profile::OTRProfileID& ChromeProfileAlloy::GetOTRProfileID() const {
NOTREACHED();
static base::NoDestructor<Profile::OTRProfileID> otr_profile_id(
"ProfileImp::NoOTRProfileID");
return *otr_profile_id;
}
variations::VariationsClient* ChromeProfileAlloy::GetVariationsClient() {
if (!variations_client_)
variations_client_ = std::make_unique<CefVariationsClient>(this);
return variations_client_.get();
}
scoped_refptr<base::SequencedTaskRunner> ChromeProfileAlloy::GetIOTaskRunner() {
NOTREACHED();
return scoped_refptr<base::SequencedTaskRunner>();
}
std::string ChromeProfileAlloy::GetProfileUserName() const {
NOTREACHED();
return std::string();
}
Profile* ChromeProfileAlloy::GetOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) {
NOTREACHED();
return nullptr;
}
std::vector<Profile*> ChromeProfileAlloy::GetAllOffTheRecordProfiles() {
return {};
}
void ChromeProfileAlloy::DestroyOffTheRecordProfile(Profile* otr_profile) {
NOTREACHED();
}
bool ChromeProfileAlloy::HasOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) {
return false;
}
bool ChromeProfileAlloy::HasAnyOffTheRecordProfile() {
return false;
}
Profile* ChromeProfileAlloy::GetOriginalProfile() {
return this;
}
const Profile* ChromeProfileAlloy::GetOriginalProfile() const {
return this;
}
bool ChromeProfileAlloy::IsSupervised() const {
return false;
}
bool ChromeProfileAlloy::IsChild() const {
return false;
}
bool ChromeProfileAlloy::IsLegacySupervised() const {
return false;
}
ExtensionSpecialStoragePolicy*
ChromeProfileAlloy::GetExtensionSpecialStoragePolicy() {
NOTREACHED();
return nullptr;
}
PrefService* ChromeProfileAlloy::GetOffTheRecordPrefs() {
NOTREACHED();
return nullptr;
}
bool ChromeProfileAlloy::IsSameOrParent(Profile* profile) {
NOTREACHED();
return false;
}
base::Time ChromeProfileAlloy::GetStartTime() const {
NOTREACHED();
return base::Time();
}
base::FilePath ChromeProfileAlloy::last_selected_directory() {
NOTREACHED();
return base::FilePath();
}
void ChromeProfileAlloy::set_last_selected_directory(
const base::FilePath& path) {
NOTREACHED();
}
GURL ChromeProfileAlloy::GetHomePage() {
NOTREACHED();
return GURL();
}
bool ChromeProfileAlloy::WasCreatedByVersionOrLater(
const std::string& version) {
NOTREACHED();
return false;
}
void ChromeProfileAlloy::SetExitType(ExitType exit_type) {
NOTREACHED();
}
Profile::ExitType ChromeProfileAlloy::GetLastSessionExitType() const {
NOTREACHED();
return EXIT_NORMAL;
}
base::Time ChromeProfileAlloy::GetCreationTime() const {
NOTREACHED();
return base::Time();
}
void ChromeProfileAlloy::SetCreationTimeForTesting(base::Time creation_time) {
NOTREACHED();
}

View File

@@ -77,8 +77,7 @@ CefAudioCapturer::CefAudioCapturer(const CefAudioParameters& params,
std::make_unique<mirroring::CapturedAudioInput>(base::BindRepeating(
&StreamCreatorHelper, base::Unretained(browser_->web_contents()),
base::Unretained(audio_stream_creator_.get()))),
media::AudioInputDevice::kLoopback,
media::AudioInputDevice::DeadStreamDetection::kEnabled);
media::AudioInputDevice::kLoopback);
audio_input_device_->Initialize(audio_params, this);
audio_input_device_->Start();

View File

@@ -7,20 +7,47 @@
#include <map>
#include <utility>
#include "libcef/browser/iothread_state.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/download_manager_delegate.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/ssl_host_state_delegate.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "content/public/browser/browser_context.h"
#include "chrome/browser/font_family_cache.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
#include "chrome/common/pref_names.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/core/simple_dependency_manager.h"
#include "components/keyed_service/core/simple_key_map.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/user_prefs/user_prefs.h"
#include "components/visitedlink/browser/visitedlink_event_listener.h"
#include "components/visitedlink/browser/visitedlink_writer.h"
#include "components/zoom/zoom_event_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/constants.h"
#include "net/proxy_resolution/proxy_config_service.h"
#include "services/network/public/mojom/cors_origin_pattern.mojom.h"
using content::BrowserThread;
@@ -63,10 +90,10 @@ class ImplManager {
return GetImplPos(impl) != all_.end();
}
CefBrowserContext* GetImplFromIDs(int render_process_id,
int render_frame_id,
int frame_tree_node_id,
bool require_frame_match) {
CefBrowserContext* GetImplForIDs(int render_process_id,
int render_frame_id,
int frame_tree_node_id,
bool require_frame_match) {
CEF_REQUIRE_UIT();
for (const auto& context : all_) {
if (context->IsAssociatedContext(render_process_id, render_frame_id,
@@ -78,15 +105,15 @@ class ImplManager {
return nullptr;
}
CefBrowserContext* GetImplFromBrowserContext(
const content::BrowserContext* context) {
CefBrowserContext* GetImplForContext(const content::BrowserContext* context) {
CEF_REQUIRE_UIT();
if (!context)
return nullptr;
for (const auto& bc : all_) {
if (bc->AsBrowserContext() == context)
return bc;
Vector::iterator it = all_.begin();
for (; it != all_.end(); ++it) {
if (*it == context)
return *it;
}
return nullptr;
}
@@ -95,11 +122,11 @@ class ImplManager {
CEF_REQUIRE_UIT();
DCHECK(!path.empty());
DCHECK(IsValidImpl(impl));
DCHECK(GetImplFromPath(path) == nullptr);
DCHECK(GetImplForPath(path) == nullptr);
map_.insert(std::make_pair(path, impl));
}
CefBrowserContext* GetImplFromPath(const base::FilePath& path) {
CefBrowserContext* GetImplForPath(const base::FilePath& path) {
CEF_REQUIRE_UIT();
DCHECK(!path.empty());
PathMap::const_iterator it = map_.find(path);
@@ -143,6 +170,59 @@ CefBrowserContext* GetSelf(base::WeakPtr<CefBrowserContext> self) {
} // namespace
// Creates and manages VisitedLinkEventListener objects for each
// CefBrowserContext sharing the same VisitedLinkWriter.
class CefVisitedLinkListener : public visitedlink::VisitedLinkWriter::Listener {
public:
CefVisitedLinkListener() { DCHECK(listener_map_.empty()); }
void CreateListenerForContext(const CefBrowserContext* context) {
CEF_REQUIRE_UIT();
auto listener = std::make_unique<visitedlink::VisitedLinkEventListener>(
const_cast<CefBrowserContext*>(context));
listener_map_.insert(std::make_pair(context, std::move(listener)));
}
void RemoveListenerForContext(const CefBrowserContext* context) {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.find(context);
DCHECK(it != listener_map_.end());
listener_map_.erase(it);
}
// visitedlink::VisitedLinkWriter::Listener methods.
void NewTable(base::ReadOnlySharedMemoryRegion* table_region) override {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.begin();
for (; it != listener_map_.end(); ++it)
it->second->NewTable(table_region);
}
void Add(visitedlink::VisitedLinkCommon::Fingerprint fingerprint) override {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.begin();
for (; it != listener_map_.end(); ++it)
it->second->Add(fingerprint);
}
void Reset(bool invalidate_hashes) override {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.begin();
for (; it != listener_map_.end(); ++it)
it->second->Reset(invalidate_hashes);
}
private:
// Map of CefBrowserContext to the associated VisitedLinkEventListener.
typedef std::map<const CefBrowserContext*,
std::unique_ptr<visitedlink::VisitedLinkEventListener>>
ListenerMap;
ListenerMap listener_map_;
DISALLOW_COPY_AND_ASSIGN(CefVisitedLinkListener);
};
CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings)
: settings_(settings), weak_ptr_factory_(this) {
g_manager.Get().AddImpl(this);
@@ -151,33 +231,6 @@ CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings)
CefBrowserContext::~CefBrowserContext() {
CEF_REQUIRE_UIT();
#if DCHECK_IS_ON()
DCHECK(is_shutdown_);
#endif
if (iothread_state_) {
// Destruction of the CefIOThreadState will trigger destruction of all
// associated network requests.
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
iothread_state_.release());
}
}
void CefBrowserContext::Initialize() {
cache_path_ = base::FilePath(CefString(&settings_.cache_path));
if (!cache_path_.empty())
g_manager.Get().SetImplPath(this, cache_path_);
iothread_state_ = std::make_unique<CefIOThreadState>();
}
void CefBrowserContext::Shutdown() {
CEF_REQUIRE_UIT();
#if DCHECK_IS_ON()
is_shutdown_ = true;
#endif
// No CefRequestContext should be referencing this object any longer.
DCHECK(request_context_set_.empty());
@@ -187,6 +240,121 @@ void CefBrowserContext::Shutdown() {
// Destroy objects that may hold references to the MediaRouter.
media_router_manager_.reset();
// Send notifications to clean up objects associated with this Profile.
MaybeSendDestroyedNotification();
ChromePluginServiceFilter::GetInstance()->UnregisterProfile(this);
// Remove any BrowserContextKeyedServiceFactory associations. This must be
// called before the ProxyService owned by CefBrowserContext is destroyed.
// The SimpleDependencyManager should always be passed after the
// BrowserContextDependencyManager. This is because the KeyedService instances
// in the BrowserContextDependencyManager's dependency graph can depend on the
// ones in the SimpleDependencyManager's graph.
DependencyManager::PerformInterlockedTwoPhaseShutdown(
BrowserContextDependencyManager::GetInstance(), this,
SimpleDependencyManager::GetInstance(), key_.get());
key_.reset();
SimpleKeyMap::GetInstance()->Dissociate(this);
// Shuts down the storage partitions associated with this browser context.
// This must be called before the browser context is actually destroyed
// and before a clean-up task for its corresponding IO thread residents
// (e.g. ResourceContext) is posted, so that the classes that hung on
// StoragePartition can have time to do necessary cleanups on IO thread.
ShutdownStoragePartitions();
if (resource_context_.get()) {
// Destruction of the ResourceContext will trigger destruction of all
// associated network requests.
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
resource_context_.release());
}
visitedlink_listener_->RemoveListenerForContext(this);
// The FontFamilyCache references the ProxyService so delete it before the
// ProxyService is deleted.
SetUserData(&kFontFamilyCacheKey, nullptr);
pref_proxy_config_tracker_->DetachFromPrefService();
if (host_content_settings_map_)
host_content_settings_map_->ShutdownOnUIThread();
// Delete the download manager delegate here because otherwise we'll crash
// when it's accessed from the content::BrowserContext destructor.
if (download_manager_delegate_)
download_manager_delegate_.reset(nullptr);
}
void CefBrowserContext::Initialize() {
cache_path_ = base::FilePath(CefString(&settings_.cache_path));
if (!cache_path_.empty())
g_manager.Get().SetImplPath(this, cache_path_);
if (!!settings_.persist_session_cookies) {
set_should_persist_session_cookies(true);
}
key_ = std::make_unique<ProfileKey>(cache_path_);
SimpleKeyMap::GetInstance()->Associate(this, key_.get());
// Initialize the PrefService object.
pref_service_ = browser_prefs::CreatePrefService(
this, cache_path_, !!settings_.persist_user_preferences);
resource_context_.reset(new CefResourceContext(IsOffTheRecord()));
// This must be called before creating any services to avoid hitting
// DependencyManager::AssertContextWasntDestroyed when creating/destroying
// multiple browser contexts (due to pointer address reuse).
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
this);
const bool extensions_enabled = extensions::ExtensionsEnabled();
if (extensions_enabled) {
// Create the custom ExtensionSystem first because other KeyedServices
// depend on it.
extension_system_ = static_cast<extensions::CefExtensionSystem*>(
extensions::ExtensionSystem::Get(this));
extension_system_->InitForRegularProfile(true);
// Make sure the ProcessManager is created so that it receives extension
// load notifications. This is necessary for the proper initialization of
// background/event pages.
extensions::ProcessManager::Get(this);
}
// Initialize visited links management.
base::FilePath visited_link_path;
if (!cache_path_.empty())
visited_link_path = cache_path_.Append(FILE_PATH_LITERAL("Visited Links"));
visitedlink_listener_ = new CefVisitedLinkListener;
visitedlink_master_.reset(new visitedlink::VisitedLinkWriter(
visitedlink_listener_, this, !visited_link_path.empty(), false,
visited_link_path, 0));
visitedlink_listener_->CreateListenerForContext(this);
visitedlink_master_->Init();
// Initialize proxy configuration tracker.
pref_proxy_config_tracker_.reset(new PrefProxyConfigTrackerImpl(
GetPrefs(), base::CreateSingleThreadTaskRunner({BrowserThread::IO})));
// Spell checking support and possibly other subsystems retrieve the
// PrefService associated with a BrowserContext via UserPrefs::Get().
PrefService* pref_service = GetPrefs();
DCHECK(pref_service);
user_prefs::UserPrefs::Set(this, pref_service);
key_->SetPrefs(pref_service);
if (extensions_enabled)
extension_system_->Init();
ChromePluginServiceFilter::GetInstance()->RegisterProfile(this);
}
void CefBrowserContext::AddCefRequestContext(CefRequestContextImpl* context) {
@@ -198,35 +366,36 @@ void CefBrowserContext::RemoveCefRequestContext(
CefRequestContextImpl* context) {
CEF_REQUIRE_UIT();
if (extensions::ExtensionsEnabled()) {
extension_system()->OnRequestContextDeleted(context);
}
request_context_set_.erase(context);
// Delete ourselves when the reference count reaches zero.
if (request_context_set_.empty()) {
Shutdown();
if (request_context_set_.empty())
delete this;
}
}
// static
CefBrowserContext* CefBrowserContext::FromCachePath(
CefBrowserContext* CefBrowserContext::GetForCachePath(
const base::FilePath& cache_path) {
return g_manager.Get().GetImplFromPath(cache_path);
return g_manager.Get().GetImplForPath(cache_path);
}
// static
CefBrowserContext* CefBrowserContext::FromIDs(int render_process_id,
int render_frame_id,
int frame_tree_node_id,
bool require_frame_match) {
return g_manager.Get().GetImplFromIDs(render_process_id, render_frame_id,
frame_tree_node_id,
require_frame_match);
CefBrowserContext* CefBrowserContext::GetForIDs(int render_process_id,
int render_frame_id,
int frame_tree_node_id,
bool require_frame_match) {
return g_manager.Get().GetImplForIDs(render_process_id, render_frame_id,
frame_tree_node_id, require_frame_match);
}
// static
CefBrowserContext* CefBrowserContext::FromBrowserContext(
const content::BrowserContext* context) {
return g_manager.Get().GetImplFromBrowserContext(context);
CefBrowserContext* CefBrowserContext::GetForContext(
content::BrowserContext* context) {
return g_manager.Get().GetImplForContext(context);
}
// static
@@ -234,6 +403,194 @@ std::vector<CefBrowserContext*> CefBrowserContext::GetAll() {
return g_manager.Get().GetAllImpl();
}
content::ResourceContext* CefBrowserContext::GetResourceContext() {
return resource_context_.get();
}
content::ClientHintsControllerDelegate*
CefBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;
}
void CefBrowserContext::SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) {
// This method is called for Extension support.
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, std::move(closure));
}
ChromeZoomLevelPrefs* CefBrowserContext::GetZoomLevelPrefs() {
return static_cast<ChromeZoomLevelPrefs*>(
GetStoragePartition(this, nullptr)->GetZoomLevelDelegate());
}
scoped_refptr<network::SharedURLLoaderFactory>
CefBrowserContext::GetURLLoaderFactory() {
return GetDefaultStoragePartition(this)
->GetURLLoaderFactoryForBrowserProcess();
}
base::FilePath CefBrowserContext::GetPath() {
return cache_path_;
}
base::FilePath CefBrowserContext::GetPath() const {
return cache_path_;
}
std::unique_ptr<content::ZoomLevelDelegate>
CefBrowserContext::CreateZoomLevelDelegate(
const base::FilePath& partition_path) {
if (cache_path_.empty())
return std::unique_ptr<content::ZoomLevelDelegate>();
return base::WrapUnique(new ChromeZoomLevelPrefs(
GetPrefs(), cache_path_, partition_path,
zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
}
bool CefBrowserContext::IsOffTheRecord() const {
// CEF contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false;
}
content::DownloadManagerDelegate*
CefBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_) {
content::DownloadManager* manager =
BrowserContext::GetDownloadManager(this);
download_manager_delegate_.reset(new CefDownloadManagerDelegate(manager));
}
return download_manager_delegate_.get();
}
content::BrowserPluginGuestManager* CefBrowserContext::GetGuestManager() {
DCHECK(extensions::ExtensionsEnabled());
return guest_view::GuestViewManager::FromBrowserContext(this);
}
storage::SpecialStoragePolicy* CefBrowserContext::GetSpecialStoragePolicy() {
return nullptr;
}
content::PushMessagingService* CefBrowserContext::GetPushMessagingService() {
return nullptr;
}
content::StorageNotificationService*
CefBrowserContext::GetStorageNotificationService() {
return nullptr;
}
content::SSLHostStateDelegate* CefBrowserContext::GetSSLHostStateDelegate() {
if (!ssl_host_state_delegate_.get())
ssl_host_state_delegate_.reset(new CefSSLHostStateDelegate());
return ssl_host_state_delegate_.get();
}
content::PermissionControllerDelegate*
CefBrowserContext::GetPermissionControllerDelegate() {
return nullptr;
}
content::BackgroundFetchDelegate*
CefBrowserContext::GetBackgroundFetchDelegate() {
return nullptr;
}
content::BackgroundSyncController*
CefBrowserContext::GetBackgroundSyncController() {
return nullptr;
}
content::BrowsingDataRemoverDelegate*
CefBrowserContext::GetBrowsingDataRemoverDelegate() {
return nullptr;
}
PrefService* CefBrowserContext::GetPrefs() {
return pref_service_.get();
}
const PrefService* CefBrowserContext::GetPrefs() const {
return pref_service_.get();
}
ProfileKey* CefBrowserContext::GetProfileKey() const {
DCHECK(key_);
return key_.get();
}
policy::SchemaRegistryService*
CefBrowserContext::GetPolicySchemaRegistryService() {
NOTREACHED();
return nullptr;
}
policy::UserCloudPolicyManager* CefBrowserContext::GetUserCloudPolicyManager() {
NOTREACHED();
return nullptr;
}
policy::ProfilePolicyConnector* CefBrowserContext::GetProfilePolicyConnector() {
NOTREACHED();
return nullptr;
}
const policy::ProfilePolicyConnector*
CefBrowserContext::GetProfilePolicyConnector() const {
NOTREACHED();
return nullptr;
}
const CefRequestContextSettings& CefBrowserContext::GetSettings() const {
return settings_;
}
HostContentSettingsMap* CefBrowserContext::GetHostContentSettingsMap() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!host_content_settings_map_.get()) {
// The |is_incognito_profile| and |is_guest_profile| arguments are
// intentionally set to false as they otherwise limit the types of values
// that can be stored in the settings map (for example, default values set
// via DefaultProvider::SetWebsiteSetting).
host_content_settings_map_ =
new HostContentSettingsMap(GetPrefs(), false, false, false, false);
// Change the default plugin policy.
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
const std::string& plugin_policy_str =
command_line->GetSwitchValueASCII(switches::kPluginPolicy);
if (!plugin_policy_str.empty()) {
ContentSetting plugin_policy = CONTENT_SETTING_ALLOW;
if (base::LowerCaseEqualsASCII(plugin_policy_str,
switches::kPluginPolicy_Detect)) {
plugin_policy = CONTENT_SETTING_DETECT_IMPORTANT_CONTENT;
} else if (base::LowerCaseEqualsASCII(plugin_policy_str,
switches::kPluginPolicy_Block)) {
plugin_policy = CONTENT_SETTING_BLOCK;
}
host_content_settings_map_->SetDefaultContentSetting(
ContentSettingsType::PLUGINS, plugin_policy);
}
}
return host_content_settings_map_.get();
}
void CefBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
visitedlink_master_->AddURLs(urls);
}
void CefBrowserContext::RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) {
// Called when visited links will not or cannot be loaded from disk.
enumerator->OnComplete(true);
}
void CefBrowserContext::OnRenderFrameCreated(
CefRequestContextImpl* request_context,
int render_process_id,
@@ -254,14 +611,15 @@ void CefBrowserContext::OnRenderFrameCreated(
handler_map_.AddHandler(render_process_id, render_frame_id,
frame_tree_node_id, handler);
if (iothread_state_) {
if (resource_context_) {
// Using base::Unretained() is safe because both this callback and
// possible deletion of |iothread_state_| will execute on the IO thread,
// possible deletion of |resource_context_| will execute on the IO thread,
// and this callback will be executed first.
CEF_POST_TASK(CEF_IOT, base::Bind(&CefIOThreadState::AddHandler,
base::Unretained(iothread_state_.get()),
render_process_id, render_frame_id,
frame_tree_node_id, handler));
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefResourceContext::AddHandler,
base::Unretained(resource_context_.get()),
render_process_id, render_frame_id,
frame_tree_node_id, handler));
}
}
}
@@ -292,14 +650,15 @@ void CefBrowserContext::OnRenderFrameDeleted(
handler_map_.RemoveHandler(render_process_id, render_frame_id,
frame_tree_node_id);
if (iothread_state_) {
if (resource_context_) {
// Using base::Unretained() is safe because both this callback and
// possible deletion of |iothread_state_| will execute on the IO thread,
// possible deletion of |resource_context_| will execute on the IO thread,
// and this callback will be executed first.
CEF_POST_TASK(CEF_IOT, base::Bind(&CefIOThreadState::RemoveHandler,
base::Unretained(iothread_state_.get()),
render_process_id, render_frame_id,
frame_tree_node_id));
CEF_POST_TASK(
CEF_IOT,
base::Bind(&CefResourceContext::RemoveHandler,
base::Unretained(resource_context_.get()),
render_process_id, render_frame_id, frame_tree_node_id));
}
}
@@ -401,74 +760,56 @@ void CefBrowserContext::ClearPluginLoadDecision(int render_process_id) {
}
void CefBrowserContext::RegisterSchemeHandlerFactory(
const CefString& scheme_name,
const CefString& domain_name,
const std::string& scheme_name,
const std::string& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory) {
if (iothread_state_) {
if (resource_context_) {
// Using base::Unretained() is safe because both this callback and possible
// deletion of |iothread_state_| will execute on the IO thread, and this
// deletion of |resource_context_| will execute on the IO thread, and this
// callback will be executed first.
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefIOThreadState::RegisterSchemeHandlerFactory,
base::Unretained(iothread_state_.get()),
base::Bind(&CefResourceContext::RegisterSchemeHandlerFactory,
base::Unretained(resource_context_.get()),
scheme_name, domain_name, factory));
}
}
void CefBrowserContext::ClearSchemeHandlerFactories() {
if (iothread_state_) {
if (resource_context_) {
// Using base::Unretained() is safe because both this callback and possible
// deletion of |iothread_state_| will execute on the IO thread, and this
// deletion of |resource_context_| will execute on the IO thread, and this
// callback will be executed first.
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefIOThreadState::ClearSchemeHandlerFactories,
base::Unretained(iothread_state_.get())));
base::Bind(&CefResourceContext::ClearSchemeHandlerFactories,
base::Unretained(resource_context_.get())));
}
}
void CefBrowserContext::LoadExtension(
const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler,
CefRefPtr<CefRequestContext> loader_context) {
NOTIMPLEMENTED();
if (handler)
handler->OnExtensionLoadFailed(ERR_ABORTED);
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
CEF_REQUIRE_UIT();
return GetDefaultStoragePartition(this)->GetNetworkContext();
}
bool CefBrowserContext::GetExtensions(std::vector<CefString>& extension_ids) {
NOTIMPLEMENTED();
return false;
}
CefRefPtr<CefExtension> CefBrowserContext::GetExtension(
const CefString& extension_id) {
NOTIMPLEMENTED();
return nullptr;
}
bool CefBrowserContext::UnloadExtension(const CefString& extension_id) {
NOTIMPLEMENTED();
return false;
DownloadPrefs* CefBrowserContext::GetDownloadPrefs() {
CEF_REQUIRE_UIT();
if (!download_prefs_) {
download_prefs_.reset(new DownloadPrefs(this));
}
return download_prefs_.get();
}
bool CefBrowserContext::IsPrintPreviewSupported() const {
return true;
}
void CefBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {}
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
CEF_REQUIRE_UIT();
auto browser_context = AsBrowserContext();
return browser_context->GetDefaultStoragePartition(browser_context)
->GetNetworkContext();
if (!extensions::PrintPreviewEnabled())
return false;
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
}
CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
CEF_REQUIRE_UIT();
if (!media_router_manager_) {
media_router_manager_.reset(new CefMediaRouterManager(AsBrowserContext()));
media_router_manager_.reset(new CefMediaRouterManager(this));
}
return media_router_manager_.get();
}

View File

@@ -7,17 +7,23 @@
#pragma once
#include <set>
#include <vector>
#include "include/cef_request_context_handler.h"
#include "libcef/browser/chrome_profile_stub.h"
#include "libcef/browser/request_context_handler_map.h"
#include "libcef/browser/resource_context.h"
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/common/plugin.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "components/proxy_config/pref_proxy_config_tracker.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "url/origin.h"
/*
@@ -25,30 +31,31 @@
//
// WC = WebContents
// Content API representation of a browser. Created by BHI or the system (for
// popups) and owned by BHI. Keeps a pointer to the content::BrowserContext.
// popups) and owned by BHI. Keeps a pointer to BC.
//
// BHI = CefBrowserHostImpl
// Implements the CefBrowser and CefBrowserHost interfaces which are exposed
// to clients. References an RCI instance. Owns a WC. Lifespan is controlled
// by client references and CefBrowserInfoManager (until the browser has
// closed).
// to clients. References an RCI instance. Owns a WC. Life span is controlled
// by client references and CefContentBrowserClient.
//
// RCI = CefRequestContextImpl
// Implements the CefRequestContext interface which is exposed to clients.
// Creates or references a BC. Lifespan is controlled by client references and
// BrowserMainParts (for the global RCI).
// References the isolated BC.
//
// BC = CefBrowserContext
// Is/owns the content::BrowserContext which is the entry point from WC.
// Owns the IOTS and creates the SPI indirectly. Potentially shared by
// multiple RCI. Deletes itself when no longer needed by RCI.
// Entry point from WC when using an isolated RCI. Owns the RC and creates the
// SPI indirectly. Owned by CefBrowserMainParts for the global context or RCI
// for non-global contexts.
//
// SPI = content::StoragePartitionImpl
// Owns storage-related objects like Quota, IndexedDB, Cache, etc. Created by
// StoragePartitionImplMap::Get(). Life span is controlled indirectly by BC.
// StoragePartitionImplMap::Get(). Provides access to the URCG. Life span is
// controlled indirectly by BC.
//
// IOTS = CefIOThreadState
// Stores state for access on the IO thread. Life span is controlled by BC.
// RC = CefResourceContext
// Acts as a bridge for resource loading. Network request life span is tied to
// this object. Must be destroyed before the associated URCG. Life span is
// controlled by BC.
//
//
// Relationship diagram:
@@ -56,65 +63,142 @@
// own = ownership (std::unique_ptr)
// ptr = raw pointer
//
// BHI -ref-> RCI -ptr-> BC -own-> SPI, IOTS
// ^
// BHI -own-> WC -ptr--/
// CefBrowserMainParts
// |
// own
// v
// BHI -own-> WC -ptr-> BC -own-> SPI
//
// BHI -ref-> RCI -own-> BC -own-> RC
//
//
// How shutdown works:
// 1. CefBrowserHostImpl::DestroyBrowser is called on the UI thread after the
// browser is closed and deletes the WebContents.
// 1. CefBrowserHostImpl is destroyed on any thread when the last reference
// is released.
// 1. CefBrowserHostImpl is destroyed on any thread due to browser close,
// ref release, etc.
// 2. CefRequestContextImpl is destroyed (possibly asynchronously) on the UI
// thread when the last reference is released.
// 3. CefBrowserContext is destroyed on the UI thread when no longer needed
// by any CefRequestContextImpl (via RemoveCefRequestContext).
// 4. CefIOThreadState is destroyed asynchronously on the IO thread after
// the owning CefBrowserContext is destroyed.
// thread due to CefBrowserHostImpl destruction, ref release, etc.
// 3. CefBrowserContext is destroyed on the UI thread due to
// CefRequestContextImpl destruction or deletion in
// CefBrowserMainParts::PostMainMessageLoopRun().
// 4. CefResourceContext is destroyed asynchronously on the IO thread due to
// CefBrowserContext destruction. This cancels/destroys any pending
// network requests.
*/
namespace content {
class BrowserContext;
}
class CefDownloadManagerDelegate;
class CefMediaRouterManager;
class CefRequestContextImpl;
class CefIOThreadState;
class Profile;
class CefSSLHostStateDelegate;
class CefVisitedLinkListener;
class HostContentSettingsMap;
class PrefService;
// Main entry point for configuring behavior on a per-RequestContext basis. The
// content::BrowserContext represented by this class is passed to
// WebContents::Create in CefBrowserHostImpl::CreateInternal. Only accessed on
// the UI thread unless otherwise indicated.
class CefBrowserContext {
namespace extensions {
class CefExtensionSystem;
}
namespace visitedlink {
class VisitedLinkWriter;
}
// Main entry point for configuring behavior on a per-browser basis. An instance
// of this class is passed to WebContents::Create in CefBrowserHostImpl::
// CreateInternal. Only accessed on the UI thread unless otherwise indicated.
class CefBrowserContext : public ChromeProfileStub,
public visitedlink::VisitedLinkDelegate {
public:
explicit CefBrowserContext(const CefRequestContextSettings& settings);
// Returns the existing instance, if any, associated with the specified
// |cache_path|.
static CefBrowserContext* FromCachePath(const base::FilePath& cache_path);
static CefBrowserContext* GetForCachePath(const base::FilePath& cache_path);
// Returns the existing instance, if any, associated with the specified IDs.
// See comments on IsAssociatedContext() for usage.
static CefBrowserContext* FromIDs(int render_process_id,
int render_frame_id,
int frame_tree_node_id,
bool require_frame_match);
static CefBrowserContext* GetForIDs(int render_process_id,
int render_frame_id,
int frame_tree_node_id,
bool require_frame_match);
// Returns the underlying CefBrowserContext if any.
static CefBrowserContext* FromBrowserContext(
const content::BrowserContext* context);
static CefBrowserContext* GetForContext(content::BrowserContext* context);
// Returns all existing CefBrowserContext.
static std::vector<CefBrowserContext*> GetAll();
// Returns the content and chrome layer representations of the context.
virtual content::BrowserContext* AsBrowserContext() = 0;
virtual Profile* AsProfile() = 0;
// Must be called immediately after this object is created.
void Initialize();
// Called from CefRequestContextImpl to track associated objects. This
// object will delete itself when the count reaches zero.
// Track associated CefRequestContextImpl objects. This object will delete
// itself when the count reaches zero.
void AddCefRequestContext(CefRequestContextImpl* context);
virtual void RemoveCefRequestContext(CefRequestContextImpl* context);
void RemoveCefRequestContext(CefRequestContextImpl* context);
// BrowserContext methods.
content::ResourceContext* GetResourceContext() override;
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
void SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) override;
base::FilePath GetPath() override;
base::FilePath GetPath() const override;
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath& partition_path) override;
bool IsOffTheRecord() const override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::PushMessagingService* GetPushMessagingService() override;
content::StorageNotificationService* GetStorageNotificationService() override;
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::PermissionControllerDelegate* GetPermissionControllerDelegate()
override;
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
content::BackgroundSyncController* GetBackgroundSyncController() override;
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()
override;
// Profile methods.
ChromeZoomLevelPrefs* GetZoomLevelPrefs() override;
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
PrefService* GetPrefs() override;
bool AllowsBrowserWindows() const override { return false; }
const PrefService* GetPrefs() const override;
ProfileKey* GetProfileKey() const override;
policy::SchemaRegistryService* GetPolicySchemaRegistryService() override;
policy::UserCloudPolicyManager* GetUserCloudPolicyManager() override;
policy::ProfilePolicyConnector* GetProfilePolicyConnector() override;
const policy::ProfilePolicyConnector* GetProfilePolicyConnector()
const override;
// Values checked in ProfileNetworkContextService::CreateNetworkContextParams
// when creating the NetworkContext.
bool ShouldRestoreOldSessionCookies() override {
return should_persist_session_cookies_;
}
bool ShouldPersistSessionCookies() override {
return should_persist_session_cookies_;
}
base::Optional<std::vector<std::string>> GetCookieableSchemes() override {
return cookieable_schemes_;
}
// visitedlink::VisitedLinkDelegate methods.
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
// Returns the settings associated with this object. Safe to call from any
// thread.
const CefRequestContextSettings& GetSettings() const;
// Settings for plugins and extensions.
HostContentSettingsMap* GetHostContentSettingsMap();
// Called from CefBrowserHostImpl::DidNavigateAnyFrame to update the table of
// visited links.
void AddVisitedURLs(const std::vector<GURL>& urls);
// Called from CefRequestContextImpl::OnRenderFrameCreated.
void OnRenderFrameCreated(CefRequestContextImpl* request_context,
@@ -170,72 +254,79 @@ class CefBrowserContext {
void ClearPluginLoadDecision(int render_process_id);
// Called from CefRequestContextImpl methods of the same name.
void RegisterSchemeHandlerFactory(const CefString& scheme_name,
const CefString& domain_name,
void RegisterSchemeHandlerFactory(const std::string& scheme_name,
const std::string& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory);
void ClearSchemeHandlerFactories();
// TODO(chrome-runtime): Make these extension methods pure virtual.
virtual void LoadExtension(const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler,
CefRefPtr<CefRequestContext> loader_context);
virtual bool GetExtensions(std::vector<CefString>& extension_ids);
virtual CefRefPtr<CefExtension> GetExtension(const CefString& extension_id);
// Called from CefExtensionImpl::Unload().
virtual bool UnloadExtension(const CefString& extension_id);
// Returns true if this context supports print preview.
virtual bool IsPrintPreviewSupported() const;
// Called from CefBrowserHostImpl::DidNavigateAnyFrame to update the table of
// visited links.
virtual void AddVisitedURLs(const std::vector<GURL>& urls);
network::mojom::NetworkContext* GetNetworkContext();
CefMediaRouterManager* GetMediaRouterManager();
using CookieableSchemes = base::Optional<std::vector<std::string>>;
void set_cookieable_schemes(const CookieableSchemes& schemes) {
void set_should_persist_session_cookies(bool value) {
should_persist_session_cookies_ = value;
}
void set_cookieable_schemes(
base::Optional<std::vector<std::string>> schemes) {
cookieable_schemes_ = schemes;
}
CookieableSchemes cookieable_schemes() const { return cookieable_schemes_; }
// These accessors are safe to call from any thread because the values don't
// change during this object's lifespan.
const CefRequestContextSettings& settings() const { return settings_; }
base::FilePath cache_path() const { return cache_path_; }
CefIOThreadState* iothread_state() const { return iothread_state_.get(); }
CefResourceContext* resource_context() const {
return resource_context_.get();
}
extensions::CefExtensionSystem* extension_system() const {
return extension_system_;
}
// Used to hold a WeakPtr reference to this this object. The Getter returns
// nullptr if this object has already been destroyed.
// Called from DownloadPrefs::FromBrowserContext.
DownloadPrefs* GetDownloadPrefs();
// Returns true if this context supports print preview.
bool IsPrintPreviewSupported() const;
CefMediaRouterManager* GetMediaRouterManager();
// Returns the BrowserContext, or nullptr if the BrowserContext has already
// been destroyed.
using Getter = base::RepeatingCallback<CefBrowserContext*()>;
Getter getter() const { return getter_; }
protected:
explicit CefBrowserContext(const CefRequestContextSettings& settings);
virtual ~CefBrowserContext();
private:
// Allow deletion via std::unique_ptr().
friend std::default_delete<CefBrowserContext>;
// Will be called immediately after this object is created.
virtual void Initialize();
~CefBrowserContext() override;
// Will be called immediately before this object is deleted.
virtual void Shutdown();
// Members initialized during construction or Initialize() are safe to access
// from any thread.
// Members initialized during construction are safe to access from any thread.
const CefRequestContextSettings settings_;
base::FilePath cache_path_;
private:
std::unique_ptr<CefIOThreadState> iothread_state_;
CookieableSchemes cookieable_schemes_;
std::unique_ptr<CefMediaRouterManager> media_router_manager_;
// CefRequestContextImpl objects referencing this object.
std::set<CefRequestContextImpl*> request_context_set_;
std::unique_ptr<PrefService> pref_service_;
std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_master_;
// |visitedlink_listener_| is owned by visitedlink_master_.
CefVisitedLinkListener* visitedlink_listener_;
bool should_persist_session_cookies_ = false;
base::Optional<std::vector<std::string>> cookieable_schemes_;
std::unique_ptr<CefResourceContext> resource_context_;
// Owned by the KeyedService system.
extensions::CefExtensionSystem* extension_system_ = nullptr;
// The key to index KeyedService instances created by
// SimpleKeyedServiceFactory.
std::unique_ptr<ProfileKey> key_;
std::unique_ptr<DownloadPrefs> download_prefs_;
std::unique_ptr<CefMediaRouterManager> media_router_manager_;
// Map IDs to CefRequestContextHandler objects.
CefRequestContextHandlerMap handler_map_;
@@ -259,10 +350,6 @@ class CefBrowserContext {
typedef std::set<int> NodeIdSet;
NodeIdSet node_id_set_;
#if DCHECK_IS_ON()
bool is_shutdown_ = false;
#endif
Getter getter_;
base::WeakPtrFactory<CefBrowserContext> weak_ptr_factory_;

File diff suppressed because it is too large Load Diff

View File

@@ -42,10 +42,6 @@ class Extension;
class ExtensionHost;
} // namespace extensions
namespace gfx {
class ImageSkia;
}
#if defined(USE_AURA)
namespace views {
class Widget;
@@ -285,6 +281,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Returns true if this browser is views-hosted.
bool IsViewsHosted() const;
// Returns true if this browser supports print preview.
bool IsPrintPreviewSupported() const;
// Returns true if this browser supports picture-in-picture.
bool IsPictureInPictureSupported() const;
@@ -351,8 +350,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
}
// Accessors that must be called on the UI thread.
content::BrowserContext* GetBrowserContext() const;
extensions::ExtensionHost* GetExtensionHost() const;
content::BrowserContext* GetBrowserContext();
extensions::ExtensionHost* extension_host() const { return extension_host_; }
void OnSetFocus(cef_focus_source_t source);
@@ -365,6 +364,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool HandleContextMenu(content::WebContents* web_contents,
const content::ContextMenuParams& params);
// Returns the WebContents most likely to handle an action. If extensions are
// enabled and this browser has a full-page guest (for example, a full-page
// PDF viewer extension) then the guest's WebContents will be returned.
// Otherwise, the browser's WebContents will be returned.
content::WebContents* GetActionableWebContents() const;
enum DestructionState {
DESTRUCTION_STATE_NONE = 0,
DESTRUCTION_STATE_PENDING,
@@ -399,6 +404,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool proceed,
bool* proceed_to_fire_unload) override;
bool TakeFocus(content::WebContents* source, bool reverse) override;
bool HandleContextMenu(content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params) override;
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
@@ -430,11 +436,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
content::WebContents* source) override;
void RunFileChooser(content::RenderFrameHost* render_frame_host,
scoped_refptr<content::FileSelectListener> listener,
std::unique_ptr<content::FileSelectListener> listener,
const blink::mojom::FileChooserParams& params) override;
bool EmbedsFullscreenWidget() override;
void EnterFullscreenModeForTab(
content::RenderFrameHost* requesting_frame,
content::WebContents* web_contents,
const GURL& origin,
const blink::mojom::FullscreenOptions& options) override;
void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
bool IsFullscreenForTabOrPending(
@@ -486,7 +493,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override;
void DidUpdateFaviconURL(
content::RenderFrameHost* render_frame_host,
const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
void OnAudioStateChanged(bool audible) override;
bool OnMessageReceived(const IPC::Message& message,
@@ -497,9 +503,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
void AccessibilityLocationChangesReceived(
const std::vector<content::AXLocationChangeNotificationDetails>& locData)
override;
void OnWebContentsFocused(
content::RenderWidgetHost* render_widget_host) override;
void WebContentsDestroyed() override;
// Manage observer objects. The observer must either outlive this object or
// remove itself before destruction. These methods can only be called on the
@@ -523,8 +529,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
std::unique_ptr<NavigationLock> CreateNavigationLock();
private:
friend class CefBrowserPlatformDelegateAlloy;
static CefRefPtr<CefBrowserHostImpl> CreateInternal(
const CefBrowserSettings& settings,
CefRefPtr<CefClient> client,
@@ -552,9 +556,20 @@ class CefBrowserHostImpl : public CefBrowserHost,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension);
void set_owned_web_contents(content::WebContents* owned_contents);
// Give the platform delegate an opportunity to create the host window.
bool CreateHostWindow();
// Create/delete the host for extensions.
void CreateExtensionHost(const extensions::Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
extensions::ViewType host_type);
void DestroyExtensionHost();
void OnExtensionHostDeleted();
// Returns true if navigation actions are currently locked.
bool navigation_locked() const;
// Action to be executed once the navigation lock is released.
@@ -573,6 +588,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Create the CefFileDialogManager if it doesn't already exist.
void EnsureFileDialogManager();
void ConfigureAutoResize();
void StartAudioCapturer();
void OnRecentlyAudibleTimerFired();
@@ -589,8 +606,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
const bool is_windowless_;
const bool is_views_hosted_;
CefWindowHandle host_window_handle_ = kNullWindowHandle;
CefRefPtr<CefExtension> extension_;
bool is_background_host_ = false;
// Non-nullptr if this object owns the WebContents. Will be nullptr for popup
// browsers between the calls to WebContentsCreated() and AddNewContents(),
// and may never be set if the parent browser is destroyed during popup
// creation.
std::unique_ptr<content::WebContents> owned_web_contents_;
// Volatile state information. All access must be protected by the state lock.
base::Lock state_lock_;
@@ -646,6 +667,14 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Observers that want to be notified of changes to this object.
base::ObserverList<Observer>::Unchecked observers_;
// Used to provide unique incremental IDs for each find request.
int find_request_id_counter_ = 0;
// Used when the browser is hosting an extension.
extensions::ExtensionHost* extension_host_ = nullptr;
CefRefPtr<CefExtension> extension_;
bool is_background_host_ = false;
// Used for capturing audio for CefAudioHandler.
std::unique_ptr<CefAudioCapturer> audio_capturer_;
@@ -654,6 +683,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
// being audible again before it fires.
base::OneShotTimer recently_audible_timer_;
// Used with auto-resize.
bool auto_resize_enabled_ = false;
gfx::Size auto_resize_min_;
gfx::Size auto_resize_max_;
IMPLEMENT_REFCOUNTING(CefBrowserHostImpl);
DISALLOW_COPY_AND_ASSIGN(CefBrowserHostImpl);
};

View File

@@ -157,7 +157,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
CefPopupFeatures cef_features;
TranslatePopupFeatures(features, cef_features);
#if (defined(OS_WIN) || defined(OS_MAC))
#if (defined(OS_WIN) || defined(OS_MACOSX))
// Default to the size from the popup features.
if (cef_features.xSet)
window_info->x = cef_features.x;

View File

@@ -64,7 +64,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
bool is_windowless,
CefRefPtr<CefDictionaryValue> extra_info);
// Called from AlloyContentBrowserClient::CanCreateWindow. See comments on
// Called from CefContentBrowserClient::CanCreateWindow. See comments on
// PendingPopup for more information.
bool CanCreateWindow(content::RenderFrameHost* opener,
const GURL& target_url,
@@ -151,7 +151,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
// Store state information about pending popups. Call order is:
// - AlloyContentBrowserClient::CanCreateWindow (UIT)
// - CefContentBrowserClient::CanCreateWindow (UIT)
// Provides an opportunity to cancel the popup (calls OnBeforePopup) and
// creates the new platform delegate for the popup. If the popup owner is
// an extension guest view then the popup is canceled and

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/alloy_browser_main.h"
#include "libcef/browser/browser_main.h"
#include <stdint.h>
@@ -10,6 +10,7 @@
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_context_keyed_service_factories.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/extensions/extension_system_factory.h"
@@ -18,12 +19,12 @@
#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"
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
#include "chrome/browser/browser_process.h"
@@ -57,7 +58,7 @@
#endif // defined(USE_AURA)
#if defined(TOOLKIT_VIEWS)
#if defined(OS_MAC)
#if defined(OS_MACOSX)
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_views_delegate.h"
#else
@@ -73,15 +74,15 @@
#include "libcef/browser/printing/print_dialog_linux.h"
#endif
AlloyBrowserMainParts::AlloyBrowserMainParts(
CefBrowserMainParts::CefBrowserMainParts(
const content::MainFunctionParams& parameters)
: BrowserMainParts(), devtools_delegate_(nullptr) {}
AlloyBrowserMainParts::~AlloyBrowserMainParts() {
CefBrowserMainParts::~CefBrowserMainParts() {
constrained_window::SetConstrainedWindowViewsClient(nullptr);
}
int AlloyBrowserMainParts::PreEarlyInitialization() {
int CefBrowserMainParts::PreEarlyInitialization() {
#if defined(USE_AURA) && defined(OS_LINUX)
// TODO(linux): Consider using a real input method or
// views::LinuxUI::SetInstance.
@@ -91,7 +92,7 @@ int AlloyBrowserMainParts::PreEarlyInitialization() {
return service_manager::RESULT_CODE_NORMAL_EXIT;
}
void AlloyBrowserMainParts::ToolkitInitialized() {
void CefBrowserMainParts::ToolkitInitialized() {
SetConstrainedWindowViewsClient(CreateCefConstrainedWindowViewsClient());
#if defined(USE_AURA)
CHECK(aura::Env::GetInstance());
@@ -100,12 +101,12 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
#if defined(OS_WIN)
ui::CursorLoaderWin::SetCursorResourceModule(
CefAppManager::Get()->GetResourceDllName());
CefContentBrowserClient::Get()->GetResourceDllName());
#endif
#endif // defined(USE_AURA)
#if defined(TOOLKIT_VIEWS)
#if defined(OS_MAC)
#if defined(OS_MACOSX)
views_delegate_ = std::make_unique<ChromeViewsDelegate>();
layout_provider_ = ChromeLayoutProvider::CreateLayoutProvider();
#else
@@ -114,7 +115,7 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
#endif // defined(TOOLKIT_VIEWS)
}
void AlloyBrowserMainParts::PreMainMessageLoopStart() {
void CefBrowserMainParts::PreMainMessageLoopStart() {
#if defined(USE_AURA) && defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif
@@ -132,7 +133,7 @@ void AlloyBrowserMainParts::PreMainMessageLoopStart() {
#endif // defined(OS_WIN)
}
void AlloyBrowserMainParts::PostMainMessageLoopStart() {
void CefBrowserMainParts::PostMainMessageLoopStart() {
#if defined(OS_LINUX)
printing::PrintingContextLinux::SetCreatePrintDialogFunction(
&CefPrintDialogLinux::CreatePrintDialog);
@@ -141,7 +142,7 @@ void AlloyBrowserMainParts::PostMainMessageLoopStart() {
#endif
}
int AlloyBrowserMainParts::PreCreateThreads() {
int CefBrowserMainParts::PreCreateThreads() {
#if defined(OS_WIN)
PlatformInitialize();
#endif
@@ -156,7 +157,7 @@ int AlloyBrowserMainParts::PreCreateThreads() {
return 0;
}
void AlloyBrowserMainParts::PreMainMessageLoopRun() {
void CefBrowserMainParts::PreMainMessageLoopRun() {
#if defined(USE_AURA)
display::Screen::SetScreenInstance(views::CreateDesktopScreen());
#endif
@@ -195,8 +196,8 @@ void AlloyBrowserMainParts::PreMainMessageLoopRun() {
// Create the global RequestContext.
global_request_context_ =
CefRequestContextImpl::CreateGlobalRequestContext(settings);
auto browser_context =
global_request_context_->GetBrowserContext()->AsBrowserContext();
CefBrowserContext* browser_context = static_cast<CefBrowserContext*>(
global_request_context_->GetBrowserContext());
CefDevToolsManagerDelegate::StartHttpHandler(browser_context);
@@ -212,7 +213,7 @@ void AlloyBrowserMainParts::PreMainMessageLoopRun() {
scheme::RegisterWebUIControllerFactory();
}
void AlloyBrowserMainParts::PostMainMessageLoopRun() {
void CefBrowserMainParts::PostMainMessageLoopRun() {
// NOTE: Destroy objects in reverse order of creation.
CefDevToolsManagerDelegate::StopHttpHandler();
@@ -222,7 +223,7 @@ void AlloyBrowserMainParts::PostMainMessageLoopRun() {
global_request_context_ = nullptr;
}
void AlloyBrowserMainParts::PostDestroyThreads() {
void CefBrowserMainParts::PostDestroyThreads() {
if (extensions::ExtensionsEnabled()) {
extensions::ExtensionsBrowserClient::Set(nullptr);
extensions_browser_client_.reset();
@@ -230,7 +231,7 @@ void AlloyBrowserMainParts::PostDestroyThreads() {
#if defined(TOOLKIT_VIEWS)
views_delegate_.reset();
#if defined(OS_MAC)
#if defined(OS_MACOSX)
layout_provider_.reset();
#endif
#endif // defined(TOOLKIT_VIEWS)

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
#ifndef CEF_LIBCEF_BROWSER_BROWSER_MAIN_H_
#define CEF_LIBCEF_BROWSER_BROWSER_MAIN_H_
#pragma once
#include "libcef/browser/request_context_impl.h"
@@ -32,18 +32,18 @@ class WMState;
#if defined(TOOLKIT_VIEWS)
namespace views {
class ViewsDelegate;
#if defined(OS_MAC)
#if defined(OS_MACOSX)
class LayoutProvider;
#endif
} // namespace views
}
#endif // defined(TOOLKIT_VIEWS)
class CefDevToolsDelegate;
class AlloyBrowserMainParts : public content::BrowserMainParts {
class CefBrowserMainParts : public content::BrowserMainParts {
public:
explicit AlloyBrowserMainParts(const content::MainFunctionParams& parameters);
~AlloyBrowserMainParts() override;
explicit CefBrowserMainParts(const content::MainFunctionParams& parameters);
~CefBrowserMainParts() override;
int PreEarlyInitialization() override;
void ToolkitInitialized() override;
@@ -96,12 +96,12 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
#if defined(TOOLKIT_VIEWS)
std::unique_ptr<views::ViewsDelegate> views_delegate_;
#if defined(OS_MAC)
#if defined(OS_MACOSX)
std::unique_ptr<views::LayoutProvider> layout_provider_;
#endif
#endif // defined(TOOLKIT_VIEWS)
DISALLOW_COPY_AND_ASSIGN(AlloyBrowserMainParts);
DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts);
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
#endif // CEF_LIBCEF_BROWSER_BROWSER_MAIN_H_

View File

@@ -6,11 +6,11 @@
#include <commctrl.h>
#include <windows.h>
#include "libcef/browser/alloy/alloy_browser_main.h"
#include "libcef/browser/browser_main.h"
#include "base/logging.h"
void AlloyBrowserMainParts::PlatformInitialize() {
void CefBrowserMainParts::PlatformInitialize() {
HRESULT res;
// Initialize common controls.

View File

@@ -7,8 +7,8 @@
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/origin_whitelist_impl.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/content_client.h"
#include "libcef/common/values_impl.h"
#include "base/bind.h"
@@ -42,6 +42,18 @@ bool CefBrowserMessageFilter::OnMessageReceived(const IPC::Message& message) {
void CefBrowserMessageFilter::OnGetNewRenderThreadInfo(
CefProcessHostMsg_GetNewRenderThreadInfo_Params* params) {
GetCrossOriginWhitelistEntries(&params->cross_origin_whitelist_entries);
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> handler =
app->GetBrowserProcessHandler();
if (handler.get()) {
CefRefPtr<CefListValueImpl> listValuePtr(
new CefListValueImpl(&params->extra_info, false, false));
handler->OnRenderProcessThreadCreated(listValuePtr.get());
listValuePtr->Detach(nullptr);
}
}
}
void CefBrowserMessageFilter::OnGetNewBrowserInfo(int render_frame_routing_id,

View File

@@ -3,13 +3,14 @@
// be found in the LICENSE file.
#include "libcef/browser/browser_message_loop.h"
#include "libcef/common/app_manager.h"
#include "libcef/browser/context.h"
#include "libcef/common/content_client.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_pump.h"
#include "base/message_loop/message_pump_for_ui.h"
#if defined(OS_MAC)
#if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/message_loop/message_pump_mac.h"
#endif
@@ -29,7 +30,7 @@ class MessagePumpExternal : public base::MessagePumpForUI {
void Run(Delegate* delegate) override {
base::TimeTicks start = base::TimeTicks::Now();
while (true) {
#if defined(OS_MAC)
#if defined(OS_MACOSX)
base::mac::ScopedNSAutoreleasePool autorelease_pool;
#endif
@@ -93,7 +94,7 @@ class MessagePumpExternal : public base::MessagePumpForUI {
};
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
if (app)
return app->GetBrowserProcessHandler();
return nullptr;
@@ -108,7 +109,7 @@ std::unique_ptr<base::MessagePump> MessagePumpFactoryForUI() {
return std::make_unique<MessagePumpExternal>(0.01f, handler);
}
#if defined(OS_MAC)
#if defined(OS_MACOSX)
return base::MessagePumpMac::Create();
#else
return std::make_unique<base::MessagePumpForUI>();
@@ -117,6 +118,9 @@ std::unique_ptr<base::MessagePump> MessagePumpFactoryForUI() {
} // namespace
void InitExternalMessagePumpFactoryForUI() {
base::MessagePump::OverrideMessagePumpForUIFactory(MessagePumpFactoryForUI);
void InitMessagePumpFactoryForUI() {
const CefSettings& settings = CefContext::Get()->settings();
if (settings.external_message_pump) {
base::MessagePump::OverrideMessagePumpForUIFactory(MessagePumpFactoryForUI);
}
}

View File

@@ -5,6 +5,6 @@
#ifndef CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_
#define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_
void InitExternalMessagePumpFactoryForUI();
void InitMessagePumpFactoryForUI();
#endif // CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_

View File

@@ -5,10 +5,16 @@
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/osr/browser_platform_delegate_osr.h"
#include "libcef/browser/web_contents_dialog_helper.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/logging.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() = default;
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() {}
CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() {
DCHECK(!browser_);
@@ -21,62 +27,25 @@ void CefBrowserPlatformDelegate::CreateViewForWebContents(
}
void CefBrowserPlatformDelegate::WebContentsCreated(
content::WebContents* web_contents,
bool owned) {
// We should not have a browser at this point.
DCHECK(!browser_);
DCHECK(!web_contents_);
web_contents_ = web_contents;
}
void CefBrowserPlatformDelegate::AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
NOTREACHED();
}
void CefBrowserPlatformDelegate::WebContentsDestroyed(
content::WebContents* web_contents) {
DCHECK(web_contents_ && web_contents_ == web_contents);
web_contents_ = nullptr;
}
bool CefBrowserPlatformDelegate::ShouldTransferNavigation(
bool is_main_frame_navigation) {
return true;
}
content::WebContents* web_contents) {}
void CefBrowserPlatformDelegate::RenderViewCreated(
content::RenderViewHost* render_view_host) {}
void CefBrowserPlatformDelegate::RenderViewReady() {}
content::RenderViewHost* render_view_host) {
// Indicate that the view has an external parent (namely us). This changes the
// default view behavior in some cases (e.g. focus handling on Linux).
if (!IsViewsHosted() && render_view_host->GetWidget()->GetView())
render_view_host->GetWidget()->GetView()->SetHasExternalParent(true);
}
void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostImpl* browser) {
// We should have an associated WebContents at this point.
DCHECK(web_contents_);
DCHECK(!browser_);
DCHECK(browser);
browser_ = browser;
}
void CefBrowserPlatformDelegate::CreateExtensionHost(
const extensions::Extension* extension,
const GURL& url,
extensions::ViewType host_type) {
NOTREACHED();
}
extensions::ExtensionHost* CefBrowserPlatformDelegate::GetExtensionHost()
const {
NOTREACHED();
return nullptr;
if (browser_->IsPrintPreviewSupported()) {
web_contents_dialog_helper_.reset(
new CefWebContentsDialogHelper(browser_->web_contents(), this));
}
}
void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
@@ -84,9 +53,6 @@ void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostImpl* browser) {
// WebContentsDestroyed should already be called.
DCHECK(!web_contents_);
DCHECK(browser_ && browser_ == browser);
browser_ = nullptr;
}
@@ -124,35 +90,30 @@ void CefBrowserPlatformDelegate::PopupBrowserCreated(
bool is_devtools) {}
void CefBrowserPlatformDelegate::SendCaptureLostEvent() {
NOTIMPLEMENTED();
content::RenderWidgetHostImpl* widget = content::RenderWidgetHostImpl::From(
browser_->web_contents()->GetRenderViewHost()->GetWidget());
if (widget)
widget->LostCapture();
}
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {}
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX))
void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {
// Dismiss any existing popups.
content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost();
if (host)
host->NotifyMoveOrResizeStarted();
}
void CefBrowserPlatformDelegate::SizeTo(int width, int height) {}
#endif
bool CefBrowserPlatformDelegate::PreHandleGestureEvent(
content::WebContents* source,
const blink::WebGestureEvent& event) {
return false;
}
bool CefBrowserPlatformDelegate::IsNeverComposited(
content::WebContents* web_contents) {
return false;
}
std::unique_ptr<CefFileDialogRunner>
CefBrowserPlatformDelegate::CreateFileDialogRunner() {
NOTIMPLEMENTED();
return nullptr;
}
std::unique_ptr<CefJavaScriptDialogRunner>
CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() {
NOTIMPLEMENTED();
return nullptr;
}
@@ -267,42 +228,12 @@ gfx::Size CefBrowserPlatformDelegate::GetMaximumDialogSize() {
return gfx::Size();
}
void CefBrowserPlatformDelegate::SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) {
NOTIMPLEMENTED();
}
base::RepeatingClosure CefBrowserPlatformDelegate::GetBoundsChangedCallback() {
if (web_contents_dialog_helper_) {
return web_contents_dialog_helper_->GetBoundsChangedCallback();
}
void CefBrowserPlatformDelegate::SetAccessibilityState(
cef_state_t accessibility_state) {
NOTIMPLEMENTED();
}
bool CefBrowserPlatformDelegate::IsPrintPreviewSupported() const {
return true;
}
void CefBrowserPlatformDelegate::Print() {
NOTIMPLEMENTED();
}
void CefBrowserPlatformDelegate::PrintToPDF(
const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback) {
NOTIMPLEMENTED();
}
void CefBrowserPlatformDelegate::Find(int identifier,
const CefString& searchText,
bool forward,
bool matchCase,
bool findNext) {
NOTIMPLEMENTED();
}
void CefBrowserPlatformDelegate::StopFinding(bool clearSelection) {
NOTIMPLEMENTED();
return base::RepeatingClosure();
}
// static

View File

@@ -32,19 +32,17 @@ class RenderViewHostDelegateView;
class WebContentsView;
} // namespace content
namespace extensions {
class ExtensionHost;
}
#if defined(USE_AURA)
namespace views {
class Widget;
}
#endif
class CefBrowserInfo;
class CefFileDialogRunner;
class CefJavaScriptDialogRunner;
class CefMenuRunner;
class CefWebContentsDialogHelper;
// Provides platform-specific implementations of browser functionality. All
// methods are called on the browser process UI thread unless otherwise
@@ -56,13 +54,6 @@ class CefBrowserPlatformDelegate {
static std::unique_ptr<CefBrowserPlatformDelegate> Create(
CefBrowserHostImpl::CreateParams& create_params);
// Called from CefBrowserHostImpl::Create.
// Wait for the call to WebContentsCreated(owned=true) before taking ownership
// of the resulting WebContents object.
virtual content::WebContents* CreateWebContents(
CefBrowserHostImpl::CreateParams& create_params,
bool& own_web_contents) = 0;
// Called to create the view objects for a new WebContents. Will only be
// called a single time per instance. May be called on multiple threads. Only
// used with windowless rendering.
@@ -70,52 +61,18 @@ class CefBrowserPlatformDelegate {
content::WebContentsView** view,
content::RenderViewHostDelegateView** delegate_view);
// Called after the WebContents for a browser has been created. |owned| will
// be true if |web_contents| was created via CreateWebContents() and we should
// take ownership. This will also be called for popup WebContents created
// indirectly by Chromium. Will only be called a single time per instance.
virtual void WebContentsCreated(content::WebContents* web_contents,
bool owned);
// Called when Chromium is ready to hand over ownership of a popup
// WebContents. WebContentsCreated(owned=false) will be called first for
// |new_contents|. Will only be called a single time per instance. See also
// the WebContentsDelegate documentation.
virtual void AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked);
// Called when the WebContents is destroyed. This will be called before
// BrowserDestroyed(). Will only be called a single time per instance.
virtual void WebContentsDestroyed(content::WebContents* web_contents);
// See WebContentsDelegate documentation.
virtual bool ShouldTransferNavigation(bool is_main_frame_navigation);
// Called after the WebContents for the browser is created. Will only be
// called a single time per instance.
virtual void WebContentsCreated(content::WebContents* web_contents);
// Called after the RenderViewHost is created.
virtual void RenderViewCreated(content::RenderViewHost* render_view_host);
// See WebContentsObserver documentation.
virtual void RenderViewReady();
// Called after the owning CefBrowserHostImpl is created. Will only be called
// a single time per instance. Do not send any client notifications from this
// method.
virtual void BrowserCreated(CefBrowserHostImpl* browser);
// Called from CefBrowserHostImpl::Create.
virtual void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::ViewType host_type);
// Returns the current extension host.
virtual extensions::ExtensionHost* GetExtensionHost() const;
// Send any notifications related to browser creation. Called after
// BrowserCreated().
virtual void NotifyBrowserCreated();
@@ -184,6 +141,9 @@ class CefBrowserPlatformDelegate {
// enable transparency.
virtual SkColor GetBackgroundColor() const = 0;
virtual bool CanUseSharedTexture() const = 0;
virtual bool CanUseExternalBeginFrame() const = 0;
// Notify the window that it was resized.
virtual void WasResized() = 0;
@@ -207,7 +167,7 @@ class CefBrowserPlatformDelegate {
// Send capture lost event.
virtual void SendCaptureLostEvent();
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX))
// The window hosting the browser is about to be moved or resized. Only used
// on Windows and Linux.
virtual void NotifyMoveOrResizeStarted();
@@ -229,13 +189,6 @@ class CefBrowserPlatformDelegate {
virtual bool HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) = 0;
// See WebContentsDelegate documentation.
virtual bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event);
// See WebContentsDelegate documentation.
virtual bool IsNeverComposited(content::WebContents* web_contents);
// Invoke platform specific handling for the external protocol.
static void HandleExternalProtocol(const GURL& url);
@@ -271,7 +224,6 @@ class CefBrowserPlatformDelegate {
// Invalidate the view. Only used with windowless rendering.
virtual void Invalidate(cef_paint_element_type_t type);
// Send the external begin frame message. Only used with windowless rendering.
virtual void SendExternalBeginFrame();
// Set the windowless frame rate. Only used with windowless rendering.
@@ -315,23 +267,6 @@ class CefBrowserPlatformDelegate {
virtual gfx::Point GetDialogPosition(const gfx::Size& size);
virtual gfx::Size GetMaximumDialogSize();
// See CefBrowserHost documentation.
virtual void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size);
virtual void SetAccessibilityState(cef_state_t accessibility_state);
virtual bool IsPrintPreviewSupported() const;
virtual void Print();
virtual void PrintToPDF(const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback);
virtual void Find(int identifier,
const CefString& searchText,
bool forward,
bool matchCase,
bool findNext);
virtual void StopFinding(bool clearSelection);
protected:
// Allow deletion via scoped_ptr only.
friend std::default_delete<CefBrowserPlatformDelegate>;
@@ -339,11 +274,15 @@ class CefBrowserPlatformDelegate {
CefBrowserPlatformDelegate();
virtual ~CefBrowserPlatformDelegate();
base::RepeatingClosure GetBoundsChangedCallback();
static int TranslateWebEventModifiers(uint32 cef_modifiers);
// Not owned by this object.
content::WebContents* web_contents_ = nullptr;
CefBrowserHostImpl* browser_ = nullptr;
CefBrowserHostImpl* browser_ = nullptr; // Not owned by this object.
private:
// Used for the print preview dialog.
std::unique_ptr<CefWebContentsDialogHelper> web_contents_dialog_helper_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegate);
};

View File

@@ -11,14 +11,12 @@
#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
#include "libcef/browser/extensions/browser_platform_delegate_background.h"
#include "libcef/features/runtime_checks.h"
#if defined(OS_WIN)
#include "libcef/browser/native/browser_platform_delegate_native_win.h"
#include "libcef/browser/osr/browser_platform_delegate_osr_win.h"
#elif defined(OS_MAC)
#elif defined(OS_MACOSX)
#include "libcef/browser/native/browser_platform_delegate_native_mac.h"
#include "libcef/browser/osr/browser_platform_delegate_osr_mac.h"
#elif defined(OS_LINUX)
@@ -36,32 +34,33 @@ namespace {
std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
const CefWindowInfo& window_info,
SkColor background_color) {
SkColor background_color,
bool use_shared_texture,
bool use_external_begin_frame) {
#if defined(OS_WIN)
return std::make_unique<CefBrowserPlatformDelegateNativeWin>(
window_info, background_color);
#elif defined(OS_MAC)
window_info, background_color, use_shared_texture,
use_external_begin_frame);
#elif defined(OS_MACOSX)
return std::make_unique<CefBrowserPlatformDelegateNativeMac>(
window_info, background_color);
#elif defined(OS_LINUX)
return std::make_unique<CefBrowserPlatformDelegateNativeLinux>(
window_info, background_color);
window_info, background_color, use_external_begin_frame);
#endif
}
std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate,
bool use_shared_texture,
bool use_external_begin_frame) {
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate) {
#if defined(OS_WIN)
return std::make_unique<CefBrowserPlatformDelegateOsrWin>(
std::move(native_delegate), use_shared_texture, use_external_begin_frame);
#elif defined(OS_MAC)
std::move(native_delegate));
#elif defined(OS_MACOSX)
return std::make_unique<CefBrowserPlatformDelegateOsrMac>(
std::move(native_delegate));
#elif defined(OS_LINUX)
return std::make_unique<CefBrowserPlatformDelegateOsrLinux>(
std::move(native_delegate), use_external_begin_frame);
std::move(native_delegate));
#endif
}
@@ -77,34 +76,31 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
const SkColor background_color = CefContext::Get()->GetBackgroundColor(
&create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED);
if (cef::IsChromeRuntimeEnabled()) {
return std::make_unique<CefBrowserPlatformDelegateChrome>(background_color);
bool use_shared_texture = false;
bool use_external_begin_frame = false;
if (is_windowless) {
use_shared_texture = create_params.window_info &&
create_params.window_info->shared_texture_enabled;
use_external_begin_frame =
create_params.window_info &&
create_params.window_info->external_begin_frame_enabled;
}
if (create_params.window_info) {
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(*create_params.window_info.get(),
background_color);
if (is_windowless) {
REQUIRE_ALLOY_RUNTIME();
const bool use_shared_texture =
create_params.window_info &&
create_params.window_info->shared_texture_enabled;
const bool use_external_begin_frame =
create_params.window_info &&
create_params.window_info->external_begin_frame_enabled;
return CreateOSRDelegate(std::move(native_delegate), use_shared_texture,
use_external_begin_frame);
}
CreateNativeDelegate(*create_params.window_info.get(), background_color,
use_shared_texture, use_external_begin_frame);
if (is_windowless)
return CreateOSRDelegate(std::move(native_delegate));
return std::move(native_delegate);
} else if (create_params.extension_host_type ==
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
// Creating a background extension host without a window.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo(), background_color);
CreateNativeDelegate(CefWindowInfo(), background_color,
use_shared_texture, use_external_begin_frame);
return std::make_unique<CefBrowserPlatformDelegateBackground>(
std::move(native_delegate));
}
@@ -112,7 +108,8 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
else {
// CefWindowInfo is not used in this case.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo(), background_color);
CreateNativeDelegate(CefWindowInfo(), background_color,
use_shared_texture, use_external_begin_frame);
return std::make_unique<CefBrowserPlatformDelegateViews>(
std::move(native_delegate),
static_cast<CefBrowserViewImpl*>(create_params.browser_view.get()));

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,34 +0,0 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
#include "libcef/browser/context.h"
#include "base/task/post_task.h"
ChromeBrowserMainExtraPartsCef::ChromeBrowserMainExtraPartsCef() = default;
ChromeBrowserMainExtraPartsCef::~ChromeBrowserMainExtraPartsCef() = default;
void ChromeBrowserMainExtraPartsCef::PostProfileInit() {
CefRequestContextSettings settings;
CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
// Create the global RequestContext.
global_request_context_ =
CefRequestContextImpl::CreateGlobalRequestContext(settings);
}
void ChromeBrowserMainExtraPartsCef::PostMainMessageLoopRun() {
background_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_visible_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_blocking_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
}

View File

@@ -1,54 +0,0 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_MAIN_EXTRA_PARTS_CEF_H_
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_MAIN_EXTRA_PARTS_CEF_H_
#include <memory>
#include "libcef/browser/request_context_impl.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
// Wrapper that owns and initialize the browser memory-related extra parts.
class ChromeBrowserMainExtraPartsCef : public ChromeBrowserMainExtraParts {
public:
ChromeBrowserMainExtraPartsCef();
~ChromeBrowserMainExtraPartsCef() override;
CefRefPtr<CefRequestContextImpl> request_context() const {
return global_request_context_;
}
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const {
return background_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const {
return user_visible_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner()
const {
return user_blocking_task_runner_;
}
private:
// ChromeBrowserMainExtraParts overrides.
void PostProfileInit() override;
void PostMainMessageLoopRun() override;
CefRefPtr<CefRequestContextImpl> global_request_context_;
// Blocking task runners exposed via CefTaskRunner. For consistency with
// previous named thread behavior always execute all pending tasks before
// shutdown (e.g. to make sure critical data is saved to disk).
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner_;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsCef);
};
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_MAIN_EXTRA_PARTS_CEF_H_

View File

@@ -1,69 +0,0 @@
// Copyright 2020 The Chromium Embedded Framework Authors.
// Portions copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
#include "libcef/common/cef_switches.h"
#include "base/command_line.h"
#include "base/path_service.h"
#include "chrome/browser/chrome_browser_main.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
ChromeContentBrowserClientCef::ChromeContentBrowserClientCef(
StartupData* startup_data)
: ChromeContentBrowserClient(startup_data) {}
ChromeContentBrowserClientCef::~ChromeContentBrowserClientCef() = default;
std::unique_ptr<content::BrowserMainParts>
ChromeContentBrowserClientCef::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
auto main_parts =
ChromeContentBrowserClient::CreateBrowserMainParts(parameters);
browser_main_parts_ = new ChromeBrowserMainExtraPartsCef;
static_cast<ChromeBrowserMainParts*>(main_parts.get())
->AddParts(
base::WrapUnique<ChromeBrowserMainExtraParts>(browser_main_parts_));
return main_parts;
}
void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
base::CommandLine* command_line,
int child_process_id) {
ChromeContentBrowserClient::AppendExtraCommandLineSwitches(command_line,
child_process_id);
// Necessary to launch sub-processes in the correct mode.
command_line->AppendSwitch(switches::kEnableChromeRuntime);
// Necessary to populate DIR_USER_DATA in sub-processes.
// See resource_util.cc GetUserDataPath.
base::FilePath user_data_dir;
if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
}
}
CefRefPtr<CefRequestContextImpl>
ChromeContentBrowserClientCef::request_context() const {
return browser_main_parts_->request_context();
}
scoped_refptr<base::SingleThreadTaskRunner>
ChromeContentBrowserClientCef::background_task_runner() const {
return browser_main_parts_->background_task_runner();
}
scoped_refptr<base::SingleThreadTaskRunner>
ChromeContentBrowserClientCef::user_visible_task_runner() const {
return browser_main_parts_->user_visible_task_runner();
}
scoped_refptr<base::SingleThreadTaskRunner>
ChromeContentBrowserClientCef::user_blocking_task_runner() const {
return browser_main_parts_->user_blocking_task_runner();
}

View File

@@ -1,42 +0,0 @@
// Copyright 2020 The Chromium Embedded Framework Authors.
// Portions copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTENT_BROWSER_CLIENT_CEF_
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTENT_BROWSER_CLIENT_CEF_
#include <memory>
#include "libcef/browser/request_context_impl.h"
#include "base/macros.h"
#include "chrome/browser/chrome_content_browser_client.h"
class ChromeBrowserMainExtraPartsCef;
// CEF override of ChromeContentBrowserClient
class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
public:
explicit ChromeContentBrowserClientCef(StartupData* startup_data = nullptr);
~ChromeContentBrowserClientCef() override;
// ChromeContentBrowserClient overrides.
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
const content::MainFunctionParams& parameters) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override;
CefRefPtr<CefRequestContextImpl> request_context() const;
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const;
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const;
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner() const;
private:
ChromeBrowserMainExtraPartsCef* browser_main_parts_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClientCef);
};
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTENT_BROWSER_CLIENT_CEF_

View File

@@ -3,10 +3,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/chrome_browser_process_alloy.h"
#include "libcef/browser/chrome_browser_process_stub.h"
#include "libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/chrome_profile_manager_stub.h"
#include "libcef/browser/context.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/thread_util.h"
@@ -27,17 +27,17 @@
#include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
ChromeBrowserProcessAlloy::ChromeBrowserProcessAlloy()
ChromeBrowserProcessStub::ChromeBrowserProcessStub()
: initialized_(false),
context_initialized_(false),
shutdown_(false),
locale_("en-US") {}
ChromeBrowserProcessAlloy::~ChromeBrowserProcessAlloy() {
ChromeBrowserProcessStub::~ChromeBrowserProcessStub() {
DCHECK((!initialized_ && !context_initialized_) || shutdown_);
}
void ChromeBrowserProcessAlloy::Initialize() {
void ChromeBrowserProcessStub::Initialize() {
DCHECK(!initialized_);
DCHECK(!context_initialized_);
DCHECK(!shutdown_);
@@ -49,7 +49,7 @@ void ChromeBrowserProcessAlloy::Initialize() {
initialized_ = true;
}
void ChromeBrowserProcessAlloy::OnContextInitialized() {
void ChromeBrowserProcessStub::OnContextInitialized() {
CEF_REQUIRE_UIT();
DCHECK(initialized_);
DCHECK(!context_initialized_);
@@ -57,12 +57,12 @@ void ChromeBrowserProcessAlloy::OnContextInitialized() {
// Must be created after the NotificationService.
print_job_manager_.reset(new printing::PrintJobManager());
profile_manager_.reset(new ChromeProfileManagerAlloy());
profile_manager_.reset(new ChromeProfileManagerStub());
event_router_forwarder_ = new extensions::EventRouterForwarder();
context_initialized_ = true;
}
void ChromeBrowserProcessAlloy::CleanupOnUIThread() {
void ChromeBrowserProcessStub::Shutdown() {
CEF_REQUIRE_UIT();
DCHECK(initialized_);
DCHECK(context_initialized_);
@@ -84,9 +84,8 @@ void ChromeBrowserProcessAlloy::CleanupOnUIThread() {
// Release any references held by objects associated with a Profile. The
// Profile will be deleted later.
for (const auto& browser_context : CefBrowserContext::GetAll()) {
for (const auto& profile : CefBrowserContext::GetAll()) {
// Release any references to |local_state_|.
auto profile = browser_context->AsProfile();
PrefWatcher* pref_watcher = PrefWatcher::Get(profile);
if (pref_watcher)
pref_watcher->Shutdown();
@@ -108,54 +107,54 @@ void ChromeBrowserProcessAlloy::CleanupOnUIThread() {
shutdown_ = true;
}
void ChromeBrowserProcessAlloy::EndSession() {
void ChromeBrowserProcessStub::EndSession() {
NOTREACHED();
}
void ChromeBrowserProcessAlloy::FlushLocalStateAndReply(
void ChromeBrowserProcessStub::FlushLocalStateAndReply(
base::OnceClosure reply) {
NOTREACHED();
}
metrics_services_manager::MetricsServicesManager*
ChromeBrowserProcessAlloy::GetMetricsServicesManager() {
ChromeBrowserProcessStub::GetMetricsServicesManager() {
NOTREACHED();
return nullptr;
}
metrics::MetricsService* ChromeBrowserProcessAlloy::metrics_service() {
metrics::MetricsService* ChromeBrowserProcessStub::metrics_service() {
NOTREACHED();
return nullptr;
}
rappor::RapporServiceImpl* ChromeBrowserProcessAlloy::rappor_service() {
rappor::RapporServiceImpl* ChromeBrowserProcessStub::rappor_service() {
// Called from PluginInfoHostImpl::ReportMetrics.
return nullptr;
}
SystemNetworkContextManager*
ChromeBrowserProcessAlloy::system_network_context_manager() {
ChromeBrowserProcessStub::system_network_context_manager() {
DCHECK(SystemNetworkContextManager::GetInstance());
return SystemNetworkContextManager::GetInstance();
}
network::NetworkQualityTracker*
ChromeBrowserProcessAlloy::network_quality_tracker() {
ChromeBrowserProcessStub::network_quality_tracker() {
NOTREACHED();
return nullptr;
}
WatchDogThread* ChromeBrowserProcessAlloy::watchdog_thread() {
WatchDogThread* ChromeBrowserProcessStub::watchdog_thread() {
NOTREACHED();
return nullptr;
}
ProfileManager* ChromeBrowserProcessAlloy::profile_manager() {
ProfileManager* ChromeBrowserProcessStub::profile_manager() {
DCHECK(context_initialized_);
return profile_manager_.get();
}
PrefService* ChromeBrowserProcessAlloy::local_state() {
PrefService* ChromeBrowserProcessStub::local_state() {
DCHECK(initialized_);
if (!local_state_) {
// Use a location that is shared by all request contexts.
@@ -174,40 +173,40 @@ PrefService* ChromeBrowserProcessAlloy::local_state() {
}
scoped_refptr<network::SharedURLLoaderFactory>
ChromeBrowserProcessAlloy::shared_url_loader_factory() {
ChromeBrowserProcessStub::shared_url_loader_factory() {
NOTREACHED();
return nullptr;
}
variations::VariationsService* ChromeBrowserProcessAlloy::variations_service() {
variations::VariationsService* ChromeBrowserProcessStub::variations_service() {
NOTREACHED();
return nullptr;
}
BrowserProcessPlatformPart* ChromeBrowserProcessAlloy::platform_part() {
BrowserProcessPlatformPart* ChromeBrowserProcessStub::platform_part() {
NOTREACHED();
return nullptr;
}
extensions::EventRouterForwarder*
ChromeBrowserProcessAlloy::extension_event_router_forwarder() {
ChromeBrowserProcessStub::extension_event_router_forwarder() {
DCHECK(context_initialized_);
return event_router_forwarder_.get();
}
NotificationUIManager* ChromeBrowserProcessAlloy::notification_ui_manager() {
NotificationUIManager* ChromeBrowserProcessStub::notification_ui_manager() {
NOTREACHED();
return nullptr;
}
NotificationPlatformBridge*
ChromeBrowserProcessAlloy::notification_platform_bridge() {
ChromeBrowserProcessStub::notification_platform_bridge() {
NOTREACHED();
return nullptr;
}
policy::ChromeBrowserPolicyConnector*
ChromeBrowserProcessAlloy::browser_policy_connector() {
ChromeBrowserProcessStub::browser_policy_connector() {
if (!browser_policy_connector_) {
browser_policy_connector_ =
std::make_unique<policy::ChromeBrowserPolicyConnector>();
@@ -215,40 +214,40 @@ ChromeBrowserProcessAlloy::browser_policy_connector() {
return browser_policy_connector_.get();
}
policy::PolicyService* ChromeBrowserProcessAlloy::policy_service() {
policy::PolicyService* ChromeBrowserProcessStub::policy_service() {
return browser_policy_connector()->GetPolicyService();
}
IconManager* ChromeBrowserProcessAlloy::icon_manager() {
IconManager* ChromeBrowserProcessStub::icon_manager() {
NOTREACHED();
return nullptr;
}
GpuModeManager* ChromeBrowserProcessAlloy::gpu_mode_manager() {
GpuModeManager* ChromeBrowserProcessStub::gpu_mode_manager() {
NOTREACHED();
return nullptr;
}
void ChromeBrowserProcessAlloy::CreateDevToolsProtocolHandler() {
void ChromeBrowserProcessStub::CreateDevToolsProtocolHandler() {
NOTREACHED();
}
void ChromeBrowserProcessAlloy::CreateDevToolsAutoOpener() {
void ChromeBrowserProcessStub::CreateDevToolsAutoOpener() {
NOTREACHED();
}
bool ChromeBrowserProcessAlloy::IsShuttingDown() {
bool ChromeBrowserProcessStub::IsShuttingDown() {
NOTREACHED();
return false;
}
printing::PrintJobManager* ChromeBrowserProcessAlloy::print_job_manager() {
printing::PrintJobManager* ChromeBrowserProcessStub::print_job_manager() {
DCHECK(context_initialized_);
return print_job_manager_.get();
}
printing::PrintPreviewDialogController*
ChromeBrowserProcessAlloy::print_preview_dialog_controller() {
ChromeBrowserProcessStub::print_preview_dialog_controller() {
if (!print_preview_dialog_controller_.get()) {
print_preview_dialog_controller_ =
new printing::PrintPreviewDialogController();
@@ -257,7 +256,7 @@ ChromeBrowserProcessAlloy::print_preview_dialog_controller() {
}
printing::BackgroundPrintingManager*
ChromeBrowserProcessAlloy::background_printing_manager() {
ChromeBrowserProcessStub::background_printing_manager() {
if (!background_printing_manager_.get()) {
background_printing_manager_.reset(
new printing::BackgroundPrintingManager());
@@ -266,120 +265,111 @@ ChromeBrowserProcessAlloy::background_printing_manager() {
}
IntranetRedirectDetector*
ChromeBrowserProcessAlloy::intranet_redirect_detector() {
ChromeBrowserProcessStub::intranet_redirect_detector() {
NOTREACHED();
return nullptr;
}
const std::string& ChromeBrowserProcessAlloy::GetApplicationLocale() {
const std::string& ChromeBrowserProcessStub::GetApplicationLocale() {
DCHECK(!locale_.empty());
return locale_;
}
void ChromeBrowserProcessAlloy::SetApplicationLocale(
const std::string& locale) {
void ChromeBrowserProcessStub::SetApplicationLocale(const std::string& locale) {
locale_ = locale;
}
DownloadStatusUpdater* ChromeBrowserProcessAlloy::download_status_updater() {
DownloadStatusUpdater* ChromeBrowserProcessStub::download_status_updater() {
NOTREACHED();
return nullptr;
}
DownloadRequestLimiter* ChromeBrowserProcessAlloy::download_request_limiter() {
DownloadRequestLimiter* ChromeBrowserProcessStub::download_request_limiter() {
NOTREACHED();
return nullptr;
}
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
BackgroundModeManager* ChromeBrowserProcessAlloy::background_mode_manager() {
BackgroundModeManager* ChromeBrowserProcessStub::background_mode_manager() {
NOTREACHED();
return nullptr;
}
void ChromeBrowserProcessAlloy::set_background_mode_manager_for_test(
void ChromeBrowserProcessStub::set_background_mode_manager_for_test(
std::unique_ptr<BackgroundModeManager> manager) {
NOTREACHED();
}
#endif
StatusTray* ChromeBrowserProcessAlloy::status_tray() {
StatusTray* ChromeBrowserProcessStub::status_tray() {
NOTREACHED();
return nullptr;
}
safe_browsing::SafeBrowsingService*
ChromeBrowserProcessAlloy::safe_browsing_service() {
ChromeBrowserProcessStub::safe_browsing_service() {
return nullptr;
}
subresource_filter::RulesetService*
ChromeBrowserProcessAlloy::subresource_filter_ruleset_service() {
NOTREACHED();
return nullptr;
}
federated_learning::FlocBlocklistService*
ChromeBrowserProcessAlloy::floc_blocklist_service() {
ChromeBrowserProcessStub::subresource_filter_ruleset_service() {
NOTREACHED();
return nullptr;
}
optimization_guide::OptimizationGuideService*
ChromeBrowserProcessAlloy::optimization_guide_service() {
ChromeBrowserProcessStub::optimization_guide_service() {
NOTREACHED();
return nullptr;
}
StartupData* ChromeBrowserProcessAlloy::startup_data() {
StartupData* ChromeBrowserProcessStub::startup_data() {
NOTREACHED();
return nullptr;
}
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
void ChromeBrowserProcessAlloy::StartAutoupdateTimer() {}
void ChromeBrowserProcessStub::StartAutoupdateTimer() {}
#endif
component_updater::ComponentUpdateService*
ChromeBrowserProcessAlloy::component_updater() {
ChromeBrowserProcessStub::component_updater() {
NOTREACHED();
return nullptr;
}
MediaFileSystemRegistry*
ChromeBrowserProcessAlloy::media_file_system_registry() {
ChromeBrowserProcessStub::media_file_system_registry() {
NOTREACHED();
return nullptr;
}
WebRtcLogUploader* ChromeBrowserProcessAlloy::webrtc_log_uploader() {
WebRtcLogUploader* ChromeBrowserProcessStub::webrtc_log_uploader() {
NOTREACHED();
return nullptr;
}
network_time::NetworkTimeTracker*
ChromeBrowserProcessAlloy::network_time_tracker() {
ChromeBrowserProcessStub::network_time_tracker() {
NOTREACHED();
return nullptr;
}
gcm::GCMDriver* ChromeBrowserProcessAlloy::gcm_driver() {
gcm::GCMDriver* ChromeBrowserProcessStub::gcm_driver() {
NOTREACHED();
return nullptr;
}
resource_coordinator::TabManager* ChromeBrowserProcessAlloy::GetTabManager() {
resource_coordinator::TabManager* ChromeBrowserProcessStub::GetTabManager() {
NOTREACHED();
return nullptr;
}
resource_coordinator::ResourceCoordinatorParts*
ChromeBrowserProcessAlloy::resource_coordinator_parts() {
ChromeBrowserProcessStub::resource_coordinator_parts() {
NOTREACHED();
return nullptr;
}
BuildState* ChromeBrowserProcessAlloy::GetBuildState() {
BuildState* ChromeBrowserProcessStub::GetBuildState() {
NOTREACHED();
return nullptr;
}

View File

@@ -6,8 +6,8 @@
// This file provides a stub implementation of Chrome's BrowserProcess object
// for use as an interop layer between CEF and files that live in chrome/.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_
#define CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_
#ifndef CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_
#include <memory>
#include <string>
@@ -18,7 +18,7 @@
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "media/media_buildflags.h"
class ChromeProfileManagerAlloy;
class ChromeProfileManagerStub;
class BackgroundModeManager {
public:
@@ -29,14 +29,14 @@ class BackgroundModeManager {
DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager);
};
class ChromeBrowserProcessAlloy : public BrowserProcess {
class ChromeBrowserProcessStub : public BrowserProcess {
public:
ChromeBrowserProcessAlloy();
~ChromeBrowserProcessAlloy() override;
ChromeBrowserProcessStub();
~ChromeBrowserProcessStub() override;
void Initialize();
void OnContextInitialized();
void CleanupOnUIThread();
void Shutdown();
// BrowserProcess implementation.
void EndSession() override;
@@ -73,16 +73,13 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
void SetApplicationLocale(const std::string& locale) override;
DownloadStatusUpdater* download_status_updater() override;
DownloadRequestLimiter* download_request_limiter() override;
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
BackgroundModeManager* background_mode_manager() override;
void set_background_mode_manager_for_test(
std::unique_ptr<BackgroundModeManager> manager) override;
#endif
StatusTray* status_tray() override;
safe_browsing::SafeBrowsingService* safe_browsing_service() override;
subresource_filter::RulesetService* subresource_filter_ruleset_service()
override;
federated_learning::FlocBlocklistService* floc_blocklist_service() override;
optimization_guide::OptimizationGuideService* optimization_guide_service()
override;
StartupData* startup_data() override;
@@ -108,7 +105,7 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
std::string locale_;
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
std::unique_ptr<ChromeProfileManagerAlloy> profile_manager_;
std::unique_ptr<ChromeProfileManagerStub> profile_manager_;
scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
scoped_refptr<printing::PrintPreviewDialogController>
print_preview_dialog_controller_;
@@ -120,7 +117,7 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
browser_policy_connector_;
std::unique_ptr<base::FieldTrialList> field_trial_list_;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProcessAlloy);
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProcessStub);
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_
#endif // CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_

View File

@@ -5,11 +5,11 @@
#include "build/build_config.h"
#if defined(OS_MAC)
#if defined(OS_MACOSX)
#include "chrome/app/chrome_crash_reporter_client.h"
// Required due to https://crrev.com/1c9f89a06f
void ChromeCrashReporterClient::Create() {}
#endif // defined(OS_MAC)
#endif // defined(OS_MACOSX)

View File

@@ -3,11 +3,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "libcef/browser/chrome_profile_manager_stub.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/common/app_manager.h"
#include "libcef/browser/content_browser_client.h"
namespace {
@@ -22,22 +21,21 @@ namespace {
// Return the main context for now since we don't currently have a good way to
// determine that.
CefBrowserContext* GetActiveBrowserContext() {
auto request_context = static_cast<CefRequestContextImpl*>(
CefAppManager::Get()->GetGlobalRequestContext().get());
return request_context->GetBrowserContext();
return static_cast<CefBrowserContext*>(
CefContentBrowserClient::Get()->request_context()->GetBrowserContext());
}
} // namespace
ChromeProfileManagerAlloy::ChromeProfileManagerAlloy()
ChromeProfileManagerStub::ChromeProfileManagerStub()
: ProfileManager(base::FilePath()) {}
ChromeProfileManagerAlloy::~ChromeProfileManagerAlloy() {}
ChromeProfileManagerStub::~ChromeProfileManagerStub() {}
Profile* ChromeProfileManagerAlloy::GetProfile(
Profile* ChromeProfileManagerStub::GetProfile(
const base::FilePath& profile_dir) {
CefBrowserContext* browser_context =
CefBrowserContext::FromCachePath(profile_dir);
CefBrowserContext::GetForCachePath(profile_dir);
if (!browser_context) {
// ProfileManager makes assumptions about profile directory paths that do
// not match CEF usage. For example, the default Chrome profile name is
@@ -47,19 +45,19 @@ Profile* ChromeProfileManagerAlloy::GetProfile(
// asking for.
browser_context = GetActiveBrowserContext();
}
return browser_context->AsProfile();
return browser_context;
}
bool ChromeProfileManagerAlloy::IsValidProfile(const void* profile) {
bool ChromeProfileManagerStub::IsValidProfile(const void* profile) {
if (!profile)
return false;
return !!CefBrowserContext::FromBrowserContext(
static_cast<const content::BrowserContext*>(profile));
return !!CefBrowserContext::GetForContext(
reinterpret_cast<content::BrowserContext*>(const_cast<void*>(profile)));
}
Profile* ChromeProfileManagerAlloy::GetLastUsedProfile(
Profile* ChromeProfileManagerStub::GetLastUsedProfile(
const base::FilePath& user_data_dir) {
// Override this method to avoid having to register prefs::kProfileLastUsed,
// usage of which doesn't make sense for CEF.
return GetActiveBrowserContext()->AsProfile();
return GetActiveBrowserContext();
}

View File

@@ -6,22 +6,22 @@
// This file provides a stub implementation of Chrome's ProfileManager object
// for use as an interop layer between CEF and files that live in chrome/.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_
#define CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_
#ifndef CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_
#define CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_
#include "chrome/browser/profiles/profile_manager.h"
class ChromeProfileManagerAlloy : public ProfileManager {
class ChromeProfileManagerStub : public ProfileManager {
public:
ChromeProfileManagerAlloy();
~ChromeProfileManagerAlloy() override;
ChromeProfileManagerStub();
~ChromeProfileManagerStub() override;
Profile* GetProfile(const base::FilePath& profile_dir) override;
bool IsValidProfile(const void* profile) override;
Profile* GetLastUsedProfile(const base::FilePath& user_data_dir) override;
private:
DISALLOW_COPY_AND_ASSIGN(ChromeProfileManagerAlloy);
DISALLOW_COPY_AND_ASSIGN(ChromeProfileManagerStub);
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_
#endif // CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_

View File

@@ -0,0 +1,177 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/chrome_profile_stub.h"
#include "components/variations/variations_client.h"
#include "components/variations/variations_http_header_provider.h"
#include "content/public/browser/resource_context.h"
#include "net/url_request/url_request_context.h"
namespace {
class CefVariationsClient : public variations::VariationsClient {
public:
explicit CefVariationsClient(content::BrowserContext* browser_context)
: browser_context_(browser_context) {}
~CefVariationsClient() override = default;
bool IsIncognito() const override {
return browser_context_->IsOffTheRecord();
}
std::string GetVariationsHeader() const override {
return variations::VariationsHttpHeaderProvider::GetInstance()
->GetClientDataHeader(false /* is_signed_in */);
}
private:
content::BrowserContext* browser_context_;
};
} // namespace
ChromeProfileStub::ChromeProfileStub() {}
ChromeProfileStub::~ChromeProfileStub() {}
bool ChromeProfileStub::IsOffTheRecord() {
return false;
}
bool ChromeProfileStub::IsOffTheRecord() const {
return false;
}
const Profile::OTRProfileID& ChromeProfileStub::GetOTRProfileID() const {
NOTREACHED();
static base::NoDestructor<Profile::OTRProfileID> otr_profile_id(
"ProfileImp::NoOTRProfileID");
return *otr_profile_id;
}
variations::VariationsClient* ChromeProfileStub::GetVariationsClient() {
if (!variations_client_)
variations_client_ = std::make_unique<CefVariationsClient>(this);
return variations_client_.get();
}
scoped_refptr<base::SequencedTaskRunner> ChromeProfileStub::GetIOTaskRunner() {
NOTREACHED();
return scoped_refptr<base::SequencedTaskRunner>();
}
std::string ChromeProfileStub::GetProfileUserName() const {
NOTREACHED();
return std::string();
}
Profile::ProfileType ChromeProfileStub::GetProfileType() const {
return REGULAR_PROFILE;
}
Profile* ChromeProfileStub::GetOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) {
NOTREACHED();
return nullptr;
}
std::vector<Profile*> ChromeProfileStub::GetAllOffTheRecordProfiles() {
NOTREACHED();
return {};
}
void ChromeProfileStub::DestroyOffTheRecordProfile(Profile* otr_profile) {
NOTREACHED();
}
bool ChromeProfileStub::HasOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) {
return false;
}
bool ChromeProfileStub::HasAnyOffTheRecordProfile() {
return false;
}
Profile* ChromeProfileStub::GetOriginalProfile() {
return this;
}
const Profile* ChromeProfileStub::GetOriginalProfile() const {
return this;
}
bool ChromeProfileStub::IsSupervised() const {
return false;
}
bool ChromeProfileStub::IsChild() const {
return false;
}
bool ChromeProfileStub::IsLegacySupervised() const {
return false;
}
ExtensionSpecialStoragePolicy*
ChromeProfileStub::GetExtensionSpecialStoragePolicy() {
NOTREACHED();
return nullptr;
}
PrefService* ChromeProfileStub::GetOffTheRecordPrefs() {
NOTREACHED();
return nullptr;
}
bool ChromeProfileStub::IsSameProfile(Profile* profile) {
NOTREACHED();
return false;
}
base::Time ChromeProfileStub::GetStartTime() const {
NOTREACHED();
return base::Time();
}
base::FilePath ChromeProfileStub::last_selected_directory() {
NOTREACHED();
return base::FilePath();
}
void ChromeProfileStub::set_last_selected_directory(
const base::FilePath& path) {
NOTREACHED();
}
GURL ChromeProfileStub::GetHomePage() {
NOTREACHED();
return GURL();
}
bool ChromeProfileStub::WasCreatedByVersionOrLater(const std::string& version) {
NOTREACHED();
return false;
}
void ChromeProfileStub::SetExitType(ExitType exit_type) {
NOTREACHED();
}
Profile::ExitType ChromeProfileStub::GetLastSessionExitType() {
NOTREACHED();
return EXIT_NORMAL;
}
base::Time ChromeProfileStub::GetCreationTime() const {
NOTREACHED();
return base::Time();
}
void ChromeProfileStub::SetCreationTimeForTesting(base::Time creation_time) {
NOTREACHED();
}

View File

@@ -5,18 +5,18 @@
// This class gathers state related to a single user profile.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_
#define CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_
#ifndef CEF_LIBCEF_BROWSER_CHROME_PROFILE_STUB_H_
#define CEF_LIBCEF_BROWSER_CHROME_PROFILE_STUB_H_
#include "chrome/browser/profiles/profile.h"
// This file provides a stub implementation of Chrome's Profile object for use
// as an interop layer between CEF and files that live in chrome/.
class ChromeProfileAlloy : public Profile {
class ChromeProfileStub : public Profile {
public:
ChromeProfileAlloy();
~ChromeProfileAlloy() override;
ChromeProfileStub();
~ChromeProfileStub() override;
protected:
// Profile methods.
@@ -26,6 +26,7 @@ class ChromeProfileAlloy : public Profile {
variations::VariationsClient* GetVariationsClient() override;
scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override;
std::string GetProfileUserName() const override;
ProfileType GetProfileType() const override;
Profile* GetOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) override;
std::vector<Profile*> GetAllOffTheRecordProfiles() override;
@@ -40,21 +41,21 @@ class ChromeProfileAlloy : public Profile {
bool IsLegacySupervised() const override;
ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
PrefService* GetOffTheRecordPrefs() override;
bool IsSameOrParent(Profile* profile) override;
bool IsSameProfile(Profile* profile) override;
base::Time GetStartTime() const override;
base::FilePath last_selected_directory() override;
void set_last_selected_directory(const base::FilePath& path) override;
GURL GetHomePage() override;
bool WasCreatedByVersionOrLater(const std::string& version) override;
void SetExitType(ExitType exit_type) override;
ExitType GetLastSessionExitType() const override;
ExitType GetLastSessionExitType() override;
base::Time GetCreationTime() const override;
void SetCreationTimeForTesting(base::Time creation_time) override;
private:
std::unique_ptr<variations::VariationsClient> variations_client_;
DISALLOW_COPY_AND_ASSIGN(ChromeProfileAlloy);
DISALLOW_COPY_AND_ASSIGN(ChromeProfileStub);
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_
#endif // CEF_LIBCEF_BROWSER_CHROME_PROFILE_STUB_H_

View File

@@ -2,18 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/content_browser_client.h"
#include <algorithm>
#include <utility>
#include "include/cef_version.h"
#include "libcef/browser/alloy/alloy_browser_context.h"
#include "libcef/browser/alloy/alloy_browser_main.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_main.h"
#include "libcef/browser/browser_message_filter.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
@@ -32,14 +31,14 @@
#include "libcef/browser/ssl_info_impl.h"
#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"
#include "libcef/common/content_client.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net/scheme_registration.h"
#include "libcef/common/request_impl.h"
#include "libcef/common/service_manifests/cef_content_browser_overlay_manifest.h"
#include "base/base_switches.h"
#include "base/command_line.h"
@@ -51,7 +50,6 @@
#include "cef/grit/cef_resources.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/plugins/plugin_info_host_impl.h"
#include "chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.h"
@@ -70,10 +68,10 @@
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/services/printing/printing_service.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/navigation_interception/intercept_navigation_throttle.h"
#include "components/navigation_interception/navigation_params.h"
#include "components/spellcheck/common/spellcheck.mojom.h"
#include "components/variations/variations_http_header_provider.h"
#include "components/version_info/version_info.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/plugin_service_impl.h"
@@ -104,8 +102,6 @@
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/info_map.h"
#include "extensions/browser/process_map.h"
#include "extensions/browser/url_loader_factory_manager.h"
#include "extensions/common/constants.h"
#include "extensions/common/switches.h"
@@ -114,11 +110,11 @@
#include "net/base/auth.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "ppapi/host/ppapi_host.h"
#include "sandbox/policy/switches.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
#include "services/service_manager/embedder/switches.h"
#include "services/service_manager/public/mojom/connector.mojom.h"
#include "services/service_manager/sandbox/switches.h"
#include "storage/browser/quota/quota_settings.h"
#include "third_party/blink/public/mojom/insecure_input/insecure_input_service.mojom.h"
#include "third_party/blink/public/mojom/prerender/prerender.mojom.h"
@@ -133,7 +129,7 @@
#include "libcef/common/widevine_loader.h"
#endif
#if defined(OS_POSIX) && !defined(OS_MAC)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include "base/debug/leak_annotations.h"
#include "chrome/common/chrome_paths.h"
#include "components/crash/content/browser/crash_handler_host_linux.h"
@@ -141,7 +137,7 @@
#include "content/public/common/content_descriptors.h"
#endif
#if defined(OS_MAC)
#if defined(OS_MACOSX)
#include "net/ssl/client_cert_store_mac.h"
#include "services/video_capture/public/mojom/constants.mojom.h"
#endif
@@ -383,7 +379,7 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext {
DISALLOW_COPY_AND_ASSIGN(CefQuotaPermissionContext);
};
#if defined(OS_POSIX) && !defined(OS_MAC)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
const std::string& process_type) {
base::FilePath dumps_path;
@@ -391,7 +387,7 @@ breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
{
ANNOTATE_SCOPED_MEMORY_LEAK;
// Uploads will only occur if a non-empty crash URL is specified in
// AlloyMainDelegate::InitCrashReporter.
// CefMainDelegate::InitCrashReporter.
breakpad::CrashHandlerHostLinux* crash_handler =
new breakpad::CrashHandlerHostLinux(process_type, dumps_path,
true /* upload */);
@@ -438,7 +434,7 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
return -1;
}
#endif // defined(OS_POSIX) && !defined(OS_MAC)
#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
// TODO(cef): We can't currently trust NavigationParams::is_main_frame() because
// it's always set to true in
@@ -457,7 +453,6 @@ bool NavigationOnUIThread(
params.url(), params.referrer(), WindowOpenDisposition::CURRENT_TAB,
params.transition_type(), params.is_renderer_initiated());
open_params.user_gesture = params.has_user_gesture();
open_params.initiator_origin = params.initiator_origin();
CefRefPtr<CefBrowserHostImpl> browser;
if (!CefBrowserInfoManager::GetInstance()->MaybeAllowNavigation(
@@ -549,22 +544,31 @@ void PopulateChromeFrameBinders(
} // namespace
AlloyContentBrowserClient::AlloyContentBrowserClient() {
CefContentBrowserClient::CefContentBrowserClient()
: browser_main_parts_(nullptr) {
plugin_service_filter_.reset(new CefPluginServiceFilter);
content::PluginServiceImpl::GetInstance()->SetFilter(
plugin_service_filter_.get());
}
AlloyContentBrowserClient::~AlloyContentBrowserClient() {}
CefContentBrowserClient::~CefContentBrowserClient() {}
// static
CefContentBrowserClient* CefContentBrowserClient::Get() {
if (!CefContentClient::Get())
return nullptr;
return static_cast<CefContentBrowserClient*>(
CefContentClient::Get()->browser());
}
std::unique_ptr<content::BrowserMainParts>
AlloyContentBrowserClient::CreateBrowserMainParts(
CefContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
browser_main_parts_ = new AlloyBrowserMainParts(parameters);
browser_main_parts_ = new CefBrowserMainParts(parameters);
return base::WrapUnique(browser_main_parts_);
}
void AlloyContentBrowserClient::RenderProcessWillLaunch(
void CefContentBrowserClient::RenderProcessWillLaunch(
content::RenderProcessHost* host) {
const int id = host->GetID();
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
@@ -590,7 +594,7 @@ void AlloyContentBrowserClient::RenderProcessWillLaunch(
->InitializeRenderer(host);
}
bool AlloyContentBrowserClient::ShouldUseProcessPerSite(
bool CefContentBrowserClient::ShouldUseProcessPerSite(
content::BrowserContext* browser_context,
const GURL& effective_url) {
if (!extensions::ExtensionsEnabled())
@@ -619,7 +623,7 @@ bool AlloyContentBrowserClient::ShouldUseProcessPerSite(
// Based on
// ChromeContentBrowserClientExtensionsPart::DoesSiteRequireDedicatedProcess.
bool AlloyContentBrowserClient::DoesSiteRequireDedicatedProcess(
bool CefContentBrowserClient::DoesSiteRequireDedicatedProcess(
content::BrowserContext* browser_context,
const GURL& effective_site_url) {
if (!extensions::ExtensionsEnabled())
@@ -633,7 +637,7 @@ bool AlloyContentBrowserClient::DoesSiteRequireDedicatedProcess(
return extension != nullptr;
}
void AlloyContentBrowserClient::OverrideURLLoaderFactoryParams(
void CefContentBrowserClient::OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
const url::Origin& origin,
bool is_for_isolated_world,
@@ -644,21 +648,21 @@ void AlloyContentBrowserClient::OverrideURLLoaderFactoryParams(
}
}
void AlloyContentBrowserClient::GetAdditionalWebUISchemes(
void CefContentBrowserClient::GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) {
// Any schemes listed here are treated as WebUI schemes but do not get WebUI
// bindings. Also, view-source is allowed for these schemes. WebUI schemes
// will not be passed to HandleExternalProtocol.
}
void AlloyContentBrowserClient::GetAdditionalViewSourceSchemes(
void CefContentBrowserClient::GetAdditionalViewSourceSchemes(
std::vector<std::string>* additional_schemes) {
GetAdditionalWebUISchemes(additional_schemes);
additional_schemes->push_back(extensions::kExtensionScheme);
}
void AlloyContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
void CefContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* additional_allowed_schemes) {
ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
additional_allowed_schemes);
@@ -666,12 +670,12 @@ void AlloyContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
additional_allowed_schemes->push_back(content::kChromeUIScheme);
}
bool AlloyContentBrowserClient::IsWebUIAllowedToMakeNetworkRequests(
bool CefContentBrowserClient::IsWebUIAllowedToMakeNetworkRequests(
const url::Origin& origin) {
return scheme::IsWebUIAllowedToMakeNetworkRequests(origin);
}
bool AlloyContentBrowserClient::IsHandledURL(const GURL& url) {
bool CefContentBrowserClient::IsHandledURL(const GURL& url) {
if (!url.is_valid())
return false;
const std::string& scheme = url.scheme();
@@ -680,10 +684,10 @@ bool AlloyContentBrowserClient::IsHandledURL(const GURL& url) {
if (scheme::IsInternalHandledScheme(scheme))
return true;
return CefAppManager::Get()->HasCustomScheme(scheme);
return CefContentClient::Get()->HasCustomScheme(scheme);
}
void AlloyContentBrowserClient::SiteInstanceGotProcess(
void CefContentBrowserClient::SiteInstanceGotProcess(
content::SiteInstance* site_instance) {
if (!extensions::ExtensionsEnabled())
return;
@@ -693,15 +697,21 @@ void AlloyContentBrowserClient::SiteInstanceGotProcess(
if (!extension)
return;
auto browser_context =
static_cast<AlloyBrowserContext*>(site_instance->GetBrowserContext());
CefBrowserContext* browser_context =
static_cast<CefBrowserContext*>(site_instance->GetBrowserContext());
extensions::ProcessMap::Get(browser_context)
->Insert(extension->id(), site_instance->GetProcess()->GetID(),
site_instance->GetId());
CEF_POST_TASK(
CEF_IOT, base::Bind(&extensions::InfoMap::RegisterExtensionProcess,
browser_context->extension_system()->info_map(),
extension->id(), site_instance->GetProcess()->GetID(),
site_instance->GetId()));
}
void AlloyContentBrowserClient::SiteInstanceDeleting(
void CefContentBrowserClient::SiteInstanceDeleting(
content::SiteInstance* site_instance) {
if (!extensions::ExtensionsEnabled())
return;
@@ -719,15 +729,21 @@ void AlloyContentBrowserClient::SiteInstanceDeleting(
if (!extension)
return;
auto browser_context =
static_cast<AlloyBrowserContext*>(site_instance->GetBrowserContext());
CefBrowserContext* browser_context =
static_cast<CefBrowserContext*>(site_instance->GetBrowserContext());
extensions::ProcessMap::Get(browser_context)
->Remove(extension->id(), site_instance->GetProcess()->GetID(),
site_instance->GetId());
CEF_POST_TASK(
CEF_IOT, base::Bind(&extensions::InfoMap::UnregisterExtensionProcess,
browser_context->extension_system()->info_map(),
extension->id(), site_instance->GetProcess()->GetID(),
site_instance->GetId()));
}
void AlloyContentBrowserClient::BindHostReceiverForRenderer(
void CefContentBrowserClient::BindHostReceiverForRenderer(
content::RenderProcessHost* render_process_host,
mojo::GenericPendingReceiver receiver) {
if (auto host_receiver = receiver.As<spellcheck::mojom::SpellCheckHost>()) {
@@ -746,7 +762,16 @@ void AlloyContentBrowserClient::BindHostReceiverForRenderer(
#endif // BUILDFLAG(HAS_SPELLCHECK_PANEL)
}
void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
base::Optional<service_manager::Manifest>
CefContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
if (name == content::mojom::kBrowserServiceName) {
return GetCefContentBrowserOverlayManifest();
}
return base::nullopt;
}
void CefContentBrowserClient::AppendExtraCommandLineSwitches(
base::CommandLine* command_line,
int child_process_id) {
const base::CommandLine* browser_cmd = base::CommandLine::ForCurrentProcess();
@@ -756,7 +781,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
// associated values) if present in the browser command line.
static const char* const kSwitchNames[] = {
switches::kDisablePackLoading,
#if defined(OS_MAC)
#if defined(OS_MACOSX)
switches::kFrameworkDirPath,
switches::kMainBundlePath,
#endif
@@ -797,19 +822,18 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
if (extensions::ExtensionsEnabled()) {
content::RenderProcessHost* process =
content::RenderProcessHost::FromID(child_process_id);
auto browser_context = process->GetBrowserContext();
CefBrowserContext* cef_browser_context =
process ? CefBrowserContext::FromBrowserContext(browser_context)
: nullptr;
if (cef_browser_context) {
if (cef_browser_context->IsPrintPreviewSupported()) {
CefBrowserContext* context =
process
? CefBrowserContext::GetForContext(process->GetBrowserContext())
: nullptr;
if (context) {
if (context->IsPrintPreviewSupported()) {
command_line->AppendSwitch(switches::kEnablePrintPreview);
}
// Based on ChromeContentBrowserClientExtensionsPart::
// AppendExtraRendererCommandLineSwitches
if (extensions::ProcessMap::Get(browser_context)
->Contains(process->GetID())) {
if (extensions::ProcessMap::Get(context)->Contains(process->GetID())) {
command_line->AppendSwitch(extensions::switches::kExtensionProcess);
}
}
@@ -836,7 +860,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
base::size(kSwitchNames));
#if BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
if (!browser_cmd->HasSwitch(sandbox::policy::switches::kNoSandbox)) {
if (!browser_cmd->HasSwitch(service_manager::switches::kNoSandbox)) {
// Pass the Widevine CDM path to the Zygote process. See comments in
// CefWidevineLoader::AddContentDecryptionModules.
const base::FilePath& cdm_path = CefWidevineLoader::GetInstance()->path();
@@ -855,7 +879,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
}
#endif // defined(OS_LINUX)
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> handler =
app->GetBrowserProcessHandler();
@@ -868,12 +892,12 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
}
}
std::string AlloyContentBrowserClient::GetApplicationLocale() {
std::string CefContentBrowserClient::GetApplicationLocale() {
return g_browser_process->GetApplicationLocale();
}
scoped_refptr<network::SharedURLLoaderFactory>
AlloyContentBrowserClient::GetSystemSharedURLLoaderFactory() {
CefContentBrowserClient::GetSystemSharedURLLoaderFactory() {
DCHECK(
content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ||
!content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI));
@@ -886,23 +910,23 @@ AlloyContentBrowserClient::GetSystemSharedURLLoaderFactory() {
}
network::mojom::NetworkContext*
AlloyContentBrowserClient::GetSystemNetworkContext() {
CefContentBrowserClient::GetSystemNetworkContext() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(SystemNetworkContextManager::GetInstance());
return SystemNetworkContextManager::GetInstance()->GetContext();
}
scoped_refptr<content::QuotaPermissionContext>
AlloyContentBrowserClient::CreateQuotaPermissionContext() {
CefContentBrowserClient::CreateQuotaPermissionContext() {
return new CefQuotaPermissionContext();
}
content::MediaObserver* AlloyContentBrowserClient::GetMediaObserver() {
content::MediaObserver* CefContentBrowserClient::GetMediaObserver() {
return CefMediaCaptureDevicesDispatcher::GetInstance();
}
content::SpeechRecognitionManagerDelegate*
AlloyContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
CefContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableSpeechInput))
@@ -912,7 +936,7 @@ AlloyContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
}
content::GeneratedCodeCacheSettings
AlloyContentBrowserClient::GetGeneratedCodeCacheSettings(
CefContentBrowserClient::GetGeneratedCodeCacheSettings(
content::BrowserContext* context) {
// If we pass 0 for size, disk_cache will pick a default size using the
// heuristics based on available disk size. These are implemented in
@@ -922,7 +946,7 @@ AlloyContentBrowserClient::GetGeneratedCodeCacheSettings(
0 /* size */, cache_path);
}
void AlloyContentBrowserClient::AllowCertificateError(
void CefContentBrowserClient::AllowCertificateError(
content::WebContents* web_contents,
int cert_error,
const net::SSLInfo& ssl_info,
@@ -968,7 +992,7 @@ void AlloyContentBrowserClient::AllowCertificateError(
}
}
base::OnceClosure AlloyContentBrowserClient::SelectClientCertificate(
base::OnceClosure CefContentBrowserClient::SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList client_certs,
@@ -1009,7 +1033,7 @@ base::OnceClosure AlloyContentBrowserClient::SelectClientCertificate(
return base::OnceClosure();
}
bool AlloyContentBrowserClient::CanCreateWindow(
bool CefContentBrowserClient::CanCreateWindow(
content::RenderFrameHost* opener,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
@@ -1031,7 +1055,7 @@ bool AlloyContentBrowserClient::CanCreateWindow(
user_gesture, opener_suppressed, no_javascript_access);
}
void AlloyContentBrowserClient::OverrideWebkitPrefs(
void CefContentBrowserClient::OverrideWebkitPrefs(
content::RenderViewHost* rvh,
content::WebPreferences* prefs) {
// Using RVH instead of RFH here because rvh->GetMainFrame() may be nullptr
@@ -1044,23 +1068,16 @@ void AlloyContentBrowserClient::OverrideWebkitPrefs(
}
}
bool AlloyContentBrowserClient::OverrideWebPreferencesAfterNavigation(
content::WebContents* web_contents,
content::WebPreferences* prefs) {
return renderer_prefs::PopulateWebPreferencesAfterNavigation(web_contents,
*prefs);
}
void AlloyContentBrowserClient::BrowserURLHandlerCreated(
void CefContentBrowserClient::BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) {
scheme::BrowserURLHandlerCreated(handler);
}
std::string AlloyContentBrowserClient::GetDefaultDownloadName() {
std::string CefContentBrowserClient::GetDefaultDownloadName() {
return "download";
}
void AlloyContentBrowserClient::DidCreatePpapiPlugin(
void CefContentBrowserClient::DidCreatePpapiPlugin(
content::BrowserPpapiHost* browser_host) {
browser_host->GetPpapiHost()->AddHostFactoryFilter(
std::unique_ptr<ppapi::host::HostFactory>(
@@ -1068,12 +1085,12 @@ void AlloyContentBrowserClient::DidCreatePpapiPlugin(
}
content::DevToolsManagerDelegate*
AlloyContentBrowserClient::GetDevToolsManagerDelegate() {
CefContentBrowserClient::GetDevToolsManagerDelegate() {
return new CefDevToolsManagerDelegate();
}
std::vector<std::unique_ptr<content::NavigationThrottle>>
AlloyContentBrowserClient::CreateThrottlesForNavigation(
CefContentBrowserClient::CreateThrottlesForNavigation(
content::NavigationHandle* navigation_handle) {
CEF_REQUIRE_UIT();
@@ -1106,7 +1123,7 @@ AlloyContentBrowserClient::CreateThrottlesForNavigation(
}
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
AlloyContentBrowserClient::CreateURLLoaderThrottles(
CefContentBrowserClient::CreateURLLoaderThrottles(
const network::ResourceRequest& request,
content::BrowserContext* browser_context,
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
@@ -1131,7 +1148,7 @@ AlloyContentBrowserClient::CreateURLLoaderThrottles(
}
#if defined(OS_LINUX)
void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
void CefContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
const base::CommandLine& command_line,
int child_process_id,
content::PosixFileDescriptorInfo* mappings) {
@@ -1143,13 +1160,29 @@ void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
#endif // defined(OS_LINUX)
#if defined(OS_WIN)
bool AlloyContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) {
const wchar_t* CefContentBrowserClient::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 CefContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) {
return true;
}
#endif // defined(OS_WIN)
void AlloyContentBrowserClient::ExposeInterfacesToRenderer(
void CefContentBrowserClient::ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* host) {
@@ -1158,7 +1191,7 @@ void AlloyContentBrowserClient::ExposeInterfacesToRenderer(
}
std::unique_ptr<net::ClientCertStore>
AlloyContentBrowserClient::CreateClientCertStore(
CefContentBrowserClient::CreateClientCertStore(
content::BrowserContext* browser_context) {
// Match the logic in ProfileNetworkContextService::CreateClientCertStore.
#if defined(USE_NSS_CERTS)
@@ -1167,7 +1200,7 @@ AlloyContentBrowserClient::CreateClientCertStore(
net::ClientCertStoreNSS::PasswordDelegateFactory()));
#elif defined(OS_WIN)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin());
#elif defined(OS_MAC)
#elif defined(OS_MACOSX)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreMac());
#else
#error Unknown platform.
@@ -1175,7 +1208,7 @@ AlloyContentBrowserClient::CreateClientCertStore(
}
std::unique_ptr<content::LoginDelegate>
AlloyContentBrowserClient::CreateLoginDelegate(
CefContentBrowserClient::CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
const content::GlobalRequestID& request_id,
@@ -1189,9 +1222,8 @@ AlloyContentBrowserClient::CreateLoginDelegate(
std::move(auth_required_callback));
}
void AlloyContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
void CefContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
int frame_tree_node_id,
base::UkmSourceId ukm_source_id,
NonNetworkURLLoaderFactoryMap* factories) {
if (!extensions::ExtensionsEnabled())
return;
@@ -1201,11 +1233,11 @@ void AlloyContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
factories->emplace(
extensions::kExtensionScheme,
extensions::CreateExtensionNavigationURLLoaderFactory(
web_contents->GetBrowserContext(), ukm_source_id,
web_contents->GetBrowserContext(),
!!extensions::WebViewGuest::FromWebContents(web_contents)));
}
void AlloyContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
void CefContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
int render_frame_id,
NonNetworkURLLoaderFactoryMap* factories) {
@@ -1244,7 +1276,6 @@ void AlloyContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
extensions::Manifest::IsComponentLocation(extension->location())) {
// Components of chrome that are implemented as extensions or platform apps
// are allowed to use chrome://resources/ and chrome://theme/ URLs.
// See also HasCrossOriginWhitelistEntry.
allowed_webui_hosts.emplace_back(content::kChromeUIResourcesHost);
allowed_webui_hosts.emplace_back(chrome::kChromeUIThemeHost);
}
@@ -1256,7 +1287,7 @@ void AlloyContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
}
}
bool AlloyContentBrowserClient::WillCreateURLLoaderFactory(
bool CefContentBrowserClient::WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,
content::RenderFrameHost* frame,
int render_process_id,
@@ -1280,7 +1311,7 @@ bool AlloyContentBrowserClient::WillCreateURLLoaderFactory(
return true;
}
void AlloyContentBrowserClient::OnNetworkServiceCreated(
void CefContentBrowserClient::OnNetworkServiceCreated(
network::mojom::NetworkService* network_service) {
DCHECK(g_browser_process);
PrefService* local_state = g_browser_process->local_state();
@@ -1292,7 +1323,7 @@ void AlloyContentBrowserClient::OnNetworkServiceCreated(
network_service);
}
void AlloyContentBrowserClient::ConfigureNetworkContextParams(
void CefContentBrowserClient::ConfigureNetworkContextParams(
content::BrowserContext* context,
bool in_memory,
const base::FilePath& relative_partition_path,
@@ -1319,7 +1350,7 @@ void AlloyContentBrowserClient::ConfigureNetworkContextParams(
// The sandbox may block read/write access from the NetworkService to
// directories that are not returned by this method.
std::vector<base::FilePath>
AlloyContentBrowserClient::GetNetworkContextsParentDirectory() {
CefContentBrowserClient::GetNetworkContextsParentDirectory() {
base::FilePath user_data_path;
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_path);
DCHECK(!user_data_path.empty());
@@ -1335,7 +1366,7 @@ AlloyContentBrowserClient::GetNetworkContextsParentDirectory() {
return {user_data_path, root_cache_path};
}
bool AlloyContentBrowserClient::HandleExternalProtocol(
bool CefContentBrowserClient::HandleExternalProtocol(
const GURL& url,
base::OnceCallback<content::WebContents*()> web_contents_getter,
int child_id,
@@ -1349,7 +1380,7 @@ bool AlloyContentBrowserClient::HandleExternalProtocol(
return false;
}
bool AlloyContentBrowserClient::HandleExternalProtocol(
bool CefContentBrowserClient::HandleExternalProtocol(
content::WebContents::Getter web_contents_getter,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
@@ -1387,7 +1418,7 @@ bool AlloyContentBrowserClient::HandleExternalProtocol(
}
std::unique_ptr<content::OverlayWindow>
AlloyContentBrowserClient::CreateWindowForPictureInPicture(
CefContentBrowserClient::CreateWindowForPictureInPicture(
content::PictureInPictureWindowController* controller) {
// Note: content::OverlayWindow::Create() is defined by platform-specific
// implementation in chrome/browser/ui/views. This layering hack, which goes
@@ -1398,7 +1429,7 @@ AlloyContentBrowserClient::CreateWindowForPictureInPicture(
return content::OverlayWindow::Create(controller);
}
void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
void CefContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) {
PopulateChromeFrameBinders(map);
@@ -1428,25 +1459,25 @@ void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
}
base::FilePath
AlloyContentBrowserClient::GetSandboxedStorageServiceDataDirectory() {
CefContentBrowserClient::GetSandboxedStorageServiceDataDirectory() {
return GetRootCachePath();
}
std::string AlloyContentBrowserClient::GetProduct() {
std::string CefContentBrowserClient::GetProduct() {
// Match the logic in chrome_content_browser_client.cc GetProduct().
return ::GetProduct();
}
std::string AlloyContentBrowserClient::GetChromeProduct() {
std::string CefContentBrowserClient::GetChromeProduct() {
return version_info::GetProductNameAndVersionForUserAgent();
}
std::string AlloyContentBrowserClient::GetUserAgent() {
std::string CefContentBrowserClient::GetUserAgent() {
// Match the logic in chrome_content_browser_client.cc GetUserAgent().
return ::GetUserAgent();
}
blink::UserAgentMetadata AlloyContentBrowserClient::GetUserAgentMetadata() {
blink::UserAgentMetadata CefContentBrowserClient::GetUserAgentMetadata() {
blink::UserAgentMetadata metadata;
metadata.brand_version_list = {blink::UserAgentBrandVersion{
@@ -1462,7 +1493,7 @@ blink::UserAgentMetadata AlloyContentBrowserClient::GetUserAgentMetadata() {
}
base::flat_set<std::string>
AlloyContentBrowserClient::GetPluginMimeTypesWithExternalHandlers(
CefContentBrowserClient::GetPluginMimeTypesWithExternalHandlers(
content::BrowserContext* browser_context) {
base::flat_set<std::string> mime_types;
auto map = PluginUtils::GetMimeTypeToExtensionIdMap(browser_context);
@@ -1471,18 +1502,7 @@ AlloyContentBrowserClient::GetPluginMimeTypesWithExternalHandlers(
return mime_types;
}
bool AlloyContentBrowserClient::ArePersistentMediaDeviceIDsAllowed(
content::BrowserContext* browser_context,
const GURL& url,
const GURL& site_for_cookies,
const base::Optional<url::Origin>& top_frame_origin) {
// Persistent MediaDevice IDs are allowed if cookies are allowed.
return CookieSettingsFactory::GetForProfile(
Profile::FromBrowserContext(browser_context))
->IsCookieAccessAllowed(url, site_for_cookies, top_frame_origin);
}
bool AlloyContentBrowserClient::ShouldAllowPluginCreation(
bool CefContentBrowserClient::ShouldAllowPluginCreation(
const url::Origin& embedder_origin,
const content::PepperPluginInfo& plugin_info) {
if (plugin_info.name == ChromeContentClient::kPDFInternalPluginName) {
@@ -1507,31 +1527,31 @@ bool AlloyContentBrowserClient::ShouldAllowPluginCreation(
return true;
}
CefRefPtr<CefRequestContextImpl> AlloyContentBrowserClient::request_context()
CefRefPtr<CefRequestContextImpl> CefContentBrowserClient::request_context()
const {
return browser_main_parts_->request_context();
}
CefDevToolsDelegate* AlloyContentBrowserClient::devtools_delegate() const {
CefDevToolsDelegate* CefContentBrowserClient::devtools_delegate() const {
return browser_main_parts_->devtools_delegate();
}
scoped_refptr<base::SingleThreadTaskRunner>
AlloyContentBrowserClient::background_task_runner() const {
CefContentBrowserClient::background_task_runner() const {
return browser_main_parts_->background_task_runner();
}
scoped_refptr<base::SingleThreadTaskRunner>
AlloyContentBrowserClient::user_visible_task_runner() const {
CefContentBrowserClient::user_visible_task_runner() const {
return browser_main_parts_->user_visible_task_runner();
}
scoped_refptr<base::SingleThreadTaskRunner>
AlloyContentBrowserClient::user_blocking_task_runner() const {
CefContentBrowserClient::user_blocking_task_runner() const {
return browser_main_parts_->user_blocking_task_runner();
}
const extensions::Extension* AlloyContentBrowserClient::GetExtension(
const extensions::Extension* CefContentBrowserClient::GetExtension(
content::SiteInstance* site_instance) {
extensions::ExtensionRegistry* registry =
extensions::ExtensionRegistry::Get(site_instance->GetBrowserContext());

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
#ifndef CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
#define CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
#pragma once
#include <string>
@@ -18,7 +18,7 @@
#include "content/public/browser/content_browser_client.h"
#include "third_party/skia/include/core/SkColor.h"
class AlloyBrowserMainParts;
class CefBrowserMainParts;
class CefDevToolsDelegate;
namespace content {
@@ -30,10 +30,13 @@ namespace extensions {
class Extension;
}
class AlloyContentBrowserClient : public content::ContentBrowserClient {
class CefContentBrowserClient : public content::ContentBrowserClient {
public:
AlloyContentBrowserClient();
~AlloyContentBrowserClient() override;
CefContentBrowserClient();
~CefContentBrowserClient() override;
// Returns the singleton CefContentBrowserClient instance.
static CefContentBrowserClient* Get();
// ContentBrowserClient implementation.
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
@@ -61,6 +64,8 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
void BindHostReceiverForRenderer(
content::RenderProcessHost* render_process_host,
mojo::GenericPendingReceiver receiver) override;
base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
base::StringPiece name) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override;
std::string GetApplicationLocale() override;
@@ -103,9 +108,6 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
bool* no_javascript_access) override;
void OverrideWebkitPrefs(content::RenderViewHost* rvh,
content::WebPreferences* prefs) override;
bool OverrideWebPreferencesAfterNavigation(
content::WebContents* web_contents,
content::WebPreferences* prefs) override;
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
std::string GetDefaultDownloadName() override;
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
@@ -129,6 +131,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
#endif
#if defined(OS_WIN)
const wchar_t* GetResourceDllName();
bool PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) override;
#endif
@@ -150,7 +153,6 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
LoginAuthRequiredCallback auth_required_callback) override;
void RegisterNonNetworkNavigationURLLoaderFactories(
int frame_tree_node_id,
base::UkmSourceId ukm_source_id,
NonNetworkURLLoaderFactoryMap* factories) override;
void RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
@@ -209,11 +211,6 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
blink::UserAgentMetadata GetUserAgentMetadata() override;
base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers(
content::BrowserContext* browser_context) override;
bool ArePersistentMediaDeviceIDsAllowed(
content::BrowserContext* browser_context,
const GURL& scope,
const GURL& site_for_cookies,
const base::Optional<url::Origin>& top_frame_origin) override;
bool ShouldAllowPluginCreation(
const url::Origin& embedder_origin,
const content::PepperPluginInfo& plugin_info) override;
@@ -230,9 +227,9 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
const extensions::Extension* GetExtension(
content::SiteInstance* site_instance);
AlloyBrowserMainParts* browser_main_parts_ = nullptr;
CefBrowserMainParts* browser_main_parts_;
std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
#endif // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_

View File

@@ -3,26 +3,48 @@
// be found in the LICENSE file.
#include "libcef/browser/context.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_main.h"
#include "libcef/browser/chrome_browser_process_stub.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/trace_subscriber.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/main_delegate.h"
#include "libcef/common/widevine_loader.h"
#include "libcef/renderer/content_renderer_client.h"
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/debug/debugger.h"
#include "base/files/file_util.h"
#include "base/run_loop.h"
#include "base/task/current_thread.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread_restrictions.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "content/app/content_service_manager_main_delegate.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h"
#include "services/service_manager/embedder/main.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_WIN)
#include "base/strings/utf_string_conversions.h"
#include "chrome/chrome_elf/chrome_elf_main.h"
#include "chrome/install_static/initialize_from_primary_module.h"
#include "components/crash/core/app/crashpad.h"
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#endif
#if defined(OS_MACOSX) || defined(OS_WIN)
#include "components/crash/core/app/crash_switches.h"
#include "third_party/crashpad/crashpad/handler/handler_main.h"
#endif
namespace {
@@ -73,6 +95,54 @@ void InitCrashReporter() {
}
#endif // defined(OS_WIN)
#if defined(OS_MACOSX) || defined(OS_WIN)
// Based on components/crash/core/app/run_as_crashpad_handler_win.cc
// Remove the "--type=crashpad-handler" command-line flag that will otherwise
// confuse the crashpad handler.
// Chrome uses an embedded crashpad handler on Windows only and imports this
// function via the existing "run_as_crashpad_handler" target defined in
// components/crash/core/app/BUILD.gn. CEF uses an embedded handler on both
// Windows and macOS so we define the function here instead of using the
// existing target (because we can't use that target on macOS).
int RunAsCrashpadHandler(const base::CommandLine& command_line) {
base::CommandLine::StringVector argv = command_line.argv();
const base::CommandLine::StringType process_type =
FILE_PATH_LITERAL("--type=");
argv.erase(
std::remove_if(argv.begin(), argv.end(),
[&process_type](const base::CommandLine::StringType& str) {
return base::StartsWith(str, process_type,
base::CompareCase::SENSITIVE) ||
(!str.empty() && str[0] == L'/');
}),
argv.end());
#if defined(OS_MACOSX)
// HandlerMain on macOS uses the system version of getopt_long which expects
// the first argument to be the program name.
argv.insert(argv.begin(), command_line.GetProgram().value());
#endif
std::unique_ptr<char*[]> argv_as_utf8(new char*[argv.size() + 1]);
std::vector<std::string> storage;
storage.reserve(argv.size());
for (size_t i = 0; i < argv.size(); ++i) {
#if defined(OS_WIN)
storage.push_back(base::UTF16ToUTF8(argv[i]));
#else
storage.push_back(argv[i]);
#endif
argv_as_utf8[i] = &storage[i][0];
}
argv_as_utf8[argv.size()] = nullptr;
argv.clear();
return crashpad::HandlerMain(static_cast<int>(storage.size()),
argv_as_utf8.get(), nullptr);
}
#endif // defined(OS_MACOSX) || defined(OS_WIN)
bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) {
// Windowed browser colors must be fully opaque.
if (!is_windowless && CefColorGetA(cef_in) != SK_AlphaOPAQUE)
@@ -182,8 +252,52 @@ int CefExecuteProcess(const CefMainArgs& args,
InitCrashReporter();
#endif
return CefMainRunner::RunAsHelperProcess(args, application,
windows_sandbox_info);
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
#if defined(OS_WIN)
command_line.ParseFromString(::GetCommandLineW());
#else
command_line.InitFromArgv(args.argc, args.argv);
#endif
// Wait for the debugger as early in process initialization as possible.
if (command_line.HasSwitch(switches::kWaitForDebugger))
base::debug::WaitForDebugger(60, true);
// If no process type is specified then it represents the browser process and
// we do nothing.
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
if (process_type.empty())
return -1;
#if defined(OS_MACOSX) || defined(OS_WIN)
if (process_type == crash_reporter::switches::kCrashpadHandler)
return RunAsCrashpadHandler(command_line);
#endif
CefMainDelegate main_delegate(application);
// Execute the secondary process.
#if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (windows_sandbox_info == nullptr) {
content::InitializeSandboxInfo(&sandbox_info);
windows_sandbox_info = &sandbox_info;
}
content::ContentMainParams params(&main_delegate);
params.instance = args.instance;
params.sandbox_info =
static_cast<sandbox::SandboxInterfaceInfo*>(windows_sandbox_info);
return content::ContentMain(params);
#else
content::ContentMainParams params(&main_delegate);
params.argc = args.argc;
params.argv = const_cast<const char**>(args.argv);
return content::ContentMain(params);
#endif
}
bool CefInitialize(const CefMainArgs& args,
@@ -207,6 +321,8 @@ bool CefInitialize(const CefMainArgs& args,
return false;
}
g_browser_process = new ChromeBrowserProcessStub();
// Create the new global context object.
g_context = new CefContext();
@@ -266,7 +382,8 @@ void CefRunMessageLoop() {
return;
}
g_context->RunMessageLoop();
base::RunLoop run_loop;
run_loop.Run();
}
void CefQuitMessageLoop() {
@@ -282,7 +399,8 @@ void CefQuitMessageLoop() {
return;
}
g_context->QuitMessageLoop();
// Quit the CefBrowserMessageLoop.
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}
void CefSetOSModalLoop(bool osModalLoop) {
@@ -294,7 +412,7 @@ void CefSetOSModalLoop(bool osModalLoop) {
}
if (CEF_CURRENTLY_ON_UIT())
base::CurrentThread::Get()->set_os_modal_loop(osModalLoop);
base::MessageLoopCurrent::Get()->set_os_modal_loop(osModalLoop);
else
CEF_POST_TASK(CEF_UIT, base::Bind(CefSetOSModalLoop, osModalLoop));
#endif // defined(OS_WIN)
@@ -318,7 +436,6 @@ bool CefContext::Initialize(const CefMainArgs& args,
void* windows_sandbox_info) {
init_thread_id_ = base::PlatformThread::CurrentId();
settings_ = settings;
application_ = application;
#if !(defined(OS_WIN) || defined(OS_LINUX))
if (settings.multi_threaded_message_loop) {
@@ -349,29 +466,78 @@ bool CefContext::Initialize(const CefMainArgs& args,
NormalizePathAndSet(settings_.resources_dir_path, "resources_dir_path");
NormalizePathAndSet(settings_.locales_dir_path, "locales_dir_path");
main_delegate_.reset(new CefMainDelegate(application));
browser_info_manager_.reset(new CefBrowserInfoManager);
main_runner_.reset(new CefMainRunner(settings_.multi_threaded_message_loop,
settings_.external_message_pump));
return main_runner_->Initialize(
&settings_, application, args, windows_sandbox_info, &initialized_,
base::BindOnce(&CefContext::OnContextInitialized,
base::Unretained(this)));
}
int exit_code;
void CefContext::RunMessageLoop() {
// Must always be called on the same thread as Initialize.
DCHECK(OnInitThread());
// Initialize the content runner.
content::ContentMainParams params(main_delegate_.get());
#if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (windows_sandbox_info == nullptr) {
windows_sandbox_info = &sandbox_info;
settings_.no_sandbox = true;
}
// Blocks until QuitMessageLoop() is called.
main_runner_->RunMessageLoop();
}
params.instance = args.instance;
params.sandbox_info =
static_cast<sandbox::SandboxInterfaceInfo*>(windows_sandbox_info);
#else
params.argc = args.argc;
params.argv = const_cast<const char**>(args.argv);
#endif
void CefContext::QuitMessageLoop() {
// Must always be called on the same thread as Initialize.
DCHECK(OnInitThread());
sm_main_delegate_.reset(
new content::ContentServiceManagerMainDelegate(params));
sm_main_params_.reset(
new service_manager::MainParams(sm_main_delegate_.get()));
main_runner_->QuitMessageLoop();
#if defined(OS_POSIX) && !defined(OS_ANDROID)
sm_main_params_->argc = params.argc;
sm_main_params_->argv = params.argv;
#endif
exit_code = service_manager::MainInitialize(*sm_main_params_);
DCHECK_LT(exit_code, 0);
if (exit_code >= 0)
return false;
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Initialize();
if (settings.multi_threaded_message_loop) {
base::WaitableEvent uithread_startup_event(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
if (!main_delegate_->CreateUIThread(base::BindOnce(
[](CefContext* context, base::WaitableEvent* event) {
service_manager::MainRun(*context->sm_main_params_);
event->Signal();
},
base::Unretained(this),
base::Unretained(&uithread_startup_event)))) {
return false;
}
initialized_ = true;
// We need to wait until service_manager::MainRun has finished.
uithread_startup_event.Wait();
} else {
initialized_ = true;
service_manager::MainRun(*sm_main_params_);
}
if (CEF_CURRENTLY_ON_UIT()) {
OnContextInitialized();
} else {
// Continue initialization on the UI thread.
CEF_POST_TASK(CEF_UIT, base::Bind(&CefContext::OnContextInitialized,
base::Unretained(this)));
}
return true;
}
void CefContext::Shutdown() {
@@ -380,9 +546,28 @@ void CefContext::Shutdown() {
shutting_down_ = true;
main_runner_->Shutdown(
base::BindOnce(&CefContext::ShutdownOnUIThread, base::Unretained(this)),
base::BindOnce(&CefContext::FinalizeShutdown, base::Unretained(this)));
if (settings_.multi_threaded_message_loop) {
// Events that will be used to signal when shutdown is complete. Start in
// non-signaled mode so that the event will block.
base::WaitableEvent uithread_shutdown_event(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
// Finish shutdown on the UI thread.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefContext::FinishShutdownOnUIThread,
base::Unretained(this), &uithread_shutdown_event));
/// Block until UI thread shutdown is complete.
uithread_shutdown_event.Wait();
FinalizeShutdown();
} else {
// Finish shutdown on the current thread, which should be the UI thread.
FinishShutdownOnUIThread(nullptr);
FinalizeShutdown();
}
}
bool CefContext::OnInitThread() {
@@ -469,16 +654,25 @@ bool CefContext::HasObserver(Observer* observer) const {
void CefContext::OnContextInitialized() {
CEF_REQUIRE_UIT();
static_cast<ChromeBrowserProcessStub*>(g_browser_process)
->OnContextInitialized();
#if BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
CefWidevineLoader::GetInstance()->OnContextInitialized();
#endif
// Notify the handler.
if (application_) {
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> handler =
application_->GetBrowserProcessHandler();
if (handler)
app->GetBrowserProcessHandler();
if (handler.get())
handler->OnContextInitialized();
}
}
void CefContext::ShutdownOnUIThread() {
void CefContext::FinishShutdownOnUIThread(
base::WaitableEvent* uithread_shutdown_event) {
CEF_REQUIRE_UIT();
browser_info_manager_->DestroyAllBrowsers();
@@ -488,9 +682,34 @@ void CefContext::ShutdownOnUIThread() {
if (trace_subscriber_.get())
trace_subscriber_.reset(nullptr);
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Shutdown();
ui::ResourceBundle::GetSharedInstance().CleanupOnUIThread();
sm_main_delegate_->ShutdownOnUIThread();
if (uithread_shutdown_event)
uithread_shutdown_event->Signal();
}
void CefContext::FinalizeShutdown() {
if (content::RenderProcessHost::run_renderer_in_process()) {
// Blocks until RenderProcess cleanup is complete.
CefContentRendererClient::Get()->RunSingleProcessCleanup();
}
// Shut down the browser runner or UI thread.
main_delegate_->ShutdownBrowser();
// Shut down the content runner.
service_manager::MainShutdown(*sm_main_params_);
browser_info_manager_.reset(nullptr);
application_ = nullptr;
sm_main_params_.reset(nullptr);
sm_main_delegate_.reset(nullptr);
main_delegate_.reset(nullptr);
delete g_browser_process;
g_browser_process = nullptr;
}

View File

@@ -11,14 +11,26 @@
#include <string>
#include "include/cef_app.h"
#include "libcef/browser/main_runner.h"
#include "base/observer_list.h"
#include "base/threading/platform_thread.h"
#include "third_party/skia/include/core/SkColor.h"
namespace base {
class WaitableEvent;
}
namespace content {
class ContentServiceManagerMainDelegate;
}
namespace service_manager {
struct MainParams;
}
class CefBrowserHostImpl;
class CefBrowserInfoManager;
class CefMainDelegate;
class CefTraceSubscriber;
class CefContext {
@@ -47,8 +59,6 @@ class CefContext {
const CefSettings& settings,
CefRefPtr<CefApp> application,
void* windows_sandbox_info);
void RunMessageLoop();
void QuitMessageLoop();
void Shutdown();
// Returns true if the current thread is the initialization thread.
@@ -95,7 +105,7 @@ class CefContext {
// Performs shutdown actions that need to occur on the UI thread before any
// threads are destroyed.
void ShutdownOnUIThread();
void FinishShutdownOnUIThread(base::WaitableEvent* uithread_shutdown_event);
// Destroys the main runner and related objects.
void FinalizeShutdown();
@@ -108,9 +118,10 @@ class CefContext {
base::PlatformThreadId init_thread_id_;
CefSettings settings_;
CefRefPtr<CefApp> application_;
std::unique_ptr<CefMainRunner> main_runner_;
std::unique_ptr<CefMainDelegate> main_delegate_;
std::unique_ptr<content::ContentServiceManagerMainDelegate> sm_main_delegate_;
std::unique_ptr<service_manager::MainParams> sm_main_params_;
std::unique_ptr<CefTraceSubscriber> trace_subscriber_;
std::unique_ptr<CefBrowserInfoManager> browser_info_manager_;

View File

@@ -16,7 +16,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/util/values/values_util.h"
#include "base/value_conversions.h"
#include "base/values.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/scoped_user_pref_update.h"
@@ -81,9 +81,9 @@ void CefDevToolsFileManager::Save(const std::string& url,
const base::Value* path_value;
if (file_map->Get(base::MD5String(url), &path_value)) {
base::Optional<base::FilePath> path = util::ValueToFilePath(*path_value);
if (path)
initial_path = std::move(*path);
// Ignore base::GetValueAsFilePath() failure since we handle empty
// |initial_path| below.
ignore_result(base::GetValueAsFilePath(*path_value, &initial_path));
}
if (initial_path.empty()) {
@@ -142,7 +142,7 @@ void CefDevToolsFileManager::SaveAsFileSelected(const std::string& url,
DictionaryPrefUpdate update(prefs_, prefs::kDevToolsEditedFiles);
base::DictionaryValue* files_map = update.Get();
files_map->SetKey(base::MD5String(url), util::FilePathToValue(path));
files_map->SetKey(base::MD5String(url), base::CreateFilePathValue(path));
std::string file_system_path = path.AsUTF8Unsafe();
callback.Run(file_system_path);
file_task_runner_->PostTask(FROM_HERE,

View File

@@ -10,10 +10,10 @@
#include <utility>
#include "libcef/browser/browser_context.h"
#include "libcef/browser/content_browser_client.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"
@@ -25,12 +25,10 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/browser_context.h"
@@ -539,7 +537,7 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
if (ProtocolLoggingEnabled()) {
// Quick check to avoid parsing the JSON object. Events begin with a
// "method" value whereas method results begin with an "id" value.
LogProtocolMessage(base::StartsWith(str_message, "{\"method\":")
LogProtocolMessage(str_message.starts_with("{\"method\":")
? ProtocolMessageType::EVENT
: ProtocolMessageType::RESULT,
str_message);
@@ -608,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 = CefTaskRunnerManager::Get()->GetBackgroundTaskRunner();
auto task_runner = CefContentBrowserClient::Get()->background_task_runner();
task_runner->PostTask(
FROM_HERE, base::BindOnce(::LogProtocolMessage, protocol_log_file_, type,
std::move(to_log)));
@@ -622,8 +620,7 @@ void CefDevToolsFrontend::AgentHostClosed(
}
PrefService* CefDevToolsFrontend::GetPrefs() const {
return CefBrowserContext::FromBrowserContext(
return static_cast<CefBrowserContext*>(
frontend_browser_->web_contents()->GetBrowserContext())
->AsProfile()
->GetPrefs();
}

View File

@@ -5,7 +5,6 @@
#include "libcef/browser/devtools/devtools_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
namespace devtools_util {
@@ -25,7 +24,7 @@ bool ParseEvent(const base::StringPiece& message,
static const char kMethodEnd[] = "\"";
static const char kParamsStart[] = ",\"params\":";
if (!base::StartsWith(message, kMethodStart))
if (!message.starts_with(kMethodStart))
return false;
const size_t method_start = sizeof(kMethodStart) - 1;
@@ -42,7 +41,7 @@ bool ParseEvent(const base::StringPiece& message,
params = base::StringPiece();
} else {
const base::StringPiece& remainder = message.substr(remainder_start);
if (base::StartsWith(remainder, kParamsStart)) {
if (remainder.starts_with(kParamsStart)) {
// Stop immediately before the message closing bracket.
remainder_start += sizeof(kParamsStart) - 1;
params =
@@ -72,7 +71,7 @@ bool ParseResult(const base::StringPiece& message,
static const char kResultStart[] = "\"result\":";
static const char kErrorStart[] = "\"error\":";
if (!base::StartsWith(message, kIdStart))
if (!message.starts_with(kIdStart))
return false;
const size_t id_start = sizeof(kIdStart) - 1;
@@ -85,13 +84,13 @@ bool ParseResult(const base::StringPiece& message,
size_t remainder_start = id_end + sizeof(kIdEnd) - 1;
const base::StringPiece& remainder = message.substr(remainder_start);
if (base::StartsWith(remainder, kResultStart)) {
if (remainder.starts_with(kResultStart)) {
// Stop immediately before the message closing bracket.
remainder_start += sizeof(kResultStart) - 1;
result =
message.substr(remainder_start, message.size() - 1 - remainder_start);
success = true;
} else if (base::StartsWith(remainder, kErrorStart)) {
} else if (remainder.starts_with(kErrorStart)) {
// Stop immediately before the message closing bracket.
remainder_start += sizeof(kErrorStart) - 1;
result =

View File

@@ -152,7 +152,6 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::MixedContentStatus::UNKNOWN, suggested_path,
base::nullopt /*download_schedule*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE);
}
}
@@ -171,8 +170,7 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
std::move(callback).Run(path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::MixedContentStatus::UNKNOWN,
path, base::nullopt /*download_schedule*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE);
path, download::DOWNLOAD_INTERRUPT_REASON_NONE);
}
base::WeakPtr<DownloadManager> manager_;
@@ -357,8 +355,7 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::MixedContentStatus::UNKNOWN,
item->GetForcedFilePath(), base::nullopt /*download_schedule*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE);
item->GetForcedFilePath(), download::DOWNLOAD_INTERRUPT_REASON_NONE);
return true;
}

View File

@@ -4,6 +4,7 @@
#include "libcef/browser/extension_impl.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/values_impl.h"
@@ -88,6 +89,7 @@ void CefExtensionImpl::Unload() {
const bool result = static_cast<CefRequestContextImpl*>(loader_context_)
->GetBrowserContext()
->extension_system()
->UnloadExtension(id_);
ALLOW_UNUSED_LOCAL(result);
DCHECK(result);

View File

@@ -149,16 +149,16 @@ CefRefPtr<CefBrowserHostImpl> GetBrowserForTabId(
if (tab_id < 0 || !browser_context)
return nullptr;
auto cef_browser_context =
CefBrowserContext::FromBrowserContext(browser_context);
CefBrowserContext* browser_context_impl =
CefBrowserContext::GetForContext(browser_context);
for (const auto& browser_info :
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList()) {
CefRefPtr<CefBrowserHostImpl> current_browser = browser_info->browser();
if (current_browser && current_browser->GetIdentifier() == tab_id) {
// Make sure we're operating in the same CefBrowserContext.
if (CefBrowserContext::FromBrowserContext(
current_browser->GetBrowserContext()) == cef_browser_context) {
// Make sure we're operating in the same BrowserContextImpl.
if (CefBrowserContext::GetForContext(
current_browser->GetBrowserContext()) == browser_context_impl) {
return current_browser;
} else {
LOG(WARNING) << "Browser with tabId " << tab_id

View File

@@ -45,7 +45,7 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForFrameRoute(
// |is_guest_view| will be set to true if the host matches a guest view
// associated with the returned browser instead of the browser itself.
// TODO(cef): Delete the RVH variant once the remaining use case
// (via AlloyContentBrowserClient::OverrideWebkitPrefs) has been removed.
// (via CefContentBrowserClient::OverrideWebkitPrefs) has been removed.
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
content::RenderViewHost* host,
bool* is_guest_view);

View File

@@ -35,6 +35,14 @@ CefWindowHandle CefBrowserPlatformDelegateBackground::GetHostWindowHandle()
return kNullWindowHandle;
}
bool CefBrowserPlatformDelegateBackground::CanUseSharedTexture() const {
return native_delegate_->CanUseSharedTexture();
}
bool CefBrowserPlatformDelegateBackground::CanUseExternalBeginFrame() const {
return native_delegate_->CanUseExternalBeginFrame();
}
SkColor CefBrowserPlatformDelegateBackground::GetBackgroundColor() const {
return native_delegate_->GetBackgroundColor();
}

View File

@@ -5,12 +5,12 @@
#ifndef CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_BACKGROUND_H_
#define CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_BACKGROUND_H_
#include "libcef/browser/alloy/browser_platform_delegate_alloy.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/native/browser_platform_delegate_native.h"
// Implementation of browser functionality for background script hosts.
class CefBrowserPlatformDelegateBackground
: public CefBrowserPlatformDelegateAlloy,
: public CefBrowserPlatformDelegate,
public CefBrowserPlatformDelegateNative::WindowlessHandler {
public:
// Platform-specific behaviors will be delegated to |native_delegate|.
@@ -22,6 +22,8 @@ class CefBrowserPlatformDelegateBackground
void CloseHostWindow() override;
CefWindowHandle GetHostWindowHandle() const override;
SkColor GetBackgroundColor() const override;
bool CanUseSharedTexture() const override;
bool CanUseExternalBeginFrame() const override;
void WasResized() override;
void SendKeyEvent(const CefKeyEvent& event) override;
void SendMouseClickEvent(const CefMouseEvent& event,

View File

@@ -8,7 +8,6 @@
#include <map>
#include "base/files/file_path.h"
#include "base/macros.h"
#include "extensions/browser/component_extension_resource_manager.h"
struct GritResourceMap;

View File

@@ -15,12 +15,13 @@ CefExtensionBackgroundHost::CefExtensionBackgroundHost(
CefBrowserHostImpl* browser,
base::OnceClosure deleted_callback,
const Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
ViewType host_type)
: ExtensionHost(new CefExtensionHostDelegate(browser),
extension,
host_contents->GetBrowserContext(),
browser_context,
host_contents,
url,
host_type),

View File

@@ -27,6 +27,7 @@ class CefExtensionBackgroundHost : public ExtensionHost {
CefExtensionBackgroundHost(CefBrowserHostImpl* browser,
base::OnceClosure deleted_callback,
const Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
ViewType host_type);

View File

@@ -166,10 +166,9 @@ CefRefPtr<CefBrowserHostImpl> CefExtensionFunctionDetails::GetCurrentBrowser()
CefRefPtr<CefBrowserHostImpl> active_browser_impl =
static_cast<CefBrowserHostImpl*>(active_browser.get());
// Make sure we're operating in the same CefBrowserContext.
if (CefBrowserContext::FromBrowserContext(
browser->GetBrowserContext()) ==
CefBrowserContext::FromBrowserContext(
// Make sure we're operating in the same BrowserContextImpl.
if (CefBrowserContext::GetForContext(browser->GetBrowserContext()) ==
CefBrowserContext::GetForContext(
active_browser_impl->GetBrowserContext())) {
browser = active_browser_impl;
} else {
@@ -348,12 +347,13 @@ base::DictionaryValue* CefExtensionFunctionDetails::OpenTab(
if (params.index.get())
index = *params.index;
auto cef_browser_context = CefBrowserContext::FromBrowserContext(
active_browser->GetBrowserContext());
CefBrowserContext* browser_context_impl =
CefBrowserContext::GetForContext(active_browser->GetBrowserContext());
// A CEF representation should always exist.
CefRefPtr<CefExtension> cef_extension =
cef_browser_context->GetExtension(function()->extension()->id());
browser_context_impl->extension_system()->GetExtension(
function()->extension()->id());
DCHECK(cef_extension);
if (!cef_extension)
return nullptr;
@@ -466,7 +466,8 @@ CefExtensionFunctionDetails::CreateMutedInfo(content::WebContents* contents) {
CefRefPtr<CefExtension> CefExtensionFunctionDetails::GetCefExtension() const {
if (!cef_extension_) {
cef_extension_ =
CefBrowserContext::FromBrowserContext(function_->browser_context())
static_cast<CefBrowserContext*>(function_->browser_context())
->extension_system()
->GetExtension(function_->extension_id());
DCHECK(cef_extension_);
}

View File

@@ -20,6 +20,7 @@
#include "base/path_service.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_paths.h"
@@ -53,6 +54,7 @@
#include "net/base/mime_util.h"
using content::BrowserContext;
using content::BrowserThread;
namespace extensions {
@@ -177,6 +179,10 @@ void CefExtensionSystem::Init() {
// Inform the rest of the extensions system to start.
ready_.Signal();
content::NotificationService::current()->Notify(
NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
content::Source<BrowserContext>(browser_context_),
content::NotificationService::NoDetails());
// Add the internal PDF extension. PDF loading works as follows:
// 1. The PDF PPAPI plugin is registered in libcef/common/content_client.cc
@@ -218,7 +224,7 @@ void CefExtensionSystem::Init() {
// WebContents routing IDs with the owner CefBrowser. MimeHandlerViewGuest
// then loads the extension URL (index.html) in the guest WebContents.
// 13.Creation of the RenderFrame in the guest renderer process triggers a
// sync IPC call from AlloyContentRendererClient::MaybeCreateBrowser to
// sync IPC call from CefContentRendererClient::MaybeCreateBrowser to
// CefBrowserInfoManager::GetBrowserInfo in the browser process to retrieve
// the CefBrowser information, which will be immediately available due to
// step 12.
@@ -242,7 +248,7 @@ void CefExtensionSystem::Init() {
// 17.HTMLPlugInElement::RequestObject is called in the guest renderer process
// and determines that the PDF PPAPI plugin should be handled internally
// (handled_externally=false). A PluginDocument is created and
// AlloyContentRendererClient::OverrideCreatePlugin is called to create a
// CefContentRendererClient::OverrideCreatePlugin is called to create a
// WebPlugin.
// 18.The PDF extension and PDF plugin are now loaded. Print commands, if
// any, are handled in the guest renderer process by ChromePDFPrintClient
@@ -407,7 +413,7 @@ ServiceWorkerManager* CefExtensionSystem::service_worker_manager() {
return service_worker_manager_.get();
}
SharedUserScriptManager* CefExtensionSystem::shared_user_script_manager() {
SharedUserScriptMaster* CefExtensionSystem::shared_user_script_master() {
return nullptr;
}
@@ -444,8 +450,8 @@ void CefExtensionSystem::RegisterExtensionWithRequestContexts(
base::OnceClosure callback) {
// TODO(extensions): The |incognito_enabled| value should be set based on
// manifest settings.
content::GetIOThreadTaskRunner({})->PostTaskAndReply(
FROM_HERE,
base::PostTaskAndReply(
FROM_HERE, {BrowserThread::IO},
base::Bind(&InfoMap::AddExtension, info_map(),
base::RetainedRef(extension), base::Time::Now(),
true, // incognito_enabled
@@ -458,8 +464,8 @@ void CefExtensionSystem::RegisterExtensionWithRequestContexts(
void CefExtensionSystem::UnregisterExtensionWithRequestContexts(
const std::string& extension_id,
const UnloadedExtensionReason reason) {
content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE,
base::PostTask(
FROM_HERE, {BrowserThread::IO},
base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
}
@@ -467,10 +473,6 @@ const base::OneShotEvent& CefExtensionSystem::ready() const {
return ready_;
}
bool CefExtensionSystem::is_ready() const {
return ready_.is_signaled();
}
ContentVerifier* CefExtensionSystem::content_verifier() {
return nullptr;
}
@@ -487,7 +489,7 @@ void CefExtensionSystem::InstallUpdate(
bool install_immediately,
InstallUpdateCallback install_update_callback) {
NOTREACHED();
base::DeletePathRecursively(temp_dir);
base::DeleteFile(temp_dir, true /* recursive */);
}
void CefExtensionSystem::PerformActionBasedOnOmahaAttributes(

View File

@@ -17,9 +17,12 @@
#include "base/one_shot_event.h"
#include "extensions/browser/extension_system.h"
class BrowserContextKeyedServiceFactory;
namespace base {
class DictionaryValue;
}
class FilePath;
} // namespace base
namespace content {
class BrowserContext;
@@ -28,8 +31,11 @@ class BrowserContext;
namespace extensions {
class ExtensionRegistry;
class InfoMap;
class ProcessManager;
class RendererStartupHelper;
class SharedUserScriptMaster;
class ValueStoreFactory;
// Used to manage extensions.
class CefExtensionSystem : public ExtensionSystem {
@@ -87,7 +93,7 @@ class CefExtensionSystem : public ExtensionSystem {
RuntimeData* runtime_data() override;
ManagementPolicy* management_policy() override;
ServiceWorkerManager* service_worker_manager() override;
SharedUserScriptManager* shared_user_script_manager() override;
SharedUserScriptMaster* shared_user_script_master() override;
StateStore* state_store() override;
StateStore* rules_store() override;
scoped_refptr<ValueStoreFactory> store_factory() override;
@@ -101,7 +107,6 @@ class CefExtensionSystem : public ExtensionSystem {
const std::string& extension_id,
const UnloadedExtensionReason reason) override;
const base::OneShotEvent& ready() const override;
bool is_ready() const override;
ContentVerifier* content_verifier() override;
std::unique_ptr<ExtensionSet> GetDependentExtensions(
const Extension* extension) override;

View File

@@ -21,14 +21,16 @@ using content::WebContentsObserver;
namespace extensions {
CefExtensionViewHost::CefExtensionViewHost(CefBrowserHostImpl* browser,
const Extension* extension,
content::WebContents* host_contents,
const GURL& url,
ViewType host_type)
CefExtensionViewHost::CefExtensionViewHost(
CefBrowserHostImpl* browser,
const Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
ViewType host_type)
: ExtensionHost(new CefExtensionHostDelegate(browser),
extension,
host_contents->GetBrowserContext(),
browser_context,
host_contents,
url,
host_type) {

View File

@@ -29,6 +29,7 @@ class CefExtensionViewHost : public ExtensionHost,
public:
CefExtensionViewHost(CefBrowserHostImpl* browser,
const Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
ViewType host_type);

View File

@@ -36,8 +36,8 @@ CefExtensionsAPIClient::CreateGuestViewManagerDelegate(
// The GuestViewManager instance associated with the returned Delegate, which
// will be retrieved in the future via GuestViewManager::FromBrowserContext,
// will be associated with the CefBrowserContext.
return base::WrapUnique(
new extensions::ExtensionsGuestViewManagerDelegate(context));
return base::WrapUnique(new extensions::ExtensionsGuestViewManagerDelegate(
CefBrowserContext::GetForContext(context)));
}
std::unique_ptr<MimeHandlerViewGuestDelegate>

View File

@@ -138,10 +138,7 @@ BrowserContext* CefExtensionsBrowserClient::GetOffTheRecordContext(
BrowserContext* CefExtensionsBrowserClient::GetOriginalContext(
BrowserContext* context) {
auto cef_browser_context = CefBrowserContext::FromBrowserContext(context);
if (cef_browser_context)
return cef_browser_context->AsBrowserContext();
return nullptr;
return CefBrowserContext::GetForContext(context);
}
bool CefExtensionsBrowserClient::IsGuestSession(BrowserContext* context) const {
@@ -203,9 +200,7 @@ bool CefExtensionsBrowserClient::AllowCrossRendererResourceLoad(
PrefService* CefExtensionsBrowserClient::GetPrefServiceForContext(
BrowserContext* context) {
return CefBrowserContext::FromBrowserContext(context)
->AsProfile()
->GetPrefs();
return static_cast<CefBrowserContext*>(context)->GetPrefs();
}
void CefExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
@@ -229,12 +224,12 @@ bool CefExtensionsBrowserClient::CreateBackgroundExtensionHost(
content::BrowserContext* browser_context,
const GURL& url,
ExtensionHost** host) {
auto cef_browser_context =
CefBrowserContext::FromBrowserContext(browser_context);
CefBrowserContext* browser_context_impl =
CefBrowserContext::GetForContext(browser_context);
// A CEF representation should always exist.
CefRefPtr<CefExtension> cef_extension =
cef_browser_context->GetExtension(extension->id());
browser_context_impl->extension_system()->GetExtension(extension->id());
DCHECK(cef_extension);
if (!cef_extension) {
// Cancel the background host creation.
@@ -272,7 +267,7 @@ bool CefExtensionsBrowserClient::CreateBackgroundExtensionHost(
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::Create(create_params);
if (browser) {
*host = browser->GetExtensionHost();
*host = browser->extension_host();
DCHECK(*host);
}
return true;

View File

@@ -5,10 +5,10 @@
#include "libcef/browser/extensions/mime_handler_view_guest_delegate.h"
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/osr/web_contents_view_osr.h"
#include "content/browser/browser_plugin/browser_plugin_guest.h"

View File

@@ -9,7 +9,6 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
namespace {

View File

@@ -13,6 +13,7 @@
#include "content/public/browser/file_select_listener.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/file_chooser_file_info.h"
#include "net/base/directory_lister.h"
namespace {
@@ -201,7 +202,7 @@ void CefFileDialogManager::RunFileDialog(
}
void CefFileDialogManager::RunFileChooser(
scoped_refptr<content::FileSelectListener> listener,
std::unique_ptr<content::FileSelectListener> listener,
const blink::mojom::FileChooserParams& params) {
CEF_REQUIRE_UIT();
@@ -212,11 +213,11 @@ void CefFileDialogManager::RunFileChooser(
if (params.mode == blink::mojom::FileChooserParams::Mode::kUploadFolder) {
callback = base::BindOnce(
&CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode, listener);
weak_ptr_factory_.GetWeakPtr(), params.mode, std::move(listener));
} else {
callback =
base::BindOnce(&CefFileDialogManager::OnRunFileChooserDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode, listener);
callback = base::BindOnce(
&CefFileDialogManager::OnRunFileChooserDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode, std::move(listener));
}
RunFileChooserInternal(cef_params, std::move(callback));
@@ -319,7 +320,7 @@ void CefFileDialogManager::OnRunFileChooserCallback(
void CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback(
const blink::mojom::FileChooserParams::Mode mode,
scoped_refptr<content::FileSelectListener> listener,
std::unique_ptr<content::FileSelectListener> listener,
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths) {
CEF_REQUIRE_UIT();
@@ -327,21 +328,21 @@ void CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback(
if (file_paths.size() == 0) {
// Client canceled the file chooser.
OnRunFileChooserDelegateCallback(mode, listener, selected_accept_filter,
file_paths);
OnRunFileChooserDelegateCallback(mode, std::move(listener),
selected_accept_filter, file_paths);
} else {
lister_.reset(new net::DirectoryLister(
file_paths[0], net::DirectoryLister::NO_SORT_RECURSIVE,
new UploadFolderHelper(base::BindOnce(
&CefFileDialogManager::OnRunFileChooserDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), mode, listener))));
weak_ptr_factory_.GetWeakPtr(), mode, std::move(listener)))));
lister_->Start();
}
}
void CefFileDialogManager::OnRunFileChooserDelegateCallback(
blink::mojom::FileChooserParams::Mode mode,
scoped_refptr<content::FileSelectListener> listener,
std::unique_ptr<content::FileSelectListener> listener,
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths) {
CEF_REQUIRE_UIT();

View File

@@ -46,7 +46,7 @@ class CefFileDialogManager {
// Called from CefBrowserHostImpl::RunFileChooser.
// See WebContentsDelegate::RunFileChooser documentation.
void RunFileChooser(scoped_refptr<content::FileSelectListener> listener,
void RunFileChooser(std::unique_ptr<content::FileSelectListener> listener,
const blink::mojom::FileChooserParams& params);
// Run the file chooser dialog specified by |params|. Only a single dialog may
@@ -71,7 +71,7 @@ class CefFileDialogManager {
// blink::mojom::FileChooserParams::Mode::kUploadFolder.
void OnRunFileChooserUploadFolderDelegateCallback(
const blink::mojom::FileChooserParams::Mode mode,
scoped_refptr<content::FileSelectListener> listener,
std::unique_ptr<content::FileSelectListener> listener,
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths);
@@ -79,7 +79,7 @@ class CefFileDialogManager {
// RenderFrameHost.
void OnRunFileChooserDelegateCallback(
blink::mojom::FileChooserParams::Mode mode,
scoped_refptr<content::FileSelectListener> listener,
std::unique_ptr<content::FileSelectListener> listener,
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths);

View File

@@ -1,534 +0,0 @@
// Copyright 2020 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/browser/main_runner.h"
#include "libcef/browser/browser_message_loop.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/alloy/alloy_main_runner_delegate.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/chrome/chrome_main_runner_delegate.h"
#include "libcef/features/runtime.h"
#include "base/at_exit.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug/debugger.h"
#include "base/run_loop.h"
#include "base/sequence_checker.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "content/app/content_service_manager_main_delegate.h"
#include "content/browser/scheduler/browser_task_executor.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h"
#include "services/service_manager/embedder/main.h"
#if defined(OS_WIN)
#include <Objbase.h>
#include <windows.h>
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#endif
#if defined(OS_MAC) || defined(OS_WIN)
#include "components/crash/core/app/crash_switches.h"
#include "third_party/crashpad/crashpad/handler/handler_main.h"
#endif
namespace {
enum class RuntimeType {
UNINITIALIZED,
ALLOY,
CHROME,
};
RuntimeType g_runtime_type = RuntimeType::UNINITIALIZED;
std::unique_ptr<CefMainRunnerDelegate> MakeDelegate(
RuntimeType type,
CefMainRunnerHandler* runner,
CefSettings* settings,
CefRefPtr<CefApp> application) {
if (type == RuntimeType::ALLOY) {
g_runtime_type = RuntimeType::ALLOY;
return std::make_unique<AlloyMainRunnerDelegate>(runner, settings,
application);
} else {
g_runtime_type = RuntimeType::CHROME;
return std::make_unique<ChromeMainRunnerDelegate>(runner, settings,
application);
}
}
#if defined(OS_MAC) || defined(OS_WIN)
// Based on components/crash/core/app/run_as_crashpad_handler_win.cc
// Remove the "--type=crashpad-handler" command-line flag that will otherwise
// confuse the crashpad handler.
// Chrome uses an embedded crashpad handler on Windows only and imports this
// function via the existing "run_as_crashpad_handler" target defined in
// components/crash/core/app/BUILD.gn. CEF uses an embedded handler on both
// Windows and macOS so we define the function here instead of using the
// existing target (because we can't use that target on macOS).
int RunAsCrashpadHandler(const base::CommandLine& command_line) {
base::CommandLine::StringVector argv = command_line.argv();
const base::CommandLine::StringType process_type =
FILE_PATH_LITERAL("--type=");
argv.erase(
std::remove_if(argv.begin(), argv.end(),
[&process_type](const base::CommandLine::StringType& str) {
return base::StartsWith(str, process_type,
base::CompareCase::SENSITIVE) ||
(!str.empty() && str[0] == L'/');
}),
argv.end());
#if defined(OS_MAC)
// HandlerMain on macOS uses the system version of getopt_long which expects
// the first argument to be the program name.
argv.insert(argv.begin(), command_line.GetProgram().value());
#endif
std::unique_ptr<char*[]> argv_as_utf8(new char*[argv.size() + 1]);
std::vector<std::string> storage;
storage.reserve(argv.size());
for (size_t i = 0; i < argv.size(); ++i) {
#if defined(OS_WIN)
storage.push_back(base::UTF16ToUTF8(argv[i]));
#else
storage.push_back(argv[i]);
#endif
argv_as_utf8[i] = &storage[i][0];
}
argv_as_utf8[argv.size()] = nullptr;
argv.clear();
return crashpad::HandlerMain(static_cast<int>(storage.size()),
argv_as_utf8.get(), nullptr);
}
#endif // defined(OS_MAC) || defined(OS_WIN)
} // namespace
// Used to run the UI on a separate thread.
class CefUIThread : public base::PlatformThread::Delegate {
public:
CefUIThread(CefMainRunner* runner, base::OnceClosure setup_callback)
: runner_(runner), setup_callback_(std::move(setup_callback)) {}
~CefUIThread() override { Stop(); }
void Start() {
base::AutoLock lock(thread_lock_);
bool success = base::PlatformThread::CreateWithPriority(
0, this, &thread_, base::ThreadPriority::NORMAL);
if (!success) {
LOG(FATAL) << "failed to UI create thread";
}
}
void Stop() {
base::AutoLock lock(thread_lock_);
if (!stopping_) {
stopping_ = true;
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefMainRunner::QuitMessageLoop,
base::Unretained(runner_)));
}
// Can't join if the |thread_| is either already gone or is non-joinable.
if (thread_.is_null())
return;
base::PlatformThread::Join(thread_);
thread_ = base::PlatformThreadHandle();
stopping_ = false;
}
bool WaitUntilThreadStarted() const {
DCHECK(owning_sequence_checker_.CalledOnValidSequence());
start_event_.Wait();
return true;
}
void InitializeBrowserRunner(
const content::MainFunctionParams& main_function_params) {
// Use our own browser process runner.
browser_runner_ = content::BrowserMainRunner::Create();
// Initialize browser process state. Uses the current thread's message loop.
int exit_code = browser_runner_->Initialize(main_function_params);
CHECK_EQ(exit_code, -1);
}
protected:
void ThreadMain() override {
base::PlatformThread::SetName("CefUIThread");
#if defined(OS_WIN)
// Initializes the COM library on the current thread.
CoInitialize(nullptr);
#endif
start_event_.Signal();
std::move(setup_callback_).Run();
runner_->RunMessageLoop();
browser_runner_->Shutdown();
browser_runner_.reset();
content::BrowserTaskExecutor::Shutdown();
// Run exit callbacks on the UI thread to avoid sequence check failures.
base::AtExitManager::ProcessCallbacksNow();
#if defined(OS_WIN)
// Closes the COM library on the current thread. CoInitialize must
// be balanced by a corresponding call to CoUninitialize.
CoUninitialize();
#endif
}
CefMainRunner* const runner_;
base::OnceClosure setup_callback_;
std::unique_ptr<content::BrowserMainRunner> browser_runner_;
bool stopping_ = false;
// The thread's handle.
base::PlatformThreadHandle thread_;
mutable base::Lock thread_lock_; // Protects |thread_|.
mutable base::WaitableEvent start_event_;
// This class is not thread-safe, use this to verify access from the owning
// sequence of the Thread.
base::SequenceChecker owning_sequence_checker_;
};
CefMainRunner::CefMainRunner(bool multi_threaded_message_loop,
bool external_message_pump)
: multi_threaded_message_loop_(multi_threaded_message_loop),
external_message_pump_(external_message_pump) {}
CefMainRunner::~CefMainRunner() = default;
bool CefMainRunner::Initialize(CefSettings* settings,
CefRefPtr<CefApp> application,
const CefMainArgs& args,
void* windows_sandbox_info,
bool* initialized,
base::OnceClosure context_initialized) {
DCHECK(!main_delegate_);
main_delegate_ = MakeDelegate(
settings->chrome_runtime ? RuntimeType::CHROME : RuntimeType::ALLOY, this,
settings, application);
const int exit_code =
ContentMainInitialize(args, windows_sandbox_info, &settings->no_sandbox);
if (exit_code >= 0) {
NOTREACHED() << "ContentMainInitialize failed";
return false;
}
if (!ContentMainRun(initialized, std::move(context_initialized))) {
NOTREACHED() << "ContentMainRun failed";
return false;
}
return true;
}
void CefMainRunner::Shutdown(base::OnceClosure shutdown_on_ui_thread,
base::OnceClosure finalize_shutdown) {
if (multi_threaded_message_loop_) {
// Events that will be used to signal when shutdown is complete. Start in
// non-signaled mode so that the event will block.
base::WaitableEvent uithread_shutdown_event(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
// Finish shutdown on the UI thread.
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefMainRunner::FinishShutdownOnUIThread,
base::Unretained(this), std::move(shutdown_on_ui_thread),
&uithread_shutdown_event));
/// Block until UI thread shutdown is complete.
uithread_shutdown_event.Wait();
FinalizeShutdown(std::move(finalize_shutdown));
} else {
// Finish shutdown on the current thread, which should be the UI thread.
FinishShutdownOnUIThread(std::move(shutdown_on_ui_thread), nullptr);
FinalizeShutdown(std::move(finalize_shutdown));
}
}
void CefMainRunner::RunMessageLoop() {
base::RunLoop run_loop;
DCHECK(quit_when_idle_callback_.is_null());
quit_when_idle_callback_ = run_loop.QuitWhenIdleClosure();
main_delegate_->BeforeMainMessageLoopRun(&run_loop);
// Blocks until QuitMessageLoop() is called.
run_loop.Run();
}
void CefMainRunner::QuitMessageLoop() {
if (!quit_when_idle_callback_.is_null()) {
if (main_delegate_->HandleMainMessageLoopQuit())
return;
std::move(quit_when_idle_callback_).Run();
}
}
// static
int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args,
CefRefPtr<CefApp> application,
void* windows_sandbox_info) {
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
#if defined(OS_WIN)
command_line.ParseFromString(::GetCommandLineW());
#else
command_line.InitFromArgv(args.argc, args.argv);
#endif
// Wait for the debugger as early in process initialization as possible.
if (command_line.HasSwitch(switches::kWaitForDebugger))
base::debug::WaitForDebugger(60, true);
// If no process type is specified then it represents the browser process and
// we do nothing.
const std::string& process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
if (process_type.empty())
return -1;
auto runtime_type = command_line.HasSwitch(switches::kEnableChromeRuntime)
? RuntimeType::CHROME
: RuntimeType::ALLOY;
auto main_delegate = MakeDelegate(runtime_type, /*runner=*/nullptr,
/*settings=*/nullptr, application);
main_delegate->BeforeExecuteProcess(args);
int result;
#if defined(OS_MAC) || defined(OS_WIN)
if (process_type == crash_reporter::switches::kCrashpadHandler) {
result = RunAsCrashpadHandler(command_line);
main_delegate->AfterExecuteProcess();
return result;
}
#endif
// Execute the secondary process.
content::ContentMainParams params(main_delegate->GetContentMainDelegate());
#if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (windows_sandbox_info == nullptr) {
content::InitializeSandboxInfo(&sandbox_info);
windows_sandbox_info = &sandbox_info;
}
params.instance = args.instance;
params.sandbox_info =
static_cast<sandbox::SandboxInterfaceInfo*>(windows_sandbox_info);
#else
params.argc = args.argc;
params.argv = const_cast<const char**>(args.argv);
#endif
result = content::ContentMain(params);
main_delegate->AfterExecuteProcess();
return result;
}
int CefMainRunner::ContentMainInitialize(const CefMainArgs& args,
void* windows_sandbox_info,
int* no_sandbox) {
main_delegate_->BeforeMainThreadInitialize(args);
// Initialize the content runner.
content::ContentMainParams params(main_delegate_->GetContentMainDelegate());
#if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (windows_sandbox_info == nullptr) {
windows_sandbox_info = &sandbox_info;
*no_sandbox = true;
}
params.instance = args.instance;
params.sandbox_info =
static_cast<sandbox::SandboxInterfaceInfo*>(windows_sandbox_info);
#else
params.argc = args.argc;
params.argv = const_cast<const char**>(args.argv);
#endif
sm_main_delegate_.reset(
new content::ContentServiceManagerMainDelegate(params));
sm_main_params_.reset(
new service_manager::MainParams(sm_main_delegate_.get()));
#if defined(OS_POSIX) && !defined(OS_ANDROID)
sm_main_params_->argc = params.argc;
sm_main_params_->argv = params.argv;
#endif
return service_manager::MainInitialize(*sm_main_params_);
}
bool CefMainRunner::ContentMainRun(bool* initialized,
base::OnceClosure context_initialized) {
main_delegate_->BeforeMainThreadRun();
if (multi_threaded_message_loop_) {
base::WaitableEvent uithread_startup_event(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
if (!CreateUIThread(base::BindOnce(
[](CefMainRunner* runner, base::WaitableEvent* event) {
service_manager::MainRun(*runner->sm_main_params_);
event->Signal();
},
base::Unretained(this),
base::Unretained(&uithread_startup_event)))) {
return false;
}
*initialized = true;
// We need to wait until service_manager::MainRun has finished.
uithread_startup_event.Wait();
} else {
*initialized = true;
service_manager::MainRun(*sm_main_params_);
}
if (CEF_CURRENTLY_ON_UIT()) {
OnContextInitialized(std::move(context_initialized));
} else {
// Continue initialization on the UI thread.
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefMainRunner::OnContextInitialized,
base::Unretained(this),
std::move(context_initialized)));
}
return true;
}
void CefMainRunner::PreCreateMainMessageLoop() {
if (external_message_pump_) {
InitExternalMessagePumpFactoryForUI();
}
}
int CefMainRunner::RunMainProcess(
const content::MainFunctionParams& main_function_params) {
if (!multi_threaded_message_loop_) {
// Use our own browser process runner.
browser_runner_ = content::BrowserMainRunner::Create();
// Initialize browser process state. Results in a call to
// AlloyBrowserMain::PreMainMessageLoopStart() which creates the UI message
// loop.
int exit_code = browser_runner_->Initialize(main_function_params);
if (exit_code >= 0)
return exit_code;
} else {
// Running on the separate UI thread.
DCHECK(ui_thread_);
ui_thread_->InitializeBrowserRunner(main_function_params);
}
return 0;
}
bool CefMainRunner::CreateUIThread(base::OnceClosure setup_callback) {
DCHECK(!ui_thread_);
ui_thread_.reset(new CefUIThread(this, std::move(setup_callback)));
ui_thread_->Start();
ui_thread_->WaitUntilThreadStarted();
if (external_message_pump_) {
InitExternalMessagePumpFactoryForUI();
}
return true;
}
void CefMainRunner::OnContextInitialized(
base::OnceClosure context_initialized) {
CEF_REQUIRE_UIT();
main_delegate_->AfterUIThreadInitialize();
std::move(context_initialized).Run();
}
void CefMainRunner::FinishShutdownOnUIThread(
base::OnceClosure shutdown_on_ui_thread,
base::WaitableEvent* uithread_shutdown_event) {
CEF_REQUIRE_UIT();
sm_main_delegate_->ShutdownOnUIThread();
std::move(shutdown_on_ui_thread).Run();
main_delegate_->AfterUIThreadShutdown();
if (uithread_shutdown_event)
uithread_shutdown_event->Signal();
}
void CefMainRunner::FinalizeShutdown(base::OnceClosure finalize_shutdown) {
main_delegate_->BeforeMainThreadShutdown();
if (browser_runner_.get()) {
browser_runner_->Shutdown();
browser_runner_.reset();
}
if (ui_thread_.get()) {
// Blocks until the thread has stopped.
ui_thread_->Stop();
ui_thread_.reset();
}
// Shut down the content runner.
service_manager::MainShutdown(*sm_main_params_);
sm_main_params_.reset();
sm_main_delegate_.reset();
std::move(finalize_shutdown).Run();
main_delegate_->AfterMainThreadShutdown();
main_delegate_.reset();
g_runtime_type = RuntimeType::UNINITIALIZED;
}
// From libcef/features/runtime.h:
namespace cef {
bool IsAlloyRuntimeEnabled() {
return g_runtime_type == RuntimeType::ALLOY;
}
bool IsChromeRuntimeEnabled() {
return g_runtime_type == RuntimeType::CHROME;
}
} // namespace cef

View File

@@ -1,102 +0,0 @@
// Copyright 2020 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_BROWSER_MAIN_RUNNER_H_
#define CEF_LIBCEF_BROWSER_MAIN_RUNNER_H_
#pragma once
#include "include/cef_app.h"
#include "libcef/common/main_runner_delegate.h"
#include "libcef/common/main_runner_handler.h"
#include "base/callback.h"
#include "base/macros.h"
#include "content/public/browser/browser_main_runner.h"
namespace base {
class WaitableEvent;
}
namespace content {
class ContentMainDelegate;
class ContentServiceManagerMainDelegate;
struct MainFunctionParams;
} // namespace content
namespace service_manager {
struct MainParams;
}
class CefUIThread;
// Manages the main process lifespan and related objects.
class CefMainRunner : public CefMainRunnerHandler {
public:
CefMainRunner(bool multi_threaded_message_loop, bool external_message_pump);
~CefMainRunner();
// Called from CefContext::Initialize.
bool Initialize(CefSettings* settings,
CefRefPtr<CefApp> application,
const CefMainArgs& args,
void* windows_sandbox_info,
bool* initialized,
base::OnceClosure context_initialized);
// Called from CefContext::Shutdown.
void Shutdown(base::OnceClosure shutdown_on_ui_thread,
base::OnceClosure finalize_shutdown);
void RunMessageLoop();
void QuitMessageLoop();
// Called from CefExecuteProcess.
static int RunAsHelperProcess(const CefMainArgs& args,
CefRefPtr<CefApp> application,
void* windows_sandbox_info);
private:
// Called from Initialize().
int ContentMainInitialize(const CefMainArgs& args,
void* windows_sandbox_info,
int* no_sandbox);
bool ContentMainRun(bool* initialized, base::OnceClosure context_initialized);
// CefMainRunnerHandler methods:
void PreCreateMainMessageLoop() override;
int RunMainProcess(
const content::MainFunctionParams& main_function_params) override;
// Create the UI thread when running with multi-threaded message loop mode.
bool CreateUIThread(base::OnceClosure setup_callback);
// Called on the UI thread after the context is initialized.
void OnContextInitialized(base::OnceClosure context_initialized);
// Performs shutdown actions that need to occur on the UI thread before any
// threads are destroyed.
void FinishShutdownOnUIThread(base::OnceClosure shutdown_on_ui_thread,
base::WaitableEvent* uithread_shutdown_event);
// Destroys the runtime and related objects.
void FinalizeShutdown(base::OnceClosure finalize_shutdown);
const bool multi_threaded_message_loop_;
const bool external_message_pump_;
std::unique_ptr<CefMainRunnerDelegate> main_delegate_;
std::unique_ptr<content::ContentServiceManagerMainDelegate> sm_main_delegate_;
std::unique_ptr<service_manager::MainParams> sm_main_params_;
std::unique_ptr<content::BrowserMainRunner> browser_runner_;
std::unique_ptr<CefUIThread> ui_thread_;
// Used to quit the current base::RunLoop.
base::OnceClosure quit_when_idle_callback_;
DISALLOW_COPY_AND_ASSIGN(CefMainRunner);
};
#endif // CEF_LIBCEF_BROWSER_MAIN_RUNNER_H_

Some files were not shown because too many files have changed in this diff Show More