Compare commits

..

17 Commits
4515 ... 4324

Author SHA1 Message Date
Marshall Greenblatt
5c8711aa60 Update to Chromium version 88.0.4324.182 2021-02-18 18:54:36 -05:00
Marshall Greenblatt
e484012396 Linux: cefclient: Fix GTK expectations with OSR multi-threaded-message-loop (fixes issue #3087) 2021-02-15 12:57:32 -05:00
Marshall Greenblatt
c18ff5804d Linux: cefclient: Fix GTK behavior with multi-threaded-message-loop (fixes issue #3087)
Switch to using g_main_context_default() in MainMessageLoopMultithreadedGtk. As of M86
(https://crrev.com/b960daf4e6) Chromium now creates its own context in MessagePumpGlib so
we can use the default context in cefclient. This is also more "correct" from a GTK usage
perspective. As part of this change all GTK dialogs and callbacks are now executed on the
main thread instead of the UI thread (note that these are the same thread when not using
multi-threaded-message-loop).
2021-02-12 15:04:22 -05:00
Marshall Greenblatt
d717f0e7ea Mac: Fix incorrect creation of NSAutoreleasePool (fixes issue #2160) 2021-02-11 17:35:20 -05:00
Cristian Amarie
cab058ba28 Fix loading of URL without scheme (fixes issue #3079) 2021-02-10 18:30:43 +00:00
Marshall Greenblatt
f3c4ca9260 Update to Chromium version 88.0.4324.150 2021-02-05 21:06:10 -05:00
Marshall Greenblatt
92508bcc87 Fix chrome runtime startup assertion and PDF loading (see issue #2969) 2021-02-04 18:29:08 -05:00
Marshall Greenblatt
be147ed683 Fix PDF viewer label substitutions (fixes issue #3081) 2021-02-04 18:21:29 -05:00
Marshall Greenblatt
0b18d0bc60 Update to Chromium version 88.0.4324.146 2021-02-03 21:13:35 -05:00
Marshall Greenblatt
6a304f532c Update copyright year on generated files 2021-01-27 13:44:21 -05:00
Marshall Greenblatt
4fe33a194a Add workaround for crash on Views popup window creation (see issue #3040) 2021-01-21 13:33:09 -05:00
Marshall Greenblatt
9249bfe7c4 Windows: cmake: Fix unknown arguments error with VS2017 generator 2021-01-21 11:11:09 -05:00
Marshall Greenblatt
5a6ab2302c Update to Chromium version 88.0.4324.96 2021-01-20 19:08:37 -05:00
Marshall Greenblatt
5b4e0eee60 Update to Chromium version 88.0.4324.87 2021-01-19 13:57:34 -05:00
Marshall Greenblatt
ac8e5f01b3 Windows: Ignore INCLUDE/LIB env if vcvarsall.bat is available (see issue #2773)
Windows ARM64 cross-compile requires building Clang x64 binaries. Building both
arm64 and x64 binaries in the same build is not possible when using INCLUDE/LIB
values set via the environment. Instead, allow Chromium to extract the correct
configuration from vcvarsall.bat for populating the environment.[arch] files.
2021-01-11 14:15:34 -05:00
Marshall Greenblatt
63ad8fc88d Windows: Add ARM64 distribution support (see issue #2773)
To generate Windows ARM64 builds set the CEF_ENABLE_ARM64=1 environment
variable and pass the "--arm64-build --build-target=cefsimple" command-line
arguments to automate-git.py. We can't build cefclient.exe for ARM64 due to
missing OpenGL library support so build cefsimple.exe instead.
2021-01-11 14:15:26 -05:00
Marshall Greenblatt
433d6e1fa4 Update to Chromium version 88.0.4324.27 2020-12-08 15:19:14 -05:00
563 changed files with 9546 additions and 15162 deletions

516
BUILD.gn
View File

@@ -98,6 +98,7 @@ import("//build/config/features.gni")
import("//build/config/locales.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni")
import("//cef/cef_repack_locales.gni")
import("//chrome/common/features.gni")
import("//content/public/app/mac_helpers.gni")
import("//extensions/buildflags/buildflags.gni")
@@ -125,6 +126,7 @@ if (is_mac) {
import("//build/config/mac/rules.gni")
import("//build/util/version.gni")
import("//media/cdm/library_cdm/cdm_paths.gni")
import("//build/config/mac/base_rules.gni")
# Template to compile .xib and .storyboard files.
#
@@ -261,6 +263,12 @@ if (is_clang) {
assert(!clang_use_chrome_plugins)
}
if (is_mac) {
# Always generate dSYM files. The make_distrib script will fail if
# enable_dsyms=true is not explicitly set when is_official_build=false.
assert(enable_dsyms)
}
#
# Local variables.
@@ -357,9 +365,6 @@ if (is_win) {
# Required by content_switches.cc
"//media:media_buildflags",
# Required by crash_keys.cc (from base/stl_util.h)
"//third_party/abseil-cpp:absl",
]
}
}
@@ -428,8 +433,6 @@ static_library("libcef_static") {
"libcef/browser/browser_context.h",
"libcef/browser/browser_context_keyed_service_factories.cc",
"libcef/browser/browser_context_keyed_service_factories.h",
"libcef/browser/browser_frame.cc",
"libcef/browser/browser_frame.h",
"libcef/browser/browser_host_base.cc",
"libcef/browser/browser_host_base.h",
"libcef/browser/browser_host_create.cc",
@@ -437,8 +440,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_manager.cc",
"libcef/browser/browser_manager.h",
"libcef/browser/browser_message_filter.cc",
"libcef/browser/browser_message_filter.h",
"libcef/browser/browser_message_loop.cc",
"libcef/browser/browser_message_loop.h",
"libcef/browser/browser_platform_delegate.cc",
@@ -459,8 +462,6 @@ static_library("libcef_static") {
"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/chrome_context_menu_handler.cc",
"libcef/browser/chrome/chrome_context_menu_handler.h",
"libcef/browser/chrome_crash_reporter_client_stub.cc",
"libcef/browser/context.cc",
"libcef/browser/context.h",
@@ -486,8 +487,6 @@ static_library("libcef_static") {
"libcef/browser/extensions/api/storage/sync_value_store_cache.h",
"libcef/browser/extensions/api/tabs/tabs_api.cc",
"libcef/browser/extensions/api/tabs/tabs_api.h",
"libcef/browser/extensions/alloy_extensions_util.cc",
"libcef/browser/extensions/alloy_extensions_util.h",
"libcef/browser/extensions/browser_extensions_util.cc",
"libcef/browser/extensions/browser_extensions_util.h",
"libcef/browser/extensions/browser_platform_delegate_background.cc",
@@ -561,6 +560,8 @@ static_library("libcef_static") {
"libcef/browser/native/browser_platform_delegate_native.h",
"libcef/browser/native/cursor_util.h",
"libcef/browser/native/cursor_util.cc",
"libcef/browser/navigate_params.cc",
"libcef/browser/navigate_params.h",
"libcef/browser/navigation_entry_impl.cc",
"libcef/browser/navigation_entry_impl.h",
"libcef/browser/net/chrome_scheme_handler.cc",
@@ -627,6 +628,8 @@ static_library("libcef_static") {
"libcef/browser/print_settings_impl.h",
"libcef/browser/printing/constrained_window_views_client.cc",
"libcef/browser/printing/constrained_window_views_client.h",
"libcef/browser/printing/printing_message_filter.cc",
"libcef/browser/printing/printing_message_filter.h",
"libcef/browser/printing/print_view_manager.cc",
"libcef/browser/printing/print_view_manager.h",
"libcef/browser/process_util_impl.cc",
@@ -637,8 +640,6 @@ static_library("libcef_static") {
"libcef/browser/scheme_impl.cc",
"libcef/browser/server_impl.cc",
"libcef/browser/server_impl.h",
"libcef/browser/simple_menu_model_impl.cc",
"libcef/browser/simple_menu_model_impl.h",
"libcef/browser/speech_recognition_manager_delegate.cc",
"libcef/browser/speech_recognition_manager_delegate.h",
"libcef/browser/ssl_host_state_delegate.cc",
@@ -674,6 +675,10 @@ static_library("libcef_static") {
"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",
"libcef/common/cef_messages.cc",
"libcef/common/cef_messages.h",
"libcef/common/cef_switches.cc",
"libcef/common/cef_switches.h",
"libcef/common/chrome/chrome_content_client_cef.cc",
@@ -710,8 +715,10 @@ static_library("libcef_static") {
"libcef/common/net/net_resource_provider.h",
"libcef/common/net/scheme_registration.cc",
"libcef/common/net/scheme_registration.h",
"libcef/common/net/url_util.cc",
"libcef/common/net/url_util.h",
"libcef/common/net/upload_data.cc",
"libcef/common/net/upload_data.h",
"libcef/common/net/upload_element.cc",
"libcef/common/net/upload_element.h",
"libcef/common/net_service/net_service_util.cc",
"libcef/common/net_service/net_service_util.h",
"libcef/common/parser_impl.cc",
@@ -727,14 +734,14 @@ static_library("libcef_static") {
"libcef/common/resource_util.h",
"libcef/common/response_impl.cc",
"libcef/common/response_impl.h",
"libcef/common/response_manager.cc",
"libcef/common/response_manager.h",
"libcef/common/scheme_registrar_impl.cc",
"libcef/common/scheme_registrar_impl.h",
"libcef/common/string_list_impl.cc",
"libcef/common/string_map_impl.cc",
"libcef/common/string_multimap_impl.cc",
"libcef/common/string_types_impl.cc",
"libcef/common/string_util.cc",
"libcef/common/string_util.h",
"libcef/common/task_impl.cc",
"libcef/common/task_runner_impl.cc",
"libcef/common/task_runner_impl.h",
@@ -760,12 +767,16 @@ static_library("libcef_static") {
"libcef/features/runtime_checks.h",
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
"libcef/renderer/alloy/alloy_content_renderer_client.h",
"libcef/renderer/alloy/alloy_render_frame_observer.cc",
"libcef/renderer/alloy/alloy_render_frame_observer.h",
"libcef/renderer/alloy/alloy_render_thread_observer.cc",
"libcef/renderer/alloy/alloy_render_thread_observer.h",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.cc",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.h",
"libcef/renderer/browser_impl.cc",
"libcef/renderer/browser_impl.h",
"libcef/renderer/browser_manager.cc",
"libcef/renderer/browser_manager.h",
"libcef/renderer/chrome/chrome_content_renderer_client_cef.cc",
"libcef/renderer/chrome/chrome_content_renderer_client_cef.h",
"libcef/renderer/dom_document_impl.cc",
@@ -784,8 +795,8 @@ static_library("libcef_static") {
"libcef/renderer/render_frame_observer.h",
"libcef/renderer/render_frame_util.cc",
"libcef/renderer/render_frame_util.h",
"libcef/renderer/render_manager.cc",
"libcef/renderer/render_manager.h",
"libcef/renderer/render_thread_observer.cc",
"libcef/renderer/render_thread_observer.h",
"libcef/renderer/render_urlrequest_impl.cc",
"libcef/renderer/render_urlrequest_impl.h",
"libcef/renderer/thread_util.h",
@@ -795,10 +806,6 @@ static_library("libcef_static") {
# For Chrome runtime support.
"//chrome/app/chrome_main_delegate.cc",
"//chrome/app/chrome_main_delegate.h",
# Part of //content//test::test_support which is testingonly.
"//content/public/test/scoped_web_ui_controller_factory_registration.cc",
"//content/public/test/scoped_web_ui_controller_factory_registration.h",
]
configs += [
@@ -825,7 +832,6 @@ static_library("libcef_static") {
deps = [
":cef_make_headers",
"libcef/common/mojom",
":libcef_static_unittested",
@@ -1054,17 +1060,13 @@ static_library("libcef_static") {
}
if (toolkit_views) {
deps += [
"//ui/views",
]
}
if (use_aura) {
sources += [
"libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc",
"libcef/browser/chrome/views/browser_platform_delegate_chrome_views.h",
"libcef/browser/chrome/views/chrome_browser_frame.cc",
"libcef/browser/chrome/views/chrome_browser_frame.h",
"libcef/browser/chrome/views/chrome_browser_view.cc",
"libcef/browser/chrome/views/chrome_browser_view.h",
"libcef/browser/chrome/views/toolbar_view_impl.cc",
"libcef/browser/chrome/views/toolbar_view_impl.h",
"libcef/browser/chrome/views/toolbar_view_view.cc",
"libcef/browser/chrome/views/toolbar_view_view.h",
"libcef/browser/native/window_delegate_view.cc",
"libcef/browser/native/window_delegate_view.h",
"libcef/browser/views/basic_label_button_impl.cc",
@@ -1125,106 +1127,84 @@ static_library("libcef_static") {
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/desktop_test_views_delegate.h",
"//ui/views/test/desktop_test_views_delegate_aura.cc",
"//ui/views/test/test_views_delegate.h",
"//ui/views/test/test_views_delegate_aura.cc",
# Support for UI input events.
# Part of //ui/base:test_support which is testingonly.
"//ui/base/test/ui_controls.h",
"//ui/base/test/ui_controls_aura.cc",
"//ui/aura/test/ui_controls_factory_aura.h",
]
if (is_linux && !use_x11) {
sources += [
"//ui/aura/test/ui_controls_factory_ozone.cc",
"//ui/events/test/events_test_utils.cc"
]
}
deps += [
"//ui/aura",
"//ui/events",
"//ui/strings",
"//ui/views",
"//ui/views/controls/webview",
"//ui/wm",
"//ui/wm/public",
]
if (use_aura) {
sources += [
"libcef/browser/native/browser_platform_delegate_native_aura.cc",
"libcef/browser/native/browser_platform_delegate_native_aura.h",
"libcef/browser/views/view_util_aura.cc",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/desktop_test_views_delegate_aura.cc",
"//ui/views/test/test_views_delegate_aura.cc",
# Support for UI input events.
# Part of //ui/base:test_support which is testingonly.
"//ui/base/test/ui_controls_aura.cc",
"//ui/aura/test/ui_controls_factory_aura.h",
]
if (toolkit_views) {
deps += [
"//ui/aura",
"//ui/wm",
"//ui/wm/public",
"//ui/views/controls/webview",
]
}
if (is_win) {
sources += [
# Support for UI input events.
# Part of //base/test:test_config which is testingonly.
"//base/test/test_switches.cc",
"//base/test/test_switches.h",
"//base/test/test_timeouts.cc",
"//base/test/test_timeouts.h",
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/ui_controls_factory_aurawin.cc",
# Part of //ui/base:test_support which is testingonly.
"//ui/base/test/ui_controls_internal_win.cc",
"//ui/base/test/ui_controls_internal_win.h",
]
}
if (is_linux) {
sources += [
# Support for UI input events.
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/aura_test_utils.cc",
"//ui/aura/test/aura_test_utils.h",
# Part of //ui/events:test_support which is testingonly.
"//ui/events/test/x11_event_waiter.cc",
"//ui/events/test/x11_event_waiter.h",
]
if (is_win) {
if (use_x11) {
sources += [
# Support for UI input events.
# Part of //base/test:test_config which is testingonly.
"//base/test/test_switches.cc",
"//base/test/test_switches.h",
"//base/test/test_timeouts.cc",
"//base/test/test_timeouts.h",
# Part of //ui/base/x:test_support which is testingonly.
"//ui/base/x/test/x11_ui_controls_test_helper.cc",
"//ui/base/x/test/x11_ui_controls_test_helper.h",
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/ui_controls_factory_aurawin.cc",
# Part of //ui/base:test_support which is testingonly.
"//ui/base/test/ui_controls_internal_win.cc",
"//ui/base/test/ui_controls_internal_win.h",
"//ui/aura/test/x11_event_sender.h",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
"//ui/views/test/ui_controls_factory_desktop_aurax11.h",
]
}
if (is_linux) {
sources += [
# Support for UI input events.
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/aura_test_utils.cc",
"//ui/aura/test/aura_test_utils.h",
# Part of //ui/events:test_support which is testingonly.
"//ui/events/test/x11_event_waiter.cc",
"//ui/events/test/x11_event_waiter.h",
]
if (use_x11) {
sources += [
# Support for UI input events.
# Part of //ui/base/x:test_support which is testingonly.
"//ui/base/x/test/x11_ui_controls_test_helper.cc",
"//ui/base/x/test/x11_ui_controls_test_helper.h",
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/x11_event_sender.h",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
"//ui/views/test/ui_controls_factory_desktop_aurax11.h",
]
} else {
sources += [
# Support for UI input events.
# Part of //ui/base:test_support which is testingonly.
"//ui/aura/test/ui_controls_factory_ozone.cc",
# Part of //ui//events:test_support which is testingonly.
"//ui/events/test/events_test_utils.cc"
]
}
}
}
if (is_mac) {
if (is_win || is_linux) {
sources += [
"libcef/browser/views/view_util_mac.mm",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/desktop_test_views_delegate_mac.mm",
"//ui/views/test/test_views_delegate_mac.mm",
# Support for UI input events.
# Part of //ui/base:test_support which is testingonly.
"//ui/base/test/ui_controls_mac.mm",
# Part of //ui//events:test_support which is testingonly.
"//ui/events/test/cocoa_test_event_utils.mm",
"libcef/browser/native/browser_platform_delegate_native_aura.cc",
"libcef/browser/native/browser_platform_delegate_native_aura.h",
]
}
} else {
@@ -1303,8 +1283,119 @@ if (is_mac) {
# Resource grit/pack targets.
#
# Included in locales/*.pak via //chrome/chrome_repack_locales.gni.
# Helper for generating scaled resource packs.
template("cef_pak_scaled") {
percent = invoker.percent
repack("pak_${target_name}") {
# Each input pak file should also have a deps line for completeness.
# Add associated .h files in the make_pack_header("resources") target.
sources = [
"$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
"$root_gen_dir/components/components_resources_${percent}_percent.pak",
"$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak",
"$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak",
"$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_${percent}_percent.pak",
"$root_gen_dir/ui/resources/ui_resources_${percent}_percent.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 = [
"//chrome/renderer:resources",
"//components/resources:components_scaled_resources",
"//content/app/resources",
"//extensions:extensions_browser_resources",
"//third_party/blink/public:scaled_resources",
"//ui/resources:ui_resources_grd",
]
deps = [
# This repack target generates the blink_scaled_resources_*_percent.pak
# file but doesn't expose the public_deps required by make_pack_header.
"//third_party/blink/public:scaled_resources_${percent}_percent",
]
if (toolkit_views) {
sources += [
"$root_gen_dir/ui/views/resources/views_resources_${percent}_percent.pak"
]
public_deps += [
"//ui/views/resources:resources_grd"
]
}
output = "$root_out_dir/cef_${percent}_percent.pak"
}
}
# Generate cef_100_percent.pak.
cef_pak_scaled("100_percent") {
percent = "100"
}
# Generate cef_200_percent.pak.
cef_pak_scaled("200_percent") {
percent = "200"
}
# Generate devtools_resources.pak.
repack("pak_devtools") {
# Each input pak file should also have a deps line for completeness.
# 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",
]
output = "$root_out_dir/devtools_resources.pak"
}
# Generate cef_extensions.pak.
repack("pak_extensions") {
# Each input pak file should also have a deps line for completeness.
# Add associated .h files in the make_pack_header("resources") target.
sources = [
"$root_gen_dir/chrome/component_extension_resources.pak",
"$root_gen_dir/content/browser/resources/media/media_internals_resources.pak",
"$root_gen_dir/content/browser/webrtc/resources/webrtc_internals_resources.pak",
"$root_gen_dir/extensions/extensions_renderer_resources.pak",
"$root_gen_dir/extensions/extensions_resources.pak",
"$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
"$root_gen_dir/ui/resources/webui_generated_resources.pak",
"$root_gen_dir/ui/resources/webui_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 = [
"//chrome/browser/resources:component_extension_resources",
"//content/browser/resources/media:media_internals_resources",
"//content/browser/webrtc/resources",
"//extensions:extensions_renderer_resources",
"//extensions:extensions_resources_grd",
"//mojo/public/js:resources",
"//ui/resources:webui_generated_resources_grd",
"//ui/resources:webui_resources_grd",
]
output = "$root_out_dir/cef_extensions.pak"
}
grit("cef_strings") {
visibility = [ ":*" ]
source = "libcef/resources/cef_strings.grd"
outputs = [
"grit/cef_strings.h",
@@ -1315,8 +1406,22 @@ grit("cef_strings") {
}
}
# Included in resources.pak via //chrome/chrome_paks.gni.
# Generate locales/<locale>.pak.
# See cef_repack_locales.gni for the list of input pak files and deps.
cef_repack_locales("repack_locales_pack") {
visibility = [ ":*" ]
input_locales = locales
if (is_mac) {
output_locales = locales_as_mac_outputs
} else {
output_locales = locales
}
}
grit("cef_resources") {
visibility = [ ":*" ]
source = "libcef/resources/cef_resources.grd"
outputs = [
"grit/cef_resources.h",
@@ -1328,11 +1433,54 @@ grit("cef_resources") {
]
}
# Generate cef.pak.
repack("pak") {
# Each input pak file should also have a deps line for completeness.
# Add associated .h files in the make_pack_header("resources") target.
sources = [
"$root_gen_dir/base/tracing/protos/tracing_proto_resources.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_resources.pak",
"$root_gen_dir/chrome/common_resources.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/components/dev_ui_components_resources.pak",
"$root_gen_dir/cef/cef_resources.pak",
"$root_gen_dir/content/browser/tracing/tracing_resources.pak",
"$root_gen_dir/content/content_resources.pak",
"$root_gen_dir/content/dev_ui_content_resources.pak",
"$root_gen_dir/net/net_resources.pak",
"$root_gen_dir/third_party/blink/public/resources/blink_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 = [
"//base/tracing/protos:chrome_track_event_resources",
"//chrome/browser:dev_ui_browser_resources",
"//chrome/browser:resources",
"//chrome/browser/resources/net_internals:net_internals_resources",
"//chrome/browser/resources/print_preview:print_preview_resources",
"//chrome/common:resources",
"//components/resources:components_resources",
"//components/resources:dev_ui_components_resources",
":cef_resources",
"//content/browser/tracing:resources",
"//content:content_resources",
"//content:dev_ui_content_resources",
"//net:net_resources",
"//third_party/blink/public:resources",
]
output = "$root_out_dir/cef.pak"
}
# Helper for generating pack header files.
template("make_pack_header") {
assert(defined(invoker.header))
assert(defined(invoker.inputs))
assert(defined(invoker.deps))
action("make_pack_header_${target_name}") {
script = "tools/make_pack_header.py"
@@ -1343,7 +1491,16 @@ template("make_pack_header") {
args = rebase_path(outputs, root_build_dir) +
rebase_path(inputs, root_build_dir)
deps = invoker.deps
deps = [
# List all targets that generate pack files here. The grit targets that
# generate |inputs| will be picked up via public_deps.
":pak",
":pak_100_percent",
":pak_200_percent",
":pak_devtools",
":pak_extensions",
":repack_locales_pack",
]
}
}
@@ -1357,55 +1514,25 @@ make_pack_header("resources") {
"$root_gen_dir/chrome/grit/common_resources.h",
"$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_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",
"$root_gen_dir/content/browser/devtools/grit/devtools_resources.h",
"$root_gen_dir/content/browser/tracing/grit/tracing_resources.h",
"$root_gen_dir/content/browser/webrtc/resources/grit/webrtc_internals_resources.h",
"$root_gen_dir/content/grit/content_resources.h",
"$root_gen_dir/content/grit/dev_ui_content_resources.h",
"$root_gen_dir/extensions/grit/extensions_browser_resources.h",
"$root_gen_dir/extensions/grit/extensions_renderer_resources.h",
"$root_gen_dir/extensions/grit/extensions_resources.h",
"$root_gen_dir/mojo/public/js/grit/mojo_bindings_resources.h",
"$root_gen_dir/net/grit/net_resources.h",
"$root_gen_dir/third_party/blink/public/resources/grit/blink_resources.h",
"$root_gen_dir/ui/resources/grit/ui_resources.h",
"$root_gen_dir/ui/resources/grit/webui_generated_resources.h",
"$root_gen_dir/ui/resources/grit/webui_resources.h",
"$root_gen_dir/ui/views/resources/grit/views_resources.h",
]
deps = [
":cef_resources",
"//base/tracing/protos:chrome_track_event_resources",
"//chrome/browser:dev_ui_browser_resources",
"//chrome/browser:resources",
"//chrome/browser/resources:component_extension_resources",
"//chrome/common:resources",
"//chrome/renderer:resources",
"//components/resources:components_resources",
"//components/resources:dev_ui_components_resources",
"//content/browser/devtools:devtools_resources",
"//content/browser/tracing:resources",
"//content/browser/webrtc/resources",
"//content:content_resources",
"//content:dev_ui_content_resources",
"//extensions:extensions_browser_resources",
"//extensions:extensions_renderer_resources",
"//extensions:extensions_resources_grd",
"//mojo/public/js:resources",
"//net:net_resources",
"//third_party/blink/public:resources",
"//ui/resources:ui_resources_grd",
"//ui/resources:webui_generated_resources_grd",
"//ui/resources:webui_resources_grd",
]
if (toolkit_views) {
inputs += [ "$root_gen_dir/ui/views/resources/grit/views_resources.h" ]
deps += [ "//ui/views/resources:resources_grd" ]
}
}
# Generate cef_pack_strings.h.
@@ -1425,23 +1552,6 @@ make_pack_header("strings") {
"$root_gen_dir/third_party/blink/public/strings/grit/blink_strings.h",
"$root_gen_dir/ui/strings/grit/ui_strings.h",
]
deps = [
":cef_strings",
"//chrome/app:chromium_strings",
"//chrome/app:generated_resources",
"//chrome/app/resources:locale_settings",
"//chrome/app/resources:platform_locale_settings",
"//components/omnibox/resources:omnibox_resources",
"//components/strings:components_chromium_strings",
"//components/strings:components_locale_settings",
"//components/strings:components_strings",
"//extensions/strings",
"//services/strings",
"//third_party/blink/public/strings",
"//ui/strings:app_locale_settings",
"//ui/strings:ui_strings",
]
}
# Generate cef_api_hash.h.
@@ -1491,9 +1601,37 @@ if (is_mac) {
]
}
bundle_data("cef_framework_resources") {
bundle_data("cef_framework_locales") {
sources = []
public_deps = []
foreach(locale, locales_as_mac_outputs) {
sources += [ "$root_gen_dir/repack/locales/$locale.pak" ]
}
public_deps = [
":repack_locales_pack",
]
outputs = [
"{{bundle_resources_dir}}/{{source_name_part}}.lproj/locale.pak",
]
}
bundle_data("cef_framework_resources") {
sources = [
"$root_out_dir/cef.pak",
"$root_out_dir/cef_100_percent.pak",
"$root_out_dir/cef_200_percent.pak",
"$root_out_dir/cef_extensions.pak",
"$root_out_dir/devtools_resources.pak",
]
public_deps = [
":pak",
":pak_100_percent",
":pak_200_percent",
":pak_devtools",
":pak_extensions",
]
if (icu_use_data_file) {
sources += [ "$root_out_dir/icudtl.dat" ]
@@ -1584,6 +1722,7 @@ if (is_mac) {
deps = [
":cef_framework_angle_library",
":cef_framework_locales",
":cef_framework_resources",
":cef_framework_swiftshader_library",
":libcef_static",
@@ -1654,29 +1793,6 @@ if (is_mac) {
# Executable/app targets.
#
# Source files for TeamCity GTest integration.
# See tests/gtest/teamcity/README.cef for details.
source_set("gtest_teamcity") {
testonly = true
sources = [
"tests/gtest/teamcity/include/teamcity_gtest.h",
"tests/gtest/teamcity/src/teamcity_gtest.cpp",
"tests/gtest/teamcity/src/teamcity_gtest.h",
"tests/gtest/teamcity/src/teamcity_messages.cpp",
"tests/gtest/teamcity/src/teamcity_messages.h",
]
deps = [
"//testing/gtest",
]
configs += [
"libcef/features:config",
"//build/config:precompiled_headers",
]
}
if (is_mac) {
# Helper for generating the CEF app bundle.
template("cef_app") {
@@ -1796,9 +1912,7 @@ if (is_mac) {
sources = invoker.sources
public_deps = [ ":libcef_dll_wrapper" ]
deps = [
":cef_make_headers",
":libcef_dll_wrapper",
":${app_name}_framework_bundle_data",
]
@@ -2004,7 +2118,6 @@ if (is_mac) {
gypi_paths2.shared_sources_mac_helper +
gypi_paths2.ceftests_sources_mac_helper
helper_deps = [
":gtest_teamcity",
"//testing/gtest",
]
helper_defines = [
@@ -2025,7 +2138,6 @@ if (is_mac) {
":ceftests_resources_bundle_data",
":ceftests_resources_bundle_data_english",
":ceftests_xibs",
":gtest_teamcity",
"//testing/gtest",
]
frameworks = [
@@ -2054,12 +2166,18 @@ if (is_mac) {
pkg_config("gtk") {
packages = [
"gmodule-2.0",
"gtk+-3.0",
"gtk+-2.0",
"gthread-2.0",
"gtk+-unix-print-3.0",
"gtk+-unix-print-2.0",
"xi",
]
}
pkg_config("gtkglext") {
packages = [
"gtkglext-1.0",
]
}
}
if (is_linux) {
@@ -2140,13 +2258,13 @@ if (is_mac) {
]
libs = [
"GL",
"X11",
]
if (cef_use_gtk) {
configs += [
":gtk",
":gtkglext",
]
}
@@ -2239,12 +2357,12 @@ if (is_mac) {
gypi_paths2.shared_sources_browser +
gypi_paths2.shared_sources_common +
gypi_paths2.shared_sources_renderer +
gypi_paths2.ceftests_sources_common
gypi_paths2.ceftests_sources_common +
gypi_paths2.ceftests_sources_views
deps = [
":libcef",
":libcef_dll_wrapper",
":gtest_teamcity",
"//testing/gtest",
]

View File

@@ -7,6 +7,6 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/92.0.4515.159',
'depot_tools_checkout': '58542b7fef'
'chromium_checkout': 'refs/tags/88.0.4324.182',
'depot_tools_checkout': '55e9ddf219'
}

View File

@@ -44,7 +44,8 @@
# work but may not have been tested.
# Required packages include:
# build-essential
# libgtk3.0-dev (required by the cefclient target only)
# libgtk2.0-dev (required by the cefclient target only)
# libgtkglext1-dev (required by the cefclient target only)
#
# - MacOS requirements:
# Xcode 8 or newer building on MacOS 10.11 (El Capitan) or newer for x86_64.

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=d723a9f6637cec523b158a6750d3a64698b407c3$
# $hash=f1877c7a493342351e284cb6c14e6f223461facb$
#
{
@@ -40,7 +40,6 @@
'include/cef_find_handler.h',
'include/cef_focus_handler.h',
'include/cef_frame.h',
'include/cef_frame_handler.h',
'include/cef_image.h',
'include/cef_jsdialog_handler.h',
'include/cef_keyboard_handler.h',
@@ -138,7 +137,6 @@
'include/capi/cef_find_handler_capi.h',
'include/capi/cef_focus_handler_capi.h',
'include/capi/cef_frame_capi.h',
'include/capi/cef_frame_handler_capi.h',
'include/capi/cef_image_capi.h',
'include/capi/cef_jsdialog_handler_capi.h',
'include/capi/cef_keyboard_handler_capi.h',
@@ -302,8 +300,6 @@
'libcef_dll/ctocpp/focus_handler_ctocpp.h',
'libcef_dll/cpptoc/frame_cpptoc.cc',
'libcef_dll/cpptoc/frame_cpptoc.h',
'libcef_dll/ctocpp/frame_handler_ctocpp.cc',
'libcef_dll/ctocpp/frame_handler_ctocpp.h',
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.cc',
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h',
'libcef_dll/cpptoc/image_cpptoc.cc',
@@ -614,8 +610,6 @@
'libcef_dll/cpptoc/focus_handler_cpptoc.h',
'libcef_dll/ctocpp/frame_ctocpp.cc',
'libcef_dll/ctocpp/frame_ctocpp.h',
'libcef_dll/cpptoc/frame_handler_cpptoc.cc',
'libcef_dll/cpptoc/frame_handler_cpptoc.h',
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.cc',
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h',
'libcef_dll/ctocpp/image_ctocpp.cc',

View File

@@ -22,6 +22,7 @@
'include/base/cef_platform_thread.h',
'include/base/cef_ref_counted.h',
'include/base/cef_scoped_ptr.h',
'include/base/cef_string16.h',
'include/base/cef_template_util.h',
'include/base/cef_thread_checker.h',
'include/base/cef_trace_event.h',
@@ -127,6 +128,7 @@
'libcef_dll/base/cef_lock_impl.cc',
'libcef_dll/base/cef_logging.cc',
'libcef_dll/base/cef_ref_counted.cc',
'libcef_dll/base/cef_string16.cc',
'libcef_dll/base/cef_thread_checker_impl.cc',
'libcef_dll/base/cef_weak_ptr.cc',
],
@@ -258,8 +260,6 @@
'tests/cefclient/browser/root_window_create.cc',
'tests/cefclient/browser/root_window_manager.cc',
'tests/cefclient/browser/root_window_manager.h',
'tests/cefclient/browser/root_window_views.cc',
'tests/cefclient/browser/root_window_views.h',
'tests/cefclient/browser/scheme_test.cc',
'tests/cefclient/browser/scheme_test.h',
'tests/cefclient/browser/server_test.cc',
@@ -269,18 +269,10 @@
'tests/cefclient/browser/test_runner.h',
'tests/cefclient/browser/urlrequest_test.cc',
'tests/cefclient/browser/urlrequest_test.h',
'tests/cefclient/browser/views_menu_bar.cc',
'tests/cefclient/browser/views_menu_bar.h',
'tests/cefclient/browser/views_style.cc',
'tests/cefclient/browser/views_style.h',
'tests/cefclient/browser/views_window.cc',
'tests/cefclient/browser/views_window.h',
'tests/cefclient/browser/window_test.cc',
'tests/cefclient/browser/window_test.h',
'tests/cefclient/browser/window_test_runner.cc',
'tests/cefclient/browser/window_test_runner.h',
'tests/cefclient/browser/window_test_runner_views.cc',
'tests/cefclient/browser/window_test_runner_views.h',
],
'cefclient_sources_common': [
'tests/cefclient/common/client_app_delegates_common.cc',
@@ -353,10 +345,20 @@
'tests/cefclient/browser/osr_window_win.cc',
'tests/cefclient/browser/osr_window_win.h',
'tests/cefclient/browser/resource_util_win_idmap.cc',
'tests/cefclient/browser/root_window_views.cc',
'tests/cefclient/browser/root_window_views.h',
'tests/cefclient/browser/root_window_win.cc',
'tests/cefclient/browser/root_window_win.h',
'tests/cefclient/browser/temp_window_win.cc',
'tests/cefclient/browser/temp_window_win.h',
'tests/cefclient/browser/views_menu_bar.cc',
'tests/cefclient/browser/views_menu_bar.h',
'tests/cefclient/browser/views_style.cc',
'tests/cefclient/browser/views_style.h',
'tests/cefclient/browser/views_window.cc',
'tests/cefclient/browser/views_window.h',
'tests/cefclient/browser/window_test_runner_views.cc',
'tests/cefclient/browser/window_test_runner_views.h',
'tests/cefclient/browser/window_test_runner_win.cc',
'tests/cefclient/browser/window_test_runner_win.h',
'tests/cefclient/cefclient_win.cc',
@@ -409,12 +411,22 @@
'tests/cefclient/browser/resource_util_linux.cc',
'tests/cefclient/browser/root_window_gtk.cc',
'tests/cefclient/browser/root_window_gtk.h',
'tests/cefclient/browser/root_window_views.cc',
'tests/cefclient/browser/root_window_views.h',
'tests/cefclient/browser/temp_window_x11.cc',
'tests/cefclient/browser/temp_window_x11.h',
'tests/cefclient/browser/util_gtk.cc',
'tests/cefclient/browser/util_gtk.h',
'tests/cefclient/browser/views_menu_bar.cc',
'tests/cefclient/browser/views_menu_bar.h',
'tests/cefclient/browser/views_style.cc',
'tests/cefclient/browser/views_style.h',
'tests/cefclient/browser/views_window.cc',
'tests/cefclient/browser/views_window.h',
'tests/cefclient/browser/window_test_runner_gtk.cc',
'tests/cefclient/browser/window_test_runner_gtk.h',
'tests/cefclient/browser/window_test_runner_views.cc',
'tests/cefclient/browser/window_test_runner_views.h',
'tests/cefclient/cefclient_gtk.cc',
],
'cefsimple_sources_common': [
@@ -471,7 +483,6 @@
'tests/ceftests/extensions/extension_test_handler.h',
'tests/ceftests/extensions/view_unittest.cc',
'tests/ceftests/file_util_unittest.cc',
'tests/ceftests/frame_handler_unittest.cc',
'tests/ceftests/frame_unittest.cc',
'tests/ceftests/image_unittest.cc',
'tests/ceftests/image_util.cc',
@@ -527,6 +538,12 @@
'tests/ceftests/v8_unittest.cc',
'tests/ceftests/values_unittest.cc',
'tests/ceftests/version_unittest.cc',
'tests/ceftests/waitable_event_unittest.cc',
'tests/ceftests/webui_unittest.cc',
'tests/ceftests/xml_reader_unittest.cc',
'tests/ceftests/zip_reader_unittest.cc',
],
'ceftests_sources_views': [
'tests/ceftests/views/button_unittest.cc',
'tests/ceftests/views/panel_unittest.cc',
'tests/ceftests/views/scroll_view_unittest.cc',
@@ -534,10 +551,6 @@
'tests/ceftests/views/test_window_delegate.h',
'tests/ceftests/views/textfield_unittest.cc',
'tests/ceftests/views/window_unittest.cc',
'tests/ceftests/waitable_event_unittest.cc',
'tests/ceftests/webui_unittest.cc',
'tests/ceftests/xml_reader_unittest.cc',
'tests/ceftests/zip_reader_unittest.cc',
],
'ceftests_sources_win': [
'tests/ceftests/resource_util_win_idmap.cc',
@@ -562,7 +575,6 @@
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/client_app_delegates.cc',
'tests/ceftests/cookie_unittest.cc',
'tests/ceftests/cors_unittest.cc',
'tests/ceftests/dom_unittest.cc',
'tests/ceftests/frame_unittest.cc',
'tests/ceftests/message_router_unittest.cc',

136
cef_repack_locales.gni Normal file
View File

@@ -0,0 +1,136 @@
# Copyright 2016 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.
#
# This is a copy of src/chrome/chrome_repack_locales.gni with the necessary
# modifications to meet CEF's requirements.
import("//build/config/chrome_build.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//tools/grit/repack.gni")
# Arguments:
#
# locale
# Internal name of locale. e.g. "pt-BR"
#
# output
# Output file name.
#
# visibility
# Normal meaning.
template("_repack_one_locale") {
locale = invoker.locale
repack(target_name) {
visibility = invoker.visibility
# Each input pak file should also have a deps line for completeness.
# Add associated .h files in the make_pack_header("strings") target.
sources = [
"${root_gen_dir}/cef/cef_strings_${locale}.pak",
"${root_gen_dir}/chrome/chromium_strings_${locale}.pak",
"${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/omnibox/resources/omnibox_resources_${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",
"${root_gen_dir}/services/strings/services_strings_${locale}.pak",
"${root_gen_dir}/third_party/blink/public/strings/blink_strings_${locale}.pak",
"${root_gen_dir}/ui/strings/app_locale_settings_${locale}.pak",
"${root_gen_dir}/ui/strings/ui_strings_${locale}.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 = [
":cef_strings",
"//chrome/app:chromium_strings",
"//chrome/app:generated_resources",
"//chrome/app/resources:locale_settings",
"//chrome/app/resources:platform_locale_settings",
"//components/omnibox/resources:omnibox_resources",
"//components/strings:components_chromium_strings",
"//components/strings:components_locale_settings",
"//components/strings:components_strings",
"//extensions/strings",
"//services/strings",
"//third_party/blink/public/strings",
"//ui/strings:app_locale_settings",
"//ui/strings:ui_strings",
]
output = invoker.output
}
}
# Creates an action to call the repack_locales script.
#
# The GYP version generates the locales in the "gen" directory and then copies
# it to the root build directory. This isn't easy to express in a GN copy
# rule since the files on Mac have a complex structure. So we generate the
# files into the final place and skip the "gen" directory.
#
# This template uses GN's looping constructs to avoid the complex call to
# chrome/tools/build/repack_locales.py which wraps the repack commands in the
# GYP build.
#
# Arguments
#
# input_locales
# List of locale names to use as inputs.
#
# output_locales
# A list containing the corresponding output names for each of the
# input names. Mac uses different names in some cases.
#
# visibility
template("cef_repack_locales") {
# This is the name of the group below that will collect all the invidual
# locale targets. External targets will depend on this.
group_target_name = target_name
# GN's subscript is too stupid to do invoker.output_locales[foo] so we need
# to make a copy and do output_locales[foo].
output_locales = invoker.output_locales
# Collects all targets the loop generates.
locale_targets = []
# This loop iterates over the input locales and also keeps a counter so it
# can simultaneously iterate over the output locales (using GN's very
# limited looping capabilities).
current_index = 0
foreach(input_locale, invoker.input_locales) {
output_locale = output_locales[current_index]
# Compute the name of the target for the current file. Save it for the deps.
current_name = "${target_name}_${input_locale}"
locale_targets += [ ":$current_name" ]
_repack_one_locale(current_name) {
visibility = [ ":$group_target_name" ]
locale = input_locale
# Compute the output name. Mac uses a different location.
if (is_mac || is_ios) {
output = "${root_gen_dir}/repack/locales/${output_locale}.pak"
} else {
output = "${root_out_dir}/locales/${output_locale}.pak"
}
}
current_index = current_index + 1
}
# The group that external targets depend on which collects all deps.
group(group_target_name) {
forward_variables_from(invoker, [ "visibility" ])
public_deps = locale_targets
}
}

View File

@@ -95,7 +95,6 @@ if(OS_LINUX)
-Wno-unused-parameter # Don't warn about unused parameters
-Wno-error=comment # Don't warn about code in comments
-Wno-comment # Don't warn about code in comments
-Wno-deprecated-declarations # Don't warn about using deprecated methods
)
list(APPEND CEF_C_COMPILER_FLAGS
-std=c99 # Use the C99 language standard
@@ -229,9 +228,11 @@ if(OS_LINUX)
# List of CEF resource files.
set(CEF_RESOURCE_FILES
chrome_100_percent.pak
chrome_200_percent.pak
resources.pak
cef.pak
cef_100_percent.pak
cef_200_percent.pak
cef_extensions.pak
devtools_resources.pak
icudtl.dat
locales
)
@@ -479,9 +480,11 @@ if(OS_WINDOWS)
# List of CEF resource files.
set(CEF_RESOURCE_FILES
chrome_100_percent.pak
chrome_200_percent.pak
resources.pak
cef.pak
cef_100_percent.pak
cef_200_percent.pak
cef_extensions.pak
devtools_resources.pak
icudtl.dat
locales
)
@@ -491,9 +494,6 @@ if(OS_WINDOWS)
PSAPI_VERSION=1 # Required by cef_sandbox.lib
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
)
list(APPEND CEF_COMPILER_DEFINES_DEBUG
_HAS_ITERATOR_DEBUGGING=0 # Disable iterator debugging
)
# Libraries required by cef_sandbox.lib.
set(CEF_SANDBOX_STANDARD_LIBS

View File

@@ -75,6 +75,7 @@ typedef unsigned short uint16;
#endif
// UTF-16 character type.
// This should be kept synchronized with base/strings/string16.h
#ifndef char16
#if defined(WCHAR_T_IS_UTF16)
typedef wchar_t char16;

223
include/base/cef_string16.h Normal file
View File

@@ -0,0 +1,223 @@
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2013
// Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_BASE_CEF_STRING16_H_
#define CEF_INCLUDE_BASE_CEF_STRING16_H_
#pragma once
#if defined(BASE_STRINGS_STRING16_H_)
// Do nothing if the Chromium header has already been included.
// This can happen in cases where Chromium code is used directly by the
// client application. When using Chromium code directly always include
// the Chromium header first to avoid type conflicts.
#elif defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "base/strings/string16.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.
// WHAT:
// A version of std::basic_string that provides 2-byte characters even when
// wchar_t is not implemented as a 2-byte type. You can access this class as
// string16. We also define char16, which string16 is based upon.
//
// WHY:
// On Windows, wchar_t is 2 bytes, and it can conveniently handle UTF-16/UCS-2
// data. Plenty of existing code operates on strings encoded as UTF-16.
//
// On many other platforms, sizeof(wchar_t) is 4 bytes by default. We can make
// it 2 bytes by using the GCC flag -fshort-wchar. But then std::wstring fails
// at run time, because it calls some functions (like wcslen) that come from
// the system's native C library -- which was built with a 4-byte wchar_t!
// It's wasteful to use 4-byte wchar_t strings to carry UTF-16 data, and it's
// entirely improper on those systems where the encoding of wchar_t is defined
// as UTF-32.
//
// Here, we define string16, which is similar to std::wstring but replaces all
// libc functions with custom, 2-byte-char compatible routines. It is capable
// of carrying UTF-16-encoded data.
#include <stdio.h>
#include <string>
#include "include/base/cef_basictypes.h"
#if defined(WCHAR_T_IS_UTF16)
namespace base {
typedef wchar_t char16;
typedef std::wstring string16;
typedef std::char_traits<wchar_t> string16_char_traits;
} // namespace base
#elif defined(WCHAR_T_IS_UTF32)
#include <stdint.h> // For uint16_t
#include "include/base/cef_macros.h"
namespace cef {
namespace base {
typedef uint16_t char16;
// char16 versions of the functions required by string16_char_traits; these
// are based on the wide character functions of similar names ("w" or "wcs"
// instead of "c16").
int c16memcmp(const char16* s1, const char16* s2, size_t n);
size_t c16len(const char16* s);
const char16* c16memchr(const char16* s, char16 c, size_t n);
char16* c16memmove(char16* s1, const char16* s2, size_t n);
char16* c16memcpy(char16* s1, const char16* s2, size_t n);
char16* c16memset(char16* s, char16 c, size_t n);
struct string16_char_traits {
typedef char16 char_type;
typedef int int_type;
// int_type needs to be able to hold each possible value of char_type, and in
// addition, the distinct value of eof().
COMPILE_ASSERT(sizeof(int_type) > sizeof(char_type), unexpected_type_width);
typedef std::streamoff off_type;
typedef mbstate_t state_type;
typedef std::fpos<state_type> pos_type;
static void assign(char_type& c1, const char_type& c2) { c1 = c2; }
static bool eq(const char_type& c1, const char_type& c2) { return c1 == c2; }
static bool lt(const char_type& c1, const char_type& c2) { return c1 < c2; }
static int compare(const char_type* s1, const char_type* s2, size_t n) {
return c16memcmp(s1, s2, n);
}
static size_t length(const char_type* s) { return c16len(s); }
static const char_type* find(const char_type* s,
size_t n,
const char_type& a) {
return c16memchr(s, a, n);
}
static char_type* move(char_type* s1, const char_type* s2, int_type n) {
return c16memmove(s1, s2, n);
}
static char_type* copy(char_type* s1, const char_type* s2, size_t n) {
return c16memcpy(s1, s2, n);
}
static char_type* assign(char_type* s, size_t n, char_type a) {
return c16memset(s, a, n);
}
static int_type not_eof(const int_type& c) {
return eq_int_type(c, eof()) ? 0 : c;
}
static char_type to_char_type(const int_type& c) { return char_type(c); }
static int_type to_int_type(const char_type& c) { return int_type(c); }
static bool eq_int_type(const int_type& c1, const int_type& c2) {
return c1 == c2;
}
static int_type eof() { return static_cast<int_type>(EOF); }
};
typedef std::basic_string<char16, string16_char_traits> string16;
} // namespace base
} // namespace cef
namespace base {
typedef cef::base::char16 char16;
typedef cef::base::string16 string16;
extern std::ostream& operator<<(std::ostream& out, const string16& str);
// This is required by googletest to print a readable output on test failures.
extern void PrintTo(const string16& str, std::ostream* out);
} // namespace base
// The string class will be explicitly instantiated only once, in string16.cc.
//
// std::basic_string<> in GNU libstdc++ contains a static data member,
// _S_empty_rep_storage, to represent empty strings. When an operation such
// as assignment or destruction is performed on a string, causing its existing
// data member to be invalidated, it must not be freed if this static data
// member is being used. Otherwise, it counts as an attempt to free static
// (and not allocated) data, which is a memory error.
//
// Generally, due to C++ template magic, _S_empty_rep_storage will be marked
// as a coalesced symbol, meaning that the linker will combine multiple
// instances into a single one when generating output.
//
// If a string class is used by multiple shared libraries, a problem occurs.
// Each library will get its own copy of _S_empty_rep_storage. When strings
// are passed across a library boundary for alteration or destruction, memory
// errors will result. GNU libstdc++ contains a configuration option,
// --enable-fully-dynamic-string (_GLIBCXX_FULLY_DYNAMIC_STRING), which
// disables the static data member optimization, but it's a good optimization
// and non-STL code is generally at the mercy of the system's STL
// configuration. Fully-dynamic strings are not the default for GNU libstdc++
// libstdc++ itself or for the libstdc++ installations on the systems we care
// about, such as Mac OS X and relevant flavors of Linux.
//
// See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196 .
//
// To avoid problems, string classes need to be explicitly instantiated only
// once, in exactly one library. All other string users see it via an "extern"
// declaration. This is precisely how GNU libstdc++ handles
// std::basic_string<char> (string) and std::basic_string<wchar_t> (wstring).
//
// This also works around a Mac OS X linker bug in ld64-85.2.1 (Xcode 3.1.2),
// in which the linker does not fully coalesce symbols when dead code
// stripping is enabled. This bug causes the memory errors described above
// to occur even when a std::basic_string<> does not cross shared library
// boundaries, such as in statically-linked executables.
//
// TODO(mark): File this bug with Apple and update this note with a bug number.
extern template class std::basic_string<cef::base::char16,
cef::base::string16_char_traits>;
#endif // WCHAR_T_IS_UTF32
#endif // !USING_CHROMIUM_INCLUDES
#endif // CEF_INCLUDE_BASE_CEF_STRING16_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=6e192c6e8a59c37e98e458578a287dd36b8ed90f$
// $hash=09b6ebd4116e983b4af634f1efa17b326a3fc517$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
@@ -57,10 +57,10 @@ struct _cef_browser_host_t;
struct _cef_client_t;
///
// Structure used to represent a browser. When used in the browser process the
// functions of this structure may be called on any thread unless otherwise
// indicated in the comments. When used in the render process the functions of
// this structure may only be called on the main thread.
// Structure used to represent a browser window. When used in the browser
// process the functions of this structure may be called on any thread unless
// otherwise indicated in the comments. When used in the render process the
// functions of this structure may only be called on the main thread.
///
typedef struct _cef_browser_t {
///
@@ -68,12 +68,6 @@ typedef struct _cef_browser_t {
///
cef_base_ref_counted_t base;
///
// True if this object is currently valid. This will return false (0) after
// cef_life_span_handler_t::OnBeforeClose is called.
///
int(CEF_CALLBACK* is_valid)(struct _cef_browser_t* self);
///
// Returns the browser host object. This function can only be called in the
// browser process.
@@ -135,7 +129,7 @@ typedef struct _cef_browser_t {
struct _cef_browser_t* that);
///
// Returns true (1) if the browser is a popup.
// Returns true (1) if the window is a popup window.
///
int(CEF_CALLBACK* is_popup)(struct _cef_browser_t* self);
@@ -145,19 +139,13 @@ typedef struct _cef_browser_t {
int(CEF_CALLBACK* has_document)(struct _cef_browser_t* self);
///
// Returns the main (top-level) frame for the browser. In the browser process
// this will return a valid object until after
// cef_life_span_handler_t::OnBeforeClose is called. In the renderer process
// this will return NULL if the main frame is hosted in a different renderer
// process (e.g. for cross-origin sub-frames). The main frame object will
// change during cross-origin navigation or re-navigation after renderer
// process termination (due to crashes, etc).
// Returns the main (top-level) frame for the browser window.
///
struct _cef_frame_t*(CEF_CALLBACK* get_main_frame)(
struct _cef_browser_t* self);
///
// Returns the focused frame for the browser.
// Returns the focused frame for the browser window.
///
struct _cef_frame_t*(CEF_CALLBACK* get_focused_frame)(
struct _cef_browser_t* self);
@@ -286,10 +274,10 @@ typedef struct _cef_download_image_callback_t {
} cef_download_image_callback_t;
///
// Structure used to represent the browser process aspects of a browser. The
// functions of this structure can only be called in the browser process. They
// may be called on any thread in that process unless otherwise indicated in the
// comments.
// Structure used to represent the browser process aspects of a browser window.
// The functions of this structure can only be called in the browser process.
// They may be called on any thread in that process unless otherwise indicated
// in the comments.
///
typedef struct _cef_browser_host_t {
///
@@ -318,12 +306,11 @@ typedef struct _cef_browser_host_t {
///
// Helper for closing a browser. Call this function from the top-level window
// close handler (if any). Internally this calls CloseBrowser(false (0)) if
// the close has not yet been initiated. This function returns false (0) while
// the close is pending and true (1) after the close has completed. See
// close_browser() and cef_life_span_handler_t::do_close() documentation for
// additional usage information. This function must be called on the browser
// process UI thread.
// close handler. Internally this calls CloseBrowser(false (0)) if the close
// has not yet been initiated. This function returns false (0) while the close
// is pending and true (1) after the close has completed. See close_browser()
// and cef_life_span_handler_t::do_close() documentation for additional usage
// information. This function must be called on the browser process UI thread.
///
int(CEF_CALLBACK* try_close_browser)(struct _cef_browser_host_t* self);
@@ -333,19 +320,18 @@ typedef struct _cef_browser_host_t {
void(CEF_CALLBACK* set_focus)(struct _cef_browser_host_t* self, int focus);
///
// Retrieve the window handle (if any) for this browser. If this browser is
// wrapped in a cef_browser_view_t this function should be called on the
// browser process UI thread and it will return the handle for the top-level
// native window.
// Retrieve the window handle for this browser. If this browser is wrapped in
// a cef_browser_view_t this function should be called on the browser process
// UI thread and it will return the handle for the top-level native window.
///
cef_window_handle_t(CEF_CALLBACK* get_window_handle)(
struct _cef_browser_host_t* self);
///
// Retrieve the window handle (if any) of the browser that opened this
// browser. Will return NULL for non-popup browsers or if this browser is
// wrapped in a cef_browser_view_t. This function can be used in combination
// with custom handling of modal windows.
// Retrieve the window handle of the browser that opened this browser. Will
// return NULL for non-popup windows or if this browser is wrapped in a
// cef_browser_view_t. This function can be used in combination with custom
// handling of modal windows.
///
cef_window_handle_t(CEF_CALLBACK* get_opener_window_handle)(
struct _cef_browser_host_t* self);
@@ -923,9 +909,9 @@ typedef struct _cef_browser_host_t {
} cef_browser_host_t;
///
// Create a new browser using the window parameters specified by |windowInfo|.
// All values will be copied internally and the actual window (if any) will be
// created on the UI thread. If |request_context| is NULL the global request
// Create a new browser window using the window parameters specified by
// |windowInfo|. All values will be copied internally and the actual window will
// be created on the UI thread. If |request_context| is NULL the global request
// context will be used. This function can be called on any browser process
// thread and will not block. The optional |extra_info| parameter provides an
// opportunity to specify extra information specific to the created browser that
@@ -941,11 +927,11 @@ CEF_EXPORT int cef_browser_host_create_browser(
struct _cef_request_context_t* request_context);
///
// Create a new browser using the window parameters specified by |windowInfo|.
// If |request_context| is NULL the global request context will be used. This
// function can only be called on the browser process UI thread. The optional
// |extra_info| parameter provides an opportunity to specify extra information
// specific to the created browser that will be passed to
// Create a new browser window using the window parameters specified by
// |windowInfo|. If |request_context| is NULL the global request context will be
// used. This function can only be called on the browser process UI thread. The
// optional |extra_info| parameter provides an opportunity to specify extra
// information specific to the created browser that will be passed to
// cef_render_process_handler_t::on_browser_created() in the render process.
///
CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync(

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=ade537f836add7fe0b5fd94ceba26d678abb3e43$
// $hash=f0cd169568e9ea5bcc8bf2aa891691b76c05356d$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
@@ -43,6 +43,7 @@
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_client_capi.h"
#include "include/capi/cef_command_line_capi.h"
#include "include/capi/cef_print_handler_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
@@ -60,6 +61,25 @@ typedef struct _cef_browser_process_handler_t {
///
cef_base_ref_counted_t base;
///
// Called on the browser process UI thread to retrieve the list of schemes
// that should support cookies. If |include_defaults| is true (1) the default
// schemes ("http", "https", "ws" and "wss") will also be supported. Providing
// an NULL |schemes| value and setting |include_defaults| to false (0) will
// disable all loading and saving of cookies.
//
// This state will apply to the cef_cookie_manager_t associated with the
// global cef_request_context_t. It will also be used as the initial state for
// any new cef_request_context_ts created by the client. After creating a new
// cef_request_context_t the cef_cookie_manager_t::SetSupportedSchemes
// function may be called on the associated cef_cookie_manager_t to futher
// override these values.
///
void(CEF_CALLBACK* get_cookieable_schemes)(
struct _cef_browser_process_handler_t* self,
cef_string_list_t schemes,
int* include_defaults);
///
// Called on the browser process UI thread immediately after the CEF context
// has been initialized.
@@ -78,6 +98,13 @@ typedef struct _cef_browser_process_handler_t {
struct _cef_browser_process_handler_t* self,
struct _cef_command_line_t* command_line);
///
// Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform.
///
struct _cef_print_handler_t*(CEF_CALLBACK* get_print_handler)(
struct _cef_browser_process_handler_t* self);
///
// Called from any thread when work has been scheduled for the browser process
// main (UI) thread. This callback is used in combination with CefSettings.

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=845a1d1dda63a06f4ae33ed39acfd2599b46a885$
// $hash=4cfcac55d2a1dee466a2a0753f30fb34a78ef3b2$
//
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
@@ -49,12 +49,10 @@
#include "include/capi/cef_drag_handler_capi.h"
#include "include/capi/cef_find_handler_capi.h"
#include "include/capi/cef_focus_handler_capi.h"
#include "include/capi/cef_frame_handler_capi.h"
#include "include/capi/cef_jsdialog_handler_capi.h"
#include "include/capi/cef_keyboard_handler_capi.h"
#include "include/capi/cef_life_span_handler_capi.h"
#include "include/capi/cef_load_handler_capi.h"
#include "include/capi/cef_print_handler_capi.h"
#include "include/capi/cef_process_message_capi.h"
#include "include/capi/cef_render_handler_capi.h"
#include "include/capi/cef_request_handler_capi.h"
@@ -123,14 +121,6 @@ typedef struct _cef_client_t {
struct _cef_focus_handler_t*(CEF_CALLBACK* get_focus_handler)(
struct _cef_client_t* self);
///
// Return the handler for events related to cef_frame_t lifespan. This
// function will be called once during cef_browser_t creation and the result
// will be cached for performance reasons.
///
struct _cef_frame_handler_t*(CEF_CALLBACK* get_frame_handler)(
struct _cef_client_t* self);
///
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.
@@ -156,13 +146,6 @@ typedef struct _cef_client_t {
struct _cef_load_handler_t*(CEF_CALLBACK* get_load_handler)(
struct _cef_client_t* self);
///
// Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform.
///
struct _cef_print_handler_t*(CEF_CALLBACK* get_print_handler)(
struct _cef_client_t* self);
///
// Return the handler for off-screen rendering events.
///
@@ -177,8 +160,8 @@ typedef struct _cef_client_t {
///
// Called when a new message is received from a different process. Return true
// (1) if the message was handled or false (0) otherwise. It is safe to keep
// a reference to |message| outside of this callback.
// (1) if the message was handled or false (0) otherwise. Do not keep a
// reference to or attempt to access the message outside of this callback.
///
int(CEF_CALLBACK* on_process_message_received)(
struct _cef_client_t* self,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=175779df75a1405fcc5c337a09e6322c556698ba$
// $hash=bd04d49bcd5d269f237c92163b40435d5588209b$
//
#ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
@@ -294,6 +294,11 @@ typedef struct _cef_context_menu_params_t {
// items).
///
int(CEF_CALLBACK* is_custom_menu)(struct _cef_context_menu_params_t* self);
///
// Returns true (1) if the context menu was invoked from a pepper plugin.
///
int(CEF_CALLBACK* is_pepper_menu)(struct _cef_context_menu_params_t* self);
} cef_context_menu_params_t;
#ifdef __cplusplus

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=b19ef1c8a781f8d59276357609fe64370bb8a107$
// $hash=20ba58ac3e861344ee738b58433869223c757e24$
//
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
@@ -61,6 +61,21 @@ typedef struct _cef_cookie_manager_t {
///
cef_base_ref_counted_t base;
///
// Set the schemes supported by this manager. If |include_defaults| is true
// (1) the default schemes ("http", "https", "ws" and "wss") will also be
// supported. Calling this function with an NULL |schemes| value and
// |include_defaults| set to false (0) will disable all loading and saving of
// cookies for this manager. If |callback| is non-NULL it will be executed
// asnychronously on the UI thread after the change has been applied. Must be
// called before any cookies are accessed.
///
void(CEF_CALLBACK* set_supported_schemes)(
struct _cef_cookie_manager_t* self,
cef_string_list_t schemes,
int include_defaults,
struct _cef_completion_callback_t* callback);
///
// Visit all cookies on the UI thread. The returned cookies are ordered by
// longest path, then by earliest creation date. Returns false (0) if cookies

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=872fd1e811d41f56f03da0da75a8f2e89cad40cd$
// $hash=bce865a34f45e6dee8f413f0d6bd7f4c37ab55c0$
//
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
@@ -242,12 +242,10 @@ typedef struct _cef_frame_t {
struct _cef_urlrequest_client_t* client);
///
// Send a message to the specified |target_process|. Ownership of the message
// contents will be transferred and the |message| reference will be
// invalidated. Message delivery is not guaranteed in all cases (for example,
// if the browser is closing, navigating, or if the target process crashes).
// Send an ACK message back from the target process if confirmation is
// required.
// Send a message to the specified |target_process|. Message delivery is not
// guaranteed in all cases (for example, if the browser is closing,
// navigating, or if the target process crashes). Send an ACK message back
// from the target process if confirmation is required.
///
void(CEF_CALLBACK* send_process_message)(
struct _cef_frame_t* self,

View File

@@ -1,191 +0,0 @@
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=503984bf98aa52ff67ce52f26a560bbb1d4439bc$
//
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#include "include/capi/cef_frame_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Implement this structure to handle events related to cef_frame_t life span.
// The order of callbacks is:
//
// (1) During initial cef_browser_host_t creation and navigation of the main
// frame: - cef_frame_handler_t::OnFrameCreated => The initial main frame object
// has been
// created. Any commands will be queued until the frame is attached.
// - cef_frame_handler_t::OnMainFrameChanged => The initial main frame object
// has
// been assigned to the browser.
// - cef_life_span_handler_t::OnAfterCreated => The browser is now valid and can
// be
// used.
// - cef_frame_handler_t::OnFrameAttached => The initial main frame object is
// now
// connected to its peer in the renderer process. Commands can be routed.
//
// (2) During further cef_browser_host_t navigation/loading of the main frame
// and/or sub-frames: - cef_frame_handler_t::OnFrameCreated => A new main frame
// or sub-frame object has
// been created. Any commands will be queued until the frame is attached.
// - cef_frame_handler_t::OnFrameAttached => A new main frame or sub-frame
// object is
// now connected to its peer in the renderer process. Commands can be routed.
// - cef_frame_handler_t::OnFrameDetached => An existing main frame or sub-frame
// object has lost its connection to the renderer process. If multiple objects
// are detached at the same time then notifications will be sent for any
// sub-frame objects before the main frame object. Commands can no longer be
// routed and will be discarded.
// - cef_frame_handler_t::OnMainFrameChanged => A new main frame object has been
// assigned to the browser. This will only occur with cross-origin navigation
// or re-navigation after renderer process termination (due to crashes, etc).
//
// (3) During final cef_browser_host_t destruction of the main frame: -
// cef_frame_handler_t::OnFrameDetached => Any sub-frame objects have lost their
// connection to the renderer process. Commands can no longer be routed and
// will be discarded.
// - cef_life_span_handler_t::OnBeforeClose => The browser has been destroyed. -
// cef_frame_handler_t::OnFrameDetached => The main frame object have lost its
// connection to the renderer process. Notifications will be sent for any
// sub-frame objects before the main frame object. Commands can no longer be
// routed and will be discarded.
// - cef_frame_handler_t::OnMainFrameChanged => The final main frame object has
// been
// removed from the browser.
//
// Cross-origin navigation and/or loading receives special handling.
//
// When the main frame navigates to a different origin the OnMainFrameChanged
// callback (2) will be executed with the old and new main frame objects.
//
// When a new sub-frame is loaded in, or an existing sub-frame is navigated to,
// a different origin from the parent frame, a temporary sub-frame object will
// first be created in the parent's renderer process. That temporary sub-frame
// will then be discarded after the real cross-origin sub-frame is created in
// the new/target renderer process. The client will receive cross-origin
// navigation callbacks (2) for the transition from the temporary sub-frame to
// the real sub-frame. The temporary sub-frame will not recieve or execute
// commands during this transitional period (any sent commands will be
// discarded).
//
// When a new popup browser is created in a different origin from the parent
// browser, a temporary main frame object for the popup will first be created in
// the parent's renderer process. That temporary main frame will then be
// discarded after the real cross-origin main frame is created in the new/target
// renderer process. The client will recieve creation and initial navigation
// callbacks (1) for the temporary main frame, followed by cross-origin
// navigation callbacks (2) for the transition from the temporary main frame to
// the real main frame. The temporary main frame may receive and execute
// commands during this transitional period (any sent commands may be executed,
// but the behavior is potentially undesirable since they execute in the parent
// browser's renderer process and not the new/target renderer process).
//
// Callbacks will not be executed for placeholders that may be created during
// pre-commit navigation for sub-frames that do not yet exist in the renderer
// process. Placeholders will have cef_frame_t::get_identifier() == -4.
//
// The functions of this structure will be called on the UI thread unless
// otherwise indicated.
///
typedef struct _cef_frame_handler_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called when a new frame is created. This will be the first notification
// that references |frame|. Any commands that require transport to the
// associated renderer process (LoadRequest, SendProcessMessage, GetSource,
// etc.) will be queued until OnFrameAttached is called for |frame|.
///
void(CEF_CALLBACK* on_frame_created)(struct _cef_frame_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame);
///
// Called when a frame can begin routing commands to/from the associated
// renderer process. Any commands that were queued have now been dispatched.
///
void(CEF_CALLBACK* on_frame_attached)(struct _cef_frame_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame);
///
// Called when a frame loses its connection to the renderer process and will
// be destroyed. Any pending or future commands will be discarded and
// cef_frame_t::is_valid() will now return false (0) for |frame|. If called
// after cef_life_span_handler_t::on_before_close() during browser destruction
// then cef_browser_t::is_valid() will return false (0) for |browser|.
///
void(CEF_CALLBACK* on_frame_detached)(struct _cef_frame_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame);
///
// Called when the main frame changes due to (a) initial browser creation, (b)
// final browser destruction, (c) cross-origin navigation or (d) re-navigation
// after renderer process termination (due to crashes, etc). |old_frame| will
// be NULL and |new_frame| will be non-NULL when a main frame is assigned to
// |browser| for the first time. |old_frame| will be non-NULL and |new_frame|
// will be NULL and when a main frame is removed from |browser| for the last
// time. Both |old_frame| and |new_frame| will be non-NULL for cross-origin
// navigations or re-navigation after renderer process termination. This
// function will be called after on_frame_created() for |new_frame| and/or
// after on_frame_detached() for |old_frame|. If called after
// cef_life_span_handler_t::on_before_close() during browser destruction then
// cef_browser_t::is_valid() will return false (0) for |browser|.
///
void(CEF_CALLBACK* on_main_frame_changed)(struct _cef_frame_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* old_frame,
struct _cef_frame_t* new_frame);
} cef_frame_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=e44bb89a337942c82bfa246275b4b033821b2782$
// $hash=d7521ac4f73dabd876344400a165d15954c770b0$
//
#ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
@@ -101,10 +101,8 @@ typedef struct _cef_life_span_handler_t {
int* no_javascript_access);
///
// Called after a new browser is created. It is now safe to begin performing
// actions with |browser|. cef_frame_handler_t callbacks related to initial
// main frame creation will arrive before this callback. See
// cef_frame_handler_t documentation for additional usage information.
// Called after a new browser is created. This callback will be the first
// notification that references |browser|.
///
void(CEF_CALLBACK* on_after_created)(struct _cef_life_span_handler_t* self,
struct _cef_browser_t* browser);
@@ -204,14 +202,13 @@ typedef struct _cef_life_span_handler_t {
///
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any functions on the browser
// object (other than IsValid, GetIdentifier or IsSame) after this callback
// returns. cef_frame_handler_t callbacks related to final main frame
// destruction will arrive after this callback and cef_browser_t::IsValid will
// return false (0) at that time. Any in-progress network requests associated
// with |browser| will be aborted when the browser is destroyed, and
// object (other than GetIdentifier or IsSame) after this callback returns.
// This callback will be the last notification that references |browser| on
// the UI thread. Any in-progress network requests associated with |browser|
// will be aborted when the browser is destroyed, and
// cef_resource_request_handler_t callbacks related to those requests may
// still arrive on the IO thread after this callback. See cef_frame_handler_t
// and do_close() documentation for additional usage information.
// still arrive on the IO thread after this function is called. See do_close()
// documentation for additional usage information.
///
void(CEF_CALLBACK* on_before_close)(struct _cef_life_span_handler_t* self,
struct _cef_browser_t* browser);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=79e4e38c732c0cfeef495c8a9726e105054012bb$
// $hash=3767c7759578cd4abc1c2ecef504e7ed60775abb$
//
#ifndef CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
@@ -41,7 +41,6 @@
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_callback_capi.h"
#include "include/capi/cef_registration_capi.h"
#ifdef __cplusplus
@@ -111,14 +110,11 @@ typedef struct _cef_media_router_t {
} cef_media_router_t;
///
// Returns the MediaRouter object associated with the global request context. If
// |callback| is non-NULL it will be executed asnychronously on the UI thread
// after the manager's storage has been initialized. Equivalent to calling cef_r
// equest_context_t::cef_request_context_get_global_context()->get_media_router(
// ).
// Returns the MediaRouter object associated with the global request context.
// Equivalent to calling cef_request_context_t::cef_request_context_get_global_c
// ontext()->get_media_router().
///
CEF_EXPORT cef_media_router_t* cef_media_router_get_global(
struct _cef_completion_callback_t* callback);
CEF_EXPORT cef_media_router_t* cef_media_router_get_global();
///
// Implemented by the client to observe MediaRouter events and registered via

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=84fc58b3898f25476d9cdd260553390ba5e0b30b$
// $hash=54ed1e16c5c1d133bcd097350c5f5871228efd4f$
//
#ifndef CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_
@@ -148,7 +148,6 @@ typedef struct _cef_print_handler_t {
///
cef_size_t(CEF_CALLBACK* get_pdf_paper_size)(
struct _cef_print_handler_t* self,
struct _cef_browser_t* browser,
int device_units_per_inch);
} cef_print_handler_t;

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=4ebf99611a11cc8714d710c37417fbd9f50f0618$
// $hash=41339414bca54054046a8f7fbce402a0e0dd8020$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_
@@ -73,7 +73,7 @@ typedef struct _cef_render_process_handler_t {
///
// Called after a browser has been created. When browsing cross-origin a new
// browser will be created before the old browser with the same identifier is
// destroyed. |extra_info| is an optional read-only value originating from
// destroyed. |extra_info| is a read-only value originating from
// cef_browser_host_t::cef_browser_host_create_browser(),
// cef_browser_host_t::cef_browser_host_create_browser_sync(),
// cef_life_span_handler_t::on_before_popup() or
@@ -150,8 +150,8 @@ typedef struct _cef_render_process_handler_t {
///
// Called when a new message is received from a different process. Return true
// (1) if the message was handled or false (0) otherwise. It is safe to keep a
// reference to |message| outside of this callback.
// (1) if the message was handled or false (0) otherwise. Do not keep a
// reference to or attempt to access the message outside of this callback.
///
int(CEF_CALLBACK* on_process_message_received)(
struct _cef_render_process_handler_t* self,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=2e42334fc22050e207e5a0af6fe290a592e4105f$
// $hash=d5079b6a5146ccd2085c3bbf948925c009d329ed$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@@ -132,7 +132,7 @@ typedef struct _cef_request_context_t {
///
// Returns the cookie manager for this object. If |callback| is non-NULL it
// will be executed asnychronously on the UI thread after the manager's
// will be executed asnychronously on the IO thread after the manager's
// storage has been initialized.
///
struct _cef_cookie_manager_t*(CEF_CALLBACK* get_cookie_manager)(
@@ -356,13 +356,10 @@ typedef struct _cef_request_context_t {
const cef_string_t* extension_id);
///
// Returns the MediaRouter object associated with this context. If |callback|
// is non-NULL it will be executed asnychronously on the UI thread after the
// manager's context has been initialized.
// Returns the MediaRouter object associated with this context.
///
struct _cef_media_router_t*(CEF_CALLBACK* get_media_router)(
struct _cef_request_context_t* self,
struct _cef_completion_callback_t* callback);
struct _cef_request_context_t* self);
} cef_request_context_t;
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=f74bf4d33914d56d760f1bf5aadcf2651740c711$
// $hash=d8b5b641cc036a9cd9375442254d558b066ada69$
//
#ifndef CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_
@@ -214,7 +214,7 @@ CEF_EXPORT void cef_is_web_plugin_unstable(
// D. "x-cdm-interface-versions": Interface API version (e.g. "8").
// E. "x-cdm-host-versions": Host API version (e.g. "8").
// F. "version": CDM version (e.g. "1.4.8.903").
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp09,avc1").
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1").
//
// A through E are used to verify compatibility with the current Chromium
// version. If the CDM is not compatible the registration will fail and

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=3e4eb9ed3a0cb28ae0459a50f20c8405c7722437$
// $hash=0fbd582ed5d0231550840ebf3eed2e488ac546d4$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
@@ -65,17 +65,6 @@ typedef struct _cef_browser_view_t {
struct _cef_browser_t*(CEF_CALLBACK* get_browser)(
struct _cef_browser_view_t* self);
///
// Returns the Chrome toolbar associated with this BrowserView. Only supported
// when using the Chrome runtime. The cef_browser_view_delegate_t::
// get_chrome_toolbar_type() function must return a value other than
// CEF_CTT_NONE and the toolbar will not be available until after this
// BrowserView is added to a cef_window_t and
// cef_view_delegate_t::on_window_changed() has been called.
///
struct _cef_view_t*(CEF_CALLBACK* get_chrome_toolbar)(
struct _cef_browser_view_t* self);
///
// Sets whether accelerators registered with cef_window_t::SetAccelerator are
// triggered before or after the event is sent to the cef_browser_t. If

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=220a126af3682f716f10b9019e8d1461702aa7c9$
// $hash=37bbfadf761b3a1996276885d593d27d3fed5f8d$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_
@@ -112,14 +112,6 @@ typedef struct _cef_browser_view_delegate_t {
struct _cef_browser_view_t* browser_view,
struct _cef_browser_view_t* popup_browser_view,
int is_devtools);
///
// Returns the Chrome toolbar type that will be available via
// cef_browser_view_t::get_chrome_toolbar(). See that function for related
// documentation.
///
cef_chrome_toolbar_type_t(CEF_CALLBACK* get_chrome_toolbar_type)(
struct _cef_browser_view_delegate_t* self);
} cef_browser_view_delegate_t;
#ifdef __cplusplus

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=a060cb3c53317d758e7f6b4a275288cd08f086e7$
// $hash=8bd92dd03af4f5cf8c359c45a2d6d013565c2ead$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_
@@ -114,13 +114,6 @@ typedef struct _cef_view_delegate_t {
int added,
struct _cef_view_t* child);
///
// Called when |view| is added or removed from the cef_window_t.
///
void(CEF_CALLBACK* on_window_changed)(struct _cef_view_delegate_t* self,
struct _cef_view_t* view,
int added);
///
// Called when |view| gains focus.
///

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 "7fb6a7510f39c359767b3a893c9ebfb5fb5973d7"
#define CEF_API_HASH_UNIVERSAL "89715b43c948313782d2546131f510eab1975844"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "0a848e5b676ddc931dbb5b174a64eb7be7f7dfbf"
#define CEF_API_HASH_PLATFORM "80648a2c5a87db1581fdb994b7154ed77d74a3c5"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "4c666fab20ab43dddf2f7ac6543197a1fecee389"
#define CEF_API_HASH_PLATFORM "3af393a2bf165edd934c5a59f6e6fce8a4bb579c"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "5f756efd08c6e10629fe1f81e9266c7af71aa5ce"
#define CEF_API_HASH_PLATFORM "8049cab9a43c1d554ccdd4dd3d5e38ecebce42af"
#endif
#ifdef __cplusplus

View File

@@ -52,21 +52,14 @@ class CefBrowserHost;
class CefClient;
///
// Class used to represent a browser. When used in the browser process the
// methods of this class may be called on any thread unless otherwise indicated
// in the comments. When used in the render process the methods of this class
// may only be called on the main thread.
// Class used to represent a browser window. When used in the browser process
// the methods of this class may be called on any thread unless otherwise
// indicated in the comments. When used in the render process the methods of
// this class may only be called on the main thread.
///
/*--cef(source=library)--*/
class CefBrowser : public virtual CefBaseRefCounted {
public:
///
// True if this object is currently valid. This will return false after
// CefLifeSpanHandler::OnBeforeClose is called.
///
/*--cef()--*/
virtual bool IsValid() = 0;
///
// Returns the browser host object. This method can only be called in the
// browser process.
@@ -137,7 +130,7 @@ class CefBrowser : public virtual CefBaseRefCounted {
virtual bool IsSame(CefRefPtr<CefBrowser> that) = 0;
///
// Returns true if the browser is a popup.
// Returns true if the window is a popup window.
///
/*--cef()--*/
virtual bool IsPopup() = 0;
@@ -149,19 +142,13 @@ class CefBrowser : public virtual CefBaseRefCounted {
virtual bool HasDocument() = 0;
///
// Returns the main (top-level) frame for the browser. In the browser process
// this will return a valid object until after
// CefLifeSpanHandler::OnBeforeClose is called. In the renderer process this
// will return NULL if the main frame is hosted in a different renderer
// process (e.g. for cross-origin sub-frames). The main frame object will
// change during cross-origin navigation or re-navigation after renderer
// process termination (due to crashes, etc).
// Returns the main (top-level) frame for the browser window.
///
/*--cef()--*/
virtual CefRefPtr<CefFrame> GetMainFrame() = 0;
///
// Returns the focused frame for the browser.
// Returns the focused frame for the browser window.
///
/*--cef()--*/
virtual CefRefPtr<CefFrame> GetFocusedFrame() = 0;
@@ -274,9 +261,10 @@ class CefDownloadImageCallback : public virtual CefBaseRefCounted {
};
///
// Class used to represent the browser process aspects of a browser. The methods
// of this class can only be called in the browser process. They may be called
// on any thread in that process unless otherwise indicated in the comments.
// Class used to represent the browser process aspects of a browser window. The
// methods of this class can only be called in the browser process. They may be
// called on any thread in that process unless otherwise indicated in the
// comments.
///
/*--cef(source=library)--*/
class CefBrowserHost : public virtual CefBaseRefCounted {
@@ -287,14 +275,14 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
typedef cef_paint_element_type_t PaintElementType;
///
// Create a new browser using the window parameters specified by |windowInfo|.
// All values will be copied internally and the actual window (if any) will be
// created on the UI thread. If |request_context| is empty the global request
// context will be used. This method can be called on any browser process
// thread and will not block. The optional |extra_info| parameter provides an
// opportunity to specify extra information specific to the created browser
// that will be passed to CefRenderProcessHandler::OnBrowserCreated() in the
// render process.
// Create a new browser window using the window parameters specified by
// |windowInfo|. All values will be copied internally and the actual window
// will be created on the UI thread. If |request_context| is empty the
// global request context will be used. This method can be called on any
// browser process thread and will not block. The optional |extra_info|
// parameter provides an opportunity to specify extra information specific
// to the created browser that will be passed to
// CefRenderProcessHandler::OnBrowserCreated() in the render process.
///
/*--cef(optional_param=client,optional_param=url,
optional_param=request_context,optional_param=extra_info)--*/
@@ -306,12 +294,13 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
CefRefPtr<CefRequestContext> request_context);
///
// Create a new browser using the window parameters specified by |windowInfo|.
// If |request_context| is empty the global request context will be used. This
// method can only be called on the browser process UI thread. The optional
// |extra_info| parameter provides an opportunity to specify extra information
// specific to the created browser that will be passed to
// CefRenderProcessHandler::OnBrowserCreated() in the render process.
// Create a new browser window using the window parameters specified by
// |windowInfo|. If |request_context| is empty the global request context
// will be used. This method can only be called on the browser process UI
// thread. The optional |extra_info| parameter provides an opportunity to
// specify extra information specific to the created browser that will be
// passed to CefRenderProcessHandler::OnBrowserCreated() in the render
// process.
///
/*--cef(optional_param=client,optional_param=url,
optional_param=request_context,optional_param=extra_info)--*/
@@ -344,9 +333,9 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
///
// Helper for closing a browser. Call this method from the top-level window
// close handler (if any). Internally this calls CloseBrowser(false) if the
// close has not yet been initiated. This method returns false while the close
// is pending and true after the close has completed. See CloseBrowser() and
// close handler. Internally this calls CloseBrowser(false) if the close has
// not yet been initiated. This method returns false while the close is
// pending and true after the close has completed. See CloseBrowser() and
// CefLifeSpanHandler::DoClose() documentation for additional usage
// information. This method must be called on the browser process UI thread.
///
@@ -360,19 +349,18 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
virtual void SetFocus(bool focus) = 0;
///
// Retrieve the window handle (if any) for this browser. If this browser is
// wrapped in a CefBrowserView this method should be called on the browser
// process UI thread and it will return the handle for the top-level native
// window.
// Retrieve the window handle for this browser. If this browser is wrapped in
// a CefBrowserView this method should be called on the browser process UI
// thread and it will return the handle for the top-level native window.
///
/*--cef()--*/
virtual CefWindowHandle GetWindowHandle() = 0;
///
// Retrieve the window handle (if any) of the browser that opened this
// browser. Will return NULL for non-popup browsers or if this browser is
// wrapped in a CefBrowserView. This method can be used in combination with
// custom handling of modal windows.
// Retrieve the window handle of the browser that opened this browser. Will
// return NULL for non-popup windows or if this browser is wrapped in a
// CefBrowserView. This method can be used in combination with custom handling
// of modal windows.
///
/*--cef()--*/
virtual CefWindowHandle GetOpenerWindowHandle() = 0;

View File

@@ -41,6 +41,7 @@
#include "include/cef_base.h"
#include "include/cef_client.h"
#include "include/cef_command_line.h"
#include "include/cef_print_handler.h"
#include "include/cef_values.h"
///
@@ -50,6 +51,23 @@
/*--cef(source=client,no_debugct_check)--*/
class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
public:
///
// Called on the browser process UI thread to retrieve the list of schemes
// that should support cookies. If |include_defaults| is true the default
// schemes ("http", "https", "ws" and "wss") will also be supported. Providing
// an empty |schemes| value and setting |include_defaults| to false will
// disable all loading and saving of cookies.
//
// This state will apply to the CefCookieManager associated with the global
// CefRequestContext. It will also be used as the initial state for any new
// CefRequestContexts created by the client. After creating a new
// CefRequestContext the CefCookieManager::SetSupportedSchemes method may be
// called on the associated CefCookieManager to futher override these values.
///
/*--cef()--*/
virtual void GetCookieableSchemes(std::vector<CefString>& schemes,
bool& include_defaults) {}
///
// Called on the browser process UI thread immediately after the CEF context
// has been initialized.
@@ -68,6 +86,13 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
virtual void OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line) {}
///
// Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform.
///
/*--cef()--*/
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() { return nullptr; }
///
// Called from any thread when work has been scheduled for the browser process
// main (UI) thread. This callback is used in combination with CefSettings.

View File

@@ -47,12 +47,10 @@
#include "include/cef_drag_handler.h"
#include "include/cef_find_handler.h"
#include "include/cef_focus_handler.h"
#include "include/cef_frame_handler.h"
#include "include/cef_jsdialog_handler.h"
#include "include/cef_keyboard_handler.h"
#include "include/cef_life_span_handler.h"
#include "include/cef_load_handler.h"
#include "include/cef_print_handler.h"
#include "include/cef_process_message.h"
#include "include/cef_render_handler.h"
#include "include/cef_request_handler.h"
@@ -116,14 +114,6 @@ class CefClient : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() { return nullptr; }
///
// Return the handler for events related to CefFrame lifespan. This method
// will be called once during CefBrowser creation and the result will be
// cached for performance reasons.
///
/*--cef()--*/
virtual CefRefPtr<CefFrameHandler> GetFrameHandler() { return nullptr; }
///
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.
@@ -149,13 +139,6 @@ class CefClient : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() { return nullptr; }
///
// Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform.
///
/*--cef()--*/
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() { return nullptr; }
///
// Return the handler for off-screen rendering events.
///
@@ -170,8 +153,8 @@ class CefClient : public virtual CefBaseRefCounted {
///
// Called when a new message is received from a different process. Return true
// if the message was handled or false otherwise. It is safe to keep a
// reference to |message| outside of this callback.
// if the message was handled or false otherwise. Do not keep a reference to
// or attempt to access the message outside of this callback.
///
/*--cef()--*/
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,

View File

@@ -281,6 +281,12 @@ class CefContextMenuParams : public virtual CefBaseRefCounted {
///
/*--cef()--*/
virtual bool IsCustomMenu() = 0;
///
// Returns true if the context menu was invoked from a pepper plugin.
///
/*--cef()--*/
virtual bool IsPepperMenu() = 0;
};
#endif // CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_

View File

@@ -64,6 +64,21 @@ class CefCookieManager : public virtual CefBaseRefCounted {
static CefRefPtr<CefCookieManager> GetGlobalManager(
CefRefPtr<CefCompletionCallback> callback);
///
// Set the schemes supported by this manager. If |include_defaults| is true
// the default schemes ("http", "https", "ws" and "wss") will also be
// supported. Calling this method with an empty |schemes| value and
// |include_defaults| set to false will disable all loading and saving of
// cookies for this manager. If |callback| is non-NULL it will be executed
// asnychronously on the UI thread after the change has been applied. Must be
// called before any cookies are accessed.
///
/*--cef(optional_param=callback)--*/
virtual void SetSupportedSchemes(
const std::vector<CefString>& schemes,
bool include_defaults,
CefRefPtr<CefCompletionCallback> callback) = 0;
///
// Visit all cookies on the UI thread. The returned cookies are ordered by
// longest path, then by earliest creation date. Returns false if cookies

View File

@@ -246,12 +246,10 @@ class CefFrame : public virtual CefBaseRefCounted {
CefRefPtr<CefURLRequestClient> client) = 0;
///
// Send a message to the specified |target_process|. Ownership of the message
// contents will be transferred and the |message| reference will be
// invalidated. Message delivery is not guaranteed in all cases (for example,
// if the browser is closing, navigating, or if the target process crashes).
// Send an ACK message back from the target process if confirmation is
// required.
// Send a message to the specified |target_process|. Message delivery is not
// guaranteed in all cases (for example, if the browser is closing,
// navigating, or if the target process crashes). Send an ACK message back
// from the target process if confirmation is required.
///
/*--cef()--*/
virtual void SendProcessMessage(CefProcessId target_process,

View File

@@ -1,172 +0,0 @@
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_FRAME_HANDLER_H_
#define CEF_INCLUDE_CEF_FRAME_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "include/cef_frame.h"
///
// Implement this interface to handle events related to CefFrame life span. The
// order of callbacks is:
//
// (1) During initial CefBrowserHost creation and navigation of the main frame:
// - CefFrameHandler::OnFrameCreated => The initial main frame object has been
// created. Any commands will be queued until the frame is attached.
// - CefFrameHandler::OnMainFrameChanged => The initial main frame object has
// been assigned to the browser.
// - CefLifeSpanHandler::OnAfterCreated => The browser is now valid and can be
// used.
// - CefFrameHandler::OnFrameAttached => The initial main frame object is now
// connected to its peer in the renderer process. Commands can be routed.
//
// (2) During further CefBrowserHost navigation/loading of the main frame and/or
// sub-frames:
// - CefFrameHandler::OnFrameCreated => A new main frame or sub-frame object has
// been created. Any commands will be queued until the frame is attached.
// - CefFrameHandler::OnFrameAttached => A new main frame or sub-frame object is
// now connected to its peer in the renderer process. Commands can be routed.
// - CefFrameHandler::OnFrameDetached => An existing main frame or sub-frame
// object has lost its connection to the renderer process. If multiple objects
// are detached at the same time then notifications will be sent for any
// sub-frame objects before the main frame object. Commands can no longer be
// routed and will be discarded.
// - CefFrameHandler::OnMainFrameChanged => A new main frame object has been
// assigned to the browser. This will only occur with cross-origin navigation
// or re-navigation after renderer process termination (due to crashes, etc).
//
// (3) During final CefBrowserHost destruction of the main frame:
// - CefFrameHandler::OnFrameDetached => Any sub-frame objects have lost their
// connection to the renderer process. Commands can no longer be routed and
// will be discarded.
// - CefLifeSpanHandler::OnBeforeClose => The browser has been destroyed.
// - CefFrameHandler::OnFrameDetached => The main frame object have lost its
// connection to the renderer process. Notifications will be sent for any
// sub-frame objects before the main frame object. Commands can no longer be
// routed and will be discarded.
// - CefFrameHandler::OnMainFrameChanged => The final main frame object has been
// removed from the browser.
//
// Cross-origin navigation and/or loading receives special handling.
//
// When the main frame navigates to a different origin the OnMainFrameChanged
// callback (2) will be executed with the old and new main frame objects.
//
// When a new sub-frame is loaded in, or an existing sub-frame is navigated to,
// a different origin from the parent frame, a temporary sub-frame object will
// first be created in the parent's renderer process. That temporary sub-frame
// will then be discarded after the real cross-origin sub-frame is created in
// the new/target renderer process. The client will receive cross-origin
// navigation callbacks (2) for the transition from the temporary sub-frame to
// the real sub-frame. The temporary sub-frame will not recieve or execute
// commands during this transitional period (any sent commands will be
// discarded).
//
// When a new popup browser is created in a different origin from the parent
// browser, a temporary main frame object for the popup will first be created in
// the parent's renderer process. That temporary main frame will then be
// discarded after the real cross-origin main frame is created in the new/target
// renderer process. The client will recieve creation and initial navigation
// callbacks (1) for the temporary main frame, followed by cross-origin
// navigation callbacks (2) for the transition from the temporary main frame to
// the real main frame. The temporary main frame may receive and execute
// commands during this transitional period (any sent commands may be executed,
// but the behavior is potentially undesirable since they execute in the parent
// browser's renderer process and not the new/target renderer process).
//
// Callbacks will not be executed for placeholders that may be created during
// pre-commit navigation for sub-frames that do not yet exist in the renderer
// process. Placeholders will have CefFrame::GetIdentifier() == -4.
//
// The methods of this class will be called on the UI thread unless otherwise
// indicated.
///
/*--cef(source=client)--*/
class CefFrameHandler : public virtual CefBaseRefCounted {
public:
///
// Called when a new frame is created. This will be the first notification
// that references |frame|. Any commands that require transport to the
// associated renderer process (LoadRequest, SendProcessMessage, GetSource,
// etc.) will be queued until OnFrameAttached is called for |frame|.
///
/*--cef()--*/
virtual void OnFrameCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {}
///
// Called when a frame can begin routing commands to/from the associated
// renderer process. Any commands that were queued have now been dispatched.
///
/*--cef()--*/
virtual void OnFrameAttached(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {}
///
// Called when a frame loses its connection to the renderer process and will
// be destroyed. Any pending or future commands will be discarded and
// CefFrame::IsValid() will now return false for |frame|. If called after
// CefLifeSpanHandler::OnBeforeClose() during browser destruction then
// CefBrowser::IsValid() will return false for |browser|.
///
/*--cef()--*/
virtual void OnFrameDetached(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {}
///
// Called when the main frame changes due to (a) initial browser creation, (b)
// final browser destruction, (c) cross-origin navigation or (d) re-navigation
// after renderer process termination (due to crashes, etc). |old_frame| will
// be NULL and |new_frame| will be non-NULL when a main frame is assigned to
// |browser| for the first time. |old_frame| will be non-NULL and |new_frame|
// will be NULL and when a main frame is removed from |browser| for the last
// time. Both |old_frame| and |new_frame| will be non-NULL for cross-origin
// navigations or re-navigation after renderer process termination. This
// method will be called after OnFrameCreated() for |new_frame| and/or after
// OnFrameDetached() for |old_frame|. If called after
// CefLifeSpanHandler::OnBeforeClose() during browser destruction then
// CefBrowser::IsValid() will return false for |browser|.
///
/*--cef(optional_param=old_frame,optional_param=new_frame)--*/
virtual void OnMainFrameChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> old_frame,
CefRefPtr<CefFrame> new_frame) {}
};
#endif // CEF_INCLUDE_CEF_FRAME_HANDLER_H_

View File

@@ -95,10 +95,8 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
}
///
// Called after a new browser is created. It is now safe to begin performing
// actions with |browser|. CefFrameHandler callbacks related to initial main
// frame creation will arrive before this callback. See CefFrameHandler
// documentation for additional usage information.
// Called after a new browser is created. This callback will be the first
// notification that references |browser|.
///
/*--cef()--*/
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) {}
@@ -197,14 +195,13 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
///
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any methods on the browser
// object (other than IsValid, GetIdentifier or IsSame) after this callback
// returns. CefFrameHandler callbacks related to final main frame destruction
// will arrive after this callback and CefBrowser::IsValid will return false
// at that time. Any in-progress network requests associated with |browser|
// object (other than GetIdentifier or IsSame) after this callback returns.
// This callback will be the last notification that references |browser| on
// the UI thread. Any in-progress network requests associated with |browser|
// will be aborted when the browser is destroyed, and
// CefResourceRequestHandler callbacks related to those requests may still
// arrive on the IO thread after this callback. See CefFrameHandler and
// DoClose() documentation for additional usage information.
// arrive on the IO thread after this method is called. See DoClose()
// documentation for additional usage information.
///
/*--cef()--*/
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) {}

View File

@@ -40,7 +40,6 @@
#include <vector>
#include "include/cef_base.h"
#include "include/cef_callback.h"
#include "include/cef_registration.h"
class CefMediaObserver;
@@ -60,13 +59,11 @@ class CefMediaRouter : public virtual CefBaseRefCounted {
public:
///
// Returns the MediaRouter object associated with the global request context.
// If |callback| is non-NULL it will be executed asnychronously on the UI
// thread after the manager's storage has been initialized. Equivalent to
// calling CefRequestContext::GetGlobalContext()->GetMediaRouter().
// Equivalent to calling
// CefRequestContext::GetGlobalContext()->GetMediaRouter().
///
/*--cef(optional_param=callback)--*/
static CefRefPtr<CefMediaRouter> GetGlobalMediaRouter(
CefRefPtr<CefCompletionCallback> callback);
/*--cef()--*/
static CefRefPtr<CefMediaRouter> GetGlobalMediaRouter();
///
// Add an observer for MediaRouter events. The observer will remain registered

View File

@@ -133,8 +133,7 @@ class CefPrintHandler : public virtual CefBaseRefCounted {
// CefBrowserHost::PrintToPDF().
///
/*--cef()--*/
virtual CefSize GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
int device_units_per_inch) {
virtual CefSize GetPdfPaperSize(int device_units_per_inch) {
return CefSize();
}
};

View File

@@ -66,11 +66,11 @@ class CefRenderProcessHandler : public virtual CefBaseRefCounted {
///
// Called after a browser has been created. When browsing cross-origin a new
// browser will be created before the old browser with the same identifier is
// destroyed. |extra_info| is an optional read-only value originating from
// destroyed. |extra_info| is a read-only value originating from
// CefBrowserHost::CreateBrowser(), CefBrowserHost::CreateBrowserSync(),
// CefLifeSpanHandler::OnBeforePopup() or CefBrowserView::CreateBrowserView().
///
/*--cef(optional_param=extra_info)--*/
/*--cef()--*/
virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDictionaryValue> extra_info) {}
@@ -134,8 +134,8 @@ class CefRenderProcessHandler : public virtual CefBaseRefCounted {
///
// Called when a new message is received from a different process. Return true
// if the message was handled or false otherwise. It is safe to keep a
// reference to |message| outside of this callback.
// if the message was handled or false otherwise. Do not keep a reference to
// or attempt to access the message outside of this callback.
///
/*--cef()--*/
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,

View File

@@ -146,7 +146,7 @@ class CefRequestContext : public virtual CefBaseRefCounted {
///
// Returns the cookie manager for this object. If |callback| is non-NULL it
// will be executed asnychronously on the UI thread after the manager's
// will be executed asnychronously on the IO thread after the manager's
// storage has been initialized.
///
/*--cef(optional_param=callback)--*/
@@ -364,13 +364,10 @@ class CefRequestContext : public virtual CefBaseRefCounted {
const CefString& extension_id) = 0;
///
// Returns the MediaRouter object associated with this context. If |callback|
// is non-NULL it will be executed asnychronously on the UI thread after the
// manager's context has been initialized.
// Returns the MediaRouter object associated with this context.
///
/*--cef(optional_param=callback)--*/
virtual CefRefPtr<CefMediaRouter> GetMediaRouter(
CefRefPtr<CefCompletionCallback> callback) = 0;
/*--cef()--*/
virtual CefRefPtr<CefMediaRouter> GetMediaRouter() = 0;
};
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_

View File

@@ -191,7 +191,7 @@ class CefRegisterCdmCallback : public virtual CefBaseRefCounted {
// D. "x-cdm-interface-versions": Interface API version (e.g. "8").
// E. "x-cdm-host-versions": Host API version (e.g. "8").
// F. "version": CDM version (e.g. "1.4.8.903").
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp09,avc1").
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1").
//
// A through E are used to verify compatibility with the current Chromium
// version. If the CDM is not compatible the registration will fail and

View File

@@ -34,6 +34,7 @@
#include <memory.h>
#include <string>
#include "include/base/cef_string16.h"
#include "include/internal/cef_string_types.h"
#if defined(USING_CHROMIUM_INCLUDES)
@@ -79,63 +80,40 @@ struct CefStringTraitsWide {
cef_string_utf8_clear(&cstr);
return str;
}
static inline bool from_string(const std::string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf8_to_wide(data, length, s) ? true : false;
}
static inline bool from_string(const std::string& str, struct_type* s) {
return from_string(str.data(), str.length(), s);
return cef_string_utf8_to_wide(str.c_str(), str.length(), s) ? true : false;
}
static inline std::wstring to_wstring(const struct_type* s) {
return std::wstring(s->str, s->length);
}
static inline bool from_wstring(const std::wstring::value_type* data,
size_t length,
struct_type* s) {
return cef_string_wide_set(data, length, s, true) ? true : false;
}
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return from_wstring(str.data(), str.length(), s);
return cef_string_wide_set(str.c_str(), str.length(), s, true) ? true
: false;
}
#if defined(WCHAR_T_IS_UTF32)
static inline std::u16string to_string16(const struct_type* s) {
static inline base::string16 to_string16(const struct_type* s) {
cef_string_utf16_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_wide_to_utf16(s->str, s->length, &cstr);
std::u16string str;
if (cstr.length > 0) {
str = std::u16string(
reinterpret_cast<std::u16string::value_type*>(cstr.str), cstr.length);
}
base::string16 str;
if (cstr.length > 0)
str = base::string16(cstr.str, cstr.length);
cef_string_utf16_clear(&cstr);
return str;
}
static inline bool from_string16(const std::u16string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf16_to_wide(reinterpret_cast<const char16*>(data),
length, s)
? true
: false;
static inline bool from_string16(const base::string16& str, struct_type* s) {
return cef_string_utf16_to_wide(str.c_str(), str.length(), s) ? true
: false;
}
#else // WCHAR_T_IS_UTF32
static inline std::u16string to_string16(const struct_type* s) {
return std::u16string(
reinterpret_cast<const std::u16string::value_type*>(s->str), s->length);
static inline base::string16 to_string16(const struct_type* s) {
return base::string16(s->str, s->length);
}
static inline bool from_string16(const std::u16string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_wide_set(reinterpret_cast<const wchar_t*>(data), length,
s, true)
? true
: false;
static inline bool from_string16(const base::string16& str, struct_type* s) {
return cef_string_wide_set(str.c_str(), str.length(), s, true) ? true
: false;
}
#endif // WCHAR_T_IS_UTF32
static inline bool from_string16(const std::u16string& str, struct_type* s) {
return from_string16(str.data(), str.length(), s);
}
};
///
@@ -170,13 +148,8 @@ struct CefStringTraitsUTF8 {
static inline std::string to_string(const struct_type* s) {
return std::string(s->str, s->length);
}
static inline bool from_string(const std::string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf8_copy(data, length, s) ? true : false;
}
static inline bool from_string(const std::string& str, struct_type* s) {
return from_string(str.c_str(), str.length(), s);
return cef_string_utf8_copy(str.c_str(), str.length(), s) ? true : false;
}
static inline std::wstring to_wstring(const struct_type* s) {
cef_string_wide_t cstr;
@@ -188,36 +161,22 @@ struct CefStringTraitsUTF8 {
cef_string_wide_clear(&cstr);
return str;
}
static inline bool from_wstring(const std::wstring::value_type* data,
size_t length,
struct_type* s) {
return cef_string_wide_to_utf8(data, length, s) ? true : false;
}
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return from_wstring(str.data(), str.length(), s);
return cef_string_wide_to_utf8(str.c_str(), str.length(), s) ? true : false;
}
static inline std::u16string to_string16(const struct_type* s) {
static inline base::string16 to_string16(const struct_type* s) {
cef_string_utf16_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_utf8_to_utf16(s->str, s->length, &cstr);
std::u16string str;
if (cstr.length > 0) {
str = std::u16string(
reinterpret_cast<std::u16string::value_type*>(cstr.str), cstr.length);
}
base::string16 str;
if (cstr.length > 0)
str = base::string16(cstr.str, cstr.length);
cef_string_utf16_clear(&cstr);
return str;
}
static inline bool from_string16(const std::u16string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf16_to_utf8(reinterpret_cast<const char16*>(data),
length, s)
? true
: false;
}
static inline bool from_string16(const std::u16string& str, struct_type* s) {
return from_string16(str.data(), str.length(), s);
static inline bool from_string16(const base::string16& str, struct_type* s) {
return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ? true
: false;
}
};
@@ -260,13 +219,9 @@ struct CefStringTraitsUTF16 {
cef_string_utf8_clear(&cstr);
return str;
}
static inline bool from_string(const std::string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf8_to_utf16(data, length, s) ? true : false;
}
static inline bool from_string(const std::string& str, struct_type* s) {
return from_string(str.data(), str.length(), s);
return cef_string_utf8_to_utf16(str.c_str(), str.length(), s) ? true
: false;
}
#if defined(WCHAR_T_IS_UTF32)
static inline std::wstring to_wstring(const struct_type* s) {
@@ -279,38 +234,25 @@ struct CefStringTraitsUTF16 {
cef_string_wide_clear(&cstr);
return str;
}
static inline bool from_wstring(const std::wstring::value_type* data,
size_t length,
struct_type* s) {
return cef_string_wide_to_utf16(data, length, s) ? true : false;
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ? true
: false;
}
#else // WCHAR_T_IS_UTF32
static inline std::wstring to_wstring(const struct_type* s) {
return std::wstring(s->str, s->length);
}
static inline bool from_wstring(const std::wstring::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf16_set(data, length, s, true) ? true : false;
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? true
: false;
}
#endif // WCHAR_T_IS_UTF32
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return from_wstring(str.data(), str.length(), s);
static inline base::string16 to_string16(const struct_type* s) {
return base::string16(s->str, s->length);
}
static inline std::u16string to_string16(const struct_type* s) {
return std::u16string(
reinterpret_cast<const std::u16string::value_type*>(s->str), s->length);
}
static inline bool from_string16(const std::u16string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf16_set(reinterpret_cast<const char16*>(data), length,
s, true)
? true
: false;
}
static inline bool from_string16(const std::u16string& str, struct_type* s) {
return from_string16(str.data(), str.length(), s);
static inline bool from_string16(const base::string16& str, struct_type* s) {
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? true
: false;
}
};
@@ -369,10 +311,9 @@ class CefStringBase {
CefStringBase(const std::string& src) : string_(NULL), owner_(false) {
FromString(src);
}
CefStringBase(const char* src, size_t length = 0)
: string_(NULL), owner_(false) {
CefStringBase(const char* src) : string_(NULL), owner_(false) {
if (src)
FromString(src, length);
FromString(std::string(src));
}
///
@@ -383,32 +324,23 @@ class CefStringBase {
CefStringBase(const std::wstring& src) : string_(NULL), owner_(false) {
FromWString(src);
}
CefStringBase(const wchar_t* src, size_t length = 0)
: string_(NULL), owner_(false) {
CefStringBase(const wchar_t* src) : string_(NULL), owner_(false) {
if (src)
FromWString(src, length);
FromWString(std::wstring(src));
}
#if defined(WCHAR_T_IS_UTF32)
///
// Create a new string from an existing string16. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
CefStringBase(const std::u16string& src) : string_(NULL), owner_(false) {
CefStringBase(const base::string16& src) : string_(NULL), owner_(false) {
FromString16(src);
}
CefStringBase(const std::u16string::value_type* src, size_t length = 0)
: string_(NULL), owner_(false) {
CefStringBase(const char16* src) : string_(NULL), owner_(false) {
if (src)
FromString16(src, length);
}
#if defined(WCHAR_T_IS_UTF32)
CefStringBase(const char16* src, size_t length = 0)
: string_(NULL), owner_(false) {
if (src) {
FromString16(reinterpret_cast<const std::u16string::value_type*>(src),
length);
}
FromString16(base::string16(src));
}
#endif // WCHAR_T_IS_UTF32
@@ -647,23 +579,6 @@ class CefStringBase {
return traits::from_string(str, string_);
}
///
// Set this string's data from existing |data| and optional |length|. Data
// will be always copied. Translation will occur if necessary based on the
// underlying string type.
///
bool FromString(const std::string::value_type* data, size_t length = 0) {
if (data && length == 0) {
length = std::char_traits<std::string::value_type>::length(data);
}
if (!data || length == 0) {
clear();
return true;
}
AllocIfNeeded();
return traits::from_string(data, length, string_);
}
///
// Return this string's data as a std::wstring. Translation will occur if
// necessary based on the underlying string type.
@@ -688,29 +603,13 @@ class CefStringBase {
return traits::from_wstring(str, string_);
}
///
// Set this string's data from existing |data| and optional |length|. Data
// will be always copied. Translation will occur if necessary based on the
// underlying string type.
///
bool FromWString(const std::wstring::value_type* data, size_t length = 0) {
if (data && length == 0) {
length = std::char_traits<std::wstring::value_type>::length(data);
}
if (!data || length == 0) {
clear();
return true;
}
AllocIfNeeded();
return traits::from_wstring(data, length, string_);
}
///
// Return this string's data as a string16. Translation will occur if
// necessary based on the underlying string type.
///
std::u16string ToString16() const {
base::string16 ToString16() const {
if (empty())
return std::u16string();
return base::string16();
return traits::to_string16(string_);
}
@@ -719,7 +618,7 @@ class CefStringBase {
// copied. Translation will occur if necessary based on the underlying string
// type.
///
bool FromString16(const std::u16string& str) {
bool FromString16(const base::string16& str) {
if (str.empty()) {
clear();
return true;
@@ -728,23 +627,6 @@ class CefStringBase {
return traits::from_string16(str, string_);
}
///
// Set this string's data from existing |data| and optional |length|. Data
// will be always copied. Translation will occur if necessary based on the
// underlying string type.
///
bool FromString16(const std::u16string::value_type* data, size_t length = 0) {
if (data && length == 0) {
length = std::char_traits<std::u16string::value_type>::length(data);
}
if (!data || length == 0) {
clear();
return true;
}
AllocIfNeeded();
return traits::from_string16(data, length, string_);
}
///
// Comparison operator overloads.
///
@@ -775,8 +657,8 @@ class CefStringBase {
FromString(str);
return *this;
}
CefStringBase& operator=(const std::string::value_type* str) {
FromString(str);
CefStringBase& operator=(const char* str) {
FromString(std::string(str));
return *this;
}
operator std::wstring() const { return ToWString(); }
@@ -784,22 +666,18 @@ class CefStringBase {
FromWString(str);
return *this;
}
CefStringBase& operator=(const std::wstring::value_type* str) {
FromWString(str);
return *this;
}
operator std::u16string() const { return ToString16(); }
CefStringBase& operator=(const std::u16string& str) {
FromString16(str);
return *this;
}
CefStringBase& operator=(const std::u16string::value_type* str) {
FromString16(str);
CefStringBase& operator=(const wchar_t* str) {
FromWString(std::wstring(str));
return *this;
}
#if defined(WCHAR_T_IS_UTF32)
operator base::string16() const { return ToString16(); }
CefStringBase& operator=(const base::string16& str) {
FromString16(str);
return *this;
}
CefStringBase& operator=(const char16* str) {
FromString16(reinterpret_cast<const std::u16string::value_type*>(str));
FromString16(base::string16(str));
return *this;
}
#endif // WCHAR_T_IS_UTF32

View File

@@ -242,9 +242,7 @@ typedef struct _cef_settings_t {
// in-memory caches are used for storage and no data is persisted to disk.
// HTML5 databases such as localStorage will only persist across sessions if a
// cache path is specified. Can be overridden for individual CefRequestContext
// instances via the CefRequestContextSettings.cache_path value. When using
// the Chrome runtime the "default" profile will be used if |cache_path| and
// |root_cache_path| have the same value.
// instances via the CefRequestContextSettings.cache_path value.
///
cef_string_t cache_path;
@@ -266,8 +264,7 @@ typedef struct _cef_settings_t {
// directory on Linux, "~/Library/Application Support/CEF/User Data" directory
// on Mac OS X, "Local Settings\Application Data\CEF\User Data" directory
// under the user profile directory on Windows). If this value is non-empty
// then it must be an absolute path. When using the Chrome runtime this value
// will be ignored in favor of the |root_cache_path| value.
// then it must be an absolute path.
///
cef_string_t user_data_path;
@@ -304,9 +301,9 @@ typedef struct _cef_settings_t {
// Value that will be inserted as the product portion of the default
// User-Agent string. If empty the Chromium product version will be used. If
// |userAgent| is specified this value will be ignored. Also configurable
// using the "user-agent-product" command-line switch.
// using the "product-version" command-line switch.
///
cef_string_t user_agent_product;
cef_string_t product_version;
///
// The locale string that will be passed to WebKit. If empty the default
@@ -345,10 +342,10 @@ typedef struct _cef_settings_t {
///
// The fully qualified path for the resources directory. If this value is
// empty the *.pak files must be located in the module directory on
// Windows/Linux or the app bundle Resources directory on Mac OS X. If this
// value is non-empty then it must be an absolute path. Also configurable
// using the "resources-dir-path" command-line switch.
// empty the cef.pak and/or devtools_resources.pak files must be located in
// the module directory on Windows/Linux or the app bundle Resources directory
// on Mac OS X. If this value is non-empty then it must be an absolute path.
// Also configurable using the "resources-dir-path" command-line switch.
///
cef_string_t resources_dir_path;
@@ -422,20 +419,6 @@ typedef struct _cef_settings_t {
///
cef_string_t accept_language_list;
///
// Comma delimited list of schemes supported by the associated
// CefCookieManager. If |cookieable_schemes_exclude_defaults| is false (0) the
// default schemes ("http", "https", "ws" and "wss") will also be supported.
// Specifying a |cookieable_schemes_list| value and setting
// |cookieable_schemes_exclude_defaults| to true (1) will disable all loading
// and saving of cookies for this manager. Can be overridden
// for individual CefRequestContext instances via the
// CefRequestContextSettings.cookieable_schemes_list and
// CefRequestContextSettings.cookieable_schemes_exclude_defaults values.
///
cef_string_t cookieable_schemes_list;
int cookieable_schemes_exclude_defaults;
///
// GUID string used for identifying the application. This is passed to the
// system AV function for scanning downloaded files. By default, the GUID
@@ -504,18 +487,6 @@ typedef struct _cef_request_context_settings_t {
// ignored if |cache_path| matches the CefSettings.cache_path value.
///
cef_string_t accept_language_list;
///
// Comma delimited list of schemes supported by the associated
// CefCookieManager. If |cookieable_schemes_exclude_defaults| is false (0) the
// default schemes ("http", "https", "ws" and "wss") will also be supported.
// Specifying a |cookieable_schemes_list| value and setting
// |cookieable_schemes_exclude_defaults| to true (1) will disable all loading
// and saving of cookies for this manager. These values will be ignored if
// |cache_path| matches the CefSettings.cache_path value.
///
cef_string_t cookieable_schemes_list;
int cookieable_schemes_exclude_defaults;
} cef_request_context_settings_t;
///
@@ -614,6 +585,14 @@ typedef struct _cef_browser_settings_t {
///
cef_state_t file_access_from_file_urls;
///
// Controls whether web security restrictions (same-origin policy) will be
// enforced. Disabling this setting is not recommend as it will allow risky
// security behavior such as cross-site scripting (XSS). Also configurable
// using the "disable-web-security" command-line switch.
///
cef_state_t web_security;
///
// Controls whether image URLs will be loaded from the network. A cached image
// will still be rendered if requested. Also configurable using the
@@ -680,7 +659,7 @@ typedef struct _cef_browser_settings_t {
///
// Comma delimited ordered list of language codes without any whitespace that
// will be used in the "Accept-Language" HTTP header. May be set globally
// using the CefSettings.accept_language_list value. If both values are
// using the CefBrowserSettings.accept_language_list value. If both values are
// empty then "en-US,en" will be used.
///
cef_string_t accept_language_list;
@@ -1458,6 +1437,7 @@ typedef enum {
// CefShutdown() are guaranteed to run.
///
TID_FILE_BACKGROUND,
TID_FILE = TID_FILE_BACKGROUND,
///
// Used for blocking tasks (e.g. file system access) that affect UI or
@@ -3213,15 +3193,6 @@ typedef enum {
CEF_TFC_SELECT_ALL,
} cef_text_field_commands_t;
///
// Supported Chrome toolbar types.
///
typedef enum {
CEF_CTT_NONE = 1,
CEF_CTT_NORMAL,
CEF_CTT_LOCATION,
} cef_chrome_toolbar_type_t;
#ifdef __cplusplus
}
#endif

View File

@@ -151,9 +151,10 @@ class CefPoint : public CefStructBase<CefPointTraits> {
public:
typedef CefStructBase<CefPointTraits> parent;
CefPoint() {}
CefPoint() : parent() {}
CefPoint(const cef_point_t& r) : parent(r) {}
CefPoint(int x, int y) { Set(x, y); }
CefPoint(const CefPoint& r) : parent(r) {}
CefPoint(int x, int y) : parent() { Set(x, y); }
bool IsEmpty() const { return x <= 0 && y <= 0; }
void Set(int x_val, int y_val) { x = x_val, y = y_val; }
@@ -187,9 +188,12 @@ class CefRect : public CefStructBase<CefRectTraits> {
public:
typedef CefStructBase<CefRectTraits> parent;
CefRect() {}
CefRect() : parent() {}
CefRect(const cef_rect_t& r) : parent(r) {}
CefRect(int x, int y, int width, int height) { Set(x, y, width, height); }
CefRect(const CefRect& r) : parent(r) {}
CefRect(int x, int y, int width, int height) : parent() {
Set(x, y, width, height);
}
bool IsEmpty() const { return width <= 0 || height <= 0; }
void Set(int x_val, int y_val, int width_val, int height_val) {
@@ -236,9 +240,10 @@ class CefSize : public CefStructBase<CefSizeTraits> {
public:
typedef CefStructBase<CefSizeTraits> parent;
CefSize() {}
CefSize() : parent() {}
CefSize(const cef_size_t& r) : parent(r) {}
CefSize(int width, int height) { Set(width, height); }
CefSize(const CefSize& r) : parent(r) {}
CefSize(int width, int height) : parent() { Set(width, height); }
bool IsEmpty() const { return width <= 0 || height <= 0; }
void Set(int width_val, int height_val) {
@@ -274,9 +279,10 @@ class CefRange : public CefStructBase<CefRangeTraits> {
public:
typedef CefStructBase<CefRangeTraits> parent;
CefRange() {}
CefRange() : parent() {}
CefRange(const cef_range_t& r) : parent(r) {}
CefRange(int from, int to) { Set(from, to); }
CefRange(const CefRange& r) : parent(r) {}
CefRange(int from, int to) : parent() { Set(from, to); }
void Set(int from_val, int to_val) { from = from_val, to = to_val; }
};
@@ -309,9 +315,10 @@ class CefInsets : public CefStructBase<CefInsetsTraits> {
public:
typedef CefStructBase<CefInsetsTraits> parent;
CefInsets() {}
CefInsets() : parent() {}
CefInsets(const cef_insets_t& r) : parent(r) {}
CefInsets(int top, int left, int bottom, int right) {
CefInsets(const CefInsets& r) : parent(r) {}
CefInsets(int top, int left, int bottom, int right) : parent() {
Set(top, left, bottom, right);
}
@@ -349,9 +356,10 @@ class CefDraggableRegion : public CefStructBase<CefDraggableRegionTraits> {
public:
typedef CefStructBase<CefDraggableRegionTraits> parent;
CefDraggableRegion() {}
CefDraggableRegion() : parent() {}
CefDraggableRegion(const cef_draggable_region_t& r) : parent(r) {}
CefDraggableRegion(const CefRect& bounds, bool draggable) {
CefDraggableRegion(const CefDraggableRegion& r) : parent(r) {}
CefDraggableRegion(const CefRect& bounds, bool draggable) : parent() {
Set(bounds, draggable);
}
@@ -397,14 +405,16 @@ class CefScreenInfo : public CefStructBase<CefScreenInfoTraits> {
public:
typedef CefStructBase<CefScreenInfoTraits> parent;
CefScreenInfo() {}
CefScreenInfo() : parent() {}
CefScreenInfo(const cef_screen_info_t& r) : parent(r) {}
CefScreenInfo(const CefScreenInfo& r) : parent(r) {}
CefScreenInfo(float device_scale_factor,
int depth,
int depth_per_component,
bool is_monochrome,
const CefRect& rect,
const CefRect& available_rect) {
const CefRect& available_rect)
: parent() {
Set(device_scale_factor, depth, depth_per_component, is_monochrome, rect,
available_rect);
}
@@ -538,14 +548,13 @@ struct CefSettingsTraits {
cef_string_clear(&s->root_cache_path);
cef_string_clear(&s->user_data_path);
cef_string_clear(&s->user_agent);
cef_string_clear(&s->user_agent_product);
cef_string_clear(&s->product_version);
cef_string_clear(&s->locale);
cef_string_clear(&s->log_file);
cef_string_clear(&s->javascript_flags);
cef_string_clear(&s->resources_dir_path);
cef_string_clear(&s->locales_dir_path);
cef_string_clear(&s->accept_language_list);
cef_string_clear(&s->cookieable_schemes_list);
cef_string_clear(&s->application_client_id_for_file_scanning);
}
@@ -577,8 +586,8 @@ struct CefSettingsTraits {
cef_string_set(src->user_agent.str, src->user_agent.length,
&target->user_agent, copy);
cef_string_set(src->user_agent_product.str, src->user_agent_product.length,
&target->user_agent_product, copy);
cef_string_set(src->product_version.str, src->product_version.length,
&target->product_version, copy);
cef_string_set(src->locale.str, src->locale.length, &target->locale, copy);
cef_string_set(src->log_file.str, src->log_file.length, &target->log_file,
@@ -600,13 +609,6 @@ struct CefSettingsTraits {
cef_string_set(src->accept_language_list.str,
src->accept_language_list.length,
&target->accept_language_list, copy);
cef_string_set(src->cookieable_schemes_list.str,
src->cookieable_schemes_list.length,
&target->cookieable_schemes_list, copy);
target->cookieable_schemes_exclude_defaults =
src->cookieable_schemes_exclude_defaults;
cef_string_set(src->application_client_id_for_file_scanning.str,
src->application_client_id_for_file_scanning.length,
&target->application_client_id_for_file_scanning, copy);
@@ -626,7 +628,6 @@ struct CefRequestContextSettingsTraits {
static inline void clear(struct_type* s) {
cef_string_clear(&s->cache_path);
cef_string_clear(&s->accept_language_list);
cef_string_clear(&s->cookieable_schemes_list);
}
static inline void set(const struct_type* src,
@@ -640,12 +641,6 @@ struct CefRequestContextSettingsTraits {
cef_string_set(src->accept_language_list.str,
src->accept_language_list.length,
&target->accept_language_list, copy);
cef_string_set(src->cookieable_schemes_list.str,
src->cookieable_schemes_list.length,
&target->cookieable_schemes_list, copy);
target->cookieable_schemes_exclude_defaults =
src->cookieable_schemes_exclude_defaults;
}
};
@@ -710,6 +705,7 @@ struct CefBrowserSettingsTraits {
target->universal_access_from_file_urls =
src->universal_access_from_file_urls;
target->file_access_from_file_urls = src->file_access_from_file_urls;
target->web_security = src->web_security;
target->image_loading = src->image_loading;
target->image_shrink_standalone_to_fit =
src->image_shrink_standalone_to_fit;
@@ -796,10 +792,11 @@ class CefTime : public CefStructBase<CefTimeTraits> {
public:
typedef CefStructBase<CefTimeTraits> parent;
CefTime() {}
CefTime() : parent() {}
CefTime(const cef_time_t& r) : parent(r) {}
explicit CefTime(time_t r) { SetTimeT(r); }
explicit CefTime(double r) { SetDoubleT(r); }
CefTime(const CefTime& r) : parent(r) {}
explicit CefTime(time_t r) : parent() { SetTimeT(r); }
explicit CefTime(double r) : parent() { SetDoubleT(r); }
// Converts to/from time_t.
void SetTimeT(time_t r) { cef_time_from_timet(r, this); }

View File

@@ -80,17 +80,6 @@ class CefBrowserView : public CefView {
/*--cef()--*/
virtual CefRefPtr<CefBrowser> GetBrowser() = 0;
///
// Returns the Chrome toolbar associated with this BrowserView. Only supported
// when using the Chrome runtime. The CefBrowserViewDelegate::
// GetChromeToolbarType() method must return a value other than
// CEF_CTT_NONE and the toolbar will not be available until after this
// BrowserView is added to a CefWindow and CefViewDelegate::OnWindowChanged()
// has been called.
///
/*--cef()--*/
virtual CefRefPtr<CefView> GetChromeToolbar() = 0;
///
// Sets whether accelerators registered with CefWindow::SetAccelerator are
// triggered before or after the event is sent to the CefBrowser. If

View File

@@ -52,8 +52,6 @@ class CefBrowserView;
/*--cef(source=client)--*/
class CefBrowserViewDelegate : public CefViewDelegate {
public:
typedef cef_chrome_toolbar_type_t ChromeToolbarType;
///
// Called when |browser| associated with |browser_view| is created. This
// method will be called after CefLifeSpanHandler::OnAfterCreated() is called
@@ -106,14 +104,6 @@ class CefBrowserViewDelegate : public CefViewDelegate {
bool is_devtools) {
return false;
}
///
// Returns the Chrome toolbar type that will be available via
// CefBrowserView::GetChromeToolbar(). See that method for related
// documentation.
///
/*--cef(default_retval=CEF_CTT_NONE)--*/
virtual ChromeToolbarType GetChromeToolbarType() { return CEF_CTT_NONE; }
};
#endif // CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_DELEGATE_H_

View File

@@ -105,12 +105,6 @@ class CefViewDelegate : public virtual CefBaseRefCounted {
bool added,
CefRefPtr<CefView> child) {}
///
// Called when |view| is added or removed from the CefWindow.
///
/*--cef(optional_param=window)--*/
virtual void OnWindowChanged(CefRefPtr<CefView> view, bool added) {}
///
// Called when |view| gains focus.
///

View File

@@ -48,12 +48,7 @@
#define CEF_REQUIRE_UI_THREAD() DCHECK(CefCurrentlyOn(TID_UI));
#define CEF_REQUIRE_IO_THREAD() DCHECK(CefCurrentlyOn(TID_IO));
#define CEF_REQUIRE_FILE_BACKGROUND_THREAD() \
DCHECK(CefCurrentlyOn(TID_FILE_BACKGROUND));
#define CEF_REQUIRE_FILE_USER_VISIBLE_THREAD() \
DCHECK(CefCurrentlyOn(TID_FILE_USER_VISIBLE));
#define CEF_REQUIRE_FILE_USER_BLOCKING_THREAD() \
DCHECK(CefCurrentlyOn(TID_FILE_USER_BLOCKING));
#define CEF_REQUIRE_FILE_THREAD() DCHECK(CefCurrentlyOn(TID_FILE));
#define CEF_REQUIRE_RENDERER_THREAD() DCHECK(CefCurrentlyOn(TID_RENDERER));
// Use this struct in conjuction with refcounted types to ensure that an
@@ -91,12 +86,7 @@ struct CefDeleteOnThread {
struct CefDeleteOnUIThread : public CefDeleteOnThread<TID_UI> {};
struct CefDeleteOnIOThread : public CefDeleteOnThread<TID_IO> {};
struct CefDeleteOnFileBackgroundThread
: public CefDeleteOnThread<TID_FILE_BACKGROUND> {};
struct CefDeleteOnFileUserVisibleThread
: public CefDeleteOnThread<TID_FILE_USER_VISIBLE> {};
struct CefDeleteOnFileUserBlockingThread
: public CefDeleteOnThread<TID_FILE_USER_BLOCKING> {};
struct CefDeleteOnFileThread : public CefDeleteOnThread<TID_FILE> {};
struct CefDeleteOnRendererThread : public CefDeleteOnThread<TID_RENDERER> {};
// Same as IMPLEMENT_REFCOUNTING() but using the specified Destructor.
@@ -124,6 +114,7 @@ struct CefDeleteOnRendererThread : public CefDeleteOnThread<TID_RENDERER> {};
#define IMPLEMENT_REFCOUNTING_DELETE_ON_IOT(ClassName) \
IMPLEMENT_REFCOUNTING_EX(ClassName, CefDeleteOnIOThread)
///
// Helper class to manage a scoped copy of |argv|.
///

View File

@@ -46,7 +46,7 @@
// The below classes implement support for routing aynchronous messages between
// JavaScript running in the renderer process and C++ running in the browser
// process. An application interacts with the router by passing it data from
// standard CEF C++ callbacks (OnBeforeBrowse, OnProcessMessageReceived,
// standard CEF C++ callbacks (OnBeforeBrowse, OnProcessMessageRecieved,
// OnContextCreated, etc). The renderer-side router supports generic JavaScript
// callback registration and execution while the browser-side router supports
// application-specific logic via one or more application-provided Handler

View File

@@ -113,18 +113,6 @@ AlloyBrowserContext::~AlloyBrowserContext() {
}
}
bool AlloyBrowserContext::IsInitialized() const {
CEF_REQUIRE_UIT();
return !!key_;
}
void AlloyBrowserContext::StoreOrTriggerInitCallback(
base::OnceClosure callback) {
CEF_REQUIRE_UIT();
// Initialization is always synchronous.
std::move(callback).Run();
}
void AlloyBrowserContext::Initialize() {
CefBrowserContext::Initialize();
@@ -309,14 +297,24 @@ 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(nullptr)->GetZoomLevelDelegate());
GetStoragePartition(this, nullptr)->GetZoomLevelDelegate());
}
scoped_refptr<network::SharedURLLoaderFactory>
AlloyBrowserContext::GetURLLoaderFactory() {
return GetDefaultStoragePartition()->GetURLLoaderFactoryForBrowserProcess();
return GetDefaultStoragePartition(this)
->GetURLLoaderFactoryForBrowserProcess();
}
base::FilePath AlloyBrowserContext::GetPath() {
@@ -338,11 +336,18 @@ AlloyBrowserContext::CreateZoomLevelDelegate(
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_) {
download_manager_delegate_.reset(
new CefDownloadManagerDelegate(GetDownloadManager()));
content::DownloadManager* manager =
BrowserContext::GetDownloadManager(this);
download_manager_delegate_.reset(new CefDownloadManagerDelegate(manager));
}
return download_manager_delegate_.get();
}
@@ -432,11 +437,6 @@ AlloyBrowserContext::GetProfilePolicyConnector() const {
return nullptr;
}
bool AlloyBrowserContext::IsNewProfile() const {
NOTREACHED();
return false;
}
void AlloyBrowserContext::RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) {
// Called when visited links will not or cannot be loaded from disk.

View File

@@ -42,8 +42,6 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
// CefBrowserContext overrides.
content::BrowserContext* AsBrowserContext() override { return this; }
Profile* AsProfile() override { return this; }
bool IsInitialized() const override;
void StoreOrTriggerInitCallback(base::OnceClosure callback) override;
void Initialize() override;
void Shutdown() override;
void RemoveCefRequestContext(CefRequestContextImpl* context) override;
@@ -60,10 +58,16 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
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;
@@ -90,7 +94,6 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
policy::ProfilePolicyConnector* GetProfilePolicyConnector() override;
const policy::ProfilePolicyConnector* GetProfilePolicyConnector()
const override;
bool IsNewProfile() const override;
// Values checked in ProfileNetworkContextService::CreateNetworkContextParams
// when creating the NetworkContext.

View File

@@ -21,9 +21,9 @@
#include "libcef/browser/osr/osr_util.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/drag_data_impl.h"
#include "libcef/common/net/url_util.h"
#include "libcef/common/request_impl.h"
#include "libcef/common/values_impl.h"
#include "libcef/features/runtime_checks.h"
@@ -175,13 +175,12 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
if (!browser)
return nullptr;
GURL url = url_util::MakeGURL(create_params.url, /*fixup=*/true);
if (create_params.extension) {
platform_delegate_ptr->CreateExtensionHost(
create_params.extension, url, create_params.extension_host_type);
} else if (!url.is_empty()) {
content::OpenURLParams params(url, content::Referrer(),
create_params.extension, create_params.url,
create_params.extension_host_type);
} else if (!create_params.url.is_empty()) {
content::OpenURLParams params(create_params.url, content::Referrer(),
WindowOpenDisposition::CURRENT_TAB,
CefFrameHostImpl::kPageTransitionExplicit,
/*is_renderer_initiated=*/false);
@@ -379,7 +378,7 @@ void AlloyBrowserHostImpl::SetFocusInternal(bool focus) {
}
CefWindowHandle AlloyBrowserHostImpl::GetWindowHandle() {
if (is_views_hosted_ && CEF_CURRENTLY_ON_UIT()) {
if (IsViewsHosted() && CEF_CURRENTLY_ON_UIT()) {
// Always return the most up-to-date window handle for a views-hosted
// browser since it may change if the view is re-parented.
if (platform_delegate_)
@@ -392,6 +391,10 @@ CefWindowHandle AlloyBrowserHostImpl::GetOpenerWindowHandle() {
return opener_;
}
bool AlloyBrowserHostImpl::HasView() {
return IsViewsHosted();
}
double AlloyBrowserHostImpl::GetZoomLevel() {
// Verify that this method is being called on the UI thread.
if (!CEF_CURRENTLY_ON_UIT()) {
@@ -529,6 +532,82 @@ bool AlloyBrowserHostImpl::HasDevTools() {
return devtools_manager_->HasDevTools();
}
bool AlloyBrowserHostImpl::SendDevToolsMessage(const void* message,
size_t message_size) {
if (!message || message_size == 0)
return false;
if (!CEF_CURRENTLY_ON_UIT()) {
std::string message_str(static_cast<const char*>(message), message_size);
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
[](CefRefPtr<AlloyBrowserHostImpl> self, std::string message_str) {
self->SendDevToolsMessage(message_str.data(), message_str.size());
},
CefRefPtr<AlloyBrowserHostImpl>(this), std::move(message_str)));
return false;
}
if (!EnsureDevToolsManager())
return false;
return devtools_manager_->SendDevToolsMessage(message, message_size);
}
int AlloyBrowserHostImpl::ExecuteDevToolsMethod(
int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
base::IgnoreResult(&AlloyBrowserHostImpl::ExecuteDevToolsMethod),
this, message_id, method, params));
return 0;
}
if (!EnsureDevToolsManager())
return 0;
return devtools_manager_->ExecuteDevToolsMethod(message_id, method, params);
}
CefRefPtr<CefRegistration> AlloyBrowserHostImpl::AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) {
if (!observer)
return nullptr;
auto registration = CefDevToolsManager::CreateRegistration(observer);
InitializeDevToolsRegistrationOnUIThread(registration);
return registration.get();
}
bool AlloyBrowserHostImpl::EnsureDevToolsManager() {
CEF_REQUIRE_UIT();
if (!web_contents())
return false;
if (!devtools_manager_) {
devtools_manager_.reset(new CefDevToolsManager(this));
}
return true;
}
void AlloyBrowserHostImpl::InitializeDevToolsRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
&AlloyBrowserHostImpl::InitializeDevToolsRegistrationOnUIThread,
this, registration));
return;
}
if (!EnsureDevToolsManager())
return;
devtools_manager_->InitializeRegistrationOnUIThread(registration);
}
void AlloyBrowserHostImpl::SetAccessibilityState(
cef_state_t accessibility_state) {
if (!CEF_CURRENTLY_ON_UIT()) {
@@ -639,7 +718,7 @@ void AlloyBrowserHostImpl::SendExternalBeginFrame() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&AlloyBrowserHostImpl::SendExternalBeginFrame, this));
base::Bind(&AlloyBrowserHostImpl::SendExternalBeginFrame, this));
return;
}
@@ -654,8 +733,8 @@ void AlloyBrowserHostImpl::SendTouchEvent(const CefTouchEvent& event) {
}
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SendTouchEvent,
this, event));
CEF_POST_TASK(CEF_UIT, base::Bind(&AlloyBrowserHostImpl::SendTouchEvent,
this, event));
return;
}
@@ -724,6 +803,10 @@ bool AlloyBrowserHostImpl::IsWindowless() const {
return is_windowless_;
}
bool AlloyBrowserHostImpl::IsViewsHosted() const {
return is_views_hosted_;
}
bool AlloyBrowserHostImpl::IsPictureInPictureSupported() const {
// Not currently supported with OSR.
return !IsWindowless();
@@ -782,9 +865,27 @@ void AlloyBrowserHostImpl::DestroyBrowser() {
recently_audible_timer_.Stop();
audio_capturer_.reset(nullptr);
devtools_manager_.reset(nullptr);
CefBrowserHostBase::DestroyBrowser();
}
#if defined(USE_AURA)
views::Widget* AlloyBrowserHostImpl::GetWindowWidget() const {
CEF_REQUIRE_UIT();
if (!platform_delegate_)
return nullptr;
return platform_delegate_->GetWindowWidget();
}
CefRefPtr<CefBrowserView> AlloyBrowserHostImpl::GetBrowserView() const {
CEF_REQUIRE_UIT();
if (IsViewsHosted() && platform_delegate_)
return platform_delegate_->GetBrowserView();
return nullptr;
}
#endif
void AlloyBrowserHostImpl::CancelContextMenu() {
CEF_REQUIRE_UIT();
if (menu_manager_)
@@ -800,10 +901,10 @@ bool AlloyBrowserHostImpl::MaybeAllowNavigation(
// The PDF viewer will load the PDF extension in the guest view, and print
// preview will load chrome://print in the guest view. All other navigations
// are passed to the owner browser.
CEF_POST_TASK(CEF_UIT,
base::BindOnce(
base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
this, nullptr, params));
CEF_POST_TASK(
CEF_UIT,
base::Bind(base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
this, nullptr, params));
return false;
}
@@ -811,6 +912,12 @@ bool AlloyBrowserHostImpl::MaybeAllowNavigation(
return true;
}
SkColor AlloyBrowserHostImpl::GetBackgroundColor() const {
// Don't use |platform_delegate_| because it's not thread-safe.
return CefContext::Get()->GetBackgroundColor(
&settings_, is_windowless_ ? STATE_ENABLED : STATE_DISABLED);
}
extensions::ExtensionHost* AlloyBrowserHostImpl::GetExtensionHost() const {
CEF_REQUIRE_UIT();
DCHECK(platform_delegate_);
@@ -1077,8 +1184,8 @@ void AlloyBrowserHostImpl::DragSourceEndedAt(
void AlloyBrowserHostImpl::SetAudioMuted(bool mute) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SetAudioMuted,
this, mute));
CEF_POST_TASK(CEF_UIT,
base::Bind(&AlloyBrowserHostImpl::SetAudioMuted, this, mute));
return;
}
if (!web_contents())
@@ -1168,11 +1275,6 @@ void AlloyBrowserHostImpl::CloseContents(content::WebContents* source) {
// destroyed.
CefRefPtr<AlloyBrowserHostImpl> browser(this);
if (source) {
// Try to fast shutdown the associated process.
source->GetMainFrame()->GetProcess()->FastShutdownIfPossible(1, false);
}
// No window exists. Destroy the browser immediately. Don't call other
// browser methods after calling DestroyBrowser().
DestroyBrowser();
@@ -1190,9 +1292,9 @@ void AlloyBrowserHostImpl::UpdateTargetURL(content::WebContents* source,
bool AlloyBrowserHostImpl::DidAddMessageToConsole(
content::WebContents* source,
blink::mojom::ConsoleMessageLevel level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) {
const base::string16& source_id) {
return contents_delegate_->DidAddMessageToConsole(source, level, message,
line_no, source_id);
}
@@ -1471,13 +1573,11 @@ void AlloyBrowserHostImpl::ExitPictureInPicture() {
// content::WebContentsObserver methods.
// -----------------------------------------------------------------------------
void AlloyBrowserHostImpl::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) {
if (render_frame_host->GetParent() == nullptr) {
auto render_view_host = render_frame_host->GetRenderViewHost();
new CefWidgetHostInterceptor(this, render_view_host);
platform_delegate_->RenderViewCreated(render_view_host);
}
void AlloyBrowserHostImpl::RenderViewCreated(
content::RenderViewHost* render_view_host) {
new CefWidgetHostInterceptor(this, render_view_host);
platform_delegate_->RenderViewCreated(render_view_host);
}
void AlloyBrowserHostImpl::RenderViewReady() {
@@ -1584,10 +1684,11 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
content::WebContentsObserver(web_contents),
opener_(kNullWindowHandle),
is_windowless_(platform_delegate_->IsWindowless()),
is_views_hosted_(platform_delegate_->IsViewsHosted()),
extension_(extension) {
contents_delegate_->ObserveWebContents(web_contents);
if (opener.get() && !is_views_hosted_) {
if (opener.get() && !platform_delegate_->IsViewsHosted()) {
// GetOpenerWindowHandle() only returns a value for non-views-hosted
// popup browsers.
opener_ = opener->GetWindowHandle();
@@ -1596,8 +1697,8 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
// Associate the platform delegate with this browser.
platform_delegate_->BrowserCreated(this);
// Make sure RenderFrameCreated is called at least one time.
RenderFrameCreated(web_contents->GetMainFrame());
// Make sure RenderViewCreated is called at least one time.
RenderViewCreated(web_contents->GetRenderViewHost());
}
bool AlloyBrowserHostImpl::CreateHostWindow() {
@@ -1606,7 +1707,7 @@ bool AlloyBrowserHostImpl::CreateHostWindow() {
bool success = true;
if (!IsWindowless())
success = platform_delegate_->CreateHostWindow();
if (success && !is_views_hosted_)
if (success && !IsViewsHosted())
host_window_handle_ = platform_delegate_->GetHostWindowHandle();
return success;
}
@@ -1631,8 +1732,7 @@ void AlloyBrowserHostImpl::StartDragging(
}
}
void AlloyBrowserHostImpl::UpdateDragCursor(
ui::mojom::DragOperation operation) {
void AlloyBrowserHostImpl::UpdateDragCursor(blink::DragOperation operation) {
if (platform_delegate_)
platform_delegate_->UpdateDragCursor(operation);
}

View File

@@ -22,14 +22,16 @@
#include "libcef/browser/menu_manager.h"
#include "libcef/browser/request_context_impl.h"
#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "extensions/common/mojom/view_type.mojom-forward.h"
#include "extensions/common/view_type.h"
class CefAudioCapturer;
class CefBrowserInfo;
class CefDevToolsManager;
class SiteInstance;
// CefBrowser implementation for the alloy runtime. Method calls are delegated
@@ -86,6 +88,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void SetFocus(bool focus) override;
CefWindowHandle GetWindowHandle() override;
CefWindowHandle GetOpenerWindowHandle() override;
bool HasView() override;
double GetZoomLevel() override;
void SetZoomLevel(double zoomLevel) override;
void RunFileDialog(FileDialogMode mode,
@@ -110,6 +113,12 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
const CefPoint& inspect_element_at) override;
void CloseDevTools() override;
bool HasDevTools() override;
bool SendDevToolsMessage(const void* message, size_t message_size) override;
int ExecuteDevToolsMethod(int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) override;
CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) override;
bool IsWindowRenderingDisabled() override;
void WasResized() override;
void WasHidden(bool hidden) override;
@@ -150,13 +159,16 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
bool IsBackgroundHost() override;
// Returns true if windowless rendering is enabled.
bool IsWindowless() const override;
bool IsWindowless() const;
// Returns true if this browser is views-hosted.
bool IsViewsHosted() const;
// Returns true if this browser supports picture-in-picture.
bool IsPictureInPictureSupported() const;
// Called when the OS window hosting the browser is destroyed.
void WindowDestroyed() override;
void WindowDestroyed();
// Destroy the browser members. This method should only be called after the
// native browser window is not longer processing messages.
@@ -165,6 +177,16 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
// Cancel display of the context menu, if any.
void CancelContextMenu();
#if defined(USE_AURA)
// Returns the Widget owner for the browser window. Only used with windowed
// rendering.
views::Widget* GetWindowWidget() const;
// Returns the BrowserView associated with this browser. Only used with views-
// based browsers.
CefRefPtr<CefBrowserView> GetBrowserView() const;
#endif
bool MaybeAllowNavigation(content::RenderFrameHost* opener,
bool is_guest_view,
const content::OpenURLParams& params) override;
@@ -179,7 +201,10 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
const gfx::Vector2d& image_offset,
const blink::mojom::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh);
void UpdateDragCursor(ui::mojom::DragOperation operation);
void UpdateDragCursor(blink::DragOperation operation);
// Thread safe accessors.
SkColor GetBackgroundColor() const;
// Accessors that must be called on the UI thread.
extensions::ExtensionHost* GetExtensionHost() const;
@@ -221,9 +246,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
bool DidAddMessageToConsole(content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) override;
const base::string16& source_id) override;
void BeforeUnloadFired(content::WebContents* source,
bool proceed,
bool* proceed_to_fire_unload) override;
@@ -295,7 +320,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
// content::WebContentsObserver methods.
using content::WebContentsObserver::BeforeUnloadFired;
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
void RenderViewReady() override;
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override;
@@ -341,10 +366,15 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void StartAudioCapturer();
void OnRecentlyAudibleTimerFired();
bool EnsureDevToolsManager();
void InitializeDevToolsRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration);
void SetFocusInternal(bool focus);
CefWindowHandle opener_;
const bool is_windowless_;
const bool is_views_hosted_;
CefWindowHandle host_window_handle_ = kNullWindowHandle;
CefRefPtr<CefExtension> extension_;
bool is_background_host_ = false;
@@ -366,6 +396,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
// Used for creating and managing context menus.
std::unique_ptr<CefMenuManager> menu_manager_;
// Used for creating and managing DevTools instances.
std::unique_ptr<CefDevToolsManager> devtools_manager_;
// Used for capturing audio for CefAudioHandler.
std::unique_ptr<CefAudioCapturer> audio_capturer_;

View File

@@ -16,6 +16,7 @@
#include "libcef/browser/extensions/extensions_browser_client.h"
#include "libcef/browser/net/chrome_scheme_handler.h"
#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"
@@ -25,7 +26,6 @@
#include "base/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/media/router/chrome_media_router_factory.h"
#include "chrome/browser/net/system_network_context_manager.h"
@@ -53,6 +53,7 @@
#include "chrome/browser/chrome_browser_main_win.h"
#include "chrome/browser/win/parental_controls.h"
#include "components/os_crypt/os_crypt.h"
#include "ui/base/cursor/cursor_loader_win.h"
#endif
#endif // defined(USE_AURA)
@@ -97,6 +98,11 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
CHECK(aura::Env::GetInstance());
wm_state_.reset(new wm::WMState);
#if defined(OS_WIN)
ui::CursorLoaderWin::SetCursorResourceModule(
CefAppManager::Get()->GetResourceDllName());
#endif
#endif // defined(USE_AURA)
#if defined(TOOLKIT_VIEWS)
@@ -109,7 +115,7 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
#endif // defined(TOOLKIT_VIEWS)
}
void AlloyBrowserMainParts::PreCreateMainMessageLoop() {
void AlloyBrowserMainParts::PreMainMessageLoopStart() {
#if defined(USE_AURA) && defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif
@@ -129,7 +135,7 @@ void AlloyBrowserMainParts::PreCreateMainMessageLoop() {
media_router::ChromeMediaRouterFactory::DoPlatformInit();
}
void AlloyBrowserMainParts::PostCreateMainMessageLoop() {
void AlloyBrowserMainParts::PostMainMessageLoopStart() {
#if defined(OS_LINUX)
printing::PrintingContextLinux::SetCreatePrintDialogFunction(
&CefPrintDialogLinux::CreatePrintDialog);
@@ -153,10 +159,9 @@ int AlloyBrowserMainParts::PreCreateThreads() {
return 0;
}
int AlloyBrowserMainParts::PreMainMessageLoopRun() {
void AlloyBrowserMainParts::PreMainMessageLoopRun() {
#if defined(USE_AURA)
screen_ = views::CreateDesktopScreen();
display::Screen::SetScreenInstance(screen_.get());
display::Screen::SetScreenInstance(views::CreateDesktopScreen());
#endif
if (extensions::ExtensionsEnabled()) {
@@ -175,14 +180,16 @@ int AlloyBrowserMainParts::PreMainMessageLoopRun() {
// ChromeBrowserMainExtraPartsProfiles for details.
cef::EnsureBrowserContextKeyedServiceFactoriesBuilt();
background_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::BEST_EFFORT,
printing::CefPrintingMessageFilter::EnsureShutdownNotifierFactoryBuilt();
background_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_visible_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::USER_VISIBLE,
user_visible_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_blocking_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::USER_BLOCKING,
user_blocking_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
CefRequestContextSettings settings;
@@ -206,8 +213,6 @@ int AlloyBrowserMainParts::PreMainMessageLoopRun() {
PluginFinder::GetInstance()->Init();
scheme::RegisterWebUIControllerFactory();
return content::RESULT_CODE_NORMAL_EXIT;
}
void AlloyBrowserMainParts::PostMainMessageLoopRun() {

View File

@@ -24,9 +24,6 @@ class ExtensionsClient;
} // namespace extensions
#if defined(USE_AURA)
namespace display {
class Screen;
}
namespace wm {
class WMState;
}
@@ -50,10 +47,10 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
int PreEarlyInitialization() override;
void ToolkitInitialized() override;
void PreCreateMainMessageLoop() override;
void PostCreateMainMessageLoop() override;
void PreMainMessageLoopStart() override;
void PostMainMessageLoopStart() override;
int PreCreateThreads() override;
int PreMainMessageLoopRun() override;
void PreMainMessageLoopRun() override;
void PostMainMessageLoopRun() override;
void PostDestroyThreads() override;
@@ -94,7 +91,6 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner_;
#if defined(USE_AURA)
std::unique_ptr<display::Screen> screen_;
std::unique_ptr<wm::WMState> wm_state_;
#endif

View File

@@ -12,10 +12,9 @@
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/alloy/alloy_browser_main.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_frame.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_manager.h"
#include "libcef/browser/browser_message_filter.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
@@ -30,12 +29,14 @@
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
#include "libcef/browser/plugins/plugin_service_filter.h"
#include "libcef/browser/prefs/renderer_prefs.h"
#include "libcef/browser/printing/printing_message_filter.h"
#include "libcef/browser/speech_recognition_manager_delegate.h"
#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/extensions/extensions_util.h"
@@ -51,9 +52,8 @@
#include "base/threading/thread_restrictions.h"
#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/profile_network_context_service.h"
#include "chrome/browser/net/profile_network_context_service_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"
@@ -73,8 +73,6 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/services/printing/printing_service.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/embedder_support/switches.h"
#include "components/embedder_support/user_agent_utils.h"
#include "components/spellcheck/common/spellcheck.mojom.h"
#include "components/version_info/version_info.h"
#include "content/browser/plugin_service_impl.h"
@@ -95,10 +93,10 @@
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_ui_url_loader_factory.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/service_names.mojom.h"
#include "content/public/common/storage_quota_params.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/user_agent.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_message_filter.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/extension_registry.h"
@@ -239,10 +237,9 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
RunNow(std::move(callback_), allow);
}
} else {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefAllowCertificateErrorCallbackImpl::Continue, this,
allow));
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefAllowCertificateErrorCallbackImpl::Continue,
this, allow));
}
}
@@ -255,7 +252,7 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
CEF_REQUIRE_UIT();
std::move(callback).Run(
allow ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE
: content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
: content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
}
CallbackType callback_;
@@ -504,6 +501,9 @@ void AlloyContentBrowserClient::RenderProcessWillLaunch(
const int id = host->GetID();
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
host->AddFilter(new CefBrowserMessageFilter(id));
host->AddFilter(new printing::CefPrintingMessageFilter(id, profile));
if (extensions::ExtensionsEnabled()) {
host->AddFilter(new extensions::ExtensionMessageFilter(id, profile));
host->AddFilter(
@@ -695,9 +695,9 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kLocalesDirPath,
switches::kLogFile,
switches::kLogSeverity,
switches::kProductVersion,
switches::kResourcesDirPath,
embedder_support::kUserAgent,
switches::kUserAgentProductAndVersion,
switches::kUserAgent,
};
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
base::size(kSwitchNames));
@@ -782,7 +782,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
CefRefPtr<CefCommandLineImpl> commandLinePtr(
new CefCommandLineImpl(command_line, false, false));
handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
ignore_result(commandLinePtr->Detach(nullptr));
commandLinePtr->Detach(nullptr);
}
}
}
@@ -855,7 +855,7 @@ void AlloyContentBrowserClient::AllowCertificateError(
// A sub-resource has a certificate error. The user doesn't really
// have a context for making the right decision, so block the request
// hard.
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
return;
}
@@ -882,7 +882,7 @@ void AlloyContentBrowserClient::AllowCertificateError(
// |callback| may be null if the user executed it despite returning false.
callback = callbackImpl->Disconnect();
if (!callback.is_null()) {
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
}
}
}
@@ -951,10 +951,8 @@ bool AlloyContentBrowserClient::CanCreateWindow(
}
void AlloyContentBrowserClient::OverrideWebkitPrefs(
content::WebContents* web_contents,
content::RenderViewHost* rvh,
blink::web_pref::WebPreferences* prefs) {
auto rvh = web_contents->GetRenderViewHost();
// Using RVH instead of RFH here because rvh->GetMainFrame() may be nullptr
// when this method is called.
renderer_prefs::PopulateWebPreferences(rvh, *prefs);
@@ -988,9 +986,9 @@ void AlloyContentBrowserClient::DidCreatePpapiPlugin(
new ChromeBrowserPepperHostFactory(browser_host)));
}
std::unique_ptr<content::DevToolsManagerDelegate>
AlloyContentBrowserClient::CreateDevToolsManagerDelegate() {
return std::make_unique<CefDevToolsManagerDelegate>();
content::DevToolsManagerDelegate*
AlloyContentBrowserClient::GetDevToolsManagerDelegate() {
return new CefDevToolsManagerDelegate();
}
std::vector<std::unique_ptr<content::NavigationThrottle>>
@@ -1012,7 +1010,7 @@ AlloyContentBrowserClient::CreateURLLoaderThrottles(
// Used to substitute View ID for PDF contents when using the PDF plugin.
result.push_back(std::make_unique<PluginResponseInterceptorURLLoaderThrottle>(
request.destination, frame_tree_node_id));
request.resource_type, frame_tree_node_id));
Profile* profile = Profile::FromBrowserContext(browser_context);
@@ -1038,20 +1036,19 @@ void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
}
#endif // defined(OS_LINUX)
#if defined(OS_WIN)
bool AlloyContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) {
return true;
}
#endif // defined(OS_WIN)
void AlloyContentBrowserClient::ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* host) {
associated_registry->AddInterface(
base::BindRepeating(&BindPluginInfoHost, host->GetID()));
if (extensions::ExtensionsEnabled()) {
associated_registry->AddInterface(base::BindRepeating(
&extensions::EventRouter::BindForRenderer, host->GetID()));
}
CefBrowserManager::ExposeInterfacesToRenderer(registry, associated_registry,
host);
}
std::unique_ptr<net::ClientCertStore>
@@ -1159,7 +1156,7 @@ bool AlloyContentBrowserClient::WillCreateURLLoaderFactory(
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
base::Optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -1195,8 +1192,7 @@ void AlloyContentBrowserClient::ConfigureNetworkContextParams(
bool in_memory,
const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
cert_verifier::mojom::CertVerifierCreationParams*
cert_verifier_creation_params) {
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params) {
// This method may be called during shutdown when using multi-threaded
// message loop mode. In that case exit early to avoid crashes.
if (!SystemNetworkContextManager::GetInstance()) {
@@ -1209,17 +1205,9 @@ void AlloyContentBrowserClient::ConfigureNetworkContextParams(
auto cef_context = CefBrowserContext::FromBrowserContext(context);
Profile* profile = cef_context->AsProfile();
ProfileNetworkContextService* service =
ProfileNetworkContextServiceFactory::GetForContext(profile);
if (service) {
service->ConfigureNetworkContextParams(in_memory, relative_partition_path,
network_context_params,
cert_verifier_creation_params);
} else {
// Set default params.
network_context_params->user_agent = GetUserAgent();
network_context_params->accept_language = GetApplicationLocale();
}
profile->ConfigureNetworkContextParams(in_memory, relative_partition_path,
network_context_params,
cert_verifier_creation_params);
network_context_params->cookieable_schemes =
cef_context->GetCookieableSchemes();
@@ -1252,12 +1240,11 @@ bool AlloyContentBrowserClient::HandleExternalProtocol(
const GURL& url,
content::WebContents::OnceGetter web_contents_getter,
int child_id,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
// Call the other HandleExternalProtocol variant.
return false;
@@ -1276,8 +1263,8 @@ bool AlloyContentBrowserClient::HandleExternalProtocol(
// nothing handles the request.
auto request_handler = net_service::CreateInterceptedRequestHandler(
web_contents_getter, frame_tree_node_id, resource_request,
base::BindRepeating(CefBrowserPlatformDelegate::HandleExternalProtocol,
resource_request.url));
base::Bind(CefBrowserPlatformDelegate::HandleExternalProtocol,
resource_request.url));
net_service::ProxyURLLoaderFactory::CreateProxy(
web_contents_getter, std::move(receiver), std::move(request_handler));
@@ -1300,8 +1287,6 @@ void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) {
PopulateChromeFrameBinders(map);
CefBrowserFrame::RegisterBrowserInterfaceBindersForFrame(render_frame_host,
map);
if (!extensions::ExtensionsEnabled())
return;
@@ -1333,7 +1318,8 @@ AlloyContentBrowserClient::GetSandboxedStorageServiceDataDirectory() {
}
std::string AlloyContentBrowserClient::GetProduct() {
return embedder_support::GetProduct();
// Match the logic in chrome_content_browser_client.cc GetProduct().
return ::GetProduct();
}
std::string AlloyContentBrowserClient::GetChromeProduct() {
@@ -1341,7 +1327,8 @@ std::string AlloyContentBrowserClient::GetChromeProduct() {
}
std::string AlloyContentBrowserClient::GetUserAgent() {
return embedder_support::GetUserAgent();
// Match the logic in chrome_content_browser_client.cc GetUserAgent().
return ::GetUserAgent();
}
blink::UserAgentMetadata AlloyContentBrowserClient::GetUserAgentMetadata() {
@@ -1373,7 +1360,7 @@ bool AlloyContentBrowserClient::ArePersistentMediaDeviceIDsAllowed(
content::BrowserContext* browser_context,
const GURL& url,
const GURL& site_for_cookies,
const absl::optional<url::Origin>& top_frame_origin) {
const base::Optional<url::Origin>& top_frame_origin) {
// Persistent MediaDevice IDs are allowed if cookies are allowed.
return CookieSettingsFactory::GetForProfile(
Profile::FromBrowserContext(browser_context))

View File

@@ -101,7 +101,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
bool user_gesture,
bool opener_suppressed,
bool* no_javascript_access) override;
void OverrideWebkitPrefs(content::WebContents* web_contents,
void OverrideWebkitPrefs(content::RenderViewHost* rvh,
blink::web_pref::WebPreferences* prefs) override;
bool OverrideWebPreferencesAfterNavigation(
content::WebContents* web_contents,
@@ -109,8 +109,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
std::string GetDefaultDownloadName() override;
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
std::unique_ptr<content::DevToolsManagerDelegate>
CreateDevToolsManagerDelegate() override;
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
std::vector<std::unique_ptr<content::NavigationThrottle>>
CreateThrottlesForNavigation(
content::NavigationHandle* navigation_handle) override;
@@ -129,6 +128,11 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
content::PosixFileDescriptorInfo* mappings) override;
#endif
#if defined(OS_WIN)
bool PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) override;
#endif
void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
@@ -158,7 +162,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
base::Optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -173,19 +177,18 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
bool in_memory,
const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
cert_verifier::mojom::CertVerifierCreationParams*
cert_verifier_creation_params) override;
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params)
override;
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
bool HandleExternalProtocol(
const GURL& url,
content::WebContents::OnceGetter web_contents_getter,
int child_id,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
bool HandleExternalProtocol(
@@ -211,7 +214,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
content::BrowserContext* browser_context,
const GURL& scope,
const GURL& site_for_cookies,
const absl::optional<url::Origin>& top_frame_origin) override;
const base::Optional<url::Origin>& top_frame_origin) override;
bool ShouldAllowPluginCreation(
const url::Origin& embedder_origin,
const content::PepperPluginInfo& plugin_info) override;

View File

@@ -12,7 +12,6 @@
#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 "libcef/common/net/url_util.h"
#include "libcef/features/runtime_checks.h"
#include "base/logging.h"
@@ -59,20 +58,18 @@ content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
}
scoped_refptr<content::SiteInstance> site_instance;
if (extensions::ExtensionsEnabled() && !create_params.url.empty()) {
GURL gurl = url_util::MakeGURL(create_params.url, /*fixup=*/true);
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, gurl);
extensions::GetExtensionForUrl(browser_context, create_params.url);
}
if (create_params.extension) {
if (create_params.extension_host_type ==
extensions::mojom::ViewType::kInvalid) {
if (create_params.extension_host_type == extensions::VIEW_TYPE_INVALID) {
// Default to dialog behavior.
create_params.extension_host_type =
extensions::mojom::ViewType::kExtensionDialog;
extensions::VIEW_TYPE_EXTENSION_DIALOG;
}
// Extension resources will fail to load if we don't use a SiteInstance
@@ -82,7 +79,7 @@ content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
// ExtensionProtocolHandler::MaybeCreateJob will return false resulting in
// ERR_BLOCKED_BY_CLIENT).
site_instance = extensions::ProcessManager::Get(browser_context)
->GetSiteInstanceForURL(gurl);
->GetSiteInstanceForURL(create_params.url);
DCHECK(site_instance);
}
}
@@ -192,7 +189,7 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type) {
extensions::ViewType host_type) {
REQUIRE_ALLOY_RUNTIME();
DCHECK(primary_);
@@ -203,15 +200,14 @@ void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
auto alloy_browser = static_cast<AlloyBrowserHostImpl*>(browser_);
if (host_type == extensions::mojom::ViewType::kExtensionDialog ||
host_type == extensions::mojom::ViewType::kExtensionPopup) {
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(
alloy_browser, extension, web_contents_, url, host_type);
// Trigger load of the extension URL.
extension_host_->CreateRendererSoon();
} else if (host_type ==
extensions::mojom::ViewType::kExtensionBackgroundPage) {
extension_host_->CreateRenderViewSoon();
} else if (host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
is_background_host_ = true;
alloy_browser->is_background_host_ = true;
// Create an extension host that will be owned by ProcessManager.
@@ -379,12 +375,12 @@ void CefBrowserPlatformDelegateAlloy::PrintToPDF(
return;
printing::CefPrintViewManager::PdfPrintCallback pdf_callback;
if (callback.get()) {
pdf_callback = base::BindOnce(&CefPdfPrintCallback::OnPdfPrintFinished,
callback.get(), path);
pdf_callback = base::Bind(&CefPdfPrintCallback::OnPdfPrintFinished,
callback.get(), path);
}
GetPrintViewManager(actionable_contents)
->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path),
settings, std::move(pdf_callback));
settings, pdf_callback);
}
void CefBrowserPlatformDelegateAlloy::Find(int identifier,
@@ -453,7 +449,7 @@ void CefBrowserPlatformDelegateAlloy::DestroyExtensionHost() {
if (!extension_host_)
return;
if (extension_host_->extension_host_type() ==
extensions::mojom::ViewType::kExtensionBackgroundPage) {
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

View File

@@ -33,7 +33,7 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
void BrowserCreated(CefBrowserHostBase* browser) override;
void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type) override;
extensions::ViewType host_type) override;
extensions::ExtensionHost* GetExtensionHost() const override;
void BrowserDestroyed(CefBrowserHostBase* browser) override;
void SendCaptureLostEvent() override;

View File

@@ -128,6 +128,11 @@ metrics::MetricsService* ChromeBrowserProcessAlloy::metrics_service() {
return nullptr;
}
rappor::RapporServiceImpl* ChromeBrowserProcessAlloy::rappor_service() {
// Called from PluginInfoHostImpl::ReportMetrics.
return nullptr;
}
SystemNetworkContextManager*
ChromeBrowserProcessAlloy::system_network_context_manager() {
DCHECK(SystemNetworkContextManager::GetInstance());
@@ -320,6 +325,12 @@ ChromeBrowserProcessAlloy::floc_sorting_lsh_clusters_service() {
return nullptr;
}
optimization_guide::OptimizationGuideService*
ChromeBrowserProcessAlloy::optimization_guide_service() {
NOTREACHED();
return nullptr;
}
StartupData* ChromeBrowserProcessAlloy::startup_data() {
NOTREACHED();
return nullptr;

View File

@@ -44,6 +44,7 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
metrics_services_manager::MetricsServicesManager* GetMetricsServicesManager()
override;
metrics::MetricsService* metrics_service() override;
rappor::RapporServiceImpl* rappor_service() override;
SystemNetworkContextManager* system_network_context_manager() override;
network::NetworkQualityTracker* network_quality_tracker() override;
WatchDogThread* watchdog_thread() override;
@@ -83,6 +84,8 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
override;
federated_learning::FlocSortingLshClustersService*
floc_sorting_lsh_clusters_service() override;
optimization_guide::OptimizationGuideService* optimization_guide_service()
override;
StartupData* startup_data() override;
#if defined(OS_WIN) || defined(OS_LINUX)

View File

@@ -6,7 +6,6 @@
#include "libcef/browser/alloy/chrome_profile_alloy.h"
#include "base/no_destructor.h"
#include "components/profile_metrics/browser_profile_type.h"
#include "components/variations/variations_client.h"
#include "components/variations/variations_ids_provider.h"
#include "net/url_request/url_request_context.h"
@@ -36,10 +35,7 @@ class CefVariationsClient : public variations::VariationsClient {
} // namespace
ChromeProfileAlloy::ChromeProfileAlloy() {
profile_metrics::SetBrowserProfileType(
this, profile_metrics::BrowserProfileType::kRegular);
}
ChromeProfileAlloy::ChromeProfileAlloy() {}
ChromeProfileAlloy::~ChromeProfileAlloy() {}
@@ -48,15 +44,13 @@ bool ChromeProfileAlloy::IsOffTheRecord() {
}
bool ChromeProfileAlloy::IsOffTheRecord() const {
// Alloy contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false;
}
const Profile::OTRProfileID& ChromeProfileAlloy::GetOTRProfileID() const {
NOTREACHED();
static base::NoDestructor<Profile::OTRProfileID> otr_profile_id(
Profile::OTRProfileID::PrimaryID());
"ProfileImp::NoOTRProfileID");
return *otr_profile_id;
}
@@ -77,8 +71,7 @@ std::string ChromeProfileAlloy::GetProfileUserName() const {
}
Profile* ChromeProfileAlloy::GetOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id,
bool create_if_needed) {
const Profile::OTRProfileID& otr_profile_id) {
NOTREACHED();
return nullptr;
}
@@ -116,12 +109,21 @@ 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;
@@ -174,8 +176,3 @@ void ChromeProfileAlloy::SetCreationTimeForTesting(base::Time creation_time) {
void ChromeProfileAlloy::RecordMainFrameNavigation() {
NOTREACHED();
}
bool ChromeProfileAlloy::IsSignedIn() {
NOTREACHED();
return false;
}

View File

@@ -26,8 +26,8 @@ class ChromeProfileAlloy : public Profile {
variations::VariationsClient* GetVariationsClient() override;
scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override;
std::string GetProfileUserName() const override;
Profile* GetOffTheRecordProfile(const Profile::OTRProfileID& otr_profile_id,
bool create_if_needed) override;
Profile* GetOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) override;
std::vector<Profile*> GetAllOffTheRecordProfiles() override;
void DestroyOffTheRecordProfile(Profile* otr_profile) override;
bool HasOffTheRecordProfile(
@@ -37,7 +37,9 @@ class ChromeProfileAlloy : public Profile {
const Profile* GetOriginalProfile() const override;
bool IsSupervised() const override;
bool IsChild() const override;
bool IsLegacySupervised() const override;
ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
PrefService* GetOffTheRecordPrefs() override;
bool IsSameOrParent(Profile* profile) override;
base::Time GetStartTime() const override;
base::FilePath last_selected_directory() override;
@@ -49,7 +51,6 @@ class ChromeProfileAlloy : public Profile {
base::Time GetCreationTime() const override;
void SetCreationTimeForTesting(base::Time creation_time) override;
void RecordMainFrameNavigation() override;
bool IsSignedIn() override;
private:
std::unique_ptr<variations::VariationsClient> variations_client_;

View File

@@ -56,3 +56,10 @@ bool ChromeProfileManagerAlloy::IsValidProfile(const void* profile) {
return !!CefBrowserContext::FromBrowserContext(
static_cast<const content::BrowserContext*>(profile));
}
Profile* ChromeProfileManagerAlloy::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();
}

View File

@@ -18,6 +18,7 @@ class ChromeProfileManagerAlloy : public ProfileManager {
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);

View File

@@ -110,9 +110,7 @@ void CefAudioCapturer::Capture(const media::AudioBus* source,
pts.InMilliseconds());
}
void CefAudioCapturer::OnCaptureError(
media::AudioCapturerSource::ErrorCode code,
const std::string& message) {
void CefAudioCapturer::OnCaptureError(const std::string& message) {
audio_handler_->OnAudioStreamError(browser_, message);
StopStream();
}

View File

@@ -33,8 +33,7 @@ class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback {
base::TimeTicks audio_capture_time,
double volume,
bool key_pressed) override;
void OnCaptureError(media::AudioCapturerSource::ErrorCode code,
const std::string& message) override;
void OnCaptureError(const std::string& message) override;
void OnCaptureMuted(bool is_muted) override {}
void StopStream();

View File

@@ -44,7 +44,7 @@ class StreamCreatedCallbackAdapter final
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted,
const absl::optional<base::UnguessableToken>& stream_id) override {
const base::Optional<base::UnguessableToken>& stream_id) override {
DCHECK(!initially_muted); // Loopback streams shouldn't be started muted.
callback_.Run(std::move(stream), std::move(client_receiver),
std::move(data_pipe));

View File

@@ -8,7 +8,6 @@
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/browser_util.h"
#include "content/public/browser/focused_node_details.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/navigation_entry.h"
@@ -17,8 +16,6 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_view_host.h"
#include "third_party/blink/public/mojom/favicon/favicon_url.mojom.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
using content::KeyboardEventProcessingResult;
@@ -44,7 +41,9 @@ void CefBrowserContentsDelegate::ObserveWebContents(
content::Source<content::NavigationController>(
&new_contents->GetController()));
// Make sure RenderFrameCreated is called at least one time.
// Make sure RenderViewCreated is called at least one time.
RenderViewCreated(new_contents->GetRenderViewHost());
// Create the frame representation before OnAfterCreated is called for a new
// browser. Additionally, RenderFrameCreated is otherwise not called at all
// for new popup browsers.
@@ -71,12 +70,9 @@ content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) {
// May return nullptr for omnibox navigations.
auto frame = browser()->GetFrame(params.frame_tree_node_id);
if (!frame)
frame = browser()->GetMainFrame();
cancel = handler->OnOpenURLFromTab(
browser(), frame, params.url.spec(),
browser(), browser()->GetFrame(params.frame_tree_node_id),
params.url.spec(),
static_cast<cef_window_open_disposition_t>(params.disposition),
params.user_gesture);
}
@@ -111,7 +107,6 @@ void CefBrowserContentsDelegate::LoadingStateChanged(
if (auto c = client()) {
if (auto handler = c->GetLoadHandler()) {
auto navigation_lock = browser_info_->CreateNavigationLock();
handler->OnLoadingStateChange(browser(), is_loading, can_go_back,
can_go_forward);
}
@@ -130,9 +125,9 @@ void CefBrowserContentsDelegate::UpdateTargetURL(content::WebContents* source,
bool CefBrowserContentsDelegate::DidAddMessageToConsole(
content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) {
const base::string16& source_id) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
// Use LOGSEVERITY_DEBUG for unrecognized |level| values.
@@ -243,13 +238,6 @@ void CefBrowserContentsDelegate::RenderFrameHostChanged(
RenderFrameCreated(new_host);
}
void CefBrowserContentsDelegate::RenderFrameHostStateChanged(
content::RenderFrameHost* host,
content::RenderFrameHost::LifecycleState old_state,
content::RenderFrameHost::LifecycleState new_state) {
browser_info_->FrameHostStateChanged(host, old_state, new_state);
}
void CefBrowserContentsDelegate::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
const auto frame_id = CefFrameHostImpl::MakeFrameId(render_frame_host);
@@ -261,6 +249,28 @@ void CefBrowserContentsDelegate::RenderFrameDeleted(
}
}
void CefBrowserContentsDelegate::RenderViewCreated(
content::RenderViewHost* render_view_host) {
// May be already registered if the renderer crashed previously.
if (!registrar_->IsRegistered(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host))) {
registrar_->Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host));
}
}
void CefBrowserContentsDelegate::RenderViewDeleted(
content::RenderViewHost* render_view_host) {
if (registrar_->IsRegistered(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host))) {
registrar_->Remove(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host));
}
}
void CefBrowserContentsDelegate::RenderViewReady() {
if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) {
@@ -315,8 +325,7 @@ void CefBrowserContentsDelegate::OnFrameFocused(
OnStateChanged(State::kFocusedFrame);
}
void CefBrowserContentsDelegate::DocumentAvailableInMainFrame(
content::RenderFrameHost* render_frame_host) {
void CefBrowserContentsDelegate::DocumentAvailableInMainFrame() {
has_document_ = true;
OnStateChanged(State::kDocument);
@@ -412,6 +421,18 @@ void CefBrowserContentsDelegate::DidFailLoad(
OnLoadEnd(frame, validated_url, error_code);
}
bool CefBrowserContentsDelegate::OnMessageReceived(
const IPC::Message& message,
content::RenderFrameHost* render_frame_host) {
// Messages may arrive after a frame is detached. Ignore those messages.
auto frame = browser_info_->GetFrameForHost(render_frame_host);
if (frame) {
return static_cast<CefFrameHostImpl*>(frame.get())
->OnMessageReceived(message);
}
return false;
}
void CefBrowserContentsDelegate::TitleWasSet(content::NavigationEntry* entry) {
// |entry| may be NULL if a popup is created via window.open and never
// navigated.
@@ -458,13 +479,6 @@ void CefBrowserContentsDelegate::OnWebContentsFocused(
}
}
void CefBrowserContentsDelegate::OnFocusChangedInPage(
content::FocusedNodeDetails* details) {
focus_on_editable_field_ =
details->focus_type != blink::mojom::blink::FocusType::kNone &&
details->is_editable_node;
}
void CefBrowserContentsDelegate::WebContentsDestroyed() {
auto wc = web_contents();
ObserveWebContents(nullptr);
@@ -477,12 +491,15 @@ void CefBrowserContentsDelegate::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(type, content::NOTIFICATION_LOAD_STOP);
DCHECK(type == content::NOTIFICATION_LOAD_STOP ||
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE);
if (type == content::NOTIFICATION_LOAD_STOP) {
content::NavigationController* controller =
content::Source<content::NavigationController>(source).ptr();
OnTitleChange(controller->GetWebContents()->GetTitle());
} else if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) {
focus_on_editable_field_ = *content::Details<bool>(details).ptr();
}
}
@@ -491,7 +508,6 @@ void CefBrowserContentsDelegate::OnLoadEnd(CefRefPtr<CefFrame> frame,
int http_status_code) {
if (auto c = client()) {
if (auto handler = c->GetLoadHandler()) {
auto navigation_lock = browser_info_->CreateNavigationLock();
handler->OnLoadEnd(browser(), frame, http_status_code);
}
}
@@ -550,7 +566,6 @@ void CefBrowserContentsDelegate::OnLoadStart(
ui::PageTransition transition_type) {
if (auto c = client()) {
if (auto handler = c->GetLoadHandler()) {
auto navigation_lock = browser_info_->CreateNavigationLock();
// On the handler that loading has started.
handler->OnLoadStart(browser(), frame,
static_cast<cef_transition_type_t>(transition_type));
@@ -572,7 +587,7 @@ void CefBrowserContentsDelegate::OnLoadError(CefRefPtr<CefFrame> frame,
}
}
void CefBrowserContentsDelegate::OnTitleChange(const std::u16string& title) {
void CefBrowserContentsDelegate::OnTitleChange(const base::string16& title) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
handler->OnTitleChange(browser(), title);

View File

@@ -10,7 +10,6 @@
#include "libcef/browser/frame_host_impl.h"
#include "base/callback_list.h"
#include "base/observer_list.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -88,9 +87,9 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
bool DidAddMessageToConsole(content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) override;
const base::string16& source_id) override;
void DidNavigateMainFramePostCommit(
content::WebContents* web_contents) override;
void EnterFullscreenModeForTab(
@@ -108,16 +107,13 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
content::RenderFrameHost* new_host) override;
void RenderFrameHostStateChanged(
content::RenderFrameHost* host,
content::RenderFrameHost::LifecycleState old_state,
content::RenderFrameHost::LifecycleState new_state) override;
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
void RenderViewReady() override;
void RenderProcessGone(base::TerminationStatus status) override;
void OnFrameFocused(content::RenderFrameHost* render_frame_host) override;
void DocumentAvailableInMainFrame(
content::RenderFrameHost* render_frame_host) override;
void DocumentAvailableInMainFrame() override;
void LoadProgressChanged(double progress) override;
void DidStopLoading() override;
void DidFinishNavigation(
@@ -125,6 +121,8 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void DidFailLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code) override;
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
void TitleWasSet(content::NavigationEntry* entry) override;
void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override;
@@ -133,7 +131,6 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
void OnWebContentsFocused(
content::RenderWidgetHost* render_widget_host) override;
void OnFocusChangedInPage(content::FocusedNodeDetails* details) override;
void WebContentsDestroyed() override;
// NotificationObserver methods.
@@ -167,7 +164,7 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void OnLoadStart(CefRefPtr<CefFrame> frame,
ui::PageTransition transition_type);
void OnLoadError(CefRefPtr<CefFrame> frame, const GURL& url, int error_code);
void OnTitleChange(const std::u16string& title);
void OnTitleChange(const base::string16& title);
void OnFullscreenModeChange(bool fullscreen);
void OnStateChanged(State state_changed);

View File

@@ -7,20 +7,16 @@
#include <map>
#include <utility>
#include "libcef/browser/context.h"
#include "libcef/browser/iothread_state.h"
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/features/runtime.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
@@ -145,28 +141,6 @@ CefBrowserContext* GetSelf(base::WeakPtr<CefBrowserContext> self) {
return self.get();
}
CefBrowserContext::CookieableSchemes MakeSupportedSchemes(
const CefString& schemes_list,
bool include_defaults) {
std::vector<std::string> all_schemes;
if (!schemes_list.empty()) {
all_schemes =
base::SplitString(schemes_list.ToString(), std::string(","),
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
}
if (include_defaults) {
// Add default schemes that should always support cookies.
// This list should match CookieMonster::kDefaultCookieableSchemes.
all_schemes.push_back("http");
all_schemes.push_back("https");
all_schemes.push_back("ws");
all_schemes.push_back("wss");
}
return base::make_optional(all_schemes);
}
} // namespace
CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings)
@@ -180,6 +154,13 @@ CefBrowserContext::~CefBrowserContext() {
#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() {
@@ -188,14 +169,7 @@ void CefBrowserContext::Initialize() {
if (!cache_path_.empty())
g_manager.Get().SetImplPath(this, cache_path_);
iothread_state_ = base::MakeRefCounted<CefIOThreadState>();
if (settings_.cookieable_schemes_list.length > 0 ||
settings_.cookieable_schemes_exclude_defaults) {
cookieable_schemes_ =
MakeSupportedSchemes(CefString(&settings_.cookieable_schemes_list),
!settings_.cookieable_schemes_exclude_defaults);
}
iothread_state_ = std::make_unique<CefIOThreadState>();
}
void CefBrowserContext::Shutdown() {
@@ -229,9 +203,7 @@ void CefBrowserContext::RemoveCefRequestContext(
// Delete ourselves when the reference count reaches zero.
if (request_context_set_.empty()) {
Shutdown();
// Allow the current call stack to unwind before deleting |this|.
content::BrowserThread::DeleteSoon(CEF_UIT, FROM_HERE, this);
delete this;
}
}
@@ -257,25 +229,6 @@ CefBrowserContext* CefBrowserContext::FromBrowserContext(
return g_manager.Get().GetImplFromBrowserContext(context);
}
// static
CefBrowserContext* CefBrowserContext::FromProfile(const Profile* profile) {
auto* cef_context = FromBrowserContext(profile);
if (cef_context)
return cef_context;
if (cef::IsChromeRuntimeEnabled()) {
auto* original_profile = profile->GetOriginalProfile();
if (original_profile != profile) {
// With the Chrome runtime if the user launches an incognito window via
// the UI we might be associated with the original Profile instead of the
// (current) incognito profile.
return FromBrowserContext(original_profile);
}
}
return nullptr;
}
// static
std::vector<CefBrowserContext*> CefBrowserContext::GetAll() {
return g_manager.Get().GetAllImpl();
@@ -301,10 +254,15 @@ void CefBrowserContext::OnRenderFrameCreated(
handler_map_.AddHandler(render_process_id, render_frame_id,
frame_tree_node_id, handler);
CEF_POST_TASK(CEF_IOT,
base::BindOnce(&CefIOThreadState::AddHandler, iothread_state_,
render_process_id, render_frame_id,
frame_tree_node_id, handler));
if (iothread_state_) {
// Using base::Unretained() is safe because both this callback and
// possible deletion of |iothread_state_| 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));
}
}
}
@@ -334,9 +292,15 @@ void CefBrowserContext::OnRenderFrameDeleted(
handler_map_.RemoveHandler(render_process_id, render_frame_id,
frame_tree_node_id);
CEF_POST_TASK(CEF_IOT, base::BindOnce(&CefIOThreadState::RemoveHandler,
iothread_state_, render_process_id,
render_frame_id, frame_tree_node_id));
if (iothread_state_) {
// Using base::Unretained() is safe because both this callback and
// possible deletion of |iothread_state_| 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));
}
}
if (is_main_frame) {
@@ -440,16 +404,26 @@ void CefBrowserContext::RegisterSchemeHandlerFactory(
const CefString& scheme_name,
const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory) {
CEF_POST_TASK(
CEF_IOT,
base::BindOnce(&CefIOThreadState::RegisterSchemeHandlerFactory,
iothread_state_, scheme_name, domain_name, factory));
if (iothread_state_) {
// Using base::Unretained() is safe because both this callback and possible
// deletion of |iothread_state_| 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()),
scheme_name, domain_name, factory));
}
}
void CefBrowserContext::ClearSchemeHandlerFactories() {
CEF_POST_TASK(CEF_IOT,
base::BindOnce(&CefIOThreadState::ClearSchemeHandlerFactories,
iothread_state_));
if (iothread_state_) {
// Using base::Unretained() is safe because both this callback and possible
// deletion of |iothread_state_| 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())));
}
}
void CefBrowserContext::LoadExtension(
@@ -485,7 +459,8 @@ bool CefBrowserContext::IsPrintPreviewSupported() const {
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
CEF_REQUIRE_UIT();
auto browser_context = AsBrowserContext();
return browser_context->GetDefaultStoragePartition()->GetNetworkContext();
return browser_context->GetDefaultStoragePartition(browser_context)
->GetNetworkContext();
}
CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
@@ -502,24 +477,5 @@ CefBrowserContext::CookieableSchemes CefBrowserContext::GetCookieableSchemes()
if (cookieable_schemes_)
return cookieable_schemes_;
return GetGlobalCookieableSchemes();
}
// static
CefBrowserContext::CookieableSchemes
CefBrowserContext::GetGlobalCookieableSchemes() {
CEF_REQUIRE_UIT();
static base::NoDestructor<CookieableSchemes> schemes(
[]() -> CookieableSchemes {
const auto& settings = CefContext::Get()->settings();
if (settings.cookieable_schemes_list.length > 0 ||
settings.cookieable_schemes_exclude_defaults) {
return MakeSupportedSchemes(
CefString(&settings.cookieable_schemes_list),
!settings.cookieable_schemes_exclude_defaults);
}
return absl::nullopt;
}());
return *schemes;
return CefCookieManagerImpl::GetGlobalCookieableSchemes();
}

View File

@@ -10,16 +10,14 @@
#include <vector>
#include "include/cef_request_context_handler.h"
#include "libcef/browser/iothread_state.h"
#include "libcef/browser/request_context_handler_map.h"
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/optional.h"
#include "chrome/common/plugin.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/origin.h"
/*
@@ -82,6 +80,7 @@ class BrowserContext;
class CefMediaRouterManager;
class CefRequestContextImpl;
class CefIOThreadState;
class Profile;
// Main entry point for configuring behavior on a per-RequestContext basis. The
@@ -104,7 +103,6 @@ class CefBrowserContext {
// Returns the underlying CefBrowserContext if any.
static CefBrowserContext* FromBrowserContext(
const content::BrowserContext* context);
static CefBrowserContext* FromProfile(const Profile* profile);
// Returns all existing CefBrowserContext.
static std::vector<CefBrowserContext*> GetAll();
@@ -113,13 +111,6 @@ class CefBrowserContext {
virtual content::BrowserContext* AsBrowserContext() = 0;
virtual Profile* AsProfile() = 0;
// Returns true if the context is fully initialized.
virtual bool IsInitialized() const = 0;
// If the context is fully initialized execute |callback|, otherwise
// store it until the context is fully initialized.
virtual void StoreOrTriggerInitCallback(base::OnceClosure callback) = 0;
// Called from CefRequestContextImpl to track associated objects. This
// object will delete itself when the count reaches zero.
void AddCefRequestContext(CefRequestContextImpl* context);
@@ -201,20 +192,22 @@ class CefBrowserContext {
CefMediaRouterManager* GetMediaRouterManager();
using CookieableSchemes = absl::optional<std::vector<std::string>>;
using CookieableSchemes = base::Optional<std::vector<std::string>>;
// Returns the schemes associated with this context specifically, or the
// global configuration if unset.
CookieableSchemes GetCookieableSchemes() const;
static CookieableSchemes GetGlobalCookieableSchemes();
// Set the schemes associated with this context specifically.
void set_cookieable_schemes(const CookieableSchemes& schemes) {
cookieable_schemes_ = 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_; }
scoped_refptr<CefIOThreadState> iothread_state() const {
return iothread_state_;
}
CefIOThreadState* iothread_state() const { return iothread_state_.get(); }
// Used to hold a WeakPtr reference to this this object. The Getter returns
// nullptr if this object has already been destroyed.
@@ -237,10 +230,7 @@ class CefBrowserContext {
base::FilePath cache_path_;
private:
// For DeleteSoon().
friend class base::DeleteHelper<CefBrowserContext>;
scoped_refptr<CefIOThreadState> iothread_state_;
std::unique_ptr<CefIOThreadState> iothread_state_;
CookieableSchemes cookieable_schemes_;
std::unique_ptr<CefMediaRouterManager> media_router_manager_;

View File

@@ -1,77 +0,0 @@
// Copyright 2021 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/browser_frame.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/thread_util.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
CefBrowserFrame::CefBrowserFrame(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<cef::mojom::BrowserFrame> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)) {}
CefBrowserFrame::~CefBrowserFrame() = default;
// static
void CefBrowserFrame::RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) {
map->Add<cef::mojom::BrowserFrame>(base::BindRepeating(
[](content::RenderFrameHost* frame_host,
mojo::PendingReceiver<cef::mojom::BrowserFrame> receiver) {
// This object is bound to the lifetime of |frame_host| and the mojo
// connection. See FrameServiceBase for details.
new CefBrowserFrame(frame_host, std::move(receiver));
}));
}
void CefBrowserFrame::SendMessage(const std::string& name,
base::Value arguments) {
// Always associate with the newly created RFH, which may be speculative when
// navigating cross-origin.
if (auto host = GetFrameHost(/*prefer_speculative=*/true)) {
host->SendMessage(name, std::move(arguments));
}
}
void CefBrowserFrame::FrameAttached() {
// Always send to the newly created RFH, which may be speculative when
// navigating cross-origin.
if (auto host = GetFrameHost(/*prefer_speculative=*/true)) {
host->FrameAttached();
}
}
void CefBrowserFrame::DidFinishFrameLoad(const GURL& validated_url,
int http_status_code) {
if (auto host = GetFrameHost()) {
host->DidFinishFrameLoad(validated_url, http_status_code);
}
}
void CefBrowserFrame::UpdateDraggableRegions(
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) {
if (auto host = GetFrameHost()) {
host->UpdateDraggableRegions(std::move(regions));
}
}
CefRefPtr<CefFrameHostImpl> CefBrowserFrame::GetFrameHost(
bool prefer_speculative) const {
CEF_REQUIRE_UIT();
auto rfh = render_frame_host();
if (auto browser = CefBrowserHostBase::GetBrowserForHost(rfh)) {
return browser->browser_info()->GetFrameForHost(rfh, nullptr,
prefer_speculative);
}
NOTREACHED();
return nullptr;
}

View File

@@ -1,51 +0,0 @@
// Copyright 2021 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_BROWSER_FRAME_H_
#define CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_
#pragma once
#include "libcef/browser/frame_host_impl.h"
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "content/public/browser/frame_service_base.h"
#include "mojo/public/cpp/bindings/binder_map.h"
// Implementation of the BrowserFrame mojo interface.
// This is implemented separately from CefFrameHostImpl to better manage the
// association with the RenderFrameHost (which may be speculative, etc.), and so
// that messages are always routed to the most appropriate CefFrameHostImpl
// instance. Lifespan is tied to the RFH via FrameServiceBase.
class CefBrowserFrame
: public content::FrameServiceBase<cef::mojom::BrowserFrame> {
public:
CefBrowserFrame(content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<cef::mojom::BrowserFrame> receiver);
~CefBrowserFrame() override;
// Called from the ContentBrowserClient method of the same name.
static void RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map);
private:
// cef::mojom::BrowserFrame methods:
void SendMessage(const std::string& name, base::Value arguments) override;
void FrameAttached() override;
void DidFinishFrameLoad(const GURL& validated_url,
int32_t http_status_code) override;
void UpdateDraggableRegions(
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions)
override;
// FrameServiceBase methods:
bool ShouldCloseOnFinishNavigation() const override { return false; }
CefRefPtr<CefFrameHostImpl> GetFrameHost(
bool prefer_speculative = false) const;
DISALLOW_COPY_AND_ASSIGN(CefBrowserFrame);
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_

View File

@@ -6,17 +6,16 @@
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
#include "libcef/browser/image_impl.h"
#include "libcef/browser/navigation_entry_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/net/url_util.h"
#include "base/logging.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "components/favicon/core/favicon_url.h"
#include "components/spellcheck/common/spellcheck_features.h"
#include "components/url_formatter/url_fixer.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/download_request_utils.h"
@@ -164,8 +163,7 @@ CefBrowserHostBase::CefBrowserHostBase(
client_(client),
platform_delegate_(std::move(platform_delegate)),
browser_info_(browser_info),
request_context_(request_context),
is_views_hosted_(platform_delegate_->IsViewsHosted()) {
request_context_(request_context) {
CEF_REQUIRE_UIT();
DCHECK(!browser_info_->browser().get());
browser_info_->SetBrowser(this);
@@ -186,8 +184,6 @@ void CefBrowserHostBase::InitializeBrowser() {
void CefBrowserHostBase::DestroyBrowser() {
CEF_REQUIRE_UIT();
devtools_manager_.reset(nullptr);
platform_delegate_.reset(nullptr);
contents_delegate_->RemoveObserver(this);
@@ -209,10 +205,6 @@ CefRefPtr<CefRequestContext> CefBrowserHostBase::GetRequestContext() {
return request_context_;
}
bool CefBrowserHostBase::HasView() {
return is_views_hosted_;
}
void CefBrowserHostBase::StartDownload(const CefString& url) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
@@ -232,7 +224,8 @@ void CefBrowserHostBase::StartDownload(const CefString& url) {
if (!browser_context)
return;
content::DownloadManager* manager = browser_context->GetDownloadManager();
content::DownloadManager* manager =
content::BrowserContext::GetDownloadManager(browser_context);
if (!manager)
return;
@@ -291,54 +284,6 @@ void CefBrowserHostBase::DownloadImage(
max_image_size, callback));
}
bool CefBrowserHostBase::SendDevToolsMessage(const void* message,
size_t message_size) {
if (!message || message_size == 0)
return false;
if (!CEF_CURRENTLY_ON_UIT()) {
std::string message_str(static_cast<const char*>(message), message_size);
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
[](CefRefPtr<CefBrowserHostBase> self, std::string message_str) {
self->SendDevToolsMessage(message_str.data(), message_str.size());
},
CefRefPtr<CefBrowserHostBase>(this), std::move(message_str)));
return false;
}
if (!EnsureDevToolsManager())
return false;
return devtools_manager_->SendDevToolsMessage(message, message_size);
}
int CefBrowserHostBase::ExecuteDevToolsMethod(
int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT, base::BindOnce(base::IgnoreResult(
&CefBrowserHostBase::ExecuteDevToolsMethod),
this, message_id, method, params));
return 0;
}
if (!EnsureDevToolsManager())
return 0;
return devtools_manager_->ExecuteDevToolsMethod(message_id, method, params);
}
CefRefPtr<CefRegistration> CefBrowserHostBase::AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) {
if (!observer)
return nullptr;
auto registration = CefDevToolsManager::CreateRegistration(observer);
InitializeDevToolsRegistrationOnUIThread(registration);
return registration.get();
}
void CefBrowserHostBase::GetNavigationEntries(
CefRefPtr<CefNavigationEntryVisitor> visitor,
bool current_only) {
@@ -366,7 +311,7 @@ void CefBrowserHostBase::GetNavigationEntries(
CefRefPtr<CefNavigationEntryImpl> entry =
new CefNavigationEntryImpl(controller.GetEntryAtIndex(current));
visitor->Visit(entry.get(), true, current, total);
ignore_result(entry->Detach(nullptr));
entry->Detach(nullptr);
} else {
// Visit all entries.
bool cont = true;
@@ -374,7 +319,7 @@ void CefBrowserHostBase::GetNavigationEntries(
CefRefPtr<CefNavigationEntryImpl> entry =
new CefNavigationEntryImpl(controller.GetEntryAtIndex(i));
cont = visitor->Visit(entry.get(), (i == current), i, total);
ignore_result(entry->Detach(nullptr));
entry->Detach(nullptr);
}
}
}
@@ -496,10 +441,6 @@ void CefBrowserHostBase::SendMouseWheelEvent(const CefMouseEvent& event,
}
}
bool CefBrowserHostBase::IsValid() {
return browser_info_->browser() == this;
}
CefRefPtr<CefBrowserHost> CefBrowserHostBase::GetHost() {
return this;
}
@@ -765,9 +706,16 @@ bool CefBrowserHostBase::Navigate(const content::OpenURLParams& params) {
CEF_REQUIRE_UIT();
auto web_contents = GetWebContents();
if (web_contents) {
GURL gurl = params.url;
if (!url_util::FixupGURL(gurl))
// Fix common problems with user-typed text. Among other things, this:
// - Converts absolute file paths to "file://" URLs.
// - Normalizes "about:" and "chrome:" to "chrome://" URLs.
// - Adds the "http://" scheme if none was specified.
GURL gurl = url_formatter::FixupURL(params.url.possibly_invalid_spec(),
std::string());
if (!gurl.is_valid()) {
LOG(ERROR) << "Invalid URL: " << params.url.possibly_invalid_spec();
return false;
}
web_contents->GetController().LoadURL(
gurl, params.referrer, params.transition, params.extra_headers);
@@ -830,16 +778,6 @@ int CefBrowserHostBase::browser_id() const {
return browser_info_->browser_id();
}
SkColor CefBrowserHostBase::GetBackgroundColor() const {
// Don't use |platform_delegate_| because it's not thread-safe.
return CefContext::Get()->GetBackgroundColor(
&settings_, IsWindowless() ? STATE_ENABLED : STATE_DISABLED);
}
bool CefBrowserHostBase::IsWindowless() const {
return false;
}
content::WebContents* CefBrowserHostBase::GetWebContents() const {
CEF_REQUIRE_UIT();
return contents_delegate_->web_contents();
@@ -852,46 +790,3 @@ content::BrowserContext* CefBrowserHostBase::GetBrowserContext() const {
return web_contents->GetBrowserContext();
return nullptr;
}
#if defined(TOOLKIT_VIEWS)
views::Widget* CefBrowserHostBase::GetWindowWidget() const {
CEF_REQUIRE_UIT();
if (!platform_delegate_)
return nullptr;
return platform_delegate_->GetWindowWidget();
}
CefRefPtr<CefBrowserView> CefBrowserHostBase::GetBrowserView() const {
CEF_REQUIRE_UIT();
if (is_views_hosted_ && platform_delegate_)
return platform_delegate_->GetBrowserView();
return nullptr;
}
#endif // defined(TOOLKIT_VIEWS)
bool CefBrowserHostBase::EnsureDevToolsManager() {
CEF_REQUIRE_UIT();
if (!contents_delegate_->web_contents())
return false;
if (!devtools_manager_) {
devtools_manager_.reset(new CefDevToolsManager(this));
}
return true;
}
void CefBrowserHostBase::InitializeDevToolsRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
&CefBrowserHostBase::InitializeDevToolsRegistrationOnUIThread, this,
registration));
return;
}
if (!EnsureDevToolsManager())
return;
devtools_manager_->InitializeRegistrationOnUIThread(registration);
}

View File

@@ -12,13 +12,12 @@
#include "libcef/browser/browser_contents_delegate.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/devtools/devtools_manager.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/request_context_impl.h"
#include "base/observer_list.h"
#include "base/synchronization/lock.h"
#include "extensions/common/mojom/view_type.mojom.h"
#include "extensions/common/view_type.h"
namespace extensions {
class Extension;
@@ -39,9 +38,6 @@ struct CefBrowserCreateParams {
settings = that.settings;
request_context = that.request_context;
extra_info = that.extra_info;
#if defined(TOOLKIT_VIEWS)
browser_view = that.browser_view;
#endif
return *this;
}
@@ -49,15 +45,11 @@ struct CefBrowserCreateParams {
// views-hosted browser. Currently used with the alloy runtime only.
std::unique_ptr<CefWindowInfo> window_info;
#if defined(TOOLKIT_VIEWS)
// The BrowserView that will own a Views-hosted browser. Will be nullptr for
// popup browsers.
#if defined(USE_AURA)
// The BrowserView that will own a views-hosted browser. Will be nullptr for
// popup browsers (the BrowserView will be created later in that case).
// Currently used with the alloy runtime only.
CefRefPtr<CefBrowserView> browser_view;
// True if this browser is a popup and has a Views-hosted opener, in which
// case the BrowserView for this browser will be created later (from
// PopupWebContentsCreated).
bool popup_with_views_hosted_opener = false;
#endif
// Client implementation. May be nullptr.
@@ -65,7 +57,7 @@ struct CefBrowserCreateParams {
// Initial URL to load. May be empty. If this is a valid extension URL then
// the browser will be created as an app view extension host.
CefString url;
GURL url;
// Browser settings.
CefBrowserSettings settings;
@@ -86,8 +78,7 @@ struct CefBrowserCreateParams {
// ProcessManager::CreateBackgroundHost. Currently used with the alloy
// runtime only.
const extensions::Extension* extension = nullptr;
extensions::mojom::ViewType extension_host_type =
extensions::mojom::ViewType::kInvalid;
extensions::ViewType extension_host_type = extensions::VIEW_TYPE_INVALID;
};
// Base class for CefBrowserHost implementations. Includes functionality that is
@@ -109,11 +100,6 @@ class CefBrowserHostBase : public CefBrowserHost,
virtual ~Observer() {}
};
// Create a new CefBrowserHost instance of the current runtime type with
// owned WebContents.
static CefRefPtr<CefBrowserHostBase> Create(
CefBrowserCreateParams& create_params);
// Returns the browser associated with the specified RenderViewHost.
static CefRefPtr<CefBrowserHostBase> GetBrowserForHost(
const content::RenderViewHost* host);
@@ -141,10 +127,6 @@ class CefBrowserHostBase : public CefBrowserHost,
// Called on the UI thread after the associated WebContents is created.
virtual void InitializeBrowser();
// Called on the UI thread when the OS window hosting the browser is
// destroyed.
virtual void WindowDestroyed() = 0;
// Called on the UI thread after the associated WebContents is destroyed.
// Also called from CefBrowserInfoManager::DestroyAllBrowsers if the browser
// was not properly shut down.
@@ -154,7 +136,6 @@ class CefBrowserHostBase : public CefBrowserHost,
CefRefPtr<CefBrowser> GetBrowser() override;
CefRefPtr<CefClient> GetClient() override;
CefRefPtr<CefRequestContext> GetRequestContext() override;
bool HasView() override;
void StartDownload(const CefString& url) override;
void DownloadImage(const CefString& image_url,
bool is_favicon,
@@ -172,18 +153,11 @@ class CefBrowserHostBase : public CefBrowserHost,
void SendMouseWheelEvent(const CefMouseEvent& event,
int deltaX,
int deltaY) override;
bool SendDevToolsMessage(const void* message, size_t message_size) override;
int ExecuteDevToolsMethod(int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) override;
CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) override;
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
bool current_only) override;
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
// CefBrowser methods:
bool IsValid() override;
CefRefPtr<CefBrowserHost> GetHost() override;
bool CanGoBack() override;
void GoBack() override;
@@ -247,11 +221,6 @@ class CefBrowserHostBase : public CefBrowserHost,
CefRefPtr<CefRequestContextImpl> request_context() const {
return request_context_;
}
bool is_views_hosted() const { return is_views_hosted_; }
SkColor GetBackgroundColor() const;
// Returns true if windowless rendering is enabled.
virtual bool IsWindowless() const;
// Accessors that must be called on the UI thread.
content::WebContents* GetWebContents() const;
@@ -263,21 +232,7 @@ class CefBrowserHostBase : public CefBrowserHost,
return contents_delegate_.get();
}
#if defined(TOOLKIT_VIEWS)
// Returns the Widget owner for the browser window. Only used with windowed
// rendering.
views::Widget* GetWindowWidget() const;
// Returns the BrowserView associated with this browser. Only used with Views-
// based browsers.
CefRefPtr<CefBrowserView> GetBrowserView() const;
#endif
protected:
bool EnsureDevToolsManager();
void InitializeDevToolsRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration);
// Called from LoadMainFrameURL to perform the actual navigation.
virtual bool Navigate(const content::OpenURLParams& params);
@@ -287,7 +242,6 @@ class CefBrowserHostBase : public CefBrowserHost,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate_;
scoped_refptr<CefBrowserInfo> browser_info_;
CefRefPtr<CefRequestContextImpl> request_context_;
const bool is_views_hosted_;
// Only accessed on the UI thread.
std::unique_ptr<CefBrowserContentsDelegate> contents_delegate_;
@@ -306,9 +260,6 @@ class CefBrowserHostBase : public CefBrowserHost,
bool is_fullscreen_ = false;
CefRefPtr<CefFrameHostImpl> focused_frame_;
// Used for creating and managing DevTools instances.
std::unique_ptr<CefDevToolsManager> devtools_manager_;
private:
IMPLEMENT_REFCOUNTING(CefBrowserHostBase);
DISALLOW_COPY_AND_ASSIGN(CefBrowserHostBase);

View File

@@ -27,11 +27,6 @@ class CreateBrowserHelper {
extra_info_(extra_info),
request_context_(request_context) {}
void Run() {
CefBrowserHost::CreateBrowserSync(window_info_, client_, url_, settings_,
extra_info_, request_context_);
}
CefWindowInfo window_info_;
CefRefPtr<CefClient> client_;
CefString url_;
@@ -76,25 +71,19 @@ bool CefBrowserHost::CreateBrowser(
"reduced performance or runtime errors.";
}
if (!request_context) {
request_context = CefRequestContext::GetGlobalContext();
}
auto helper = std::make_unique<CreateBrowserHelper>(
// Create the browser on the UI thread.
CreateBrowserHelper* helper = new CreateBrowserHelper(
windowInfo, client, url, settings, extra_info, request_context);
auto request_context_impl =
static_cast<CefRequestContextImpl*>(request_context.get());
// Wait for the browser context to be initialized before creating the browser.
request_context_impl->ExecuteWhenBrowserContextInitialized(base::BindOnce(
[](std::unique_ptr<CreateBrowserHelper> helper) {
// Always execute asynchronously to avoid potential issues if we're
// being called synchronously during app initialization.
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CreateBrowserHelper::Run,
std::move(helper)));
},
std::move(helper)));
CEF_POST_TASK(CEF_UIT, base::BindOnce(
[](CreateBrowserHelper* helper) {
CefBrowserHost::CreateBrowserSync(
helper->window_info_, helper->client_,
helper->url_, helper->settings_,
helper->extra_info_,
helper->request_context_);
delete helper;
},
helper));
return true;
}
@@ -119,14 +108,9 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
return nullptr;
}
if (!request_context) {
request_context = CefRequestContext::GetGlobalContext();
}
// Verify that the browser context is valid.
auto request_context_impl =
static_cast<CefRequestContextImpl*>(request_context.get());
if (!request_context_impl->VerifyBrowserContext()) {
// Verify that this method is being called on the UI thread.
if (!CEF_CURRENTLY_ON_UIT()) {
NOTREACHED() << "called on invalid thread";
return nullptr;
}
@@ -140,17 +124,16 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
CefBrowserCreateParams create_params;
create_params.window_info.reset(new CefWindowInfo(windowInfo));
create_params.client = client;
create_params.url = url;
create_params.url = GURL(url.ToString());
if (!url.empty() && !create_params.url.is_valid() &&
!create_params.url.has_scheme()) {
std::string new_url = std::string("http://") + url.ToString();
create_params.url = GURL(new_url);
}
create_params.settings = settings;
create_params.extra_info = extra_info;
create_params.request_context = request_context;
return CefBrowserHostBase::Create(create_params);
}
// static
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::Create(
CefBrowserCreateParams& create_params) {
if (cef::IsChromeRuntimeEnabled()) {
auto browser = ChromeBrowserHostImpl::Create(create_params);
return browser.get();

View File

@@ -15,12 +15,10 @@
#include "ipc/ipc_message.h"
CefBrowserInfo::FrameInfo::~FrameInfo() {
#if DCHECK_IS_ON()
if (frame_ && !IsCurrentMainFrame()) {
// Should already be Detached.
DCHECK(!frame_->GetRenderFrameHost());
if (frame_ && !is_main_frame_) {
// Disassociate sub-frames from the browser.
frame_->Detach();
}
#endif
}
CefBrowserInfo::CefBrowserInfo(int browser_id,
@@ -34,9 +32,7 @@ CefBrowserInfo::CefBrowserInfo(int browser_id,
DCHECK_GT(browser_id, 0);
}
CefBrowserInfo::~CefBrowserInfo() {
DCHECK(frame_info_set_.empty());
}
CefBrowserInfo::~CefBrowserInfo() {}
CefRefPtr<CefBrowserHostBase> CefBrowserInfo::browser() const {
base::AutoLock lock_scope(lock_);
@@ -44,29 +40,11 @@ CefRefPtr<CefBrowserHostBase> CefBrowserInfo::browser() const {
}
void CefBrowserInfo::SetBrowser(CefRefPtr<CefBrowserHostBase> browser) {
NotificationStateLock lock_scope(this);
if (browser) {
DCHECK(!browser_);
// Cache the associated frame handler.
if (auto client = browser->GetClient()) {
frame_handler_ = client->GetFrameHandler();
}
} else {
DCHECK(browser_);
}
auto old_browser = browser_;
base::AutoLock lock_scope(lock_);
browser_ = browser;
if (!browser_) {
RemoveAllFrames(old_browser);
// Any future calls to MaybeExecuteFrameNotification will now fail.
// NotificationStateLock already took a reference for the delivery of any
// notifications that are currently queued due to RemoveAllFrames.
frame_handler_ = nullptr;
if (!browser) {
RemoveAllFrames();
}
}
@@ -90,7 +68,7 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
->render_manager()
->current_frame_host() != host);
NotificationStateLock lock_scope(this);
base::AutoLock lock_scope(lock_);
DCHECK(browser_);
const auto it = frame_id_map_.find(frame_id);
@@ -108,8 +86,14 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
if (!info->is_guest_view_ && info->is_speculative_ && !is_speculative) {
// Upgrade the frame info from speculative to non-speculative.
if (info->is_main_frame_) {
// Set the main frame object.
SetMainFrame(browser_, info->frame_);
if (main_frame_) {
// Update the existing main frame object.
main_frame_->SetRenderFrameHost(host);
info->frame_ = main_frame_;
} else {
// Set the main frame object.
main_frame_ = info->frame_;
}
}
info->is_speculative_ = false;
MaybeUpdateFrameTreeNodeIdMap(info);
@@ -127,13 +111,17 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
// Guest views don't get their own CefBrowser or CefFrame objects.
if (!is_guest_view) {
// Create a new frame object.
frame_info->frame_ = new CefFrameHostImpl(this, host);
MaybeNotifyFrameCreated(frame_info->frame_);
if (is_main_frame && !is_speculative) {
SetMainFrame(browser_, frame_info->frame_);
if (is_main_frame && main_frame_ && !is_speculative) {
// Update the existing main frame object.
main_frame_->SetRenderFrameHost(host);
frame_info->frame_ = main_frame_;
} else {
// Create a new frame object.
frame_info->frame_ = new CefFrameHostImpl(this, host);
if (is_main_frame && !is_speculative) {
main_frame_ = frame_info->frame_;
}
}
#if DCHECK_IS_ON()
// Check that the frame info hasn't changed unexpectedly.
DCHECK_EQ(frame_id, frame_info->frame_->GetIdentifier());
@@ -153,36 +141,10 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
frame_info_set_.insert(base::WrapUnique(frame_info));
}
void CefBrowserInfo::FrameHostStateChanged(
content::RenderFrameHost* host,
content::RenderFrameHost::LifecycleState old_state,
content::RenderFrameHost::LifecycleState new_state) {
CEF_REQUIRE_UIT();
// We currently only care about BackForwardCache state changes.
bool added_to_bfcache =
new_state ==
content::RenderFrameHost::LifecycleState::kInBackForwardCache;
bool removed_from_bfcache =
old_state ==
content::RenderFrameHost::LifecycleState::kInBackForwardCache;
if (!added_to_bfcache && !removed_from_bfcache)
return;
base::AutoLock lock_scope(lock_);
const auto frame_id = CefFrameHostImpl::MakeFrameId(host);
auto it = frame_id_map_.find(frame_id);
DCHECK(it != frame_id_map_.end());
DCHECK((!it->second->is_in_bfcache_ && added_to_bfcache) ||
(it->second->is_in_bfcache_ && removed_from_bfcache));
it->second->is_in_bfcache_ = added_to_bfcache;
}
void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
CEF_REQUIRE_UIT();
NotificationStateLock lock_scope(this);
base::AutoLock lock_scope(lock_);
const auto frame_id = CefFrameHostImpl::MakeFrameId(host);
@@ -212,25 +174,19 @@ void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
// And finally delete the frame info.
{
auto it2 = frame_info_set_.find(frame_info);
// Explicitly Detach everything but the current main frame.
const auto& frame_info = *it2;
if (frame_info->frame_ && !frame_info->IsCurrentMainFrame()) {
if (frame_info->frame_->Detach())
MaybeNotifyFrameDetached(browser_, frame_info->frame_);
}
frame_info_set_.erase(it2);
}
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetMainFrame() {
NotificationStateLock lock_scope(this);
// Early exit if called post-destruction.
if (!browser_)
return nullptr;
CHECK(main_frame_);
base::AutoLock lock_scope(lock_);
DCHECK(browser_);
if (!main_frame_) {
// Create a temporary object that will eventually be updated with real
// routing information.
main_frame_ =
new CefFrameHostImpl(this, true, CefFrameHostImpl::kInvalidFrameId);
}
return main_frame_;
}
@@ -239,29 +195,25 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::CreateTempSubFrame(
CefRefPtr<CefFrameHostImpl> parent = GetFrameForId(parent_frame_id);
if (!parent)
parent = GetMainFrame();
// Intentionally not notifying for temporary frames.
return new CefFrameHostImpl(this, parent->GetIdentifier());
return new CefFrameHostImpl(this, false, parent->GetIdentifier());
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForHost(
const content::RenderFrameHost* host,
bool* is_guest_view,
bool prefer_speculative) const {
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
if (!host)
return nullptr;
return GetFrameForId(CefFrameHostImpl::MakeFrameId(host), is_guest_view,
prefer_speculative);
return GetFrameForId(CefFrameHostImpl::MakeFrameId(host), is_guest_view);
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForRoute(
int32_t render_process_id,
int32_t render_routing_id,
bool* is_guest_view,
bool prefer_speculative) const {
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
@@ -270,13 +222,12 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForRoute(
return GetFrameForId(
CefFrameHostImpl::MakeFrameId(render_process_id, render_routing_id),
is_guest_view, prefer_speculative);
is_guest_view);
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForId(
int64_t frame_id,
bool* is_guest_view,
bool prefer_speculative) const {
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
@@ -295,7 +246,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForId(
return nullptr;
}
if (info->is_speculative_ && !prefer_speculative) {
if (info->is_speculative_) {
if (info->is_main_frame_ && main_frame_) {
// Always prefer the non-speculative main frame.
return main_frame_;
@@ -340,9 +291,8 @@ CefBrowserInfo::FrameHostList CefBrowserInfo::GetAllFrames() const {
base::AutoLock lock_scope(lock_);
FrameHostList frames;
for (const auto& info : frame_info_set_) {
if (info->frame_ && !info->is_speculative_ && !info->is_in_bfcache_) {
if (info->frame_ && !info->is_speculative_)
frames.insert(info->frame_);
}
}
return frames;
}
@@ -378,30 +328,6 @@ bool CefBrowserInfo::IsNavigationLocked(base::OnceClosure pending_action) {
return false;
}
void CefBrowserInfo::MaybeExecuteFrameNotification(
FrameNotifyOnceAction pending_action) {
CefRefPtr<CefFrameHandler> frame_handler;
{
base::AutoLock lock_scope_(notification_lock_);
if (!frame_handler_) {
// No notifications will be executed.
return;
}
if (notification_state_lock_) {
// Queue the notification until the lock is released.
notification_state_lock_->queue_.push(std::move(pending_action));
return;
}
frame_handler = frame_handler_;
}
// Execute immediately if not locked.
std::move(pending_action).Run(frame_handler);
}
void CefBrowserInfo::MaybeUpdateFrameTreeNodeIdMap(FrameInfo* info) {
lock_.AssertAcquired();
@@ -455,150 +381,24 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForFrameTreeNodeInternal(
return nullptr;
}
// Passing in |browser| here because |browser_| may already be cleared.
void CefBrowserInfo::SetMainFrame(CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> frame) {
void CefBrowserInfo::RemoveAllFrames() {
lock_.AssertAcquired();
DCHECK(browser);
DCHECK(!frame || frame->IsMain());
CefRefPtr<CefFrameHostImpl> old_frame;
if (main_frame_) {
old_frame = main_frame_;
if (old_frame->Detach())
MaybeNotifyFrameDetached(browser, old_frame);
}
main_frame_ = frame;
MaybeNotifyMainFrameChanged(browser, old_frame, main_frame_);
}
void CefBrowserInfo::MaybeNotifyFrameCreated(
CefRefPtr<CefFrameHostImpl> frame) {
CEF_REQUIRE_UIT();
// Never notify for temporary objects.
DCHECK(!frame->is_temporary());
MaybeExecuteFrameNotification(base::BindOnce(
[](scoped_refptr<CefBrowserInfo> self, CefRefPtr<CefFrameHostImpl> frame,
CefRefPtr<CefFrameHandler> handler) {
if (auto browser = self->browser()) {
handler->OnFrameCreated(browser, frame);
}
},
scoped_refptr<CefBrowserInfo>(this), frame));
}
// Passing in |browser| here because |browser_| may already be cleared.
void CefBrowserInfo::MaybeNotifyFrameDetached(
CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> frame) {
CEF_REQUIRE_UIT();
// Never notify for temporary objects.
DCHECK(!frame->is_temporary());
MaybeExecuteFrameNotification(base::BindOnce(
[](CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> frame,
CefRefPtr<CefFrameHandler> handler) {
handler->OnFrameDetached(browser, frame);
},
browser, frame));
}
// Passing in |browser| here because |browser_| may already be cleared.
void CefBrowserInfo::MaybeNotifyMainFrameChanged(
CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> old_frame,
CefRefPtr<CefFrameHostImpl> new_frame) {
CEF_REQUIRE_UIT();
// Never notify for temporary objects.
DCHECK(!old_frame || !old_frame->is_temporary());
DCHECK(!new_frame || !new_frame->is_temporary());
MaybeExecuteFrameNotification(base::BindOnce(
[](CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> old_frame,
CefRefPtr<CefFrameHostImpl> new_frame,
CefRefPtr<CefFrameHandler> handler) {
handler->OnMainFrameChanged(browser, old_frame, new_frame);
},
browser, old_frame, new_frame));
}
void CefBrowserInfo::RemoveAllFrames(
CefRefPtr<CefBrowserHostBase> old_browser) {
lock_.AssertAcquired();
// Make sure any callbacks will see the correct state (e.g. like
// CefBrowser::GetMainFrame returning nullptr and CefBrowser::IsValid
// returning false).
DCHECK(!browser_);
DCHECK(old_browser);
// Clear the lookup maps.
frame_id_map_.clear();
frame_tree_node_id_map_.clear();
// Explicitly Detach everything but the current main frame.
// Explicitly Detach main frames.
for (auto& info : frame_info_set_) {
if (info->frame_ && !info->IsCurrentMainFrame()) {
if (info->frame_->Detach())
MaybeNotifyFrameDetached(old_browser, info->frame_);
}
if (info->frame_ && info->is_main_frame_)
info->frame_->Detach();
}
if (main_frame_)
SetMainFrame(old_browser, nullptr);
if (main_frame_) {
main_frame_->Detach();
main_frame_ = nullptr;
}
// And finally delete the frame info.
frame_info_set_.clear();
}
CefBrowserInfo::NotificationStateLock::NotificationStateLock(
CefBrowserInfo* browser_info)
: browser_info_(browser_info) {
// Take the navigation state lock.
{
base::AutoLock lock_scope_(browser_info_->notification_lock_);
CHECK(!browser_info_->notification_state_lock_);
browser_info_->notification_state_lock_ = this;
// We may need this on destruction, and the original might be cleared.
frame_handler_ = browser_info_->frame_handler_;
}
// Take the browser info state lock.
browser_info_lock_scope_.reset(new base::AutoLock(browser_info_->lock_));
}
CefBrowserInfo::NotificationStateLock::~NotificationStateLock() {
// Unlock in reverse order.
browser_info_lock_scope_.reset();
{
base::AutoLock lock_scope_(browser_info_->notification_lock_);
CHECK_EQ(this, browser_info_->notification_state_lock_);
browser_info_->notification_state_lock_ = nullptr;
}
if (!queue_.empty()) {
DCHECK(frame_handler_);
scoped_refptr<NavigationLock> nav_lock;
if (CEF_CURRENTLY_ON_UIT()) {
// Don't navigate while inside callbacks.
nav_lock = browser_info_->CreateNavigationLock();
}
// Empty the queue of pending actions. Any of these actions might result in
// the acquisition of a new NotificationStateLock.
while (!queue_.empty()) {
std::move(queue_.front()).Run(frame_handler_);
queue_.pop();
}
}
}

View File

@@ -6,7 +6,6 @@
#define CEF_LIBCEF_BROWSER_BROWSER_INFO_H_
#pragma once
#include <queue>
#include <set>
#include <unordered_map>
@@ -19,10 +18,12 @@
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
#include "base/values.h"
#include "content/public/browser/render_frame_host.h"
namespace content {
class RenderFrameHost;
}
class CefBrowserHostBase;
class CefFrameHandler;
class CefFrameHostImpl;
// CefBrowserInfo is used to associate a browser ID and render view/process
@@ -59,13 +60,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// true).
void MaybeCreateFrame(content::RenderFrameHost* host, bool is_guest_view);
// Used to track state changes such as entering/exiting the BackForwardCache.
// Called from CefBrowserContentsDelegate::RenderFrameHostStateChanged.
void FrameHostStateChanged(
content::RenderFrameHost* host,
content::RenderFrameHost::LifecycleState old_state,
content::RenderFrameHost::LifecycleState new_state);
// Remove the frame record for |host|. Called for the main frame when the
// RenderView is destroyed, or for a sub-frame when the associated RenderFrame
// is destroyed in the renderer process.
@@ -94,8 +88,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// UI thread.
CefRefPtr<CefFrameHostImpl> GetFrameForHost(
const content::RenderFrameHost* host,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
bool* is_guest_view = nullptr) const;
// Returns the frame object matching the specified IDs or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
@@ -105,8 +98,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
CefRefPtr<CefFrameHostImpl> GetFrameForRoute(
int32_t render_process_id,
int32_t render_routing_id,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
bool* is_guest_view = nullptr) const;
// Returns the frame object matching the specified ID or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
@@ -115,8 +107,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// thread.
CefRefPtr<CefFrameHostImpl> GetFrameForId(
int64_t frame_id,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
bool* is_guest_view = nullptr) const;
// Returns the frame object matching the specified ID or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
@@ -155,16 +146,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// thread.
bool IsNavigationLocked(base::OnceClosure pending_action);
using FrameNotifyOnceAction =
base::OnceCallback<void(CefRefPtr<CefFrameHandler>)>;
// Specifies a CefFrameHandler notification action whose execution may need
// to be blocked on release of a potentially held NotificationStateLock. If no
// CefFrameHandler exists then the action will be discarded without executing.
// If the NotificationStateLock is not currently held then the action will be
// executed immediately.
void MaybeExecuteFrameNotification(FrameNotifyOnceAction pending_action);
private:
friend class base::RefCountedThreadSafe<CefBrowserInfo>;
@@ -173,17 +154,12 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
struct FrameInfo {
~FrameInfo();
inline bool IsCurrentMainFrame() const {
return frame_ && is_main_frame_ && !is_speculative_ && !is_in_bfcache_;
}
content::RenderFrameHost* host_;
int64_t frame_id_; // Combination of render_process_id + render_routing_id.
int frame_tree_node_id_;
bool is_guest_view_;
bool is_main_frame_;
bool is_speculative_;
bool is_in_bfcache_ = false;
CefRefPtr<CefFrameHostImpl> frame_;
};
@@ -193,17 +169,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
int frame_tree_node_id,
bool* is_guest_view = nullptr) const;
void SetMainFrame(CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> frame);
void MaybeNotifyFrameCreated(CefRefPtr<CefFrameHostImpl> frame);
void MaybeNotifyFrameDetached(CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> frame);
void MaybeNotifyMainFrameChanged(CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> old_frame,
CefRefPtr<CefFrameHostImpl> new_frame);
void RemoveAllFrames(CefRefPtr<CefBrowserHostBase> old_browser);
void RemoveAllFrames();
int browser_id_;
bool is_popup_;
@@ -214,29 +180,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// Only accessed on the UI thread.
base::WeakPtr<NavigationLock> navigation_lock_;
// Used instead of |base::AutoLock(lock_)| in situations that might generate
// CefFrameHandler notifications. Any notifications passed to
// MaybeExecuteFrameNotification() will be queued until the lock is released,
// and then executed in order.
class NotificationStateLock final {
public:
explicit NotificationStateLock(CefBrowserInfo* browser_info);
~NotificationStateLock();
protected:
friend class CefBrowserInfo;
CefBrowserInfo* const browser_info_;
CefRefPtr<CefFrameHandler> frame_handler_;
std::unique_ptr<base::AutoLock> browser_info_lock_scope_;
std::queue<FrameNotifyOnceAction> queue_;
};
mutable base::Lock notification_lock_;
// These members must be protected by |notification_lock_|.
NotificationStateLock* notification_state_lock_ = nullptr;
CefRefPtr<CefFrameHandler> frame_handler_;
mutable base::Lock lock_;
// The below members must be protected by |lock_|.

View File

@@ -10,6 +10,7 @@
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/values_impl.h"
@@ -17,7 +18,6 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
@@ -95,9 +95,9 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
// Continue any pending NewBrowserInfo request.
auto it = pending_new_browser_info_map_.find(frame_id);
if (it != pending_new_browser_info_map_.end()) {
SendNewBrowserInfoResponse(
render_process_id, browser_info, /*is_guest_view=*/false,
std::move(it->second->callback), it->second->callback_runner);
SendNewBrowserInfoResponse(render_process_id, browser_info,
false /* is_guest_view */,
it->second->reply_msg);
pending_new_browser_info_map_.erase(it);
}
@@ -181,11 +181,8 @@ bool CefBrowserInfoManager::CanCreateWindow(
if (allow) {
CefBrowserCreateParams create_params;
if (browser->HasView()) {
create_params.popup_with_views_hosted_opener = true;
} else {
if (!browser->HasView())
create_params.window_info = std::move(window_info);
}
create_params.settings = pending_popup->settings;
create_params.client = pending_popup->client;
@@ -262,15 +259,12 @@ void CefBrowserInfoManager::WebContentsCreated(
extra_info = pending_popup->extra_info;
}
void CefBrowserInfoManager::OnGetNewBrowserInfo(
int render_process_id,
int render_routing_id,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) {
void CefBrowserInfoManager::OnGetNewBrowserInfo(int render_process_id,
int render_routing_id,
IPC::Message* reply_msg) {
DCHECK_NE(render_process_id, content::ChildProcessHost::kInvalidUniqueID);
DCHECK_GT(render_routing_id, 0);
DCHECK(callback);
auto callback_runner = base::SequencedTaskRunnerHandle::Get();
DCHECK(reply_msg);
base::AutoLock lock_scope(browser_info_lock_);
@@ -282,7 +276,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
if (browser_info.get()) {
// Send the response immediately.
SendNewBrowserInfoResponse(render_process_id, browser_info, is_guest_view,
std::move(callback), callback_runner);
reply_msg);
return;
}
@@ -300,8 +294,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
pending->render_process_id = render_process_id;
pending->render_routing_id = render_routing_id;
pending->timeout_id = timeout_id;
pending->callback = std::move(callback);
pending->callback_runner = callback_runner;
pending->reply_msg = reply_msg;
pending_new_browser_info_map_.insert(
std::make_pair(frame_id, std::move(pending)));
@@ -429,8 +422,6 @@ void CefBrowserInfoManager::RenderProcessHostDestroyed(
content::RenderProcessHost* host) {
CEF_REQUIRE_UIT();
host->RemoveObserver(this);
const int render_process_id = host->GetID();
DCHECK_GT(render_process_id, 0);
@@ -441,13 +432,11 @@ void CefBrowserInfoManager::RenderProcessHostDestroyed(
PendingNewBrowserInfoMap::iterator it =
pending_new_browser_info_map_.begin();
while (it != pending_new_browser_info_map_.end()) {
const auto& info = it->second;
if (info->render_process_id == render_process_id) {
CancelNewBrowserInfoResponse(info.get());
auto info = it->second.get();
if (info->render_process_id == render_process_id)
it = pending_new_browser_info_map_.erase(it);
} else {
else
++it;
}
}
}
@@ -528,47 +517,44 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
int render_process_id,
scoped_refptr<CefBrowserInfo> browser_info,
bool is_guest_view,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_runner) {
if (!callback_runner->RunsTasksInCurrentSequence()) {
callback_runner->PostTask(
FROM_HERE,
base::BindOnce(&CefBrowserInfoManager::SendNewBrowserInfoResponse,
render_process_id, browser_info, is_guest_view,
std::move(callback), callback_runner));
IPC::Message* reply_msg) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::Bind(&CefBrowserInfoManager::SendNewBrowserInfoResponse,
render_process_id, browser_info, is_guest_view, reply_msg));
return;
}
auto params = cef::mojom::NewBrowserInfo::New();
params->is_guest_view = is_guest_view;
content::RenderProcessHost* host =
content::RenderProcessHost::FromID(render_process_id);
if (!host) {
delete reply_msg;
return;
}
CefProcessHostMsg_GetNewBrowserInfo_Params params;
params.is_guest_view = is_guest_view;
if (browser_info) {
params->browser_id = browser_info->browser_id();
params->is_windowless = browser_info->is_windowless();
params->is_popup = browser_info->is_popup();
params.browser_id = browser_info->browser_id();
params.is_windowless = browser_info->is_windowless();
params.is_popup = browser_info->is_popup();
auto extra_info = browser_info->extra_info();
if (extra_info) {
auto extra_info_impl =
static_cast<CefDictionaryValueImpl*>(extra_info.get());
auto extra_info_value = base::WrapUnique(extra_info_impl->CopyValue());
params->extra_info = std::move(*extra_info_value);
auto extra_info_value = extra_info_impl->CopyValue();
extra_info_value->Swap(&params.extra_info);
}
} else {
// The new browser info response has timed out.
params->browser_id = -1;
params.browser_id = -1;
}
std::move(callback).Run(std::move(params));
}
// static
void CefBrowserInfoManager::CancelNewBrowserInfoResponse(
PendingNewBrowserInfo* pending_info) {
SendNewBrowserInfoResponse(pending_info->render_process_id,
/*browser_info=*/nullptr, /*is_guest_view=*/false,
std::move(pending_info->callback),
pending_info->callback_runner);
CefProcessHostMsg_GetNewBrowserInfo::WriteReplyParams(reply_msg, params);
host->Send(reply_msg);
}
// static
@@ -591,7 +577,9 @@ void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse(int64_t frame_id,
<< pending_info->render_process_id << " and routing id "
<< pending_info->render_routing_id;
CancelNewBrowserInfoResponse(pending_info.get());
SendNewBrowserInfoResponse(pending_info->render_process_id, nullptr,
false /* is_guest_view */,
pending_info->reply_msg);
g_info_manager->pending_new_browser_info_map_.erase(it);
}
}

View File

@@ -14,9 +14,7 @@
#include "libcef/browser/browser_info.h"
#include "base/sequenced_task_runner.h"
#include "base/synchronization/lock.h"
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "content/public/browser/render_process_host_observer.h"
#include "third_party/blink/public/mojom/window_features/window_features.mojom.h"
#include "ui/base/window_open_disposition.h"
@@ -35,6 +33,10 @@ class WebContents;
class WebContentsView;
} // namespace content
namespace IPC {
class Message;
}
class CefBrowserHostBase;
class CefBrowserPlatformDelegate;
@@ -95,17 +97,16 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
std::unique_ptr<CefBrowserPlatformDelegate>& platform_delegate,
CefRefPtr<CefDictionaryValue>& extra_info);
// Called from CefBrowserManager::GetNewBrowserInfo for delivering
// Called from CefBrowserMessageFilter::OnGetNewBrowserInfo for delivering
// browser info to the renderer process. If the browser info already exists
// the response will be sent immediately. Otherwise, the response will be sent
// when CreatePopupBrowserInfo creates the browser info. The info will already
// exist for explicitly created browsers and guest views. It may sometimes
// already exist for traditional popup browsers depending on timing. See
// comments on PendingPopup for more information.
void OnGetNewBrowserInfo(
int render_process_id,
int render_routing_id,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback);
void OnGetNewBrowserInfo(int render_process_id,
int render_routing_id,
IPC::Message* reply_msg);
// Called from CefBrowserHostBase::DestroyBrowser() when a browser is
// destroyed.
@@ -162,7 +163,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Creates the OSR views for windowless popups.
// - WebContentsCreated (UIT):
// Creates the CefBrowserHost representation for the popup.
// - CefBrowserManager::GetNewBrowserInfo (IOT)
// - CefBrowserMessageFilter::OnGetNewBrowserInfo (IOT)
// Passes information about the popup to the renderer process.
struct PendingPopup {
// Track the last method that modified this PendingPopup instance. There may
@@ -208,24 +209,19 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
int render_process_id,
scoped_refptr<CefBrowserInfo> browser_info,
bool is_guest_view,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_runner);
IPC::Message* reply_msg);
// Time out a response if it's still pending.
static void TimeoutNewBrowserInfoResponse(int64_t frame_id, int timeout_id);
// Pending request for OnGetNewBrowserInfo.
struct PendingNewBrowserInfo {
int render_process_id;
int render_routing_id;
int timeout_id;
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback;
scoped_refptr<base::SequencedTaskRunner> callback_runner;
IPC::Message* reply_msg;
};
// Cancel a response that is still pending.
static void CancelNewBrowserInfoResponse(PendingNewBrowserInfo* pending_info);
// Time out a response if it's still pending.
static void TimeoutNewBrowserInfoResponse(int64_t frame_id, int timeout_id);
mutable base::Lock browser_info_lock_;
// Access to the below members must be protected by |browser_info_lock_|.

View File

@@ -1,56 +0,0 @@
// Copyright 2021 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/browser_manager.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/origin_whitelist_impl.h"
#include "content/public/browser/render_process_host.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/service_manager/public/cpp/binder_registry.h"
CefBrowserManager::CefBrowserManager(int render_process_id)
: render_process_id_(render_process_id) {}
CefBrowserManager::~CefBrowserManager() = default;
// static
void CefBrowserManager::ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* host) {
registry->AddInterface(base::BindRepeating(
[](int render_process_id,
mojo::PendingReceiver<cef::mojom::BrowserManager> receiver) {
mojo::MakeSelfOwnedReceiver(
std::make_unique<CefBrowserManager>(render_process_id),
std::move(receiver));
},
host->GetID()));
}
// static
mojo::Remote<cef::mojom::RenderManager>
CefBrowserManager::GetRenderManagerForProcess(
content::RenderProcessHost* host) {
mojo::Remote<cef::mojom::RenderManager> client;
host->BindReceiver(client.BindNewPipeAndPassReceiver());
return client;
}
void CefBrowserManager::GetNewRenderThreadInfo(
cef::mojom::BrowserManager::GetNewRenderThreadInfoCallback callback) {
auto info = cef::mojom::NewRenderThreadInfo::New();
GetCrossOriginWhitelistEntries(&info->cross_origin_whitelist_entries);
std::move(callback).Run(std::move(info));
}
void CefBrowserManager::GetNewBrowserInfo(
int32_t render_frame_routing_id,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) {
CefBrowserInfoManager::GetInstance()->OnGetNewBrowserInfo(
render_process_id_, render_frame_routing_id, std::move(callback));
}

View File

@@ -1,54 +0,0 @@
// Copyright 2021 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_BROWSER_MANAGER_H_
#define CEF_LIBCEF_BROWSER_BROWSER_MANAGER_H_
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/binder_registry.h"
namespace blink {
class AssociatedInterfaceRegistry;
}
namespace content {
class RenderProcessHost;
}
class CefBrowserManager : public cef::mojom::BrowserManager {
public:
explicit CefBrowserManager(int render_process_id);
~CefBrowserManager() override;
// Called from the ContentBrowserClient method of the same name.
// |associated_registry| is used for interfaces which must be associated with
// some IPC::ChannelProxy, meaning that messages on the interface retain FIFO
// with respect to legacy Chrome IPC messages sent or dispatched on the
// channel.
static void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* host);
// Connects to CefRenderManager in the render process.
static mojo::Remote<cef::mojom::RenderManager> GetRenderManagerForProcess(
content::RenderProcessHost* host);
private:
// cef::mojom::BrowserManager methods:
void GetNewRenderThreadInfo(
cef::mojom::BrowserManager::GetNewRenderThreadInfoCallback callback)
override;
void GetNewBrowserInfo(
int32_t render_frame_routing_id,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) override;
// The process ID of the renderer.
const int render_process_id_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserManager);
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_MANAGER_H_

View File

@@ -0,0 +1,55 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions (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.
#include "libcef/browser/browser_message_filter.h"
#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/values_impl.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "content/public/common/child_process_host.h"
CefBrowserMessageFilter::CefBrowserMessageFilter(int render_process_id)
: content::BrowserMessageFilter(ExtensionMsgStart),
render_process_id_(render_process_id) {}
CefBrowserMessageFilter::~CefBrowserMessageFilter() {}
void CefBrowserMessageFilter::OnFilterRemoved() {
render_process_id_ = content::ChildProcessHost::kInvalidUniqueID;
content::BrowserMessageFilter::OnFilterRemoved();
}
bool CefBrowserMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(CefBrowserMessageFilter, message)
IPC_MESSAGE_HANDLER(CefProcessHostMsg_GetNewRenderThreadInfo,
OnGetNewRenderThreadInfo)
IPC_MESSAGE_HANDLER_DELAY_REPLY(CefProcessHostMsg_GetNewBrowserInfo,
OnGetNewBrowserInfo)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void CefBrowserMessageFilter::OnGetNewRenderThreadInfo(
CefProcessHostMsg_GetNewRenderThreadInfo_Params* params) {
GetCrossOriginWhitelistEntries(&params->cross_origin_whitelist_entries);
}
void CefBrowserMessageFilter::OnGetNewBrowserInfo(int render_frame_routing_id,
IPC::Message* reply_msg) {
if (render_process_id_ != content::ChildProcessHost::kInvalidUniqueID) {
CefBrowserInfoManager::GetInstance()->OnGetNewBrowserInfo(
render_process_id_, render_frame_routing_id, reply_msg);
} else {
delete reply_msg;
}
}

View File

@@ -0,0 +1,40 @@
// Copyright (c) 2012 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_BROWSER_MESSAGE_FILTER_H_
#define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_FILTER_H_
#include <stdint.h>
#include <string>
#include "content/public/browser/browser_message_filter.h"
struct CefProcessHostMsg_GetNewBrowserInfo_Params;
struct CefProcessHostMsg_GetNewRenderThreadInfo_Params;
// This class sends and receives control messages on the browser process.
class CefBrowserMessageFilter : public content::BrowserMessageFilter {
public:
explicit CefBrowserMessageFilter(int render_process_id);
~CefBrowserMessageFilter() override;
// IPC::ChannelProxy::MessageFilter implementation.
void OnFilterRemoved() override;
bool OnMessageReceived(const IPC::Message& message) override;
private:
// Message handlers.
void OnGetNewRenderThreadInfo(
CefProcessHostMsg_GetNewRenderThreadInfo_Params* params);
void OnGetNewBrowserInfo(int render_frame_routing_id,
IPC::Message* reply_msg);
int render_process_id_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserMessageFilter);
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_FILTER_H_

View File

@@ -76,7 +76,7 @@ void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostBase* browser) {
void CefBrowserPlatformDelegate::CreateExtensionHost(
const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type) {
extensions::ViewType host_type) {
NOTREACHED();
}
@@ -112,7 +112,7 @@ CefWindowHandle CefBrowserPlatformDelegate::GetHostWindowHandle() const {
return kNullWindowHandle;
}
#if defined(TOOLKIT_VIEWS)
#if defined(USE_AURA)
views::Widget* CefBrowserPlatformDelegate::GetWindowWidget() const {
NOTREACHED();
return nullptr;
@@ -122,7 +122,7 @@ CefRefPtr<CefBrowserView> CefBrowserPlatformDelegate::GetBrowserView() const {
NOTREACHED();
return nullptr;
}
#endif // defined(TOOLKIT_VIEWS)
#endif
void CefBrowserPlatformDelegate::PopupWebContentsCreated(
const CefBrowserSettings& settings,
@@ -318,7 +318,7 @@ void CefBrowserPlatformDelegate::StartDragging(
}
void CefBrowserPlatformDelegate::UpdateDragCursor(
ui::mojom::DragOperation operation) {
blink::DragOperation operation) {
NOTREACHED();
}

View File

@@ -15,11 +15,10 @@
#include "include/views/cef_browser_view.h"
#include "base/callback_forward.h"
#include "extensions/common/mojom/view_type.mojom-forward.h"
#include "extensions/common/view_type.h"
#include "third_party/blink/public/common/page/drag_operation.h"
#include "third_party/blink/public/mojom/page/drag.mojom-forward.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-forward.h"
#include "ui/base/window_open_disposition.h"
class GURL;
@@ -57,7 +56,7 @@ class Size;
class Vector2d;
} // namespace gfx
#if defined(TOOLKIT_VIEWS)
#if defined(USE_AURA)
namespace views {
class Widget;
}
@@ -134,7 +133,7 @@ class CefBrowserPlatformDelegate {
// Called from AlloyBrowserHostImpl::Create.
virtual void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type);
extensions::ViewType host_type);
// Returns the current extension host.
virtual extensions::ExtensionHost* GetExtensionHost() const;
@@ -168,7 +167,7 @@ class CefBrowserPlatformDelegate {
// the client, which may be NULL. May be called on multiple threads.
virtual CefWindowHandle GetHostWindowHandle() const;
#if defined(TOOLKIT_VIEWS)
#if defined(USE_AURA)
// Returns the Widget owner for the browser window. Only used with windowed
// rendering.
virtual views::Widget* GetWindowWidget() const;
@@ -328,7 +327,7 @@ class CefBrowserPlatformDelegate {
const gfx::Vector2d& image_offset,
const blink::mojom::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh);
virtual void UpdateDragCursor(ui::mojom::DragOperation operation);
virtual void UpdateDragCursor(blink::DragOperation operation);
virtual void DragSourceEndedAt(int x, int y, cef_drag_operations_mask_t op);
virtual void DragSourceSystemDragEnded();
virtual void AccessibilityEventReceived(

View File

@@ -29,8 +29,7 @@
#error A delegate implementation is not available for your platform.
#endif
#if defined(TOOLKIT_VIEWS)
#include "libcef/browser/chrome/views/browser_platform_delegate_chrome_views.h"
#if defined(USE_AURA)
#include "libcef/browser/views/browser_platform_delegate_views.h"
#endif
@@ -83,14 +82,6 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
// CefWindowInfo is not used in this case.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo(), background_color);
#if defined(TOOLKIT_VIEWS)
if (create_params.browser_view ||
create_params.popup_with_views_hosted_opener) {
return std::make_unique<CefBrowserPlatformDelegateChromeViews>(
std::move(native_delegate),
static_cast<CefBrowserViewImpl*>(create_params.browser_view.get()));
}
#endif
return std::make_unique<CefBrowserPlatformDelegateChrome>(
std::move(native_delegate));
}
@@ -115,14 +106,14 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
}
return std::move(native_delegate);
} else if (create_params.extension_host_type ==
extensions::mojom::ViewType::kExtensionBackgroundPage) {
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
// Creating a background extension host without a window.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo(), background_color);
return std::make_unique<CefBrowserPlatformDelegateBackground>(
std::move(native_delegate));
}
#if defined(TOOLKIT_VIEWS)
#if defined(USE_AURA)
else {
// CefWindowInfo is not used in this case.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
@@ -131,7 +122,7 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
std::move(native_delegate),
static_cast<CefBrowserViewImpl*>(create_params.browser_view.get()));
}
#endif // defined(TOOLKIT_VIEWS)
#endif // defined(USE_AURA)
NOTREACHED();
return nullptr;

View File

@@ -86,11 +86,6 @@ void CefBrowserPlatformDelegateChrome::ViewText(const std::string& text) {
native_delegate_->ViewText(text);
}
CefEventHandle CefBrowserPlatformDelegateChrome::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const {
return native_delegate_->GetEventHandle(event);
}
CefWindowHandle CefBrowserPlatformDelegateChrome::GetParentWindowHandle()
const {
return GetHostWindowHandle();

View File

@@ -36,8 +36,6 @@ class CefBrowserPlatformDelegateChrome
int deltaY) override;
gfx::Point GetScreenPoint(const gfx::Point& view) const override;
void ViewText(const std::string& text) override;
CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override;
// CefBrowserPlatformDelegateNative::WindowlessHandler methods:
CefWindowHandle GetParentWindowHandle() const override;
@@ -45,7 +43,7 @@ class CefBrowserPlatformDelegateChrome
void set_chrome_browser(Browser* browser);
protected:
private:
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate_;
Browser* chrome_browser_ = nullptr;

View File

@@ -4,154 +4,37 @@
#include "libcef/browser/chrome/chrome_browser_context.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/off_the_record_profile_impl.h"
#include "chrome/browser/profiles/profile_keep_alive_types.h"
#include "chrome/browser/profiles/scoped_profile_keep_alive.h"
#include "chrome/browser/profiles/profile_manager.h"
ChromeBrowserContext::ChromeBrowserContext(
const CefRequestContextSettings& settings)
: CefBrowserContext(settings), weak_ptr_factory_(this) {}
: CefBrowserContext(settings) {}
ChromeBrowserContext::~ChromeBrowserContext() = default;
content::BrowserContext* ChromeBrowserContext::AsBrowserContext() {
CHECK(!destroyed_);
return profile_;
}
Profile* ChromeBrowserContext::AsProfile() {
CHECK(!destroyed_);
return profile_;
}
bool ChromeBrowserContext::IsInitialized() const {
CEF_REQUIRE_UIT();
CHECK(!destroyed_);
return !!profile_;
}
void ChromeBrowserContext::StoreOrTriggerInitCallback(
base::OnceClosure callback) {
CEF_REQUIRE_UIT();
if (IsInitialized()) {
std::move(callback).Run();
} else {
init_callbacks_.emplace_back(std::move(callback));
}
}
void ChromeBrowserContext::InitializeAsync(base::OnceClosure initialized_cb) {
init_callbacks_.emplace_back(std::move(initialized_cb));
void ChromeBrowserContext::Initialize() {
CefBrowserContext::Initialize();
if (!cache_path_.empty()) {
auto* profile_manager = g_browser_process->profile_manager();
const auto& user_data_dir = profile_manager->user_data_dir();
// 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();
if (cache_path_ == user_data_dir) {
// Use the default disk-based profile.
auto profile = profile_manager->GetPrimaryUserProfile();
ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_INITIALIZED);
return;
} else if (cache_path_.DirName() == user_data_dir) {
// Create or load a specific disk-based profile. May continue
// synchronously or asynchronously.
profile_manager->CreateProfileAsync(
cache_path_,
base::BindRepeating(&ChromeBrowserContext::ProfileCreated,
weak_ptr_factory_.GetWeakPtr()));
return;
} else {
// All profile directories must be relative to |user_data_dir|.
LOG(ERROR) << "Cannot create profile at path "
<< cache_path_.AsUTF8Unsafe();
}
}
// Default to creating a new/unique OffTheRecord profile.
ProfileCreated(nullptr, Profile::CreateStatus::CREATE_STATUS_CANCELED);
browser_prefs::SetLanguagePrefs(profile_);
}
void ChromeBrowserContext::Shutdown() {
CefBrowserContext::Shutdown();
// Allow potential deletion of the Profile at some future point (controlled
// by ProfileManager).
profile_keep_alive_.reset();
// |g_browser_process| may be nullptr during shutdown.
if (g_browser_process) {
if (should_destroy_) {
g_browser_process->profile_manager()
->GetPrimaryUserProfile()
->DestroyOffTheRecordProfile(profile_);
} else if (profile_) {
OnProfileWillBeDestroyed(profile_);
}
}
}
void ChromeBrowserContext::ProfileCreated(Profile* profile,
Profile::CreateStatus status) {
Profile* parent_profile = nullptr;
OffTheRecordProfileImpl* otr_profile = nullptr;
if (status != Profile::CreateStatus::CREATE_STATUS_CREATED &&
status != Profile::CreateStatus::CREATE_STATUS_INITIALIZED) {
CHECK(!profile);
CHECK(!profile_);
// Profile creation may access the filesystem.
base::ScopedAllowBlockingForTesting allow_blocking;
// Creation of a disk-based profile failed for some reason. Create a
// new/unique OffTheRecord profile instead.
const auto& profile_id = Profile::OTRProfileID::CreateUniqueForCEF();
parent_profile =
g_browser_process->profile_manager()->GetPrimaryUserProfile();
profile_ = parent_profile->GetOffTheRecordProfile(
profile_id, /*create_if_needed=*/true);
otr_profile = static_cast<OffTheRecordProfileImpl*>(profile_);
status = Profile::CreateStatus::CREATE_STATUS_INITIALIZED;
should_destroy_ = true;
} else if (profile && !profile_) {
// May be CREATE_STATUS_CREATED or CREATE_STATUS_INITIALIZED since
// *CREATED isn't always sent for a disk-based profile that already
// exists.
profile_ = profile;
profile_->AddObserver(this);
profile_keep_alive_.reset(new ScopedProfileKeepAlive(
profile_, ProfileKeepAliveOrigin::kAppWindow));
}
if (status == Profile::CreateStatus::CREATE_STATUS_INITIALIZED) {
CHECK(profile_);
// Must set |profile_| before Init() calls
// ChromeContentBrowserClientCef::ConfigureNetworkContextParams so that
// CefBrowserContext::FromBrowserContext can find us.
if (otr_profile) {
otr_profile->Init();
parent_profile->NotifyOffTheRecordProfileCreated(otr_profile);
}
if (!init_callbacks_.empty()) {
for (auto& callback : init_callbacks_) {
std::move(callback).Run();
}
init_callbacks_.clear();
}
}
}
void ChromeBrowserContext::OnProfileWillBeDestroyed(Profile* profile) {
CHECK_EQ(profile_, profile);
profile_->RemoveObserver(this);
profile_ = nullptr;
destroyed_ = true;
}

View File

@@ -8,45 +8,22 @@
#include "libcef/browser/browser_context.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_observer.h"
class ScopedProfileKeepAlive;
// See CefBrowserContext documentation for usage. Only accessed on the UI thread
// unless otherwise indicated.
class ChromeBrowserContext : public CefBrowserContext, public ProfileObserver {
class ChromeBrowserContext : public CefBrowserContext {
public:
explicit ChromeBrowserContext(const CefRequestContextSettings& settings);
void InitializeAsync(base::OnceClosure initialized_cb);
// CefBrowserContext overrides.
content::BrowserContext* AsBrowserContext() override;
Profile* AsProfile() override;
bool IsInitialized() const override;
void StoreOrTriggerInitCallback(base::OnceClosure callback) override;
void Initialize() override;
void Shutdown() override;
// ProfileObserver overrides.
void OnProfileWillBeDestroyed(Profile* profile) override;
private:
~ChromeBrowserContext() override;
void ProfileCreated(Profile* profile, Profile::CreateStatus status);
base::OnceClosure initialized_cb_;
Profile* profile_ = nullptr;
bool should_destroy_ = false;
bool destroyed_ = false;
std::unique_ptr<ScopedProfileKeepAlive> profile_keep_alive_;
std::vector<base::OnceClosure> init_callbacks_;
base::WeakPtrFactory<ChromeBrowserContext> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserContext);
};

View File

@@ -16,7 +16,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/native_web_keyboard_event.h"
@@ -66,7 +65,7 @@ void ChromeBrowserDelegate::SetAsDelegate(content::WebContents* web_contents,
create_params_.request_context);
CreateBrowser(web_contents, create_params_.settings, create_params_.client,
std::move(platform_delegate), browser_info, /*opener=*/nullptr,
std::move(platform_delegate), browser_info,
request_context_impl);
}
@@ -104,28 +103,7 @@ void ChromeBrowserDelegate::WebContentsCreated(
// We don't officially own |new_contents| until AddNewContents() is called.
// However, we need to install observers/delegates here.
CreateBrowser(new_contents, settings, client, std::move(platform_delegate),
browser_info, opener, request_context_impl);
}
void ChromeBrowserDelegate::AddNewContents(
content::WebContents* source_contents,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
auto new_browser =
ChromeBrowserHostImpl::GetBrowserForContents(new_contents.get());
if (new_browser) {
// Create a new Browser and give it ownership of the WebContents.
new_browser->AddNewContents(std::move(new_contents));
return;
}
// Fall back to default behavior from Browser::AddNewContents.
chrome::AddWebContents(browser_, source_contents, std::move(new_contents),
target_url, disposition, initial_rect);
browser_info, request_context_impl);
}
content::WebContents* ChromeBrowserDelegate::OpenURLFromTab(
@@ -156,9 +134,9 @@ void ChromeBrowserDelegate::UpdateTargetURL(content::WebContents* source,
bool ChromeBrowserDelegate::DidAddMessageToConsole(
content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) {
const base::string16& source_id) {
if (auto delegate = GetDelegateForWebContents(source)) {
return delegate->DidAddMessageToConsole(source, log_level, message, line_no,
source_id);
@@ -217,7 +195,6 @@ void ChromeBrowserDelegate::CreateBrowser(
CefRefPtr<CefClient> client,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<ChromeBrowserHostImpl> opener,
CefRefPtr<CefRequestContextImpl> request_context_impl) {
CEF_REQUIRE_UIT();
DCHECK(web_contents);
@@ -225,9 +202,6 @@ void ChromeBrowserDelegate::CreateBrowser(
DCHECK(browser_info);
DCHECK(request_context_impl);
// If |opener| is non-nullptr it must be a popup window.
DCHECK(!opener.get() || browser_info->is_popup());
if (!client) {
if (auto app = CefAppManager::Get()->GetApplication()) {
if (auto bph = app->GetBrowserProcessHandler()) {
@@ -252,12 +226,7 @@ void ChromeBrowserDelegate::CreateBrowser(
CefRefPtr<ChromeBrowserHostImpl> browser_host =
new ChromeBrowserHostImpl(settings, client, std::move(platform_delegate),
browser_info, request_context_impl);
browser_host->Attach(web_contents, opener);
// The Chrome browser for a popup won't be created until AddNewContents().
if (!opener) {
browser_host->SetBrowser(browser_);
}
browser_host->Attach(browser_, web_contents);
}
CefBrowserContentsDelegate* ChromeBrowserDelegate::GetDelegateForWebContents(
@@ -283,11 +252,6 @@ std::unique_ptr<BrowserDelegate> BrowserDelegate::Create(
cef_params.get());
if (params) {
create_params = params->create_params_;
// Clear these values so they're not persisted to additional Browsers.
#if defined(TOOLKIT_VIEWS)
params->create_params_.browser_view = nullptr;
#endif
}
return std::make_unique<ChromeBrowserDelegate>(browser, create_params);

View File

@@ -12,7 +12,7 @@
#include "libcef/browser/browser_info.h"
#include "libcef/browser/chrome/browser_delegate.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "base/optional.h"
class CefBrowserContentsDelegate;
class CefRequestContextImpl;
@@ -55,13 +55,6 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) override;
void AddNewContents(content::WebContents* source_contents,
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;
content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) override;
@@ -70,9 +63,9 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
bool DidAddMessageToConsole(content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) override;
const base::string16& source_id) override;
void DidNavigateMainFramePostCommit(
content::WebContents* web_contents) override;
void EnterFullscreenModeForTab(
@@ -95,7 +88,6 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
CefRefPtr<CefClient> client,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<ChromeBrowserHostImpl> opener,
CefRefPtr<CefRequestContextImpl> request_context_impl);
CefBrowserContentsDelegate* GetDelegateForWebContents(

View File

@@ -7,8 +7,6 @@
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/views/browser_view_impl.h"
#include "libcef/common/net/url_util.h"
#include "libcef/features/runtime_checks.h"
#include "base/logging.h"
@@ -22,18 +20,32 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/pref_names.h"
#if defined(TOOLKIT_VIEWS)
#include "libcef/browser/chrome/views/chrome_browser_frame.h"
#include "libcef/browser/chrome/views/chrome_browser_view.h"
#endif
#include "url/url_constants.h"
// static
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::Create(
const CefBrowserCreateParams& params) {
auto browser = CreateBrowser(params);
// Get or create the request context and profile.
CefRefPtr<CefRequestContextImpl> request_context_impl =
CefRequestContextImpl::GetOrCreateForRequestContext(
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();
GURL url = url_util::MakeGURL(params.url, /*fixup=*/true);
Browser::CreateParams chrome_params =
Browser::CreateParams(profile, /*user_gesture=*/false);
// Pass |params| to cef::BrowserDelegate::Create from the Browser constructor.
chrome_params.cef_params = base::MakeRefCounted<DelegateCreateParams>(params);
// Create the Browser. This will indirectly create the ChomeBrowserDelegate.
// The same params will be used to create a new Browser if the tab is dragged
// out of the existing Browser.
auto browser = Browser::Create(chrome_params);
GURL url = params.url;
if (url.is_empty()) {
// Chrome will navigate to kChromeUINewTabURL by default. We want to keep
// the current CEF behavior of not navigating at all. Use a special URL that
@@ -44,8 +56,7 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::Create(
// Add a new tab. This will indirectly create a new tab WebContents and
// call ChromeBrowserDelegate::OnWebContentsCreated to create the associated
// ChromeBrowserHostImpl.
chrome::AddTabAt(browser, url, /*index=*/TabStripModel::kNoTab,
/*foreground=*/true);
chrome::AddTabAt(browser, url, /*idx=*/-1, /*foreground=*/true);
// The new tab WebContents.
auto web_contents = browser->tab_strip_model()->GetActiveWebContents();
@@ -106,34 +117,6 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForFrameRoute(
ChromeBrowserHostImpl::~ChromeBrowserHostImpl() = default;
void ChromeBrowserHostImpl::AddNewContents(
std::unique_ptr<content::WebContents> contents) {
DCHECK(contents);
DCHECK(!browser_);
// We should already be associated with the WebContents.
DCHECK_EQ(GetWebContents(), contents.get());
CefBrowserCreateParams params;
params.request_context = request_context();
#if defined(TOOLKIT_VIEWS)
params.browser_view = GetBrowserView();
#endif
// Create the new Browser representation.
auto browser = CreateBrowser(params);
// Add the WebContents to the Browser.
browser->tab_strip_model()->AddWebContents(
std::move(contents), /*index=*/TabStripModel::kNoTab,
ui::PageTransition::PAGE_TRANSITION_AUTO_TOPLEVEL,
TabStripModel::ADD_ACTIVE);
SetBrowser(browser);
browser->window()->Show();
}
void ChromeBrowserHostImpl::OnWebContentsDestroyed(
content::WebContents* web_contents) {
platform_delegate_->WebContentsDestroyed(web_contents);
@@ -165,9 +148,8 @@ void ChromeBrowserHostImpl::CloseBrowser(bool force_close) {
}
bool ChromeBrowserHostImpl::TryCloseBrowser() {
// TODO(chrome): Handle the case where the browser may not close immediately.
CloseBrowser(true);
return true;
NOTIMPLEMENTED();
return false;
}
void ChromeBrowserHostImpl::SetFocus(bool focus) {
@@ -186,6 +168,11 @@ CefWindowHandle ChromeBrowserHostImpl::GetOpenerWindowHandle() {
return kNullWindowHandle;
}
bool ChromeBrowserHostImpl::HasView() {
// TODO(chrome-runtime): Support Views-hosted browsers.
return false;
}
double ChromeBrowserHostImpl::GetZoomLevel() {
NOTIMPLEMENTED();
return 0.0;
@@ -258,6 +245,26 @@ bool ChromeBrowserHostImpl::HasDevTools() {
return false;
}
bool ChromeBrowserHostImpl::SendDevToolsMessage(const void* message,
size_t message_size) {
NOTIMPLEMENTED();
return false;
}
int ChromeBrowserHostImpl::ExecuteDevToolsMethod(
int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) {
NOTIMPLEMENTED();
return 0;
}
CefRefPtr<CefRegistration> ChromeBrowserHostImpl::AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) {
NOTIMPLEMENTED();
return nullptr;
}
bool ChromeBrowserHostImpl::IsWindowRenderingDisabled() {
return false;
}
@@ -391,17 +398,13 @@ bool ChromeBrowserHostImpl::Navigate(const content::OpenURLParams& params) {
}
if (browser_) {
GURL gurl = params.url;
if (!url_util::FixupGURL(gurl))
return false;
// This is generally equivalent to calling Browser::OpenURL, except:
// 1. It doesn't trigger a call to CefRequestHandler::OnOpenURLFromTab, and
// 2. It navigates in this CefBrowserHost's WebContents instead of
// (a) creating a new WebContents, or (b) using the Browser's active
// WebContents (which may not be the same), and
// 3. There is no risk of triggering chrome's popup blocker.
NavigateParams nav_params(browser_, gurl, params.transition);
NavigateParams nav_params(browser_, params.url, params.transition);
nav_params.FillNavigateParamsFromOpenURLParams(params);
// Always navigate in the current tab.
@@ -429,113 +432,17 @@ ChromeBrowserHostImpl::ChromeBrowserHostImpl(
browser_info,
request_context) {}
// static
Browser* ChromeBrowserHostImpl::CreateBrowser(
const CefBrowserCreateParams& params) {
// Get or create the request context and profile.
CefRefPtr<CefRequestContextImpl> request_context_impl =
CefRequestContextImpl::GetOrCreateForRequestContext(
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();
CHECK(profile);
Browser::CreateParams chrome_params =
Browser::CreateParams(profile, /*user_gesture=*/false);
// Pass |params| to cef::BrowserDelegate::Create from the Browser constructor.
chrome_params.cef_params = base::MakeRefCounted<DelegateCreateParams>(params);
#if defined(TOOLKIT_VIEWS)
// Configure Browser creation to use the existing Views-based
// Widget/BrowserFrame (ChromeBrowserFrame) and BrowserView/BrowserWindow
// (ChromeBrowserView). See views/chrome_browser_frame.h for related
// documentation.
ChromeBrowserView* chrome_browser_view = nullptr;
if (params.browser_view) {
// Don't show most controls.
chrome_params.type = Browser::TYPE_POPUP;
// Don't show title bar or address.
chrome_params.trusted_source = true;
auto view_impl =
static_cast<CefBrowserViewImpl*>(params.browser_view.get());
chrome_browser_view =
static_cast<ChromeBrowserView*>(view_impl->root_view());
chrome_params.window = chrome_browser_view;
auto chrome_widget =
static_cast<ChromeBrowserFrame*>(chrome_browser_view->GetWidget());
chrome_browser_view->set_frame(chrome_widget);
}
#endif // defined(TOOLKIT_VIEWS)
// Create the Browser. This will indirectly create the ChomeBrowserDelegate.
// The same params will be used to create a new Browser if the tab is dragged
// out of the existing Browser. The returned Browser is owned by the
// associated BrowserView.
auto browser = Browser::Create(chrome_params);
#if defined(TOOLKIT_VIEWS)
if (chrome_browser_view) {
// Initialize the BrowserFrame and BrowserView and create the controls that
// require access to the Browser.
chrome_browser_view->InitBrowser(base::WrapUnique(browser),
params.browser_view);
}
#endif
return browser;
}
void ChromeBrowserHostImpl::Attach(content::WebContents* web_contents,
CefRefPtr<ChromeBrowserHostImpl> opener) {
void ChromeBrowserHostImpl::Attach(Browser* browser,
content::WebContents* web_contents) {
DCHECK(browser);
DCHECK(web_contents);
if (opener) {
// Give the opener browser's platform delegate an opportunity to modify the
// new browser's platform delegate.
opener->platform_delegate_->PopupWebContentsCreated(
settings_, client_, web_contents, platform_delegate_.get(),
/*is_devtools_popup=*/false);
}
platform_delegate_->WebContentsCreated(web_contents,
/*own_web_contents=*/false);
SetBrowser(browser);
contents_delegate_->ObserveWebContents(web_contents);
// Associate the platform delegate with this browser.
platform_delegate_->BrowserCreated(this);
// Associate the base class with the WebContents.
InitializeBrowser();
// Notify that the browser has been created. These must be delivered in the
// expected order.
// 1. Notify the browser's LifeSpanHandler. This must always be the first
// notification for the browser.
{
// The WebContents won't be added to the Browser's TabStripModel until later
// in the current call stack. Block navigation until that time.
auto navigation_lock = browser_info_->CreateNavigationLock();
OnAfterCreated();
}
// 2. Notify the platform delegate. With Views this will result in a call to
// CefBrowserViewDelegate::OnBrowserCreated().
platform_delegate_->NotifyBrowserCreated();
if (opener && opener->platform_delegate_) {
// 3. Notify the opener browser's platform delegate. With Views this will
// result in a call to CefBrowserViewDelegate::OnPopupBrowserViewCreated().
opener->platform_delegate_->PopupBrowserCreated(
this,
/*is_devtools_popup=*/false);
}
}
void ChromeBrowserHostImpl::SetBrowser(Browser* browser) {
@@ -545,17 +452,19 @@ void ChromeBrowserHostImpl::SetBrowser(Browser* browser) {
->set_chrome_browser(browser);
}
void ChromeBrowserHostImpl::WindowDestroyed() {
void ChromeBrowserHostImpl::InitializeBrowser() {
CEF_REQUIRE_UIT();
#if defined(TOOLKIT_VIEWS)
if (browser_ && is_views_hosted_) {
auto chrome_browser_view =
static_cast<ChromeBrowserView*>(browser_->window());
chrome_browser_view->Destroyed();
}
#endif
DCHECK(browser_);
platform_delegate_->CloseHostWindow();
// Associate the platform delegate with this browser.
platform_delegate_->BrowserCreated(this);
CefBrowserHostBase::InitializeBrowser();
// The WebContents won't be added to the Browser's TabStripModel until later
// in the current call stack. Block navigation until that time.
auto navigation_lock = browser_info_->CreateNavigationLock();
OnAfterCreated();
}
void ChromeBrowserHostImpl::DestroyBrowser() {
@@ -577,8 +486,6 @@ void ChromeBrowserHostImpl::DoCloseBrowser(bool force_close) {
// Like chrome::CloseTab() but specifying the WebContents.
const int tab_index = GetCurrentTabIndex();
if (tab_index != TabStripModel::kNoTab) {
// TODO(chrome): Handle the case where this method returns false,
// indicating that the contents were not closed immediately.
browser_->tab_strip_model()->CloseWebContentsAt(
tab_index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB |
TabStripModel::CLOSE_USER_GESTURE);

View File

@@ -66,6 +66,7 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
void SetFocus(bool focus) override;
CefWindowHandle GetWindowHandle() override;
CefWindowHandle GetOpenerWindowHandle() override;
bool HasView() override;
double GetZoomLevel() override;
void SetZoomLevel(double zoomLevel) override;
void RunFileDialog(FileDialogMode mode,
@@ -90,6 +91,12 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
const CefPoint& inspect_element_at) override;
void CloseDevTools() override;
bool HasDevTools() override;
bool SendDevToolsMessage(const void* message, size_t message_size) override;
int ExecuteDevToolsMethod(int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) override;
CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) override;
bool IsWindowRenderingDisabled() override;
void WasResized() override;
void WasHidden(bool hidden) override;
@@ -142,25 +149,17 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<CefRequestContextImpl> request_context);
// Create a new Browser without initializing the WebContents.
static Browser* CreateBrowser(const CefBrowserCreateParams& params);
// Called from ChromeBrowserDelegate::CreateBrowser when this object is first
// Called from ChromeBrowserDelegate::SetAsDelegate when this object is first
// created. Must be called on the UI thread.
void Attach(content::WebContents* web_contents,
CefRefPtr<ChromeBrowserHostImpl> opener);
void Attach(Browser* browser, content::WebContents* web_contents);
// Called from ChromeBrowserDelegate::AddNewContents to take ownership of a
// popup WebContents.
void AddNewContents(std::unique_ptr<content::WebContents> contents);
// Called when this object changes Browser ownership (e.g. initially created,
// dragging between windows, etc). The old Browser, if any, will be cleared
// before the new Browser is added. Must be called on the UI thread.
// Called from ChromeBrowserDelegate::SetAsDelegate when this object changes
// Browser ownership (e.g. dragging between windows). The old Browser will be
// cleared before the new Browser is added. Must be called on the UI thread.
void SetBrowser(Browser* browser);
// CefBrowserHostBase methods:
void WindowDestroyed() override;
void InitializeBrowser() override;
void DestroyBrowser() override;
void DoCloseBrowser(bool force_close);

View File

@@ -4,12 +4,9 @@
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
#include "libcef/browser/chrome/chrome_context_menu_handler.h"
#include "libcef/browser/context.h"
#include "libcef/browser/net/chrome_scheme_handler.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
ChromeBrowserMainExtraPartsCef::ChromeBrowserMainExtraPartsCef() = default;
@@ -25,16 +22,13 @@ void ChromeBrowserMainExtraPartsCef::PostProfileInit() {
}
void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
background_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::BEST_EFFORT,
background_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_visible_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::USER_VISIBLE,
user_visible_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_blocking_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::USER_BLOCKING,
user_blocking_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
scheme::RegisterWebUIControllerFactory();
context_menu::RegisterMenuCreatedCallback();
}

View File

@@ -5,20 +5,14 @@
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
#include "libcef/browser/browser_frame.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_manager.h"
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
#include "libcef/browser/browser_message_filter.h"
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
#include "libcef/browser/context.h"
#include "libcef/browser/net/chrome_scheme_handler.h"
#include "libcef/browser/net/throttle_handler.h"
#include "libcef/browser/net_service/cookie_manager_impl.h"
#include "libcef/browser/net_service/login_delegate.h"
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/prefs/renderer_prefs.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/command_line_impl.h"
@@ -30,11 +24,7 @@
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/common/content_switches.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
namespace {
@@ -42,15 +32,13 @@ namespace {
void HandleExternalProtocolHelper(
ChromeContentBrowserClientCef* self,
content::WebContents::OnceGetter web_contents_getter,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
const network::ResourceRequest& resource_request) {
// Match the logic of the original call in
// NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
self->HandleExternalProtocol(
resource_request.url, std::move(web_contents_getter),
content::ChildProcessHost::kInvalidUniqueID, frame_tree_node_id,
navigation_data,
content::ChildProcessHost::kInvalidUniqueID, navigation_data,
resource_request.resource_type ==
static_cast<int>(blink::mojom::ResourceType::kMainFrame),
static_cast<ui::PageTransition>(resource_request.transition_type),
@@ -93,16 +81,6 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
const base::CommandLine* browser_cmd = base::CommandLine::ForCurrentProcess();
{
// Propagate the following switches to all command lines (along with any
// associated values) if present in the browser command line.
static const char* const kSwitchNames[] = {
switches::kUserAgentProductAndVersion,
};
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
base::size(kSwitchNames));
}
const std::string& process_type =
command_line->GetSwitchValueASCII(switches::kProcessType);
if (process_type == switches::kRendererProcess) {
@@ -123,7 +101,7 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
CefRefPtr<CefCommandLineImpl> commandLinePtr(
new CefCommandLineImpl(command_line, false, false));
handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
ignore_result(commandLinePtr->Detach(nullptr));
commandLinePtr->Detach(nullptr);
}
}
}
@@ -132,6 +110,9 @@ void ChromeContentBrowserClientCef::RenderProcessWillLaunch(
content::RenderProcessHost* host) {
ChromeContentBrowserClient::RenderProcessWillLaunch(host);
const int id = host->GetID();
host->AddFilter(new CefBrowserMessageFilter(id));
// If the renderer process crashes then the host may already have
// CefBrowserInfoManager as an observer. Try to remove it first before adding
// to avoid DCHECKs.
@@ -166,40 +147,13 @@ bool ChromeContentBrowserClientCef::CanCreateWindow(
user_gesture, opener_suppressed, no_javascript_access);
}
void ChromeContentBrowserClientCef::OverrideWebkitPrefs(
content::WebContents* web_contents,
blink::web_pref::WebPreferences* prefs) {
renderer_prefs::SetDefaultPrefs(*prefs);
ChromeContentBrowserClient::OverrideWebkitPrefs(web_contents, prefs);
auto browser = ChromeBrowserHostImpl::GetBrowserForContents(web_contents);
if (browser) {
renderer_prefs::SetCefPrefs(browser->settings(), *prefs);
// Set the background color for the WebView.
prefs->base_background_color = browser->GetBackgroundColor();
} else {
// We don't know for sure that the browser will be windowless but assume
// that the global windowless state is likely to be accurate.
prefs->base_background_color =
CefContext::Get()->GetBackgroundColor(nullptr, STATE_DEFAULT);
}
auto rvh = web_contents->GetRenderViewHost();
if (rvh->GetWidget()->GetView()) {
rvh->GetWidget()->GetView()->SetBackgroundColor(
prefs->base_background_color);
}
}
bool ChromeContentBrowserClientCef::WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,
content::RenderFrameHost* frame,
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
base::Optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -216,13 +170,6 @@ bool ChromeContentBrowserClientCef::WillCreateURLLoaderFactory(
return use_proxy;
}
// Don't intercept requests for Profiles that were not created by CEF.
// For example, the User Manager profile created via
// profiles::CreateSystemProfileForUserManager.
auto profile = Profile::FromBrowserContext(browser_context);
if (!CefBrowserContext::FromProfile(profile))
return false;
auto request_handler = net_service::CreateInterceptedRequestHandler(
browser_context, frame, render_process_id,
type == URLLoaderFactoryType::kNavigation,
@@ -238,12 +185,11 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
const GURL& url,
content::WebContents::OnceGetter web_contents_getter,
int child_id,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
// |out_factory| will be non-nullptr when this method is initially called
// from NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
@@ -256,9 +202,9 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
// HandleExternalProtocolHelper. Forward to the chrome layer for default
// handling.
return ChromeContentBrowserClient::HandleExternalProtocol(
url, std::move(web_contents_getter), child_id, frame_tree_node_id,
navigation_data, is_main_frame, page_transition, has_user_gesture,
initiating_origin, nullptr);
url, std::move(web_contents_getter), child_id, navigation_data,
is_main_frame, page_transition, has_user_gesture, initiating_origin,
nullptr);
}
bool ChromeContentBrowserClientCef::HandleExternalProtocol(
@@ -273,9 +219,8 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
// HandleExternalProtocolHelper may be called if nothing handles the request.
auto request_handler = net_service::CreateInterceptedRequestHandler(
web_contents_getter, frame_tree_node_id, resource_request,
base::BindRepeating(HandleExternalProtocolHelper, base::Unretained(this),
web_contents_getter, frame_tree_node_id,
navigation_data, resource_request));
base::Bind(HandleExternalProtocolHelper, base::Unretained(this),
web_contents_getter, navigation_data, resource_request));
net_service::ProxyURLLoaderFactory::CreateProxy(
web_contents_getter, std::move(receiver), std::move(request_handler));
@@ -296,8 +241,7 @@ void ChromeContentBrowserClientCef::ConfigureNetworkContextParams(
bool in_memory,
const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
cert_verifier::mojom::CertVerifierCreationParams*
cert_verifier_creation_params) {
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params) {
ChromeContentBrowserClient::ConfigureNetworkContextParams(
context, in_memory, relative_partition_path, network_context_params,
cert_verifier_creation_params);
@@ -305,18 +249,7 @@ void ChromeContentBrowserClientCef::ConfigureNetworkContextParams(
auto cef_context = CefBrowserContext::FromBrowserContext(context);
network_context_params->cookieable_schemes =
cef_context ? cef_context->GetCookieableSchemes()
: CefBrowserContext::GetGlobalCookieableSchemes();
// Prefer the CEF settings configuration, if specified, instead of the
// kAcceptLanguages preference which is controlled by the
// chrome://settings/languages configuration.
const std::string& accept_language_list =
browser_prefs::GetAcceptLanguageList(cef_context, /*browser=*/nullptr,
/*expand=*/true);
if (!accept_language_list.empty() &&
accept_language_list != network_context_params->accept_language) {
network_context_params->accept_language = accept_language_list;
}
: CefCookieManagerImpl::GetGlobalCookieableSchemes();
}
std::unique_ptr<content::LoginDelegate>
@@ -343,39 +276,6 @@ ChromeContentBrowserClientCef::CreateLoginDelegate(
response_headers, first_auth_attempt, std::move(auth_required_callback));
}
void ChromeContentBrowserClientCef::BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) {
// Register the Chrome handlers first for proper URL rewriting.
ChromeContentBrowserClient::BrowserURLHandlerCreated(handler);
scheme::BrowserURLHandlerCreated(handler);
}
bool ChromeContentBrowserClientCef::IsWebUIAllowedToMakeNetworkRequests(
const url::Origin& origin) {
return scheme::IsWebUIAllowedToMakeNetworkRequests(origin);
}
void ChromeContentBrowserClientCef::ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* host) {
ChromeContentBrowserClient::ExposeInterfacesToRenderer(
registry, associated_registry, host);
CefBrowserManager::ExposeInterfacesToRenderer(registry, associated_registry,
host);
}
void ChromeContentBrowserClientCef::RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) {
ChromeContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
render_frame_host, map);
CefBrowserFrame::RegisterBrowserInterfaceBindersForFrame(render_frame_host,
map);
}
CefRefPtr<CefRequestContextImpl>
ChromeContentBrowserClientCef::request_context() const {
return browser_main_parts_->request_context();

View File

@@ -40,15 +40,13 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
bool user_gesture,
bool opener_suppressed,
bool* no_javascript_access) override;
void OverrideWebkitPrefs(content::WebContents* web_contents,
blink::web_pref::WebPreferences* prefs) override;
bool WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,
content::RenderFrameHost* frame,
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
base::Optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -60,12 +58,11 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
const GURL& url,
content::WebContents::OnceGetter web_contents_getter,
int child_id,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
bool HandleExternalProtocol(
@@ -83,8 +80,8 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
bool in_memory,
const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
cert_verifier::mojom::CertVerifierCreationParams*
cert_verifier_creation_params) override;
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params)
override;
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
@@ -94,15 +91,6 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback) override;
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) override;
void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* render_process_host) override;
void RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override;
CefRefPtr<CefRequestContextImpl> request_context() const;

View File

@@ -1,207 +0,0 @@
// Copyright (c) 2021 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_context_menu_handler.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/context_menu_params_impl.h"
#include "libcef/browser/simple_menu_model_impl.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
namespace context_menu {
namespace {
// Lifespan is controlled by RenderViewContextMenu.
class CefContextMenuObserver : public RenderViewContextMenuObserver,
public CefSimpleMenuModelImpl::StateDelegate {
public:
CefContextMenuObserver(RenderViewContextMenu* context_menu,
CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefContextMenuHandler> handler)
: context_menu_(context_menu), browser_(browser), handler_(handler) {}
// RenderViewContextMenuObserver methods:
void InitMenu(const content::ContextMenuParams& params) override {
params_ = new CefContextMenuParamsImpl(
const_cast<content::ContextMenuParams*>(&context_menu_->params()));
model_ = new CefSimpleMenuModelImpl(
const_cast<ui::SimpleMenuModel*>(&context_menu_->menu_model()),
context_menu_, this, /*is_owned=*/false, /*is_popup=*/false);
handler_->OnBeforeContextMenu(browser_, GetFrame(), params_, model_);
}
bool IsCommandIdSupported(int command_id) override {
// Always claim support for the reserved user ID range.
if (command_id >= MENU_ID_USER_FIRST && command_id <= MENU_ID_USER_LAST)
return true;
// Also claim support in specific cases where an ItemInfo exists.
return GetItemInfo(command_id) != nullptr;
}
// Only called if IsCommandIdSupported() returns true.
bool IsCommandIdEnabled(int command_id) override {
// Always return true to use the SimpleMenuModel state.
return true;
}
// Only called if IsCommandIdSupported() returns true.
bool IsCommandIdChecked(int command_id) override {
auto* info = GetItemInfo(command_id);
return info ? info->checked : false;
}
// Only called if IsCommandIdSupported() returns true.
bool GetAccelerator(int command_id, ui::Accelerator* accel) override {
auto* info = GetItemInfo(command_id);
if (info && info->accel) {
*accel = *info->accel;
return true;
}
return false;
}
void CommandWillBeExecuted(int command_id) override {
if (handler_->OnContextMenuCommand(browser_, GetFrame(), params_,
command_id, EVENTFLAG_NONE)) {
// Create an ItemInfo so that we get the ExecuteCommand() callback
// instead of the default handler.
GetOrCreateItemInfo(command_id);
}
}
// Only called if IsCommandIdSupported() returns true.
void ExecuteCommand(int command_id) override {
auto* info = GetItemInfo(command_id);
if (info) {
// In case it was added in CommandWillBeExecuted().
MaybeDeleteItemInfo(command_id, info);
}
}
void OnMenuClosed() override {
handler_->OnContextMenuDismissed(browser_, GetFrame());
model_->Detach();
// Clear stored state because this object won't be deleted until a new
// context menu is created or the associated browser is destroyed.
browser_ = nullptr;
handler_ = nullptr;
params_ = nullptr;
model_ = nullptr;
iteminfomap_.clear();
}
// CefSimpleMenuModelImpl::StateDelegate methods:
void SetChecked(int command_id, bool checked) override {
// No-op if already at the default state.
if (!checked && !GetItemInfo(command_id))
return;
auto* info = GetOrCreateItemInfo(command_id);
info->checked = checked;
if (!checked)
MaybeDeleteItemInfo(command_id, info);
}
void SetAccelerator(int command_id,
absl::optional<ui::Accelerator> accel) override {
// No-op if already at the default state.
if (!accel && !GetItemInfo(command_id))
return;
auto* info = GetOrCreateItemInfo(command_id);
info->accel = accel;
if (!accel)
MaybeDeleteItemInfo(command_id, info);
}
private:
struct ItemInfo {
ItemInfo() {}
bool checked = false;
absl::optional<ui::Accelerator> accel;
};
ItemInfo* GetItemInfo(int command_id) {
auto it = iteminfomap_.find(command_id);
if (it != iteminfomap_.end()) {
return &it->second;
}
return nullptr;
}
ItemInfo* GetOrCreateItemInfo(int command_id) {
if (auto info = GetItemInfo(command_id))
return info;
auto result = iteminfomap_.insert(std::make_pair(command_id, ItemInfo()));
return &result.first->second;
}
void MaybeDeleteItemInfo(int command_id, ItemInfo* info) {
// Remove if all info has reverted to the default state.
if (!info->checked && !info->accel) {
auto it = iteminfomap_.find(command_id);
iteminfomap_.erase(it);
}
}
CefRefPtr<CefFrame> GetFrame() const {
CefRefPtr<CefFrame> frame;
// May return nullptr if the frame is destroyed while the menu is pending.
auto* rfh = context_menu_->GetRenderFrameHost();
if (rfh) {
frame = browser_->GetFrameForHost(rfh);
}
if (!frame) {
frame = browser_->GetMainFrame();
}
return frame;
}
RenderViewContextMenu* const context_menu_;
CefRefPtr<CefBrowserHostBase> browser_;
CefRefPtr<CefContextMenuHandler> handler_;
CefRefPtr<CefContextMenuParams> params_;
CefRefPtr<CefSimpleMenuModelImpl> model_;
// Map of command_id to ItemInfo.
using ItemInfoMap = std::map<int, ItemInfo>;
ItemInfoMap iteminfomap_;
DISALLOW_COPY_AND_ASSIGN(CefContextMenuObserver);
};
std::unique_ptr<RenderViewContextMenuObserver> MenuCreatedCallback(
RenderViewContextMenu* context_menu) {
auto browser = CefBrowserHostBase::GetBrowserForContents(
context_menu->source_web_contents());
if (browser) {
if (auto client = browser->GetClient()) {
if (auto handler = client->GetContextMenuHandler()) {
return std::make_unique<CefContextMenuObserver>(context_menu, browser,
handler);
}
}
}
return nullptr;
}
} // namespace
void RegisterMenuCreatedCallback() {
RenderViewContextMenu::RegisterMenuCreatedCallback(
base::BindRepeating(&MenuCreatedCallback));
}
} // namespace context_menu

View File

@@ -1,16 +0,0 @@
// Copyright (c) 2021 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_CONTEXT_MENU_HANDLER_H_
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTEXT_MENU_HANDLER_H_
#pragma once
namespace context_menu {
// Register the context menu created callback.
void RegisterMenuCreatedCallback();
} // namespace context_menu
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTEXT_MENU_HANDLER_H_

View File

@@ -1,153 +0,0 @@
// Copyright 2021 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/views/browser_platform_delegate_chrome_views.h"
#include "include/views/cef_window.h"
#include "chrome/browser/ui/browser.h"
#include "ui/views/widget/widget.h"
namespace {
// Default popup window delegate implementation.
class PopupWindowDelegate : public CefWindowDelegate {
public:
explicit PopupWindowDelegate(CefRefPtr<CefBrowserView> browser_view)
: browser_view_(browser_view) {}
void OnWindowCreated(CefRefPtr<CefWindow> window) override {
window->AddChildView(browser_view_);
window->Show();
browser_view_->RequestFocus();
}
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override {
browser_view_ = nullptr;
}
bool CanClose(CefRefPtr<CefWindow> window) override {
CefRefPtr<CefBrowser> browser = browser_view_->GetBrowser();
if (browser)
return browser->GetHost()->TryCloseBrowser();
return true;
}
private:
CefRefPtr<CefBrowserView> browser_view_;
IMPLEMENT_REFCOUNTING(PopupWindowDelegate);
DISALLOW_COPY_AND_ASSIGN(PopupWindowDelegate);
};
} // namespace
CefBrowserPlatformDelegateChromeViews::CefBrowserPlatformDelegateChromeViews(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate,
CefRefPtr<CefBrowserViewImpl> browser_view)
: CefBrowserPlatformDelegateChrome(std::move(native_delegate)) {
if (browser_view)
SetBrowserView(browser_view);
}
void CefBrowserPlatformDelegateChromeViews::SetBrowserView(
CefRefPtr<CefBrowserViewImpl> browser_view) {
DCHECK(!browser_view_);
DCHECK(browser_view);
browser_view_ = browser_view;
}
void CefBrowserPlatformDelegateChromeViews::WebContentsCreated(
content::WebContents* web_contents,
bool owned) {
CefBrowserPlatformDelegateChrome::WebContentsCreated(web_contents, owned);
browser_view_->WebContentsCreated(web_contents);
}
void CefBrowserPlatformDelegateChromeViews::BrowserCreated(
CefBrowserHostBase* browser) {
CefBrowserPlatformDelegateChrome::BrowserCreated(browser);
browser_view_->BrowserCreated(browser, base::RepeatingClosure());
}
void CefBrowserPlatformDelegateChromeViews::NotifyBrowserCreated() {
if (browser_view_->delegate())
browser_view_->delegate()->OnBrowserCreated(browser_view_, browser_);
}
void CefBrowserPlatformDelegateChromeViews::NotifyBrowserDestroyed() {
if (browser_view_->delegate())
browser_view_->delegate()->OnBrowserDestroyed(browser_view_, browser_);
}
void CefBrowserPlatformDelegateChromeViews::BrowserDestroyed(
CefBrowserHostBase* browser) {
CefBrowserPlatformDelegateChrome::BrowserDestroyed(browser);
browser_view_->BrowserDestroyed(browser);
}
void CefBrowserPlatformDelegateChromeViews::CloseHostWindow() {
views::Widget* widget = GetWindowWidget();
if (widget && !widget->IsClosed())
widget->Close();
}
views::Widget* CefBrowserPlatformDelegateChromeViews::GetWindowWidget() const {
if (browser_view_->root_view())
return browser_view_->root_view()->GetWidget();
return nullptr;
}
CefRefPtr<CefBrowserView>
CefBrowserPlatformDelegateChromeViews::GetBrowserView() const {
return browser_view_.get();
}
void CefBrowserPlatformDelegateChromeViews::PopupWebContentsCreated(
const CefBrowserSettings& settings,
CefRefPtr<CefClient> client,
content::WebContents* new_web_contents,
CefBrowserPlatformDelegate* new_platform_delegate,
bool is_devtools) {
DCHECK(new_platform_delegate->IsViewsHosted());
auto* new_platform_delegate_impl =
static_cast<CefBrowserPlatformDelegateChromeViews*>(
new_platform_delegate);
CefRefPtr<CefBrowserViewDelegate> new_delegate;
if (browser_view_->delegate()) {
new_delegate = browser_view_->delegate()->GetDelegateForPopupBrowserView(
browser_view_.get(), settings, client, is_devtools);
}
// Create a new BrowserView for the popup.
CefRefPtr<CefBrowserViewImpl> new_browser_view =
CefBrowserViewImpl::CreateForPopup(settings, new_delegate);
// Associate the PlatformDelegate with the new BrowserView.
new_platform_delegate_impl->SetBrowserView(new_browser_view);
}
void CefBrowserPlatformDelegateChromeViews::PopupBrowserCreated(
CefBrowserHostBase* new_browser,
bool is_devtools) {
CefRefPtr<CefBrowserView> new_browser_view =
CefBrowserView::GetForBrowser(new_browser);
DCHECK(new_browser_view);
bool popup_handled = false;
if (browser_view_->delegate()) {
popup_handled = browser_view_->delegate()->OnPopupBrowserViewCreated(
browser_view_.get(), new_browser_view.get(), is_devtools);
}
if (!popup_handled) {
CefWindow::CreateTopLevelWindow(
new PopupWindowDelegate(new_browser_view.get()));
}
}
bool CefBrowserPlatformDelegateChromeViews::IsViewsHosted() const {
return true;
}

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