Compare commits

..

49 Commits
4044 ... 3945

Author SHA1 Message Date
Marshall Greenblatt
ecefb59aa8 Add missing current_view_bounds_ member (see issue #2733) 2020-02-22 12:31:41 -05:00
Marshall Greenblatt
b05ffc446b Fix OSR surface sizing on browser resize (fixes issue #2733).
This includes the following changes:
- Update usage of surface IDs to match the Aura implementation from the
  RWHVAura/Window classes.
- Batch CefBrowserHost::WasResized calls to avoid excessive/unnecessary calls
  to SynchronizeVisualProperties.
- Cache the results of CefRenderHandler::GetViewRect after resize and make
  RWHVOSR::GetViewBounds the source of truth for all size calculations.
- Fix bounds calculations in CefVideoConsumerOSR with GPU enabled.

Known issues:
- The size passed to OnPaint may be off by 1 pixel in cases where the device
  scale factor is not 1 and does not divide evenly into the pixel size. This is
  due to the inexact conversion from integer pixel size to integer logical size
  for GetViewRect.
2020-02-21 15:03:26 -05:00
Marshall Greenblatt
90301bdb7f Fix race between OpenInputStreamWrapper Open and Cancel (fixes issue #2843) 2020-01-29 17:37:53 -05:00
Marshall Greenblatt
febbb4adb7 cefsimple: Fix sizing of popup windows with --use-views (see issue #2854) 2020-01-27 20:39:16 -05:00
Marshall Greenblatt
5dd41fd1c1 Update to Chromium version 79.0.3945.130 2020-01-27 18:47:49 -05:00
Marshall Greenblatt
5ee40133ac Linux: Fix crashes on main window close (fixes issue #2831)
Call DesktopWindowTreeHostPlatform::Close after destroying CEF's X11 window
so that objects owned by the WindowTreeHost (Compositor, X11Window, etc) are
properly cleaned up.
2020-01-27 17:43:35 -05:00
Marshall Greenblatt
1d805e5357 macOS: Disable toolchain prompt for tests (see issue #2692) 2020-01-27 17:43:09 -05:00
Marshall Greenblatt
fc9ef34529 Linux: Add CEF_INSTALL_SYSROOT env variable for calling install-sysroot.py (see issue #1990) 2020-01-16 15:22:03 +01:00
Marshall Greenblatt
f3796e2964 Fix crash due to NULL frame during navigation (fixes issue #2772) 2020-01-16 11:21:29 +01:00
Marshall Greenblatt
a5bf6d5484 Fix potential crash in OpenInputStreamWrapper::Open (fixes issue #2808) 2020-01-15 16:47:16 +01:00
Marshall Greenblatt
f272726527 Windows: cmake: Add VS2019 version 16.4 2020-01-14 16:22:56 +01:00
Marshall Greenblatt
d2449e563c Fix tarfile issues by using GNU_FORMAT with Python 3.8 (see issue #2856) 2020-01-14 11:19:45 +01:00
Marshall Greenblatt
50b44dcfea fix_style: Add Python 3 support (see issue #2856) 2020-01-13 21:45:22 +01:00
Marshall Greenblatt
cb2b46f6d7 crash_server: Add Python 3 support (see issue #2856) 2020-01-13 21:45:14 +01:00
Marshall Greenblatt
1dbdf7b9cb gn_args: Fix representation of int-type GN_DEFINES values (see issue #2856) 2020-01-13 17:02:15 +01:00
Marshall Greenblatt
71efeca335 gn_args: Fix Python 3 AttributeError: 'module' object has no attribute 'exc_clear' (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
cc2fc7eaff Use explicit check for python version (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
f527bf312c build: Add Python 3 support (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
f24e1caec9 gclient_hook: Add Python 3 support (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
6dbe2b782f Fix Python 2 TypeError: write() argument 1 must be unicode, not str (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
716121c74a make_distrib: Add Python 3 support (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
29cbaf7e21 Fix incorrectly translated types in capi header comments (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
ca65ff02c4 translator: Add Python 3 support (see issue #2856)
This also fixes incorrect translation of types in capi header comments.
2020-01-13 17:02:14 +01:00
Marshall Greenblatt
b06a408e7f cef_version: Add Python 3 support (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
5eeb26cb76 patch_updater: Add Python 3 support (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
70c5db44d1 patcher: Add Python 3 support (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
d2de1468d8 gn_args: Add Python 3 support (see issue #2856) 2020-01-13 17:02:14 +01:00
Marshall Greenblatt
497033bd8a cefbuilds: Add Python 3 support (see issue #2856) 2020-01-13 17:02:10 +01:00
Yong Li
7ec49fabd5 Remove possibly incorrect CHECK in ProxyURLLoaderFactory::MaybeDestroySelf()
See also commit #81064faa.
2020-01-08 17:11:24 +02:00
Andrei Kurushin
8c1ac9dc42 Fix OSR popup view mouse wheel double event (fixes issue #2547) 2020-01-08 17:02:22 +02:00
Marshall Greenblatt
b3bb1273fe Update to Chromium version 79.0.3945.117 2020-01-08 16:36:27 +02:00
Riku Palomäki
fae3bd1f16 Ignore OSR paint events on hidden views (fixes issue #2817) 2020-01-08 14:41:27 +02:00
Riku Palomäki
a86d586b9f Fix routing of OSR input events inside iframes (fixes issue #2789)
Mouse events need to be routed to the correct view and
CefRenderWidgetHostViewOSR::TransformPointToCoordSpaceForView needs to be
properly implemented for
RenderWidgetHostInputEventRouter::DispatchTouchscreenGestureEvent to
transform event position in the target widget.
2020-01-08 14:41:20 +02:00
elad bahar
767a901be2 Fix OSR rendering recovery after GPU process crash (fixes issue #2827) 2020-01-08 12:33:57 +00:00
Marshall Greenblatt
d3604dea82 Windows: Build the double_conversion target as C++17 (fixes issue #2819)
This works around a bug in the Visual C++ standard library where the
std::is_integral templates are exported instead of inlined when building
with C++14. See also https://bugs.llvm.org/show_bug.cgi?id=42027.
2020-01-07 15:11:25 +02:00
Marshall Greenblatt
a5342ed51c Only create Documents\Downloads dir if necessary (fixes issue #2841) 2020-01-06 17:00:01 +02:00
Marshall Greenblatt
de7b51479e Fix crash when loading a file URL if using CefCookieAccessFilter (fixes issue #2818) 2020-01-06 14:48:11 +02:00
Marshall Greenblatt
3455686ac7 Fix crash when running with --disable-extensions (fixes issue #2852) 2020-01-06 14:21:30 +02:00
Marshall Greenblatt
cded9f4db3 Update copyright year 2020-01-06 12:05:16 +02:00
Marshall Greenblatt
e866a07123 Update to Chromium version 79.0.3945.88 2019-12-31 19:50:39 +02:00
Marshall Greenblatt
ba025c621c Windows: Fix ImportError: No module named win32file (see https://crbug.com/1033106) 2019-12-31 18:50:40 +02:00
Andy Tzeng
6ef19fd061 Check for non-empty string before writing to logger (fixes issue #2825) 2019-12-31 17:49:27 +02:00
Marshall Greenblatt
e8680c0482 Convert usage and tests to the new CefResourceHandler API (see issue #2622)
Limited test coverage for the old API is still available by passing the
`--test-old-resource-api` command-line flag to ceftests.
2019-12-31 16:52:52 +02:00
Marshall Greenblatt
c10886dc25 Fix shutdown crash in InitNetworkContext with multi-threaded message loop (fixes issue #2703) 2019-11-26 16:30:53 -05:00
Riku Palomäki
76da0744f0 Fix OSR scrolling by passing our compositor to the fling scheduler (fixes issue #2745) 2019-11-26 14:05:53 -05:00
Riku Palomäki
d12e990737 Fix crash when resizing an OSR browser window (fixes issue #2614)
(cherry picked from commit feffedbae9)
2019-11-26 14:05:47 -05:00
Masako Toda
0b5365f822 Pass the raw size of pixel data instead of valid area (fixes issue #2733) 2019-11-26 13:30:50 -05:00
Marshall Greenblatt
f4d74643b0 Fix potential OSR crash due to uninitialized host_display_client_ (see issue #2811) 2019-11-26 13:30:44 -05:00
Marshall Greenblatt
eb5fe4ee13 Update to Chromium version 79.0.3945.36 2019-11-19 19:17:53 -05:00
744 changed files with 5672 additions and 13810 deletions

View File

@@ -1,8 +1,6 @@
# This file is an addendum to the Chromium AUTHORS file. It lists authors # This file is an addendum to the Chromium AUTHORS file.
# through March 16, 2015 when Git was introduced for source code management. # Names should be added to this file like so:
# A list of additional authors added after that date can be found by executing # Name or Organization <email address>
# this command on a local Git checkout:
# git log --all --format="%aN <%aE>" | sort -u
Marshall Greenblatt <magreenblatt@gmail.com> Marshall Greenblatt <magreenblatt@gmail.com>
Jamie Kirkpatrick <jkp@spotify.com> Jamie Kirkpatrick <jkp@spotify.com>

View File

@@ -473,16 +473,6 @@ static_library("libcef_static") {
"libcef/browser/javascript_dialog_manager.h", "libcef/browser/javascript_dialog_manager.h",
"libcef/browser/media_capture_devices_dispatcher.cc", "libcef/browser/media_capture_devices_dispatcher.cc",
"libcef/browser/media_capture_devices_dispatcher.h", "libcef/browser/media_capture_devices_dispatcher.h",
"libcef/browser/media_router/media_route_impl.cc",
"libcef/browser/media_router/media_route_impl.h",
"libcef/browser/media_router/media_router_impl.cc",
"libcef/browser/media_router/media_router_impl.h",
"libcef/browser/media_router/media_router_manager.cc",
"libcef/browser/media_router/media_router_manager.h",
"libcef/browser/media_router/media_sink_impl.cc",
"libcef/browser/media_router/media_sink_impl.h",
"libcef/browser/media_router/media_source_impl.cc",
"libcef/browser/media_router/media_source_impl.h",
"libcef/browser/menu_manager.cc", "libcef/browser/menu_manager.cc",
"libcef/browser/menu_manager.h", "libcef/browser/menu_manager.h",
"libcef/browser/menu_model_impl.cc", "libcef/browser/menu_model_impl.cc",
@@ -697,6 +687,8 @@ static_library("libcef_static") {
"libcef/renderer/render_frame_observer.h", "libcef/renderer/render_frame_observer.h",
"libcef/renderer/render_frame_util.cc", "libcef/renderer/render_frame_util.cc",
"libcef/renderer/render_frame_util.h", "libcef/renderer/render_frame_util.h",
"libcef/renderer/render_message_filter.cc",
"libcef/renderer/render_message_filter.h",
"libcef/renderer/render_thread_observer.cc", "libcef/renderer/render_thread_observer.cc",
"libcef/renderer/render_thread_observer.h", "libcef/renderer/render_thread_observer.h",
"libcef/renderer/render_urlrequest_impl.cc", "libcef/renderer/render_urlrequest_impl.cc",
@@ -782,9 +774,9 @@ static_library("libcef_static") {
"//components/printing/common", "//components/printing/common",
"//components/printing/renderer", "//components/printing/renderer",
"//components/proxy_config", "//components/proxy_config",
"//components/safe_browsing/core/db:test_database_manager", "//components/safe_browsing/db:test_database_manager",
"//components/services/print_compositor/public/cpp", "//components/services/pdf_compositor/public/cpp",
"//components/services/print_compositor/public/mojom", "//components/services/pdf_compositor/public/mojom",
"//components/tracing", "//components/tracing",
"//components/update_client", "//components/update_client",
"//components/url_formatter", "//components/url_formatter",
@@ -815,6 +807,7 @@ static_library("libcef_static") {
"//media", "//media",
"//media/blink", "//media/blink",
"//net", "//net",
"//net:net_with_v8",
"//pdf", "//pdf",
"//ppapi/buildflags", "//ppapi/buildflags",
"//printing/buildflags", "//printing/buildflags",
@@ -829,7 +822,7 @@ static_library("libcef_static") {
"//third_party/cld_3/src/src:cld_3", "//third_party/cld_3/src/src:cld_3",
"//third_party/hunspell", "//third_party/hunspell",
"//third_party/leveldatabase", "//third_party/leveldatabase",
"//third_party/libxml:libxml", "//third_party/libxml",
"//third_party/widevine/cdm:headers", "//third_party/widevine/cdm:headers",
"//third_party/widevine/cdm", "//third_party/widevine/cdm",
"//third_party/icu", "//third_party/icu",
@@ -1105,13 +1098,6 @@ static_library("libcef_static") {
] ]
} }
} }
if (is_win || is_linux) {
sources += [
"libcef/browser/native/browser_platform_delegate_native_aura.cc",
"libcef/browser/native/browser_platform_delegate_native_aura.h",
]
}
} else { } else {
sources += [ sources += [
# Provides stub implementations for the views static methods. # Provides stub implementations for the views static methods.
@@ -1207,6 +1193,7 @@ source_set("cef_content_browser_overlay_manifest") {
source_set("cef_content_renderer_overlay_manifest") { source_set("cef_content_renderer_overlay_manifest") {
sources = [ sources = [
"libcef/common/service_manifests/cef_content_renderer_overlay_manifest.cc",
"libcef/common/service_manifests/cef_content_renderer_overlay_manifest.h", "libcef/common/service_manifests/cef_content_renderer_overlay_manifest.h",
] ]
@@ -1317,8 +1304,6 @@ repack("pak_extensions") {
# Add associated .h files in the make_pack_header("resources") target. # Add associated .h files in the make_pack_header("resources") target.
sources = [ sources = [
"$root_gen_dir/chrome/component_extension_resources.pak", "$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_renderer_resources.pak",
"$root_gen_dir/extensions/extensions_resources.pak", "$root_gen_dir/extensions/extensions_resources.pak",
"$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak", "$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
@@ -1330,8 +1315,6 @@ repack("pak_extensions") {
# listed both here and in the libcef_static target. # listed both here and in the libcef_static target.
public_deps = [ public_deps = [
"//chrome/browser/resources:component_extension_resources", "//chrome/browser/resources:component_extension_resources",
"//content/browser/resources/media:media_internals_resources",
"//content/browser/webrtc/resources",
"//extensions:extensions_renderer_resources", "//extensions:extensions_renderer_resources",
"//extensions:extensions_resources_grd", "//extensions:extensions_resources_grd",
"//mojo/public/js:resources", "//mojo/public/js:resources",
@@ -1387,16 +1370,13 @@ repack("pak") {
# Add associated .h files in the make_pack_header("resources") target. # Add associated .h files in the make_pack_header("resources") target.
sources = [ sources = [
"$root_gen_dir/chrome/browser_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/net_internals_resources.pak",
"$root_gen_dir/chrome/print_preview_resources.pak", "$root_gen_dir/chrome/print_preview_resources.pak",
"$root_gen_dir/chrome/common_resources.pak", "$root_gen_dir/chrome/common_resources.pak",
"$root_gen_dir/components/components_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/cef/cef_resources.pak",
"$root_gen_dir/content/browser/tracing/tracing_resources.pak", "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
"$root_gen_dir/content/content_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/net/net_resources.pak",
"$root_gen_dir/third_party/blink/public/resources/blink_resources.pak", "$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
] ]
@@ -1405,17 +1385,14 @@ repack("pak") {
# the libcef_static target. Grit deps that generate .cc files must be # the libcef_static target. Grit deps that generate .cc files must be
# listed both here and in the libcef_static target. # listed both here and in the libcef_static target.
public_deps = [ public_deps = [
"//chrome/browser:dev_ui_browser_resources",
"//chrome/browser:resources", "//chrome/browser:resources",
"//chrome/browser/resources/net_internals:net_internals_resources", "//chrome/browser/resources:net_internals_resources",
"//chrome/browser/resources:print_preview_resources", "//chrome/browser/resources:print_preview_resources",
"//chrome/common:resources", "//chrome/common:resources",
"//components/resources:components_resources", "//components/resources:components_resources",
"//components/resources:dev_ui_components_resources",
":cef_resources", ":cef_resources",
"//content/browser/tracing:resources", "//content/browser/tracing:resources",
"//content:content_resources", "//content:resources",
"//content:dev_ui_content_resources",
"//net:net_resources", "//net:net_resources",
"//third_party/blink/public:resources", "//third_party/blink/public:resources",
] ]
@@ -1458,15 +1435,12 @@ make_pack_header("resources") {
"$root_gen_dir/chrome/grit/browser_resources.h", "$root_gen_dir/chrome/grit/browser_resources.h",
"$root_gen_dir/chrome/grit/common_resources.h", "$root_gen_dir/chrome/grit/common_resources.h",
"$root_gen_dir/chrome/grit/component_extension_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/net_internals_resources.h",
"$root_gen_dir/chrome/grit/renderer_resources.h", "$root_gen_dir/chrome/grit/renderer_resources.h",
"$root_gen_dir/components/grit/components_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/devtools/grit/devtools_resources.h",
"$root_gen_dir/content/browser/tracing/grit/tracing_resources.h", "$root_gen_dir/content/browser/tracing/grit/tracing_resources.h",
"$root_gen_dir/content/grit/content_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_browser_resources.h",
"$root_gen_dir/extensions/grit/extensions_renderer_resources.h", "$root_gen_dir/extensions/grit/extensions_renderer_resources.h",
"$root_gen_dir/extensions/grit/extensions_resources.h", "$root_gen_dir/extensions/grit/extensions_resources.h",
@@ -1563,6 +1537,7 @@ if (is_mac) {
if (v8_use_external_startup_data) { if (v8_use_external_startup_data) {
sources += [ sources += [
"$root_out_dir/natives_blob.bin",
"$root_out_dir/snapshot_blob.bin", "$root_out_dir/snapshot_blob.bin",
] ]
public_deps += [ "//v8" ] public_deps += [ "//v8" ]
@@ -2162,18 +2137,13 @@ if (is_mac) {
libs = [ libs = [
"comctl32.lib", "comctl32.lib",
"d3d11.lib", "d3d11.lib",
"glu32.lib",
"imm32.lib", "imm32.lib",
"oleacc.lib", "oleacc.lib",
"opengl32.lib",
"rpcrt4.lib", "rpcrt4.lib",
"shlwapi.lib", "shlwapi.lib",
] ]
if (target_cpu != "arm64") {
libs += [
"opengl32.lib",
"glu32.lib"
]
}
} }
if (is_linux) { if (is_linux) {

View File

@@ -7,6 +7,5 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding # https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{ {
'chromium_checkout': 'refs/tags/81.0.4044.138', 'chromium_checkout': 'refs/tags/79.0.3945.130'
'depot_tools_checkout': 'ec2a6ce270'
} }

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for # by hand. See the translator.README.txt file in the tools directory for
# more information. # more information.
# #
# $hash=578c0aef11c3c7840679e480069fc9031c628e25$ # $hash=98198bc4243deb46c848735f0d5499aa4891e535$
# #
{ {
@@ -43,7 +43,6 @@
'include/cef_keyboard_handler.h', 'include/cef_keyboard_handler.h',
'include/cef_life_span_handler.h', 'include/cef_life_span_handler.h',
'include/cef_load_handler.h', 'include/cef_load_handler.h',
'include/cef_media_router.h',
'include/cef_menu_model.h', 'include/cef_menu_model.h',
'include/cef_menu_model_delegate.h', 'include/cef_menu_model_delegate.h',
'include/cef_navigation_entry.h', 'include/cef_navigation_entry.h',
@@ -54,7 +53,6 @@
'include/cef_print_settings.h', 'include/cef_print_settings.h',
'include/cef_process_message.h', 'include/cef_process_message.h',
'include/cef_process_util.h', 'include/cef_process_util.h',
'include/cef_registration.h',
'include/cef_render_handler.h', 'include/cef_render_handler.h',
'include/cef_render_process_handler.h', 'include/cef_render_process_handler.h',
'include/cef_request.h', 'include/cef_request.h',
@@ -138,7 +136,6 @@
'include/capi/cef_keyboard_handler_capi.h', 'include/capi/cef_keyboard_handler_capi.h',
'include/capi/cef_life_span_handler_capi.h', 'include/capi/cef_life_span_handler_capi.h',
'include/capi/cef_load_handler_capi.h', 'include/capi/cef_load_handler_capi.h',
'include/capi/cef_media_router_capi.h',
'include/capi/cef_menu_model_capi.h', 'include/capi/cef_menu_model_capi.h',
'include/capi/cef_menu_model_delegate_capi.h', 'include/capi/cef_menu_model_delegate_capi.h',
'include/capi/cef_navigation_entry_capi.h', 'include/capi/cef_navigation_entry_capi.h',
@@ -149,7 +146,6 @@
'include/capi/cef_print_settings_capi.h', 'include/capi/cef_print_settings_capi.h',
'include/capi/cef_process_message_capi.h', 'include/capi/cef_process_message_capi.h',
'include/capi/cef_process_util_capi.h', 'include/capi/cef_process_util_capi.h',
'include/capi/cef_registration_capi.h',
'include/capi/cef_render_handler_capi.h', 'include/capi/cef_render_handler_capi.h',
'include/capi/cef_render_process_handler_capi.h', 'include/capi/cef_render_process_handler_capi.h',
'include/capi/cef_request_capi.h', 'include/capi/cef_request_capi.h',
@@ -312,18 +308,6 @@
'libcef_dll/cpptoc/list_value_cpptoc.h', 'libcef_dll/cpptoc/list_value_cpptoc.h',
'libcef_dll/ctocpp/load_handler_ctocpp.cc', 'libcef_dll/ctocpp/load_handler_ctocpp.cc',
'libcef_dll/ctocpp/load_handler_ctocpp.h', 'libcef_dll/ctocpp/load_handler_ctocpp.h',
'libcef_dll/ctocpp/media_observer_ctocpp.cc',
'libcef_dll/ctocpp/media_observer_ctocpp.h',
'libcef_dll/cpptoc/media_route_cpptoc.cc',
'libcef_dll/cpptoc/media_route_cpptoc.h',
'libcef_dll/ctocpp/media_route_create_callback_ctocpp.cc',
'libcef_dll/ctocpp/media_route_create_callback_ctocpp.h',
'libcef_dll/cpptoc/media_router_cpptoc.cc',
'libcef_dll/cpptoc/media_router_cpptoc.h',
'libcef_dll/cpptoc/media_sink_cpptoc.cc',
'libcef_dll/cpptoc/media_sink_cpptoc.h',
'libcef_dll/cpptoc/media_source_cpptoc.cc',
'libcef_dll/cpptoc/media_source_cpptoc.h',
'libcef_dll/cpptoc/views/menu_button_cpptoc.cc', 'libcef_dll/cpptoc/views/menu_button_cpptoc.cc',
'libcef_dll/cpptoc/views/menu_button_cpptoc.h', 'libcef_dll/cpptoc/views/menu_button_cpptoc.h',
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc', 'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc',
@@ -362,8 +346,6 @@
'libcef_dll/ctocpp/read_handler_ctocpp.h', 'libcef_dll/ctocpp/read_handler_ctocpp.h',
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.cc', 'libcef_dll/ctocpp/register_cdm_callback_ctocpp.cc',
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.h', 'libcef_dll/ctocpp/register_cdm_callback_ctocpp.h',
'libcef_dll/cpptoc/registration_cpptoc.cc',
'libcef_dll/cpptoc/registration_cpptoc.h',
'libcef_dll/ctocpp/render_handler_ctocpp.cc', 'libcef_dll/ctocpp/render_handler_ctocpp.cc',
'libcef_dll/ctocpp/render_handler_ctocpp.h', 'libcef_dll/ctocpp/render_handler_ctocpp.h',
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc', 'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
@@ -616,18 +598,6 @@
'libcef_dll/ctocpp/list_value_ctocpp.h', 'libcef_dll/ctocpp/list_value_ctocpp.h',
'libcef_dll/cpptoc/load_handler_cpptoc.cc', 'libcef_dll/cpptoc/load_handler_cpptoc.cc',
'libcef_dll/cpptoc/load_handler_cpptoc.h', 'libcef_dll/cpptoc/load_handler_cpptoc.h',
'libcef_dll/cpptoc/media_observer_cpptoc.cc',
'libcef_dll/cpptoc/media_observer_cpptoc.h',
'libcef_dll/ctocpp/media_route_ctocpp.cc',
'libcef_dll/ctocpp/media_route_ctocpp.h',
'libcef_dll/cpptoc/media_route_create_callback_cpptoc.cc',
'libcef_dll/cpptoc/media_route_create_callback_cpptoc.h',
'libcef_dll/ctocpp/media_router_ctocpp.cc',
'libcef_dll/ctocpp/media_router_ctocpp.h',
'libcef_dll/ctocpp/media_sink_ctocpp.cc',
'libcef_dll/ctocpp/media_sink_ctocpp.h',
'libcef_dll/ctocpp/media_source_ctocpp.cc',
'libcef_dll/ctocpp/media_source_ctocpp.h',
'libcef_dll/ctocpp/views/menu_button_ctocpp.cc', 'libcef_dll/ctocpp/views/menu_button_ctocpp.cc',
'libcef_dll/ctocpp/views/menu_button_ctocpp.h', 'libcef_dll/ctocpp/views/menu_button_ctocpp.h',
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc', 'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc',
@@ -666,8 +636,6 @@
'libcef_dll/cpptoc/read_handler_cpptoc.h', 'libcef_dll/cpptoc/read_handler_cpptoc.h',
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.cc', 'libcef_dll/cpptoc/register_cdm_callback_cpptoc.cc',
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.h', 'libcef_dll/cpptoc/register_cdm_callback_cpptoc.h',
'libcef_dll/ctocpp/registration_ctocpp.cc',
'libcef_dll/ctocpp/registration_ctocpp.h',
'libcef_dll/cpptoc/render_handler_cpptoc.cc', 'libcef_dll/cpptoc/render_handler_cpptoc.cc',
'libcef_dll/cpptoc/render_handler_cpptoc.h', 'libcef_dll/cpptoc/render_handler_cpptoc.h',
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc', 'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',

View File

@@ -238,8 +238,6 @@
'tests/cefclient/browser/main_context.h', 'tests/cefclient/browser/main_context.h',
'tests/cefclient/browser/main_context_impl.cc', 'tests/cefclient/browser/main_context_impl.cc',
'tests/cefclient/browser/main_context_impl.h', 'tests/cefclient/browser/main_context_impl.h',
'tests/cefclient/browser/media_router_test.cc',
'tests/cefclient/browser/media_router_test.h',
'tests/cefclient/browser/osr_dragdrop_events.h', 'tests/cefclient/browser/osr_dragdrop_events.h',
'tests/cefclient/browser/osr_renderer.h', 'tests/cefclient/browser/osr_renderer.h',
'tests/cefclient/browser/osr_renderer.cc', 'tests/cefclient/browser/osr_renderer.cc',
@@ -289,7 +287,6 @@
'tests/cefclient/resources/drm.html', 'tests/cefclient/resources/drm.html',
'tests/cefclient/resources/localstorage.html', 'tests/cefclient/resources/localstorage.html',
'tests/cefclient/resources/logo.png', 'tests/cefclient/resources/logo.png',
'tests/cefclient/resources/media_router.html',
'tests/cefclient/resources/menu_icon.1x.png', 'tests/cefclient/resources/menu_icon.1x.png',
'tests/cefclient/resources/menu_icon.2x.png', 'tests/cefclient/resources/menu_icon.2x.png',
'tests/cefclient/resources/other_tests.html', 'tests/cefclient/resources/other_tests.html',

View File

@@ -218,6 +218,7 @@ if(OS_LINUX)
libcef.so libcef.so
libEGL.so libEGL.so
libGLESv2.so libGLESv2.so
natives_blob.bin
snapshot_blob.bin snapshot_blob.bin
v8_context_snapshot.bin v8_context_snapshot.bin
swiftshader swiftshader
@@ -480,6 +481,7 @@ if(OS_WINDOWS)
libcef.dll libcef.dll
libEGL.dll libEGL.dll
libGLESv2.dll libGLESv2.dll
natives_blob.bin
snapshot_blob.bin snapshot_blob.bin
v8_context_snapshot.bin v8_context_snapshot.bin
swiftshader swiftshader

View File

@@ -178,7 +178,7 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
// Include our platform specific implementation. // Include our platform specific implementation.
#if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY) #if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY)
#include "include/base/internal/cef_atomicops_x86_msvc.h" #include "include/base/internal/cef_atomicops_x86_msvc.h"
#elif defined(OS_WIN) && (defined(__ARM_ARCH_ISA_A64) || defined(_M_ARM64)) #elif defined(OS_WIN) && defined(__ARM_ARCH_ISA_A64)
#include "include/base/internal/cef_atomicops_arm64_msvc.h" #include "include/base/internal/cef_atomicops_arm64_msvc.h"
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
#include "include/base/internal/cef_atomicops_mac.h" #include "include/base/internal/cef_atomicops_mac.h"

View File

@@ -95,7 +95,7 @@
#define ARCH_CPU_ARMEL 1 #define ARCH_CPU_ARMEL 1
#define ARCH_CPU_32_BITS 1 #define ARCH_CPU_32_BITS 1
#define ARCH_CPU_LITTLE_ENDIAN 1 #define ARCH_CPU_LITTLE_ENDIAN 1
#elif defined(__aarch64__) || defined(_M_ARM64) #elif defined(__aarch64__)
#define ARCH_CPU_ARM_FAMILY 1 #define ARCH_CPU_ARM_FAMILY 1
#define ARCH_CPU_ARM64 1 #define ARCH_CPU_ARM64 1
#define ARCH_CPU_64_BITS 1 #define ARCH_CPU_64_BITS 1

View File

@@ -144,9 +144,9 @@
// Always define the DCHECK_IS_ON macro which is used from other CEF headers. // Always define the DCHECK_IS_ON macro which is used from other CEF headers.
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
#define DCHECK_IS_ON() false #define DCHECK_IS_ON() 0
#else #else
#define DCHECK_IS_ON() true #define DCHECK_IS_ON() 1
#endif #endif
#elif defined(USING_CHROMIUM_INCLUDES) #elif defined(USING_CHROMIUM_INCLUDES)

View File

@@ -1,328 +0,0 @@
// Copyright (c) 2020 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=aa1310919932145744d5347d449d6ee10a3a0813$
//
#ifndef CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_registration_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_media_observer_t;
struct _cef_media_route_create_callback_t;
struct _cef_media_route_t;
struct _cef_media_sink_t;
struct _cef_media_source_t;
///
// Supports discovery of and communication with media devices on the local
// network via the Cast and DIAL protocols. The functions of this structure may
// be called on any browser process thread unless otherwise indicated.
///
typedef struct _cef_media_router_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Add an observer for MediaRouter events. The observer will remain registered
// until the returned Registration object is destroyed.
///
struct _cef_registration_t*(CEF_CALLBACK* add_observer)(
struct _cef_media_router_t* self,
struct _cef_media_observer_t* observer);
///
// Returns a MediaSource object for the specified media source URN. Supported
// URN schemes include "cast:" and "dial:", and will be already known by the
// client application (e.g. "cast:<appId>?clientId=<clientId>").
///
struct _cef_media_source_t*(CEF_CALLBACK* get_source)(
struct _cef_media_router_t* self,
const cef_string_t* urn);
///
// Trigger an asynchronous call to cef_media_observer_t::OnSinks on all
// registered observers.
///
void(CEF_CALLBACK* notify_current_sinks)(struct _cef_media_router_t* self);
///
// Create a new route between |source| and |sink|. Source and sink must be
// valid, compatible (as reported by cef_media_sink_t::IsCompatibleWith), and
// a route between them must not already exist. |callback| will be executed on
// success or failure. If route creation succeeds it will also trigger an
// asynchronous call to cef_media_observer_t::OnRoutes on all registered
// observers.
///
void(CEF_CALLBACK* create_route)(
struct _cef_media_router_t* self,
struct _cef_media_source_t* source,
struct _cef_media_sink_t* sink,
struct _cef_media_route_create_callback_t* callback);
///
// Trigger an asynchronous call to cef_media_observer_t::OnRoutes on all
// registered observers.
///
void(CEF_CALLBACK* notify_current_routes)(struct _cef_media_router_t* self);
} cef_media_router_t;
///
// 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();
///
// Implemented by the client to observe MediaRouter events and registered via
// cef_media_router_t::AddObserver. The functions of this structure will be
// called on the browser process UI thread.
///
typedef struct _cef_media_observer_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// The list of available media sinks has changed or
// cef_media_router_t::NotifyCurrentSinks was called.
///
void(CEF_CALLBACK* on_sinks)(struct _cef_media_observer_t* self,
size_t sinksCount,
struct _cef_media_sink_t* const* sinks);
///
// The list of available media routes has changed or
// cef_media_router_t::NotifyCurrentRoutes was called.
///
void(CEF_CALLBACK* on_routes)(struct _cef_media_observer_t* self,
size_t routesCount,
struct _cef_media_route_t* const* routes);
///
// The connection state of |route| has changed.
///
void(CEF_CALLBACK* on_route_state_changed)(
struct _cef_media_observer_t* self,
struct _cef_media_route_t* route,
cef_media_route_connection_state_t state);
///
// A message was recieved over |route|. |message| is only valid for the scope
// of this callback and should be copied if necessary.
///
void(CEF_CALLBACK* on_route_message_received)(
struct _cef_media_observer_t* self,
struct _cef_media_route_t* route,
const void* message,
size_t message_size);
} cef_media_observer_t;
///
// Represents the route between a media source and sink. Instances of this
// object are created via cef_media_router_t::CreateRoute and retrieved via
// cef_media_observer_t::OnRoutes. Contains the status and metadata of a routing
// operation. The functions of this structure may be called on any browser
// process thread unless otherwise indicated.
///
typedef struct _cef_media_route_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns the ID for this route.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_route_t* self);
///
// Returns the source associated with this route.
///
struct _cef_media_source_t*(CEF_CALLBACK* get_source)(
struct _cef_media_route_t* self);
///
// Returns the sink associated with this route.
///
struct _cef_media_sink_t*(CEF_CALLBACK* get_sink)(
struct _cef_media_route_t* self);
///
// Send a message over this route. |message| will be copied if necessary.
///
void(CEF_CALLBACK* send_route_message)(struct _cef_media_route_t* self,
const void* message,
size_t message_size);
///
// Terminate this route. Will result in an asynchronous call to
// cef_media_observer_t::OnRoutes on all registered observers.
///
void(CEF_CALLBACK* terminate)(struct _cef_media_route_t* self);
} cef_media_route_t;
///
// Callback structure for cef_media_router_t::CreateRoute. The functions of this
// structure will be called on the browser process UI thread.
///
typedef struct _cef_media_route_create_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Method that will be executed when the route creation has finished. |result|
// will be CEF_MRCR_OK if the route creation succeeded. |error| will be a
// description of the error if the route creation failed. |route| is the
// resulting route, or NULL if the route creation failed.
///
void(CEF_CALLBACK* on_media_route_create_finished)(
struct _cef_media_route_create_callback_t* self,
cef_media_route_create_result_t result,
const cef_string_t* error,
struct _cef_media_route_t* route);
} cef_media_route_create_callback_t;
///
// Represents a sink to which media can be routed. Instances of this object are
// retrieved via cef_media_observer_t::OnSinks. The functions of this structure
// may be called on any browser process thread unless otherwise indicated.
///
typedef struct _cef_media_sink_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns the ID for this sink.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_sink_t* self);
///
// Returns true (1) if this sink is valid.
///
int(CEF_CALLBACK* is_valid)(struct _cef_media_sink_t* self);
///
// Returns the name of this sink.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_media_sink_t* self);
///
// Returns the description of this sink.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_description)(
struct _cef_media_sink_t* self);
///
// Returns the icon type for this sink.
///
cef_media_sink_icon_type_t(CEF_CALLBACK* get_icon_type)(
struct _cef_media_sink_t* self);
///
// Returns true (1) if this sink accepts content via Cast.
///
int(CEF_CALLBACK* is_cast_sink)(struct _cef_media_sink_t* self);
///
// Returns true (1) if this sink accepts content via DIAL.
///
int(CEF_CALLBACK* is_dial_sink)(struct _cef_media_sink_t* self);
///
// Returns true (1) if this sink is compatible with |source|.
///
int(CEF_CALLBACK* is_compatible_with)(struct _cef_media_sink_t* self,
struct _cef_media_source_t* source);
} cef_media_sink_t;
///
// Represents a source from which media can be routed. Instances of this object
// are retrieved via cef_media_router_t::GetSource. The functions of this
// structure may be called on any browser process thread unless otherwise
// indicated.
///
typedef struct _cef_media_source_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns the ID (media source URN or URL) for this source.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_source_t* self);
///
// Returns true (1) if this source is valid.
///
int(CEF_CALLBACK* is_valid)(struct _cef_media_source_t* self);
///
// Returns true (1) if this source outputs its content via Cast.
///
int(CEF_CALLBACK* is_cast_source)(struct _cef_media_source_t* self);
///
// Returns true (1) if this source outputs its content via DIAL.
///
int(CEF_CALLBACK* is_dial_source)(struct _cef_media_source_t* self);
} cef_media_source_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_

View File

@@ -1,63 +0,0 @@
// Copyright (c) 2020 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=029e237cf80f94a25453bac5a9b1e0765bb56f37$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Generic callback structure used for managing the lifespan of a registration.
///
typedef struct _cef_registration_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
} cef_registration_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=7ce0953f069204a4dd2037c4a05ac9454c5e66a6$ // $hash=2b01472d9b9a8cc9d1b2e669c91c2849bdb162e9$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@@ -44,7 +44,6 @@
#include "include/capi/cef_cookie_capi.h" #include "include/capi/cef_cookie_capi.h"
#include "include/capi/cef_extension_capi.h" #include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_extension_handler_capi.h" #include "include/capi/cef_extension_handler_capi.h"
#include "include/capi/cef_media_router_capi.h"
#include "include/capi/cef_values_capi.h" #include "include/capi/cef_values_capi.h"
#ifdef __cplusplus #ifdef __cplusplus
@@ -354,12 +353,6 @@ typedef struct _cef_request_context_t {
struct _cef_extension_t*(CEF_CALLBACK* get_extension)( struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
struct _cef_request_context_t* self, struct _cef_request_context_t* self,
const cef_string_t* extension_id); const cef_string_t* extension_id);
///
// Returns the MediaRouter object associated with this context.
///
struct _cef_media_router_t*(CEF_CALLBACK* get_media_router)(
struct _cef_request_context_t* self);
} cef_request_context_t; } cef_request_context_t;
/// ///

View File

@@ -34,7 +34,7 @@
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
// $hash=fd013f5bdcf2333b1f0fb452442d300dffe598e5$ // $hash=06d0c1ccfa43926a01cbeb3ec95ff2a001fd0b45$
// //
#ifndef CEF_INCLUDE_API_HASH_H_ #ifndef CEF_INCLUDE_API_HASH_H_
@@ -47,13 +47,13 @@
// way that may cause binary incompatibility with other builds. The universal // way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash // hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected. // values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "c80d4c5f1dc72279ac7a44d7b174fb80cf728abc" #define CEF_API_HASH_UNIVERSAL "3ad9591f7024619a1e2fd796c7ad51ae3a34abbb"
#if defined(OS_WIN) #if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "bde71fdc88914ed7353ee7308d060cd6b4f8c8af" #define CEF_API_HASH_PLATFORM "3b8e38ae40c1a930227c6277c39dbc24081ccec1"
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
#define CEF_API_HASH_PLATFORM "2fb3e42a6d2e594aa55792b5852d7f57524ab011" #define CEF_API_HASH_PLATFORM "4a77f1908fabccdb01a2d3bdbede5ca09fbaa394"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "222824f83536a111c6480dba64833251c01cd6fd" #define CEF_API_HASH_PLATFORM "434da6be7db70fd90c4265118ac47ace4073c6ae"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -178,7 +178,7 @@ class CefApp : public virtual CefBaseRefCounted {
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() { virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() {
return nullptr; return NULL;
} }
/// ///
@@ -187,7 +187,7 @@ class CefApp : public virtual CefBaseRefCounted {
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() { virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
return nullptr; return NULL;
} }
/// ///
@@ -196,7 +196,7 @@ class CefApp : public virtual CefBaseRefCounted {
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() { virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() {
return nullptr; return NULL;
} }
}; };

View File

@@ -84,7 +84,7 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
// provided then printing will not be supported on the Linux platform. // provided then printing will not be supported on the Linux platform.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() { return nullptr; } virtual CefRefPtr<CefPrintHandler> GetPrintHandler() { return NULL; }
/// ///
// Called from any thread when work has been scheduled for the browser process // Called from any thread when work has been scheduled for the browser process

View File

@@ -66,7 +66,7 @@ class CefClient : public virtual CefBaseRefCounted {
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() { virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() {
return nullptr; return NULL;
} }
/// ///
@@ -74,75 +74,75 @@ class CefClient : public virtual CefBaseRefCounted {
// implementation will be used. // implementation will be used.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefDialogHandler> GetDialogHandler() { return nullptr; } virtual CefRefPtr<CefDialogHandler> GetDialogHandler() { return NULL; }
/// ///
// Return the handler for browser display state events. // Return the handler for browser display state events.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() { return nullptr; } virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() { return NULL; }
/// ///
// Return the handler for download events. If no handler is returned downloads // Return the handler for download events. If no handler is returned downloads
// will not be allowed. // will not be allowed.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() { return nullptr; } virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() { return NULL; }
/// ///
// Return the handler for drag events. // Return the handler for drag events.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefDragHandler> GetDragHandler() { return nullptr; } virtual CefRefPtr<CefDragHandler> GetDragHandler() { return NULL; }
/// ///
// Return the handler for find result events. // Return the handler for find result events.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefFindHandler> GetFindHandler() { return nullptr; } virtual CefRefPtr<CefFindHandler> GetFindHandler() { return NULL; }
/// ///
// Return the handler for focus events. // Return the handler for focus events.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() { return nullptr; } virtual CefRefPtr<CefFocusHandler> GetFocusHandler() { return NULL; }
/// ///
// Return the handler for JavaScript dialogs. If no handler is provided the // Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used. // default implementation will be used.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() { return nullptr; } virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() { return NULL; }
/// ///
// Return the handler for keyboard events. // Return the handler for keyboard events.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() { return nullptr; } virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() { return NULL; }
/// ///
// Return the handler for browser life span events. // Return the handler for browser life span events.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() { return nullptr; } virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() { return NULL; }
/// ///
// Return the handler for browser load status events. // Return the handler for browser load status events.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() { return nullptr; } virtual CefRefPtr<CefLoadHandler> GetLoadHandler() { return NULL; }
/// ///
// Return the handler for off-screen rendering events. // Return the handler for off-screen rendering events.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() { return nullptr; } virtual CefRefPtr<CefRenderHandler> GetRenderHandler() { return NULL; }
/// ///
// Return the handler for browser request events. // Return the handler for browser request events.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() { return nullptr; } virtual CefRefPtr<CefRequestHandler> GetRequestHandler() { return NULL; }
/// ///
// Called when a new message is received from a different process. Return true // Called when a new message is received from a different process. Return true

View File

@@ -157,7 +157,7 @@ class CefExtensionHandler : public virtual CefBaseRefCounted {
CefRefPtr<CefExtension> extension, CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser, CefRefPtr<CefBrowser> browser,
bool include_incognito) { bool include_incognito) {
return nullptr; return NULL;
} }
/// ///

View File

@@ -1,308 +0,0 @@
// Copyright (c) 2020 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_MEDIA_ROUTER_H_
#define CEF_INCLUDE_CEF_MEDIA_ROUTER_H_
#pragma once
#include <vector>
#include "include/cef_base.h"
#include "include/cef_registration.h"
class CefMediaObserver;
class CefMediaRoute;
class CefMediaRouteCreateCallback;
class CefMediaSink;
class CefMediaSource;
///
// Supports discovery of and communication with media devices on the local
// network via the Cast and DIAL protocols. The methods of this class may be
// called on any browser process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaRouter : public virtual CefBaseRefCounted {
public:
///
// Returns the MediaRouter object associated with the global request context.
// Equivalent to calling
// CefRequestContext::GetGlobalContext()->GetMediaRouter().
///
/*--cef()--*/
static CefRefPtr<CefMediaRouter> GetGlobalMediaRouter();
///
// Add an observer for MediaRouter events. The observer will remain registered
// until the returned Registration object is destroyed.
///
/*--cef()--*/
virtual CefRefPtr<CefRegistration> AddObserver(
CefRefPtr<CefMediaObserver> observer) = 0;
///
// Returns a MediaSource object for the specified media source URN. Supported
// URN schemes include "cast:" and "dial:", and will be already known by the
// client application (e.g. "cast:<appId>?clientId=<clientId>").
///
/*--cef()--*/
virtual CefRefPtr<CefMediaSource> GetSource(const CefString& urn) = 0;
///
// Trigger an asynchronous call to CefMediaObserver::OnSinks on all
// registered observers.
///
/*--cef()--*/
virtual void NotifyCurrentSinks() = 0;
///
// Create a new route between |source| and |sink|. Source and sink must be
// valid, compatible (as reported by CefMediaSink::IsCompatibleWith), and a
// route between them must not already exist. |callback| will be executed
// on success or failure. If route creation succeeds it will also trigger an
// asynchronous call to CefMediaObserver::OnRoutes on all registered
// observers.
///
/*--cef()--*/
virtual void CreateRoute(CefRefPtr<CefMediaSource> source,
CefRefPtr<CefMediaSink> sink,
CefRefPtr<CefMediaRouteCreateCallback> callback) = 0;
///
// Trigger an asynchronous call to CefMediaObserver::OnRoutes on all
// registered observers.
///
/*--cef()--*/
virtual void NotifyCurrentRoutes() = 0;
};
///
// Implemented by the client to observe MediaRouter events and registered via
// CefMediaRouter::AddObserver. The methods of this class will be called on the
// browser process UI thread.
///
/*--cef(source=client)--*/
class CefMediaObserver : public virtual CefBaseRefCounted {
public:
typedef cef_media_route_connection_state_t ConnectionState;
///
// The list of available media sinks has changed or
// CefMediaRouter::NotifyCurrentSinks was called.
///
/*--cef()--*/
virtual void OnSinks(const std::vector<CefRefPtr<CefMediaSink>>& sinks) = 0;
///
// The list of available media routes has changed or
// CefMediaRouter::NotifyCurrentRoutes was called.
///
/*--cef()--*/
virtual void OnRoutes(
const std::vector<CefRefPtr<CefMediaRoute>>& routes) = 0;
///
// The connection state of |route| has changed.
///
/*--cef()--*/
virtual void OnRouteStateChanged(CefRefPtr<CefMediaRoute> route,
ConnectionState state) = 0;
///
// A message was recieved over |route|. |message| is only valid for
// the scope of this callback and should be copied if necessary.
///
/*--cef()--*/
virtual void OnRouteMessageReceived(CefRefPtr<CefMediaRoute> route,
const void* message,
size_t message_size) = 0;
};
///
// Represents the route between a media source and sink. Instances of this
// object are created via CefMediaRouter::CreateRoute and retrieved via
// CefMediaObserver::OnRoutes. Contains the status and metadata of a
// routing operation. The methods of this class may be called on any browser
// process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaRoute : public virtual CefBaseRefCounted {
public:
///
// Returns the ID for this route.
///
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns the source associated with this route.
///
/*--cef()--*/
virtual CefRefPtr<CefMediaSource> GetSource() = 0;
///
// Returns the sink associated with this route.
///
/*--cef()--*/
virtual CefRefPtr<CefMediaSink> GetSink() = 0;
///
// Send a message over this route. |message| will be copied if necessary.
///
/*--cef()--*/
virtual void SendRouteMessage(const void* message, size_t message_size) = 0;
///
// Terminate this route. Will result in an asynchronous call to
// CefMediaObserver::OnRoutes on all registered observers.
///
/*--cef()--*/
virtual void Terminate() = 0;
};
///
// Callback interface for CefMediaRouter::CreateRoute. The methods of this
// class will be called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefMediaRouteCreateCallback : public virtual CefBaseRefCounted {
public:
typedef cef_media_route_create_result_t RouteCreateResult;
///
// Method that will be executed when the route creation has finished. |result|
// will be CEF_MRCR_OK if the route creation succeeded. |error| will be a
// description of the error if the route creation failed. |route| is the
// resulting route, or empty if the route creation failed.
///
/*--cef(optional_param=error,optional_param=route)--*/
virtual void OnMediaRouteCreateFinished(RouteCreateResult result,
const CefString& error,
CefRefPtr<CefMediaRoute> route) = 0;
};
///
// Represents a sink to which media can be routed. Instances of this object are
// retrieved via CefMediaObserver::OnSinks. The methods of this class may
// be called on any browser process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaSink : public virtual CefBaseRefCounted {
public:
typedef cef_media_sink_icon_type_t IconType;
///
// Returns the ID for this sink.
///
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns true if this sink is valid.
///
/*--cef()--*/
virtual bool IsValid() = 0;
///
// Returns the name of this sink.
///
/*--cef()--*/
virtual CefString GetName() = 0;
///
// Returns the description of this sink.
///
/*--cef()--*/
virtual CefString GetDescription() = 0;
///
// Returns the icon type for this sink.
///
/*--cef(default_retval=CEF_MSIT_GENERIC)--*/
virtual IconType GetIconType() = 0;
///
// Returns true if this sink accepts content via Cast.
///
/*--cef()--*/
virtual bool IsCastSink() = 0;
///
// Returns true if this sink accepts content via DIAL.
///
/*--cef()--*/
virtual bool IsDialSink() = 0;
///
// Returns true if this sink is compatible with |source|.
///
/*--cef()--*/
virtual bool IsCompatibleWith(CefRefPtr<CefMediaSource> source) = 0;
};
///
// Represents a source from which media can be routed. Instances of this object
// are retrieved via CefMediaRouter::GetSource. The methods of this class may be
// called on any browser process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaSource : public virtual CefBaseRefCounted {
public:
///
// Returns the ID (media source URN or URL) for this source.
///
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns true if this source is valid.
///
/*--cef()--*/
virtual bool IsValid() = 0;
///
// Returns true if this source outputs its content via Cast.
///
/*--cef()--*/
virtual bool IsCastSource() = 0;
///
// Returns true if this source outputs its content via DIAL.
///
/*--cef()--*/
virtual bool IsDialSource() = 0;
};
#endif // CEF_INCLUDE_CEF_MEDIA_ROUTER_H_

View File

@@ -1,49 +0,0 @@
// Copyright (c) 2020 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_REGISTRATION_H_
#define CEF_INCLUDE_CEF_REGISTRATION_H_
#pragma once
#include "include/cef_base.h"
///
// Generic callback interface used for managing the lifespan of a registration.
///
/*--cef(source=library)--*/
class CefRegistration : public virtual CefBaseRefCounted {};
#endif // CEF_INCLUDE_CEF_REGISTRATION_H_

View File

@@ -65,7 +65,7 @@ class CefRenderHandler : public virtual CefBaseRefCounted {
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefAccessibilityHandler> GetAccessibilityHandler() { virtual CefRefPtr<CefAccessibilityHandler> GetAccessibilityHandler() {
return nullptr; return NULL;
} }
/// ///

View File

@@ -93,7 +93,7 @@ class CefRenderProcessHandler : public virtual CefBaseRefCounted {
// Return the handler for browser load status events. // Return the handler for browser load status events.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() { return nullptr; } virtual CefRefPtr<CefLoadHandler> GetLoadHandler() { return NULL; }
/// ///
// Called immediately after the V8 context for a frame has been created. To // Called immediately after the V8 context for a frame has been created. To

View File

@@ -44,7 +44,6 @@
#include "include/cef_cookie.h" #include "include/cef_cookie.h"
#include "include/cef_extension.h" #include "include/cef_extension.h"
#include "include/cef_extension_handler.h" #include "include/cef_extension_handler.h"
#include "include/cef_media_router.h"
#include "include/cef_values.h" #include "include/cef_values.h"
class CefRequestContextHandler; class CefRequestContextHandler;
@@ -362,12 +361,6 @@ class CefRequestContext : public virtual CefBaseRefCounted {
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefExtension> GetExtension( virtual CefRefPtr<CefExtension> GetExtension(
const CefString& extension_id) = 0; const CefString& extension_id) = 0;
///
// Returns the MediaRouter object associated with this context.
///
/*--cef()--*/
virtual CefRefPtr<CefMediaRouter> GetMediaRouter() = 0;
}; };
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_ #endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_

View File

@@ -119,7 +119,7 @@ class CefRequestContextHandler : public virtual CefBaseRefCounted {
bool is_download, bool is_download,
const CefString& request_initiator, const CefString& request_initiator,
bool& disable_default_handling) { bool& disable_default_handling) {
return nullptr; return NULL;
} }
}; };

View File

@@ -145,7 +145,7 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
bool is_download, bool is_download,
const CefString& request_initiator, const CefString& request_initiator,
bool& disable_default_handling) { bool& disable_default_handling) {
return nullptr; return NULL;
} }
/// ///

View File

@@ -72,7 +72,7 @@ class CefResourceRequestHandler : public virtual CefBaseRefCounted {
CefRefPtr<CefBrowser> browser, CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) { CefRefPtr<CefRequest> request) {
return nullptr; return NULL;
} }
/// ///
@@ -109,7 +109,7 @@ class CefResourceRequestHandler : public virtual CefBaseRefCounted {
CefRefPtr<CefBrowser> browser, CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) { CefRefPtr<CefRequest> request) {
return nullptr; return NULL;
} }
/// ///
@@ -163,7 +163,7 @@ class CefResourceRequestHandler : public virtual CefBaseRefCounted {
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request, CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response) { CefRefPtr<CefResponse> response) {
return nullptr; return NULL;
} }
/// ///

View File

@@ -725,11 +725,6 @@ typedef struct _cef_urlparts_t {
// Query string component (i.e., everything following the '?'). // Query string component (i.e., everything following the '?').
/// ///
cef_string_t query; cef_string_t query;
///
// Fragment (hash) identifier component (i.e., the string following the '#').
///
cef_string_t fragment;
} cef_urlparts_t; } cef_urlparts_t;
/// ///
@@ -1097,16 +1092,6 @@ typedef enum {
// A resource that a plugin requested. // A resource that a plugin requested.
/// ///
RT_PLUGIN_RESOURCE, RT_PLUGIN_RESOURCE,
///
// A main-frame service worker navigation preload request.
///
RT_NAVIGATION_PRELOAD_MAIN_FRAME = 19,
///
// A sub-frame service worker navigation preload request.
///
RT_NAVIGATION_PRELOAD_SUB_FRAME,
} cef_resource_type_t; } cef_resource_type_t;
/// ///
@@ -1122,8 +1107,9 @@ typedef enum {
TT_LINK = 0, TT_LINK = 0,
/// ///
// Source is some other "explicit" navigation. This is the default value for // Source is some other "explicit" navigation action such as creating a new
// navigations where the actual type is unknown. See also TT_DIRECT_LOAD_FLAG. // browser or using the LoadURL function. This is also the default value
// for navigations where the actual type is unknown.
/// ///
TT_EXPLICIT = 1, TT_EXPLICIT = 1,
@@ -1175,15 +1161,9 @@ typedef enum {
/// ///
// Used the Forward or Back function to navigate among browsing history. // Used the Forward or Back function to navigate among browsing history.
// Will be ORed to the transition type for the original load.
/// ///
TT_FORWARD_BACK_FLAG = 0x01000000, TT_FORWARD_BACK_FLAG = 0x01000000,
///
// Loaded a URL directly via CreateBrowser, LoadURL or LoadRequest.
///
TT_DIRECT_LOAD_FLAG = 0x02000000,
/// ///
// The beginning of a navigation chain. // The beginning of a navigation chain.
/// ///
@@ -1790,7 +1770,6 @@ typedef enum {
EVENTFLAG_IS_KEY_PAD = 1 << 9, EVENTFLAG_IS_KEY_PAD = 1 << 9,
EVENTFLAG_IS_LEFT = 1 << 10, EVENTFLAG_IS_LEFT = 1 << 10,
EVENTFLAG_IS_RIGHT = 1 << 11, EVENTFLAG_IS_RIGHT = 1 << 11,
EVENTFLAG_ALTGR_DOWN = 1 << 12,
} cef_event_flags_t; } cef_event_flags_t;
/// ///
@@ -2308,10 +2287,21 @@ typedef enum {
/// ///
UU_URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS = 1 << 3, UU_URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS = 1 << 3,
///
// Unescapes characters that can be used in spoofing attempts (such as LOCK)
// and control characters (such as BiDi control characters and %01). This
// INCLUDES NULLs. This is used for rare cases such as data: URL decoding
// where the result is binary data.
//
// DO NOT use UU_SPOOFING_AND_CONTROL_CHARS if the URL is going to be
// displayed in the UI for security reasons.
///
UU_SPOOFING_AND_CONTROL_CHARS = 1 << 4,
/// ///
// URL queries use "+" for space. This flag controls that replacement. // URL queries use "+" for space. This flag controls that replacement.
/// ///
UU_REPLACE_PLUS_WITH_SPACE = 1 << 4, UU_REPLACE_PLUS_WITH_SPACE = 1 << 5,
} cef_uri_unescape_rule_t; } cef_uri_unescape_rule_t;
/// ///
@@ -2434,13 +2424,13 @@ typedef struct _cef_pdf_print_settings_t {
int scale_factor; int scale_factor;
/// ///
// Margins in points. Only used if |margin_type| is set to // Margins in millimeters. Only used if |margin_type| is set to
// PDF_PRINT_MARGIN_CUSTOM. // PDF_PRINT_MARGIN_CUSTOM.
/// ///
int margin_top; double margin_top;
int margin_right; double margin_right;
int margin_bottom; double margin_bottom;
int margin_left; double margin_left;
/// ///
// Margin type. // Margin type.
@@ -2931,16 +2921,6 @@ typedef enum {
CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED, CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED,
} cef_cdm_registration_error_t; } cef_cdm_registration_error_t;
///
// Composition underline style.
///
typedef enum {
CEF_CUS_SOLID,
CEF_CUS_DOT,
CEF_CUS_DASH,
CEF_CUS_NONE,
} cef_composition_underline_style_t;
/// ///
// Structure representing IME composition underline information. This is a thin // Structure representing IME composition underline information. This is a thin
// wrapper around Blink's WebCompositionUnderline class and should be kept in // wrapper around Blink's WebCompositionUnderline class and should be kept in
@@ -2966,59 +2946,8 @@ typedef struct _cef_composition_underline_t {
// Set to true (1) for thick underline. // Set to true (1) for thick underline.
/// ///
int thick; int thick;
///
// Style.
///
cef_composition_underline_style_t style;
} cef_composition_underline_t; } cef_composition_underline_t;
///
// Result codes for CefMediaRouter::CreateRoute. Should be kept in sync with
// Chromium's media_router::RouteRequestResult::ResultCode type.
///
typedef enum {
CEF_MRCR_UNKNOWN_ERROR = 0,
CEF_MRCR_OK = 1,
CEF_MRCR_TIMED_OUT = 2,
CEF_MRCR_ROUTE_NOT_FOUND = 3,
CEF_MRCR_SINK_NOT_FOUND = 4,
CEF_MRCR_INVALID_ORIGIN = 5,
CEF_MRCR_NO_SUPPORTED_PROVIDER = 7,
CEF_MRCR_CANCELLED = 8,
CEF_MRCR_ROUTE_ALREADY_EXISTS = 9,
CEF_MRCR_TOTAL_COUNT = 11 // The total number of values.
} cef_media_route_create_result_t;
///
// Connection state for a MediaRoute object.
///
typedef enum {
CEF_MRCS_UNKNOWN,
CEF_MRCS_CONNECTING,
CEF_MRCS_CONNECTED,
CEF_MRCS_CLOSED,
CEF_MRCS_TERMINATED,
} cef_media_route_connection_state_t;
///
// Icon types for a MediaSink object. Should be kept in sync with Chromium's
// media_router::SinkIconType type.
///
typedef enum {
CEF_MSIT_CAST,
CEF_MSIT_CAST_AUDIO_GROUP,
CEF_MSIT_CAST_AUDIO,
CEF_MSIT_MEETING,
CEF_MSIT_HANGOUT,
CEF_MSIT_EDUCATION,
CEF_MSIT_WIRED_DISPLAY,
CEF_MSIT_GENERIC,
CEF_MSIT_TOTAL_COUNT, // The total number of values.
} cef_media_sink_icon_type_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -743,7 +743,6 @@ struct CefURLPartsTraits {
cef_string_clear(&s->origin); cef_string_clear(&s->origin);
cef_string_clear(&s->path); cef_string_clear(&s->path);
cef_string_clear(&s->query); cef_string_clear(&s->query);
cef_string_clear(&s->fragment);
} }
static inline void set(const struct_type* src, static inline void set(const struct_type* src,
@@ -760,8 +759,6 @@ struct CefURLPartsTraits {
cef_string_set(src->origin.str, src->origin.length, &target->origin, copy); cef_string_set(src->origin.str, src->origin.length, &target->origin, copy);
cef_string_set(src->path.str, src->path.length, &target->path, copy); cef_string_set(src->path.str, src->path.length, &target->path, copy);
cef_string_set(src->query.str, src->query.length, &target->query, copy); cef_string_set(src->query.str, src->query.length, &target->query, copy);
cef_string_set(src->fragment.str, src->fragment.length, &target->fragment,
copy);
} }
}; };
@@ -869,7 +866,10 @@ struct CefCursorInfoTraits {
static inline void set(const struct_type* src, static inline void set(const struct_type* src,
struct_type* target, struct_type* target,
bool copy) { bool copy) {
*target = *src; target->hotspot = src->hotspot;
target->image_scale_factor = src->image_scale_factor;
target->buffer = src->buffer;
target->size = src->size;
} }
}; };
@@ -942,14 +942,23 @@ typedef CefStructBase<CefBoxLayoutSettingsTraits> CefBoxLayoutSettings;
struct CefCompositionUnderlineTraits { struct CefCompositionUnderlineTraits {
typedef cef_composition_underline_t struct_type; typedef cef_composition_underline_t struct_type;
static inline void init(struct_type* s) {} static inline void init(struct_type* s) {
s->range.from = 0;
s->range.to = 0;
s->color = 0;
s->background_color = 0;
s->thick = 0;
}
static inline void clear(struct_type* s) {} static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, static inline void set(const struct_type* src,
struct_type* target, struct_type* target,
bool copy) { bool copy) {
*target = *src; target->range = src->range;
target->color = src->color;
target->background_color = src->background_color;
target->thick = src->thick;
} }
}; };

View File

@@ -75,7 +75,7 @@ class CefWindowDelegate : public CefPanelDelegate {
virtual CefRefPtr<CefWindow> GetParentWindow(CefRefPtr<CefWindow> window, virtual CefRefPtr<CefWindow> GetParentWindow(CefRefPtr<CefWindow> window,
bool* is_menu, bool* is_menu,
bool* can_activate_menu) { bool* can_activate_menu) {
return nullptr; return NULL;
} }
/// ///

View File

@@ -11,7 +11,6 @@
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/download_manager_delegate.h" #include "libcef/browser/download_manager_delegate.h"
#include "libcef/browser/extensions/extension_system.h" #include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/prefs/browser_prefs.h" #include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/request_context_impl.h" #include "libcef/browser/request_context_impl.h"
#include "libcef/browser/ssl_host_state_delegate.h" #include "libcef/browser/ssl_host_state_delegate.h"
@@ -38,7 +37,7 @@
#include "components/proxy_config/pref_proxy_config_tracker_impl.h" #include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/user_prefs/user_prefs.h" #include "components/user_prefs/user_prefs.h"
#include "components/visitedlink/browser/visitedlink_event_listener.h" #include "components/visitedlink/browser/visitedlink_event_listener.h"
#include "components/visitedlink/browser/visitedlink_writer.h" #include "components/visitedlink/browser/visitedlink_master.h"
#include "components/zoom/zoom_event_manager.h" #include "components/zoom/zoom_event_manager.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
@@ -165,16 +164,11 @@ base::LazyInstance<ImplManager>::DestructorAtExit g_manager =
base::LazyInstance<ImplManager>::Leaky g_manager = LAZY_INSTANCE_INITIALIZER; base::LazyInstance<ImplManager>::Leaky g_manager = LAZY_INSTANCE_INITIALIZER;
#endif #endif
CefBrowserContext* GetSelf(base::WeakPtr<CefBrowserContext> self) {
CEF_REQUIRE_UIT();
return self.get();
}
} // namespace } // namespace
// Creates and manages VisitedLinkEventListener objects for each // Creates and manages VisitedLinkEventListener objects for each
// CefBrowserContext sharing the same VisitedLinkWriter. // CefBrowserContext sharing the same VisitedLinkMaster.
class CefVisitedLinkListener : public visitedlink::VisitedLinkWriter::Listener { class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::Listener {
public: public:
CefVisitedLinkListener() { DCHECK(listener_map_.empty()); } CefVisitedLinkListener() { DCHECK(listener_map_.empty()); }
@@ -192,7 +186,7 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkWriter::Listener {
listener_map_.erase(it); listener_map_.erase(it);
} }
// visitedlink::VisitedLinkWriter::Listener methods. // visitedlink::VisitedLinkMaster::Listener methods.
void NewTable(base::ReadOnlySharedMemoryRegion* table_region) override { void NewTable(base::ReadOnlySharedMemoryRegion* table_region) override {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
@@ -226,9 +220,8 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkWriter::Listener {
}; };
CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings) CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings)
: settings_(settings), weak_ptr_factory_(this) { : settings_(settings) {
g_manager.Get().AddImpl(this); g_manager.Get().AddImpl(this);
getter_ = base::BindRepeating(GetSelf, weak_ptr_factory_.GetWeakPtr());
} }
CefBrowserContext::~CefBrowserContext() { CefBrowserContext::~CefBrowserContext() {
@@ -240,9 +233,6 @@ CefBrowserContext::~CefBrowserContext() {
// Unregister the context first to avoid re-entrancy during shutdown. // Unregister the context first to avoid re-entrancy during shutdown.
g_manager.Get().RemoveImpl(this, cache_path_); g_manager.Get().RemoveImpl(this, cache_path_);
// Destroy objects that may hold references to the MediaRouter.
media_router_manager_.reset();
// Send notifications to clean up objects associated with this Profile. // Send notifications to clean up objects associated with this Profile.
MaybeSendDestroyedNotification(); MaybeSendDestroyedNotification();
@@ -351,7 +341,7 @@ void CefBrowserContext::Initialize() {
if (!cache_path_.empty()) if (!cache_path_.empty())
visited_link_path = cache_path_.Append(FILE_PATH_LITERAL("Visited Links")); visited_link_path = cache_path_.Append(FILE_PATH_LITERAL("Visited Links"));
visitedlink_listener_ = new CefVisitedLinkListener; visitedlink_listener_ = new CefVisitedLinkListener;
visitedlink_master_.reset(new visitedlink::VisitedLinkWriter( visitedlink_master_.reset(new visitedlink::VisitedLinkMaster(
visitedlink_listener_, this, !visited_link_path.empty(), false, visitedlink_listener_, this, !visited_link_path.empty(), false,
visited_link_path, 0)); visited_link_path, 0));
visitedlink_listener_->CreateListenerForContext(this); visitedlink_listener_->CreateListenerForContext(this);
@@ -592,7 +582,7 @@ HostContentSettingsMap* CefBrowserContext::GetHostContentSettingsMap() {
plugin_policy = CONTENT_SETTING_BLOCK; plugin_policy = CONTENT_SETTING_BLOCK;
} }
host_content_settings_map_->SetDefaultContentSetting( host_content_settings_map_->SetDefaultContentSetting(
ContentSettingsType::PLUGINS, plugin_policy); CONTENT_SETTINGS_TYPE_PLUGINS, plugin_policy);
} }
} }
return host_content_settings_map_.get(); return host_content_settings_map_.get();
@@ -822,11 +812,3 @@ bool CefBrowserContext::IsPrintPreviewSupported() const {
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled); return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
} }
CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
CEF_REQUIRE_UIT();
if (!media_router_manager_) {
media_router_manager_.reset(new CefMediaRouterManager(this));
}
return media_router_manager_.get();
}

View File

@@ -13,10 +13,8 @@
#include "libcef/browser/request_context_handler_map.h" #include "libcef/browser/request_context_handler_map.h"
#include "libcef/browser/resource_context.h" #include "libcef/browser/resource_context.h"
#include "base/callback.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/download/download_prefs.h" #include "chrome/browser/download/download_prefs.h"
#include "chrome/common/plugin.mojom.h" #include "chrome/common/plugin.mojom.h"
#include "components/proxy_config/pref_proxy_config_tracker.h" #include "components/proxy_config/pref_proxy_config_tracker.h"
@@ -86,7 +84,6 @@
*/ */
class CefDownloadManagerDelegate; class CefDownloadManagerDelegate;
class CefMediaRouterManager;
class CefRequestContextImpl; class CefRequestContextImpl;
class CefSSLHostStateDelegate; class CefSSLHostStateDelegate;
class CefVisitedLinkListener; class CefVisitedLinkListener;
@@ -98,7 +95,7 @@ class CefExtensionSystem;
} }
namespace visitedlink { namespace visitedlink {
class VisitedLinkWriter; class VisitedLinkMaster;
} }
// Main entry point for configuring behavior on a per-browser basis. An instance // Main entry point for configuring behavior on a per-browser basis. An instance
@@ -282,13 +279,6 @@ class CefBrowserContext : public ChromeProfileStub,
// Returns true if this context supports print preview. // Returns true if this context supports print preview.
bool IsPrintPreviewSupported() const; bool IsPrintPreviewSupported() const;
CefMediaRouterManager* GetMediaRouterManager();
// Returns the BrowserContext, or nullptr if the BrowserContext has already
// been destroyed.
using Getter = base::RepeatingCallback<CefBrowserContext*()>;
Getter getter() const { return getter_; }
private: private:
// Allow deletion via std::unique_ptr(). // Allow deletion via std::unique_ptr().
friend std::default_delete<CefBrowserContext>; friend std::default_delete<CefBrowserContext>;
@@ -308,7 +298,7 @@ class CefBrowserContext : public ChromeProfileStub,
std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_; std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_; std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
scoped_refptr<HostContentSettingsMap> host_content_settings_map_; scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_master_; std::unique_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
// |visitedlink_listener_| is owned by visitedlink_master_. // |visitedlink_listener_| is owned by visitedlink_master_.
CefVisitedLinkListener* visitedlink_listener_; CefVisitedLinkListener* visitedlink_listener_;
bool should_persist_session_cookies_ = false; bool should_persist_session_cookies_ = false;
@@ -325,8 +315,6 @@ class CefBrowserContext : public ChromeProfileStub,
std::unique_ptr<DownloadPrefs> download_prefs_; std::unique_ptr<DownloadPrefs> download_prefs_;
std::unique_ptr<CefMediaRouterManager> media_router_manager_;
// Map IDs to CefRequestContextHandler objects. // Map IDs to CefRequestContextHandler objects.
CefRequestContextHandlerMap handler_map_; CefRequestContextHandlerMap handler_map_;
@@ -350,9 +338,6 @@ class CefBrowserContext : public ChromeProfileStub,
typedef std::set<int> NodeIdSet; typedef std::set<int> NodeIdSet;
NodeIdSet node_id_set_; NodeIdSet node_id_set_;
Getter getter_;
base::WeakPtrFactory<CefBrowserContext> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserContext); DISALLOW_COPY_AND_ASSIGN(CefBrowserContext);
}; };

View File

@@ -381,8 +381,7 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::Create(
create_params.extension_host_type); create_params.extension_host_type);
} else if (!create_params.url.is_empty()) { } else if (!create_params.url.is_empty()) {
browser->LoadMainFrameURL(create_params.url.spec(), content::Referrer(), browser->LoadMainFrameURL(create_params.url.spec(), content::Referrer(),
CefFrameHostImpl::kPageTransitionExplicit, ui::PAGE_TRANSITION_TYPED, std::string());
std::string());
} }
return browser.get(); return browser.get();
@@ -592,7 +591,7 @@ void CefBrowserHostImpl::CloseBrowser(bool force_close) {
} }
content::WebContents* contents = web_contents(); content::WebContents* contents = web_contents();
if (contents && contents->NeedToFireBeforeUnloadOrUnload()) { if (contents && contents->NeedToFireBeforeUnload()) {
// Will result in a call to BeforeUnloadFired() and, if the close isn't // Will result in a call to BeforeUnloadFired() and, if the close isn't
// canceled, CloseContents(). // canceled, CloseContents().
contents->DispatchBeforeUnload(false /* auto_cancel */); contents->DispatchBeforeUnload(false /* auto_cancel */);
@@ -764,9 +763,8 @@ void CefBrowserHostImpl::DownloadImage(
return; return;
web_contents()->DownloadImage( web_contents()->DownloadImage(
gurl, is_favicon, max_image_size, gurl, is_favicon, max_image_size * gfx::ImageSkia::GetMaxSupportedScale(),
max_image_size * gfx::ImageSkia::GetMaxSupportedScale(), bypass_cache, bypass_cache, base::BindOnce(OnDownloadImage, max_image_size, callback));
base::BindOnce(OnDownloadImage, max_image_size, callback));
} }
void CefBrowserHostImpl::Print() { void CefBrowserHostImpl::Print() {
@@ -929,7 +927,7 @@ void CefBrowserHostImpl::GetNavigationEntries(
CefRefPtr<CefNavigationEntryImpl> entry = CefRefPtr<CefNavigationEntryImpl> entry =
new CefNavigationEntryImpl(controller.GetEntryAtIndex(current)); new CefNavigationEntryImpl(controller.GetEntryAtIndex(current));
visitor->Visit(entry.get(), true, current, total); visitor->Visit(entry.get(), true, current, total);
entry->Detach(nullptr); entry->Detach(NULL);
} else { } else {
// Visit all entries. // Visit all entries.
bool cont = true; bool cont = true;
@@ -937,7 +935,7 @@ void CefBrowserHostImpl::GetNavigationEntries(
CefRefPtr<CefNavigationEntryImpl> entry = CefRefPtr<CefNavigationEntryImpl> entry =
new CefNavigationEntryImpl(controller.GetEntryAtIndex(i)); new CefNavigationEntryImpl(controller.GetEntryAtIndex(i));
cont = visitor->Visit(entry.get(), (i == current), i, total); cont = visitor->Visit(entry.get(), (i == current), i, total);
entry->Detach(nullptr); entry->Detach(NULL);
} }
} }
} }
@@ -1165,7 +1163,11 @@ void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
if (!web_contents() || !platform_delegate_) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->SendKeyEvent(event); content::NativeWebKeyboardEvent web_event(blink::WebInputEvent::kUndefined,
blink::WebInputEvent::kNoModifiers,
ui::EventTimeForNow());
platform_delegate_->TranslateKeyEvent(web_event, event);
platform_delegate_->SendKeyEvent(web_event);
} }
void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event, void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event,
@@ -1182,7 +1184,10 @@ void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event,
if (!web_contents() || !platform_delegate_) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->SendMouseClickEvent(event, type, mouseUp, clickCount); blink::WebMouseEvent web_event;
platform_delegate_->TranslateClickEvent(web_event, event, type, mouseUp,
clickCount);
platform_delegate_->SendMouseEvent(web_event);
} }
void CefBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event, void CefBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event,
@@ -1197,7 +1202,9 @@ void CefBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event,
if (!web_contents() || !platform_delegate_) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->SendMouseMoveEvent(event, mouseLeave); blink::WebMouseEvent web_event;
platform_delegate_->TranslateMoveEvent(web_event, event, mouseLeave);
platform_delegate_->SendMouseEvent(web_event);
} }
void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event, void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event,
@@ -1218,7 +1225,9 @@ void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event,
if (!web_contents() || !platform_delegate_) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->SendMouseWheelEvent(event, deltaX, deltaY); blink::WebMouseWheelEvent web_event;
platform_delegate_->TranslateWheelEvent(web_event, event, deltaX, deltaY);
platform_delegate_->SendMouseWheelEvent(web_event);
} }
void CefBrowserHostImpl::SendFocusEvent(bool setFocus) { void CefBrowserHostImpl::SendFocusEvent(bool setFocus) {
@@ -1545,19 +1554,19 @@ void CefBrowserHostImpl::DestroyBrowser() {
// Disassociate the platform delegate from this browser. // Disassociate the platform delegate from this browser.
platform_delegate_->BrowserDestroyed(this); platform_delegate_->BrowserDestroyed(this);
registrar_.reset(nullptr); registrar_.reset(NULL);
content::WebContentsObserver::Observe(nullptr); content::WebContentsObserver::Observe(NULL);
if (owned_web_contents_) if (owned_web_contents_)
owned_web_contents_.reset(nullptr); owned_web_contents_.reset(NULL);
// Delete objects created by the platform delegate that may be referenced by // Delete objects created by the platform delegate that may be referenced by
// the WebContents. // the WebContents.
file_dialog_manager_.reset(nullptr); file_dialog_manager_.reset(NULL);
javascript_dialog_manager_.reset(nullptr); javascript_dialog_manager_.reset(NULL);
menu_manager_.reset(nullptr); menu_manager_.reset(NULL);
// Delete the platform delegate. // Delete the platform delegate.
platform_delegate_.reset(nullptr); platform_delegate_.reset(NULL);
CefBrowserInfoManager::GetInstance()->RemoveBrowserInfo(browser_info_); CefBrowserInfoManager::GetInstance()->RemoveBrowserInfo(browser_info_);
browser_info_->SetBrowser(nullptr); browser_info_->SetBrowser(nullptr);
@@ -1641,6 +1650,30 @@ void CefBrowserHostImpl::LoadMainFrameURL(const std::string& url,
} }
} }
void CefBrowserHostImpl::OnFrameFocused(CefRefPtr<CefFrameHostImpl> frame) {
DCHECK(frame);
CefRefPtr<CefFrameHostImpl> previous_frame;
{
base::AutoLock lock_scope(state_lock_);
previous_frame = focused_frame_;
if (frame->IsMain())
focused_frame_ = nullptr;
else
focused_frame_ = frame;
}
if (!previous_frame) {
// The main frame is focused by default.
previous_frame = browser_info_->GetMainFrame();
}
if (previous_frame->GetIdentifier() != frame->GetIdentifier()) {
previous_frame->SetFocused(false);
frame->SetFocused(true);
}
}
void CefBrowserHostImpl::OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame, void CefBrowserHostImpl::OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
const GURL& validated_url, const GURL& validated_url,
int http_status_code) { int http_status_code) {
@@ -1708,9 +1741,9 @@ void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
void CefBrowserHostImpl::RunFileChooser( void CefBrowserHostImpl::RunFileChooser(
const CefFileDialogRunner::FileChooserParams& params, const CefFileDialogRunner::FileChooserParams& params,
CefFileDialogRunner::RunFileChooserCallback callback) { const CefFileDialogRunner::RunFileChooserCallback& callback) {
EnsureFileDialogManager(); EnsureFileDialogManager();
file_dialog_manager_->RunFileChooser(params, std::move(callback)); file_dialog_manager_->RunFileChooser(params, callback);
} }
bool CefBrowserHostImpl::EmbedsFullscreenWidget() { bool CefBrowserHostImpl::EmbedsFullscreenWidget() {
@@ -2086,7 +2119,8 @@ void CefBrowserHostImpl::LoadingStateChanged(content::WebContents* source,
} }
} }
void CefBrowserHostImpl::LoadProgressChanged(double progress) { void CefBrowserHostImpl::LoadProgressChanged(content::WebContents* source,
double progress) {
if (client_.get()) { if (client_.get()) {
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler(); CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
if (handler.get()) { if (handler.get()) {
@@ -2467,9 +2501,9 @@ bool CefBrowserHostImpl::CheckMediaAccessPermission(
return command_line->HasSwitch(switches::kEnableMediaStream); return command_line->HasSwitch(switches::kEnableMediaStream);
} }
bool CefBrowserHostImpl::IsNeverComposited(content::WebContents* web_contents) { bool CefBrowserHostImpl::IsNeverVisible(content::WebContents* web_contents) {
if (extension_host_) if (extension_host_)
return extension_host_->IsNeverComposited(web_contents); return extension_host_->IsNeverVisible(web_contents);
return false; return false;
} }
@@ -2531,13 +2565,6 @@ void CefBrowserHostImpl::RenderViewCreated(
RenderFrameCreated(render_view_host->GetMainFrame()); RenderFrameCreated(render_view_host->GetMainFrame());
platform_delegate_->RenderViewCreated(render_view_host); platform_delegate_->RenderViewCreated(render_view_host);
// Make sure the background color is set on the WebView and the Widget.
render_view_host->OnWebkitPreferencesChanged();
if (render_view_host->GetWidget()->GetView()) {
render_view_host->GetWidget()->GetView()->SetBackgroundColor(
GetBackgroundColor());
}
} }
void CefBrowserHostImpl::RenderViewDeleted( void CefBrowserHostImpl::RenderViewDeleted(
@@ -2658,7 +2685,8 @@ void CefBrowserHostImpl::DocumentAvailableInMainFrame() {
void CefBrowserHostImpl::DidFailLoad( void CefBrowserHostImpl::DidFailLoad(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
const GURL& validated_url, const GURL& validated_url,
int error_code) { int error_code,
const base::string16& error_description) {
// The navigation failed after commit. OnLoadStart was called so we also call // The navigation failed after commit. OnLoadStart was called so we also call
// OnLoadEnd. // OnLoadEnd.
auto frame = browser_info_->GetFrameForHost(render_frame_host); auto frame = browser_info_->GetFrameForHost(render_frame_host);
@@ -2723,34 +2751,6 @@ bool CefBrowserHostImpl::OnMessageReceived(
return false; return false;
} }
void CefBrowserHostImpl::OnFrameFocused(
content::RenderFrameHost* render_frame_host) {
CefRefPtr<CefFrameHostImpl> frame =
static_cast<CefFrameHostImpl*>(GetFrameForHost(render_frame_host).get());
if (!frame || frame->IsFocused())
return;
CefRefPtr<CefFrameHostImpl> previous_frame;
{
base::AutoLock lock_scope(state_lock_);
previous_frame = focused_frame_;
if (frame->IsMain())
focused_frame_ = nullptr;
else
focused_frame_ = frame;
}
if (!previous_frame) {
// The main frame is focused by default.
previous_frame = browser_info_->GetMainFrame();
}
if (previous_frame->GetIdentifier() != frame->GetIdentifier()) {
previous_frame->SetFocused(false);
frame->SetFocused(true);
}
}
void CefBrowserHostImpl::AccessibilityEventReceived( void CefBrowserHostImpl::AccessibilityEventReceived(
const content::AXEventNotificationDetails& content_event_bundle) { const content::AXEventNotificationDetails& content_event_bundle) {
// Only needed in windowless mode. // Only needed in windowless mode.
@@ -2879,7 +2879,7 @@ CefBrowserHostImpl::CefBrowserHostImpl(
is_in_onsetfocus_(false), is_in_onsetfocus_(false),
focus_on_editable_field_(false), focus_on_editable_field_(false),
mouse_cursor_change_disabled_(false), mouse_cursor_change_disabled_(false),
devtools_frontend_(nullptr), devtools_frontend_(NULL),
extension_(extension) { extension_(extension) {
if (opener.get() && !platform_delegate_->IsViewsHosted()) { if (opener.get() && !platform_delegate_->IsViewsHosted()) {
// GetOpenerWindowHandle() only returns a value for non-views-hosted // GetOpenerWindowHandle() only returns a value for non-views-hosted
@@ -3092,7 +3092,7 @@ void CefBrowserHostImpl::OnTitleChange(const base::string16& title) {
void CefBrowserHostImpl::OnDevToolsWebContentsDestroyed() { void CefBrowserHostImpl::OnDevToolsWebContentsDestroyed() {
devtools_observer_.reset(); devtools_observer_.reset();
devtools_frontend_ = nullptr; devtools_frontend_ = NULL;
} }
void CefBrowserHostImpl::EnsureFileDialogManager() { void CefBrowserHostImpl::EnsureFileDialogManager() {

View File

@@ -313,6 +313,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
const std::string& extra_headers); const std::string& extra_headers);
// Called from CefFrameHostImpl. // Called from CefFrameHostImpl.
void OnFrameFocused(CefRefPtr<CefFrameHostImpl> frame);
void OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame, void OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
const GURL& validated_url, const GURL& validated_url,
int http_status_code); int http_status_code);
@@ -351,8 +352,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Run the file chooser dialog specified by |params|. Only a single dialog may // Run the file chooser dialog specified by |params|. Only a single dialog may
// be pending at any given time. |callback| will be executed asynchronously // be pending at any given time. |callback| will be executed asynchronously
// after the dialog is dismissed or if another dialog is already pending. // after the dialog is dismissed or if another dialog is already pending.
void RunFileChooser(const CefFileDialogRunner::FileChooserParams& params, void RunFileChooser(
CefFileDialogRunner::RunFileChooserCallback callback); const CefFileDialogRunner::FileChooserParams& params,
const CefFileDialogRunner::RunFileChooserCallback& callback);
bool HandleContextMenu(content::WebContents* web_contents, bool HandleContextMenu(content::WebContents* web_contents,
const content::ContextMenuParams& params); const content::ContextMenuParams& params);
@@ -384,7 +386,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool* was_blocked) override; bool* was_blocked) override;
void LoadingStateChanged(content::WebContents* source, void LoadingStateChanged(content::WebContents* source,
bool to_different_document) override; bool to_different_document) override;
void LoadProgressChanged(double progress) override; void LoadProgressChanged(content::WebContents* source,
double progress) override;
void CloseContents(content::WebContents* source) override; void CloseContents(content::WebContents* source) override;
void UpdateTargetURL(content::WebContents* source, const GURL& url) override; void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
bool DidAddMessageToConsole(content::WebContents* source, bool DidAddMessageToConsole(content::WebContents* source,
@@ -457,7 +460,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host, bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const GURL& security_origin, const GURL& security_origin,
blink::mojom::MediaStreamType type) override; blink::mojom::MediaStreamType type) override;
bool IsNeverComposited(content::WebContents* web_contents) override; bool IsNeverVisible(content::WebContents* web_contents) override;
content::PictureInPictureResult EnterPictureInPicture( content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents, content::WebContents* web_contents,
const viz::SurfaceId& surface_id, const viz::SurfaceId& surface_id,
@@ -480,7 +483,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
void DocumentAvailableInMainFrame() override; void DocumentAvailableInMainFrame() override;
void DidFailLoad(content::RenderFrameHost* render_frame_host, void DidFailLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url, const GURL& validated_url,
int error_code) override; int error_code,
const base::string16& error_description) override;
void TitleWasSet(content::NavigationEntry* entry) override; void TitleWasSet(content::NavigationEntry* entry) override;
void PluginCrashed(const base::FilePath& plugin_path, void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override; base::ProcessId plugin_pid) override;
@@ -489,7 +493,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool OnMessageReceived(const IPC::Message& message) override; bool OnMessageReceived(const IPC::Message& message) override;
bool OnMessageReceived(const IPC::Message& message, bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override; content::RenderFrameHost* render_frame_host) override;
void OnFrameFocused(content::RenderFrameHost* render_frame_host) override;
void AccessibilityEventReceived( void AccessibilityEventReceived(
const content::AXEventNotificationDetails& content_event_bundle) override; const content::AXEventNotificationDetails& content_event_bundle) override;
void AccessibilityLocationChangesReceived( void AccessibilityLocationChangesReceived(

View File

@@ -11,11 +11,9 @@
#include "libcef/browser/extensions/browser_extensions_util.h" #include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "libcef/common/cef_messages.h" #include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h" #include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/values_impl.h" #include "libcef/common/values_impl.h"
#include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
@@ -25,9 +23,6 @@
namespace { namespace {
// Timeout delay for new browser info responses.
const int64_t kNewBrowserInfoResponseTimeoutMs = 2000;
void TranslatePopupFeatures(const blink::mojom::WindowFeatures& webKitFeatures, void TranslatePopupFeatures(const blink::mojom::WindowFeatures& webKitFeatures,
CefPopupFeatures& features) { CefPopupFeatures& features) {
features.x = static_cast<int>(webKitFeatures.x); features.x = static_cast<int>(webKitFeatures.x);
@@ -49,7 +44,7 @@ CefBrowserInfoManager* g_info_manager = nullptr;
} // namespace } // namespace
CefBrowserInfoManager::CefBrowserInfoManager() { CefBrowserInfoManager::CefBrowserInfoManager() : next_browser_id_(0) {
DCHECK(!g_info_manager); DCHECK(!g_info_manager);
g_info_manager = this; g_info_manager = this;
} }
@@ -91,11 +86,10 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
new CefBrowserInfo(++next_browser_id_, true, is_windowless, extra_info); new CefBrowserInfo(++next_browser_id_, true, is_windowless, extra_info);
browser_info_list_.push_back(browser_info); browser_info_list_.push_back(browser_info);
// Continue any pending NewBrowserInfo request. // Continue any pending NewBrowserInfo requests.
auto it = pending_new_browser_info_map_.find(frame_id); auto it = pending_new_browser_info_map_.find(frame_id);
if (it != pending_new_browser_info_map_.end()) { if (it != pending_new_browser_info_map_.end()) {
SendNewBrowserInfoResponse(render_process_id, browser_info, SendNewBrowserInfoResponse(render_process_id, browser_info, false,
false /* is_guest_view */,
it->second->reply_msg); it->second->reply_msg);
pending_new_browser_info_map_.erase(it); pending_new_browser_info_map_.erase(it);
} }
@@ -145,7 +139,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
std::unique_ptr<CefWindowInfo> window_info(new CefWindowInfo); std::unique_ptr<CefWindowInfo> window_info(new CefWindowInfo);
#if defined(OS_WIN) #if defined(OS_WIN)
window_info->SetAsPopup(nullptr, CefString()); window_info->SetAsPopup(NULL, CefString());
#endif #endif
auto pending_popup = std::make_unique<CefBrowserInfoManager::PendingPopup>(); auto pending_popup = std::make_unique<CefBrowserInfoManager::PendingPopup>();
@@ -293,27 +287,13 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(int render_process_id,
DCHECK(pending_new_browser_info_map_.find(frame_id) == DCHECK(pending_new_browser_info_map_.find(frame_id) ==
pending_new_browser_info_map_.end()); pending_new_browser_info_map_.end());
const int timeout_id = ++next_timeout_id_;
// Queue the request. // Queue the request.
std::unique_ptr<PendingNewBrowserInfo> pending(new PendingNewBrowserInfo()); std::unique_ptr<PendingNewBrowserInfo> pending(new PendingNewBrowserInfo());
pending->render_process_id = render_process_id; pending->render_process_id = render_process_id;
pending->render_routing_id = render_routing_id; pending->render_routing_id = render_routing_id;
pending->timeout_id = timeout_id;
pending->reply_msg = reply_msg; pending->reply_msg = reply_msg;
pending_new_browser_info_map_.insert( pending_new_browser_info_map_.insert(
std::make_pair(frame_id, std::move(pending))); std::make_pair(frame_id, std::move(pending)));
// Register a timeout for the pending response so that the renderer process
// doesn't hang forever.
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableNewBrowserInfoTimeout)) {
CEF_POST_DELAYED_TASK(
CEF_UIT,
base::BindOnce(&CefBrowserInfoManager::TimeoutNewBrowserInfoResponse,
frame_id, timeout_id),
kNewBrowserInfoResponseTimeoutMs);
}
} }
void CefBrowserInfoManager::RemoveBrowserInfo( void CefBrowserInfoManager::RemoveBrowserInfo(
@@ -518,52 +498,19 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
} }
CefProcessHostMsg_GetNewBrowserInfo_Params params; CefProcessHostMsg_GetNewBrowserInfo_Params params;
params.browser_id = browser_info->browser_id();
params.is_windowless = browser_info->is_windowless();
params.is_popup = browser_info->is_popup();
params.is_guest_view = is_guest_view; params.is_guest_view = is_guest_view;
if (browser_info) { auto extra_info = browser_info->extra_info();
params.browser_id = browser_info->browser_id(); if (extra_info) {
params.is_windowless = browser_info->is_windowless(); auto extra_info_impl =
params.is_popup = browser_info->is_popup(); static_cast<CefDictionaryValueImpl*>(extra_info.get());
auto extra_info_value = extra_info_impl->CopyValue();
auto extra_info = browser_info->extra_info(); extra_info_value->Swap(&params.extra_info);
if (extra_info) {
auto extra_info_impl =
static_cast<CefDictionaryValueImpl*>(extra_info.get());
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;
} }
CefProcessHostMsg_GetNewBrowserInfo::WriteReplyParams(reply_msg, params); CefProcessHostMsg_GetNewBrowserInfo::WriteReplyParams(reply_msg, params);
host->Send(reply_msg); host->Send(reply_msg);
} }
// static
void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse(int64_t frame_id,
int timeout_id) {
if (!g_info_manager)
return;
base::AutoLock lock_scope(g_info_manager->browser_info_lock_);
// Continue the NewBrowserInfo request if it's still pending.
auto it = g_info_manager->pending_new_browser_info_map_.find(frame_id);
if (it != g_info_manager->pending_new_browser_info_map_.end()) {
const auto& pending_info = it->second;
// Don't accidentally timeout a new request for the same frame.
if (pending_info->timeout_id != timeout_id)
return;
LOG(ERROR) << "Timeout of new browser info response for frame process id "
<< pending_info->render_process_id << " and routing id "
<< pending_info->render_routing_id;
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

@@ -201,14 +201,10 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
bool is_guest_view, bool is_guest_view,
IPC::Message* reply_msg); 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. // Pending request for OnGetNewBrowserInfo.
struct PendingNewBrowserInfo { struct PendingNewBrowserInfo {
int render_process_id; int render_process_id;
int render_routing_id; int render_routing_id;
int timeout_id;
IPC::Message* reply_msg; IPC::Message* reply_msg;
}; };
@@ -217,7 +213,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Access to the below members must be protected by |browser_info_lock_|. // Access to the below members must be protected by |browser_info_lock_|.
BrowserInfoList browser_info_list_; BrowserInfoList browser_info_list_;
int next_browser_id_ = 0; int next_browser_id_;
// Map of frame ID to info. // Map of frame ID to info.
using PendingNewBrowserInfoMap = using PendingNewBrowserInfoMap =
@@ -228,8 +224,6 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
using PendingPopupList = std::vector<std::unique_ptr<PendingPopup>>; using PendingPopupList = std::vector<std::unique_ptr<PendingPopup>>;
PendingPopupList pending_popup_list_; PendingPopupList pending_popup_list_;
int next_timeout_id_ = 0;
DISALLOW_COPY_AND_ASSIGN(CefBrowserInfoManager); DISALLOW_COPY_AND_ASSIGN(CefBrowserInfoManager);
}; };

View File

@@ -50,8 +50,6 @@
#include "ui/wm/core/wm_state.h" #include "ui/wm/core/wm_state.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "chrome/browser/chrome_browser_main_win.h"
#include "components/os_crypt/os_crypt.h"
#include "ui/base/cursor/cursor_loader_win.h" #include "ui/base/cursor/cursor_loader_win.h"
#endif #endif
#endif // defined(USE_AURA) #endif // defined(USE_AURA)
@@ -73,9 +71,14 @@
#include "libcef/browser/printing/print_dialog_linux.h" #include "libcef/browser/printing/print_dialog_linux.h"
#endif #endif
#if defined(OS_MACOSX)
#include "chrome/browser/browser_process.h"
#include "components/os_crypt/os_crypt.h"
#endif
CefBrowserMainParts::CefBrowserMainParts( CefBrowserMainParts::CefBrowserMainParts(
const content::MainFunctionParams& parameters) const content::MainFunctionParams& parameters)
: BrowserMainParts(), devtools_delegate_(nullptr) {} : BrowserMainParts(), devtools_delegate_(NULL) {}
CefBrowserMainParts::~CefBrowserMainParts() { CefBrowserMainParts::~CefBrowserMainParts() {
constrained_window::SetConstrainedWindowViewsClient(nullptr); constrained_window::SetConstrainedWindowViewsClient(nullptr);
@@ -119,17 +122,12 @@ void CefBrowserMainParts::PreMainMessageLoopStart() {
ui::TouchFactory::SetTouchDeviceListFromCommandLine(); ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif #endif
#if defined(OS_WIN) #if defined(OS_MACOSX)
// Initialize the OSCrypt. // Initialize the OSCrypt.
PrefService* local_state = g_browser_process->local_state(); PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state); DCHECK(local_state);
bool os_crypt_init = OSCrypt::Init(local_state); OSCrypt::Init(local_state);
DCHECK(os_crypt_init); #endif
// installer_util references strings that are normally compiled into
// setup.exe. In Chrome, these strings are in the locale files.
ChromeBrowserMainPartsWin::SetupInstallerUtilStrings();
#endif // defined(OS_WIN)
} }
void CefBrowserMainParts::PostMainMessageLoopStart() { void CefBrowserMainParts::PostMainMessageLoopStart() {
@@ -215,12 +213,12 @@ void CefBrowserMainParts::PostMainMessageLoopRun() {
// There should be no additional references to the global CefRequestContext // There should be no additional references to the global CefRequestContext
// during shutdown. Did you forget to release a CefBrowser reference? // during shutdown. Did you forget to release a CefBrowser reference?
DCHECK(global_request_context_->HasOneRef()); DCHECK(global_request_context_->HasOneRef());
global_request_context_ = nullptr; global_request_context_ = NULL;
} }
void CefBrowserMainParts::PostDestroyThreads() { void CefBrowserMainParts::PostDestroyThreads() {
if (extensions::ExtensionsEnabled()) { if (extensions::ExtensionsEnabled()) {
extensions::ExtensionsBrowserClient::Set(nullptr); extensions::ExtensionsBrowserClient::Set(NULL);
extensions_browser_client_.reset(); extensions_browser_client_.reset();
} }

View File

@@ -14,7 +14,7 @@ void CefBrowserMainParts::PlatformInitialize() {
HRESULT res; HRESULT res;
// Initialize common controls. // Initialize common controls.
res = CoInitialize(nullptr); res = CoInitialize(NULL);
DCHECK(SUCCEEDED(res)); DCHECK(SUCCEEDED(res));
INITCOMMONCONTROLSEX InitCtrlEx; INITCOMMONCONTROLSEX InitCtrlEx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
@@ -22,6 +22,6 @@ void CefBrowserMainParts::PlatformInitialize() {
InitCommonControlsEx(&InitCtrlEx); InitCommonControlsEx(&InitCtrlEx);
// Start COM stuff. // Start COM stuff.
res = OleInitialize(nullptr); res = OleInitialize(NULL);
DCHECK(SUCCEEDED(res)); DCHECK(SUCCEEDED(res));
} }

View File

@@ -51,7 +51,7 @@ void CefBrowserMessageFilter::OnGetNewRenderThreadInfo(
CefRefPtr<CefListValueImpl> listValuePtr( CefRefPtr<CefListValueImpl> listValuePtr(
new CefListValueImpl(&params->extra_info, false, false)); new CefListValueImpl(&params->extra_info, false, false));
handler->OnRenderProcessThreadCreated(listValuePtr.get()); handler->OnRenderProcessThreadCreated(listValuePtr.get());
listValuePtr->Detach(nullptr); listValuePtr->Detach(NULL);
} }
} }
} }

View File

@@ -14,7 +14,7 @@
#include "content/public/browser/render_view_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.h"
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() {} CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() : browser_(nullptr) {}
CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() { CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() {
DCHECK(!browser_); DCHECK(!browser_);
@@ -237,33 +237,32 @@ base::RepeatingClosure CefBrowserPlatformDelegate::GetBoundsChangedCallback() {
} }
// static // static
int CefBrowserPlatformDelegate::TranslateWebEventModifiers( int CefBrowserPlatformDelegate::TranslateModifiers(uint32 cef_modifiers) {
uint32 cef_modifiers) { int webkit_modifiers = 0;
int result = 0;
// Set modifiers based on key state. // Set modifiers based on key state.
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN) if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
result |= blink::WebInputEvent::kShiftKey; webkit_modifiers |= blink::WebInputEvent::kShiftKey;
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN) if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
result |= blink::WebInputEvent::kControlKey; webkit_modifiers |= blink::WebInputEvent::kControlKey;
if (cef_modifiers & EVENTFLAG_ALT_DOWN) if (cef_modifiers & EVENTFLAG_ALT_DOWN)
result |= blink::WebInputEvent::kAltKey; webkit_modifiers |= blink::WebInputEvent::kAltKey;
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN) if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
result |= blink::WebInputEvent::kMetaKey; webkit_modifiers |= blink::WebInputEvent::kMetaKey;
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result |= blink::WebInputEvent::kLeftButtonDown; webkit_modifiers |= blink::WebInputEvent::kLeftButtonDown;
if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result |= blink::WebInputEvent::kMiddleButtonDown; webkit_modifiers |= blink::WebInputEvent::kMiddleButtonDown;
if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result |= blink::WebInputEvent::kRightButtonDown; webkit_modifiers |= blink::WebInputEvent::kRightButtonDown;
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
result |= blink::WebInputEvent::kCapsLockOn; webkit_modifiers |= blink::WebInputEvent::kCapsLockOn;
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON) if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
result |= blink::WebInputEvent::kNumLockOn; webkit_modifiers |= blink::WebInputEvent::kNumLockOn;
if (cef_modifiers & EVENTFLAG_IS_LEFT) if (cef_modifiers & EVENTFLAG_IS_LEFT)
result |= blink::WebInputEvent::kIsLeft; webkit_modifiers |= blink::WebInputEvent::kIsLeft;
if (cef_modifiers & EVENTFLAG_IS_RIGHT) if (cef_modifiers & EVENTFLAG_IS_RIGHT)
result |= blink::WebInputEvent::kIsRight; webkit_modifiers |= blink::WebInputEvent::kIsRight;
if (cef_modifiers & EVENTFLAG_IS_KEY_PAD) if (cef_modifiers & EVENTFLAG_IS_KEY_PAD)
result |= blink::WebInputEvent::kIsKeyPad; webkit_modifiers |= blink::WebInputEvent::kIsKeyPad;
return result; return webkit_modifiers;
} }

View File

@@ -148,16 +148,11 @@ class CefBrowserPlatformDelegate {
virtual void WasResized() = 0; virtual void WasResized() = 0;
// Send input events. // Send input events.
virtual void SendKeyEvent(const CefKeyEvent& event) = 0; virtual void SendKeyEvent(const content::NativeWebKeyboardEvent& event) = 0;
virtual void SendMouseClickEvent(const CefMouseEvent& event, virtual void SendMouseEvent(const blink::WebMouseEvent& event) = 0;
CefBrowserHost::MouseButtonType type, virtual void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event) = 0;
bool mouseUp,
int clickCount) = 0; // Send touch events.
virtual void SendMouseMoveEvent(const CefMouseEvent& event,
bool mouseLeave) = 0;
virtual void SendMouseWheelEvent(const CefMouseEvent& event,
int deltaX,
int deltaY) = 0;
virtual void SendTouchEvent(const CefTouchEvent& event) = 0; virtual void SendTouchEvent(const CefTouchEvent& event) = 0;
// Send focus event. The browser's WebContents may be NULL when this method is // Send focus event. The browser's WebContents may be NULL when this method is
@@ -192,6 +187,22 @@ class CefBrowserPlatformDelegate {
// Invoke platform specific handling for the external protocol. // Invoke platform specific handling for the external protocol.
static void HandleExternalProtocol(const GURL& url); static void HandleExternalProtocol(const GURL& url);
// Translate CEF events to Chromium/Blink events.
virtual void TranslateKeyEvent(content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const = 0;
virtual void TranslateClickEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const = 0;
virtual void TranslateMoveEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
bool mouseLeave) const = 0;
virtual void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const = 0;
// Returns the OS event handle, if any, associated with |event|. // Returns the OS event handle, if any, associated with |event|.
virtual CefEventHandle GetEventHandle( virtual CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const = 0; const content::NativeWebKeyboardEvent& event) const = 0;
@@ -276,9 +287,9 @@ class CefBrowserPlatformDelegate {
base::RepeatingClosure GetBoundsChangedCallback(); base::RepeatingClosure GetBoundsChangedCallback();
static int TranslateWebEventModifiers(uint32 cef_modifiers); static int TranslateModifiers(uint32 cef_modifiers);
CefBrowserHostImpl* browser_ = nullptr; // Not owned by this object. CefBrowserHostImpl* browser_; // Not owned by this object.
private: private:
// Used for the print preview dialog. // Used for the print preview dialog.

View File

@@ -72,8 +72,8 @@ void ChromeBrowserProcessStub::Shutdown() {
// this might cause a nested message loop to run, and we don't want pending // this might cause a nested message loop to run, and we don't want pending
// tasks to run once teardown has started. // tasks to run once teardown has started.
print_job_manager_->Shutdown(); print_job_manager_->Shutdown();
print_job_manager_.reset(nullptr); print_job_manager_.reset(NULL);
print_preview_dialog_controller_ = nullptr; print_preview_dialog_controller_ = NULL;
profile_manager_.reset(); profile_manager_.reset();
event_router_forwarder_ = nullptr; event_router_forwarder_ = nullptr;
@@ -119,17 +119,17 @@ void ChromeBrowserProcessStub::FlushLocalStateAndReply(
metrics_services_manager::MetricsServicesManager* metrics_services_manager::MetricsServicesManager*
ChromeBrowserProcessStub::GetMetricsServicesManager() { ChromeBrowserProcessStub::GetMetricsServicesManager() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
metrics::MetricsService* ChromeBrowserProcessStub::metrics_service() { metrics::MetricsService* ChromeBrowserProcessStub::metrics_service() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
rappor::RapporServiceImpl* ChromeBrowserProcessStub::rappor_service() { rappor::RapporServiceImpl* ChromeBrowserProcessStub::rappor_service() {
// Called from PluginInfoHostImpl::ReportMetrics. // Called from PluginInfoHostImpl::ReportMetrics.
return nullptr; return NULL;
} }
SystemNetworkContextManager* SystemNetworkContextManager*
@@ -141,12 +141,12 @@ ChromeBrowserProcessStub::system_network_context_manager() {
network::NetworkQualityTracker* network::NetworkQualityTracker*
ChromeBrowserProcessStub::network_quality_tracker() { ChromeBrowserProcessStub::network_quality_tracker() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
WatchDogThread* ChromeBrowserProcessStub::watchdog_thread() { WatchDogThread* ChromeBrowserProcessStub::watchdog_thread() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
ProfileManager* ChromeBrowserProcessStub::profile_manager() { ProfileManager* ChromeBrowserProcessStub::profile_manager() {
@@ -157,17 +157,13 @@ ProfileManager* ChromeBrowserProcessStub::profile_manager() {
PrefService* ChromeBrowserProcessStub::local_state() { PrefService* ChromeBrowserProcessStub::local_state() {
DCHECK(initialized_); DCHECK(initialized_);
if (!local_state_) { if (!local_state_) {
// Use a location that is shared by all request contexts.
const CefSettings& settings = CefContext::Get()->settings(); const CefSettings& settings = CefContext::Get()->settings();
const base::FilePath& root_cache_path = const base::FilePath& cache_path =
base::FilePath(CefString(&settings.root_cache_path)); base::FilePath(CefString(&settings.cache_path));
// Used for very early NetworkService initialization. // Used for very early NetworkService initialization.
// Always persist preferences for this PrefService if possible because it local_state_ = browser_prefs::CreatePrefService(
// contains the cookie encryption key on Windows. nullptr, cache_path, !!settings.persist_user_preferences);
local_state_ =
browser_prefs::CreatePrefService(nullptr /* profile */, root_cache_path,
true /* persist_user_preferences */);
} }
return local_state_.get(); return local_state_.get();
} }
@@ -175,17 +171,17 @@ PrefService* ChromeBrowserProcessStub::local_state() {
scoped_refptr<network::SharedURLLoaderFactory> scoped_refptr<network::SharedURLLoaderFactory>
ChromeBrowserProcessStub::shared_url_loader_factory() { ChromeBrowserProcessStub::shared_url_loader_factory() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
variations::VariationsService* ChromeBrowserProcessStub::variations_service() { variations::VariationsService* ChromeBrowserProcessStub::variations_service() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
BrowserProcessPlatformPart* ChromeBrowserProcessStub::platform_part() { BrowserProcessPlatformPart* ChromeBrowserProcessStub::platform_part() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
extensions::EventRouterForwarder* extensions::EventRouterForwarder*
@@ -196,13 +192,13 @@ ChromeBrowserProcessStub::extension_event_router_forwarder() {
NotificationUIManager* ChromeBrowserProcessStub::notification_ui_manager() { NotificationUIManager* ChromeBrowserProcessStub::notification_ui_manager() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
NotificationPlatformBridge* NotificationPlatformBridge*
ChromeBrowserProcessStub::notification_platform_bridge() { ChromeBrowserProcessStub::notification_platform_bridge() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
policy::ChromeBrowserPolicyConnector* policy::ChromeBrowserPolicyConnector*
@@ -220,12 +216,12 @@ policy::PolicyService* ChromeBrowserProcessStub::policy_service() {
IconManager* ChromeBrowserProcessStub::icon_manager() { IconManager* ChromeBrowserProcessStub::icon_manager() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
GpuModeManager* ChromeBrowserProcessStub::gpu_mode_manager() { GpuModeManager* ChromeBrowserProcessStub::gpu_mode_manager() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
void ChromeBrowserProcessStub::CreateDevToolsProtocolHandler() { void ChromeBrowserProcessStub::CreateDevToolsProtocolHandler() {
@@ -267,7 +263,7 @@ ChromeBrowserProcessStub::background_printing_manager() {
IntranetRedirectDetector* IntranetRedirectDetector*
ChromeBrowserProcessStub::intranet_redirect_detector() { ChromeBrowserProcessStub::intranet_redirect_detector() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
const std::string& ChromeBrowserProcessStub::GetApplicationLocale() { const std::string& ChromeBrowserProcessStub::GetApplicationLocale() {
@@ -281,17 +277,17 @@ void ChromeBrowserProcessStub::SetApplicationLocale(const std::string& locale) {
DownloadStatusUpdater* ChromeBrowserProcessStub::download_status_updater() { DownloadStatusUpdater* ChromeBrowserProcessStub::download_status_updater() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
DownloadRequestLimiter* ChromeBrowserProcessStub::download_request_limiter() { DownloadRequestLimiter* ChromeBrowserProcessStub::download_request_limiter() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
BackgroundModeManager* ChromeBrowserProcessStub::background_mode_manager() { BackgroundModeManager* ChromeBrowserProcessStub::background_mode_manager() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
void ChromeBrowserProcessStub::set_background_mode_manager_for_test( void ChromeBrowserProcessStub::set_background_mode_manager_for_test(
@@ -301,35 +297,35 @@ void ChromeBrowserProcessStub::set_background_mode_manager_for_test(
StatusTray* ChromeBrowserProcessStub::status_tray() { StatusTray* ChromeBrowserProcessStub::status_tray() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
safe_browsing::SafeBrowsingService* safe_browsing::SafeBrowsingService*
ChromeBrowserProcessStub::safe_browsing_service() { ChromeBrowserProcessStub::safe_browsing_service() {
return nullptr; return NULL;
} }
safe_browsing::ClientSideDetectionService* safe_browsing::ClientSideDetectionService*
ChromeBrowserProcessStub::safe_browsing_detection_service() { ChromeBrowserProcessStub::safe_browsing_detection_service() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
subresource_filter::RulesetService* subresource_filter::RulesetService*
ChromeBrowserProcessStub::subresource_filter_ruleset_service() { ChromeBrowserProcessStub::subresource_filter_ruleset_service() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
optimization_guide::OptimizationGuideService* optimization_guide::OptimizationGuideService*
ChromeBrowserProcessStub::optimization_guide_service() { ChromeBrowserProcessStub::optimization_guide_service() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
StartupData* ChromeBrowserProcessStub::startup_data() { StartupData* ChromeBrowserProcessStub::startup_data() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
@@ -339,38 +335,38 @@ void ChromeBrowserProcessStub::StartAutoupdateTimer() {}
component_updater::ComponentUpdateService* component_updater::ComponentUpdateService*
ChromeBrowserProcessStub::component_updater() { ChromeBrowserProcessStub::component_updater() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
MediaFileSystemRegistry* MediaFileSystemRegistry*
ChromeBrowserProcessStub::media_file_system_registry() { ChromeBrowserProcessStub::media_file_system_registry() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
WebRtcLogUploader* ChromeBrowserProcessStub::webrtc_log_uploader() { WebRtcLogUploader* ChromeBrowserProcessStub::webrtc_log_uploader() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
network_time::NetworkTimeTracker* network_time::NetworkTimeTracker*
ChromeBrowserProcessStub::network_time_tracker() { ChromeBrowserProcessStub::network_time_tracker() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
gcm::GCMDriver* ChromeBrowserProcessStub::gcm_driver() { gcm::GCMDriver* ChromeBrowserProcessStub::gcm_driver() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
resource_coordinator::TabManager* ChromeBrowserProcessStub::GetTabManager() { resource_coordinator::TabManager* ChromeBrowserProcessStub::GetTabManager() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
resource_coordinator::ResourceCoordinatorParts* resource_coordinator::ResourceCoordinatorParts*
ChromeBrowserProcessStub::resource_coordinator_parts() { ChromeBrowserProcessStub::resource_coordinator_parts() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }

View File

@@ -36,7 +36,7 @@ Profile::ProfileType ChromeProfileStub::GetProfileType() const {
Profile* ChromeProfileStub::GetOffTheRecordProfile() { Profile* ChromeProfileStub::GetOffTheRecordProfile() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
void ChromeProfileStub::DestroyOffTheRecordProfile() { void ChromeProfileStub::DestroyOffTheRecordProfile() {
@@ -70,12 +70,12 @@ bool ChromeProfileStub::IsLegacySupervised() const {
ExtensionSpecialStoragePolicy* ExtensionSpecialStoragePolicy*
ChromeProfileStub::GetExtensionSpecialStoragePolicy() { ChromeProfileStub::GetExtensionSpecialStoragePolicy() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
PrefService* ChromeProfileStub::GetOffTheRecordPrefs() { PrefService* ChromeProfileStub::GetOffTheRecordPrefs() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
bool ChromeProfileStub::IsSameProfile(Profile* profile) { bool ChromeProfileStub::IsSameProfile(Profile* profile) {

View File

@@ -39,6 +39,7 @@
#include "libcef/common/net/scheme_registration.h" #include "libcef/common/net/scheme_registration.h"
#include "libcef/common/request_impl.h" #include "libcef/common/request_impl.h"
#include "libcef/common/service_manifests/cef_content_browser_overlay_manifest.h" #include "libcef/common/service_manifests/cef_content_browser_overlay_manifest.h"
#include "libcef/common/service_manifests/cef_content_renderer_overlay_manifest.h"
#include "base/base_switches.h" #include "base/base_switches.h"
#include "base/command_line.h" #include "base/command_line.h"
@@ -77,6 +78,7 @@
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_ppapi_host.h" #include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/overlay_window.h" #include "content/public/browser/overlay_window.h"
@@ -101,7 +103,7 @@
#include "extensions/browser/extensions_browser_client.h" #include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h" #include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h" #include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/url_loader_factory_manager.h" #include "extensions/browser/io_thread_extension_message_filter.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "extensions/common/switches.h" #include "extensions/common/switches.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
@@ -135,19 +137,14 @@
#endif #endif
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "net/ssl/client_cert_store_mac.h" #include "services/audio/public/mojom/constants.mojom.h"
#include "services/video_capture/public/mojom/constants.mojom.h" #include "services/video_capture/public/mojom/constants.mojom.h"
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
#include "net/ssl/client_cert_store_win.h"
#include "sandbox/win/src/sandbox_policy.h" #include "sandbox/win/src/sandbox_policy.h"
#endif #endif
#if defined(USE_NSS_CERTS)
#include "net/ssl/client_cert_store_nss.h"
#endif
#if BUILDFLAG(HAS_SPELLCHECK_PANEL) #if BUILDFLAG(HAS_SPELLCHECK_PANEL)
#include "chrome/browser/spellchecker/spell_check_panel_host_impl.h" #include "chrome/browser/spellchecker/spell_check_panel_host_impl.h"
#endif #endif
@@ -156,19 +153,18 @@ namespace {
class CefQuotaCallbackImpl : public CefRequestCallback { class CefQuotaCallbackImpl : public CefRequestCallback {
public: public:
using CallbackType = content::QuotaPermissionContext::PermissionCallback; explicit CefQuotaCallbackImpl(
const content::QuotaPermissionContext::PermissionCallback& callback)
explicit CefQuotaCallbackImpl(CallbackType callback) : callback_(callback) {}
: callback_(std::move(callback)) {}
~CefQuotaCallbackImpl() { ~CefQuotaCallbackImpl() {
if (!callback_.is_null()) { if (!callback_.is_null()) {
// The callback is still pending. Cancel it now. // The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_IOT()) { if (CEF_CURRENTLY_ON_IOT()) {
RunNow(std::move(callback_), false); RunNow(callback_, false);
} else { } else {
CEF_POST_TASK(CEF_IOT, base::BindOnce(&CefQuotaCallbackImpl::RunNow, CEF_POST_TASK(CEF_IOT, base::Bind(&CefQuotaCallbackImpl::RunNow,
std::move(callback_), false)); callback_, false));
} }
} }
} }
@@ -176,28 +172,31 @@ class CefQuotaCallbackImpl : public CefRequestCallback {
void Continue(bool allow) override { void Continue(bool allow) override {
if (CEF_CURRENTLY_ON_IOT()) { if (CEF_CURRENTLY_ON_IOT()) {
if (!callback_.is_null()) { if (!callback_.is_null()) {
RunNow(std::move(callback_), allow); RunNow(callback_, allow);
callback_.Reset();
} }
} else { } else {
CEF_POST_TASK(CEF_IOT, base::BindOnce(&CefQuotaCallbackImpl::Continue, CEF_POST_TASK(CEF_IOT,
this, allow)); base::Bind(&CefQuotaCallbackImpl::Continue, this, allow));
} }
} }
void Cancel() override { Continue(false); } void Cancel() override { Continue(false); }
CallbackType Disconnect() WARN_UNUSED_RESULT { return std::move(callback_); } void Disconnect() { callback_.Reset(); }
private: private:
static void RunNow(CallbackType callback, bool allow) { static void RunNow(
const content::QuotaPermissionContext::PermissionCallback& callback,
bool allow) {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
std::move(callback).Run( callback.Run(
allow ? content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW allow ? content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW
: content::QuotaPermissionContext:: : content::QuotaPermissionContext::
QUOTA_PERMISSION_RESPONSE_DISALLOW); QUOTA_PERMISSION_RESPONSE_DISALLOW);
} }
CallbackType callback_; content::QuotaPermissionContext::PermissionCallback callback_;
IMPLEMENT_REFCOUNTING(CefQuotaCallbackImpl); IMPLEMENT_REFCOUNTING(CefQuotaCallbackImpl);
DISALLOW_COPY_AND_ASSIGN(CefQuotaCallbackImpl); DISALLOW_COPY_AND_ASSIGN(CefQuotaCallbackImpl);
@@ -205,22 +204,21 @@ class CefQuotaCallbackImpl : public CefRequestCallback {
class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback { class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
public: public:
typedef base::OnceCallback<void(content::CertificateRequestResultType)> typedef base::Callback<void(content::CertificateRequestResultType)>
CallbackType; CallbackType;
explicit CefAllowCertificateErrorCallbackImpl(CallbackType callback) explicit CefAllowCertificateErrorCallbackImpl(const CallbackType& callback)
: callback_(std::move(callback)) {} : callback_(callback) {}
~CefAllowCertificateErrorCallbackImpl() { ~CefAllowCertificateErrorCallbackImpl() {
if (!callback_.is_null()) { if (!callback_.is_null()) {
// The callback is still pending. Cancel it now. // The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
RunNow(std::move(callback_), false); RunNow(callback_, false);
} else { } else {
CEF_POST_TASK( CEF_POST_TASK(CEF_UIT,
CEF_UIT, base::Bind(&CefAllowCertificateErrorCallbackImpl::RunNow,
base::BindOnce(&CefAllowCertificateErrorCallbackImpl::RunNow, callback_, false));
std::move(callback_), false));
} }
} }
} }
@@ -228,7 +226,8 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
void Continue(bool allow) override { void Continue(bool allow) override {
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
if (!callback_.is_null()) { if (!callback_.is_null()) {
RunNow(std::move(callback_), allow); RunNow(callback_, allow);
callback_.Reset();
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
@@ -239,14 +238,13 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
void Cancel() override { Continue(false); } void Cancel() override { Continue(false); }
CallbackType Disconnect() WARN_UNUSED_RESULT { return std::move(callback_); } void Disconnect() { callback_.Reset(); }
private: private:
static void RunNow(CallbackType callback, bool allow) { static void RunNow(const CallbackType& callback, bool allow) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
std::move(callback).Run( callback.Run(allow ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE
allow ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE : content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
: content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
} }
CallbackType callback_; CallbackType callback_;
@@ -266,7 +264,7 @@ class CefSelectClientCertificateCallbackImpl
// If Select has not been called, call it with NULL to continue without any // If Select has not been called, call it with NULL to continue without any
// client certificate. // client certificate.
if (delegate_) if (delegate_)
DoSelect(nullptr); DoSelect(NULL);
} }
void Select(CefRefPtr<CefX509Certificate> cert) override { void Select(CefRefPtr<CefX509Certificate> cert) override {
@@ -279,10 +277,9 @@ class CefSelectClientCertificateCallbackImpl
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
RunNow(std::move(delegate_), cert); RunNow(std::move(delegate_), cert);
} else { } else {
CEF_POST_TASK( CEF_POST_TASK(CEF_UIT,
CEF_UIT, base::Bind(&CefSelectClientCertificateCallbackImpl::RunNow,
base::BindOnce(&CefSelectClientCertificateCallbackImpl::RunNow, base::Passed(std::move(delegate_)), cert));
std::move(delegate_), cert));
} }
} }
@@ -294,9 +291,9 @@ class CefSelectClientCertificateCallbackImpl
if (cert) { if (cert) {
CefX509CertificateImpl* certImpl = CefX509CertificateImpl* certImpl =
static_cast<CefX509CertificateImpl*>(cert.get()); static_cast<CefX509CertificateImpl*>(cert.get());
certImpl->AcquirePrivateKey(base::BindOnce( certImpl->AcquirePrivateKey(
&CefSelectClientCertificateCallbackImpl::RunWithPrivateKey, base::Bind(&CefSelectClientCertificateCallbackImpl::RunWithPrivateKey,
std::move(delegate), cert)); base::Passed(std::move(delegate)), cert));
return; return;
} }
@@ -332,11 +329,11 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext {
// The callback will be dispatched on the IO thread. // The callback will be dispatched on the IO thread.
void RequestQuotaPermission(const content::StorageQuotaParams& params, void RequestQuotaPermission(const content::StorageQuotaParams& params,
int render_process_id, int render_process_id,
PermissionCallback callback) override { const PermissionCallback& callback) override {
if (params.storage_type != blink::mojom::StorageType::kPersistent) { if (params.storage_type != blink::mojom::StorageType::kPersistent) {
// To match Chrome behavior we only support requesting quota with this // To match Chrome behavior we only support requesting quota with this
// interface for Persistent storage type. // interface for Persistent storage type.
std::move(callback).Run(QUOTA_PERMISSION_RESPONSE_DISALLOW); callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW);
return; return;
} }
@@ -351,22 +348,19 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext {
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler(); CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
if (handler.get()) { if (handler.get()) {
CefRefPtr<CefQuotaCallbackImpl> callbackImpl( CefRefPtr<CefQuotaCallbackImpl> callbackImpl(
new CefQuotaCallbackImpl(std::move(callback))); new CefQuotaCallbackImpl(callback));
handled = handler->OnQuotaRequest( handled = handler->OnQuotaRequest(
browser.get(), params.origin_url.spec(), params.requested_size, browser.get(), params.origin_url.spec(), params.requested_size,
callbackImpl.get()); callbackImpl.get());
if (!handled) { if (!handled)
// May return nullptr if the client has already executed the callbackImpl->Disconnect();
// callback.
callback = callbackImpl->Disconnect();
}
} }
} }
} }
if (!handled && !callback.is_null()) { if (!handled) {
// Disallow the request by default. // Disallow the request by default.
std::move(callback).Run(QUOTA_PERMISSION_RESPONSE_DISALLOW); callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW);
} }
} }
@@ -399,7 +393,7 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
// Extensions have the same process type as renderers. // Extensions have the same process type as renderers.
if (command_line.HasSwitch(extensions::switches::kExtensionProcess)) { if (command_line.HasSwitch(extensions::switches::kExtensionProcess)) {
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr; static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
if (!crash_handler) if (!crash_handler)
crash_handler = CreateCrashHandlerHost("extension"); crash_handler = CreateCrashHandlerHost("extension");
return crash_handler->GetDeathSignalSocket(); return crash_handler->GetDeathSignalSocket();
@@ -409,21 +403,21 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
command_line.GetSwitchValueASCII(switches::kProcessType); command_line.GetSwitchValueASCII(switches::kProcessType);
if (process_type == switches::kRendererProcess) { if (process_type == switches::kRendererProcess) {
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr; static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
if (!crash_handler) if (!crash_handler)
crash_handler = CreateCrashHandlerHost(process_type); crash_handler = CreateCrashHandlerHost(process_type);
return crash_handler->GetDeathSignalSocket(); return crash_handler->GetDeathSignalSocket();
} }
if (process_type == switches::kPpapiPluginProcess) { if (process_type == switches::kPpapiPluginProcess) {
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr; static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
if (!crash_handler) if (!crash_handler)
crash_handler = CreateCrashHandlerHost(process_type); crash_handler = CreateCrashHandlerHost(process_type);
return crash_handler->GetDeathSignalSocket(); return crash_handler->GetDeathSignalSocket();
} }
if (process_type == switches::kGpuProcess) { if (process_type == switches::kGpuProcess) {
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr; static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
if (!crash_handler) if (!crash_handler)
crash_handler = CreateCrashHandlerHost(process_type); crash_handler = CreateCrashHandlerHost(process_type);
return crash_handler->GetDeathSignalSocket(); return crash_handler->GetDeathSignalSocket();
@@ -507,8 +501,7 @@ void BindPluginInfoHost(
} // namespace } // namespace
CefContentBrowserClient::CefContentBrowserClient() CefContentBrowserClient::CefContentBrowserClient() : browser_main_parts_(NULL) {
: browser_main_parts_(nullptr) {
plugin_service_filter_.reset(new CefPluginServiceFilter); plugin_service_filter_.reset(new CefPluginServiceFilter);
content::PluginServiceImpl::GetInstance()->SetFilter( content::PluginServiceImpl::GetInstance()->SetFilter(
plugin_service_filter_.get()); plugin_service_filter_.get());
@@ -541,6 +534,7 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
if (extensions::ExtensionsEnabled()) { if (extensions::ExtensionsEnabled()) {
host->AddFilter(new extensions::ExtensionMessageFilter(id, profile)); host->AddFilter(new extensions::ExtensionMessageFilter(id, profile));
host->AddFilter(new extensions::IOThreadExtensionMessageFilter());
host->AddFilter( host->AddFilter(
new extensions::ExtensionsGuestViewMessageFilter(id, profile)); new extensions::ExtensionsGuestViewMessageFilter(id, profile));
} }
@@ -600,17 +594,6 @@ bool CefContentBrowserClient::DoesSiteRequireDedicatedProcess(
return extension != nullptr; return extension != nullptr;
} }
void CefContentBrowserClient::OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
const url::Origin& origin,
bool is_for_isolated_world,
network::mojom::URLLoaderFactoryParams* factory_params) {
if (extensions::ExtensionsEnabled()) {
extensions::URLLoaderFactoryManager::OverrideURLLoaderFactoryParams(
browser_context, origin, is_for_isolated_world, factory_params);
}
}
void CefContentBrowserClient::GetAdditionalWebUISchemes( void CefContentBrowserClient::GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) { std::vector<std::string>* additional_schemes) {
// Any schemes listed here are treated as WebUI schemes but do not get WebUI // Any schemes listed here are treated as WebUI schemes but do not get WebUI
@@ -729,6 +712,8 @@ base::Optional<service_manager::Manifest>
CefContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) { CefContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
if (name == content::mojom::kBrowserServiceName) { if (name == content::mojom::kBrowserServiceName) {
return GetCefContentBrowserOverlayManifest(); return GetCefContentBrowserOverlayManifest();
} else if (name == content::mojom::kRendererServiceName) {
return GetCefContentRendererOverlayManifest();
} }
return base::nullopt; return base::nullopt;
@@ -850,11 +835,23 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
CefRefPtr<CefCommandLineImpl> commandLinePtr( CefRefPtr<CefCommandLineImpl> commandLinePtr(
new CefCommandLineImpl(command_line, false, false)); new CefCommandLineImpl(command_line, false, false));
handler->OnBeforeChildProcessLaunch(commandLinePtr.get()); handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
commandLinePtr->Detach(nullptr); commandLinePtr->Detach(NULL);
} }
} }
} }
void CefContentBrowserClient::AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) {
#if defined(OS_MACOSX)
// On Mac, the video-capture and audio services require a CFRunLoop, provided
// by a UI message loop, to run AVFoundation and CoreAudio code.
// See https://crbug.com/834581
if (identity.name() == audio::mojom::kServiceName)
command_line->AppendSwitch(switches::kMessageLoopTypeUi);
#endif
}
std::string CefContentBrowserClient::GetApplicationLocale() { std::string CefContentBrowserClient::GetApplicationLocale() {
return g_browser_process->GetApplicationLocale(); return g_browser_process->GetApplicationLocale();
} }
@@ -884,6 +881,16 @@ CefContentBrowserClient::CreateQuotaPermissionContext() {
return new CefQuotaPermissionContext(); return new CefQuotaPermissionContext();
} }
void CefContentBrowserClient::GetQuotaSettings(
content::BrowserContext* context,
content::StoragePartition* partition,
base::OnceCallback<void(base::Optional<storage::QuotaSettings>)> callback) {
const base::FilePath& cache_path = partition->GetPath();
storage::GetNominalDynamicSettings(
cache_path, cache_path.empty() /* is_incognito */,
storage::GetDefaultDiskInfoHelper(), std::move(callback));
}
content::MediaObserver* CefContentBrowserClient::GetMediaObserver() { content::MediaObserver* CefContentBrowserClient::GetMediaObserver() {
return CefMediaCaptureDevicesDispatcher::GetInstance(); return CefMediaCaptureDevicesDispatcher::GetInstance();
} }
@@ -895,7 +902,7 @@ CefContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
if (command_line->HasSwitch(switches::kEnableSpeechInput)) if (command_line->HasSwitch(switches::kEnableSpeechInput))
return new CefSpeechRecognitionManagerDelegate(); return new CefSpeechRecognitionManagerDelegate();
return nullptr; return NULL;
} }
content::GeneratedCodeCacheSettings content::GeneratedCodeCacheSettings
@@ -916,14 +923,15 @@ void CefContentBrowserClient::AllowCertificateError(
const GURL& request_url, const GURL& request_url,
bool is_main_frame_request, bool is_main_frame_request,
bool strict_enforcement, bool strict_enforcement,
base::OnceCallback<void(content::CertificateRequestResultType)> callback) { const base::Callback<void(content::CertificateRequestResultType)>&
callback) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (!is_main_frame_request) { if (!is_main_frame_request) {
// A sub-resource has a certificate error. The user doesn't really // A sub-resource has a certificate error. The user doesn't really
// have a context for making the right decision, so block the request // have a context for making the right decision, so block the request
// hard. // hard.
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL); callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
return; return;
} }
@@ -941,17 +949,14 @@ void CefContentBrowserClient::AllowCertificateError(
CefRefPtr<CefSSLInfo> cef_ssl_info = new CefSSLInfoImpl(ssl_info); CefRefPtr<CefSSLInfo> cef_ssl_info = new CefSSLInfoImpl(ssl_info);
CefRefPtr<CefAllowCertificateErrorCallbackImpl> callbackImpl( CefRefPtr<CefAllowCertificateErrorCallbackImpl> callbackImpl(
new CefAllowCertificateErrorCallbackImpl(std::move(callback))); new CefAllowCertificateErrorCallbackImpl(callback));
bool proceed = handler->OnCertificateError( bool proceed = handler->OnCertificateError(
browser.get(), static_cast<cef_errorcode_t>(cert_error), browser.get(), static_cast<cef_errorcode_t>(cert_error),
request_url.spec(), cef_ssl_info, callbackImpl.get()); request_url.spec(), cef_ssl_info, callbackImpl.get());
if (!proceed) { if (!proceed) {
// |callback| may be null if the user executed it despite returning false. callbackImpl->Disconnect();
callback = callbackImpl->Disconnect(); callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
if (!callback.is_null()) {
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
}
} }
} }
@@ -1024,6 +1029,11 @@ void CefContentBrowserClient::OverrideWebkitPrefs(
// Using RVH instead of RFH here because rvh->GetMainFrame() may be nullptr // Using RVH instead of RFH here because rvh->GetMainFrame() may be nullptr
// when this method is called. // when this method is called.
renderer_prefs::PopulateWebPreferences(rvh, *prefs); renderer_prefs::PopulateWebPreferences(rvh, *prefs);
if (rvh->GetWidget()->GetView()) {
rvh->GetWidget()->GetView()->SetBackgroundColor(
prefs->base_background_color);
}
} }
void CefContentBrowserClient::BrowserURLHandlerCreated( void CefContentBrowserClient::BrowserURLHandlerCreated(
@@ -1153,19 +1163,11 @@ void CefContentBrowserClient::ExposeInterfacesToRenderer(
std::unique_ptr<net::ClientCertStore> std::unique_ptr<net::ClientCertStore>
CefContentBrowserClient::CreateClientCertStore( CefContentBrowserClient::CreateClientCertStore(
content::BrowserContext* browser_context) { content::ResourceContext* resource_context) {
// Match the logic in ProfileNetworkContextService::CreateClientCertStore. if (!resource_context)
#if defined(USE_NSS_CERTS) return nullptr;
// TODO: Add support for client implementation of crypto password dialog. return static_cast<CefResourceContext*>(resource_context)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS( ->CreateClientCertStore();
net::ClientCertStoreNSS::PasswordDelegateFactory()));
#elif defined(OS_WIN)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin());
#elif defined(OS_MACOSX)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreMac());
#else
#error Unknown platform.
#endif
} }
std::unique_ptr<content::LoginDelegate> std::unique_ptr<content::LoginDelegate>
@@ -1254,13 +1256,10 @@ bool CefContentBrowserClient::WillCreateURLLoaderFactory(
int render_process_id, int render_process_id,
URLLoaderFactoryType type, URLLoaderFactoryType type,
const url::Origin& request_initiator, const url::Origin& request_initiator,
base::Optional<int64_t> navigation_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver, mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>* mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
header_client, header_client,
bool* bypass_redirect_checks, bool* bypass_redirect_checks) {
bool* disable_secure_dns,
network::mojom::URLLoaderFactoryOverridePtr* factory_override) {
auto request_handler = net_service::CreateInterceptedRequestHandler( auto request_handler = net_service::CreateInterceptedRequestHandler(
browser_context, frame, render_process_id, browser_context, frame, render_process_id,
type == URLLoaderFactoryType::kNavigation, type == URLLoaderFactoryType::kNavigation,
@@ -1322,14 +1321,14 @@ CefContentBrowserClient::GetNetworkContextsParentDirectory() {
bool CefContentBrowserClient::HandleExternalProtocol( bool CefContentBrowserClient::HandleExternalProtocol(
const GURL& url, const GURL& url,
base::OnceCallback<content::WebContents*()> web_contents_getter, base::Callback<content::WebContents*(void)> web_contents_getter,
int child_id, int child_id,
content::NavigationUIData* navigation_data, content::NavigationUIData* navigation_data,
bool is_main_frame, bool is_main_frame,
ui::PageTransition page_transition, ui::PageTransition page_transition,
bool has_user_gesture, bool has_user_gesture,
const base::Optional<url::Origin>& initiating_origin, const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) { network::mojom::URLLoaderFactoryPtr* out_factory) {
// Call the other HandleExternalProtocol variant. // Call the other HandleExternalProtocol variant.
return false; return false;
} }
@@ -1339,34 +1338,32 @@ bool CefContentBrowserClient::HandleExternalProtocol(
int frame_tree_node_id, int frame_tree_node_id,
content::NavigationUIData* navigation_data, content::NavigationUIData* navigation_data,
const network::ResourceRequest& resource_request, const network::ResourceRequest& resource_request,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) { network::mojom::URLLoaderFactoryPtr* out_factory) {
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver = auto request = mojo::MakeRequest(out_factory);
out_factory->InitWithNewPipeAndPassReceiver();
// CefBrowserPlatformDelegate::HandleExternalProtocol may be called if // CefBrowserPlatformDelegate::HandleExternalProtocol may be called if
// nothing handles the request. // nothing handles the request.
if (CEF_CURRENTLY_ON_IOT()) { if (CEF_CURRENTLY_ON_IOT()) {
auto request_handler = net_service::CreateInterceptedRequestHandler( auto request_handler = net_service::CreateInterceptedRequestHandler(
web_contents_getter, frame_tree_node_id, resource_request); web_contents_getter, frame_tree_node_id, resource_request);
net_service::ProxyURLLoaderFactory::CreateProxy( net_service::ProxyURLLoaderFactory::CreateProxy(
web_contents_getter, std::move(receiver), std::move(request_handler)); web_contents_getter, std::move(request), std::move(request_handler));
} else { } else {
auto request_handler = net_service::CreateInterceptedRequestHandler( auto request_handler = net_service::CreateInterceptedRequestHandler(
web_contents_getter, frame_tree_node_id, resource_request); web_contents_getter, frame_tree_node_id, resource_request);
CEF_POST_TASK( CEF_POST_TASK(CEF_IOT,
CEF_IOT, base::BindOnce(
base::BindOnce( [](network::mojom::URLLoaderFactoryRequest request,
[](mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver, std::unique_ptr<net_service::InterceptedRequestHandler>
std::unique_ptr<net_service::InterceptedRequestHandler> request_handler,
request_handler, content::WebContents::Getter web_contents_getter) {
content::WebContents::Getter web_contents_getter) { // Manages its own lifetime.
// Manages its own lifetime.
net_service::ProxyURLLoaderFactory::CreateProxy( net_service::ProxyURLLoaderFactory::CreateProxy(
web_contents_getter, std::move(receiver), web_contents_getter, std::move(request),
std::move(request_handler)); std::move(request_handler));
}, },
std::move(receiver), std::move(request_handler), std::move(request), std::move(request_handler),
std::move(web_contents_getter))); std::move(web_contents_getter)));
} }
return true; return true;
} }
@@ -1383,33 +1380,6 @@ CefContentBrowserClient::CreateWindowForPictureInPicture(
return content::OverlayWindow::Create(controller); return content::OverlayWindow::Create(controller);
} }
void CefContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map) {
if (!extensions::ExtensionsEnabled())
return;
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
if (!web_contents)
return;
const GURL& site = render_frame_host->GetSiteInstance()->GetSiteURL();
if (!site.SchemeIs(extensions::kExtensionScheme))
return;
content::BrowserContext* browser_context =
render_frame_host->GetProcess()->GetBrowserContext();
auto* extension = extensions::ExtensionRegistry::Get(browser_context)
->enabled_extensions()
.GetByID(site.host());
if (!extension)
return;
extensions::ExtensionsBrowserClient::Get()
->RegisterBrowserInterfaceBindersForFrame(map, render_frame_host,
extension);
}
std::string CefContentBrowserClient::GetProduct() { std::string CefContentBrowserClient::GetProduct() {
// Match the logic in chrome_content_browser_client.cc GetProduct(). // Match the logic in chrome_content_browser_client.cc GetProduct().
return ::GetProduct(); return ::GetProduct();
@@ -1448,6 +1418,16 @@ CefContentBrowserClient::GetPluginMimeTypesWithExternalHandlers(
return mime_types; return mime_types;
} }
void CefContentBrowserClient::RegisterCustomScheme(const std::string& scheme) {
// Register as a Web-safe scheme so that requests for the scheme from a
// render process will be allowed in resource_dispatcher_host_impl.cc
// ShouldServiceRequest.
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
if (!policy->IsWebSafeScheme(scheme))
policy->RegisterWebSafeScheme(scheme);
}
CefRefPtr<CefRequestContextImpl> CefContentBrowserClient::request_context() CefRefPtr<CefRequestContextImpl> CefContentBrowserClient::request_context()
const { const {
return browser_main_parts_->request_context(); return browser_main_parts_->request_context();

View File

@@ -46,11 +46,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
const GURL& effective_url) override; const GURL& effective_url) override;
bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context, bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context,
const GURL& effective_site_url) override; const GURL& effective_site_url) override;
void OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
const url::Origin& origin,
bool is_for_isolated_world,
network::mojom::URLLoaderFactoryParams* factory_params) override;
void GetAdditionalWebUISchemes( void GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) override; std::vector<std::string>* additional_schemes) override;
void GetAdditionalViewSourceSchemes( void GetAdditionalViewSourceSchemes(
@@ -68,12 +63,20 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
base::StringPiece name) override; base::StringPiece name) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line, void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override; int child_process_id) override;
void AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) override;
std::string GetApplicationLocale() override; std::string GetApplicationLocale() override;
scoped_refptr<network::SharedURLLoaderFactory> scoped_refptr<network::SharedURLLoaderFactory>
GetSystemSharedURLLoaderFactory() override; GetSystemSharedURLLoaderFactory() override;
network::mojom::NetworkContext* GetSystemNetworkContext() override; network::mojom::NetworkContext* GetSystemNetworkContext() override;
scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext() scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext()
override; override;
void GetQuotaSettings(
content::BrowserContext* context,
content::StoragePartition* partition,
base::OnceCallback<void(base::Optional<storage::QuotaSettings>)> callback)
override;
content::MediaObserver* GetMediaObserver() override; content::MediaObserver* GetMediaObserver() override;
content::SpeechRecognitionManagerDelegate* content::SpeechRecognitionManagerDelegate*
CreateSpeechRecognitionManagerDelegate() override; CreateSpeechRecognitionManagerDelegate() override;
@@ -86,8 +89,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
const GURL& request_url, const GURL& request_url,
bool is_main_frame_request, bool is_main_frame_request,
bool strict_enforcement, bool strict_enforcement,
base::OnceCallback<void(content::CertificateRequestResultType)> callback) const base::Callback<void(content::CertificateRequestResultType)>&
override; callback) override;
base::OnceClosure SelectClientCertificate( base::OnceClosure SelectClientCertificate(
content::WebContents* web_contents, content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info, net::SSLCertRequestInfo* cert_request_info,
@@ -141,7 +144,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
blink::AssociatedInterfaceRegistry* associated_registry, blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* render_process_host) override; content::RenderProcessHost* render_process_host) override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore( std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
content::BrowserContext* browser_context) override; content::ResourceContext* resource_context) override;
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate( std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info, const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents, content::WebContents* web_contents,
@@ -164,13 +167,10 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
int render_process_id, int render_process_id,
URLLoaderFactoryType type, URLLoaderFactoryType type,
const url::Origin& request_initiator, const url::Origin& request_initiator,
base::Optional<int64_t> navigation_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver, mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>* mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
header_client, header_client,
bool* bypass_redirect_checks, bool* bypass_redirect_checks) override;
bool* disable_secure_dns,
network::mojom::URLLoaderFactoryOverridePtr* factory_override) override;
void OnNetworkServiceCreated( void OnNetworkServiceCreated(
network::mojom::NetworkService* network_service) override; network::mojom::NetworkService* network_service) override;
mojo::Remote<network::mojom::NetworkContext> CreateNetworkContext( mojo::Remote<network::mojom::NetworkContext> CreateNetworkContext(
@@ -180,28 +180,22 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override; std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
bool HandleExternalProtocol( bool HandleExternalProtocol(
const GURL& url, const GURL& url,
base::OnceCallback<content::WebContents*()> web_contents_getter, base::Callback<content::WebContents*(void)> web_contents_getter,
int child_id, int child_id,
content::NavigationUIData* navigation_data, content::NavigationUIData* navigation_data,
bool is_main_frame, bool is_main_frame,
ui::PageTransition page_transition, ui::PageTransition page_transition,
bool has_user_gesture, bool has_user_gesture,
const base::Optional<url::Origin>& initiating_origin, const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) network::mojom::URLLoaderFactoryPtr* out_factory) override;
override;
bool HandleExternalProtocol( bool HandleExternalProtocol(
content::WebContents::Getter web_contents_getter, content::WebContents::Getter web_contents_getter,
int frame_tree_node_id, int frame_tree_node_id,
content::NavigationUIData* navigation_data, content::NavigationUIData* navigation_data,
const network::ResourceRequest& request, const network::ResourceRequest& request,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) network::mojom::URLLoaderFactoryPtr* out_factory) override;
override;
std::unique_ptr<content::OverlayWindow> CreateWindowForPictureInPicture( std::unique_ptr<content::OverlayWindow> CreateWindowForPictureInPicture(
content::PictureInPictureWindowController* controller) override; content::PictureInPictureWindowController* controller) override;
void RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map)
override;
std::string GetProduct() override; std::string GetProduct() override;
std::string GetChromeProduct() override; std::string GetChromeProduct() override;
@@ -210,6 +204,9 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers( base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers(
content::BrowserContext* browser_context) override; content::BrowserContext* browser_context) override;
// Perform browser process registration for the custom scheme.
void RegisterCustomScheme(const std::string& scheme);
CefRefPtr<CefRequestContextImpl> request_context() const; CefRefPtr<CefRequestContextImpl> request_context() const;
CefDevToolsDelegate* devtools_delegate() const; CefDevToolsDelegate* devtools_delegate() const;

View File

@@ -49,7 +49,7 @@
namespace { namespace {
CefContext* g_context = nullptr; CefContext* g_context = NULL;
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
// When the process terminates check if CefShutdown() has been called. // When the process terminates check if CefShutdown() has been called.
@@ -201,7 +201,7 @@ int CefExecuteProcess(const CefMainArgs& args,
// Execute the secondary process. // Execute the secondary process.
#if defined(OS_WIN) #if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0}; sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (windows_sandbox_info == nullptr) { if (windows_sandbox_info == NULL) {
content::InitializeSandboxInfo(&sandbox_info); content::InitializeSandboxInfo(&sandbox_info);
windows_sandbox_info = &sandbox_info; windows_sandbox_info = &sandbox_info;
} }
@@ -270,7 +270,7 @@ void CefShutdown() {
// Delete the global context object. // Delete the global context object.
delete g_context; delete g_context;
g_context = nullptr; g_context = NULL;
} }
void CefDoMessageLoopWork() { void CefDoMessageLoopWork() {
@@ -391,7 +391,8 @@ bool CefContext::Initialize(const CefMainArgs& args,
content::ContentMainParams params(main_delegate_.get()); content::ContentMainParams params(main_delegate_.get());
#if defined(OS_WIN) #if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0}; sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (windows_sandbox_info == nullptr) { if (windows_sandbox_info == NULL) {
content::InitializeSandboxInfo(&sandbox_info);
windows_sandbox_info = &sandbox_info; windows_sandbox_info = &sandbox_info;
settings_.no_sandbox = true; settings_.no_sandbox = true;
} }
@@ -480,7 +481,7 @@ void CefContext::Shutdown() {
FinalizeShutdown(); FinalizeShutdown();
} else { } else {
// Finish shutdown on the current thread, which should be the UI thread. // Finish shutdown on the current thread, which should be the UI thread.
FinishShutdownOnUIThread(nullptr); FinishShutdownOnUIThread(NULL);
FinalizeShutdown(); FinalizeShutdown();
} }
@@ -512,7 +513,7 @@ SkColor CefContext::GetBackgroundColor(
CefTraceSubscriber* CefContext::GetTraceSubscriber() { CefTraceSubscriber* CefContext::GetTraceSubscriber() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (shutting_down_) if (shutting_down_)
return nullptr; return NULL;
if (!trace_subscriber_.get()) if (!trace_subscriber_.get())
trace_subscriber_.reset(new CefTraceSubscriber()); trace_subscriber_.reset(new CefTraceSubscriber());
return trace_subscriber_.get(); return trace_subscriber_.get();
@@ -606,7 +607,7 @@ void CefContext::FinishShutdownOnUIThread(
observer.OnContextDestroyed(); observer.OnContextDestroyed();
if (trace_subscriber_.get()) if (trace_subscriber_.get())
trace_subscriber_.reset(nullptr); trace_subscriber_.reset(NULL);
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Shutdown(); static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Shutdown();
@@ -630,11 +631,11 @@ void CefContext::FinalizeShutdown() {
// Shut down the content runner. // Shut down the content runner.
service_manager::MainShutdown(*sm_main_params_); service_manager::MainShutdown(*sm_main_params_);
browser_info_manager_.reset(nullptr); browser_info_manager_.reset(NULL);
sm_main_params_.reset(nullptr); sm_main_params_.reset(NULL);
sm_main_delegate_.reset(nullptr); sm_main_delegate_.reset(NULL);
main_delegate_.reset(nullptr); main_delegate_.reset(NULL);
delete g_browser_process; delete g_browser_process;
g_browser_process = nullptr; g_browser_process = NULL;
} }

View File

@@ -10,7 +10,7 @@ CefContextMenuParamsImpl::CefContextMenuParamsImpl(
content::ContextMenuParams* value) content::ContextMenuParams* value)
: CefValueBase<CefContextMenuParams, content::ContextMenuParams>( : CefValueBase<CefContextMenuParams, content::ContextMenuParams>(
value, value,
nullptr, NULL,
kOwnerNoDelete, kOwnerNoDelete,
true, true,
new CefValueControllerNonThreadSafe()) { new CefValueControllerNonThreadSafe()) {
@@ -38,7 +38,7 @@ CefContextMenuParamsImpl::TypeFlags CefContextMenuParamsImpl::GetTypeFlags() {
type_flags |= CM_TYPEFLAG_FRAME; type_flags |= CM_TYPEFLAG_FRAME;
if (!params.link_url.is_empty()) if (!params.link_url.is_empty())
type_flags |= CM_TYPEFLAG_LINK; type_flags |= CM_TYPEFLAG_LINK;
if (params.media_type != blink::ContextMenuDataMediaType::kNone) if (params.media_type != blink::WebContextMenuData::kMediaTypeNone)
type_flags |= CM_TYPEFLAG_MEDIA; type_flags |= CM_TYPEFLAG_MEDIA;
if (!params.selection_text.empty()) if (!params.selection_text.empty())
type_flags |= CM_TYPEFLAG_SELECTION; type_flags |= CM_TYPEFLAG_SELECTION;

View File

@@ -154,13 +154,12 @@ void CefDevToolsFileManager::FileSavedAs(const std::string& url,
base::Value url_value(url); base::Value url_value(url);
base::Value file_system_path_value(file_system_path); base::Value file_system_path_value(file_system_path);
CallClientFunction("DevToolsAPI.savedURL", &url_value, CallClientFunction("DevToolsAPI.savedURL", &url_value,
&file_system_path_value, nullptr); &file_system_path_value, NULL);
} }
void CefDevToolsFileManager::CanceledFileSaveAs(const std::string& url) { void CefDevToolsFileManager::CanceledFileSaveAs(const std::string& url) {
base::Value url_value(url); base::Value url_value(url);
CallClientFunction("DevToolsAPI.canceledSaveURL", &url_value, nullptr, CallClientFunction("DevToolsAPI.canceledSaveURL", &url_value, NULL, NULL);
nullptr);
} }
void CefDevToolsFileManager::Append(const std::string& url, void CefDevToolsFileManager::Append(const std::string& url,
@@ -176,7 +175,7 @@ void CefDevToolsFileManager::Append(const std::string& url,
void CefDevToolsFileManager::AppendedTo(const std::string& url) { void CefDevToolsFileManager::AppendedTo(const std::string& url) {
base::Value url_value(url); base::Value url_value(url);
CallClientFunction("DevToolsAPI.appendedToURL", &url_value, nullptr, nullptr); CallClientFunction("DevToolsAPI.appendedToURL", &url_value, NULL, NULL);
} }
void CefDevToolsFileManager::CallClientFunction( void CefDevToolsFileManager::CallClientFunction(

View File

@@ -45,6 +45,7 @@
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "net/traffic_annotation/network_traffic_annotation.h" #include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_response.h"
#include "services/network/public/cpp/simple_url_loader.h" #include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h" #include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
#include "services/network/public/mojom/url_response_head.mojom.h" #include "services/network/public/mojom/url_response_head.mojom.h"
@@ -58,20 +59,9 @@ static std::string GetFrontendURL() {
} }
std::unique_ptr<base::DictionaryValue> BuildObjectForResponse( std::unique_ptr<base::DictionaryValue> BuildObjectForResponse(
const net::HttpResponseHeaders* rh, const net::HttpResponseHeaders* rh) {
bool success,
int net_error) {
auto response = std::make_unique<base::DictionaryValue>(); auto response = std::make_unique<base::DictionaryValue>();
int responseCode = 200; response->SetInteger("statusCode", rh ? rh->response_code() : 200);
if (rh) {
responseCode = rh->response_code();
} else if (!success) {
// In case of no headers, assume file:// URL and failed to load
responseCode = 404;
}
response->SetInteger("statusCode", responseCode);
response->SetInteger("netError", net_error);
response->SetString("netErrorName", net::ErrorToString(net_error));
auto headers = std::make_unique<base::DictionaryValue>(); auto headers = std::make_unique<base::DictionaryValue>();
size_t iterator = 0; size_t iterator = 0;
@@ -132,8 +122,7 @@ class CefDevToolsFrontend::NetworkResourceLoader
} }
void OnComplete(bool success) override { void OnComplete(bool success) override {
auto response = BuildObjectForResponse(response_headers_.get(), success, auto response = BuildObjectForResponse(response_headers_.get());
loader_->NetError());
bindings_->SendMessageAck(request_id_, response.get()); bindings_->SendMessageAck(request_id_, response.get());
bindings_->loaders_.erase(bindings_->loaders_.find(this)); bindings_->loaders_.erase(bindings_->loaders_.find(this));
@@ -220,7 +209,7 @@ void CefDevToolsFrontend::DisconnectFromTarget() {
if (!agent_host_) if (!agent_host_)
return; return;
agent_host_->DetachClient(this); agent_host_->DetachClient(this);
agent_host_ = nullptr; agent_host_ = NULL;
} }
CefDevToolsFrontend::CefDevToolsFrontend( CefDevToolsFrontend::CefDevToolsFrontend(
@@ -285,8 +274,8 @@ void CefDevToolsFrontend::WebContentsDestroyed() {
void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend( void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
const std::string& message) { const std::string& message) {
std::string method; std::string method;
base::ListValue* params = nullptr; base::ListValue* params = NULL;
base::DictionaryValue* dict = nullptr; base::DictionaryValue* dict = NULL;
base::Optional<base::Value> parsed_message = base::JSONReader::Read(message); base::Optional<base::Value> parsed_message = base::JSONReader::Read(message);
if (!parsed_message || !parsed_message->GetAsDictionary(&dict) || if (!parsed_message || !parsed_message->GetAsDictionary(&dict) ||
!dict->GetString("method", &method)) { !dict->GetString("method", &method)) {
@@ -300,8 +289,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
std::string protocol_message; std::string protocol_message;
if (!agent_host_ || !params->GetString(0, &protocol_message)) if (!agent_host_ || !params->GetString(0, &protocol_message))
return; return;
agent_host_->DispatchProtocolMessage( agent_host_->DispatchProtocolMessage(this, protocol_message);
this, base::as_bytes(base::make_span(protocol_message)));
} else if (method == "loadCompleted") { } else if (method == "loadCompleted") {
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests( web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
base::ASCIIToUTF16("DevToolsAPI.setUseSoftMenu(true);"), base::ASCIIToUTF16("DevToolsAPI.setUseSoftMenu(true);"),
@@ -320,7 +308,6 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
if (!gurl.is_valid()) { if (!gurl.is_valid()) {
base::DictionaryValue response; base::DictionaryValue response;
response.SetInteger("statusCode", 404); response.SetInteger("statusCode", 404);
response.SetBoolean("urlValid", false);
SendMessageAck(request_id, &response); SendMessageAck(request_id, &response);
return; return;
} }
@@ -357,7 +344,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
// TODO(caseq): this preserves behavior of URLFetcher-based // TODO(caseq): this preserves behavior of URLFetcher-based
// implementation. We really need to pass proper first party origin from // implementation. We really need to pass proper first party origin from
// the front-end. // the front-end.
resource_request->site_for_cookies = net::SiteForCookies::FromUrl(gurl); resource_request->site_for_cookies = gurl;
resource_request->headers.AddHeadersFromString(headers); resource_request->headers.AddHeadersFromString(headers);
std::unique_ptr<network::mojom::URLLoaderFactory> file_url_loader_factory; std::unique_ptr<network::mojom::URLLoaderFactory> file_url_loader_factory;
@@ -448,12 +435,10 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
void CefDevToolsFrontend::DispatchProtocolMessage( void CefDevToolsFrontend::DispatchProtocolMessage(
content::DevToolsAgentHost* agent_host, content::DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) { const std::string& message) {
base::StringPiece str_message(reinterpret_cast<const char*>(message.data()), if (message.length() < kMaxMessageChunkSize) {
message.size());
if (str_message.length() < kMaxMessageChunkSize) {
std::string param; std::string param;
base::EscapeJSONString(str_message, true, &param); base::EscapeJSONString(message, true, &param);
std::string code = "DevToolsAPI.dispatchMessage(" + param + ");"; std::string code = "DevToolsAPI.dispatchMessage(" + param + ");";
base::string16 javascript = base::UTF8ToUTF16(code); base::string16 javascript = base::UTF8ToUTF16(code);
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests( web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
@@ -461,11 +446,10 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
return; return;
} }
size_t total_size = str_message.length(); size_t total_size = message.length();
for (size_t pos = 0; pos < str_message.length(); for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
pos += kMaxMessageChunkSize) {
std::string param; std::string param;
base::EscapeJSONString(str_message.substr(pos, kMaxMessageChunkSize), true, base::EscapeJSONString(message.substr(pos, kMaxMessageChunkSize), true,
&param); &param);
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," + std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," +
std::to_string(pos ? 0 : total_size) + ");"; std::to_string(pos ? 0 : total_size) + ");";

View File

@@ -66,7 +66,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
// content::DevToolsAgentHostClient implementation. // content::DevToolsAgentHostClient implementation.
void AgentHostClosed(content::DevToolsAgentHost* agent_host) override; void AgentHostClosed(content::DevToolsAgentHost* agent_host) override;
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host, void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) override; const std::string& message) override;
void HandleMessageFromDevToolsFrontend(const std::string& message); void HandleMessageFromDevToolsFrontend(const std::string& message);
private: private:

View File

@@ -12,7 +12,7 @@
CefDownloadItemImpl::CefDownloadItemImpl(download::DownloadItem* value) CefDownloadItemImpl::CefDownloadItemImpl(download::DownloadItem* value)
: CefValueBase<CefDownloadItem, download::DownloadItem>( : CefValueBase<CefDownloadItem, download::DownloadItem>(
value, value,
nullptr, NULL,
kOwnerNoDelete, kOwnerNoDelete,
true, true,
new CefValueControllerNonThreadSafe()) { new CefValueControllerNonThreadSafe()) {

View File

@@ -34,7 +34,7 @@ CefRefPtr<CefDownloadHandler> GetDownloadHandler(
CefRefPtr<CefClient> client = browser->GetClient(); CefRefPtr<CefClient> client = browser->GetClient();
if (client.get()) if (client.get())
return client->GetDownloadHandler(); return client->GetDownloadHandler();
return nullptr; return NULL;
} }
// CefBeforeDownloadCallback implementation. // CefBeforeDownloadCallback implementation.
@@ -43,11 +43,11 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
CefBeforeDownloadCallbackImpl(const base::WeakPtr<DownloadManager>& manager, CefBeforeDownloadCallbackImpl(const base::WeakPtr<DownloadManager>& manager,
uint32 download_id, uint32 download_id,
const base::FilePath& suggested_name, const base::FilePath& suggested_name,
content::DownloadTargetCallback callback) const content::DownloadTargetCallback& callback)
: manager_(manager), : manager_(manager),
download_id_(download_id), download_id_(download_id),
suggested_name_(suggested_name), suggested_name_(suggested_name),
callback_(std::move(callback)) {} callback_(callback) {}
void Continue(const CefString& download_path, bool show_dialog) override { void Continue(const CefString& download_path, bool show_dialog) override {
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
@@ -56,27 +56,28 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
if (manager_) { if (manager_) {
base::FilePath path = base::FilePath(download_path); base::FilePath path = base::FilePath(download_path);
CEF_POST_USER_VISIBLE_TASK( CEF_POST_USER_VISIBLE_TASK(base::Bind(
base::BindOnce(&CefBeforeDownloadCallbackImpl::GenerateFilename, &CefBeforeDownloadCallbackImpl::GenerateFilename, manager_,
manager_, download_id_, suggested_name_, path, download_id_, suggested_name_, path, show_dialog, callback_));
show_dialog, std::move(callback_)));
} }
download_id_ = 0; download_id_ = 0;
callback_.Reset();
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefBeforeDownloadCallbackImpl::Continue, base::Bind(&CefBeforeDownloadCallbackImpl::Continue, this,
this, download_path, show_dialog)); download_path, show_dialog));
} }
} }
private: private:
static void GenerateFilename(base::WeakPtr<DownloadManager> manager, static void GenerateFilename(
uint32 download_id, base::WeakPtr<DownloadManager> manager,
const base::FilePath& suggested_name, uint32 download_id,
const base::FilePath& download_path, const base::FilePath& suggested_name,
bool show_dialog, const base::FilePath& download_path,
content::DownloadTargetCallback callback) { bool show_dialog,
const content::DownloadTargetCallback& callback) {
CEF_REQUIRE_BLOCKING(); CEF_REQUIRE_BLOCKING();
base::FilePath suggested_path = download_path; base::FilePath suggested_path = download_path;
@@ -102,16 +103,16 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::BindOnce(&CefBeforeDownloadCallbackImpl::ChooseDownloadPath, base::Bind(&CefBeforeDownloadCallbackImpl::ChooseDownloadPath, manager,
manager, download_id, suggested_path, show_dialog, download_id, suggested_path, show_dialog, callback));
std::move(callback)));
} }
static void ChooseDownloadPath(base::WeakPtr<DownloadManager> manager, static void ChooseDownloadPath(
uint32 download_id, base::WeakPtr<DownloadManager> manager,
const base::FilePath& suggested_path, uint32 download_id,
bool show_dialog, const base::FilePath& suggested_path,
content::DownloadTargetCallback callback) { bool show_dialog,
const content::DownloadTargetCallback& callback) {
if (!manager) if (!manager)
return; return;
@@ -141,23 +142,21 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
browser->RunFileChooser( browser->RunFileChooser(
params, params,
base::BindOnce( base::Bind(
&CefBeforeDownloadCallbackImpl::ChooseDownloadPathCallback, &CefBeforeDownloadCallbackImpl::ChooseDownloadPathCallback,
std::move(callback))); callback));
} }
} }
if (!handled) { if (!handled) {
std::move(callback).Run( callback.Run(suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, suggested_path,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, download::DOWNLOAD_INTERRUPT_REASON_NONE);
download::DownloadItem::MixedContentStatus::UNKNOWN, suggested_path,
download::DOWNLOAD_INTERRUPT_REASON_NONE);
} }
} }
static void ChooseDownloadPathCallback( static void ChooseDownloadPathCallback(
content::DownloadTargetCallback callback, const content::DownloadTargetCallback& callback,
int selected_accept_filter, int selected_accept_filter,
const std::vector<base::FilePath>& file_paths) { const std::vector<base::FilePath>& file_paths) {
DCHECK_LE(file_paths.size(), (size_t)1); DCHECK_LE(file_paths.size(), (size_t)1);
@@ -167,10 +166,9 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
path = file_paths.front(); path = file_paths.front();
// The download will be cancelled if |path| is empty. // The download will be cancelled if |path| is empty.
std::move(callback).Run(path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, callback.Run(path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
download::DownloadItem::MixedContentStatus::UNKNOWN, download::DOWNLOAD_INTERRUPT_REASON_NONE);
path, download::DOWNLOAD_INTERRUPT_REASON_NONE);
} }
base::WeakPtr<DownloadManager> manager_; base::WeakPtr<DownloadManager> manager_;
@@ -264,7 +262,7 @@ CefDownloadManagerDelegate::CefDownloadManagerDelegate(DownloadManager* manager)
CefDownloadManagerDelegate::~CefDownloadManagerDelegate() { CefDownloadManagerDelegate::~CefDownloadManagerDelegate() {
if (manager_) { if (manager_) {
manager_->SetDelegate(nullptr); manager_->SetDelegate(NULL);
manager_->RemoveObserver(this); manager_->RemoveObserver(this);
} }
@@ -286,7 +284,7 @@ void CefDownloadManagerDelegate::OnDownloadUpdated(DownloadItem* download) {
handler->OnDownloadUpdated(browser.get(), download_item.get(), callback); handler->OnDownloadUpdated(browser.get(), download_item.get(), callback);
download_item->Detach(nullptr); download_item->Detach(NULL);
} }
} }
@@ -341,21 +339,20 @@ void CefDownloadManagerDelegate::OnDownloadCreated(DownloadManager* manager,
void CefDownloadManagerDelegate::ManagerGoingDown(DownloadManager* manager) { void CefDownloadManagerDelegate::ManagerGoingDown(DownloadManager* manager) {
DCHECK_EQ(manager, manager_); DCHECK_EQ(manager, manager_);
manager->SetDelegate(nullptr); manager->SetDelegate(NULL);
manager->RemoveObserver(this); manager->RemoveObserver(this);
manager_ptr_factory_.InvalidateWeakPtrs(); manager_ptr_factory_.InvalidateWeakPtrs();
manager_ = nullptr; manager_ = NULL;
} }
bool CefDownloadManagerDelegate::DetermineDownloadTarget( bool CefDownloadManagerDelegate::DetermineDownloadTarget(
DownloadItem* item, DownloadItem* item,
content::DownloadTargetCallback* callback) { const content::DownloadTargetCallback& callback) {
if (!item->GetForcedFilePath().empty()) { if (!item->GetForcedFilePath().empty()) {
std::move(*callback).Run( callback.Run(
item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE, item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, item->GetForcedFilePath(),
download::DownloadItem::MixedContentStatus::UNKNOWN, download::DOWNLOAD_INTERRUPT_REASON_NONE);
item->GetForcedFilePath(), download::DOWNLOAD_INTERRUPT_REASON_NONE);
return true; return true;
} }
@@ -375,21 +372,21 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
CefRefPtr<CefBeforeDownloadCallback> callbackObj( CefRefPtr<CefBeforeDownloadCallback> callbackObj(
new CefBeforeDownloadCallbackImpl(manager_ptr_factory_.GetWeakPtr(), new CefBeforeDownloadCallbackImpl(manager_ptr_factory_.GetWeakPtr(),
item->GetId(), suggested_name, item->GetId(), suggested_name,
std::move(*callback))); callback));
handler->OnBeforeDownload(browser.get(), download_item.get(), handler->OnBeforeDownload(browser.get(), download_item.get(),
suggested_name.value(), callbackObj); suggested_name.value(), callbackObj);
download_item->Detach(nullptr); download_item->Detach(NULL);
} }
return true; return true;
} }
void CefDownloadManagerDelegate::GetNextId( void CefDownloadManagerDelegate::GetNextId(
content::DownloadIdCallback callback) { const content::DownloadIdCallback& callback) {
static uint32 next_id = DownloadItem::kInvalidId + 1; static uint32 next_id = DownloadItem::kInvalidId + 1;
std::move(callback).Run(next_id++); callback.Run(next_id++);
} }
std::string CefDownloadManagerDelegate::ApplicationClientIdForFileScanning() { std::string CefDownloadManagerDelegate::ApplicationClientIdForFileScanning() {

View File

@@ -37,8 +37,8 @@ class CefDownloadManagerDelegate : public download::DownloadItem::Observer,
// DownloadManagerDelegate methods. // DownloadManagerDelegate methods.
bool DetermineDownloadTarget( bool DetermineDownloadTarget(
download::DownloadItem* item, download::DownloadItem* item,
content::DownloadTargetCallback* callback) override; const content::DownloadTargetCallback& callback) override;
void GetNextId(content::DownloadIdCallback callback) override; void GetNextId(const content::DownloadIdCallback& callback) override;
std::string ApplicationClientIdForFileScanning() override; std::string ApplicationClientIdForFileScanning() override;
// CefBrowserHostImpl::Observer methods. // CefBrowserHostImpl::Observer methods.

View File

@@ -110,7 +110,7 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
return set_init_result(VALIDATION_FAILURE); return set_init_result(VALIDATION_FAILURE);
// |details| are not optional. // |details| are not optional.
base::DictionaryValue* details_value = nullptr; base::DictionaryValue* details_value = NULL;
if (!args_->GetDictionary(1, &details_value)) if (!args_->GetDictionary(1, &details_value))
return set_init_result(VALIDATION_FAILURE); return set_init_result(VALIDATION_FAILURE);
std::unique_ptr<InjectDetails> details(new InjectDetails()); std::unique_ptr<InjectDetails> details(new InjectDetails());
@@ -282,10 +282,9 @@ bool TabsSetZoomFunction::RunAsync() {
zoom::ZoomController* zoom_controller = zoom::ZoomController* zoom_controller =
zoom::ZoomController::FromWebContents(web_contents); zoom::ZoomController::FromWebContents(web_contents);
double zoom_level = double zoom_level = params->zoom_factor > 0
params->zoom_factor > 0 ? blink::PageZoomFactorToZoomLevel(params->zoom_factor)
? blink::PageZoomFactorToZoomLevel(params->zoom_factor) : zoom_controller->GetDefaultZoomLevel();
: zoom_controller->GetDefaultZoomLevel();
scoped_refptr<extensions::ExtensionZoomRequestClient> client( scoped_refptr<extensions::ExtensionZoomRequestClient> client(
new extensions::ExtensionZoomRequestClient(extension())); new extensions::ExtensionZoomRequestClient(extension()));
@@ -385,9 +384,8 @@ bool TabsGetZoomSettingsFunction::RunAsync() {
zoom::ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode(); zoom::ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode();
api::tabs::ZoomSettings zoom_settings; api::tabs::ZoomSettings zoom_settings;
ZoomModeToZoomSettings(zoom_mode, &zoom_settings); ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
zoom_settings.default_zoom_factor.reset( zoom_settings.default_zoom_factor.reset(new double(
new double(blink::PageZoomLevelToZoomFactor( blink::PageZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel())));
zoom_controller->GetDefaultZoomLevel())));
results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
SendResponse(true); SendResponse(true);

View File

@@ -42,7 +42,7 @@ content::WebContents* GetFullPageGuestForOwnerContents(
if (plugin_guest) if (plugin_guest)
return plugin_guest->web_contents(); return plugin_guest->web_contents();
} }
return nullptr; return NULL;
} }
void GetAllGuestsForOwnerContents(content::WebContents* owner, void GetAllGuestsForOwnerContents(content::WebContents* owner,
@@ -58,10 +58,8 @@ content::WebContents* GetOwnerForGuestContents(content::WebContents* guest) {
static_cast<content::WebContentsImpl*>(guest); static_cast<content::WebContentsImpl*>(guest);
content::BrowserPluginGuest* plugin_guest = content::BrowserPluginGuest* plugin_guest =
guest_impl->GetBrowserPluginGuest(); guest_impl->GetBrowserPluginGuest();
if (plugin_guest) { if (plugin_guest)
return content::WebContents::FromRenderFrameHost( return plugin_guest->embedder_web_contents();
plugin_guest->GetEmbedderFrame());
}
// Maybe it's a print preview dialog. // Maybe it's a print preview dialog.
auto print_preview_controller = auto print_preview_controller =
@@ -79,7 +77,7 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForFrameRoute(
content::RenderFrameHost::FromID(render_process_id, render_routing_id); content::RenderFrameHost::FromID(render_process_id, render_routing_id);
if (host) if (host)
return GetOwnerBrowserForHost(host, is_guest_view); return GetOwnerBrowserForHost(host, is_guest_view);
return nullptr; return NULL;
} else { } else {
// Use the thread-safe approach. // Use the thread-safe approach.
scoped_refptr<CefBrowserInfo> info = scoped_refptr<CefBrowserInfo> info =
@@ -95,7 +93,7 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForFrameRoute(
} }
return browser; return browser;
} }
return nullptr; return NULL;
} }
} }

View File

@@ -52,28 +52,17 @@ void CefBrowserPlatformDelegateBackground::WasResized() {
} }
void CefBrowserPlatformDelegateBackground::SendKeyEvent( void CefBrowserPlatformDelegateBackground::SendKeyEvent(
const CefKeyEvent& event) { const content::NativeWebKeyboardEvent& event) {
// Nothing to do here. // Nothing to do here.
} }
void CefBrowserPlatformDelegateBackground::SendMouseClickEvent( void CefBrowserPlatformDelegateBackground::SendMouseEvent(
const CefMouseEvent& event, const blink::WebMouseEvent& event) {
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) {
// Nothing to do here.
}
void CefBrowserPlatformDelegateBackground::SendMouseMoveEvent(
const CefMouseEvent& event,
bool mouseLeave) {
// Nothing to do here. // Nothing to do here.
} }
void CefBrowserPlatformDelegateBackground::SendMouseWheelEvent( void CefBrowserPlatformDelegateBackground::SendMouseWheelEvent(
const CefMouseEvent& event, const blink::WebMouseWheelEvent& event) {
int deltaX,
int deltaY) {
// Nothing to do here. // Nothing to do here.
} }
@@ -102,6 +91,37 @@ bool CefBrowserPlatformDelegateBackground::HandleKeyboardEvent(
return false; return false;
} }
void CefBrowserPlatformDelegateBackground::TranslateKeyEvent(
content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const {
native_delegate_->TranslateKeyEvent(result, key_event);
}
void CefBrowserPlatformDelegateBackground::TranslateClickEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const {
native_delegate_->TranslateClickEvent(result, mouse_event, type, mouseUp,
clickCount);
}
void CefBrowserPlatformDelegateBackground::TranslateMoveEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
bool mouseLeave) const {
native_delegate_->TranslateMoveEvent(result, mouse_event, mouseLeave);
}
void CefBrowserPlatformDelegateBackground::TranslateWheelEvent(
blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const {
native_delegate_->TranslateWheelEvent(result, mouse_event, deltaX, deltaY);
}
CefEventHandle CefBrowserPlatformDelegateBackground::GetEventHandle( CefEventHandle CefBrowserPlatformDelegateBackground::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const { const content::NativeWebKeyboardEvent& event) const {
return native_delegate_->GetEventHandle(event); return native_delegate_->GetEventHandle(event);

View File

@@ -25,21 +25,29 @@ class CefBrowserPlatformDelegateBackground
bool CanUseSharedTexture() const override; bool CanUseSharedTexture() const override;
bool CanUseExternalBeginFrame() const override; bool CanUseExternalBeginFrame() const override;
void WasResized() override; void WasResized() override;
void SendKeyEvent(const CefKeyEvent& event) override; void SendKeyEvent(const content::NativeWebKeyboardEvent& event) override;
void SendMouseClickEvent(const CefMouseEvent& event, void SendMouseEvent(const blink::WebMouseEvent& event) override;
CefBrowserHost::MouseButtonType type, void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event) override;
bool mouseUp,
int clickCount) override;
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
void SendMouseWheelEvent(const CefMouseEvent& event,
int deltaX,
int deltaY) override;
void SendTouchEvent(const CefTouchEvent& event) override; void SendTouchEvent(const CefTouchEvent& event) override;
void SendFocusEvent(bool setFocus) override; void SendFocusEvent(bool setFocus) override;
gfx::Point GetScreenPoint(const gfx::Point& view) const override; gfx::Point GetScreenPoint(const gfx::Point& view) const override;
void ViewText(const std::string& text) override; void ViewText(const std::string& text) override;
bool HandleKeyboardEvent( bool HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override; const content::NativeWebKeyboardEvent& event) override;
void TranslateKeyEvent(content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const override;
void TranslateClickEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const override;
void TranslateMoveEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
bool mouseLeave) const override;
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const override;
CefEventHandle GetEventHandle( CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override; const content::NativeWebKeyboardEvent& event) const override;
std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override; std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override;

View File

@@ -50,28 +50,13 @@ CefComponentExtensionResourceManager::GetTemplateReplacementsForExtension(
void CefComponentExtensionResourceManager::AddComponentResourceEntries( void CefComponentExtensionResourceManager::AddComponentResourceEntries(
const GritResourceMap* entries, const GritResourceMap* entries,
size_t size) { size_t size) {
base::FilePath gen_folder_path = base::FilePath().AppendASCII(
"@out_folder@/gen/chrome/browser/resources/");
gen_folder_path = gen_folder_path.NormalizePathSeparators();
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
base::FilePath resource_path = base::FilePath resource_path =
base::FilePath().AppendASCII(entries[i].name); base::FilePath().AppendASCII(entries[i].name);
resource_path = resource_path.NormalizePathSeparators(); resource_path = resource_path.NormalizePathSeparators();
if (!gen_folder_path.IsParent(resource_path)) { DCHECK(!base::Contains(path_to_resource_info_, resource_path));
DCHECK(!base::Contains(path_to_resource_info_, resource_path)); path_to_resource_info_[resource_path] = entries[i].value;
path_to_resource_info_[resource_path] = entries[i].value;
} else {
// If the resource is a generated file, strip the generated folder's path,
// so that it can be served from a normal URL (as if it were not
// generated).
base::FilePath effective_path =
base::FilePath().AppendASCII(resource_path.AsUTF8Unsafe().substr(
gen_folder_path.value().length()));
DCHECK(!base::Contains(path_to_resource_info_, effective_path));
path_to_resource_info_[effective_path] = entries[i].value;
}
} }
} }

View File

@@ -44,9 +44,10 @@ class CefGetExtensionLoadFileCallbackImpl
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
RunNow(file_, std::move(callback_), nullptr); RunNow(file_, std::move(callback_), nullptr);
} else { } else {
CEF_POST_TASK(CEF_UIT, base::BindOnce( CEF_POST_TASK(
&CefGetExtensionLoadFileCallbackImpl::RunNow, CEF_UIT,
file_, std::move(callback_), nullptr)); base::BindOnce(&CefGetExtensionLoadFileCallbackImpl::RunNow, file_,
base::Passed(std::move(callback_)), nullptr));
} }
} }
} }
@@ -55,9 +56,10 @@ class CefGetExtensionLoadFileCallbackImpl
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
if (!callback_.is_null()) { if (!callback_.is_null()) {
// Always continue asynchronously. // Always continue asynchronously.
CEF_POST_TASK(CEF_UIT, base::BindOnce( CEF_POST_TASK(
&CefGetExtensionLoadFileCallbackImpl::RunNow, CEF_UIT,
file_, std::move(callback_), stream)); base::BindOnce(&CefGetExtensionLoadFileCallbackImpl::RunNow, file_,
base::Passed(std::move(callback_)), stream));
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, base::BindOnce( CEF_POST_TASK(CEF_UIT, base::BindOnce(
@@ -371,7 +373,7 @@ base::DictionaryValue* CefExtensionFunctionDetails::OpenTab(
create_params.window_info.reset(new CefWindowInfo); create_params.window_info.reset(new CefWindowInfo);
#if defined(OS_WIN) #if defined(OS_WIN)
create_params.window_info->SetAsPopup(nullptr, CefString()); create_params.window_info->SetAsPopup(NULL, CefString());
#endif #endif
// Start with the active browser's settings. // Start with the active browser's settings.

View File

@@ -27,7 +27,7 @@ content::JavaScriptDialogManager*
CefExtensionHostDelegate::GetJavaScriptDialogManager() { CefExtensionHostDelegate::GetJavaScriptDialogManager() {
// Never routed here from CefBrowserHostImpl. // Never routed here from CefBrowserHostImpl.
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
void CefExtensionHostDelegate::CreateTab( void CefExtensionHostDelegate::CreateTab(
@@ -59,6 +59,10 @@ bool CefExtensionHostDelegate::CheckMediaAccessPermission(
return false; return false;
} }
ExtensionHostQueue* CefExtensionHostDelegate::GetExtensionHostQueue() const {
return CefExtensionsBrowserClient::Get()->GetExtensionHostQueue();
}
content::PictureInPictureResult CefExtensionHostDelegate::EnterPictureInPicture( content::PictureInPictureResult CefExtensionHostDelegate::EnterPictureInPicture(
content::WebContents* web_contents, content::WebContents* web_contents,
const viz::SurfaceId& surface_id, const viz::SurfaceId& surface_id,

View File

@@ -34,6 +34,7 @@ class CefExtensionHostDelegate : public ExtensionHostDelegate {
const GURL& security_origin, const GURL& security_origin,
blink::mojom::MediaStreamType type, blink::mojom::MediaStreamType type,
const Extension* extension) override; const Extension* extension) override;
ExtensionHostQueue* GetExtensionHostQueue() const override;
content::PictureInPictureResult EnterPictureInPicture( content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents, content::WebContents* web_contents,
const viz::SurfaceId& surface_id, const viz::SurfaceId& surface_id,

View File

@@ -44,7 +44,6 @@
#include "extensions/browser/runtime_data.h" #include "extensions/browser/runtime_data.h"
#include "extensions/browser/service_worker_manager.h" #include "extensions/browser/service_worker_manager.h"
#include "extensions/browser/state_store.h" #include "extensions/browser/state_store.h"
#include "extensions/browser/unloaded_extension_reason.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "extensions/common/extension_messages.h" #include "extensions/common/extension_messages.h"
#include "extensions/common/file_util.h" #include "extensions/common/file_util.h"
@@ -64,12 +63,11 @@ namespace {
std::unique_ptr<base::DictionaryValue> ParseManifest( std::unique_ptr<base::DictionaryValue> ParseManifest(
const std::string& manifest_contents) { const std::string& manifest_contents) {
JSONStringValueDeserializer deserializer(manifest_contents); JSONStringValueDeserializer deserializer(manifest_contents);
std::unique_ptr<base::Value> manifest( std::unique_ptr<base::Value> manifest(deserializer.Deserialize(NULL, NULL));
deserializer.Deserialize(nullptr, nullptr));
if (!manifest.get() || !manifest->is_dict()) { if (!manifest.get() || !manifest->is_dict()) {
LOG(ERROR) << "Failed to parse extension manifest."; LOG(ERROR) << "Failed to parse extension manifest.";
return nullptr; return NULL;
} }
// Transfer ownership to the caller. // Transfer ownership to the caller.
return base::WrapUnique( return base::WrapUnique(
@@ -97,8 +95,9 @@ void LoadExtensionOnUIThread(base::WeakPtr<CefExtensionSystem> context,
CefRefPtr<CefExtensionHandler> handler) { CefRefPtr<CefExtensionHandler> handler) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(LoadExtensionOnUIThread, context, CEF_POST_TASK(CEF_UIT, base::BindOnce(LoadExtensionOnUIThread, context,
std::move(manifest), root_directory, base::Passed(std::move(manifest)),
internal, loader_context, handler)); root_directory, internal,
loader_context, handler));
return; return;
} }
@@ -185,78 +184,48 @@ void CefExtensionSystem::Init() {
content::NotificationService::NoDetails()); content::NotificationService::NoDetails());
// Add the internal PDF extension. PDF loading works as follows: // Add the internal PDF extension. PDF loading works as follows:
// 1. The PDF PPAPI plugin is registered in libcef/common/content_client.cc // 1. PDF PPAPI plugin is registered to handle kPDFPluginOutOfProcessMimeType
// ComputeBuiltInPlugins to handle the kPDFPluginOutOfProcessMimeType. // in libcef/common/content_client.cc ComputeBuiltInPlugins.
// 2. The PDF extension is registered by the below call to AddExtension and // 2. PDF extension is registered and associated with the "application/pdf"
// associated with the "application/pdf" mime type. // mime type by the below call to AddExtension.
// 3. Web content running in the owner CefBrowser requests to load a PDF file // 3. A page requests a resource with the "application/pdf" mime type. For
// resource with the "application/pdf" mime type. This can be via a frame // example, by loading a PDF file.
// (main frame/iframe) or object/embed tag.
// 4. PluginResponseInterceptorURLLoaderThrottle intercepts the PDF resource // 4. PluginResponseInterceptorURLLoaderThrottle intercepts the PDF resource
// load in the browser process and registers the PDF resource as a stream // load in the browser process, generates a
// via MimeHandlerStreamManager::AddStream. // unique View ID that is associated with the resource request for later
// 5. PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse triggers // retrieval via MimeHandlerStreamManager and the
// creation of a MimeHandlerViewEmbedder in the browser process via // chrome.mimeHandlerPrivate JS API (extensions/common/api/
// MimeHandlerViewAttachHelper::OverrideBodyForInterceptedResponse. // mime_handler_private.idl), and returns the unique View ID via the
// 6. MimeHandlerViewEmbedder::ReadyToCommitNavigation is called and sends a // |payload| argument.
// Mojo message to MimeHandlerViewContainerManager::SetInternalId in the // 5. The unique View ID arrives in the renderer process via
// owner renderer process. // ResourceLoader::DidReceiveData and triggers creation of a new Document.
// 7. The MimeHandlerViewContainerManager is created in the owner renderer // DOMImplementation::createDocument indirectly calls
// process via MimeHandlerViewContainerManager::BindReceiver and the // RendererBlinkPlatformImpl::getPluginList to retrieve the list of
// SetInternalId call arrives. // supported plugins from the browser process. If a plugin supports the
// 8. HTMLPlugInElement::RequestObject is called in the owner renderer process // "application/pdf" mime type then a PluginDocument is created and
// to handle the PDF file frame/object/embed tag. This results in calls to // CefContentRendererClient::OverrideCreatePlugin is called. This then
// ContentBrowserClient::GetPluginMimeTypesWithExternalHandlers (browser // indirectly calls CefContentRendererClient::CreateBrowserPluginDelegate
// process) and ContentRendererClient::IsPluginHandledExternally (owner // to create a MimeHandlerViewContainer.
// renderer process), and determines that the plugin should be handled // 6. A MimeHandlerViewGuest and CefMimeHandlerViewGuestDelegate is created in
// externally (handled_externally=true). // the browser process.
// 9. MimeHandlerViewContainerManager::IsManagedByContainerManager sends a // 7. MimeHandlerViewGuest navigates to the PDF extension URL.
// Mojo message to MimeHandlerViewEmbedder::ReadyToCreateMimeHandlerView // 8. Access to PDF extension resources is checked by
// in the browser process. // CefExtensionsBrowserClient::AllowCrossRendererResourceLoad.
// 10.MimeHandlerViewEmbedder::RenderFrameCreated triggers creation of a // 9. PDF extension resources are provided from bundle via
// MimeHandlerViewGuest and CefMimeHandlerViewGuestDelegate in the browser // CefExtensionsBrowserClient::LoadResourceFromResourceBundle,
// process. // CefContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories
// 11.MimeHandlerViewGuest::CreateWebContents creates a new guest WebContents // and CefComponentExtensionResourceManager.
// (is_guest_view=true) to host the PDF extension and the PDF resource // 10.The PDF extension (chrome/browser/resources/pdf/browser_api.js) calls
// stream is retrieved via MimeHandlerStreamManager::ReleaseStream. // chrome.mimeHandlerPrivate.getStreamInfo to retrieve the PDF resource
// 12.MimeHandlerViewGuest::DidAttachToEmbedder calls // stream. This API is implemented using Mojo as described in
// CefMimeHandlerViewGuestDelegate::OnGuestAttached to associate the guest
// WebContents routing IDs with the owner CefBrowser. MimeHandlerViewGuest
// then loads the extension URL (index.html) in the guest WebContents.
// 13.Creation of the RenderFrame in the guest renderer process triggers a
// sync IPC call from CefContentRendererClient::MaybeCreateBrowser to
// CefBrowserInfoManager::GetBrowserInfo in the browser process to retrieve
// the CefBrowser information, which will be immediately available due to
// step 12.
// 14.The PDF extension begins to load. Extension resource requests are
// handled via ExtensionURLLoaderFactory::CreateLoaderAndStart in the
// browser process. Access to PDF extension resources is checked by
// CefExtensionsBrowserClient::AllowCrossRendererResourceLoad and
// PDF extension resources are provided from bundle via
// CefExtensionsBrowserClient::LoadResourceFromResourceBundle
// and CefComponentExtensionResourceManager. Access to chrome://resources
// is granted via CefExtensionWebContentsObserver::RenderViewCreated.
// 15.The PDF extension calls chrome.mimeHandlerPrivate.getStreamInfo
// (chrome/browser/resources/pdf/browser_api.js) to retrieve the PDF
// resource stream. This API is implemented using Mojo as described in
// libcef/common/extensions/api/README.txt. // libcef/common/extensions/api/README.txt.
// 16.The PDF extension requests the PDF PPAPI plugin to handle // 11.The PDF extension requests a plugin to handle
// kPDFPluginOutOfProcessMimeType. Approval arrives in the guest renderer // kPDFPluginOutOfProcessMimeType which loads the PDF PPAPI plugin.
// process via ExtensionFrameHelper::OnExtensionResponse which calls // 12.Routing of print-related commands are handled by ChromePDFPrintClient
// NativeExtensionBindingsSystem::HandleResponse. This triggers creation of // and CefPrintRenderFrameHelperDelegate in the renderer process.
// an HTMLPlugInElement via native V8 bindings to host the PDF plugin. // 13.The PDF extension is granted access to chrome://resources via
// 17.HTMLPlugInElement::RequestObject is called in the guest renderer process // CefExtensionWebContentsObserver::RenderViewCreated in the browser
// and determines that the PDF PPAPI plugin should be handled internally // process.
// (handled_externally=false). A PluginDocument is created and
// CefContentRendererClient::OverrideCreatePlugin is called to create a
// WebPlugin.
// 18.The PDF extension and PDF plugin are now loaded. Print commands, if
// any, are handled in the guest renderer process by ChromePDFPrintClient
// and CefPrintRenderFrameHelperDelegate.
// 19.When navigating away from the PDF file or closing the owner CefBrowser
// the guest WebContents will be destroyed. This triggers a call to
// CefMimeHandlerViewGuestDelegate::OnGuestDetached which removes the
// routing ID association with the owner CefBrowser.
if (PdfExtensionEnabled()) { if (PdfExtensionEnabled()) {
LoadExtension(ParseManifest(pdf_extension_util::GetManifest()), LoadExtension(ParseManifest(pdf_extension_util::GetManifest()),
base::FilePath(FILE_PATH_LITERAL("pdf")), true /* internal */, base::FilePath(FILE_PATH_LITERAL("pdf")), true /* internal */,
@@ -447,7 +416,7 @@ AppSorting* CefExtensionSystem::app_sorting() {
// ExtensionSystemImpl::RegisterExtensionWithRequestContexts. // ExtensionSystemImpl::RegisterExtensionWithRequestContexts.
void CefExtensionSystem::RegisterExtensionWithRequestContexts( void CefExtensionSystem::RegisterExtensionWithRequestContexts(
const Extension* extension, const Extension* extension,
base::OnceClosure callback) { const base::Closure& callback) {
// TODO(extensions): The |incognito_enabled| value should be set based on // TODO(extensions): The |incognito_enabled| value should be set based on
// manifest settings. // manifest settings.
base::PostTaskAndReply( base::PostTaskAndReply(
@@ -456,7 +425,7 @@ void CefExtensionSystem::RegisterExtensionWithRequestContexts(
base::RetainedRef(extension), base::Time::Now(), base::RetainedRef(extension), base::Time::Now(),
true, // incognito_enabled true, // incognito_enabled
false), // notifications_disabled false), // notifications_disabled
std::move(callback)); callback);
} }
// Implementation based on // Implementation based on

View File

@@ -102,7 +102,7 @@ class CefExtensionSystem : public ExtensionSystem {
AppSorting* app_sorting() override; AppSorting* app_sorting() override;
void RegisterExtensionWithRequestContexts( void RegisterExtensionWithRequestContexts(
const Extension* extension, const Extension* extension,
base::OnceClosure callback) override; const base::Closure& callback) override;
void UnregisterExtensionWithRequestContexts( void UnregisterExtensionWithRequestContexts(
const std::string& extension_id, const std::string& extension_id,
const UnloadedExtensionReason reason) override; const UnloadedExtensionReason reason) override;

View File

@@ -12,7 +12,7 @@
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/browser/notification_types.h" #include "extensions/browser/notification_types.h"
#include "extensions/browser/runtime_data.h" #include "extensions/browser/runtime_data.h"
#include "third_party/blink/public/common/input/web_gesture_event.h" #include "third_party/blink/public/platform/web_gesture_event.h"
using content::NativeWebKeyboardEvent; using content::NativeWebKeyboardEvent;
using content::OpenURLParams; using content::OpenURLParams;

View File

@@ -27,7 +27,7 @@ AppViewGuestDelegate* CefExtensionsAPIClient::CreateAppViewGuestDelegate()
const { const {
// TODO(extensions): Implement to support Apps. // TODO(extensions): Implement to support Apps.
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
std::unique_ptr<guest_view::GuestViewManagerDelegate> std::unique_ptr<guest_view::GuestViewManagerDelegate>

View File

@@ -24,16 +24,14 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "extensions/browser/api/extensions_api_client.h" #include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/mime_handler_private/mime_handler_private.h"
#include "extensions/browser/api/runtime/runtime_api_delegate.h" #include "extensions/browser/api/runtime/runtime_api_delegate.h"
#include "extensions/browser/app_sorting.h" #include "extensions/browser/app_sorting.h"
#include "extensions/browser/core_extensions_browser_api_provider.h" #include "extensions/browser/core_extensions_browser_api_provider.h"
#include "extensions/browser/event_router.h" #include "extensions/browser/event_router.h"
#include "extensions/browser/extension_host_delegate.h" #include "extensions/browser/extension_host_delegate.h"
#include "extensions/browser/extensions_browser_interface_binders.h" #include "extensions/browser/mojo/interface_registration.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h" #include "extensions/browser/serial_extension_host_queue.h"
#include "extensions/browser/url_request_util.h" #include "extensions/browser/url_request_util.h"
#include "extensions/common/api/mime_handler.mojom.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
using content::BrowserContext; using content::BrowserContext;
@@ -41,41 +39,6 @@ using content::BrowserThread;
namespace extensions { namespace extensions {
namespace {
void BindMimeHandlerService(
content::RenderFrameHost* frame_host,
mojo::PendingReceiver<extensions::mime_handler::MimeHandlerService>
receiver) {
auto* web_contents = content::WebContents::FromRenderFrameHost(frame_host);
if (!web_contents)
return;
auto* guest_view =
extensions::MimeHandlerViewGuest::FromWebContents(web_contents);
if (!guest_view)
return;
extensions::MimeHandlerServiceImpl::Create(guest_view->GetStreamWeakPtr(),
std::move(receiver));
}
void BindBeforeUnloadControl(
content::RenderFrameHost* frame_host,
mojo::PendingReceiver<extensions::mime_handler::BeforeUnloadControl>
receiver) {
auto* web_contents = content::WebContents::FromRenderFrameHost(frame_host);
if (!web_contents)
return;
auto* guest_view =
extensions::MimeHandlerViewGuest::FromWebContents(web_contents);
if (!guest_view)
return;
guest_view->FuseBeforeUnloadControl(std::move(receiver));
}
} // namespace
CefExtensionsBrowserClient::CefExtensionsBrowserClient() CefExtensionsBrowserClient::CefExtensionsBrowserClient()
: api_client_(new CefExtensionsAPIClient), : api_client_(new CefExtensionsAPIClient),
resource_manager_(new CefComponentExtensionResourceManager) { resource_manager_(new CefComponentExtensionResourceManager) {
@@ -102,7 +65,7 @@ bool CefExtensionsBrowserClient::AreExtensionsDisabled(
} }
bool CefExtensionsBrowserClient::IsValidContext(BrowserContext* context) { bool CefExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
return GetOriginalContext(context) != nullptr; return GetOriginalContext(context) != NULL;
} }
bool CefExtensionsBrowserClient::IsSameContext(BrowserContext* first, bool CefExtensionsBrowserClient::IsSameContext(BrowserContext* first,
@@ -120,7 +83,7 @@ bool CefExtensionsBrowserClient::HasOffTheRecordContext(
BrowserContext* CefExtensionsBrowserClient::GetOffTheRecordContext( BrowserContext* CefExtensionsBrowserClient::GetOffTheRecordContext(
BrowserContext* context) { BrowserContext* context) {
return nullptr; return NULL;
} }
BrowserContext* CefExtensionsBrowserClient::GetOriginalContext( BrowserContext* CefExtensionsBrowserClient::GetOriginalContext(
@@ -154,11 +117,11 @@ base::FilePath CefExtensionsBrowserClient::GetBundleResourcePath(
void CefExtensionsBrowserClient::LoadResourceFromResourceBundle( void CefExtensionsBrowserClient::LoadResourceFromResourceBundle(
const network::ResourceRequest& request, const network::ResourceRequest& request,
mojo::PendingReceiver<network::mojom::URLLoader> loader, network::mojom::URLLoaderRequest loader,
const base::FilePath& resource_relative_path, const base::FilePath& resource_relative_path,
const int resource_id, const int resource_id,
const std::string& content_security_policy, const std::string& content_security_policy,
mojo::PendingRemote<network::mojom::URLLoaderClient> client, network::mojom::URLLoaderClientPtr client,
bool send_cors_header) { bool send_cors_header) {
chrome_url_request_util::LoadResourceFromResourceBundle( chrome_url_request_util::LoadResourceFromResourceBundle(
request, std::move(loader), resource_relative_path, resource_id, request, std::move(loader), resource_relative_path, resource_id,
@@ -196,7 +159,7 @@ void CefExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
ProcessManagerDelegate* CefExtensionsBrowserClient::GetProcessManagerDelegate() ProcessManagerDelegate* CefExtensionsBrowserClient::GetProcessManagerDelegate()
const { const {
return nullptr; return NULL;
} }
std::unique_ptr<ExtensionHostDelegate> std::unique_ptr<ExtensionHostDelegate>
@@ -294,16 +257,12 @@ CefExtensionsBrowserClient::GetExtensionSystemFactory() {
return CefExtensionSystemFactory::GetInstance(); return CefExtensionSystemFactory::GetInstance();
} }
void CefExtensionsBrowserClient::RegisterBrowserInterfaceBindersForFrame( void CefExtensionsBrowserClient::RegisterExtensionInterfaces(
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map, service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>*
registry,
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
const Extension* extension) const { const Extension* extension) const {
PopulateExtensionFrameBinders(map, render_frame_host, extension); RegisterInterfacesForExtension(registry, render_frame_host, extension);
map->Add<extensions::mime_handler::MimeHandlerService>(
base::BindRepeating(&BindMimeHandlerService));
map->Add<extensions::mime_handler::BeforeUnloadControl>(
base::BindRepeating(&BindBeforeUnloadControl));
} }
std::unique_ptr<RuntimeAPIDelegate> std::unique_ptr<RuntimeAPIDelegate>
@@ -332,7 +291,7 @@ void CefExtensionsBrowserClient::BroadcastEventToRenderers(
ExtensionCache* CefExtensionsBrowserClient::GetExtensionCache() { ExtensionCache* CefExtensionsBrowserClient::GetExtensionCache() {
// Only used by Chrome via ExtensionService. // Only used by Chrome via ExtensionService.
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
bool CefExtensionsBrowserClient::IsBackgroundUpdateAllowed() { bool CefExtensionsBrowserClient::IsBackgroundUpdateAllowed() {
@@ -352,7 +311,7 @@ CefExtensionsBrowserClient::GetExtensionWebContentsObserver(
KioskDelegate* CefExtensionsBrowserClient::GetKioskDelegate() { KioskDelegate* CefExtensionsBrowserClient::GetKioskDelegate() {
NOTREACHED(); NOTREACHED();
return nullptr; return NULL;
} }
bool CefExtensionsBrowserClient::IsLockScreenContext( bool CefExtensionsBrowserClient::IsLockScreenContext(
@@ -364,4 +323,10 @@ std::string CefExtensionsBrowserClient::GetApplicationLocale() {
return g_browser_process->GetApplicationLocale(); return g_browser_process->GetApplicationLocale();
} }
ExtensionHostQueue* CefExtensionsBrowserClient::GetExtensionHostQueue() {
if (!extension_host_queue_)
extension_host_queue_.reset(new SerialExtensionHostQueue);
return extension_host_queue_.get();
}
} // namespace extensions } // namespace extensions

View File

@@ -11,6 +11,7 @@
namespace extensions { namespace extensions {
class ExtensionHostQueue;
class ExtensionsAPIClient; class ExtensionsAPIClient;
// An ExtensionsBrowserClient that supports a single content::BrowserContent // An ExtensionsBrowserClient that supports a single content::BrowserContent
@@ -48,11 +49,11 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
int* resource_id) const override; int* resource_id) const override;
void LoadResourceFromResourceBundle( void LoadResourceFromResourceBundle(
const network::ResourceRequest& request, const network::ResourceRequest& request,
mojo::PendingReceiver<network::mojom::URLLoader> loader, network::mojom::URLLoaderRequest loader,
const base::FilePath& resource_relative_path, const base::FilePath& resource_relative_path,
const int resource_id, const int resource_id,
const std::string& content_security_policy, const std::string& content_security_policy,
mojo::PendingRemote<network::mojom::URLLoaderClient> client, network::mojom::URLLoaderClientPtr client,
bool send_cors_header) override; bool send_cors_header) override;
bool AllowCrossRendererResourceLoad(const GURL& url, bool AllowCrossRendererResourceLoad(const GURL& url,
content::ResourceType resource_type, content::ResourceType resource_type,
@@ -81,11 +82,10 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
bool IsAppModeForcedForApp(const ExtensionId& extension_id) override; bool IsAppModeForcedForApp(const ExtensionId& extension_id) override;
bool IsLoggedInAsPublicAccount() override; bool IsLoggedInAsPublicAccount() override;
ExtensionSystemProvider* GetExtensionSystemFactory() override; ExtensionSystemProvider* GetExtensionSystemFactory() override;
void RegisterBrowserInterfaceBindersForFrame( void RegisterExtensionInterfaces(service_manager::BinderRegistryWithArgs<
service_manager::BinderMapWithContext<content::RenderFrameHost*>* content::RenderFrameHost*>* registry,
binder_map, content::RenderFrameHost* render_frame_host,
content::RenderFrameHost* render_frame_host, const Extension* extension) const override;
const Extension* extension) const override;
std::unique_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate( std::unique_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
content::BrowserContext* context) const override; content::BrowserContext* context) const override;
const ComponentExtensionResourceManager* const ComponentExtensionResourceManager*
@@ -104,6 +104,8 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
bool IsLockScreenContext(content::BrowserContext* context) override; bool IsLockScreenContext(content::BrowserContext* context) override;
std::string GetApplicationLocale() override; std::string GetApplicationLocale() override;
ExtensionHostQueue* GetExtensionHostQueue();
private: private:
// Support for extension APIs. // Support for extension APIs.
std::unique_ptr<ExtensionsAPIClient> api_client_; std::unique_ptr<ExtensionsAPIClient> api_client_;
@@ -111,6 +113,9 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
// Resource manager used to supply resources from pak files. // Resource manager used to supply resources from pak files.
std::unique_ptr<ComponentExtensionResourceManager> resource_manager_; std::unique_ptr<ComponentExtensionResourceManager> resource_manager_;
// Used to create deferred RenderViews for extensions.
std::unique_ptr<ExtensionHostQueue> extension_host_queue_;
DISALLOW_COPY_AND_ASSIGN(CefExtensionsBrowserClient); DISALLOW_COPY_AND_ASSIGN(CefExtensionsBrowserClient);
}; };

View File

@@ -17,9 +17,22 @@
namespace extensions { namespace extensions {
namespace {
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowser(
extensions::MimeHandlerViewGuest* guest) {
content::WebContents* owner_web_contents = guest->owner_web_contents();
CefRefPtr<CefBrowserHostImpl> owner_browser =
CefBrowserHostImpl::GetBrowserForContents(owner_web_contents);
DCHECK(owner_browser);
return owner_browser;
}
} // namespace
CefMimeHandlerViewGuestDelegate::CefMimeHandlerViewGuestDelegate( CefMimeHandlerViewGuestDelegate::CefMimeHandlerViewGuestDelegate(
MimeHandlerViewGuest* guest) MimeHandlerViewGuest* guest)
: guest_(guest), owner_web_contents_(guest_->owner_web_contents()) {} : guest_(guest) {}
CefMimeHandlerViewGuestDelegate::~CefMimeHandlerViewGuestDelegate() {} CefMimeHandlerViewGuestDelegate::~CefMimeHandlerViewGuestDelegate() {}
@@ -27,10 +40,7 @@ void CefMimeHandlerViewGuestDelegate::OverrideWebContentsCreateParams(
content::WebContents::CreateParams* params) { content::WebContents::CreateParams* params) {
DCHECK(params->guest_delegate); DCHECK(params->guest_delegate);
CefRefPtr<CefBrowserHostImpl> owner_browser = CefRefPtr<CefBrowserHostImpl> owner_browser = GetOwnerBrowser(guest_);
CefBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
DCHECK(owner_browser);
if (owner_browser->IsWindowless()) { if (owner_browser->IsWindowless()) {
CefWebContentsViewOSR* view_osr = new CefWebContentsViewOSR( CefWebContentsViewOSR* view_osr = new CefWebContentsViewOSR(
owner_browser->GetBackgroundColor(), false, false); owner_browser->GetBackgroundColor(), false, false);
@@ -39,29 +49,24 @@ void CefMimeHandlerViewGuestDelegate::OverrideWebContentsCreateParams(
} }
} }
void CefMimeHandlerViewGuestDelegate::OnGuestAttached() { void CefMimeHandlerViewGuestDelegate::OnGuestAttached(
content::WebContentsView* parent_view) {
content::WebContents* web_contents = guest_->web_contents(); content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents); DCHECK(web_contents);
CefRefPtr<CefBrowserHostImpl> owner_browser =
CefBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
DCHECK(owner_browser);
// Associate guest state information with the owner browser. // Associate guest state information with the owner browser.
owner_browser->browser_info()->MaybeCreateFrame(web_contents->GetMainFrame(), GetOwnerBrowser(guest_)->browser_info()->MaybeCreateFrame(
true /* is_guest_view */); web_contents->GetMainFrame(), true /* is_guest_view */);
} }
void CefMimeHandlerViewGuestDelegate::OnGuestDetached() { void CefMimeHandlerViewGuestDelegate::OnGuestDetached(
content::WebContentsView* parent_view) {
content::WebContents* web_contents = guest_->web_contents(); content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents); DCHECK(web_contents);
CefRefPtr<CefBrowserHostImpl> owner_browser =
CefBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
DCHECK(owner_browser);
// Disassociate guest state information with the owner browser. // Disassociate guest state information with the owner browser.
owner_browser->browser_info()->RemoveFrame(web_contents->GetMainFrame()); GetOwnerBrowser(guest_)->browser_info()->RemoveFrame(
web_contents->GetMainFrame());
} }
bool CefMimeHandlerViewGuestDelegate::HandleContextMenu( bool CefMimeHandlerViewGuestDelegate::HandleContextMenu(
@@ -78,11 +83,7 @@ bool CefMimeHandlerViewGuestDelegate::HandleContextMenu(
new_params.x += guest_coordinates.x(); new_params.x += guest_coordinates.x();
new_params.y += guest_coordinates.y(); new_params.y += guest_coordinates.y();
CefRefPtr<CefBrowserHostImpl> owner_browser = return GetOwnerBrowser(guest_)->HandleContextMenu(web_contents, new_params);
CefBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
DCHECK(owner_browser);
return owner_browser->HandleContextMenu(web_contents, new_params);
} }
} // namespace extensions } // namespace extensions

View File

@@ -23,14 +23,13 @@ class CefMimeHandlerViewGuestDelegate : public MimeHandlerViewGuestDelegate {
// MimeHandlerViewGuestDelegate methods. // MimeHandlerViewGuestDelegate methods.
void OverrideWebContentsCreateParams( void OverrideWebContentsCreateParams(
content::WebContents::CreateParams* params) override; content::WebContents::CreateParams* params) override;
void OnGuestAttached() override; void OnGuestAttached(content::WebContentsView* parent_view) override;
void OnGuestDetached() override; void OnGuestDetached(content::WebContentsView* parent_view) override;
bool HandleContextMenu(content::WebContents* web_contents, bool HandleContextMenu(content::WebContents* web_contents,
const content::ContextMenuParams& params) override; const content::ContextMenuParams& params) override;
private: private:
MimeHandlerViewGuest* guest_; // Owns us. MimeHandlerViewGuest* guest_; // Owns us.
content::WebContents* owner_web_contents_;
DISALLOW_COPY_AND_ASSIGN(CefMimeHandlerViewGuestDelegate); DISALLOW_COPY_AND_ASSIGN(CefMimeHandlerViewGuestDelegate);
}; };

View File

@@ -4,8 +4,6 @@
#include "libcef/browser/extensions/pdf_web_contents_helper_client.h" #include "libcef/browser/extensions/pdf_web_contents_helper_client.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
namespace extensions { namespace extensions {
CefPDFWebContentsHelperClient::CefPDFWebContentsHelperClient() {} CefPDFWebContentsHelperClient::CefPDFWebContentsHelperClient() {}
@@ -23,11 +21,6 @@ void CefPDFWebContentsHelperClient::OnSaveURL(content::WebContents* contents) {}
void CefPDFWebContentsHelperClient::SetPluginCanSave( void CefPDFWebContentsHelperClient::SetPluginCanSave(
content::WebContents* contents, content::WebContents* contents,
bool can_save) { bool can_save) {}
auto* guest_view =
extensions::MimeHandlerViewGuest::FromWebContents(contents);
if (guest_view)
guest_view->SetPluginCanSave(can_save);
}
} // namespace extensions } // namespace extensions

View File

@@ -61,7 +61,7 @@ ValueStore::ReadResult CefValueStore::Get(
auto settings = std::make_unique<base::DictionaryValue>(); auto settings = std::make_unique<base::DictionaryValue>();
for (std::vector<std::string>::const_iterator it = keys.begin(); for (std::vector<std::string>::const_iterator it = keys.begin();
it != keys.end(); ++it) { it != keys.end(); ++it) {
base::Value* value = nullptr; base::Value* value = NULL;
if (storage_.GetWithoutPathExpansion(*it, &value)) { if (storage_.GetWithoutPathExpansion(*it, &value)) {
settings->SetWithoutPathExpansion(*it, value->CreateDeepCopy()); settings->SetWithoutPathExpansion(*it, value->CreateDeepCopy());
} }
@@ -94,7 +94,7 @@ ValueStore::WriteResult CefValueStore::Set(
std::unique_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList()); std::unique_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
for (base::DictionaryValue::Iterator it(settings); !it.IsAtEnd(); for (base::DictionaryValue::Iterator it(settings); !it.IsAtEnd();
it.Advance()) { it.Advance()) {
base::Value* old_value = nullptr; base::Value* old_value = NULL;
if (!storage_.GetWithoutPathExpansion(it.key(), &old_value) || if (!storage_.GetWithoutPathExpansion(it.key(), &old_value) ||
!old_value->Equals(&it.value())) { !old_value->Equals(&it.value())) {
changes->push_back(ValueStoreChange( changes->push_back(ValueStoreChange(

View File

@@ -20,20 +20,17 @@ namespace {
class CefFileDialogCallbackImpl : public CefFileDialogCallback { class CefFileDialogCallbackImpl : public CefFileDialogCallback {
public: public:
using CallbackType = CefFileDialogRunner::RunFileChooserCallback; explicit CefFileDialogCallbackImpl(
const CefFileDialogRunner::RunFileChooserCallback& callback)
explicit CefFileDialogCallbackImpl(CallbackType callback) : callback_(callback) {}
: callback_(std::move(callback)) {}
~CefFileDialogCallbackImpl() override { ~CefFileDialogCallbackImpl() override {
if (!callback_.is_null()) { if (!callback_.is_null()) {
// The callback is still pending. Cancel it now. // The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
CancelNow(std::move(callback_)); CancelNow(callback_);
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT, base::Bind(&CefFileDialogCallbackImpl::CancelNow,
base::BindOnce(&CefFileDialogCallbackImpl::CancelNow, callback_));
std::move(callback_)));
} }
} }
} }
@@ -48,36 +45,41 @@ class CefFileDialogCallbackImpl : public CefFileDialogCallback {
for (; it != file_paths.end(); ++it) for (; it != file_paths.end(); ++it)
vec.push_back(base::FilePath(*it)); vec.push_back(base::FilePath(*it));
} }
std::move(callback_).Run(selected_accept_filter, vec); callback_.Run(selected_accept_filter, vec);
callback_.Reset();
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefFileDialogCallbackImpl::Continue, this, base::Bind(&CefFileDialogCallbackImpl::Continue, this,
selected_accept_filter, file_paths)); selected_accept_filter, file_paths));
} }
} }
void Cancel() override { void Cancel() override {
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
if (!callback_.is_null()) { if (!callback_.is_null()) {
CancelNow(std::move(callback_)); CancelNow(callback_);
callback_.Reset();
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefFileDialogCallbackImpl::Cancel, this)); base::Bind(&CefFileDialogCallbackImpl::Cancel, this));
} }
} }
CallbackType Disconnect() WARN_UNUSED_RESULT { return std::move(callback_); } bool IsConnected() { return !callback_.is_null(); }
void Disconnect() { callback_.Reset(); }
private: private:
static void CancelNow(CallbackType callback) { static void CancelNow(
const CefFileDialogRunner::RunFileChooserCallback& callback) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
std::vector<base::FilePath> file_paths; std::vector<base::FilePath> file_paths;
std::move(callback).Run(0, file_paths); callback.Run(0, file_paths);
} }
CallbackType callback_; CefFileDialogRunner::RunFileChooserCallback callback_;
IMPLEMENT_REFCOUNTING(CefFileDialogCallbackImpl); IMPLEMENT_REFCOUNTING(CefFileDialogCallbackImpl);
}; };
@@ -97,16 +99,16 @@ class UploadFolderHelper
: public net::DirectoryLister::DirectoryListerDelegate { : public net::DirectoryLister::DirectoryListerDelegate {
public: public:
explicit UploadFolderHelper( explicit UploadFolderHelper(
CefFileDialogRunner::RunFileChooserCallback callback) const CefFileDialogRunner::RunFileChooserCallback& callback)
: callback_(std::move(callback)) {} : callback_(callback) {}
~UploadFolderHelper() override { ~UploadFolderHelper() override {
if (!callback_.is_null()) { if (!callback_.is_null()) {
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
CancelNow(std::move(callback_)); CancelNow(callback_);
} else { } else {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&UploadFolderHelper::CancelNow, CEF_POST_TASK(CEF_UIT,
std::move(callback_))); base::Bind(&UploadFolderHelper::CancelNow, callback_));
} }
} }
} }
@@ -121,15 +123,17 @@ class UploadFolderHelper
void OnListDone(int error) override { void OnListDone(int error) override {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (!callback_.is_null()) { if (!callback_.is_null()) {
std::move(callback_).Run(0, select_files_); callback_.Run(0, select_files_);
callback_.Reset();
} }
} }
private: private:
static void CancelNow(CefFileDialogRunner::RunFileChooserCallback callback) { static void CancelNow(
const CefFileDialogRunner::RunFileChooserCallback& callback) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
std::vector<base::FilePath> file_paths; std::vector<base::FilePath> file_paths;
std::move(callback).Run(0, file_paths); callback.Run(0, file_paths);
} }
CefFileDialogRunner::RunFileChooserCallback callback_; CefFileDialogRunner::RunFileChooserCallback callback_;
@@ -152,7 +156,7 @@ CefFileDialogManager::~CefFileDialogManager() {}
void CefFileDialogManager::Destroy() { void CefFileDialogManager::Destroy() {
DCHECK(!file_chooser_pending_); DCHECK(!file_chooser_pending_);
runner_.reset(nullptr); runner_.reset(NULL);
} }
void CefFileDialogManager::RunFileDialog( void CefFileDialogManager::RunFileDialog(
@@ -211,35 +215,37 @@ void CefFileDialogManager::RunFileChooser(
CefFileDialogRunner::RunFileChooserCallback callback; CefFileDialogRunner::RunFileChooserCallback callback;
if (params.mode == blink::mojom::FileChooserParams::Mode::kUploadFolder) { if (params.mode == blink::mojom::FileChooserParams::Mode::kUploadFolder) {
callback = base::BindOnce( callback = base::Bind(
&CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback, &CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode, std::move(listener)); weak_ptr_factory_.GetWeakPtr(), params.mode,
base::Passed(std::move(listener)));
} else { } else {
callback = base::BindOnce( callback =
&CefFileDialogManager::OnRunFileChooserDelegateCallback, base::Bind(&CefFileDialogManager::OnRunFileChooserDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode, std::move(listener)); weak_ptr_factory_.GetWeakPtr(), params.mode,
base::Passed(std::move(listener)));
} }
RunFileChooserInternal(cef_params, std::move(callback)); RunFileChooserInternal(cef_params, callback);
} }
void CefFileDialogManager::RunFileChooser( void CefFileDialogManager::RunFileChooser(
const CefFileDialogRunner::FileChooserParams& params, const CefFileDialogRunner::FileChooserParams& params,
CefFileDialogRunner::RunFileChooserCallback callback) { const CefFileDialogRunner::RunFileChooserCallback& callback) {
CefFileDialogRunner::RunFileChooserCallback host_callback = const CefFileDialogRunner::RunFileChooserCallback& host_callback =
base::BindOnce(&CefFileDialogManager::OnRunFileChooserCallback, base::Bind(&CefFileDialogManager::OnRunFileChooserCallback,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)); weak_ptr_factory_.GetWeakPtr(), callback);
RunFileChooserInternal(params, std::move(host_callback)); RunFileChooserInternal(params, host_callback);
} }
void CefFileDialogManager::RunFileChooserInternal( void CefFileDialogManager::RunFileChooserInternal(
const CefFileDialogRunner::FileChooserParams& params, const CefFileDialogRunner::FileChooserParams& params,
CefFileDialogRunner::RunFileChooserCallback callback) { const CefFileDialogRunner::RunFileChooserCallback& callback) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (file_chooser_pending_) { if (file_chooser_pending_) {
// Dismiss the new dialog immediately. // Dismiss the new dialog immediately.
std::move(callback).Run(0, std::vector<base::FilePath>()); callback.Run(0, std::vector<base::FilePath>());
return; return;
} }
@@ -283,30 +289,35 @@ void CefFileDialogManager::RunFileChooserInternal(
accept_filters.push_back(*it); accept_filters.push_back(*it);
CefRefPtr<CefFileDialogCallbackImpl> callbackImpl( CefRefPtr<CefFileDialogCallbackImpl> callbackImpl(
new CefFileDialogCallbackImpl(std::move(callback))); new CefFileDialogCallbackImpl(callback));
handled = handler->OnFileDialog( handled = handler->OnFileDialog(
browser_, static_cast<cef_file_dialog_mode_t>(mode), params.title, browser_, static_cast<cef_file_dialog_mode_t>(mode), params.title,
params.default_file_name.value(), accept_filters, params.default_file_name.value(), accept_filters,
params.selected_accept_filter, callbackImpl.get()); params.selected_accept_filter, callbackImpl.get());
if (!handled) { if (!handled) {
// May return nullptr if the client has already executed the callback. if (callbackImpl->IsConnected()) {
callback = callbackImpl->Disconnect(); callbackImpl->Disconnect();
} else {
// User executed the callback even though they returned false.
NOTREACHED();
handled = true;
}
} }
} }
} }
if (!handled && !callback.is_null()) { if (!handled) {
if (runner_.get()) { if (runner_.get()) {
runner_->Run(browser_, params, std::move(callback)); runner_->Run(browser_, params, callback);
} else { } else {
LOG(WARNING) << "No file dialog runner available for this platform"; LOG(WARNING) << "No file dialog runner available for this platform";
std::move(callback).Run(0, std::vector<base::FilePath>()); callback.Run(0, std::vector<base::FilePath>());
} }
} }
} }
void CefFileDialogManager::OnRunFileChooserCallback( void CefFileDialogManager::OnRunFileChooserCallback(
CefFileDialogRunner::RunFileChooserCallback callback, const CefFileDialogRunner::RunFileChooserCallback& callback,
int selected_accept_filter, int selected_accept_filter,
const std::vector<base::FilePath>& file_paths) { const std::vector<base::FilePath>& file_paths) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
@@ -314,8 +325,8 @@ void CefFileDialogManager::OnRunFileChooserCallback(
Cleanup(); Cleanup();
// Execute the callback asynchronously. // Execute the callback asynchronously.
CEF_POST_TASK(CEF_UIT, base::BindOnce(std::move(callback), CEF_POST_TASK(CEF_UIT,
selected_accept_filter, file_paths)); base::Bind(callback, selected_accept_filter, file_paths));
} }
void CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback( void CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback(
@@ -333,9 +344,10 @@ void CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback(
} else { } else {
lister_.reset(new net::DirectoryLister( lister_.reset(new net::DirectoryLister(
file_paths[0], net::DirectoryLister::NO_SORT_RECURSIVE, file_paths[0], net::DirectoryLister::NO_SORT_RECURSIVE,
new UploadFolderHelper(base::BindOnce( new UploadFolderHelper(
&CefFileDialogManager::OnRunFileChooserDelegateCallback, base::Bind(&CefFileDialogManager::OnRunFileChooserDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), mode, std::move(listener))))); weak_ptr_factory_.GetWeakPtr(), mode,
base::Passed(std::move(listener))))));
lister_->Start(); lister_->Start();
} }
} }

View File

@@ -52,18 +52,19 @@ class CefFileDialogManager {
// Run the file chooser dialog specified by |params|. Only a single dialog may // Run the file chooser dialog specified by |params|. Only a single dialog may
// be pending at any given time. |callback| will be executed asynchronously // be pending at any given time. |callback| will be executed asynchronously
// after the dialog is dismissed or if another dialog is already pending. // after the dialog is dismissed or if another dialog is already pending.
void RunFileChooser(const CefFileDialogRunner::FileChooserParams& params, void RunFileChooser(
CefFileDialogRunner::RunFileChooserCallback callback); const CefFileDialogRunner::FileChooserParams& params,
const CefFileDialogRunner::RunFileChooserCallback& callback);
private: private:
void RunFileChooserInternal( void RunFileChooserInternal(
const CefFileDialogRunner::FileChooserParams& params, const CefFileDialogRunner::FileChooserParams& params,
CefFileDialogRunner::RunFileChooserCallback callback); const CefFileDialogRunner::RunFileChooserCallback& callback);
// Used with the RunFileChooser variant where the caller specifies a callback // Used with the RunFileChooser variant where the caller specifies a callback
// (no associated RenderFrameHost). // (no associated RenderFrameHost).
void OnRunFileChooserCallback( void OnRunFileChooserCallback(
CefFileDialogRunner::RunFileChooserCallback callback, const CefFileDialogRunner::RunFileChooserCallback& callback,
int selected_accept_filter, int selected_accept_filter,
const std::vector<base::FilePath>& file_paths); const std::vector<base::FilePath>& file_paths);

View File

@@ -30,7 +30,7 @@ class CefFileDialogRunner {
}; };
// The argument vector will be empty if the dialog was canceled. // The argument vector will be empty if the dialog was canceled.
typedef base::OnceCallback<void(int, const std::vector<base::FilePath>&)> typedef base::Callback<void(int, const std::vector<base::FilePath>&)>
RunFileChooserCallback; RunFileChooserCallback;
// Display the file chooser dialog. Execute |callback| on completion. // Display the file chooser dialog. Execute |callback| on completion.

View File

@@ -158,13 +158,13 @@ void CefFrameHostImpl::GetText(CefRefPtr<CefStringVisitor> visitor) {
} }
void CefFrameHostImpl::LoadRequest(CefRefPtr<CefRequest> request) { void CefFrameHostImpl::LoadRequest(CefRefPtr<CefRequest> request) {
CefNavigateParams params(GURL(), kPageTransitionExplicit); CefNavigateParams params(GURL(), ui::PAGE_TRANSITION_TYPED);
static_cast<CefRequestImpl*>(request.get())->Get(params); static_cast<CefRequestImpl*>(request.get())->Get(params);
Navigate(params); Navigate(params);
} }
void CefFrameHostImpl::LoadURL(const CefString& url) { void CefFrameHostImpl::LoadURL(const CefString& url) {
LoadURLWithExtras(url, content::Referrer(), kPageTransitionExplicit, LoadURLWithExtras(url, content::Referrer(), ui::PAGE_TRANSITION_TYPED,
std::string()); std::string());
} }
@@ -367,11 +367,6 @@ void CefFrameHostImpl::SendCommand(
if (frame_id < CefFrameHostImpl::kMainFrameId) if (frame_id < CefFrameHostImpl::kMainFrameId)
return; return;
if (!render_frame_host_ || !response_manager_) {
// detached frame has no response_manager_
return;
}
TRACE_EVENT2("cef", "CefFrameHostImpl::SendCommand", "frame_id", frame_id, TRACE_EVENT2("cef", "CefFrameHostImpl::SendCommand", "frame_id", frame_id,
"needsResponse", responseHandler.get() ? 1 : 0); "needsResponse", responseHandler.get() ? 1 : 0);
Cef_Request_Params params; Cef_Request_Params params;
@@ -412,11 +407,6 @@ void CefFrameHostImpl::SendCode(
if (frame_id < CefFrameHostImpl::kMainFrameId) if (frame_id < CefFrameHostImpl::kMainFrameId)
return; return;
if (!render_frame_host_ || !response_manager_) {
// detached frame has no response_manager_
return;
}
TRACE_EVENT2("cef", "CefFrameHostImpl::SendCommand", "frame_id", frame_id, TRACE_EVENT2("cef", "CefFrameHostImpl::SendCommand", "frame_id", frame_id,
"needsResponse", responseHandler.get() ? 1 : 0); "needsResponse", responseHandler.get() ? 1 : 0);
Cef_Request_Params params; Cef_Request_Params params;
@@ -474,6 +464,7 @@ bool CefFrameHostImpl::OnMessageReceived(const IPC::Message& message) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(CefFrameHostImpl, message) IPC_BEGIN_MESSAGE_MAP(CefFrameHostImpl, message)
IPC_MESSAGE_HANDLER(CefHostMsg_FrameAttached, OnAttached) IPC_MESSAGE_HANDLER(CefHostMsg_FrameAttached, OnAttached)
IPC_MESSAGE_HANDLER(CefHostMsg_FrameFocused, OnFocused)
IPC_MESSAGE_HANDLER(CefHostMsg_DidFinishLoad, OnDidFinishLoad) IPC_MESSAGE_HANDLER(CefHostMsg_DidFinishLoad, OnDidFinishLoad)
IPC_MESSAGE_HANDLER(CefHostMsg_UpdateDraggableRegions, IPC_MESSAGE_HANDLER(CefHostMsg_UpdateDraggableRegions,
OnUpdateDraggableRegions) OnUpdateDraggableRegions)
@@ -543,11 +534,6 @@ const int64_t CefFrameHostImpl::kFocusedFrameId = -2;
const int64_t CefFrameHostImpl::kUnspecifiedFrameId = -3; const int64_t CefFrameHostImpl::kUnspecifiedFrameId = -3;
const int64_t CefFrameHostImpl::kInvalidFrameId = -4; const int64_t CefFrameHostImpl::kInvalidFrameId = -4;
// This equates to (TT_EXPLICIT | TT_DIRECT_LOAD_FLAG).
const ui::PageTransition CefFrameHostImpl::kPageTransitionExplicit =
static_cast<ui::PageTransition>(ui::PAGE_TRANSITION_TYPED |
ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
int64 CefFrameHostImpl::GetFrameId() const { int64 CefFrameHostImpl::GetFrameId() const {
base::AutoLock lock_scope(state_lock_); base::AutoLock lock_scope(state_lock_);
return is_main_frame_ ? kMainFrameId : frame_id_; return is_main_frame_ ? kMainFrameId : frame_id_;
@@ -570,6 +556,16 @@ void CefFrameHostImpl::OnAttached() {
} }
} }
void CefFrameHostImpl::OnFocused() {
if (!IsFocused()) {
// Calls back to SetFocused(true) after updating state on the previously
// focused frame.
auto browser = GetBrowserHostImpl();
if (browser)
browser->OnFrameFocused(this);
}
}
void CefFrameHostImpl::OnDidFinishLoad(const GURL& validated_url, void CefFrameHostImpl::OnDidFinishLoad(const GURL& validated_url,
int http_status_code) { int http_status_code) {
auto browser = GetBrowserHostImpl(); auto browser = GetBrowserHostImpl();

View File

@@ -138,17 +138,13 @@ class CefFrameHostImpl : public CefFrame {
static const int64_t kUnspecifiedFrameId; static const int64_t kUnspecifiedFrameId;
static const int64_t kInvalidFrameId; static const int64_t kInvalidFrameId;
// PageTransition type for explicit navigations. This must pass the check in
// ContentBrowserClient::IsExplicitNavigation for debug URLs (HandleDebugURL)
// to work as expected.
static const ui::PageTransition kPageTransitionExplicit;
private: private:
int64 GetFrameId() const; int64 GetFrameId() const;
CefRefPtr<CefBrowserHostImpl> GetBrowserHostImpl() const; CefRefPtr<CefBrowserHostImpl> GetBrowserHostImpl() const;
// OnMessageReceived message handlers. // OnMessageReceived message handlers.
void OnAttached(); void OnAttached();
void OnFocused();
void OnDidFinishLoad(const GURL& validated_url, int http_status_code); void OnDidFinishLoad(const GURL& validated_url, int http_status_code);
void OnUpdateDraggableRegions( void OnUpdateDraggableRegions(
const std::vector<Cef_DraggableRegion_Params>& regions); const std::vector<Cef_DraggableRegion_Params>& regions);

View File

@@ -19,19 +19,17 @@ namespace {
class CefJSDialogCallbackImpl : public CefJSDialogCallback { class CefJSDialogCallbackImpl : public CefJSDialogCallback {
public: public:
using CallbackType = content::JavaScriptDialogManager::DialogClosedCallback; using Callback = content::JavaScriptDialogManager::DialogClosedCallback;
CefJSDialogCallbackImpl(CallbackType callback) CefJSDialogCallbackImpl(Callback callback) : callback_(std::move(callback)) {}
: callback_(std::move(callback)) {}
~CefJSDialogCallbackImpl() override { ~CefJSDialogCallbackImpl() override {
if (!callback_.is_null()) { if (!callback_.is_null()) {
// The callback is still pending. Cancel it now. // The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
CancelNow(std::move(callback_)); CancelNow(std::move(callback_));
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT, base::Bind(&CefJSDialogCallbackImpl::CancelNow,
base::BindOnce(&CefJSDialogCallbackImpl::CancelNow, base::Passed(std::move(callback_))));
std::move(callback_)));
} }
} }
} }
@@ -42,20 +40,20 @@ class CefJSDialogCallbackImpl : public CefJSDialogCallback {
std::move(callback_).Run(success, user_input); std::move(callback_).Run(success, user_input);
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefJSDialogCallbackImpl::Continue, CEF_POST_TASK(CEF_UIT, base::Bind(&CefJSDialogCallbackImpl::Continue,
this, success, user_input)); this, success, user_input));
} }
} }
CallbackType Disconnect() WARN_UNUSED_RESULT { return std::move(callback_); } Callback Disconnect() WARN_UNUSED_RESULT { return std::move(callback_); }
private: private:
static void CancelNow(CallbackType callback) { static void CancelNow(Callback callback) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
std::move(callback).Run(false, base::string16()); std::move(callback).Run(false, base::string16());
} }
CallbackType callback_; Callback callback_;
IMPLEMENT_REFCOUNTING(CefJSDialogCallbackImpl); IMPLEMENT_REFCOUNTING(CefJSDialogCallbackImpl);
}; };
@@ -74,7 +72,7 @@ CefJavaScriptDialogManager::~CefJavaScriptDialogManager() {}
void CefJavaScriptDialogManager::Destroy() { void CefJavaScriptDialogManager::Destroy() {
if (runner_.get()) { if (runner_.get()) {
runner_.reset(nullptr); runner_.reset(NULL);
} }
} }
@@ -132,10 +130,11 @@ void CefJavaScriptDialogManager::RunJavaScriptDialog(
url_formatter::FormatUrlForSecurityDisplay(origin_url); url_formatter::FormatUrlForSecurityDisplay(origin_url);
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
runner_->Run( runner_->Run(browser_, message_type, display_url, message_text,
browser_, message_type, display_url, message_text, default_prompt_text, default_prompt_text,
base::BindOnce(&CefJavaScriptDialogManager::DialogClosed, base::Bind(&CefJavaScriptDialogManager::DialogClosed,
weak_ptr_factory_.GetWeakPtr(), std::move(callback))); weak_ptr_factory_.GetWeakPtr(),
base::Passed(std::move(callback))));
} }
void CefJavaScriptDialogManager::RunBeforeUnloadDialog( void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
@@ -186,13 +185,13 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
dialog_running_ = true; dialog_running_ = true;
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
runner_->Run( runner_->Run(browser_, content::JAVASCRIPT_DIALOG_TYPE_CONFIRM,
browser_, content::JAVASCRIPT_DIALOG_TYPE_CONFIRM, base::string16(), // display_url
base::string16(), // display_url message_text,
message_text, base::string16(), // default_prompt_text
base::string16(), // default_prompt_text base::Bind(&CefJavaScriptDialogManager::DialogClosed,
base::BindOnce(&CefJavaScriptDialogManager::DialogClosed, weak_ptr_factory_.GetWeakPtr(),
weak_ptr_factory_.GetWeakPtr(), std::move(callback))); base::Passed(std::move(callback))));
} }
void CefJavaScriptDialogManager::CancelDialogs( void CefJavaScriptDialogManager::CancelDialogs(

View File

@@ -15,8 +15,8 @@ class CefBrowserHostImpl;
class CefJavaScriptDialogRunner { class CefJavaScriptDialogRunner {
public: public:
typedef base::OnceCallback<void(bool /* success */, typedef base::Callback<void(bool /* success */,
const base::string16& /* user_input */)> const base::string16& /* user_input */)>
DialogClosedCallback; DialogClosedCallback;
// Run the dialog. Execute |callback| on completion. // Run the dialog. Execute |callback| on completion.
@@ -25,7 +25,7 @@ class CefJavaScriptDialogRunner {
const base::string16& display_url, const base::string16& display_url,
const base::string16& message_text, const base::string16& message_text,
const base::string16& default_prompt_text, const base::string16& default_prompt_text,
DialogClosedCallback callback) = 0; const DialogClosedCallback& callback) = 0;
// Cancel a dialog mid-flight. // Cancel a dialog mid-flight.
virtual void Cancel() = 0; virtual void Cancel() = 0;

View File

@@ -19,7 +19,7 @@ const blink::MediaStreamDevice* FindDefaultDeviceWithId(
const blink::MediaStreamDevices& devices, const blink::MediaStreamDevices& devices,
const std::string& device_id) { const std::string& device_id) {
if (devices.empty()) if (devices.empty())
return nullptr; return NULL;
blink::MediaStreamDevices::const_iterator iter = devices.begin(); blink::MediaStreamDevices::const_iterator iter = devices.begin();
for (; iter != devices.end(); ++iter) { for (; iter != devices.end(); ++iter) {

View File

@@ -1,83 +0,0 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_route_impl.h"
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/media_router/media_sink_impl.h"
#include "libcef/browser/media_router/media_source_impl.h"
#include "libcef/browser/thread_util.h"
namespace {
// Do not keep a reference to the object returned by this method.
CefBrowserContext* GetBrowserContext(const CefBrowserContext::Getter& getter) {
CEF_REQUIRE_UIT();
DCHECK(!getter.is_null());
// Will return nullptr if the BrowserContext has been destroyed.
return getter.Run();
}
} // namespace
CefMediaRouteImpl::CefMediaRouteImpl(
const media_router::MediaRoute& route,
const CefBrowserContext::Getter& browser_context_getter)
: route_(route), browser_context_getter_(browser_context_getter) {
CEF_REQUIRE_UIT();
}
CefString CefMediaRouteImpl::GetId() {
return route_.media_route_id();
}
CefRefPtr<CefMediaSource> CefMediaRouteImpl::GetSource() {
return new CefMediaSourceImpl(route_.media_source().id());
}
CefRefPtr<CefMediaSink> CefMediaRouteImpl::GetSink() {
return new CefMediaSinkImpl(route_.media_sink_id(), route_.media_sink_name());
}
void CefMediaRouteImpl::SendRouteMessage(const void* message,
size_t message_size) {
std::string message_str(reinterpret_cast<const char*>(message), message_size);
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
[](CefRefPtr<CefMediaRouteImpl> self, std::string message_str) {
self->SendRouteMessageInternal(std::move(message_str));
},
CefRefPtr<CefMediaRouteImpl>(this), std::move(message_str)));
return;
}
SendRouteMessageInternal(std::move(message_str));
}
void CefMediaRouteImpl::Terminate() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefMediaRouteImpl::Terminate, this));
return;
}
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->TerminateRoute(
route_.media_route_id());
}
void CefMediaRouteImpl::SendRouteMessageInternal(std::string message) {
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->SendRouteMessage(
route_.media_route_id(), message);
}

View File

@@ -1,40 +0,0 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_IMPL_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_IMPL_H_
#pragma once
#include "include/cef_media_router.h"
#include "libcef/browser/browser_context.h"
#include "chrome/common/media_router/media_route.h"
// Implementation of the CefMediaRoute interface. Only created on the UI thread.
class CefMediaRouteImpl : public CefMediaRoute {
public:
CefMediaRouteImpl(const media_router::MediaRoute& route,
const CefBrowserContext::Getter& browser_context_getter);
// CefMediaRoute methods.
CefString GetId() override;
CefRefPtr<CefMediaSource> GetSource() override;
CefRefPtr<CefMediaSink> GetSink() override;
void SendRouteMessage(const void* message, size_t message_size) override;
void Terminate() override;
const media_router::MediaRoute& route() const { return route_; }
private:
void SendRouteMessageInternal(std::string message);
// Read-only after creation.
const media_router::MediaRoute route_;
const CefBrowserContext::Getter browser_context_getter_;
IMPLEMENT_REFCOUNTING(CefMediaRouteImpl);
DISALLOW_COPY_AND_ASSIGN(CefMediaRouteImpl);
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_IMPL_H_

View File

@@ -1,290 +0,0 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_router_impl.h"
#include "libcef/browser/media_router/media_route_impl.h"
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/media_router/media_sink_impl.h"
#include "libcef/browser/media_router/media_source_impl.h"
#include "libcef/browser/thread_util.h"
namespace {
// Do not keep a reference to the object returned by this method.
CefBrowserContext* GetBrowserContext(const CefBrowserContext::Getter& getter) {
CEF_REQUIRE_UIT();
DCHECK(!getter.is_null());
// Will return nullptr if the BrowserContext has been destroyed.
return getter.Run();
}
} // namespace
class CefRegistrationImpl : public CefRegistration,
public CefMediaRouterManager::Observer {
public:
explicit CefRegistrationImpl(CefRefPtr<CefMediaObserver> observer)
: observer_(observer) {
DCHECK(observer_);
}
~CefRegistrationImpl() override {
CEF_REQUIRE_UIT();
// May be null if OnMediaRouterDestroyed was called.
if (browser_context_getter_.is_null())
return;
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->RemoveObserver(this);
}
void Initialize(const CefBrowserContext::Getter& browser_context_getter) {
CEF_REQUIRE_UIT();
DCHECK(!browser_context_getter.is_null());
DCHECK(browser_context_getter_.is_null());
browser_context_getter_ = browser_context_getter;
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->AddObserver(this);
}
private:
// CefMediaRouterManager::Observer methods:
void OnMediaRouterDestroyed() override { browser_context_getter_.Reset(); }
void OnMediaSinks(
const CefMediaRouterManager::MediaSinkVector& sinks) override {
std::vector<CefRefPtr<CefMediaSink>> cef_sinks;
for (const auto& sink : sinks) {
cef_sinks.push_back(new CefMediaSinkImpl(sink.sink));
}
observer_->OnSinks(cef_sinks);
}
void OnMediaRoutes(
const CefMediaRouterManager::MediaRouteVector& routes) override {
std::vector<CefRefPtr<CefMediaRoute>> cef_routes;
for (const auto& route : routes) {
cef_routes.push_back(MakeCefRoute(route));
}
observer_->OnRoutes(cef_routes);
}
void OnMediaRouteMessages(
const media_router::MediaRoute& route,
const CefMediaRouterManager::MediaMessageVector& messages) override {
CefRefPtr<CefMediaRoute> cef_route = MakeCefRoute(route);
for (const auto& message : messages) {
if (message->type == media_router::mojom::RouteMessage::Type::TEXT) {
if (message->message.has_value()) {
const std::string& str = *(message->message);
observer_->OnRouteMessageReceived(cef_route, str.c_str(), str.size());
}
} else if (message->type ==
media_router::mojom::RouteMessage::Type::BINARY) {
if (message->data.has_value()) {
const std::vector<uint8_t>& data = *(message->data);
observer_->OnRouteMessageReceived(cef_route, data.data(),
data.size());
}
}
}
}
void OnMediaRouteStateChange(
const media_router::MediaRoute& route,
const content::PresentationConnectionStateChangeInfo& info) override {
observer_->OnRouteStateChanged(MakeCefRoute(route),
ToConnectionState(info.state));
}
CefRefPtr<CefMediaRoute> MakeCefRoute(const media_router::MediaRoute& route) {
return new CefMediaRouteImpl(route, browser_context_getter_);
}
static CefMediaObserver::ConnectionState ToConnectionState(
blink::mojom::PresentationConnectionState state) {
switch (state) {
case blink::mojom::PresentationConnectionState::CONNECTING:
return CEF_MRCS_CONNECTING;
case blink::mojom::PresentationConnectionState::CONNECTED:
return CEF_MRCS_CONNECTED;
case blink::mojom::PresentationConnectionState::CLOSED:
return CEF_MRCS_CLOSED;
case blink::mojom::PresentationConnectionState::TERMINATED:
return CEF_MRCS_TERMINATED;
}
NOTREACHED();
return CEF_MRCS_UNKNOWN;
}
CefRefPtr<CefMediaObserver> observer_;
CefBrowserContext::Getter browser_context_getter_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefRegistrationImpl);
DISALLOW_COPY_AND_ASSIGN(CefRegistrationImpl);
};
CefMediaRouterImpl::CefMediaRouterImpl() {
// Verify that our enum matches Chromium's values.
static_assert(
static_cast<int>(CEF_MRCR_TOTAL_COUNT) ==
static_cast<int>(media_router::RouteRequestResult::TOTAL_COUNT),
"enum mismatch");
}
void CefMediaRouterImpl::Initialize(
const CefBrowserContext::Getter& browser_context_getter) {
CEF_REQUIRE_UIT();
DCHECK(!browser_context_getter.is_null());
DCHECK(browser_context_getter_.is_null());
browser_context_getter_ = browser_context_getter;
}
CefRefPtr<CefRegistration> CefMediaRouterImpl::AddObserver(
CefRefPtr<CefMediaObserver> observer) {
if (!observer)
return nullptr;
CefRefPtr<CefRegistrationImpl> registration =
new CefRegistrationImpl(observer);
InitializeRegistrationOnUIThread(registration);
return registration.get();
}
CefRefPtr<CefMediaSource> CefMediaRouterImpl::GetSource(const CefString& urn) {
if (urn.empty())
return nullptr;
// Check for a valid URL and supported Cast/DIAL schemes.
GURL presentation_url(urn.ToString());
if (!media_router::IsValidPresentationUrl(presentation_url)) {
return nullptr;
}
if (presentation_url.SchemeIsHTTPOrHTTPS()) {
// We don't support tab/desktop mirroring, which is what Cast uses for
// arbitrary HTTP/HTTPS URLs (see CastMediaSource).
return nullptr;
}
return new CefMediaSourceImpl(presentation_url);
}
void CefMediaRouterImpl::NotifyCurrentSinks() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT, base::BindOnce(&CefMediaRouterImpl::NotifyCurrentSinks, this));
return;
}
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->NotifyCurrentSinks();
}
void CefMediaRouterImpl::CreateRoute(
CefRefPtr<CefMediaSource> source,
CefRefPtr<CefMediaSink> sink,
CefRefPtr<CefMediaRouteCreateCallback> callback) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefMediaRouterImpl::CreateRoute,
this, source, sink, callback));
return;
}
std::string error;
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context) {
error = "Context has already been destroyed";
} else if (!source || !source->IsValid()) {
error = "Source is empty or invalid";
} else if (!sink || !sink->IsValid()) {
error = "Sink is empty or invalid";
} else if (!sink->IsCompatibleWith(source)) {
error = "Sink is not compatible with source";
}
if (!error.empty()) {
LOG(WARNING) << "Media route creation failed: " << error;
if (callback) {
callback->OnMediaRouteCreateFinished(CEF_MRCR_UNKNOWN_ERROR, error,
nullptr);
}
return;
}
auto source_impl = static_cast<CefMediaSourceImpl*>(source.get());
auto sink_impl = static_cast<CefMediaSinkImpl*>(sink.get());
browser_context->GetMediaRouterManager()->CreateRoute(
source_impl->source().id(), sink_impl->sink().id(), url::Origin(),
base::BindOnce(&CefMediaRouterImpl::CreateRouteCallback, this, callback));
}
void CefMediaRouterImpl::NotifyCurrentRoutes() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(
&CefMediaRouterImpl::NotifyCurrentRoutes, this));
return;
}
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->NotifyCurrentRoutes();
}
void CefMediaRouterImpl::InitializeRegistrationOnUIThread(
CefRefPtr<CefRegistrationImpl> registration) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefMediaRouterImpl::InitializeRegistrationOnUIThread,
this, registration));
return;
}
registration->Initialize(browser_context_getter_);
}
void CefMediaRouterImpl::CreateRouteCallback(
CefRefPtr<CefMediaRouteCreateCallback> callback,
const media_router::RouteRequestResult& result) {
CEF_REQUIRE_UIT();
if (result.result_code() != media_router::RouteRequestResult::OK) {
LOG(WARNING) << "Media route creation failed: " << result.error() << " ("
<< result.result_code() << ")";
}
if (!callback)
return;
CefRefPtr<CefMediaRoute> route;
if (result.result_code() == media_router::RouteRequestResult::OK &&
result.route()) {
route = new CefMediaRouteImpl(*result.route(), browser_context_getter_);
}
callback->OnMediaRouteCreateFinished(
static_cast<cef_media_route_create_result_t>(result.result_code()),
result.error(), route);
}
// static
CefRefPtr<CefMediaRouter> CefMediaRouter::GetGlobalMediaRouter() {
return CefRequestContext::GetGlobalContext()->GetMediaRouter();
}

View File

@@ -1,49 +0,0 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_
#pragma once
#include "include/cef_media_router.h"
#include "libcef/browser/browser_context.h"
#include "chrome/common/media_router/mojom/media_router.mojom.h"
class CefRegistrationImpl;
// Implementation of the CefMediaRouter interface. May be created on any thread.
class CefMediaRouterImpl : public CefMediaRouter {
public:
CefMediaRouterImpl();
// Called on the UI thread after object creation and before any other object
// methods are executed on the UI thread.
void Initialize(const CefBrowserContext::Getter& browser_context_getter);
// CefMediaRouter methods.
CefRefPtr<CefRegistration> AddObserver(
CefRefPtr<CefMediaObserver> observer) override;
CefRefPtr<CefMediaSource> GetSource(const CefString& urn) override;
void NotifyCurrentSinks() override;
void CreateRoute(CefRefPtr<CefMediaSource> source,
CefRefPtr<CefMediaSink> sink,
CefRefPtr<CefMediaRouteCreateCallback> callback) override;
void NotifyCurrentRoutes() override;
private:
void InitializeRegistrationOnUIThread(
CefRefPtr<CefRegistrationImpl> registration);
void CreateRouteCallback(CefRefPtr<CefMediaRouteCreateCallback> callback,
const media_router::RouteRequestResult& result);
// Only accessed on the UI thread. Will be non-null after Initialize().
CefBrowserContext::Getter browser_context_getter_;
IMPLEMENT_REFCOUNTING(CefMediaRouterImpl);
DISALLOW_COPY_AND_ASSIGN(CefMediaRouterImpl);
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_

View File

@@ -1,292 +0,0 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/thread_util.h"
#include "chrome/browser/media/router/media_router_factory.h"
#include "chrome/browser/media/router/media_routes_observer.h"
#include "chrome/browser/media/router/route_message_observer.h"
#include "chrome/browser/media/router/route_message_util.h"
namespace {
const int kTimeoutMs = 5 * 1000;
const char kDefaultPresentationUrl[] = "https://google.com";
} // namespace
class CefMediaRoutesObserver : public media_router::MediaRoutesObserver {
public:
explicit CefMediaRoutesObserver(CefMediaRouterManager* manager)
: media_router::MediaRoutesObserver(manager->GetMediaRouter()),
manager_(manager) {}
void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes,
const std::vector<media_router::MediaRoute::Id>&
joinable_route_ids) override {
manager_->routes_ = routes;
manager_->NotifyCurrentRoutes();
}
private:
CefMediaRouterManager* const manager_;
DISALLOW_COPY_AND_ASSIGN(CefMediaRoutesObserver);
};
// Used to receive messages if PresentationConnection is not supported.
class CefRouteMessageObserver : public media_router::RouteMessageObserver {
public:
CefRouteMessageObserver(CefMediaRouterManager* manager,
const media_router::MediaRoute& route)
: media_router::RouteMessageObserver(manager->GetMediaRouter(),
route.media_route_id()),
manager_(manager),
route_(route) {}
void OnMessagesReceived(
CefMediaRouterManager::MediaMessageVector messages) override {
manager_->OnMessagesReceived(route_, messages);
}
private:
CefMediaRouterManager* const manager_;
const media_router::MediaRoute route_;
DISALLOW_COPY_AND_ASSIGN(CefRouteMessageObserver);
};
// Used for messaging and route status notifications with Cast.
class CefPresentationConnection : public blink::mojom::PresentationConnection {
public:
explicit CefPresentationConnection(
CefMediaRouterManager* manager,
const media_router::MediaRoute& route,
media_router::mojom::RoutePresentationConnectionPtr connections)
: manager_(manager),
route_(route),
connection_receiver_(this, std::move(connections->connection_receiver)),
connection_remote_(std::move(connections->connection_remote)) {}
void OnMessage(
blink::mojom::PresentationConnectionMessagePtr message) override {
CefMediaRouterManager::MediaMessageVector messages;
if (message->is_message()) {
messages.push_back(media_router::message_util::RouteMessageFromString(
message->get_message()));
} else if (message->is_data()) {
messages.push_back(media_router::message_util::RouteMessageFromData(
message->get_data()));
}
if (!messages.empty()) {
manager_->OnMessagesReceived(route_, messages);
}
}
void DidChangeState(
blink::mojom::PresentationConnectionState state) override {
// May result in |this| being deleted, so post async and allow the call
// stack to unwind.
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefMediaRouterManager::OnRouteStateChange,
manager_->weak_ptr_factory_.GetWeakPtr(), route_,
content::PresentationConnectionStateChangeInfo(state)));
}
void DidClose(
blink::mojom::PresentationConnectionCloseReason reason) override {
DidChangeState(blink::mojom::PresentationConnectionState::CLOSED);
}
void SendRouteMessage(const std::string& message) {
connection_remote_->OnMessage(
blink::mojom::PresentationConnectionMessage::NewMessage(message));
}
private:
CefMediaRouterManager* const manager_;
const media_router::MediaRoute route_;
// Used to receive messages from the MRP.
mojo::Receiver<blink::mojom::PresentationConnection> connection_receiver_;
// Used to send messages to the MRP.
mojo::Remote<blink::mojom::PresentationConnection> connection_remote_;
DISALLOW_COPY_AND_ASSIGN(CefPresentationConnection);
};
CefMediaRouterManager::CefMediaRouterManager(CefBrowserContext* browser_context)
: browser_context_(browser_context),
query_result_manager_(GetMediaRouter()),
weak_ptr_factory_(this) {
// Perform initialization.
GetMediaRouter()->OnUserGesture();
query_result_manager_.AddObserver(this);
// A non-empty presentation URL to required for discovery of Cast devices.
query_result_manager_.SetSourcesForCastMode(
media_router::MediaCastMode::PRESENTATION,
{media_router::MediaSource::ForPresentationUrl(
GURL(kDefaultPresentationUrl))},
url::Origin());
routes_observer_ = std::make_unique<CefMediaRoutesObserver>(this);
}
CefMediaRouterManager::~CefMediaRouterManager() {
CEF_REQUIRE_UIT();
for (auto& observer : observers_) {
observers_.RemoveObserver(&observer);
observer.OnMediaRouterDestroyed();
}
query_result_manager_.RemoveObserver(this);
}
void CefMediaRouterManager::AddObserver(Observer* observer) {
CEF_REQUIRE_UIT();
observers_.AddObserver(observer);
}
void CefMediaRouterManager::RemoveObserver(Observer* observer) {
CEF_REQUIRE_UIT();
observers_.RemoveObserver(observer);
}
void CefMediaRouterManager::NotifyCurrentSinks() {
CEF_REQUIRE_UIT();
for (auto& observer : observers_) {
observer.OnMediaSinks(sinks_);
}
}
void CefMediaRouterManager::NotifyCurrentRoutes() {
CEF_REQUIRE_UIT();
for (auto& observer : observers_) {
observer.OnMediaRoutes(routes_);
}
}
void CefMediaRouterManager::CreateRoute(
const media_router::MediaSource::Id& source_id,
const media_router::MediaSink::Id& sink_id,
const url::Origin& origin,
CreateRouteResultCallback callback) {
GetMediaRouter()->CreateRoute(
source_id, sink_id, origin, nullptr /* web_contents */,
base::BindOnce(&CefMediaRouterManager::OnCreateRoute,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)),
base::TimeDelta::FromMilliseconds(kTimeoutMs), false /* incognito */);
}
void CefMediaRouterManager::SendRouteMessage(
const media_router::MediaRoute::Id& route_id,
const std::string& message) {
// Must use PresentationConnection to send messages if it exists.
auto state = GetRouteState(route_id);
if (state && state->presentation_connection_) {
state->presentation_connection_->SendRouteMessage(message);
return;
}
GetMediaRouter()->SendRouteMessage(route_id, message);
}
void CefMediaRouterManager::TerminateRoute(
const media_router::MediaRoute::Id& route_id) {
GetMediaRouter()->TerminateRoute(route_id);
}
void CefMediaRouterManager::OnResultsUpdated(const MediaSinkVector& sinks) {
sinks_ = sinks;
NotifyCurrentSinks();
}
media_router::MediaRouter* CefMediaRouterManager::GetMediaRouter() const {
CEF_REQUIRE_UIT();
return media_router::MediaRouterFactory::GetApiForBrowserContext(
browser_context_);
}
void CefMediaRouterManager::OnCreateRoute(
CreateRouteResultCallback callback,
media_router::mojom::RoutePresentationConnectionPtr connection,
const media_router::RouteRequestResult& result) {
CEF_REQUIRE_UIT();
if (result.route()) {
CreateRouteState(*result.route(), std::move(connection));
}
std::move(callback).Run(result);
}
void CefMediaRouterManager::OnRouteStateChange(
const media_router::MediaRoute& route,
const content::PresentationConnectionStateChangeInfo& info) {
CEF_REQUIRE_UIT();
if (info.state == blink::mojom::PresentationConnectionState::CLOSED ||
info.state == blink::mojom::PresentationConnectionState::TERMINATED) {
RemoveRouteState(route.media_route_id());
}
for (auto& observer : observers_) {
observer.OnMediaRouteStateChange(route, info);
}
}
void CefMediaRouterManager::OnMessagesReceived(
const media_router::MediaRoute& route,
const MediaMessageVector& messages) {
CEF_REQUIRE_UIT();
for (auto& observer : observers_) {
observer.OnMediaRouteMessages(route, messages);
}
}
void CefMediaRouterManager::CreateRouteState(
const media_router::MediaRoute& route,
media_router::mojom::RoutePresentationConnectionPtr connection) {
const auto route_id = route.media_route_id();
auto state = std::make_unique<RouteState>();
if (!connection.is_null()) {
// PresentationConnection must be used for messaging and status
// notifications if it exists.
state->presentation_connection_ =
std::make_unique<CefPresentationConnection>(this, route,
std::move(connection));
} else {
// Fallback if PresentationConnection is not supported.
state->message_observer_ =
std::make_unique<CefRouteMessageObserver>(this, route);
state->state_subscription_ =
GetMediaRouter()->AddPresentationConnectionStateChangedCallback(
route_id,
base::BindRepeating(&CefMediaRouterManager::OnRouteStateChange,
weak_ptr_factory_.GetWeakPtr(), route));
}
route_state_map_.insert(std::make_pair(route_id, std::move(state)));
}
CefMediaRouterManager::RouteState* CefMediaRouterManager::GetRouteState(
const media_router::MediaRoute::Id& route_id) {
const auto it = route_state_map_.find(route_id);
if (it != route_state_map_.end())
return it->second.get();
return nullptr;
}
void CefMediaRouterManager::RemoveRouteState(
const media_router::MediaRoute::Id& route_id) {
auto it = route_state_map_.find(route_id);
if (it != route_state_map_.end())
route_state_map_.erase(it);
}

View File

@@ -1,125 +0,0 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MANAGER_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MANAGER_H_
#pragma once
#include "include/cef_media_router.h"
#include "libcef/browser/browser_context.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "chrome/browser/media/router/media_router.h"
#include "chrome/browser/ui/media_router/query_result_manager.h"
#include "chrome/common/media_router/mojom/media_router.mojom.h"
class CefBrowserContext;
class CefMediaRoutesObserver;
class CefPresentationConnection;
class CefRouteMessageObserver;
// Manages CEF usage of MediaRouter. Owned by CefBrowserContext and only
// accessed on the UI thread.
class CefMediaRouterManager
: public media_router::QueryResultManager::Observer {
public:
using MediaRouteVector = std::vector<media_router::MediaRoute>;
using MediaSinkVector = std::vector<media_router::MediaSinkWithCastModes>;
using MediaMessageVector = std::vector<media_router::mojom::RouteMessagePtr>;
class Observer : public base::CheckedObserver {
public:
virtual void OnMediaRouterDestroyed() = 0;
virtual void OnMediaSinks(const MediaSinkVector& sinks) = 0;
virtual void OnMediaRoutes(const MediaRouteVector& routes) = 0;
virtual void OnMediaRouteMessages(const media_router::MediaRoute& route,
const MediaMessageVector& messages) = 0;
virtual void OnMediaRouteStateChange(
const media_router::MediaRoute& route,
const content::PresentationConnectionStateChangeInfo& info) = 0;
protected:
~Observer() override {}
};
explicit CefMediaRouterManager(CefBrowserContext* browser_context);
~CefMediaRouterManager() override;
// |observer| must outlive this object or be removed.
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
void NotifyCurrentSinks();
void NotifyCurrentRoutes();
using CreateRouteResultCallback =
base::OnceCallback<void(const media_router::RouteRequestResult& result)>;
void CreateRoute(const media_router::MediaSource::Id& source_id,
const media_router::MediaSink::Id& sink_id,
const url::Origin& origin,
CreateRouteResultCallback callback);
void SendRouteMessage(const media_router::MediaRoute::Id& route_id,
const std::string& message);
void TerminateRoute(const media_router::MediaRoute::Id& route_id);
// QueryResultManager::Observer methods.
void OnResultsUpdated(const MediaSinkVector& sinks) override;
private:
friend class CefMediaRoutesObserver;
friend class CefPresentationConnection;
friend class CefRouteMessageObserver;
// Do not keep a reference to the object returned by this method.
media_router::MediaRouter* GetMediaRouter() const;
void OnCreateRoute(
CreateRouteResultCallback callback,
media_router::mojom::RoutePresentationConnectionPtr connection,
const media_router::RouteRequestResult& result);
void OnRouteStateChange(
const media_router::MediaRoute& route,
const content::PresentationConnectionStateChangeInfo& info);
void OnMessagesReceived(const media_router::MediaRoute& route,
const MediaMessageVector& messages);
struct RouteState {
std::unique_ptr<CefPresentationConnection> presentation_connection_;
// Used if there is no RoutePresentationConnectionPtr.
std::unique_ptr<CefRouteMessageObserver> message_observer_;
std::unique_ptr<media_router::PresentationConnectionStateSubscription>
state_subscription_;
};
void CreateRouteState(
const media_router::MediaRoute& route,
media_router::mojom::RoutePresentationConnectionPtr connection);
RouteState* GetRouteState(const media_router::MediaRoute::Id& route_id);
void RemoveRouteState(const media_router::MediaRoute::Id& route_id);
CefBrowserContext* const browser_context_;
base::ObserverList<Observer> observers_;
media_router::QueryResultManager query_result_manager_;
std::unique_ptr<CefMediaRoutesObserver> routes_observer_;
MediaRouteVector routes_;
MediaSinkVector sinks_;
using RouteStateMap =
std::map<media_router::MediaRoute::Id, std::unique_ptr<RouteState>>;
RouteStateMap route_state_map_;
base::WeakPtrFactory<CefMediaRouterManager> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefMediaRouterManager);
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MANAGER_H_

View File

@@ -1,55 +0,0 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_sink_impl.h"
CefMediaSinkImpl::CefMediaSinkImpl(const media_router::MediaSink& sink)
: sink_(sink) {}
CefMediaSinkImpl::CefMediaSinkImpl(const media_router::MediaSink::Id& sink_id,
const std::string& sink_name)
: sink_(sink_id, sink_name, media_router::SinkIconType::GENERIC) {}
CefString CefMediaSinkImpl::GetId() {
return sink_.id();
}
bool CefMediaSinkImpl::IsValid() {
return true;
}
CefString CefMediaSinkImpl::GetName() {
return sink_.name();
}
CefString CefMediaSinkImpl::GetDescription() {
return sink_.description().value_or("");
}
CefMediaSink::IconType CefMediaSinkImpl::GetIconType() {
// Verify that our enum matches Chromium's values.
static_assert(static_cast<int>(CEF_MSIT_TOTAL_COUNT) ==
static_cast<int>(media_router::SinkIconType::TOTAL_COUNT),
"enum mismatch");
return static_cast<CefMediaSink::IconType>(sink_.icon_type());
}
bool CefMediaSinkImpl::IsCastSink() {
return sink_.provider_id() == media_router::CAST;
}
bool CefMediaSinkImpl::IsDialSink() {
return sink_.provider_id() == media_router::DIAL;
}
bool CefMediaSinkImpl::IsCompatibleWith(CefRefPtr<CefMediaSource> source) {
if (source) {
if (IsCastSink())
return source->IsCastSource();
if (IsDialSink())
return source->IsDialSource();
}
return false;
}

View File

@@ -1,40 +0,0 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SINK_IMPL_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SINK_IMPL_H_
#pragma once
#include "include/cef_media_router.h"
#include "chrome/common/media_router/media_sink.h"
// Implementation of the CefMediaSink interface. May be created on any thread.
class CefMediaSinkImpl : public CefMediaSink {
public:
explicit CefMediaSinkImpl(const media_router::MediaSink& sink);
CefMediaSinkImpl(const media_router::MediaSink::Id& sink_id,
const std::string& sink_name);
// CefMediaSink methods.
CefString GetId() override;
bool IsValid() override;
CefString GetName() override;
CefString GetDescription() override;
IconType GetIconType() override;
bool IsCastSink() override;
bool IsDialSink() override;
bool IsCompatibleWith(CefRefPtr<CefMediaSource> source) override;
const media_router::MediaSink& sink() const { return sink_; }
private:
// Read-only after creation.
const media_router::MediaSink sink_;
IMPLEMENT_REFCOUNTING(CefMediaSinkImpl);
DISALLOW_COPY_AND_ASSIGN(CefMediaSinkImpl);
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SINK_IMPL_H_

View File

@@ -1,28 +0,0 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_source_impl.h"
CefMediaSourceImpl::CefMediaSourceImpl(
const media_router::MediaSource::Id& source_id)
: source_(source_id) {}
CefMediaSourceImpl::CefMediaSourceImpl(const GURL& presentation_url)
: source_(presentation_url) {}
CefString CefMediaSourceImpl::GetId() {
return source_.id();
}
bool CefMediaSourceImpl::IsValid() {
return source_.IsValid();
}
bool CefMediaSourceImpl::IsCastSource() {
return !IsDialSource();
}
bool CefMediaSourceImpl::IsDialSource() {
return source_.IsDialSource();
}

View File

@@ -1,35 +0,0 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_IMPL_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_IMPL_H_
#pragma once
#include "include/cef_media_router.h"
#include "chrome/common/media_router/media_source.h"
// Implementation of the CefMediaSource interface. May be created on any thread.
class CefMediaSourceImpl : public CefMediaSource {
public:
explicit CefMediaSourceImpl(const media_router::MediaSource::Id& source_id);
explicit CefMediaSourceImpl(const GURL& presentation_url);
// CefMediaSource methods.
CefString GetId() override;
bool IsValid() override;
bool IsCastSource() override;
bool IsDialSource() override;
const media_router::MediaSource& source() const { return source_; }
private:
// Read-only after creation.
const media_router::MediaSource source_;
IMPLEMENT_REFCOUNTING(CefMediaSourceImpl);
DISALLOW_COPY_AND_ASSIGN(CefMediaSourceImpl);
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_IMPL_H_

View File

@@ -91,7 +91,7 @@ CefMenuManager::CefMenuManager(CefBrowserHostImpl* browser,
: content::WebContentsObserver(browser->web_contents()), : content::WebContentsObserver(browser->web_contents()),
browser_(browser), browser_(browser),
runner_(std::move(runner)), runner_(std::move(runner)),
custom_menu_callback_(nullptr), custom_menu_callback_(NULL),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
DCHECK(web_contents()); DCHECK(web_contents());
model_ = new CefMenuModelImpl(this, nullptr, false); model_ = new CefMenuModelImpl(this, nullptr, false);
@@ -100,13 +100,13 @@ CefMenuManager::CefMenuManager(CefBrowserHostImpl* browser,
CefMenuManager::~CefMenuManager() { CefMenuManager::~CefMenuManager() {
// The model may outlive the delegate if the context menu is visible when the // The model may outlive the delegate if the context menu is visible when the
// application is closed. // application is closed.
model_->set_delegate(nullptr); model_->set_delegate(NULL);
} }
void CefMenuManager::Destroy() { void CefMenuManager::Destroy() {
CancelContextMenu(); CancelContextMenu();
if (runner_) if (runner_)
runner_.reset(nullptr); runner_.reset(NULL);
} }
bool CefMenuManager::IsShowingContextMenu() { bool CefMenuManager::IsShowingContextMenu() {
@@ -166,13 +166,13 @@ bool CefMenuManager::CreateContextMenu(
} else { } else {
// Callback should not be executed if the handler returns false. // Callback should not be executed if the handler returns false.
DCHECK(custom_menu_callback_); DCHECK(custom_menu_callback_);
custom_menu_callback_ = nullptr; custom_menu_callback_ = NULL;
callbackImpl->Disconnect(); callbackImpl->Disconnect();
} }
} }
// Do not keep references to the parameters in the callback. // Do not keep references to the parameters in the callback.
paramsPtr->Detach(nullptr); paramsPtr->Detach(NULL);
DCHECK(paramsPtr->HasOneRef()); DCHECK(paramsPtr->HasOneRef());
DCHECK(model_->VerifyRefCount()); DCHECK(model_->VerifyRefCount());
@@ -214,7 +214,7 @@ void CefMenuManager::ExecuteCommand(CefRefPtr<CefMenuModelImpl> source,
event_flags); event_flags);
// Do not keep references to the parameters in the callback. // Do not keep references to the parameters in the callback.
paramsPtr->Detach(nullptr); paramsPtr->Detach(NULL);
DCHECK(paramsPtr->HasOneRef()); DCHECK(paramsPtr->HasOneRef());
if (handled) if (handled)
@@ -280,7 +280,7 @@ void CefMenuManager::ExecuteCommandCallback(int command_id,
if (command_id != kInvalidCommandId) if (command_id != kInvalidCommandId)
ExecuteCommand(model_, command_id, event_flags); ExecuteCommand(model_, command_id, event_flags);
MenuClosed(model_); MenuClosed(model_);
custom_menu_callback_ = nullptr; custom_menu_callback_ = NULL;
} }
void CefMenuManager::CreateDefaultModel() { void CefMenuManager::CreateDefaultModel() {

View File

@@ -107,7 +107,7 @@ class CefSimpleMenuModel : public ui::MenuModel {
bool GetIconAt(int index, gfx::Image* icon) const override { return false; } bool GetIconAt(int index, gfx::Image* icon) const override { return false; }
ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const override { ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const override {
return nullptr; return NULL;
} }
bool IsEnabledAt(int index) const override { bool IsEnabledAt(int index) const override {
@@ -128,7 +128,7 @@ class CefSimpleMenuModel : public ui::MenuModel {
CefRefPtr<CefMenuModel> submenu = impl_->GetSubMenuAt(index); CefRefPtr<CefMenuModel> submenu = impl_->GetSubMenuAt(index);
if (submenu.get()) if (submenu.get())
return static_cast<CefMenuModelImpl*>(submenu.get())->model(); return static_cast<CefMenuModelImpl*>(submenu.get())->model();
return nullptr; return NULL;
} }
void MouseOutsideMenu(const gfx::Point& screen_point) override { void MouseOutsideMenu(const gfx::Point& screen_point) override {
@@ -304,7 +304,7 @@ bool CefMenuModelImpl::AddRadioItem(int command_id,
CefRefPtr<CefMenuModel> CefMenuModelImpl::AddSubMenu(int command_id, CefRefPtr<CefMenuModel> CefMenuModelImpl::AddSubMenu(int command_id,
const CefString& label) { const CefString& label) {
if (!VerifyContext()) if (!VerifyContext())
return nullptr; return NULL;
Item item(MENUITEMTYPE_SUBMENU, command_id, label, kInvalidGroupId); Item item(MENUITEMTYPE_SUBMENU, command_id, label, kInvalidGroupId);
item.submenu_ = new CefMenuModelImpl(delegate_, menu_model_delegate_, true); item.submenu_ = new CefMenuModelImpl(delegate_, menu_model_delegate_, true);
@@ -360,7 +360,7 @@ CefRefPtr<CefMenuModel> CefMenuModelImpl::InsertSubMenuAt(
int command_id, int command_id,
const CefString& label) { const CefString& label) {
if (!VerifyContext()) if (!VerifyContext())
return nullptr; return NULL;
Item item(MENUITEMTYPE_SUBMENU, command_id, label, kInvalidGroupId); Item item(MENUITEMTYPE_SUBMENU, command_id, label, kInvalidGroupId);
item.submenu_ = new CefMenuModelImpl(delegate_, menu_model_delegate_, true); item.submenu_ = new CefMenuModelImpl(delegate_, menu_model_delegate_, true);
@@ -490,11 +490,11 @@ CefRefPtr<CefMenuModel> CefMenuModelImpl::GetSubMenu(int command_id) {
CefRefPtr<CefMenuModel> CefMenuModelImpl::GetSubMenuAt(int index) { CefRefPtr<CefMenuModel> CefMenuModelImpl::GetSubMenuAt(int index) {
if (!VerifyContext()) if (!VerifyContext())
return nullptr; return NULL;
if (index >= 0 && index < static_cast<int>(items_.size())) if (index >= 0 && index < static_cast<int>(items_.size()))
return items_[index].submenu_.get(); return items_[index].submenu_.get();
return nullptr; return NULL;
} }
bool CefMenuModelImpl::IsVisible(int command_id) { bool CefMenuModelImpl::IsVisible(int command_id) {

View File

@@ -8,7 +8,6 @@
#include "content/public/browser/render_view_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.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
CefBrowserPlatformDelegateNative::CefBrowserPlatformDelegateNative( CefBrowserPlatformDelegateNative::CefBrowserPlatformDelegateNative(
const CefWindowInfo& window_info, const CefWindowInfo& window_info,
@@ -39,6 +38,30 @@ void CefBrowserPlatformDelegateNative::WasResized() {
host->GetWidget()->SynchronizeVisualProperties(); host->GetWidget()->SynchronizeVisualProperties();
} }
void CefBrowserPlatformDelegateNative::SendKeyEvent(
const content::NativeWebKeyboardEvent& event) {
content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost();
if (host)
host->GetWidget()->ForwardKeyboardEvent(event);
}
void CefBrowserPlatformDelegateNative::SendMouseEvent(
const blink::WebMouseEvent& event) {
content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost();
if (host)
host->GetWidget()->ForwardMouseEvent(event);
}
void CefBrowserPlatformDelegateNative::SendMouseWheelEvent(
const blink::WebMouseWheelEvent& event) {
content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost();
if (host)
host->GetWidget()->ForwardWheelEvent(event);
}
void CefBrowserPlatformDelegateNative::SendTouchEvent(
const CefTouchEvent& event) {}
bool CefBrowserPlatformDelegateNative::IsWindowless() const { bool CefBrowserPlatformDelegateNative::IsWindowless() const {
return false; return false;
} }

View File

@@ -29,44 +29,25 @@ class CefBrowserPlatformDelegateNative : public CefBrowserPlatformDelegate {
bool CanUseExternalBeginFrame() const override; bool CanUseExternalBeginFrame() const override;
SkColor GetBackgroundColor() const override; SkColor GetBackgroundColor() const override;
void WasResized() override; void WasResized() override;
void SendKeyEvent(const content::NativeWebKeyboardEvent& event) override;
void SendMouseEvent(const blink::WebMouseEvent& event) override;
void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event) override;
void SendTouchEvent(const CefTouchEvent& event) override;
bool IsWindowless() const override; bool IsWindowless() const override;
bool IsViewsHosted() const override; bool IsViewsHosted() const override;
// Translate CEF events to Chromium/Blink Web events.
virtual content::NativeWebKeyboardEvent TranslateWebKeyEvent(
const CefKeyEvent& key_event) const = 0;
virtual blink::WebMouseEvent TranslateWebClickEvent(
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const = 0;
virtual blink::WebMouseEvent TranslateWebMoveEvent(
const CefMouseEvent& mouse_event,
bool mouseLeave) const = 0;
virtual blink::WebMouseWheelEvent TranslateWebWheelEvent(
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const = 0;
const CefWindowInfo& window_info() const { return window_info_; } const CefWindowInfo& window_info() const { return window_info_; }
protected: void set_windowless_handler(WindowlessHandler* handler) {
// Delegates that can wrap a native delegate. windowless_handler_ = handler;
friend class CefBrowserPlatformDelegateBackground; }
friend class CefBrowserPlatformDelegateOsr;
friend class CefBrowserPlatformDelegateViews;
protected:
CefBrowserPlatformDelegateNative(const CefWindowInfo& window_info, CefBrowserPlatformDelegateNative(const CefWindowInfo& window_info,
SkColor background_color, SkColor background_color,
bool use_shared_texture, bool use_shared_texture,
bool use_external_begin_frame); bool use_external_begin_frame);
// Methods used by delegates that can wrap a native delegate.
void set_windowless_handler(WindowlessHandler* handler) {
windowless_handler_ = handler;
}
void set_browser(CefBrowserHostImpl* browser) { browser_ = browser; }
CefWindowInfo window_info_; CefWindowInfo window_info_;
const SkColor background_color_; const SkColor background_color_;
const bool use_shared_texture_; const bool use_shared_texture_;

View File

@@ -1,235 +0,0 @@
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/native/browser_platform_delegate_native_aura.h"
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "ui/events/blink/blink_event_util.h"
#include "ui/events/blink/web_input_event.h"
#include "ui/gfx/geometry/vector2d.h"
CefBrowserPlatformDelegateNativeAura::CefBrowserPlatformDelegateNativeAura(
const CefWindowInfo& window_info,
SkColor background_color,
bool use_shared_texture,
bool use_external_begin_frame)
: CefBrowserPlatformDelegateNative(window_info,
background_color,
use_shared_texture,
use_external_begin_frame) {}
void CefBrowserPlatformDelegateNativeAura::SendKeyEvent(
const CefKeyEvent& event) {
auto view = GetHostView();
if (!view)
return;
ui::KeyEvent ui_event = TranslateUiKeyEvent(event);
view->OnKeyEvent(&ui_event);
}
void CefBrowserPlatformDelegateNativeAura::SendMouseClickEvent(
const CefMouseEvent& event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) {
auto view = GetHostView();
if (!view)
return;
ui::MouseEvent ui_event =
TranslateUiClickEvent(event, type, mouseUp, clickCount);
view->OnMouseEvent(&ui_event);
}
void CefBrowserPlatformDelegateNativeAura::SendMouseMoveEvent(
const CefMouseEvent& event,
bool mouseLeave) {
auto view = GetHostView();
if (!view)
return;
ui::MouseEvent ui_event = TranslateUiMoveEvent(event, mouseLeave);
view->OnMouseEvent(&ui_event);
}
void CefBrowserPlatformDelegateNativeAura::SendMouseWheelEvent(
const CefMouseEvent& event,
int deltaX,
int deltaY) {
auto view = GetHostView();
if (!view)
return;
ui::MouseWheelEvent ui_event = TranslateUiWheelEvent(event, deltaX, deltaY);
view->OnMouseEvent(&ui_event);
}
void CefBrowserPlatformDelegateNativeAura::SendTouchEvent(
const CefTouchEvent& event) {
NOTIMPLEMENTED();
}
content::NativeWebKeyboardEvent
CefBrowserPlatformDelegateNativeAura::TranslateWebKeyEvent(
const CefKeyEvent& key_event) const {
return content::NativeWebKeyboardEvent(TranslateUiKeyEvent(key_event));
}
blink::WebMouseEvent
CefBrowserPlatformDelegateNativeAura::TranslateWebClickEvent(
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const {
return ui::MakeWebMouseEvent(
TranslateUiClickEvent(mouse_event, type, mouseUp, clickCount));
}
blink::WebMouseEvent
CefBrowserPlatformDelegateNativeAura::TranslateWebMoveEvent(
const CefMouseEvent& mouse_event,
bool mouseLeave) const {
return ui::MakeWebMouseEvent(TranslateUiMoveEvent(mouse_event, mouseLeave));
}
blink::WebMouseWheelEvent
CefBrowserPlatformDelegateNativeAura::TranslateWebWheelEvent(
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const {
return ui::MakeWebMouseWheelEvent(
TranslateUiWheelEvent(mouse_event, deltaX, deltaY));
}
ui::MouseEvent CefBrowserPlatformDelegateNativeAura::TranslateUiClickEvent(
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const {
DCHECK_GE(clickCount, 1);
ui::EventType event_type =
mouseUp ? ui::ET_MOUSE_RELEASED : ui::ET_MOUSE_PRESSED;
gfx::PointF location(mouse_event.x, mouse_event.y);
gfx::PointF root_location(
GetScreenPoint(gfx::Point(mouse_event.x, mouse_event.y)));
base::TimeTicks time_stamp = GetEventTimeStamp();
int flags = TranslateUiEventModifiers(mouse_event.modifiers);
int changed_button_flags = 0;
switch (type) {
case MBT_LEFT:
changed_button_flags |= ui::EF_LEFT_MOUSE_BUTTON;
break;
case MBT_MIDDLE:
changed_button_flags |= ui::EF_MIDDLE_MOUSE_BUTTON;
break;
case MBT_RIGHT:
changed_button_flags |= ui::EF_RIGHT_MOUSE_BUTTON;
break;
default:
NOTREACHED();
}
ui::MouseEvent result(event_type, location, root_location, time_stamp, flags,
changed_button_flags);
result.SetClickCount(clickCount);
return result;
}
ui::MouseEvent CefBrowserPlatformDelegateNativeAura::TranslateUiMoveEvent(
const CefMouseEvent& mouse_event,
bool mouseLeave) const {
ui::EventType event_type =
mouseLeave ? ui::ET_MOUSE_EXITED : ui::ET_MOUSE_MOVED;
gfx::PointF location(mouse_event.x, mouse_event.y);
gfx::PointF root_location(
GetScreenPoint(gfx::Point(mouse_event.x, mouse_event.y)));
base::TimeTicks time_stamp = GetEventTimeStamp();
int flags = TranslateUiEventModifiers(mouse_event.modifiers);
int changed_button_flags = 0;
if (!mouseLeave) {
changed_button_flags = TranslateUiChangedButtonFlags(mouse_event.modifiers);
}
return ui::MouseEvent(event_type, location, root_location, time_stamp, flags,
changed_button_flags);
}
ui::MouseWheelEvent CefBrowserPlatformDelegateNativeAura::TranslateUiWheelEvent(
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const {
gfx::Vector2d offset(GetUiWheelEventOffset(deltaX, deltaY));
DCHECK(!offset.IsZero());
gfx::PointF location(mouse_event.x, mouse_event.y);
gfx::PointF root_location(
GetScreenPoint(gfx::Point(mouse_event.x, mouse_event.y)));
base::TimeTicks time_stamp = GetEventTimeStamp();
int flags = TranslateUiEventModifiers(mouse_event.modifiers);
int changed_button_flags =
TranslateUiChangedButtonFlags(mouse_event.modifiers);
return ui::MouseWheelEvent(offset, location, root_location, time_stamp,
(ui::EF_PRECISION_SCROLLING_DELTA | flags),
changed_button_flags);
}
gfx::Vector2d CefBrowserPlatformDelegateNativeAura::GetUiWheelEventOffset(
int deltaX,
int deltaY) const {
return gfx::Vector2d(deltaX, deltaY);
}
// static
int CefBrowserPlatformDelegateNativeAura::TranslateUiEventModifiers(
uint32 cef_modifiers) {
int result = 0;
// Set modifiers based on key state.
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
result |= ui::EF_SHIFT_DOWN;
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
result |= ui::EF_CONTROL_DOWN;
if (cef_modifiers & EVENTFLAG_ALT_DOWN)
result |= ui::EF_ALT_DOWN;
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
result |= ui::EF_COMMAND_DOWN;
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result |= ui::EF_LEFT_MOUSE_BUTTON;
if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result |= ui::EF_MIDDLE_MOUSE_BUTTON;
if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result |= ui::EF_RIGHT_MOUSE_BUTTON;
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
result |= ui::EF_CAPS_LOCK_ON;
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
result |= ui::EF_NUM_LOCK_ON;
if (cef_modifiers & EVENTFLAG_ALTGR_DOWN)
result |= ui::EF_ALTGR_DOWN;
return result;
}
// static
int CefBrowserPlatformDelegateNativeAura::TranslateUiChangedButtonFlags(
uint32 cef_modifiers) {
int result = 0;
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result |= ui::EF_LEFT_MOUSE_BUTTON;
else if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result |= ui::EF_MIDDLE_MOUSE_BUTTON;
else if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result |= ui::EF_RIGHT_MOUSE_BUTTON;
return result;
}
content::RenderWidgetHostViewAura*
CefBrowserPlatformDelegateNativeAura::GetHostView() const {
return static_cast<content::RenderWidgetHostViewAura*>(
browser_->web_contents()->GetRenderWidgetHostView());
}

View File

@@ -1,81 +0,0 @@
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_AURA_H_
#define CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_AURA_H_
#include "libcef/browser/native/browser_platform_delegate_native.h"
#include "ui/events/event.h"
namespace content {
class RenderWidgetHostViewAura;
}
namespace gfx {
class Vector2d;
}
// Windowed browser implementation for Aura platforms.
class CefBrowserPlatformDelegateNativeAura
: public CefBrowserPlatformDelegateNative {
public:
CefBrowserPlatformDelegateNativeAura(const CefWindowInfo& window_info,
SkColor background_color,
bool use_shared_texture,
bool use_external_begin_frame);
// CefBrowserPlatformDelegate methods:
void SendKeyEvent(const CefKeyEvent& event) override;
void SendMouseClickEvent(const CefMouseEvent& event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) override;
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
void SendMouseWheelEvent(const CefMouseEvent& event,
int deltaX,
int deltaY) override;
void SendTouchEvent(const CefTouchEvent& event) override;
// CefBrowserPlatformDelegateNative methods:
content::NativeWebKeyboardEvent TranslateWebKeyEvent(
const CefKeyEvent& key_event) const override;
blink::WebMouseEvent TranslateWebClickEvent(
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const override;
blink::WebMouseEvent TranslateWebMoveEvent(const CefMouseEvent& mouse_event,
bool mouseLeave) const override;
blink::WebMouseWheelEvent TranslateWebWheelEvent(
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const override;
// Translate CEF events to Chromium UI events.
virtual ui::KeyEvent TranslateUiKeyEvent(
const CefKeyEvent& key_event) const = 0;
virtual ui::MouseEvent TranslateUiClickEvent(
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const;
virtual ui::MouseEvent TranslateUiMoveEvent(const CefMouseEvent& mouse_event,
bool mouseLeave) const;
virtual ui::MouseWheelEvent TranslateUiWheelEvent(
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const;
virtual gfx::Vector2d GetUiWheelEventOffset(int deltaX, int deltaY) const;
virtual base::TimeTicks GetEventTimeStamp() const = 0;
protected:
static int TranslateUiEventModifiers(uint32 cef_modifiers);
static int TranslateUiChangedButtonFlags(uint32 cef_modifiers);
private:
content::RenderWidgetHostViewAura* GetHostView() const;
};
#endif // CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_AURA_H_

View File

@@ -46,10 +46,10 @@ CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux(
const CefWindowInfo& window_info, const CefWindowInfo& window_info,
SkColor background_color, SkColor background_color,
bool use_external_begin_frame) bool use_external_begin_frame)
: CefBrowserPlatformDelegateNativeAura(window_info, : CefBrowserPlatformDelegateNative(window_info,
background_color, background_color,
false, false,
use_external_begin_frame), use_external_begin_frame),
host_window_created_(false), host_window_created_(false),
window_widget_(nullptr) {} window_widget_(nullptr) {}
@@ -256,10 +256,133 @@ bool CefBrowserPlatformDelegateNativeLinux::HandleKeyboardEvent(
// static // static
void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {} void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {}
void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const {
result.windows_key_code = key_event.windows_key_code;
result.native_key_code = key_event.native_key_code;
result.is_system_key = key_event.is_system_key ? 1 : 0;
switch (key_event.type) {
case KEYEVENT_RAWKEYDOWN:
case KEYEVENT_KEYDOWN:
result.SetType(blink::WebInputEvent::kRawKeyDown);
break;
case KEYEVENT_KEYUP:
result.SetType(blink::WebInputEvent::kKeyUp);
break;
case KEYEVENT_CHAR:
result.SetType(blink::WebInputEvent::kChar);
break;
default:
NOTREACHED();
}
#if defined(USE_X11)
// Populate DOM values that will be passed to JavaScript handlers via
// KeyboardEvent.
result.dom_code = static_cast<int>(
ui::KeycodeConverter::NativeKeycodeToDomCode(key_event.native_key_code));
int keysym = ui::XKeysymForWindowsKeyCode(
static_cast<ui::KeyboardCode>(key_event.windows_key_code),
!!(key_event.modifiers & EVENTFLAG_SHIFT_DOWN));
base::char16 ch = ui::GetUnicodeCharacterFromXKeySym(keysym);
result.dom_key = static_cast<int>(ui::XKeySymToDomKey(keysym, ch));
result.text[0] = key_event.character;
result.unmodified_text[0] = key_event.unmodified_character;
result.SetModifiers(result.GetModifiers() |
TranslateModifiers(key_event.modifiers));
#endif // defined(USE_X11)
}
void CefBrowserPlatformDelegateNativeLinux::TranslateClickEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const {
TranslateMouseEvent(result, mouse_event);
switch (type) {
case MBT_LEFT:
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
: blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::kLeft;
break;
case MBT_MIDDLE:
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
: blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::kMiddle;
break;
case MBT_RIGHT:
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
: blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::kRight;
break;
default:
NOTREACHED();
}
result.click_count = clickCount;
}
void CefBrowserPlatformDelegateNativeLinux::TranslateMoveEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
bool mouseLeave) const {
TranslateMouseEvent(result, mouse_event);
if (!mouseLeave) {
result.SetType(blink::WebInputEvent::kMouseMove);
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kLeft;
else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kMiddle;
else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kRight;
else
result.button = blink::WebMouseEvent::Button::kNoButton;
} else {
result.SetType(blink::WebInputEvent::kMouseLeave);
result.button = blink::WebMouseEvent::Button::kNoButton;
}
result.click_count = 0;
}
void CefBrowserPlatformDelegateNativeLinux::TranslateWheelEvent(
blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const {
result = blink::WebMouseWheelEvent();
TranslateMouseEvent(result, mouse_event);
result.SetType(blink::WebInputEvent::kMouseWheel);
static const double scrollbarPixelsPerGtkTick = 40.0;
result.delta_x = deltaX;
result.delta_y = deltaY;
result.wheel_ticks_x = deltaX / scrollbarPixelsPerGtkTick;
result.wheel_ticks_y = deltaY / scrollbarPixelsPerGtkTick;
result.delta_units =
ui::input_types::ScrollGranularity::kScrollByPrecisePixel;
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kLeft;
else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kMiddle;
else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kRight;
else
result.button = blink::WebMouseEvent::Button::kNoButton;
}
CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle( CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const { const content::NativeWebKeyboardEvent& event) const {
if (!event.os_event) if (!event.os_event)
return nullptr; return NULL;
return const_cast<CefEventHandle>( return const_cast<CefEventHandle>(
static_cast<CefEventHandle>(event.os_event->native_event())); static_cast<CefEventHandle>(event.os_event->native_event()));
} }
@@ -269,6 +392,27 @@ CefBrowserPlatformDelegateNativeLinux::CreateMenuRunner() {
return base::WrapUnique(new CefMenuRunnerLinux); return base::WrapUnique(new CefMenuRunnerLinux);
} }
void CefBrowserPlatformDelegateNativeLinux::TranslateMouseEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event) const {
// position
result.SetPositionInWidget(mouse_event.x, mouse_event.y);
const gfx::Point& screen_pt =
GetScreenPoint(gfx::Point(mouse_event.x, mouse_event.y));
result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
// modifiers
result.SetModifiers(result.GetModifiers() |
TranslateModifiers(mouse_event.modifiers));
// timestamp
result.SetTimeStamp(base::TimeTicks() +
base::TimeDelta::FromSeconds(GetSystemUptime()));
result.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
}
gfx::Point CefBrowserPlatformDelegateNativeLinux::GetDialogPosition( gfx::Point CefBrowserPlatformDelegateNativeLinux::GetDialogPosition(
const gfx::Size& size) { const gfx::Size& size) {
const gfx::Size& max_size = GetMaximumDialogSize(); const gfx::Size& max_size = GetMaximumDialogSize();
@@ -279,51 +423,3 @@ gfx::Point CefBrowserPlatformDelegateNativeLinux::GetDialogPosition(
gfx::Size CefBrowserPlatformDelegateNativeLinux::GetMaximumDialogSize() { gfx::Size CefBrowserPlatformDelegateNativeLinux::GetMaximumDialogSize() {
return GetWindowWidget()->GetWindowBoundsInScreen().size(); return GetWindowWidget()->GetWindowBoundsInScreen().size();
} }
ui::KeyEvent CefBrowserPlatformDelegateNativeLinux::TranslateUiKeyEvent(
const CefKeyEvent& key_event) const {
int flags = TranslateUiEventModifiers(key_event.modifiers);
ui::KeyboardCode key_code =
static_cast<ui::KeyboardCode>(key_event.windows_key_code);
ui::DomCode dom_code =
ui::KeycodeConverter::NativeKeycodeToDomCode(key_event.native_key_code);
int keysym = ui::XKeysymForWindowsKeyCode(
key_code, !!(key_event.modifiers & EVENTFLAG_SHIFT_DOWN));
base::char16 character = ui::GetUnicodeCharacterFromXKeySym(keysym);
base::TimeTicks time_stamp = GetEventTimeStamp();
if (key_event.type == KEYEVENT_CHAR) {
return ui::KeyEvent(character, key_code, dom_code, flags, time_stamp);
}
ui::EventType type = ui::ET_UNKNOWN;
switch (key_event.type) {
case KEYEVENT_RAWKEYDOWN:
case KEYEVENT_KEYDOWN:
type = ui::ET_KEY_PRESSED;
break;
case KEYEVENT_KEYUP:
type = ui::ET_KEY_RELEASED;
break;
default:
NOTREACHED();
}
ui::DomKey dom_key = ui::XKeySymToDomKey(keysym, character);
return ui::KeyEvent(type, key_code, dom_code, flags, dom_key, time_stamp);
}
content::NativeWebKeyboardEvent
CefBrowserPlatformDelegateNativeLinux::TranslateWebKeyEvent(
const CefKeyEvent& key_event) const {
ui::KeyEvent ui_event = TranslateUiKeyEvent(key_event);
if (key_event.type == KEYEVENT_CHAR) {
return content::NativeWebKeyboardEvent(ui_event, key_event.character);
}
return content::NativeWebKeyboardEvent(ui_event);
}
base::TimeTicks CefBrowserPlatformDelegateNativeLinux::GetEventTimeStamp()
const {
return base::TimeTicks() + base::TimeDelta::FromSeconds(GetSystemUptime());
}

View File

@@ -5,7 +5,7 @@
#ifndef CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_LINUX_H_ #ifndef CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_LINUX_H_
#define CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_LINUX_H_ #define CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_LINUX_H_
#include "libcef/browser/native/browser_platform_delegate_native_aura.h" #include "libcef/browser/native/browser_platform_delegate_native.h"
#if defined(USE_X11) #if defined(USE_X11)
class CefWindowX11; class CefWindowX11;
@@ -13,7 +13,7 @@ class CefWindowX11;
// Windowed browser implementation for Linux. // Windowed browser implementation for Linux.
class CefBrowserPlatformDelegateNativeLinux class CefBrowserPlatformDelegateNativeLinux
: public CefBrowserPlatformDelegateNativeAura { : public CefBrowserPlatformDelegateNative {
public: public:
CefBrowserPlatformDelegateNativeLinux(const CefWindowInfo& window_info, CefBrowserPlatformDelegateNativeLinux(const CefWindowInfo& window_info,
SkColor background_color, SkColor background_color,
@@ -32,19 +32,30 @@ class CefBrowserPlatformDelegateNativeLinux
void ViewText(const std::string& text) override; void ViewText(const std::string& text) override;
bool HandleKeyboardEvent( bool HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override; const content::NativeWebKeyboardEvent& event) override;
void TranslateKeyEvent(content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const override;
void TranslateClickEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const override;
void TranslateMoveEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
bool mouseLeave) const override;
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const override;
CefEventHandle GetEventHandle( CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override; const content::NativeWebKeyboardEvent& event) const override;
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override; std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
gfx::Point GetDialogPosition(const gfx::Size& size) override; gfx::Point GetDialogPosition(const gfx::Size& size) override;
gfx::Size GetMaximumDialogSize() override; gfx::Size GetMaximumDialogSize() override;
// CefBrowserPlatformDelegateNativeAura methods:
ui::KeyEvent TranslateUiKeyEvent(const CefKeyEvent& key_event) const override;
content::NativeWebKeyboardEvent TranslateWebKeyEvent(
const CefKeyEvent& key_event) const override;
base::TimeTicks GetEventTimeStamp() const override;
private: private:
void TranslateMouseEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event) const;
// True if the host window has been created. // True if the host window has been created.
bool host_window_created_; bool host_window_created_;

View File

@@ -7,10 +7,6 @@
#include "libcef/browser/native/browser_platform_delegate_native.h" #include "libcef/browser/native/browser_platform_delegate_native.h"
namespace content {
class RenderWidgetHostViewMac;
}
// Windowed browser implementation for Mac OS X. // Windowed browser implementation for Mac OS X.
class CefBrowserPlatformDelegateNativeMac class CefBrowserPlatformDelegateNativeMac
: public CefBrowserPlatformDelegateNative { : public CefBrowserPlatformDelegateNative {
@@ -23,21 +19,25 @@ class CefBrowserPlatformDelegateNativeMac
bool CreateHostWindow() override; bool CreateHostWindow() override;
void CloseHostWindow() override; void CloseHostWindow() override;
CefWindowHandle GetHostWindowHandle() const override; CefWindowHandle GetHostWindowHandle() const override;
void SendKeyEvent(const CefKeyEvent& event) override;
void SendMouseClickEvent(const CefMouseEvent& event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) override;
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
void SendMouseWheelEvent(const CefMouseEvent& event,
int deltaX,
int deltaY) override;
void SendTouchEvent(const CefTouchEvent& event) override;
void SendFocusEvent(bool setFocus) override; void SendFocusEvent(bool setFocus) override;
gfx::Point GetScreenPoint(const gfx::Point& view) const override; gfx::Point GetScreenPoint(const gfx::Point& view) const override;
void ViewText(const std::string& text) override; void ViewText(const std::string& text) override;
bool HandleKeyboardEvent( bool HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override; const content::NativeWebKeyboardEvent& event) override;
void TranslateKeyEvent(content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const override;
void TranslateClickEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const override;
void TranslateMoveEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
bool mouseLeave) const override;
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const override;
CefEventHandle GetEventHandle( CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override; const content::NativeWebKeyboardEvent& event) const override;
std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override; std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override;
@@ -47,26 +47,9 @@ class CefBrowserPlatformDelegateNativeMac
gfx::Point GetDialogPosition(const gfx::Size& size) override; gfx::Point GetDialogPosition(const gfx::Size& size) override;
gfx::Size GetMaximumDialogSize() override; gfx::Size GetMaximumDialogSize() override;
// CefBrowserPlatformDelegateNative methods:
content::NativeWebKeyboardEvent TranslateWebKeyEvent(
const CefKeyEvent& key_event) const override;
blink::WebMouseEvent TranslateWebClickEvent(
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const override;
blink::WebMouseEvent TranslateWebMoveEvent(const CefMouseEvent& mouse_event,
bool mouseLeave) const override;
blink::WebMouseWheelEvent TranslateWebWheelEvent(
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const override;
private: private:
void TranslateWebMouseEvent(blink::WebMouseEvent& result, void TranslateMouseEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event) const; const CefMouseEvent& mouse_event) const;
content::RenderWidgetHostViewMac* GetHostView() const;
// True if the host window has been created. // True if the host window has been created.
bool host_window_created_; bool host_window_created_;

View File

@@ -17,16 +17,14 @@
#include "base/mac/scoped_nsautorelease_pool.h" #include "base/mac/scoped_nsautorelease_pool.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "content/browser/renderer_host/render_widget_host_view_mac.h"
#include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "third_party/blink/public/common/input/web_input_event.h" #include "third_party/blink/public/platform/web_input_event.h"
#include "third_party/blink/public/common/input/web_mouse_event.h" #include "third_party/blink/public/platform/web_mouse_event.h"
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h" #include "third_party/blink/public/platform/web_mouse_wheel_event.h"
#import "ui/base/cocoa/cocoa_base_utils.h" #import "ui/base/cocoa/cocoa_base_utils.h"
#import "ui/base/cocoa/underlay_opengl_hosting_window.h" #import "ui/base/cocoa/underlay_opengl_hosting_window.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/keycodes/keyboard_codes_posix.h" #include "ui/events/keycodes/keyboard_codes_posix.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
@@ -257,61 +255,9 @@ CefWindowHandle CefBrowserPlatformDelegateNativeMac::GetHostWindowHandle()
return window_info_.view; return window_info_.view;
} }
void CefBrowserPlatformDelegateNativeMac::SendKeyEvent(
const CefKeyEvent& event) {
auto view = GetHostView();
if (!view)
return;
content::NativeWebKeyboardEvent web_event = TranslateWebKeyEvent(event);
view->ForwardKeyboardEvent(web_event, ui::LatencyInfo());
}
void CefBrowserPlatformDelegateNativeMac::SendMouseClickEvent(
const CefMouseEvent& event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) {
auto view = GetHostView();
if (!view)
return;
blink::WebMouseEvent web_event =
TranslateWebClickEvent(event, type, mouseUp, clickCount);
view->RouteOrProcessMouseEvent(web_event);
}
void CefBrowserPlatformDelegateNativeMac::SendMouseMoveEvent(
const CefMouseEvent& event,
bool mouseLeave) {
auto view = GetHostView();
if (!view)
return;
blink::WebMouseEvent web_event = TranslateWebMoveEvent(event, mouseLeave);
view->RouteOrProcessMouseEvent(web_event);
}
void CefBrowserPlatformDelegateNativeMac::SendMouseWheelEvent(
const CefMouseEvent& event,
int deltaX,
int deltaY) {
auto view = GetHostView();
if (!view)
return;
blink::WebMouseWheelEvent web_event =
TranslateWebWheelEvent(event, deltaX, deltaY);
view->RouteOrProcessMouseEvent(web_event);
}
void CefBrowserPlatformDelegateNativeMac::SendTouchEvent(
const CefTouchEvent& event) {
NOTIMPLEMENTED();
}
void CefBrowserPlatformDelegateNativeMac::SendFocusEvent(bool setFocus) { void CefBrowserPlatformDelegateNativeMac::SendFocusEvent(bool setFocus) {
auto view = GetHostView(); content::RenderWidgetHostView* view =
browser_->web_contents()->GetRenderWidgetHostView();
if (view) { if (view) {
view->SetActive(setFocus); view->SetActive(setFocus);
@@ -358,51 +304,15 @@ bool CefBrowserPlatformDelegateNativeMac::HandleKeyboardEvent(
// static // static
void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {} void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {}
CefEventHandle CefBrowserPlatformDelegateNativeMac::GetEventHandle( void CefBrowserPlatformDelegateNativeMac::TranslateKeyEvent(
const content::NativeWebKeyboardEvent& event) const { content::NativeWebKeyboardEvent& result,
return event.os_event;
}
std::unique_ptr<CefFileDialogRunner>
CefBrowserPlatformDelegateNativeMac::CreateFileDialogRunner() {
return base::WrapUnique(new CefFileDialogRunnerMac);
}
std::unique_ptr<CefJavaScriptDialogRunner>
CefBrowserPlatformDelegateNativeMac::CreateJavaScriptDialogRunner() {
return base::WrapUnique(new CefJavaScriptDialogRunnerMac);
}
std::unique_ptr<CefMenuRunner>
CefBrowserPlatformDelegateNativeMac::CreateMenuRunner() {
return base::WrapUnique(new CefMenuRunnerMac);
}
gfx::Point CefBrowserPlatformDelegateNativeMac::GetDialogPosition(
const gfx::Size& size) {
// Dialogs are always re-positioned by the constrained window sheet controller
// so nothing interesting to return yet.
return gfx::Point();
}
gfx::Size CefBrowserPlatformDelegateNativeMac::GetMaximumDialogSize() {
// The dialog should try to fit within the overlay for the web contents.
// Note that, for things like print preview, this is just a suggested maximum.
return browser_->web_contents()->GetContainerBounds().size();
}
content::NativeWebKeyboardEvent
CefBrowserPlatformDelegateNativeMac::TranslateWebKeyEvent(
const CefKeyEvent& key_event) const { const CefKeyEvent& key_event) const {
content::NativeWebKeyboardEvent result(blink::WebInputEvent::kUndefined,
blink::WebInputEvent::kNoModifiers,
ui::EventTimeForNow());
// Use a synthetic NSEvent in order to obtain the windowsKeyCode member from // Use a synthetic NSEvent in order to obtain the windowsKeyCode member from
// the NativeWebKeyboardEvent constructor. This is the only member which can // the NativeWebKeyboardEvent constructor. This is the only member which can
// not be easily translated (without hardcoding keyCodes) // not be easily translated (without hardcoding keyCodes)
// Determining whether a modifier key is left or right seems to be done // Determining whether a modifier key is left or right seems to be done
// through the key code as well. // through the key code as well.
NSEventType event_type; NSEventType event_type;
if (key_event.character == 0 && key_event.unmodified_character == 0) { if (key_event.character == 0 && key_event.unmodified_character == 0) {
// Check if both character and unmodified_characther are empty to determine // Check if both character and unmodified_characther are empty to determine
@@ -447,18 +357,15 @@ CefBrowserPlatformDelegateNativeMac::TranslateWebKeyEvent(
result.SetType(blink::WebInputEvent::kChar); result.SetType(blink::WebInputEvent::kChar);
result.is_system_key = key_event.is_system_key; result.is_system_key = key_event.is_system_key;
return result;
} }
blink::WebMouseEvent void CefBrowserPlatformDelegateNativeMac::TranslateClickEvent(
CefBrowserPlatformDelegateNativeMac::TranslateWebClickEvent( blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event, const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type, CefBrowserHost::MouseButtonType type,
bool mouseUp, bool mouseUp,
int clickCount) const { int clickCount) const {
blink::WebMouseEvent result; TranslateMouseEvent(result, mouse_event);
TranslateWebMouseEvent(result, mouse_event);
switch (type) { switch (type) {
case MBT_LEFT: case MBT_LEFT:
@@ -481,15 +388,13 @@ CefBrowserPlatformDelegateNativeMac::TranslateWebClickEvent(
} }
result.click_count = clickCount; result.click_count = clickCount;
return result;
} }
blink::WebMouseEvent CefBrowserPlatformDelegateNativeMac::TranslateWebMoveEvent( void CefBrowserPlatformDelegateNativeMac::TranslateMoveEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event, const CefMouseEvent& mouse_event,
bool mouseLeave) const { bool mouseLeave) const {
blink::WebMouseEvent result; TranslateMouseEvent(result, mouse_event);
TranslateWebMouseEvent(result, mouse_event);
if (!mouseLeave) { if (!mouseLeave) {
result.SetType(blink::WebInputEvent::kMouseMove); result.SetType(blink::WebInputEvent::kMouseMove);
@@ -507,17 +412,15 @@ blink::WebMouseEvent CefBrowserPlatformDelegateNativeMac::TranslateWebMoveEvent(
} }
result.click_count = 0; result.click_count = 0;
return result;
} }
blink::WebMouseWheelEvent void CefBrowserPlatformDelegateNativeMac::TranslateWheelEvent(
CefBrowserPlatformDelegateNativeMac::TranslateWebWheelEvent( blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event, const CefMouseEvent& mouse_event,
int deltaX, int deltaX,
int deltaY) const { int deltaY) const {
blink::WebMouseWheelEvent result; result = blink::WebMouseWheelEvent();
TranslateWebMouseEvent(result, mouse_event); TranslateMouseEvent(result, mouse_event);
result.SetType(blink::WebInputEvent::kMouseWheel); result.SetType(blink::WebInputEvent::kMouseWheel);
@@ -526,8 +429,7 @@ CefBrowserPlatformDelegateNativeMac::TranslateWebWheelEvent(
result.delta_y = deltaY; result.delta_y = deltaY;
result.wheel_ticks_x = deltaX / scrollbarPixelsPerCocoaTick; result.wheel_ticks_x = deltaX / scrollbarPixelsPerCocoaTick;
result.wheel_ticks_y = deltaY / scrollbarPixelsPerCocoaTick; result.wheel_ticks_y = deltaY / scrollbarPixelsPerCocoaTick;
result.delta_units = result.delta_units = ui::input_types::ScrollGranularity::kScrollByPrecisePixel;
ui::input_types::ScrollGranularity::kScrollByPrecisePixel;
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kLeft; result.button = blink::WebMouseEvent::Button::kLeft;
@@ -537,11 +439,29 @@ CefBrowserPlatformDelegateNativeMac::TranslateWebWheelEvent(
result.button = blink::WebMouseEvent::Button::kRight; result.button = blink::WebMouseEvent::Button::kRight;
else else
result.button = blink::WebMouseEvent::Button::kNoButton; result.button = blink::WebMouseEvent::Button::kNoButton;
return result;
} }
void CefBrowserPlatformDelegateNativeMac::TranslateWebMouseEvent( CefEventHandle CefBrowserPlatformDelegateNativeMac::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const {
return event.os_event;
}
std::unique_ptr<CefFileDialogRunner>
CefBrowserPlatformDelegateNativeMac::CreateFileDialogRunner() {
return base::WrapUnique(new CefFileDialogRunnerMac);
}
std::unique_ptr<CefJavaScriptDialogRunner>
CefBrowserPlatformDelegateNativeMac::CreateJavaScriptDialogRunner() {
return base::WrapUnique(new CefJavaScriptDialogRunnerMac);
}
std::unique_ptr<CefMenuRunner>
CefBrowserPlatformDelegateNativeMac::CreateMenuRunner() {
return base::WrapUnique(new CefMenuRunnerMac);
}
void CefBrowserPlatformDelegateNativeMac::TranslateMouseEvent(
blink::WebMouseEvent& result, blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event) const { const CefMouseEvent& mouse_event) const {
// position // position
@@ -553,17 +473,24 @@ void CefBrowserPlatformDelegateNativeMac::TranslateWebMouseEvent(
// modifiers // modifiers
result.SetModifiers(result.GetModifiers() | result.SetModifiers(result.GetModifiers() |
TranslateWebEventModifiers(mouse_event.modifiers)); TranslateModifiers(mouse_event.modifiers));
// timestamp // timestamp - Mac OSX specific
result.SetTimeStamp(base::TimeTicks() + result.SetTimeStamp(base::TimeTicks() +
base::TimeDelta::FromSeconds(currentEventTimestamp())); base::TimeDelta::FromSeconds(currentEventTimestamp()));
result.pointer_type = blink::WebPointerProperties::PointerType::kMouse; result.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
} }
content::RenderWidgetHostViewMac* gfx::Point CefBrowserPlatformDelegateNativeMac::GetDialogPosition(
CefBrowserPlatformDelegateNativeMac::GetHostView() const { const gfx::Size& size) {
return static_cast<content::RenderWidgetHostViewMac*>( // Dialogs are always re-positioned by the constrained window sheet controller
browser_->web_contents()->GetRenderWidgetHostView()); // so nothing interesting to return yet.
return gfx::Point();
}
gfx::Size CefBrowserPlatformDelegateNativeMac::GetMaximumDialogSize() {
// The dialog should try to fit within the overlay for the web contents.
// Note that, for things like print preview, this is just a suggested maximum.
return browser_->web_contents()->GetContainerBounds().size();
} }

View File

@@ -22,8 +22,8 @@
#include "base/win/registry.h" #include "base/win/registry.h"
#include "base/win/win_util.h" #include "base/win/win_util.h"
#include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/native_web_keyboard_event.h"
#include "third_party/blink/public/common/input/web_mouse_event.h" #include "third_party/blink/public/platform/web_mouse_event.h"
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h" #include "third_party/blink/public/platform/web_mouse_wheel_event.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/win/shell.h" #include "ui/base/win/shell.h"
#include "ui/display/display.h" #include "ui/display/display.h"
@@ -32,7 +32,6 @@
#include "ui/events/keycodes/dom/keycode_converter.h" #include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion_win.h" #include "ui/events/keycodes/keyboard_code_conversion_win.h"
#include "ui/events/keycodes/platform_key_map_win.h" #include "ui/events/keycodes/platform_key_map_win.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/win/hwnd_util.h" #include "ui/gfx/win/hwnd_util.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
@@ -129,10 +128,10 @@ CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin(
SkColor background_color, SkColor background_color,
bool use_shared_texture, bool use_shared_texture,
bool use_external_begin_frame) bool use_external_begin_frame)
: CefBrowserPlatformDelegateNativeAura(window_info, : CefBrowserPlatformDelegateNative(window_info,
background_color, background_color,
use_shared_texture, use_shared_texture,
use_external_begin_frame), use_external_begin_frame),
host_window_created_(false), host_window_created_(false),
window_widget_(nullptr) {} window_widget_(nullptr) {}
@@ -405,6 +404,153 @@ void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {
CEF_POST_USER_VISIBLE_TASK(base::Bind(ExecuteExternalProtocol, url)); CEF_POST_USER_VISIBLE_TASK(base::Bind(ExecuteExternalProtocol, url));
} }
void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const {
result.windows_key_code = key_event.windows_key_code;
result.native_key_code = key_event.native_key_code;
result.is_system_key = key_event.is_system_key ? 1 : 0;
switch (key_event.type) {
case KEYEVENT_RAWKEYDOWN:
case KEYEVENT_KEYDOWN:
result.SetType(blink::WebInputEvent::kRawKeyDown);
break;
case KEYEVENT_KEYUP:
result.SetType(blink::WebInputEvent::kKeyUp);
break;
case KEYEVENT_CHAR:
result.SetType(blink::WebInputEvent::kChar);
break;
default:
NOTREACHED();
}
// Populate DOM values that will be passed to JavaScript handlers via
// KeyboardEvent.
result.dom_code = static_cast<int>(
ui::KeycodeConverter::NativeKeycodeToDomCode(key_event.native_key_code));
if (result.GetType() == blink::WebInputEvent::kChar) {
result.dom_key = ui::DomKey::FromCharacter(key_event.windows_key_code);
} else {
// TODO(cef): CefKeyEvent does not currently pass extended key status (see
// WM_KEYDOWN docs) which would be necessary to pass EF_IS_EXTENDED_KEY as
// the |flags| parameter to DomKeyFromKeyboardCode().
int flags = 0;
result.dom_key = ui::PlatformKeyMap::DomKeyFromKeyboardCode(
ui::KeyboardCodeForWindowsKeyCode(key_event.windows_key_code), &flags);
}
if (result.GetType() == blink::WebInputEvent::kChar ||
result.GetType() == blink::WebInputEvent::kRawKeyDown) {
result.text[0] = result.windows_key_code;
result.unmodified_text[0] = result.windows_key_code;
}
result.SetModifiers(result.GetModifiers() |
TranslateModifiers(key_event.modifiers));
}
void CefBrowserPlatformDelegateNativeWin::TranslateClickEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const {
TranslateMouseEvent(result, mouse_event);
switch (type) {
case MBT_LEFT:
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
: blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::kLeft;
break;
case MBT_MIDDLE:
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
: blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::kMiddle;
break;
case MBT_RIGHT:
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
: blink::WebInputEvent::kMouseDown);
result.button = blink::WebMouseEvent::Button::kRight;
break;
default:
NOTREACHED();
}
result.click_count = clickCount;
}
void CefBrowserPlatformDelegateNativeWin::TranslateMoveEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
bool mouseLeave) const {
TranslateMouseEvent(result, mouse_event);
if (!mouseLeave) {
result.SetType(blink::WebInputEvent::kMouseMove);
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kLeft;
else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kMiddle;
else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kRight;
else
result.button = blink::WebMouseEvent::Button::kNoButton;
} else {
result.SetType(blink::WebInputEvent::kMouseLeave);
result.button = blink::WebMouseEvent::Button::kNoButton;
}
result.click_count = 0;
}
void CefBrowserPlatformDelegateNativeWin::TranslateWheelEvent(
blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const {
TranslateMouseEvent(result, mouse_event);
result.SetType(blink::WebInputEvent::kMouseWheel);
result.button = blink::WebMouseEvent::Button::kNoButton;
float wheelDelta;
bool horizontalScroll = false;
wheelDelta = static_cast<float>(deltaY ? deltaY : deltaX);
horizontalScroll = (deltaY == 0);
static const ULONG defaultScrollCharsPerWheelDelta = 1;
static const FLOAT scrollbarPixelsPerLine = 100.0f / 3.0f;
static const ULONG defaultScrollLinesPerWheelDelta = 3;
wheelDelta /= WHEEL_DELTA;
float scrollDelta = wheelDelta;
if (horizontalScroll) {
ULONG scrollChars = defaultScrollCharsPerWheelDelta;
SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0);
scrollDelta *= static_cast<FLOAT>(scrollChars) * scrollbarPixelsPerLine;
} else {
ULONG scrollLines = defaultScrollLinesPerWheelDelta;
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0);
if (scrollLines == WHEEL_PAGESCROLL)
result.delta_units = ui::input_types::ScrollGranularity::kScrollByPage;
if (result.delta_units != ui::input_types::ScrollGranularity::kScrollByPage)
scrollDelta *= static_cast<FLOAT>(scrollLines) * scrollbarPixelsPerLine;
}
// Set scroll amount based on above calculations. WebKit expects positive
// deltaY to mean "scroll up" and positive deltaX to mean "scroll left".
if (horizontalScroll) {
result.delta_x = scrollDelta;
result.wheel_ticks_x = wheelDelta;
} else {
result.delta_y = scrollDelta;
result.wheel_ticks_y = wheelDelta;
}
}
CefEventHandle CefBrowserPlatformDelegateNativeWin::GetEventHandle( CefEventHandle CefBrowserPlatformDelegateNativeWin::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const { const content::NativeWebKeyboardEvent& event) const {
if (!event.os_event) if (!event.os_event)
@@ -427,6 +573,27 @@ CefBrowserPlatformDelegateNativeWin::CreateMenuRunner() {
return base::WrapUnique(new CefMenuRunnerWin); return base::WrapUnique(new CefMenuRunnerWin);
} }
void CefBrowserPlatformDelegateNativeWin::TranslateMouseEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event) const {
// position
result.SetPositionInWidget(mouse_event.x, mouse_event.y);
const gfx::Point& screen_pt =
GetScreenPoint(gfx::Point(mouse_event.x, mouse_event.y));
result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
// modifiers
result.SetModifiers(result.GetModifiers() |
TranslateModifiers(mouse_event.modifiers));
// timestamp
result.SetTimeStamp(base::TimeTicks() +
base::TimeDelta::FromMilliseconds(GetMessageTime()));
result.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
}
gfx::Point CefBrowserPlatformDelegateNativeWin::GetDialogPosition( gfx::Point CefBrowserPlatformDelegateNativeWin::GetDialogPosition(
const gfx::Size& size) { const gfx::Size& size) {
const gfx::Size& max_size = GetMaximumDialogSize(); const gfx::Size& max_size = GetMaximumDialogSize();
@@ -438,66 +605,6 @@ gfx::Size CefBrowserPlatformDelegateNativeWin::GetMaximumDialogSize() {
return GetWindowWidget()->GetWindowBoundsInScreen().size(); return GetWindowWidget()->GetWindowBoundsInScreen().size();
} }
ui::KeyEvent CefBrowserPlatformDelegateNativeWin::TranslateUiKeyEvent(
const CefKeyEvent& key_event) const {
int flags = TranslateUiEventModifiers(key_event.modifiers);
ui::KeyboardCode key_code =
ui::KeyboardCodeForWindowsKeyCode(key_event.windows_key_code);
ui::DomCode dom_code =
ui::KeycodeConverter::NativeKeycodeToDomCode(key_event.native_key_code);
base::TimeTicks time_stamp = GetEventTimeStamp();
if (key_event.type == KEYEVENT_CHAR) {
return ui::KeyEvent(key_event.windows_key_code /* character */, key_code,
dom_code, flags, time_stamp);
}
ui::EventType type = ui::ET_UNKNOWN;
switch (key_event.type) {
case KEYEVENT_RAWKEYDOWN:
case KEYEVENT_KEYDOWN:
type = ui::ET_KEY_PRESSED;
break;
case KEYEVENT_KEYUP:
type = ui::ET_KEY_RELEASED;
break;
default:
NOTREACHED();
}
ui::DomKey dom_key =
ui::PlatformKeyMap::DomKeyFromKeyboardCode(key_code, &flags);
return ui::KeyEvent(type, key_code, dom_code, flags, dom_key, time_stamp);
}
gfx::Vector2d CefBrowserPlatformDelegateNativeWin::GetUiWheelEventOffset(
int deltaX,
int deltaY) const {
static const ULONG defaultScrollCharsPerWheelDelta = 1;
static const FLOAT scrollbarPixelsPerLine = 100.0f / 3.0f;
static const ULONG defaultScrollLinesPerWheelDelta = 3;
float wheelDeltaX = float(deltaX) / WHEEL_DELTA;
float wheelDeltaY = float(deltaY) / WHEEL_DELTA;
float scrollDeltaX = wheelDeltaX;
float scrollDeltaY = wheelDeltaY;
ULONG scrollChars = defaultScrollCharsPerWheelDelta;
SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0);
scrollDeltaX *= static_cast<FLOAT>(scrollChars) * scrollbarPixelsPerLine;
ULONG scrollLines = defaultScrollLinesPerWheelDelta;
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0);
scrollDeltaY *= static_cast<FLOAT>(scrollLines) * scrollbarPixelsPerLine;
return gfx::Vector2d(scrollDeltaX, scrollDeltaY);
}
base::TimeTicks CefBrowserPlatformDelegateNativeWin::GetEventTimeStamp() const {
return base::TimeTicks() +
base::TimeDelta::FromMilliseconds(GetMessageTime());
}
// static // static
void CefBrowserPlatformDelegateNativeWin::RegisterWindowClass() { void CefBrowserPlatformDelegateNativeWin::RegisterWindowClass() {
static bool registered = false; static bool registered = false;

View File

@@ -7,11 +7,11 @@
#include <windows.h> #include <windows.h>
#include "libcef/browser/native/browser_platform_delegate_native_aura.h" #include "libcef/browser/native/browser_platform_delegate_native.h"
// Windowed browser implementation for Windows. // Windowed browser implementation for Windows.
class CefBrowserPlatformDelegateNativeWin class CefBrowserPlatformDelegateNativeWin
: public CefBrowserPlatformDelegateNativeAura { : public CefBrowserPlatformDelegateNative {
public: public:
CefBrowserPlatformDelegateNativeWin(const CefWindowInfo& window_info, CefBrowserPlatformDelegateNativeWin(const CefWindowInfo& window_info,
SkColor background_color, SkColor background_color,
@@ -31,6 +31,20 @@ class CefBrowserPlatformDelegateNativeWin
void ViewText(const std::string& text) override; void ViewText(const std::string& text) override;
bool HandleKeyboardEvent( bool HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override; const content::NativeWebKeyboardEvent& event) override;
void TranslateKeyEvent(content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const override;
void TranslateClickEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const override;
void TranslateMoveEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
bool mouseLeave) const override;
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const override;
CefEventHandle GetEventHandle( CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override; const content::NativeWebKeyboardEvent& event) const override;
std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override; std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override;
@@ -40,12 +54,10 @@ class CefBrowserPlatformDelegateNativeWin
gfx::Point GetDialogPosition(const gfx::Size& size) override; gfx::Point GetDialogPosition(const gfx::Size& size) override;
gfx::Size GetMaximumDialogSize() override; gfx::Size GetMaximumDialogSize() override;
// CefBrowserPlatformDelegateNativeAura methods:
ui::KeyEvent TranslateUiKeyEvent(const CefKeyEvent& key_event) const override;
gfx::Vector2d GetUiWheelEventOffset(int deltaX, int deltaY) const override;
base::TimeTicks GetEventTimeStamp() const override;
private: private:
void TranslateMouseEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event) const;
static void RegisterWindowClass(); static void RegisterWindowClass();
static LPCTSTR GetWndClass(); static LPCTSTR GetWndClass();
static LRESULT CALLBACK WndProc(HWND hwnd, static LRESULT CALLBACK WndProc(HWND hwnd,

View File

@@ -9,10 +9,6 @@
#include "libcef/browser/file_dialog_runner.h" #include "libcef/browser/file_dialog_runner.h"
#include "base/memory/weak_ptr.h"
@class NSView;
class CefFileDialogRunnerMac : public CefFileDialogRunner { class CefFileDialogRunnerMac : public CefFileDialogRunner {
public: public:
CefFileDialogRunnerMac(); CefFileDialogRunnerMac();
@@ -21,21 +17,6 @@ class CefFileDialogRunnerMac : public CefFileDialogRunner {
void Run(CefBrowserHostImpl* browser, void Run(CefBrowserHostImpl* browser,
const FileChooserParams& params, const FileChooserParams& params,
RunFileChooserCallback callback) override; RunFileChooserCallback callback) override;
private:
static void RunOpenFileDialog(
base::WeakPtr<CefFileDialogRunnerMac> weak_this,
const CefFileDialogRunner::FileChooserParams& params,
NSView* view,
int filter_index);
static void RunSaveFileDialog(
base::WeakPtr<CefFileDialogRunnerMac> weak_this,
const CefFileDialogRunner::FileChooserParams& params,
NSView* view,
int filter_index);
CefFileDialogRunner::RunFileChooserCallback callback_;
base::WeakPtrFactory<CefFileDialogRunnerMac> weak_ptr_factory_;
}; };
#endif // CEF_LIBCEF_BROWSER_NATIVE_FILE_DIALOG_RUNNER_MAC_H_ #endif // CEF_LIBCEF_BROWSER_NATIVE_FILE_DIALOG_RUNNER_MAC_H_

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