Compare commits

...

52 Commits
3325 ... 3396

Author SHA1 Message Date
Marshall Greenblatt
d3e36d052c Adjust out-of-flow position for rtl container with left-hand scrollbar (see https://crbug.com/832569) 2018-07-19 13:40:34 -04:00
Marshall Greenblatt
a27bbfaa0e Fix passing of lang command-line flag to the renderer (issue #2468) 2018-07-09 16:11:16 -04:00
Marshall Greenblatt
45d779dc24 CefFrame::GetURL in the renderer process should return the provisional URL for popups during loading (issue #2448) 2018-07-09 14:44:22 -04:00
Kudo Chien
185623100e Fix PDF print and save buttons (issue #2463). 2018-07-05 14:35:12 -04:00
Marshall Greenblatt
c368dbf5ad Linux: cmake: Don't warn about code in comments (issue #2346) 2018-06-27 12:49:47 -04:00
Marshall Greenblatt
238e9184b4 Linux: Use poll instead of select to fix crash during startup (issue #2466) 2018-06-27 12:36:49 -04:00
Dan Kegel
514ced40ce Add missing overrides to v8_unittest.cc (issue #2465) 2018-06-25 16:16:42 +00:00
Marshall Greenblatt
36f9eab712 macOS: Fix crash during OSR browser creation (issue #2458) 2018-06-15 13:47:31 -04:00
Marshall Greenblatt
628b9db317 Windows: cmake: Add VS2017 15.6 & 15.7 build support 2018-06-12 14:42:08 -04:00
Marshall Greenblatt
636f29b188 Update to Chromium version 67.0.3396.79 2018-06-07 13:43:46 -04:00
Marshall Greenblatt
7b00e05714 Switch DevTools to the default view that doesn't show screencast 2018-06-07 13:00:33 -04:00
Marshall Greenblatt
5340bb0700 Remove duplicate entry for resource_util.h 2018-06-01 15:37:35 -04:00
Marshall Greenblatt
a4b18ef01c Add missing depenencies in chrome/services/media_gallery_util/public/cpp (see https://crbug.com/832591) 2018-06-01 10:13:12 -04:00
Marshall Greenblatt
c3a31f5f3e Update to Chromium version 67.0.3396.62 2018-05-31 20:15:16 -04:00
Marshall Greenblatt
71574ceb11 Add support for automate-git.py --fast-update (issue #2435) 2018-05-16 14:27:38 +03:00
Marshall Greenblatt
e21d57d8b3 Fix patching of files with Windows line endings on Posix systems 2018-05-15 13:38:16 +03:00
Marshall Greenblatt
64c0c9fc4c Fix incorrect whitespace in patch files (issue #2439) 2018-05-11 14:43:42 +03:00
Marshall Greenblatt
5bf920a639 Fix DCHECK due to unreliable is_main_frame state on XHR requests (issue #2433) 2018-05-04 16:43:26 +02:00
Marshall Greenblatt
141869aa17 Update to Chromium version 67.0.3396.30 2018-05-04 15:37:58 +02:00
Marshall Greenblatt
a3c55f1d26 Update to Chromium revision 9ef2aa86 (#550428) 2018-05-04 10:50:26 +02:00
Cristian Amarie
f6c9a96a12 Add missing space at the end of verbose build command (issue #2431). 2018-05-01 15:55:47 +00:00
Felix Bruns
4b33c17533 Add user_gesture parameter to OnBeforeBrowse (issue #1526) 2018-04-27 15:11:53 +00:00
Marshall Greenblatt
0677d0d9de Linux: Fix startup hang on Ubuntu 16.04.4 (issue #2424) 2018-04-13 21:21:17 -04:00
Marshall Greenblatt
64d86a7397 Linux: Fix ASAN link error: odr-violation: global 'typeinfo name for std::exception' (see https://crbug.com/832808) 2018-04-13 17:30:17 -04:00
Marshall Greenblatt
87e33b1692 Linux: Fix crash when closing popup after printing (issue #2422) 2018-04-12 14:35:57 -04:00
Christopher Cifra
4315f3b724 Add support for V8 ArrayBuffers (issue #244) 2018-04-10 16:05:19 -04:00
Mike Wiedenbauer
bb28b85bdd Add CefDisplayHandler::OnLoadingProgressChange callback (issue #2382) 2018-04-10 13:52:31 -04:00
Mike Wiedenbauer
90863b8c5d Add ability to stop CefURLRequest on redirect (issue #1329) 2018-04-10 13:05:18 -04:00
Mike Wiedenbauer
c3f5e6463c Add OSR text selection changed handler and remove hard-coded test bounds (issue #2383) 2018-04-09 13:50:19 -04:00
Marshall Greenblatt
b220672c42 Fix compile error due to commit acb0922 (issue #2415) 2018-04-02 17:17:40 -04:00
Marshall Greenblatt
acb0922500 Fix crashes loading chrome://system with extensions disabled (issue #2415) 2018-03-29 13:58:52 -04:00
Marshall Greenblatt
b44919e3c5 Allow empty username parameter to CefAuthCallback::Continue (issue #2275) 2018-03-28 19:29:28 -04:00
Marshall Greenblatt
a1f47abaf6 Don't include locales/*.info files in distribution (issue #2375) 2018-03-28 18:20:10 -04:00
Marshall Greenblatt
ff8aa46e5e Support override of crash_reporter.cfg settings with environment variables (issue #2413) 2018-03-28 17:15:05 -04:00
Marshall Greenblatt
d4ec164297 Windows: Fix crash report upload failure on Windows 7 (see https://crbug.com/826564). 2018-03-28 16:02:11 -04:00
John Mayhew
e312a35ef3 Change CefFrame::GetName() to return assigned name if it is non-empty before returning unique name (issue #2403) 2018-03-28 17:30:15 +00:00
Marshall Greenblatt
3018e1866b Linux: Update to Debian sid sysroot (issue #2409) 2018-03-28 12:42:55 -04:00
Marshall Greenblatt
7a59914f97 Update to Chromium revision 66afc5e5 (#540276) 2018-03-22 16:56:23 -04:00
Marshall Greenblatt
4fb6e1ba29 macOS: Fix undesirable switch to discrete GPU during startup (issue #2398) 2018-03-16 14:04:16 -04:00
Marshall Greenblatt
e030236c36 Add CefCookieManager::GetBlockingManager (issue #2374) 2018-03-14 21:40:37 -04:00
Marshall Greenblatt
a98c6b1f52 Linux: Fix creation of client distribution 2018-03-08 10:55:05 -05:00
Marshall Greenblatt
5b136976e9 Revert "Linux: Add missing build dependency"
This commit causes the following build error when use_sysroot=true:

../../third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc:17:10: fatal error: 'curl/curl.h' file not found
         ^~~~~~~~~~~~~
1 error generated.

This reverts commit cd6ff760dd.
2018-03-08 10:54:57 -05:00
Marshall Greenblatt
56bbee8efb cmake: Linux: Add missing binaries (issue #2394) 2018-02-27 15:37:19 -05:00
Marshall Greenblatt
cd6ff760dd Linux: Add missing build dependency 2018-02-27 12:31:13 -05:00
Alfred Reynolds
5caccda56c Fix crash due to by delayed execution of JS functions on destroyed windows (issue #2038) 2018-02-22 15:38:12 -05:00
Dmitry Azaraev
3b499d3d11 Add unit test for crash due to by delayed execution of JS functions on destroyed windows (issue #2038) 2018-02-22 15:37:55 -05:00
Tobias Taschner
cca0bcc8e0 Windows: cmake: Add CEF_RUNTIME_LIBRARY_FLAG for overriding VS runtime type. 2018-02-22 20:00:09 +00:00
Mike Wiedenbauer
39ccd85d77 Fixes encoding issues when using a custom resource handler (issue #1906). 2018-02-22 19:05:54 +00:00
Marshall Greenblatt
0ac37cefa1 Fix OSR transparency problems (issue #2212, issue #2345) 2018-02-22 13:05:53 -05:00
Alexander Guettler
36668efc2f Fix input range handle does not follow mouse cursor with OSR (issue #2189) 2018-02-22 17:09:28 +00:00
Marshall Greenblatt
a5a5e7ff08 Windows: Fix per-monitor DPI scaling of top-level browser windows and placement of context menus (issue #2313) 2018-02-21 16:58:54 -05:00
Marshall Greenblatt
57b9cf9ddd Windows: Add per-monitor DPI support (issue #2313) 2018-02-20 17:33:25 -05:00
258 changed files with 6038 additions and 3161 deletions

View File

@@ -100,11 +100,11 @@ import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//cef/cef_repack_locales.gni") import("//cef/cef_repack_locales.gni")
import("//chrome/common/features.gni") import("//chrome/common/features.gni")
import("//extensions/features/features.gni") import("//extensions/buildflags/buildflags.gni")
import("//media/media_options.gni") import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni") import("//mojo/public/tools/bindings/mojom.gni")
import("//ppapi/features/features.gni") import("//ppapi/buildflags/buildflags.gni")
import("//printing/features/features.gni") import("//printing/buildflags/buildflags.gni")
import("//services/catalog/public/tools/catalog.gni") import("//services/catalog/public/tools/catalog.gni")
import("//services/service_manager/public/service_manifest.gni") import("//services/service_manager/public/service_manifest.gni")
import("//third_party/icu/config.gni") import("//third_party/icu/config.gni")
@@ -118,12 +118,13 @@ if (is_clang) {
} }
if (is_linux) { if (is_linux) {
import("//build/config/linux/pkg_config.gni") import("//build/config/linux/pkg_config.gni")
import("//third_party/fontconfig/fontconfig.gni")
} }
if (is_mac) { if (is_mac) {
import("//build/config/mac/rules.gni") import("//build/config/mac/rules.gni")
import("//build/mac/tweak_info_plist.gni") import("//build/mac/tweak_info_plist.gni")
import("//build/util/version.gni") import("//build/util/version.gni")
import("//media/cdm/ppapi/cdm_paths.gni") import("//media/cdm/library_cdm/cdm_paths.gni")
} }
if (is_win) { if (is_win) {
import("//build/config/win/console_app.gni") import("//build/config/win/console_app.gni")
@@ -148,6 +149,12 @@ if (is_clang) {
assert(!clang_use_chrome_plugins) assert(!clang_use_chrome_plugins)
} }
if (is_linux) {
# Use system fontconfig. This avoids a startup hang on Ubuntu 16.04.4 (see
# issue #2424).
assert(!use_bundled_fontconfig)
}
if (is_mac) { if (is_mac) {
# Always generate dSYM files. The make_distrib script will fail if # Always generate dSYM files. The make_distrib script will fail if
# enable_dsyms=true is not explicitly set when is_official_build=false. # enable_dsyms=true is not explicitly set when is_official_build=false.
@@ -266,9 +273,9 @@ if (is_win) {
"//components/crash/core/common", # crash_keys "//components/crash/core/common", # crash_keys
# Required by chrome_switches.cc # Required by chrome_switches.cc
"//chrome/common:features", "//chrome/common:buildflags",
"//ppapi/features:features", "//ppapi/buildflags:buildflags",
"//printing/features:features", "//printing/buildflags:buildflags",
"//ui/base:ui_features", "//ui/base:ui_features",
] ]
} }
@@ -691,10 +698,9 @@ static_library("libcef_static") {
"//device/base", "//device/base",
"//extensions/browser", "//extensions/browser",
"//extensions/browser/api:api_registration", "//extensions/browser/api:api_registration",
"//extensions/buildflags",
"//extensions/common/api", "//extensions/common/api",
"//extensions/features",
"//extensions/renderer", "//extensions/renderer",
"//extensions/utility",
"//gpu", "//gpu",
"//ipc", "//ipc",
"//media", "//media",
@@ -704,23 +710,23 @@ static_library("libcef_static") {
"//net:net_utility_services", "//net:net_utility_services",
"//net:net_with_v8", "//net:net_with_v8",
"//pdf", "//pdf",
"//ppapi/features", "//ppapi/buildflags",
"//printing/features", "//printing/buildflags",
"//services/network:network_service", "//services/network:network_service",
"//services/network/public/cpp", "//services/network/public/cpp",
"//services/service_manager/embedder", "//services/service_manager/embedder",
"//services/service_manager/public/interfaces", "//services/service_manager/public/cpp",
"//services/service_manager/runner/common", "//services/service_manager/runner/common",
"//skia", "//skia",
"//storage/browser", "//storage/browser",
"//third_party/blink/public:blink",
"//third_party/brotli:dec", "//third_party/brotli:dec",
"//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", "//third_party/libxml",
"//third_party/WebKit/public:blink",
"//third_party/widevine/cdm:headers", "//third_party/widevine/cdm:headers",
"//third_party/widevine/cdm:widevinecdmadapter", "//third_party/widevine/cdm",
"//third_party/icu", "//third_party/icu",
"//third_party/zlib:minizip", "//third_party/zlib:minizip",
"//ui/base", "//ui/base",
@@ -1023,6 +1029,7 @@ if (is_win) {
cef_packaged_services = [ cef_packaged_services = [
"//chrome/app:chrome_manifest", # For spell checking. "//chrome/app:chrome_manifest", # For spell checking.
"//chrome/app:chrome_renderer_manifest", # For spell checking.
"//chrome/services/printing:manifest", "//chrome/services/printing:manifest",
"//services/metrics:manifest", "//services/metrics:manifest",
"//services/proxy_resolver:proxy_resolver_manifest", "//services/proxy_resolver:proxy_resolver_manifest",
@@ -1067,11 +1074,11 @@ template("cef_pak_scaled") {
# Each input pak file should also have a deps line for completeness. # Each input pak file should also have a deps line for completeness.
# 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/blink/public/resources/blink_scaled_resources_${percent}_percent.pak",
"$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak", "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
"$root_gen_dir/components/components_resources_${percent}_percent.pak", "$root_gen_dir/components/components_resources_${percent}_percent.pak",
"$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak", "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak",
"$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak", "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak",
"$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_${percent}_percent.pak",
"$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak", "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
] ]
@@ -1079,18 +1086,18 @@ template("cef_pak_scaled") {
# 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 = [
"//third_party/WebKit/public:scaled_resources",
"//chrome/renderer:resources", "//chrome/renderer:resources",
"//components/resources:components_scaled_resources", "//components/resources:components_scaled_resources",
"//content/app/resources", "//content/app/resources",
"//extensions:extensions_browser_resources", "//extensions:extensions_browser_resources",
"//third_party/blink/public:scaled_resources",
"//ui/resources:ui_resources_grd", "//ui/resources:ui_resources_grd",
] ]
deps = [ deps = [
# This repack target generates the blink_scaled_resources_*_percent.pak # This repack target generates the blink_scaled_resources_*_percent.pak
# file but doesn't expose the public_deps required by make_pack_header. # file but doesn't expose the public_deps required by make_pack_header.
"//third_party/WebKit/public:scaled_resources_${percent}_percent", "//third_party/blink/public:scaled_resources_${percent}_percent",
] ]
if (toolkit_views) { if (toolkit_views) {
@@ -1207,7 +1214,6 @@ repack("pak") {
# Each input pak file should also have a deps line for completeness. # Each input pak file should also have a deps line for completeness.
# 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/blink/public/resources/blink_resources.pak",
"$root_gen_dir/chrome/browser_resources.pak", "$root_gen_dir/chrome/browser_resources.pak",
"$root_gen_dir/chrome/net_internals_resources.pak", "$root_gen_dir/chrome/net_internals_resources.pak",
"$root_gen_dir/chrome/common_resources.pak", "$root_gen_dir/chrome/common_resources.pak",
@@ -1216,13 +1222,13 @@ repack("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/net/net_resources.pak", "$root_gen_dir/net/net_resources.pak",
"$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
] ]
# Use public_deps so that generated grit headers are discoverable from # Use public_deps so that generated grit headers are discoverable from
# 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 = [
"//third_party/WebKit/public:resources_grit",
"//chrome/browser:resources", "//chrome/browser:resources",
"//chrome/browser/resources:net_internals_resources", "//chrome/browser/resources:net_internals_resources",
"//chrome/common:resources", "//chrome/common:resources",
@@ -1231,6 +1237,7 @@ repack("pak") {
"//content/browser/tracing:resources", "//content/browser/tracing:resources",
"//content:resources", "//content:resources",
"//net:net_resources", "//net:net_resources",
"//third_party/blink/public:resources",
] ]
output = "$root_out_dir/cef.pak" output = "$root_out_dir/cef.pak"
@@ -1267,9 +1274,6 @@ template("make_pack_header") {
make_pack_header("resources") { make_pack_header("resources") {
header = "$root_out_dir/includes/include/cef_pack_resources.h" header = "$root_out_dir/includes/include/cef_pack_resources.h"
inputs = [ inputs = [
"$root_gen_dir/blink/public/resources/grit/media_controls_resources.h",
"$root_gen_dir/blink/public/resources/grit/blink_image_resources.h",
"$root_gen_dir/blink/public/resources/grit/blink_resources.h",
"$root_gen_dir/cef/grit/cef_resources.h", "$root_gen_dir/cef/grit/cef_resources.h",
"$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",
@@ -1284,6 +1288,7 @@ make_pack_header("resources") {
"$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",
"$root_gen_dir/net/grit/net_resources.h", "$root_gen_dir/net/grit/net_resources.h",
"$root_gen_dir/third_party/blink/public/resources/grit/blink_resources.h",
"$root_gen_dir/ui/resources/grit/ui_resources.h", "$root_gen_dir/ui/resources/grit/ui_resources.h",
"$root_gen_dir/ui/resources/grit/webui_resources.h", "$root_gen_dir/ui/resources/grit/webui_resources.h",
"$root_gen_dir/ui/views/resources/grit/views_resources.h", "$root_gen_dir/ui/views/resources/grit/views_resources.h",
@@ -1349,7 +1354,6 @@ if (is_mac) {
"$root_out_dir/cef_200_percent.pak", "$root_out_dir/cef_200_percent.pak",
"$root_out_dir/cef_extensions.pak", "$root_out_dir/cef_extensions.pak",
"$root_out_dir/devtools_resources.pak", "$root_out_dir/devtools_resources.pak",
"$root_out_dir/$widevine_cdm_path/widevinecdmadapter.plugin",
] ]
public_deps = [ public_deps = [
@@ -1358,7 +1362,6 @@ if (is_mac) {
":pak_200_percent", ":pak_200_percent",
":pak_devtools", ":pak_devtools",
":pak_extensions", ":pak_extensions",
"//third_party/widevine/cdm:widevinecdmadapter",
] ]
if (icu_use_data_file) { if (icu_use_data_file) {
@@ -1386,6 +1389,11 @@ if (is_mac) {
mac_framework_bundle("cef_framework") { mac_framework_bundle("cef_framework") {
output_name = cef_framework_name output_name = cef_framework_name
framework_version = "A"
framework_contents = [
"Resources",
]
sources = gypi_paths2.includes_common + sources = gypi_paths2.includes_common +
gypi_paths2.includes_mac + gypi_paths2.includes_mac +
gypi_paths.autogen_cpp_includes + gypi_paths.autogen_cpp_includes +
@@ -1421,11 +1429,11 @@ if (is_mac) {
if (is_component_build) { if (is_component_build) {
# Set up the rpath for the framework so that it can find dylibs in the # Set up the rpath for the framework so that it can find dylibs in the
# root output directory. The framework is at # root output directory. The framework is at
# $app_name.app/Contents/Frameworks/$output_name.framework/$output_name # $app_name.app/Contents/Frameworks/$output_name.framework/Versions/A/$output_name
# so use loader_path to go back to the root output directory. # so use loader_path to go back to the root output directory.
ldflags += [ ldflags += [
"-rpath", "-rpath",
"@loader_path/../../../..", "@loader_path/../../../../../..",
] ]
} }
@@ -1442,6 +1450,7 @@ if (is_mac) {
deps = [ deps = [
":libcef_static", ":libcef_static",
"//build/config:exe_and_shlib_deps",
] ]
if (is_win) { if (is_win) {
@@ -1462,9 +1471,12 @@ if (is_mac) {
] ]
} }
if (is_linux && !is_debug && !using_sanitizer && use_allocator=="none") { if (is_linux && !is_debug && use_allocator=="none") {
# Only export necessary symbols from libcef.so. # Only export necessary symbols from libcef.so.
# Don't do this in Debug builds because it causes the resulting application to crash. # Don't do this in Debug builds because it causes the resulting
# application to crash.
# Also need to do this for ASAN builds to work around
# https://crbug.com/832808.
ldflags = [ "-Wl,--version-script=" + ldflags = [ "-Wl,--version-script=" +
rebase_path("//cef/libcef_dll/libcef.lst") ] rebase_path("//cef/libcef_dll/libcef.lst") ]
} }

View File

@@ -7,5 +7,5 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding # https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{ {
'chromium_checkout': 'bc084a8b5afa3744a74927344e304c02ae54189f', 'chromium_checkout': 'refs/tags/67.0.3396.79',
} }

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=bede6f61d0f5b45669b8e924144e4200c41f869b$ # $hash=67bc21133e37f5361a39f25dcfe004616d467dbc$
# #
{ {
@@ -432,6 +432,8 @@
'libcef_dll/ctocpp/urlrequest_client_ctocpp.h', 'libcef_dll/ctocpp/urlrequest_client_ctocpp.h',
'libcef_dll/ctocpp/v8accessor_ctocpp.cc', 'libcef_dll/ctocpp/v8accessor_ctocpp.cc',
'libcef_dll/ctocpp/v8accessor_ctocpp.h', 'libcef_dll/ctocpp/v8accessor_ctocpp.h',
'libcef_dll/ctocpp/v8array_buffer_release_callback_ctocpp.cc',
'libcef_dll/ctocpp/v8array_buffer_release_callback_ctocpp.h',
'libcef_dll/cpptoc/v8context_cpptoc.cc', 'libcef_dll/cpptoc/v8context_cpptoc.cc',
'libcef_dll/cpptoc/v8context_cpptoc.h', 'libcef_dll/cpptoc/v8context_cpptoc.h',
'libcef_dll/cpptoc/v8exception_cpptoc.cc', 'libcef_dll/cpptoc/v8exception_cpptoc.cc',
@@ -712,6 +714,8 @@
'libcef_dll/cpptoc/urlrequest_client_cpptoc.h', 'libcef_dll/cpptoc/urlrequest_client_cpptoc.h',
'libcef_dll/cpptoc/v8accessor_cpptoc.cc', 'libcef_dll/cpptoc/v8accessor_cpptoc.cc',
'libcef_dll/cpptoc/v8accessor_cpptoc.h', 'libcef_dll/cpptoc/v8accessor_cpptoc.h',
'libcef_dll/cpptoc/v8array_buffer_release_callback_cpptoc.cc',
'libcef_dll/cpptoc/v8array_buffer_release_callback_cpptoc.h',
'libcef_dll/ctocpp/v8context_ctocpp.cc', 'libcef_dll/ctocpp/v8context_ctocpp.cc',
'libcef_dll/ctocpp/v8context_ctocpp.h', 'libcef_dll/ctocpp/v8context_ctocpp.h',
'libcef_dll/ctocpp/v8exception_ctocpp.cc', 'libcef_dll/ctocpp/v8exception_ctocpp.cc',

View File

@@ -159,7 +159,6 @@
'tests/shared/browser/main_message_loop_std.cc', 'tests/shared/browser/main_message_loop_std.cc',
'tests/shared/browser/main_message_loop_std.h', 'tests/shared/browser/main_message_loop_std.h',
'tests/shared/browser/resource_util.h', 'tests/shared/browser/resource_util.h',
'tests/shared/browser/resource_util.h',
], ],
'shared_sources_common': [ 'shared_sources_common': [
'tests/shared/common/client_app.cc', 'tests/shared/common/client_app.cc',

View File

@@ -86,7 +86,8 @@ if(OS_LINUX)
-Werror # Treat warnings as errors -Werror # Treat warnings as errors
-Wno-missing-field-initializers # Don't warn about missing field initializers -Wno-missing-field-initializers # Don't warn about missing field initializers
-Wno-unused-parameter # Don't warn about unused parameters -Wno-unused-parameter # Don't warn about unused parameters
-Wno-error=comment # Don't complain about code in ascii art -Wno-error=comment # Don't warn about code in comments
-Wno-comment # Don't warn about code in comments
) )
list(APPEND CEF_C_COMPILER_FLAGS list(APPEND CEF_C_COMPILER_FLAGS
-std=c99 # Use the C99 language standard -std=c99 # Use the C99 language standard
@@ -198,9 +199,12 @@ if(OS_LINUX)
set(CEF_BINARY_FILES set(CEF_BINARY_FILES
chrome-sandbox chrome-sandbox
libcef.so libcef.so
libEGL.so
libGLESv2.so
natives_blob.bin natives_blob.bin
snapshot_blob.bin snapshot_blob.bin
v8_context_snapshot.bin v8_context_snapshot.bin
swiftshader
) )
# List of CEF resource files. # List of CEF resource files.
@@ -333,12 +337,15 @@ if(OS_WINDOWS)
option(USE_SANDBOX "Enable or disable use of the sandbox." ON) option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
if(USE_SANDBOX) if(USE_SANDBOX)
# Check if the current MSVC version is compatible with the cef_sandbox.lib # Check if the current MSVC version is compatible with the cef_sandbox.lib
# static library. # static library. For a list of all version numbers see
# https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering
list(APPEND supported_msvc_versions list(APPEND supported_msvc_versions
1900 # VS2015 and updates 1, 2, & 3 1900 # VS2015 and updates 1, 2, & 3
1910 # VS2017 version 15.1 & 15.2 1910 # VS2017 version 15.1 & 15.2
1911 # VS2017 version 15.3 & 15.4 1911 # VS2017 version 15.3 & 15.4
1912 # VS2017 version 15.5 1912 # VS2017 version 15.5
1913 # VS2017 version 15.6
1914 # VS2017 version 15.7
) )
list(FIND supported_msvc_versions ${MSVC_VERSION} _index) list(FIND supported_msvc_versions ${MSVC_VERSION} _index)
if (${_index} EQUAL -1) if (${_index} EQUAL -1)
@@ -350,6 +357,13 @@ if(OS_WINDOWS)
# Consumers who run into LNK4099 warnings can pass /Z7 instead (see issue #385). # Consumers who run into LNK4099 warnings can pass /Z7 instead (see issue #385).
set(CEF_DEBUG_INFO_FLAG "/Zi" CACHE STRING "Optional flag specifying specific /Z flag to use") set(CEF_DEBUG_INFO_FLAG "/Zi" CACHE STRING "Optional flag specifying specific /Z flag to use")
# Consumers using different runtime types may want to pass different flags
set(CEF_RUNTIME_LIBRARY_FLAG "/MT" CACHE STRING "Optional flag specifying which runtime to use")
if (CEF_RUNTIME_LIBRARY_FLAG)
list(APPEND CEF_COMPILER_FLAGS_DEBUG ${CEF_RUNTIME_LIBRARY_FLAG}d)
list(APPEND CEF_COMPILER_FLAGS_RELEASE ${CEF_RUNTIME_LIBRARY_FLAG})
endif()
# Platform-specific compiler/linker flags. # Platform-specific compiler/linker flags.
set(CEF_LIBTYPE STATIC) set(CEF_LIBTYPE STATIC)
list(APPEND CEF_COMPILER_FLAGS list(APPEND CEF_COMPILER_FLAGS
@@ -369,12 +383,10 @@ if(OS_WINDOWS)
${CEF_DEBUG_INFO_FLAG} ${CEF_DEBUG_INFO_FLAG}
) )
list(APPEND CEF_COMPILER_FLAGS_DEBUG list(APPEND CEF_COMPILER_FLAGS_DEBUG
/MTd # Multithreaded debug runtime
/RTC1 # Disable optimizations /RTC1 # Disable optimizations
/Od # Enable basic run-time checks /Od # Enable basic run-time checks
) )
list(APPEND CEF_COMPILER_FLAGS_RELEASE list(APPEND CEF_COMPILER_FLAGS_RELEASE
/MT # Multithreaded release runtime
/O2 # Optimize for maximum speed /O2 # Optimize for maximum speed
/Ob2 # Inline any suitable function /Ob2 # Inline any suitable function
/GF # Enable string pooling /GF # Enable string pooling

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=e0605a0c9918e225b9282b6d5e6138a7d697945b$ // $hash=00e6d1aa80d5998d89cc272dcb199cde0add12fa$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
@@ -159,6 +159,16 @@ typedef struct _cef_cookie_manager_t {
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager( CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
struct _cef_completion_callback_t* callback); struct _cef_completion_callback_t* callback);
///
// Returns a cookie manager that neither stores nor retrieves cookies. All usage
// of cookies will be blocked including cookies accessed via the network
// (request/response headers), via JavaScript (document.cookie), and via
// cef_cookie_manager_t functions. No cookies will be displayed in DevTools. If
// you wish to only block cookies sent via the network use the
// cef_request_tHandler CanGetCookies and CanSetCookie functions instead.
///
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_blocking_manager();
/// ///
// Creates a new cookie manager. If |path| is NULL data will be stored in memory // Creates a new cookie manager. If |path| is NULL data will be stored in memory
// only. Otherwise, data will be stored at the specified |path|. To persist // only. Otherwise, data will be stored at the specified |path|. To persist

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=ab31ef5d72b4b1c9809698e5fbbdae21918af713$ // $hash=c7641e41aca6bf30b9c36092861f061d2b16ff82$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
@@ -132,6 +132,15 @@ typedef struct _cef_display_handler_t {
int(CEF_CALLBACK* on_auto_resize)(struct _cef_display_handler_t* self, int(CEF_CALLBACK* on_auto_resize)(struct _cef_display_handler_t* self,
struct _cef_browser_t* browser, struct _cef_browser_t* browser,
const cef_size_t* new_size); const cef_size_t* new_size);
///
// Called when the overall page loading progress has changed. |progress|
// ranges from 0.0 to 1.0.
///
void(CEF_CALLBACK* on_loading_progress_change)(
struct _cef_display_handler_t* self,
struct _cef_browser_t* browser,
double progress);
} cef_display_handler_t; } cef_display_handler_t;
#ifdef __cplusplus #ifdef __cplusplus

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=3fb1034cb02cfeddcaf02d8fde0dec5b8a18f416$ // $hash=f2f3acb1df9815e4ac9bf34010ce260a2496ae5a$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_
@@ -202,6 +202,17 @@ typedef struct _cef_render_handler_t {
const cef_range_t* selected_range, const cef_range_t* selected_range,
size_t character_boundsCount, size_t character_boundsCount,
cef_rect_t const* character_bounds); cef_rect_t const* character_bounds);
///
// Called when text selection has changed for the specified |browser|.
// |selected_text| is the currently selected text and |selected_range| is the
// character range.
///
void(CEF_CALLBACK* on_text_selection_changed)(
struct _cef_render_handler_t* self,
struct _cef_browser_t* browser,
const cef_string_t* selected_text,
const cef_range_t* selected_range);
} cef_render_handler_t; } cef_render_handler_t;
#ifdef __cplusplus #ifdef __cplusplus

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=b8b5a62b11dbc48f0733c0522864e4dbda8b4f59$ // $hash=95e44047a75693dbae0ab6b07b415d188252bfdf$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_
@@ -112,12 +112,15 @@ typedef struct _cef_request_handler_t {
// If the navigation is allowed cef_load_handler_t::OnLoadStart and // If the navigation is allowed cef_load_handler_t::OnLoadStart and
// cef_load_handler_t::OnLoadEnd will be called. If the navigation is canceled // cef_load_handler_t::OnLoadEnd will be called. If the navigation is canceled
// cef_load_handler_t::OnLoadError will be called with an |errorCode| value of // cef_load_handler_t::OnLoadError will be called with an |errorCode| value of
// ERR_ABORTED. // ERR_ABORTED. The |user_gesture| value will be true (1) if the browser
// navigated via explicit user gesture (e.g. clicking a link) or false (0) if
// it navigated automatically (e.g. via the DomContentLoaded event).
/// ///
int(CEF_CALLBACK* on_before_browse)(struct _cef_request_handler_t* self, int(CEF_CALLBACK* on_before_browse)(struct _cef_request_handler_t* self,
struct _cef_browser_t* browser, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, struct _cef_frame_t* frame,
struct _cef_request_t* request, struct _cef_request_t* request,
int user_gesture,
int is_redirect); int is_redirect);
/// ///

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=561e4711432158fd3da971f3c0240dcf5e8e782a$ // $hash=fd2cbc427bccf30298e26dd6c3bcef9551433f8b$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_RESPONSE_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_RESPONSE_CAPI_H_
@@ -127,6 +127,18 @@ typedef struct _cef_response_t {
/// ///
void(CEF_CALLBACK* set_header_map)(struct _cef_response_t* self, void(CEF_CALLBACK* set_header_map)(struct _cef_response_t* self,
cef_string_multimap_t headerMap); cef_string_multimap_t headerMap);
///
// Get the resolved URL after redirects or changed as a result of HSTS.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_url)(struct _cef_response_t* self);
///
// Set the resolved URL after redirects or changed as a result of HSTS.
///
void(CEF_CALLBACK* set_url)(struct _cef_response_t* self,
const cef_string_t* url);
} cef_response_t; } cef_response_t;
/// ///

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=e9e43167b1cf8033bd7e6ba6931213d7cf4b69b5$ // $hash=2303574e76708e5311aede8e66eb7f1f679e0d1f$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_
@@ -355,6 +355,25 @@ typedef struct _cef_v8exception_t {
int(CEF_CALLBACK* get_end_column)(struct _cef_v8exception_t* self); int(CEF_CALLBACK* get_end_column)(struct _cef_v8exception_t* self);
} cef_v8exception_t; } cef_v8exception_t;
///
// Callback structure that is passed to cef_v8value_t::CreateArrayBuffer.
///
typedef struct _cef_v8array_buffer_release_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called to release |buffer| when the ArrayBuffer JS object is garbage
// collected. |buffer| is the value that was passed to CreateArrayBuffer along
// with this object.
///
void(CEF_CALLBACK* release_buffer)(
struct _cef_v8array_buffer_release_callback_t* self,
void* buffer);
} cef_v8array_buffer_release_callback_t;
/// ///
// Structure representing a V8 value handle. V8 handles can only be accessed // Structure representing a V8 value handle. V8 handles can only be accessed
// from the thread on which they are created. Valid threads for creating a V8 // from the thread on which they are created. Valid threads for creating a V8
@@ -425,6 +444,11 @@ typedef struct _cef_v8value_t {
/// ///
int(CEF_CALLBACK* is_array)(struct _cef_v8value_t* self); int(CEF_CALLBACK* is_array)(struct _cef_v8value_t* self);
///
// True if the value type is an ArrayBuffer.
///
int(CEF_CALLBACK* is_array_buffer)(struct _cef_v8value_t* self);
/// ///
// True if the value type is function. // True if the value type is function.
/// ///
@@ -639,6 +663,25 @@ typedef struct _cef_v8value_t {
/// ///
int(CEF_CALLBACK* get_array_length)(struct _cef_v8value_t* self); int(CEF_CALLBACK* get_array_length)(struct _cef_v8value_t* self);
// ARRAY BUFFER METHODS - These functions are only available on ArrayBuffers.
///
// Returns the ReleaseCallback object associated with the ArrayBuffer or NULL
// if the ArrayBuffer was not created with CreateArrayBuffer.
///
struct _cef_v8array_buffer_release_callback_t*(
CEF_CALLBACK* get_array_buffer_release_callback)(
struct _cef_v8value_t* self);
///
// Prevent the ArrayBuffer from using it's memory block by setting the length
// to zero. This operation cannot be undone. If the ArrayBuffer was created
// with CreateArrayBuffer then
// cef_v8array_buffer_release_callback_t::ReleaseBuffer will be called to
// release the underlying buffer.
///
int(CEF_CALLBACK* neuter_array_buffer)(struct _cef_v8value_t* self);
// FUNCTION METHODS - These functions are only available on functions. // FUNCTION METHODS - These functions are only available on functions.
/// ///
@@ -751,6 +794,21 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_object(
/// ///
CEF_EXPORT cef_v8value_t* cef_v8value_create_array(int length); CEF_EXPORT cef_v8value_t* cef_v8value_create_array(int length);
///
// Create a new cef_v8value_t object of type ArrayBuffer which wraps the
// provided |buffer| of size |length| bytes. The ArrayBuffer is externalized,
// meaning that it does not own |buffer|. The caller is responsible for freeing
// |buffer| when requested via a call to cef_v8array_buffer_release_callback_t::
// ReleaseBuffer. This function should only be called from within the scope of a
// cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t callback,
// or in combination with calling enter() and exit() on a stored cef_v8context_t
// reference.
///
CEF_EXPORT cef_v8value_t* cef_v8value_create_array_buffer(
void* buffer,
size_t length,
cef_v8array_buffer_release_callback_t* release_callback);
/// ///
// Create a new cef_v8value_t object of type function. This function should only // Create a new cef_v8value_t object of type function. This function should only
// be called from within the scope of a cef_render_process_handler_t, // be called from within the scope of a cef_render_process_handler_t,

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=ec4f722423ff89dd2ff61fd3336bda1776081023$ // $hash=8815d0d0778cc210fb6f9ede9dafc5ca51124169$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_
@@ -202,9 +202,6 @@ CEF_EXPORT void cef_is_web_plugin_unstable(
// 2. widevinecdm file from the CDM binary distribution (e.g. // 2. widevinecdm file from the CDM binary distribution (e.g.
// widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X, // widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X,
// libwidevinecdm.so on Linux). // libwidevinecdm.so on Linux).
// 3. widevidecdmadapter file from the CEF binary distribution (e.g.
// widevinecdmadapter.dll on Windows, widevinecdmadapter.plugin on OS X,
// libwidevinecdmadapter.so on Linux).
// //
// If any of these files are missing or if the manifest file has incorrect // If any of these files are missing or if the manifest file has incorrect
// contents the registration will fail and |callback| will receive a |result| // contents the registration will fail and |callback| will receive a |result|

View File

@@ -50,7 +50,7 @@ class CefAuthCallback : public virtual CefBaseRefCounted {
/// ///
// Continue the authentication request. // Continue the authentication request.
/// ///
/*--cef(capi_name=cont,optional_param=password)--*/ /*--cef(capi_name=cont,optional_param=username,optional_param=password)--*/
virtual void Continue(const CefString& username, virtual void Continue(const CefString& username,
const CefString& password) = 0; const CefString& password) = 0;

View File

@@ -64,6 +64,17 @@ class CefCookieManager : public virtual CefBaseRefCounted {
static CefRefPtr<CefCookieManager> GetGlobalManager( static CefRefPtr<CefCookieManager> GetGlobalManager(
CefRefPtr<CefCompletionCallback> callback); CefRefPtr<CefCompletionCallback> callback);
///
// Returns a cookie manager that neither stores nor retrieves cookies. All
// usage of cookies will be blocked including cookies accessed via the network
// (request/response headers), via JavaScript (document.cookie), and via
// CefCookieManager methods. No cookies will be displayed in DevTools. If you
// wish to only block cookies sent via the network use the CefRequestHandler
// CanGetCookies and CanSetCookie methods instead.
///
/*--cef()--*/
static CefRefPtr<CefCookieManager> GetBlockingManager();
/// ///
// Creates a new cookie manager. If |path| is empty data will be stored in // Creates a new cookie manager. If |path| is empty data will be stored in
// memory only. Otherwise, data will be stored at the specified |path|. To // memory only. Otherwise, data will be stored at the specified |path|. To

View File

@@ -127,6 +127,14 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
const CefSize& new_size) { const CefSize& new_size) {
return false; return false;
} }
///
// Called when the overall page loading progress has changed. |progress|
// ranges from 0.0 to 1.0.
///
/*--cef()--*/
virtual void OnLoadingProgressChange(CefRefPtr<CefBrowser> browser,
double progress) {}
}; };
#endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_ #endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_

View File

@@ -204,6 +204,16 @@ class CefRenderHandler : public virtual CefBaseRefCounted {
virtual void OnImeCompositionRangeChanged(CefRefPtr<CefBrowser> browser, virtual void OnImeCompositionRangeChanged(CefRefPtr<CefBrowser> browser,
const CefRange& selected_range, const CefRange& selected_range,
const RectList& character_bounds) {} const RectList& character_bounds) {}
///
// Called when text selection has changed for the specified |browser|.
// |selected_text| is the currently selected text and |selected_range| is
// the character range.
///
/*--cef(optional_param=selected_text,optional_param=selected_range)--*/
virtual void OnTextSelectionChanged(CefRefPtr<CefBrowser> browser,
const CefString& selected_text,
const CefRange& selected_range) {}
}; };
#endif // CEF_INCLUDE_CEF_RENDER_HANDLER_H_ #endif // CEF_INCLUDE_CEF_RENDER_HANDLER_H_

View File

@@ -106,12 +106,15 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
// If the navigation is allowed CefLoadHandler::OnLoadStart and // If the navigation is allowed CefLoadHandler::OnLoadStart and
// CefLoadHandler::OnLoadEnd will be called. If the navigation is canceled // CefLoadHandler::OnLoadEnd will be called. If the navigation is canceled
// CefLoadHandler::OnLoadError will be called with an |errorCode| value of // CefLoadHandler::OnLoadError will be called with an |errorCode| value of
// ERR_ABORTED. // ERR_ABORTED. The |user_gesture| value will be true if the browser
// navigated via explicit user gesture (e.g. clicking a link) or false if it
// navigated automatically (e.g. via the DomContentLoaded event).
/// ///
/*--cef()--*/ /*--cef()--*/
virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser, virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request, CefRefPtr<CefRequest> request,
bool user_gesture,
bool is_redirect) { bool is_redirect) {
return false; return false;
} }

View File

@@ -128,6 +128,18 @@ class CefResponse : public virtual CefBaseRefCounted {
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void SetHeaderMap(const HeaderMap& headerMap) = 0; virtual void SetHeaderMap(const HeaderMap& headerMap) = 0;
///
// Get the resolved URL after redirects or changed as a result of HSTS.
///
/*--cef()--*/
virtual CefString GetURL() = 0;
///
// Set the resolved URL after redirects or changed as a result of HSTS.
///
/*--cef()--*/
virtual void SetURL(const CefString& url) = 0;
}; };
#endif // CEF_INCLUDE_CEF_RESPONSE_H_ #endif // CEF_INCLUDE_CEF_RESPONSE_H_

View File

@@ -407,6 +407,21 @@ class CefV8Exception : public virtual CefBaseRefCounted {
virtual int GetEndColumn() = 0; virtual int GetEndColumn() = 0;
}; };
///
// Callback interface that is passed to CefV8Value::CreateArrayBuffer.
///
/*--cef(source=client)--*/
class CefV8ArrayBufferReleaseCallback : public virtual CefBaseRefCounted {
public:
///
// Called to release |buffer| when the ArrayBuffer JS object is garbage
// collected. |buffer| is the value that was passed to CreateArrayBuffer along
// with this object.
///
/*--cef()--*/
virtual void ReleaseBuffer(void* buffer) = 0;
};
/// ///
// Class representing a V8 value handle. V8 handles can only be accessed from // Class representing a V8 value handle. V8 handles can only be accessed from
// the thread on which they are created. Valid threads for creating a V8 handle // the thread on which they are created. Valid threads for creating a V8 handle
@@ -493,6 +508,22 @@ class CefV8Value : public virtual CefBaseRefCounted {
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefV8Value> CreateArray(int length); static CefRefPtr<CefV8Value> CreateArray(int length);
///
// Create a new CefV8Value object of type ArrayBuffer which wraps the provided
// |buffer| of size |length| bytes. The ArrayBuffer is externalized, meaning
// that it does not own |buffer|. The caller is responsible for freeing
// |buffer| when requested via a call to CefV8ArrayBufferReleaseCallback::
// ReleaseBuffer. This method should only be called from within the scope of a
// CefRenderProcessHandler, CefV8Handler or CefV8Accessor callback, or in
// combination with calling Enter() and Exit() on a stored CefV8Context
// reference.
///
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateArrayBuffer(
void* buffer,
size_t length,
CefRefPtr<CefV8ArrayBufferReleaseCallback> release_callback);
/// ///
// Create a new CefV8Value object of type function. This method should only be // Create a new CefV8Value object of type function. This method should only be
// called from within the scope of a CefRenderProcessHandler, CefV8Handler or // called from within the scope of a CefRenderProcessHandler, CefV8Handler or
@@ -571,6 +602,12 @@ class CefV8Value : public virtual CefBaseRefCounted {
/*--cef()--*/ /*--cef()--*/
virtual bool IsArray() = 0; virtual bool IsArray() = 0;
///
// True if the value type is an ArrayBuffer.
///
/*--cef()--*/
virtual bool IsArrayBuffer() = 0;
/// ///
// True if the value type is function. // True if the value type is function.
/// ///
@@ -793,6 +830,25 @@ class CefV8Value : public virtual CefBaseRefCounted {
/*--cef()--*/ /*--cef()--*/
virtual int GetArrayLength() = 0; virtual int GetArrayLength() = 0;
// ARRAY BUFFER METHODS - These methods are only available on ArrayBuffers.
///
// Returns the ReleaseCallback object associated with the ArrayBuffer or NULL
// if the ArrayBuffer was not created with CreateArrayBuffer.
///
/*--cef()--*/
virtual CefRefPtr<CefV8ArrayBufferReleaseCallback>
GetArrayBufferReleaseCallback() = 0;
///
// Prevent the ArrayBuffer from using it's memory block by setting the length
// to zero. This operation cannot be undone. If the ArrayBuffer was created
// with CreateArrayBuffer then CefV8ArrayBufferReleaseCallback::ReleaseBuffer
// will be called to release the underlying buffer.
///
/*--cef()--*/
virtual bool NeuterArrayBuffer() = 0;
// FUNCTION METHODS - These methods are only available on functions. // FUNCTION METHODS - These methods are only available on functions.
/// ///

View File

@@ -179,9 +179,6 @@ class CefRegisterCdmCallback : public virtual CefBaseRefCounted {
// 2. widevinecdm file from the CDM binary distribution (e.g. // 2. widevinecdm file from the CDM binary distribution (e.g.
// widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X, // widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X,
// libwidevinecdm.so on Linux). // libwidevinecdm.so on Linux).
// 3. widevidecdmadapter file from the CEF binary distribution (e.g.
// widevinecdmadapter.dll on Windows, widevinecdmadapter.plugin on OS X,
// libwidevinecdmadapter.so on Linux).
// //
// If any of these files are missing or if the manifest file has incorrect // If any of these files are missing or if the manifest file has incorrect
// contents the registration will fail and |callback| will receive a |result| // contents the registration will fail and |callback| will receive a |result|

View File

@@ -1264,6 +1264,12 @@ typedef enum {
// originated in the browser process. // originated in the browser process.
/// ///
UR_FLAG_NO_RETRY_ON_5XX = 1 << 5, UR_FLAG_NO_RETRY_ON_5XX = 1 << 5,
///
// If set 3XX responses will cause the fetch to halt immediately rather than
// continue through the redirect.
///
UR_FLAG_STOP_ON_REDIRECT = 1 << 6,
} cef_urlrequest_flags_t; } cef_urlrequest_flags_t;
/// ///
@@ -1379,23 +1385,41 @@ typedef enum {
/// ///
// The main thread in the browser. This will be the same as the main // The main thread in the browser. This will be the same as the main
// application thread if CefInitialize() is called with a // application thread if CefInitialize() is called with a
// CefSettings.multi_threaded_message_loop value of false. // CefSettings.multi_threaded_message_loop value of false. Do not perform
// blocking tasks on this thread. All tasks posted after
// CefBrowserProcessHandler::OnContextInitialized() and before CefShutdown()
// are guaranteed to run. This thread will outlive all other CEF threads.
/// ///
TID_UI, TID_UI,
/// ///
// Used to interact with the database. // Used for blocking tasks (e.g. file system access) where the user won't
// notice if the task takes an arbitrarily long time to complete. All tasks
// posted after CefBrowserProcessHandler::OnContextInitialized() and before
// CefShutdown() are guaranteed to run.
/// ///
TID_DB, TID_FILE_BACKGROUND,
TID_FILE = TID_FILE_BACKGROUND,
/// ///
// Used to interact with the file system. // Used for blocking tasks (e.g. file system access) that affect UI or
// responsiveness of future user interactions. Do not use if an immediate
// response to a user interaction is expected. All tasks posted after
// CefBrowserProcessHandler::OnContextInitialized() and before CefShutdown()
// are guaranteed to run.
// Examples:
// - Updating the UI to reflect progress on a long task.
// - Loading data that might be shown in the UI after a future user
// interaction.
/// ///
TID_FILE, TID_FILE_USER_VISIBLE,
/// ///
// Used for file system operations that block user interactions. // Used for blocking tasks (e.g. file system access) that affect UI
// Responsiveness of this thread affects users. // immediately after a user interaction. All tasks posted after
// CefBrowserProcessHandler::OnContextInitialized() and before CefShutdown()
// are guaranteed to run.
// Example: Generating data shown in the UI immediately after a click.
/// ///
TID_FILE_USER_BLOCKING, TID_FILE_USER_BLOCKING,
@@ -1405,12 +1429,10 @@ typedef enum {
TID_PROCESS_LAUNCHER, TID_PROCESS_LAUNCHER,
/// ///
// Used to handle slow HTTP cache operations. // Used to process IPC and network messages. Do not perform blocking tasks on
/// // this thread. All tasks posted after
TID_CACHE, // CefBrowserProcessHandler::OnContextInitialized() and before CefShutdown()
// are guaranteed to run.
///
// Used to process IPC and network messages.
/// ///
TID_IO, TID_IO,
@@ -1418,6 +1440,10 @@ typedef enum {
/// ///
// The main thread in the renderer. Used for all WebKit and V8 interaction. // The main thread in the renderer. Used for all WebKit and V8 interaction.
// Tasks may be posted to this thread after
// CefRenderProcessHandler::OnRenderThreadCreated but are not guaranteed to
// run before sub-process termination (sub-processes may be killed at any time
// without warning).
/// ///
TID_RENDERER, TID_RENDERER,
} cef_thread_id_t; } cef_thread_id_t;

View File

@@ -39,8 +39,8 @@
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "extensions/browser/extension_protocols.h" #include "extensions/browser/extension_protocols.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "net/proxy/proxy_config_service.h" #include "net/proxy_resolution/proxy_config_service.h"
#include "net/proxy/proxy_service.h" #include "net/proxy_resolution/proxy_resolution_service.h"
using content::BrowserThread; using content::BrowserThread;
@@ -162,7 +162,7 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::Listener {
void CreateListenerForContext(const CefBrowserContext* context) { void CreateListenerForContext(const CefBrowserContext* context) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
auto listener = base::MakeUnique<visitedlink::VisitedLinkEventListener>( auto listener = std::make_unique<visitedlink::VisitedLinkEventListener>(
const_cast<CefBrowserContext*>(context)); const_cast<CefBrowserContext*>(context));
listener_map_.insert(std::make_pair(context, std::move(listener))); listener_map_.insert(std::make_pair(context, std::move(listener)));
} }
@@ -176,11 +176,11 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::Listener {
// visitedlink::VisitedLinkMaster::Listener methods. // visitedlink::VisitedLinkMaster::Listener methods.
void NewTable(mojo::SharedBufferHandle table) override { void NewTable(base::ReadOnlySharedMemoryRegion* table_region) override {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.begin(); ListenerMap::iterator it = listener_map_.begin();
for (; it != listener_map_.end(); ++it) for (; it != listener_map_.end(); ++it)
it->second->NewTable(table); it->second->NewTable(table_region);
} }
void Add(visitedlink::VisitedLinkCommon::Fingerprint fingerprint) override { void Add(visitedlink::VisitedLinkCommon::Fingerprint fingerprint) override {
@@ -450,7 +450,8 @@ net::URLRequestContextGetter* CefBrowserContextImpl::CreateRequestContext(
// TODO(cef): Determine if we can use the Chrome/Mojo implementation from // TODO(cef): Determine if we can use the Chrome/Mojo implementation from
// https://crrev.com/d0d0d050 // https://crrev.com/d0d0d050
std::unique_ptr<net::ProxyConfigService> base_service( std::unique_ptr<net::ProxyConfigService> base_service(
net::ProxyService::CreateSystemProxyConfigService(io_thread_runner)); net::ProxyResolutionService::CreateSystemProxyConfigService(
io_thread_runner));
std::unique_ptr<net::ProxyConfigService> proxy_config_service( std::unique_ptr<net::ProxyConfigService> proxy_config_service(
pref_proxy_config_tracker_->CreateTrackingProxyConfigService( pref_proxy_config_tracker_->CreateTrackingProxyConfigService(
std::move(base_service))); std::move(base_service)));
@@ -461,10 +462,8 @@ net::URLRequestContextGetter* CefBrowserContextImpl::CreateRequestContext(
// data in its installation directory). // data in its installation directory).
extensions::InfoMap* extension_info_map = extension_system()->info_map(); extensions::InfoMap* extension_info_map = extension_system()->info_map();
(*protocol_handlers)[extensions::kExtensionScheme] = (*protocol_handlers)[extensions::kExtensionScheme] =
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( extensions::CreateExtensionProtocolHandler(IsOffTheRecord(),
extensions::CreateExtensionProtocolHandler(IsOffTheRecord(), extension_info_map);
extension_info_map)
.release());
} }
url_request_getter_ = new CefURLRequestContextGetterImpl( url_request_getter_ = new CefURLRequestContextGetterImpl(

View File

@@ -53,7 +53,7 @@
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "content/public/browser/desktop_media_id.h" #include "content/public/browser/desktop_media_id.h"
#include "content/public/browser/download_manager.h" #include "content/public/browser/download_manager.h"
#include "content/public/browser/download_url_parameters.h" #include "content/public/browser/download_request_utils.h"
#include "content/public/browser/host_zoom_map.h" #include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/keyboard_event_processing_result.h" #include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/native_web_keyboard_event.h"
@@ -71,7 +71,7 @@
#include "content/public/common/favicon_url.h" #include "content/public/common/favicon_url.h"
#include "extensions/browser/process_manager.h" #include "extensions/browser/process_manager.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "third_party/WebKit/public/web/WebFindOptions.h" #include "third_party/blink/public/web/web_find_options.h"
#include "ui/events/base_event_utils.h" #include "ui/events/base_event_utils.h"
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
@@ -745,8 +745,8 @@ void CefBrowserHostImpl::StartDownload(const CefString& url) {
if (!manager) if (!manager)
return; return;
std::unique_ptr<content::DownloadUrlParameters> params( std::unique_ptr<download::DownloadUrlParameters> params(
content::DownloadUrlParameters::CreateForWebContentsMainFrame( content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(
web_contents(), gurl, NO_TRAFFIC_ANNOTATION_YET)); web_contents(), gurl, NO_TRAFFIC_ANNOTATION_YET));
manager->DownloadUrl(std::move(params)); manager->DownloadUrl(std::move(params));
} }
@@ -999,16 +999,17 @@ void CefBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
return; return;
} }
if (!web_contents() || !web_contents()->GetRenderViewHost()) if (enabled == auto_resize_enabled_)
return; return;
auto_resize_enabled_ = enabled;
if (enabled) { if (enabled) {
web_contents()->GetRenderViewHost()->EnableAutoResize( auto_resize_min_ = gfx::Size(min_size.width, min_size.height);
gfx::Size(min_size.width, min_size.height), auto_resize_max_ = gfx::Size(max_size.width, max_size.height);
gfx::Size(max_size.width, max_size.height));
} else { } else {
web_contents()->GetRenderViewHost()->DisableAutoResize(gfx::Size()); auto_resize_min_ = auto_resize_max_ = gfx::Size();
} }
ConfigureAutoResize();
} }
CefRefPtr<CefExtension> CefBrowserHostImpl::GetExtension() { CefRefPtr<CefExtension> CefBrowserHostImpl::GetExtension() {
@@ -1589,10 +1590,13 @@ CefRefPtr<CefFrame> CefBrowserHostImpl::GetFrameForRequest(
content::ResourceRequestInfo::ForRequest(request); content::ResourceRequestInfo::ForRequest(request);
if (!info) if (!info)
return nullptr; return nullptr;
// The value of |IsMainFrame| is unreliable when |IsDownload| returns true. // The value of |IsMainFrame| is unreliable in these cases.
const bool is_main_frame_state_flaky =
info->IsDownload() ||
info->GetResourceType() == content::RESOURCE_TYPE_XHR;
return GetOrCreateFrame(info->GetRenderFrameID(), info->GetFrameTreeNodeId(), return GetOrCreateFrame(info->GetRenderFrameID(), info->GetFrameTreeNodeId(),
CefFrameHostImpl::kUnspecifiedFrameId, CefFrameHostImpl::kUnspecifiedFrameId,
info->IsMainFrame(), info->IsDownload(), info->IsMainFrame(), is_main_frame_state_flaky,
base::string16(), GURL()); base::string16(), GURL());
} }
@@ -2221,6 +2225,16 @@ void CefBrowserHostImpl::LoadingStateChanged(content::WebContents* source,
} }
} }
void CefBrowserHostImpl::LoadProgressChanged(content::WebContents* source,
double progress) {
if (client_.get()) {
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
if (handler.get()) {
handler->OnLoadingProgressChange(this, progress);
}
}
}
void CefBrowserHostImpl::CloseContents(content::WebContents* source) { void CefBrowserHostImpl::CloseContents(content::WebContents* source) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
@@ -2573,7 +2587,7 @@ void CefBrowserHostImpl::RequestMediaAccessPermission(
} }
bool CefBrowserHostImpl::CheckMediaAccessPermission( bool CefBrowserHostImpl::CheckMediaAccessPermission(
content::WebContents* web_contents, content::RenderFrameHost* render_frame_host,
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType type) { content::MediaStreamType type) {
// Check media access permission without prompting the user. This is called // Check media access permission without prompting the user. This is called
@@ -2691,6 +2705,8 @@ void CefBrowserHostImpl::RenderViewDeleted(
} }
void CefBrowserHostImpl::RenderViewReady() { void CefBrowserHostImpl::RenderViewReady() {
ConfigureAutoResize();
// Send the queued messages. // Send the queued messages.
queue_messages_ = false; queue_messages_ = false;
while (!queued_messages_.empty()) { while (!queued_messages_.empty()) {
@@ -3211,7 +3227,7 @@ CefRefPtr<CefFrame> CefBrowserHostImpl::GetOrCreateFrame(
int frame_tree_node_id, int frame_tree_node_id,
int64 parent_frame_id, int64 parent_frame_id,
bool is_main_frame, bool is_main_frame,
bool is_download, bool is_main_frame_state_flaky,
base::string16 frame_name, base::string16 frame_name,
const GURL& frame_url) { const GURL& frame_url) {
// We need either a valid |frame_id| or a valid |frame_tree_node_id|. // We need either a valid |frame_id| or a valid |frame_tree_node_id|.
@@ -3232,13 +3248,13 @@ CefRefPtr<CefFrame> CefBrowserHostImpl::GetOrCreateFrame(
if (frame_id < 0) { if (frame_id < 0) {
// With PlzNavigate the renderer process representation might not exist yet. // With PlzNavigate the renderer process representation might not exist yet.
if ((is_main_frame || is_download) && if ((is_main_frame || is_main_frame_state_flaky) &&
main_frame_id_ != CefFrameHostImpl::kInvalidFrameId) { main_frame_id_ != CefFrameHostImpl::kInvalidFrameId) {
// Operating in the main frame. Continue using the existing main frame // Operating in the main frame. Continue using the existing main frame
// object until the new renderer process representation is created. // object until the new renderer process representation is created.
frame_id = main_frame_id_; frame_id = main_frame_id_;
} else { } else {
if (is_main_frame || is_download) { if (is_main_frame || is_main_frame_state_flaky) {
// Always use the same pending object for the main frame. // Always use the same pending object for the main frame.
frame_tree_node_id = kMainFrameTreeNodeId; frame_tree_node_id = kMainFrameTreeNodeId;
} }
@@ -3306,7 +3322,7 @@ CefRefPtr<CefFrame> CefBrowserHostImpl::GetOrCreateFrame(
} }
} }
if (!frame_created && !is_download) if (!frame_created && !is_main_frame_state_flaky)
frame->SetAttributes(is_main_frame, url, name, parent_frame_id); frame->SetAttributes(is_main_frame, url, name, parent_frame_id);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
@@ -3497,6 +3513,20 @@ void CefBrowserHostImpl::EnsureFileDialogManager() {
} }
} }
void CefBrowserHostImpl::ConfigureAutoResize() {
CEF_REQUIRE_UIT();
if (!web_contents() || !web_contents()->GetRenderWidgetHostView()) {
return;
}
if (auto_resize_enabled_) {
web_contents()->GetRenderWidgetHostView()->EnableAutoResize(
auto_resize_min_, auto_resize_max_);
} else {
web_contents()->GetRenderWidgetHostView()->DisableAutoResize(gfx::Size());
}
}
bool CefBrowserHostImpl::Send(IPC::Message* message) { bool CefBrowserHostImpl::Send(IPC::Message* message) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK( CEF_POST_TASK(

View File

@@ -407,6 +407,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(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,
@@ -471,14 +473,13 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::WebContents* web_contents, content::WebContents* web_contents,
const content::MediaStreamRequest& request, const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback) override; const content::MediaResponseCallback& callback) override;
bool CheckMediaAccessPermission(content::WebContents* web_contents, bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType type) override; content::MediaStreamType type) override;
bool IsNeverVisible(content::WebContents* web_contents) override; bool IsNeverVisible(content::WebContents* web_contents) override;
// content::WebContentsObserver methods. // content::WebContentsObserver methods.
using content::WebContentsObserver::BeforeUnloadFired; using content::WebContentsObserver::BeforeUnloadFired;
using content::WebContentsObserver::WasHidden;
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
void RenderFrameHostChanged(content::RenderFrameHost* old_host, void RenderFrameHostChanged(content::RenderFrameHost* old_host,
content::RenderFrameHost* new_host) override; content::RenderFrameHost* new_host) override;
@@ -585,13 +586,13 @@ class CefBrowserHostImpl : public CefBrowserHost,
// if PlzNavigate is disabled; or >= 0 otherwise. |parent_frame_id| will be // if PlzNavigate is disabled; or >= 0 otherwise. |parent_frame_id| will be
// CefFrameHostImpl::kUnspecifiedFrameId if unknown. In cases where |frame_id| // CefFrameHostImpl::kUnspecifiedFrameId if unknown. In cases where |frame_id|
// is < 0 either the existing main frame object or a pending object will be // is < 0 either the existing main frame object or a pending object will be
// returned depending on current state. If |is_download| is true then the // returned depending on current state. If |is_main_frame_state_flaky| is true
// value of |is_main_frame| cannot be relied on. // then the value of |is_main_frame| cannot be relied on.
CefRefPtr<CefFrame> GetOrCreateFrame(int64 frame_id, CefRefPtr<CefFrame> GetOrCreateFrame(int64 frame_id,
int frame_tree_node_id, int frame_tree_node_id,
int64 parent_frame_id, int64 parent_frame_id,
bool is_main_frame, bool is_main_frame,
bool is_download, bool is_main_frame_state_flaky,
base::string16 frame_name, base::string16 frame_name,
const GURL& frame_url); const GURL& frame_url);
@@ -625,6 +626,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Create the CefFileDialogManager if it doesn't already exist. // Create the CefFileDialogManager if it doesn't already exist.
void EnsureFileDialogManager(); void EnsureFileDialogManager();
void ConfigureAutoResize();
// Send a message to the RenderViewHost associated with this browser. // Send a message to the RenderViewHost associated with this browser.
// TODO(cef): With the introduction of OOPIFs, WebContents can span multiple // TODO(cef): With the introduction of OOPIFs, WebContents can span multiple
// processes. Messages should be sent to specific RenderFrameHosts instead. // processes. Messages should be sent to specific RenderFrameHosts instead.
@@ -726,6 +729,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
CefRefPtr<CefExtension> extension_; CefRefPtr<CefExtension> extension_;
bool is_background_host_ = false; bool is_background_host_ = false;
// Used with auto-resize.
bool auto_resize_enabled_ = false;
gfx::Size auto_resize_min_;
gfx::Size auto_resize_max_;
IMPLEMENT_REFCOUNTING(CefBrowserHostImpl); IMPLEMENT_REFCOUNTING(CefBrowserHostImpl);
DISALLOW_COPY_AND_ASSIGN(CefBrowserHostImpl); DISALLOW_COPY_AND_ASSIGN(CefBrowserHostImpl);
}; };

View File

@@ -154,7 +154,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
window_info->SetAsPopup(NULL, CefString()); window_info->SetAsPopup(NULL, CefString());
#endif #endif
auto pending_popup = base::MakeUnique<CefBrowserInfoManager::PendingPopup>(); auto pending_popup = std::make_unique<CefBrowserInfoManager::PendingPopup>();
pending_popup->step = CefBrowserInfoManager::PendingPopup::CAN_CREATE_WINDOW; pending_popup->step = CefBrowserInfoManager::PendingPopup::CAN_CREATE_WINDOW;
pending_popup->opener_process_id = opener->GetProcess()->GetID(); pending_popup->opener_process_id = opener->GetProcess()->GetID();
pending_popup->opener_frame_id = opener->GetRoutingID(); pending_popup->opener_frame_id = opener->GetRoutingID();

View File

@@ -16,7 +16,7 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "content/public/browser/render_process_host_observer.h" #include "content/public/browser/render_process_host_observer.h"
#include "third_party/WebKit/public/web/window_features.mojom.h" #include "third_party/blink/public/web/window_features.mojom.h"
#include "ui/base/window_open_disposition.h" #include "ui/base/window_open_disposition.h"
#include "url/gurl.h" #include "url/gurl.h"

View File

@@ -26,6 +26,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/task_scheduler/post_task.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
#include "chrome/browser/plugins/plugin_finder.h" #include "chrome/browser/plugins/plugin_finder.h"
#include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/gpu_data_manager.h"
#include "content/public/common/result_codes.h" #include "content/public/common/result_codes.h"
@@ -58,13 +60,14 @@ CefBrowserMainParts::CefBrowserMainParts(
const content::MainFunctionParams& parameters) const content::MainFunctionParams& parameters)
: BrowserMainParts(), devtools_delegate_(NULL) {} : BrowserMainParts(), devtools_delegate_(NULL) {}
CefBrowserMainParts::~CefBrowserMainParts() {} CefBrowserMainParts::~CefBrowserMainParts() {
for (int i = static_cast<int>(chrome_extra_parts_.size()) - 1; i >= 0; --i)
delete chrome_extra_parts_[i];
chrome_extra_parts_.clear();
}
void CefBrowserMainParts::PreMainMessageLoopStart() { void CefBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
if (!base::MessageLoop::current()) { chrome_extra_parts_.push_back(parts);
// Create the browser message loop.
message_loop_.reset(new CefBrowserMessageLoop());
}
} }
int CefBrowserMainParts::PreEarlyInitialization() { int CefBrowserMainParts::PreEarlyInitialization() {
@@ -73,9 +76,18 @@ int CefBrowserMainParts::PreEarlyInitialization() {
// views::LinuxUI::SetInstance. // views::LinuxUI::SetInstance.
ui::InitializeInputMethodForTesting(); ui::InitializeInputMethodForTesting();
#endif #endif
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreEarlyInitialization();
return content::RESULT_CODE_NORMAL_EXIT; return content::RESULT_CODE_NORMAL_EXIT;
} }
void CefBrowserMainParts::PostEarlyInitialization() {
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostEarlyInitialization();
}
void CefBrowserMainParts::ToolkitInitialized() { void CefBrowserMainParts::ToolkitInitialized() {
#if defined(USE_AURA) #if defined(USE_AURA)
CHECK(aura::Env::GetInstance()); CHECK(aura::Env::GetInstance());
@@ -89,6 +101,19 @@ void CefBrowserMainParts::ToolkitInitialized() {
CefContentBrowserClient::Get()->GetResourceDllName()); CefContentBrowserClient::Get()->GetResourceDllName());
#endif #endif
#endif // defined(USE_AURA) #endif // defined(USE_AURA)
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->ToolkitInitialized();
}
void CefBrowserMainParts::PreMainMessageLoopStart() {
if (!base::MessageLoop::current()) {
// Create the browser message loop.
message_loop_.reset(new CefBrowserMessageLoop());
}
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreMainMessageLoopStart();
} }
void CefBrowserMainParts::PostMainMessageLoopStart() { void CefBrowserMainParts::PostMainMessageLoopStart() {
@@ -98,6 +123,9 @@ void CefBrowserMainParts::PostMainMessageLoopStart() {
printing::PrintingContextLinux::SetPdfPaperSizeFunction( printing::PrintingContextLinux::SetPdfPaperSizeFunction(
&CefPrintDialogLinux::GetPdfPaperSize); &CefPrintDialogLinux::GetPdfPaperSize);
#endif #endif
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopStart();
} }
int CefBrowserMainParts::PreCreateThreads() { int CefBrowserMainParts::PreCreateThreads() {
@@ -111,14 +139,26 @@ int CefBrowserMainParts::PreCreateThreads() {
// before the IO thread is started. // before the IO thread is started.
content::GpuDataManager::GetInstance(); content::GpuDataManager::GetInstance();
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreCreateThreads();
return 0; return 0;
} }
void CefBrowserMainParts::ServiceManagerConnectionStarted(
content::ServiceManagerConnection* connection) {
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->ServiceManagerConnectionStarted(connection);
}
void CefBrowserMainParts::PreMainMessageLoopRun() { void CefBrowserMainParts::PreMainMessageLoopRun() {
#if defined(USE_AURA) #if defined(USE_AURA)
display::Screen::SetScreenInstance(views::CreateDesktopScreen()); display::Screen::SetScreenInstance(views::CreateDesktopScreen());
#endif #endif
// CEF's profile is a BrowserContext.
PreProfileInit();
if (extensions::ExtensionsEnabled()) { if (extensions::ExtensionsEnabled()) {
// Initialize extension global objects before creating the global // Initialize extension global objects before creating the global
// BrowserContext. // BrowserContext.
@@ -137,6 +177,16 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
printing::CefPrintingMessageFilter::EnsureShutdownNotifierFactoryBuilt(); printing::CefPrintingMessageFilter::EnsureShutdownNotifierFactoryBuilt();
background_task_runner_ = base::CreateSingleThreadTaskRunnerWithTraits(
{base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_visible_task_runner_ = base::CreateSingleThreadTaskRunnerWithTraits(
{base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_blocking_task_runner_ = base::CreateSingleThreadTaskRunnerWithTraits(
{base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
CefRequestContextSettings settings; CefRequestContextSettings settings;
CefContext::Get()->PopulateRequestContextSettings(&settings); CefContext::Get()->PopulateRequestContextSettings(&settings);
@@ -146,12 +196,21 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
CefBrowserContextImpl* browser_context = static_cast<CefBrowserContextImpl*>( CefBrowserContextImpl* browser_context = static_cast<CefBrowserContextImpl*>(
global_request_context_->GetBrowserContext()); global_request_context_->GetBrowserContext());
PostProfileInit();
CefDevToolsManagerDelegate::StartHttpHandler(browser_context); CefDevToolsManagerDelegate::StartHttpHandler(browser_context);
// Triggers initialization of the singleton instance on UI thread. // Triggers initialization of the singleton instance on UI thread.
PluginFinder::GetInstance()->Init(); PluginFinder::GetInstance()->Init();
scheme::RegisterWebUIControllerFactory(); scheme::RegisterWebUIControllerFactory();
// These have no equivalent in CEF.
PreBrowserStart();
PostBrowserStart();
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreMainMessageLoopRun();
} }
void CefBrowserMainParts::PostMainMessageLoopRun() { void CefBrowserMainParts::PostMainMessageLoopRun() {
@@ -167,6 +226,9 @@ void CefBrowserMainParts::PostMainMessageLoopRun() {
extensions::ExtensionsBrowserClient::Set(NULL); extensions::ExtensionsBrowserClient::Set(NULL);
extensions_browser_client_.reset(); extensions_browser_client_.reset();
} }
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopRun();
} }
void CefBrowserMainParts::PostDestroyThreads() { void CefBrowserMainParts::PostDestroyThreads() {
@@ -175,3 +237,23 @@ void CefBrowserMainParts::PostDestroyThreads() {
delete views::ViewsDelegate::GetInstance(); delete views::ViewsDelegate::GetInstance();
#endif #endif
} }
void CefBrowserMainParts::PreProfileInit() {
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreProfileInit();
}
void CefBrowserMainParts::PostProfileInit() {
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostProfileInit();
}
void CefBrowserMainParts::PreBrowserStart() {
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreBrowserStart();
}
void CefBrowserMainParts::PostBrowserStart() {
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostBrowserStart();
}

View File

@@ -37,26 +37,51 @@ class WMState;
#endif #endif
class CefDevToolsDelegate; class CefDevToolsDelegate;
class ChromeBrowserMainExtraParts;
class CefBrowserMainParts : public content::BrowserMainParts { class CefBrowserMainParts : public content::BrowserMainParts {
public: public:
explicit CefBrowserMainParts(const content::MainFunctionParams& parameters); explicit CefBrowserMainParts(const content::MainFunctionParams& parameters);
~CefBrowserMainParts() override; ~CefBrowserMainParts() override;
// Add additional ChromeBrowserMainExtraParts.
void AddParts(ChromeBrowserMainExtraParts* parts);
int PreEarlyInitialization() override;
void PostEarlyInitialization() override;
void ToolkitInitialized() override;
void PreMainMessageLoopStart() override; void PreMainMessageLoopStart() override;
void PostMainMessageLoopStart() override; void PostMainMessageLoopStart() override;
int PreEarlyInitialization() override;
void ToolkitInitialized() override;
int PreCreateThreads() override; int PreCreateThreads() override;
void ServiceManagerConnectionStarted(
content::ServiceManagerConnection* connection);
void PreMainMessageLoopRun() override; void PreMainMessageLoopRun() override;
void PostMainMessageLoopRun() override; void PostMainMessageLoopRun() override;
void PostDestroyThreads() override; void PostDestroyThreads() override;
// Additional stages for ChromeBrowserMainExtraParts. These stages are called
// in order from PreMainMessageLoopRun(). See implementation for details.
void PreProfileInit();
void PostProfileInit();
void PreBrowserStart();
void PostBrowserStart();
CefRefPtr<CefRequestContextImpl> request_context() const { CefRefPtr<CefRequestContextImpl> request_context() const {
return global_request_context_; return global_request_context_;
} }
CefDevToolsDelegate* devtools_delegate() const { return devtools_delegate_; } CefDevToolsDelegate* devtools_delegate() const { return devtools_delegate_; }
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const {
return background_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const {
return user_visible_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner()
const {
return user_blocking_task_runner_;
}
private: private:
#if defined(OS_WIN) #if defined(OS_WIN)
void PlatformInitialize(); void PlatformInitialize();
@@ -70,10 +95,22 @@ class CefBrowserMainParts : public content::BrowserMainParts {
std::unique_ptr<extensions::ExtensionsBrowserClient> std::unique_ptr<extensions::ExtensionsBrowserClient>
extensions_browser_client_; extensions_browser_client_;
// Blocking task runners exposed via CefTaskRunner. For consistency with
// previous named thread behavior always execute all pending tasks before
// shutdown (e.g. to make sure critical data is saved to disk).
// |background_task_runner_| is also passed to SQLitePersistentCookieStore.
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner_;
#if defined(USE_AURA) #if defined(USE_AURA)
std::unique_ptr<wm::WMState> wm_state_; std::unique_ptr<wm::WMState> wm_state_;
#endif #endif
// Vector of additional ChromeBrowserMainExtraParts.
// Parts are deleted in the inverse order they are added.
std::vector<ChromeBrowserMainExtraParts*> chrome_extra_parts_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts); DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts);
}; };

View File

@@ -8,11 +8,7 @@
#include "libcef/browser/browser_main.h" #include "libcef/browser/browser_main.h"
#include "cef/grit/cef_strings.h" #include "base/logging.h"
#include "content/public/browser/utility_process_host.h"
#include "content/public/browser/utility_process_host_client.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/win/direct_write.h"
void CefBrowserMainParts::PlatformInitialize() { void CefBrowserMainParts::PlatformInitialize() {
HRESULT res; HRESULT res;

View File

@@ -36,13 +36,13 @@ std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
const CefWindowInfo& window_info, const CefWindowInfo& window_info,
SkColor background_color) { SkColor background_color) {
#if defined(OS_WIN) #if defined(OS_WIN)
return base::MakeUnique<CefBrowserPlatformDelegateNativeWin>( return std::make_unique<CefBrowserPlatformDelegateNativeWin>(
window_info, background_color); window_info, background_color);
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
return base::MakeUnique<CefBrowserPlatformDelegateNativeMac>( return std::make_unique<CefBrowserPlatformDelegateNativeMac>(
window_info, background_color); window_info, background_color);
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
return base::MakeUnique<CefBrowserPlatformDelegateNativeLinux>( return std::make_unique<CefBrowserPlatformDelegateNativeLinux>(
window_info, background_color); window_info, background_color);
#endif #endif
} }
@@ -50,13 +50,13 @@ std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate( std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate) { std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate) {
#if defined(OS_WIN) #if defined(OS_WIN)
return base::MakeUnique<CefBrowserPlatformDelegateOsrWin>( return std::make_unique<CefBrowserPlatformDelegateOsrWin>(
std::move(native_delegate)); std::move(native_delegate));
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
return base::MakeUnique<CefBrowserPlatformDelegateOsrMac>( return std::make_unique<CefBrowserPlatformDelegateOsrMac>(
std::move(native_delegate)); std::move(native_delegate));
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
return base::MakeUnique<CefBrowserPlatformDelegateOsrLinux>( return std::make_unique<CefBrowserPlatformDelegateOsrLinux>(
std::move(native_delegate)); std::move(native_delegate));
#endif #endif
} }
@@ -85,7 +85,7 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
// Creating a background extension host without a window. // Creating a background extension host without a window.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate = std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo(), background_color); CreateNativeDelegate(CefWindowInfo(), background_color);
return base::MakeUnique<CefBrowserPlatformDelegateBackground>( return std::make_unique<CefBrowserPlatformDelegateBackground>(
std::move(native_delegate)); std::move(native_delegate));
} }
#if defined(USE_AURA) #if defined(USE_AURA)
@@ -93,7 +93,7 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
// CefWindowInfo is not used in this case. // CefWindowInfo is not used in this case.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate = std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo(), background_color); CreateNativeDelegate(CefWindowInfo(), background_color);
return base::MakeUnique<CefBrowserPlatformDelegateViews>( return std::make_unique<CefBrowserPlatformDelegateViews>(
std::move(native_delegate), std::move(native_delegate),
static_cast<CefBrowserViewImpl*>(create_params.browser_view.get())); static_cast<CefBrowserViewImpl*>(create_params.browser_view.get()));
} }

View File

@@ -356,6 +356,9 @@ class CefBrowserURLRequest::Context
CefResponseImpl* responseImpl = CefResponseImpl* responseImpl =
static_cast<CefResponseImpl*>(response_.get()); static_cast<CefResponseImpl*>(response_.get());
responseImpl->SetURL(fetcher_->GetURL().spec());
responseImpl->SetStatus(fetcher_->GetResponseCode());
net::HttpResponseHeaders* headers = fetcher_->GetResponseHeaders(); net::HttpResponseHeaders* headers = fetcher_->GetResponseHeaders();
if (headers) if (headers)
responseImpl->SetResponseHeaders(*headers); responseImpl->SetResponseHeaders(*headers);

View File

@@ -15,7 +15,7 @@
#include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/print_job_manager.h"
#include "components/net_log/chrome_net_log.h" #include "components/net_log/chrome_net_log.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "ui/message_center/message_center.h" #include "services/network/public/cpp/network_switches.h"
ChromeBrowserProcessStub::ChromeBrowserProcessStub() ChromeBrowserProcessStub::ChromeBrowserProcessStub()
: initialized_(false), : initialized_(false),
@@ -165,11 +165,6 @@ ChromeBrowserProcessStub::notification_platform_bridge() {
return NULL; return NULL;
} }
message_center::MessageCenter* ChromeBrowserProcessStub::message_center() {
NOTREACHED();
return NULL;
}
policy::ChromeBrowserPolicyConnector* policy::ChromeBrowserPolicyConnector*
ChromeBrowserProcessStub::browser_policy_connector() { ChromeBrowserProcessStub::browser_policy_connector() {
NOTREACHED(); NOTREACHED();
@@ -191,9 +186,7 @@ GpuModeManager* ChromeBrowserProcessStub::gpu_mode_manager() {
return NULL; return NULL;
} }
void ChromeBrowserProcessStub::CreateDevToolsHttpProtocolHandler( void ChromeBrowserProcessStub::CreateDevToolsProtocolHandler() {
const std::string& ip,
uint16_t port) {
NOTREACHED(); NOTREACHED();
} }
@@ -296,10 +289,10 @@ net_log::ChromeNetLog* ChromeBrowserProcessStub::net_log() {
if (!net_log_) { if (!net_log_) {
const base::CommandLine& command_line = const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
net_log_ = base::MakeUnique<net_log::ChromeNetLog>(); net_log_ = std::make_unique<net_log::ChromeNetLog>();
if (command_line.HasSwitch(switches::kLogNetLog)) { if (command_line.HasSwitch(network::switches::kLogNetLog)) {
net_log_->StartWritingToFile( net_log_->StartWritingToFile(
command_line.GetSwitchValuePath(switches::kLogNetLog), command_line.GetSwitchValuePath(network::switches::kLogNetLog),
GetNetCaptureModeFromCommandLine(command_line), GetNetCaptureModeFromCommandLine(command_line),
command_line.GetCommandLineString(), std::string()); command_line.GetCommandLineString(), std::string());
} }

View File

@@ -16,7 +16,7 @@
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/event_router_forwarder.h" #include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
#include "media/media_features.h" #include "media/media_buildflags.h"
class ChromeProfileManagerStub; class ChromeProfileManagerStub;
@@ -59,13 +59,11 @@ class ChromeBrowserProcessStub : public BrowserProcess,
extensions::EventRouterForwarder* extension_event_router_forwarder() override; extensions::EventRouterForwarder* extension_event_router_forwarder() override;
NotificationUIManager* notification_ui_manager() override; NotificationUIManager* notification_ui_manager() override;
NotificationPlatformBridge* notification_platform_bridge() override; NotificationPlatformBridge* notification_platform_bridge() override;
message_center::MessageCenter* message_center() override;
policy::ChromeBrowserPolicyConnector* browser_policy_connector() override; policy::ChromeBrowserPolicyConnector* browser_policy_connector() override;
policy::PolicyService* policy_service() override; policy::PolicyService* policy_service() override;
IconManager* icon_manager() override; IconManager* icon_manager() override;
GpuModeManager* gpu_mode_manager() override; GpuModeManager* gpu_mode_manager() override;
void CreateDevToolsHttpProtocolHandler(const std::string& ip, void CreateDevToolsProtocolHandler() override;
uint16_t port) override;
void CreateDevToolsAutoOpener() override; void CreateDevToolsAutoOpener() override;
bool IsShuttingDown() override; bool IsShuttingDown() override;
printing::PrintJobManager* print_job_manager() override; printing::PrintJobManager* print_job_manager() override;

View File

@@ -41,6 +41,7 @@
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "cef/grit/cef_resources.h" #include "cef/grit/cef_resources.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_service.h" #include "chrome/browser/chrome_service.h"
#include "chrome/browser/plugins/plugin_info_host_impl.h" #include "chrome/browser/plugins/plugin_info_host_impl.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
@@ -49,7 +50,7 @@
#include "chrome/common/constants.mojom.h" #include "chrome/common/constants.mojom.h"
#include "chrome/grit/browser_resources.h" #include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/services/printing/public/interfaces/constants.mojom.h" #include "chrome/services/printing/public/mojom/constants.mojom.h"
#include "components/navigation_interception/intercept_navigation_throttle.h" #include "components/navigation_interception/intercept_navigation_throttle.h"
#include "components/navigation_interception/navigation_params.h" #include "components/navigation_interception/navigation_params.h"
#include "components/printing/service/public/interfaces/pdf_compositor.mojom.h" #include "components/printing/service/public/interfaces/pdf_compositor.mojom.h"
@@ -75,7 +76,9 @@
#include "content/public/common/service_names.mojom.h" #include "content/public/common/service_names.mojom.h"
#include "content/public/common/storage_quota_params.h" #include "content/public/common/storage_quota_params.h"
#include "content/public/common/web_preferences.h" #include "content/public/common/web_preferences.h"
#include "extensions/browser/api/web_request/web_request_api.h"
#include "extensions/browser/extension_message_filter.h" #include "extensions/browser/extension_message_filter.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#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"
@@ -84,9 +87,9 @@
#include "extensions/common/switches.h" #include "extensions/common/switches.h"
#include "net/ssl/ssl_cert_request_info.h" #include "net/ssl/ssl_cert_request_info.h"
#include "ppapi/host/ppapi_host.h" #include "ppapi/host/ppapi_host.h"
#include "services/proxy_resolver/public/interfaces/proxy_resolver.mojom.h" #include "services/service_manager/public/mojom/connector.mojom.h"
#include "storage/browser/quota/quota_settings.h" #include "storage/browser/quota/quota_settings.h"
#include "third_party/WebKit/public/web/WebWindowFeatures.h" #include "third_party/blink/public/web/web_window_features.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
@@ -96,10 +99,6 @@
#include "libcef/common/widevine_loader.h" #include "libcef/common/widevine_loader.h"
#endif #endif
#if defined(OS_MACOSX)
#include "components/spellcheck/browser/spellcheck_message_filter_platform.h"
#endif
#if defined(OS_POSIX) && !defined(OS_MACOSX) #if defined(OS_POSIX) && !defined(OS_MACOSX)
#include "base/debug/leak_annotations.h" #include "base/debug/leak_annotations.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
@@ -430,7 +429,8 @@ bool NavigationOnUIThread(
request->SetReadOnly(true); request->SetReadOnly(true);
ignore_navigation = handler->OnBeforeBrowse( ignore_navigation = handler->OnBeforeBrowse(
browser.get(), frame, request.get(), params.is_redirect()); browser.get(), frame, request.get(), params.has_user_gesture(),
params.is_redirect());
} }
} }
} }
@@ -450,6 +450,8 @@ CefContentBrowserClient::~CefContentBrowserClient() {}
// static // static
CefContentBrowserClient* CefContentBrowserClient::Get() { CefContentBrowserClient* CefContentBrowserClient::Get() {
if (!CefContentClient::Get())
return nullptr;
return static_cast<CefContentBrowserClient*>( return static_cast<CefContentBrowserClient*>(
CefContentClient::Get()->browser()); CefContentClient::Get()->browser());
} }
@@ -457,25 +459,20 @@ CefContentBrowserClient* CefContentBrowserClient::Get() {
content::BrowserMainParts* CefContentBrowserClient::CreateBrowserMainParts( content::BrowserMainParts* CefContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) { const content::MainFunctionParams& parameters) {
browser_main_parts_ = new CefBrowserMainParts(parameters); browser_main_parts_ = new CefBrowserMainParts(parameters);
browser_main_parts_->AddParts(
ChromeService::GetInstance()->CreateExtraParts());
return browser_main_parts_; return browser_main_parts_;
} }
void CefContentBrowserClient::RenderProcessWillLaunch( void CefContentBrowserClient::RenderProcessWillLaunch(
content::RenderProcessHost* host) { content::RenderProcessHost* host,
service_manager::mojom::ServiceRequest* service_request) {
const int id = host->GetID(); const int id = host->GetID();
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
host->AddFilter(new CefBrowserMessageFilter(id)); host->AddFilter(new CefBrowserMessageFilter(id));
host->AddFilter(new printing::CefPrintingMessageFilter(id, profile)); host->AddFilter(new printing::CefPrintingMessageFilter(id, profile));
#if defined(OS_MACOSX)
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
host->AddFilter(new SpellCheckMessageFilterPlatform(id));
}
#endif
if (extensions::ExtensionsEnabled()) { if (extensions::ExtensionsEnabled()) {
host->AddFilter(new extensions::ExtensionMessageFilter(id, profile)); host->AddFilter(new extensions::ExtensionMessageFilter(id, profile));
host->AddFilter( host->AddFilter(
@@ -492,6 +489,16 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
host->Send( host->Send(
new CefProcessMsg_SetIsIncognitoProcess(profile->IsOffTheRecord())); new CefProcessMsg_SetIsIncognitoProcess(profile->IsOffTheRecord()));
service_manager::mojom::ServicePtr service;
*service_request = mojo::MakeRequest(&service);
service_manager::mojom::PIDReceiverPtr pid_receiver;
service_manager::Identity renderer_identity = host->GetChildIdentity();
ChromeService::GetInstance()->connector()->StartService(
service_manager::Identity(chrome::mojom::kRendererServiceName,
renderer_identity.user_id(),
renderer_identity.instance()),
std::move(service), mojo::MakeRequest(&pid_receiver));
} }
bool CefContentBrowserClient::ShouldUseProcessPerSite( bool CefContentBrowserClient::ShouldUseProcessPerSite(
@@ -594,7 +601,7 @@ void CefContentBrowserClient::RegisterInProcessServices(
{ {
// For spell checking. // For spell checking.
service_manager::EmbeddedServiceInfo info; service_manager::EmbeddedServiceInfo info;
info.factory = base::Bind(&ChromeService::Create); info.factory = ChromeService::GetInstance()->CreateChromeServiceFactory();
services->insert(std::make_pair(chrome::mojom::kServiceName, info)); services->insert(std::make_pair(chrome::mojom::kServiceName, info));
} }
} }
@@ -633,6 +640,8 @@ std::vector<content::ContentBrowserClient::ServiceManifestInfo>
CefContentBrowserClient::GetExtraServiceManifests() { CefContentBrowserClient::GetExtraServiceManifests() {
return std::vector<ServiceManifestInfo>({ return std::vector<ServiceManifestInfo>({
{printing::mojom::kServiceName, IDR_PDF_COMPOSITOR_MANIFEST}, {printing::mojom::kServiceName, IDR_PDF_COMPOSITOR_MANIFEST},
{chrome::mojom::kRendererServiceName,
IDR_CHROME_RENDERER_SERVICE_MANIFEST},
}); });
} }
@@ -723,7 +732,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) #if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
if (!browser_cmd->HasSwitch(switches::kNoSandbox)) { if (!browser_cmd->HasSwitch(switches::kNoSandbox)) {
// Pass the Widevine CDM path to the Zygote process. See comments in // Pass the Widevine CDM path to the Zygote process. See comments in
// CefWidevineLoader::AddPepperPlugins. // CefWidevineLoader::AddContentDecryptionModules.
const base::FilePath& cdm_path = CefWidevineLoader::GetInstance()->path(); const base::FilePath& cdm_path = CefWidevineLoader::GetInstance()->path();
if (!cdm_path.empty()) if (!cdm_path.empty())
command_line->AppendSwitchPath(switches::kWidevineCdmPath, cdm_path); command_line->AppendSwitchPath(switches::kWidevineCdmPath, cdm_path);
@@ -753,6 +762,10 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
} }
} }
std::string CefContentBrowserClient::GetApplicationLocale() {
return g_browser_process->GetApplicationLocale();
}
content::QuotaPermissionContext* content::QuotaPermissionContext*
CefContentBrowserClient::CreateQuotaPermissionContext() { CefContentBrowserClient::CreateQuotaPermissionContext() {
return new CefQuotaPermissionContext(); return new CefQuotaPermissionContext();
@@ -958,7 +971,7 @@ CefContentBrowserClient::CreateThrottlesForNavigation(
} }
std::unique_ptr<content::NavigationThrottle> throttle = std::unique_ptr<content::NavigationThrottle> throttle =
base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( std::make_unique<navigation_interception::InterceptNavigationThrottle>(
navigation_handle, base::Bind(&NavigationOnUIThread, is_main_frame, navigation_handle, base::Bind(&NavigationOnUIThread, is_main_frame,
frame_id, parent_frame_id)); frame_id, parent_frame_id));
throttles.push_back(std::move(throttle)); throttles.push_back(std::move(throttle));
@@ -1010,6 +1023,77 @@ void CefContentBrowserClient::ExposeInterfacesToRenderer(
base::MakeRefCounted<PluginInfoHostImpl>(host->GetID(), profile))); base::MakeRefCounted<PluginInfoHostImpl>(host->GetID(), profile)));
} }
std::unique_ptr<net::ClientCertStore>
CefContentBrowserClient::CreateClientCertStore(
content::ResourceContext* resource_context) {
if (!resource_context)
return nullptr;
return static_cast<CefResourceContext*>(resource_context)
->CreateClientCertStore();
}
void CefContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
content::RenderFrameHost* frame_host,
NonNetworkURLLoaderFactoryMap* factories) {
if (!extensions::ExtensionsEnabled())
return;
content::BrowserContext* browser_context =
frame_host->GetProcess()->GetBrowserContext();
factories->emplace(
extensions::kExtensionScheme,
extensions::CreateExtensionNavigationURLLoaderFactory(
frame_host,
extensions::ExtensionSystem::Get(browser_context)->info_map()));
}
void CefContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
content::RenderFrameHost* frame_host,
const GURL& frame_url,
NonNetworkURLLoaderFactoryMap* factories) {
if (!extensions::ExtensionsEnabled())
return;
content::BrowserContext* browser_context =
frame_host->GetProcess()->GetBrowserContext();
auto factory = extensions::MaybeCreateExtensionSubresourceURLLoaderFactory(
frame_host, frame_url,
extensions::ExtensionSystem::Get(browser_context)->info_map());
if (factory)
factories->emplace(extensions::kExtensionScheme, std::move(factory));
}
bool CefContentBrowserClient::WillCreateURLLoaderFactory(
content::RenderFrameHost* frame,
bool is_navigation,
network::mojom::URLLoaderFactoryRequest* factory_request) {
if (!extensions::ExtensionsEnabled())
return false;
auto* web_request_api =
extensions::BrowserContextKeyedAPIFactory<extensions::WebRequestAPI>::Get(
frame->GetProcess()->GetBrowserContext());
return web_request_api->MaybeProxyURLLoaderFactory(frame, is_navigation,
factory_request);
}
bool CefContentBrowserClient::HandleExternalProtocol(
const GURL& url,
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
int child_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture) {
CEF_POST_TASK(
CEF_UIT,
base::Bind(
base::IgnoreResult(
&CefContentBrowserClient::HandleExternalProtocolOnUIThread),
url, web_contents_getter));
return false;
}
void CefContentBrowserClient::RegisterCustomScheme(const std::string& scheme) { void CefContentBrowserClient::RegisterCustomScheme(const std::string& scheme) {
// Register as a Web-safe scheme so that requests for the scheme from a // 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 // render process will be allowed in resource_dispatcher_host_impl.cc
@@ -1029,6 +1113,21 @@ CefDevToolsDelegate* CefContentBrowserClient::devtools_delegate() const {
return browser_main_parts_->devtools_delegate(); return browser_main_parts_->devtools_delegate();
} }
scoped_refptr<base::SingleThreadTaskRunner>
CefContentBrowserClient::background_task_runner() const {
return browser_main_parts_->background_task_runner();
}
scoped_refptr<base::SingleThreadTaskRunner>
CefContentBrowserClient::user_visible_task_runner() const {
return browser_main_parts_->user_visible_task_runner();
}
scoped_refptr<base::SingleThreadTaskRunner>
CefContentBrowserClient::user_blocking_task_runner() const {
return browser_main_parts_->user_blocking_task_runner();
}
const extensions::Extension* CefContentBrowserClient::GetExtension( const extensions::Extension* CefContentBrowserClient::GetExtension(
content::SiteInstance* site_instance) { content::SiteInstance* site_instance) {
extensions::ExtensionRegistry* registry = extensions::ExtensionRegistry* registry =
@@ -1038,3 +1137,18 @@ const extensions::Extension* CefContentBrowserClient::GetExtension(
return registry->enabled_extensions().GetExtensionOrAppByURL( return registry->enabled_extensions().GetExtensionOrAppByURL(
site_instance->GetSiteURL()); site_instance->GetSiteURL());
} }
// static
void CefContentBrowserClient::HandleExternalProtocolOnUIThread(
const GURL& url,
const content::ResourceRequestInfo::WebContentsGetter&
web_contents_getter) {
CEF_REQUIRE_UIT();
content::WebContents* web_contents = web_contents_getter.Run();
if (web_contents) {
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForContents(web_contents);
if (browser.get())
browser->HandleExternalProtocol(url);
}
}

View File

@@ -43,7 +43,9 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
// ContentBrowserClient implementation. // ContentBrowserClient implementation.
content::BrowserMainParts* CreateBrowserMainParts( content::BrowserMainParts* CreateBrowserMainParts(
const content::MainFunctionParams& parameters) override; const content::MainFunctionParams& parameters) override;
void RenderProcessWillLaunch(content::RenderProcessHost* host) override; void RenderProcessWillLaunch(
content::RenderProcessHost* host,
service_manager::mojom::ServiceRequest* service_request) override;
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context, bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
const GURL& effective_url) override; const GURL& effective_url) override;
bool IsHandledURL(const GURL& url) override; bool IsHandledURL(const GURL& url) override;
@@ -58,6 +60,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
content::BrowserContext* context2) override; content::BrowserContext* context2) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line, void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override; int child_process_id) override;
std::string GetApplicationLocale() override;
content::QuotaPermissionContext* CreateQuotaPermissionContext() override; content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
void GetQuotaSettings( void GetQuotaSettings(
content::BrowserContext* context, content::BrowserContext* context,
@@ -122,17 +125,50 @@ 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(
content::ResourceContext* resource_context) override;
void RegisterNonNetworkNavigationURLLoaderFactories(
content::RenderFrameHost* frame_host,
NonNetworkURLLoaderFactoryMap* factories) override;
void RegisterNonNetworkSubresourceURLLoaderFactories(
content::RenderFrameHost* frame_host,
const GURL& frame_url,
NonNetworkURLLoaderFactoryMap* factories) override;
bool WillCreateURLLoaderFactory(
content::RenderFrameHost* frame,
bool is_navigation,
network::mojom::URLLoaderFactoryRequest* factory_request) override;
bool HandleExternalProtocol(
const GURL& url,
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
int child_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture) override;
// Perform browser process registration for the custom scheme. // Perform browser process registration for the custom scheme.
void RegisterCustomScheme(const std::string& 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;
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const;
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const;
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner() const;
private: private:
// Returns the extension or app associated with |site_instance| or NULL. // Returns the extension or app associated with |site_instance| or NULL.
const extensions::Extension* GetExtension( const extensions::Extension* GetExtension(
content::SiteInstance* site_instance); content::SiteInstance* site_instance);
static void HandleExternalProtocolOnUIThread(
const GURL& url,
const content::ResourceRequestInfo::WebContentsGetter&
web_contents_getter);
CefBrowserMainParts* browser_main_parts_; CefBrowserMainParts* browser_main_parts_;
std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_; std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_;

View File

@@ -120,7 +120,8 @@ net::CookieStore* GetExistingCookieStoreHelper(
} // namespace } // namespace
CefCookieManagerImpl::CefCookieManagerImpl() : weak_ptr_factory_(this) {} CefCookieManagerImpl::CefCookieManagerImpl(bool is_blocking)
: is_blocking_(is_blocking), weak_ptr_factory_(this) {}
CefCookieManagerImpl::~CefCookieManagerImpl() { CefCookieManagerImpl::~CefCookieManagerImpl() {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
@@ -131,6 +132,7 @@ void CefCookieManagerImpl::Initialize(
const CefString& path, const CefString& path,
bool persist_session_cookies, bool persist_session_cookies,
CefRefPtr<CefCompletionCallback> callback) { CefRefPtr<CefCompletionCallback> callback) {
CHECK(!is_blocking_);
if (request_context.get()) { if (request_context.get()) {
request_context_ = request_context; request_context_ = request_context;
request_context_->GetRequestContextImpl( request_context_->GetRequestContextImpl(
@@ -160,7 +162,7 @@ void CefCookieManagerImpl::GetCookieStore(
return; return;
} }
DCHECK(cookie_store_.get()); DCHECK(is_blocking_ || cookie_store_.get());
// Binding ref-counted |this| to CookieStoreGetter may result in // Binding ref-counted |this| to CookieStoreGetter may result in
// heap-use-after-free if (a) the CookieStoreGetter contains the last // heap-use-after-free if (a) the CookieStoreGetter contains the last
@@ -192,7 +194,9 @@ net::CookieStore* CefCookieManagerImpl::GetExistingCookieStore() {
return cookie_store; return cookie_store;
} }
LOG(ERROR) << "Cookie store does not exist"; DCHECK(is_blocking_);
if (!is_blocking_)
LOG(ERROR) << "Cookie store does not exist";
return nullptr; return nullptr;
} }
@@ -299,7 +303,10 @@ bool CefCookieManagerImpl::SetStoragePath(
const base::FilePath& cookie_path = new_path.AppendASCII("Cookies"); const base::FilePath& cookie_path = new_path.AppendASCII("Cookies");
persistent_store = new net::SQLitePersistentCookieStore( persistent_store = new net::SQLitePersistentCookieStore(
cookie_path, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), cookie_path, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
BrowserThread::GetTaskRunnerForThread(BrowserThread::DB), // Intentionally using the background task runner exposed by CEF to
// facilitate unit test expectations. This task runner MUST be
// configured with BLOCK_SHUTDOWN.
CefContentBrowserClient::Get()->background_task_runner(),
persist_session_cookies, NULL); persist_session_cookies, NULL);
} else { } else {
NOTREACHED() << "The cookie storage directory could not be created"; NOTREACHED() << "The cookie storage directory could not be created";
@@ -495,12 +502,11 @@ void CefCookieManagerImpl::SetSupportedSchemesInternal(
return; return;
} }
DCHECK(cookie_store_.get()); DCHECK(is_blocking_ || cookie_store_.get());
if (!cookie_store_.get()) if (cookie_store_) {
return; supported_schemes_ = schemes;
SetCookieMonsterSchemes(cookie_store_.get(), supported_schemes_);
supported_schemes_ = schemes; }
SetCookieMonsterSchemes(cookie_store_.get(), supported_schemes_);
RunAsyncCompletionOnIOThread(callback); RunAsyncCompletionOnIOThread(callback);
} }
@@ -552,8 +558,13 @@ void CefCookieManagerImpl::SetCookieInternal(
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
net::CookieStore* cookie_store = cookie_store_getter.Run(); net::CookieStore* cookie_store = cookie_store_getter.Run();
if (!cookie_store) if (!cookie_store) {
if (callback.get()) {
CEF_POST_TASK(CEF_IOT, base::Bind(&CefSetCookieCallback::OnComplete,
callback.get(), false));
}
return; return;
}
std::string name = CefString(&cookie.name).ToString(); std::string name = CefString(&cookie.name).ToString();
std::string value = CefString(&cookie.value).ToString(); std::string value = CefString(&cookie.value).ToString();
@@ -584,8 +595,13 @@ void CefCookieManagerImpl::DeleteCookiesInternal(
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
net::CookieStore* cookie_store = cookie_store_getter.Run(); net::CookieStore* cookie_store = cookie_store_getter.Run();
if (!cookie_store) if (!cookie_store) {
if (callback.get()) {
CEF_POST_TASK(CEF_IOT, base::Bind(&CefDeleteCookiesCallback::OnComplete,
callback.get(), 0));
}
return; return;
}
if (url.is_empty()) { if (url.is_empty()) {
// Delete all cookies. // Delete all cookies.
@@ -610,8 +626,10 @@ void CefCookieManagerImpl::FlushStoreInternal(
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
net::CookieStore* cookie_store = cookie_store_getter.Run(); net::CookieStore* cookie_store = cookie_store_getter.Run();
if (!cookie_store) if (!cookie_store) {
RunAsyncCompletionOnIOThread(callback);
return; return;
}
cookie_store->FlushStore(base::Bind(RunAsyncCompletionOnIOThread, callback)); cookie_store->FlushStore(base::Bind(RunAsyncCompletionOnIOThread, callback));
} }
@@ -631,6 +649,11 @@ CefRefPtr<CefCookieManager> CefCookieManager::GetGlobalManager(
callback); callback);
} }
// static
CefRefPtr<CefCookieManager> CefCookieManager::GetBlockingManager() {
return new CefCookieManagerImpl(true);
}
// static // static
CefRefPtr<CefCookieManager> CefCookieManager::CreateManager( CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
const CefString& path, const CefString& path,
@@ -642,7 +665,8 @@ CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
return NULL; return NULL;
} }
CefRefPtr<CefCookieManagerImpl> cookie_manager = new CefCookieManagerImpl(); CefRefPtr<CefCookieManagerImpl> cookie_manager =
new CefCookieManagerImpl(false);
cookie_manager->Initialize(NULL, path, persist_session_cookies, callback); cookie_manager->Initialize(NULL, path, persist_session_cookies, callback);
return cookie_manager.get(); return cookie_manager.get();
} }

View File

@@ -18,10 +18,11 @@
// Implementation of the CefCookieManager interface. // Implementation of the CefCookieManager interface.
class CefCookieManagerImpl : public CefCookieManager { class CefCookieManagerImpl : public CefCookieManager {
public: public:
CefCookieManagerImpl(); explicit CefCookieManagerImpl(bool is_blocking);
~CefCookieManagerImpl() override; ~CefCookieManagerImpl() override;
// Must be called immediately after this object is created. // Must be called immediately after this object is created when |is_blocking|
// is false.
void Initialize(CefRefPtr<CefRequestContextImpl> request_context, void Initialize(CefRefPtr<CefRequestContextImpl> request_context,
const CefString& path, const CefString& path,
bool persist_session_cookies, bool persist_session_cookies,
@@ -113,6 +114,9 @@ class CefCookieManagerImpl : public CefCookieManager {
void FlushStoreInternal(CefRefPtr<CefCompletionCallback> callback, void FlushStoreInternal(CefRefPtr<CefCompletionCallback> callback,
const CookieStoreGetter& cookie_store_getter); const CookieStoreGetter& cookie_store_getter);
// If true all cookies will be blocked.
const bool is_blocking_;
// Used for cookie monsters owned by the context. // Used for cookie monsters owned by the context.
CefRefPtr<CefRequestContextImpl> request_context_; CefRefPtr<CefRequestContextImpl> request_context_;
scoped_refptr<CefURLRequestContextGetterImpl> request_context_impl_; scoped_refptr<CefURLRequestContextGetterImpl> request_context_impl_;

View File

@@ -100,7 +100,7 @@ int ResponseWriter::Finish(int net_error,
} }
static std::string GetFrontendURL() { static std::string GetFrontendURL() {
return base::StringPrintf("%s://%s/inspector.html", return base::StringPrintf("%s://%s/devtools_app.html",
content::kChromeDevToolsScheme, content::kChromeDevToolsScheme,
scheme::kChromeDevToolsHost); scheme::kChromeDevToolsHost);
} }
@@ -163,7 +163,7 @@ void CefDevToolsFrontend::InspectElementAt(int x, int y) {
if (inspect_element_at_.x != x || inspect_element_at_.y != y) if (inspect_element_at_.x != x || inspect_element_at_.y != y)
inspect_element_at_.Set(x, y); inspect_element_at_.Set(x, y);
if (agent_host_) if (agent_host_)
agent_host_->InspectElement(this, x, y); agent_host_->InspectElement(inspected_contents_->GetFocusedFrame(), x, y);
} }
void CefDevToolsFrontend::Close() { void CefDevToolsFrontend::Close() {
@@ -226,8 +226,8 @@ void CefDevToolsFrontend::DocumentAvailableInMainFrame() {
agent_host_ = agent_host; agent_host_ = agent_host;
agent_host_->AttachClient(this); agent_host_->AttachClient(this);
if (!inspect_element_at_.IsEmpty()) { if (!inspect_element_at_.IsEmpty()) {
agent_host_->InspectElement(this, inspect_element_at_.x, agent_host_->InspectElement(inspected_contents_->GetFocusedFrame(),
inspect_element_at_.y); inspect_element_at_.x, inspect_element_at_.y);
} }
} }
} }
@@ -392,7 +392,7 @@ void CefDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) {
DCHECK(it != pending_requests_.end()); DCHECK(it != pending_requests_.end());
base::DictionaryValue response; base::DictionaryValue response;
auto headers = base::MakeUnique<base::DictionaryValue>(); auto headers = std::make_unique<base::DictionaryValue>();
net::HttpResponseHeaders* rh = source->GetResponseHeaders(); net::HttpResponseHeaders* rh = source->GetResponseHeaders();
response.SetInteger("statusCode", rh ? rh->response_code() : 200); response.SetInteger("statusCode", rh ? rh->response_code() : 200);

View File

@@ -105,8 +105,7 @@ void CefDevToolsManagerDelegate::StartHttpHandler(
if (!socket_factory) if (!socket_factory)
return; return;
content::DevToolsAgentHost::StartRemoteDebuggingServer( content::DevToolsAgentHost::StartRemoteDebuggingServer(
std::move(socket_factory), std::string(), browser_context->GetPath(), std::move(socket_factory), browser_context->GetPath(), base::FilePath());
base::FilePath());
const base::CommandLine& command_line = const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
@@ -138,7 +137,6 @@ std::string CefDevToolsManagerDelegate::GetDiscoveryPageHTML() {
.as_string(); .as_string();
} }
std::string CefDevToolsManagerDelegate::GetFrontendResource( bool CefDevToolsManagerDelegate::HasBundledFrontendResources() {
const std::string& path) { return true;
return content::DevToolsFrontendHost::GetFrontendResource(path).as_string();
} }

View File

@@ -25,7 +25,7 @@ class CefDevToolsManagerDelegate : public content::DevToolsManagerDelegate {
scoped_refptr<content::DevToolsAgentHost> CreateNewTarget( scoped_refptr<content::DevToolsAgentHost> CreateNewTarget(
const GURL& url) override; const GURL& url) override;
std::string GetDiscoveryPageHTML() override; std::string GetDiscoveryPageHTML() override;
std::string GetFrontendResource(const std::string& path) override; bool HasBundledFrontendResources() override;
private: private:
DISALLOW_COPY_AND_ASSIGN(CefDevToolsManagerDelegate); DISALLOW_COPY_AND_ASSIGN(CefDevToolsManagerDelegate);

View File

@@ -6,11 +6,11 @@
#include "libcef/common/time_util.h" #include "libcef/common/time_util.h"
#include "content/public/browser/download_item.h" #include "components/download/public/common/download_item.h"
#include "url/gurl.h" #include "url/gurl.h"
CefDownloadItemImpl::CefDownloadItemImpl(content::DownloadItem* value) CefDownloadItemImpl::CefDownloadItemImpl(download::DownloadItem* value)
: CefValueBase<CefDownloadItem, content::DownloadItem>( : CefValueBase<CefDownloadItem, download::DownloadItem>(
value, value,
NULL, NULL,
kOwnerNoDelete, kOwnerNoDelete,
@@ -26,17 +26,17 @@ bool CefDownloadItemImpl::IsValid() {
bool CefDownloadItemImpl::IsInProgress() { bool CefDownloadItemImpl::IsInProgress() {
CEF_VALUE_VERIFY_RETURN(false, false); CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().GetState() == content::DownloadItem::IN_PROGRESS; return const_value().GetState() == download::DownloadItem::IN_PROGRESS;
} }
bool CefDownloadItemImpl::IsComplete() { bool CefDownloadItemImpl::IsComplete() {
CEF_VALUE_VERIFY_RETURN(false, false); CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().GetState() == content::DownloadItem::COMPLETE; return const_value().GetState() == download::DownloadItem::COMPLETE;
} }
bool CefDownloadItemImpl::IsCanceled() { bool CefDownloadItemImpl::IsCanceled() {
CEF_VALUE_VERIFY_RETURN(false, false); CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().GetState() == content::DownloadItem::CANCELLED; return const_value().GetState() == download::DownloadItem::CANCELLED;
} }
int64 CefDownloadItemImpl::GetCurrentSpeed() { int64 CefDownloadItemImpl::GetCurrentSpeed() {

View File

@@ -9,15 +9,15 @@
#include "include/cef_download_item.h" #include "include/cef_download_item.h"
#include "libcef/common/value_base.h" #include "libcef/common/value_base.h"
namespace content { namespace download {
class DownloadItem; class DownloadItem;
} }
// CefDownloadItem implementation // CefDownloadItem implementation
class CefDownloadItemImpl class CefDownloadItemImpl
: public CefValueBase<CefDownloadItem, content::DownloadItem> { : public CefValueBase<CefDownloadItem, download::DownloadItem> {
public: public:
explicit CefDownloadItemImpl(content::DownloadItem* value); explicit CefDownloadItemImpl(download::DownloadItem* value);
// CefDownloadItem methods. // CefDownloadItem methods.
bool IsValid() override; bool IsValid() override;

View File

@@ -15,11 +15,12 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/file_chooser_params.h" #include "content/public/common/file_chooser_params.h"
#include "net/base/filename_util.h" #include "net/base/filename_util.h"
using content::DownloadItem; using download::DownloadItem;
using content::DownloadManager; using content::DownloadManager;
using content::WebContents; using content::WebContents;
@@ -53,11 +54,9 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
if (manager_) { if (manager_) {
base::FilePath path = base::FilePath(download_path); base::FilePath path = base::FilePath(download_path);
CEF_POST_TASK( CEF_POST_USER_VISIBLE_TASK(base::Bind(
CEF_FILET, &CefBeforeDownloadCallbackImpl::GenerateFilename, manager_,
base::Bind(&CefBeforeDownloadCallbackImpl::GenerateFilename, download_id_, suggested_name_, path, show_dialog, callback_));
manager_, download_id_, suggested_name_, path,
show_dialog, callback_));
} }
download_id_ = 0; download_id_ = 0;
@@ -77,6 +76,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
const base::FilePath& download_path, const base::FilePath& download_path,
bool show_dialog, bool show_dialog,
const content::DownloadTargetCallback& callback) { const content::DownloadTargetCallback& callback) {
CEF_REQUIRE_BLOCKING();
base::FilePath suggested_path = download_path; base::FilePath suggested_path = download_path;
if (!suggested_path.empty()) { if (!suggested_path.empty()) {
// Create the directory if necessary. // Create the directory if necessary.
@@ -114,13 +115,14 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
return; return;
DownloadItem* item = manager->GetDownload(download_id); DownloadItem* item = manager->GetDownload(download_id);
if (!item || item->GetState() != content::DownloadItem::IN_PROGRESS) if (!item || item->GetState() != DownloadItem::IN_PROGRESS)
return; return;
bool handled = false; bool handled = false;
if (show_dialog) { if (show_dialog) {
WebContents* web_contents = item->GetWebContents(); WebContents* web_contents =
content::DownloadItemUtils::GetWebContents(item);
CefRefPtr<CefBrowserHostImpl> browser = CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForContents(web_contents); CefBrowserHostImpl::GetBrowserForContents(web_contents);
if (browser.get()) { if (browser.get()) {
@@ -146,8 +148,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
if (!handled) { if (!handled) {
callback.Run(suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, callback.Run(suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, suggested_path, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, suggested_path,
content::DOWNLOAD_INTERRUPT_REASON_NONE); download::DOWNLOAD_INTERRUPT_REASON_NONE);
} }
} }
@@ -163,8 +165,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
// The download will be cancelled if |path| is empty. // The download will be cancelled if |path| is empty.
callback.Run(path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, callback.Run(path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
content::DOWNLOAD_INTERRUPT_REASON_NONE); download::DOWNLOAD_INTERRUPT_REASON_NONE);
} }
base::WeakPtr<DownloadManager> manager_; base::WeakPtr<DownloadManager> manager_;
@@ -206,7 +208,7 @@ class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
if (manager_) { if (manager_) {
DownloadItem* item = manager_->GetDownload(download_id_); DownloadItem* item = manager_->GetDownload(download_id_);
if (item && item->GetState() == content::DownloadItem::IN_PROGRESS) if (item && item->GetState() == DownloadItem::IN_PROGRESS)
item->Cancel(true); item->Cancel(true);
} }
@@ -219,7 +221,7 @@ class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
if (manager_) { if (manager_) {
DownloadItem* item = manager_->GetDownload(download_id_); DownloadItem* item = manager_->GetDownload(download_id_);
if (item && item->GetState() == content::DownloadItem::IN_PROGRESS) if (item && item->GetState() == DownloadItem::IN_PROGRESS)
item->Pause(); item->Pause();
} }
} }
@@ -316,7 +318,8 @@ void CefDownloadManagerDelegate::OnDownloadDestroyed(DownloadItem* item) {
void CefDownloadManagerDelegate::OnDownloadCreated(DownloadManager* manager, void CefDownloadManagerDelegate::OnDownloadCreated(DownloadManager* manager,
DownloadItem* item) { DownloadItem* item) {
CefBrowserHostImpl* browser = nullptr; CefBrowserHostImpl* browser = nullptr;
content::WebContents* contents = item->GetWebContents(); content::WebContents* contents =
content::DownloadItemUtils::GetWebContents(item);
if (contents) { if (contents) {
browser = CefBrowserHostImpl::GetBrowserForContents(contents).get(); browser = CefBrowserHostImpl::GetBrowserForContents(contents).get();
DCHECK(browser); DCHECK(browser);
@@ -360,8 +363,8 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
if (!item->GetForcedFilePath().empty()) { if (!item->GetForcedFilePath().empty()) {
callback.Run( callback.Run(
item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE, item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE,
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, item->GetForcedFilePath(), download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, item->GetForcedFilePath(),
content::DOWNLOAD_INTERRUPT_REASON_NONE); download::DOWNLOAD_INTERRUPT_REASON_NONE);
return true; return true;
} }
@@ -419,6 +422,6 @@ CefBrowserHostImpl* CefDownloadManagerDelegate::GetBrowser(DownloadItem* item) {
// StartDownloadWithId (originating from CreateInterruptedDownload) with no // StartDownloadWithId (originating from CreateInterruptedDownload) with no
// associated WebContents and consequently no associated CEF browser. In that // associated WebContents and consequently no associated CEF browser. In that
// case DetermineDownloadTarget will be called before OnDownloadCreated. // case DetermineDownloadTarget will be called before OnDownloadCreated.
DCHECK(!item->GetWebContents()); DCHECK(!content::DownloadItemUtils::GetWebContents(item));
return nullptr; return nullptr;
} }

View File

@@ -12,11 +12,11 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "content/public/browser/download_item.h" #include "components/download/public/common/download_item.h"
#include "content/public/browser/download_manager.h" #include "content/public/browser/download_manager.h"
#include "content/public/browser/download_manager_delegate.h" #include "content/public/browser/download_manager_delegate.h"
class CefDownloadManagerDelegate : public content::DownloadItem::Observer, class CefDownloadManagerDelegate : public download::DownloadItem::Observer,
public content::DownloadManager::Observer, public content::DownloadManager::Observer,
public content::DownloadManagerDelegate, public content::DownloadManagerDelegate,
public CefBrowserHostImpl::Observer { public CefBrowserHostImpl::Observer {
@@ -26,24 +26,24 @@ class CefDownloadManagerDelegate : public content::DownloadItem::Observer,
private: private:
// DownloadItem::Observer methods. // DownloadItem::Observer methods.
void OnDownloadUpdated(content::DownloadItem* item) override; void OnDownloadUpdated(download::DownloadItem* item) override;
void OnDownloadDestroyed(content::DownloadItem* item) override; void OnDownloadDestroyed(download::DownloadItem* item) override;
// DownloadManager::Observer methods. // DownloadManager::Observer methods.
void OnDownloadCreated(content::DownloadManager* manager, void OnDownloadCreated(content::DownloadManager* manager,
content::DownloadItem* item) override; download::DownloadItem* item) override;
void ManagerGoingDown(content::DownloadManager* manager) override; void ManagerGoingDown(content::DownloadManager* manager) override;
// DownloadManagerDelegate methods. // DownloadManagerDelegate methods.
bool DetermineDownloadTarget( bool DetermineDownloadTarget(
content::DownloadItem* item, download::DownloadItem* item,
const content::DownloadTargetCallback& callback) override; const content::DownloadTargetCallback& callback) override;
void GetNextId(const content::DownloadIdCallback& callback) override; void GetNextId(const content::DownloadIdCallback& callback) override;
// CefBrowserHostImpl::Observer methods. // CefBrowserHostImpl::Observer methods.
void OnBrowserDestroyed(CefBrowserHostImpl* browser) override; void OnBrowserDestroyed(CefBrowserHostImpl* browser) override;
CefBrowserHostImpl* GetBrowser(content::DownloadItem* item); CefBrowserHostImpl* GetBrowser(download::DownloadItem* item);
content::DownloadManager* manager_; content::DownloadManager* manager_;
base::WeakPtrFactory<content::DownloadManager> manager_ptr_factory_; base::WeakPtrFactory<content::DownloadManager> manager_ptr_factory_;
@@ -51,7 +51,7 @@ class CefDownloadManagerDelegate : public content::DownloadItem::Observer,
// Map of DownloadItem to originating CefBrowserHostImpl. Maintaining this // Map of DownloadItem to originating CefBrowserHostImpl. Maintaining this
// map is necessary because DownloadItem::GetWebContents() may return NULL if // map is necessary because DownloadItem::GetWebContents() may return NULL if
// the browser navigates while the download is in progress. // the browser navigates while the download is in progress.
typedef std::map<content::DownloadItem*, CefBrowserHostImpl*> ItemBrowserMap; typedef std::map<download::DownloadItem*, CefBrowserHostImpl*> ItemBrowserMap;
ItemBrowserMap item_browser_map_; ItemBrowserMap item_browser_map_;
DISALLOW_COPY_AND_ASSIGN(CefDownloadManagerDelegate); DISALLOW_COPY_AND_ASSIGN(CefDownloadManagerDelegate);

View File

@@ -142,11 +142,11 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
return set_init_result(SUCCESS); return set_init_result(SUCCESS);
} }
bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage() { bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage(std::string* error) {
CHECK_GE(execute_tab_id_, 0); CHECK_GE(execute_tab_id_, 0);
CefRefPtr<CefBrowserHostImpl> browser = CefRefPtr<CefBrowserHostImpl> browser =
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, &error_); cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, error);
if (!browser) if (!browser)
return false; return false;
@@ -156,7 +156,7 @@ bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage() {
ExtensionApiFrameIdMap::GetRenderFrameHostById(browser->web_contents(), ExtensionApiFrameIdMap::GetRenderFrameHostById(browser->web_contents(),
frame_id); frame_id);
if (!rfh) { if (!rfh) {
error_ = ErrorUtils::FormatErrorMessage(keys::kFrameNotFoundError, *error = ErrorUtils::FormatErrorMessage(keys::kFrameNotFoundError,
base::IntToString(frame_id), base::IntToString(frame_id),
base::IntToString(execute_tab_id_)); base::IntToString(execute_tab_id_));
return false; return false;
@@ -181,11 +181,11 @@ bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage() {
// NOTE: This can give the wrong answer due to race conditions, but it is OK, // NOTE: This can give the wrong answer due to race conditions, but it is OK,
// we check again in the renderer. // we check again in the renderer.
if (!extension()->permissions_data()->CanAccessPage( if (!extension()->permissions_data()->CanAccessPage(
extension(), effective_document_url, execute_tab_id_, &error_)) { extension(), effective_document_url, execute_tab_id_, error)) {
if (is_about_url && if (is_about_url &&
extension()->permissions_data()->active_permissions().HasAPIPermission( extension()->permissions_data()->active_permissions().HasAPIPermission(
APIPermission::kTab)) { APIPermission::kTab)) {
error_ = ErrorUtils::FormatErrorMessage( *error = ErrorUtils::FormatErrorMessage(
manifest_errors::kCannotAccessAboutUrl, manifest_errors::kCannotAccessAboutUrl,
rfh->GetLastCommittedURL().spec(), rfh->GetLastCommittedURL().spec(),
rfh->GetLastCommittedOrigin().Serialize()); rfh->GetLastCommittedOrigin().Serialize());
@@ -196,11 +196,12 @@ bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage() {
return true; return true;
} }
ScriptExecutor* ExecuteCodeInTabFunction::GetScriptExecutor() { ScriptExecutor* ExecuteCodeInTabFunction::GetScriptExecutor(
std::string* error) {
CHECK_GE(execute_tab_id_, 0); CHECK_GE(execute_tab_id_, 0);
CefRefPtr<CefBrowserHostImpl> browser = CefRefPtr<CefBrowserHostImpl> browser =
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, &error_); cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, error);
if (!browser) if (!browser)
return nullptr; return nullptr;
@@ -217,7 +218,8 @@ const GURL& ExecuteCodeInTabFunction::GetWebViewSrc() const {
return GURL::EmptyGURL(); return GURL::EmptyGURL();
} }
bool ExecuteCodeInTabFunction::LoadFile(const std::string& file) { bool ExecuteCodeInTabFunction::LoadFile(const std::string& file,
std::string* error) {
if (cef_details_.LoadFile( if (cef_details_.LoadFile(
file, base::BindOnce(&ExecuteCodeInTabFunction::LoadFileComplete, file, base::BindOnce(&ExecuteCodeInTabFunction::LoadFileComplete,
this, file))) { this, file))) {
@@ -225,7 +227,7 @@ bool ExecuteCodeInTabFunction::LoadFile(const std::string& file) {
} }
// Default handling. // Default handling.
return ExecuteCodeFunction::LoadFile(file); return ExecuteCodeFunction::LoadFile(file, error);
} }
void ExecuteCodeInTabFunction::LoadFileComplete( void ExecuteCodeInTabFunction::LoadFileComplete(
@@ -239,15 +241,6 @@ bool TabsExecuteScriptFunction::ShouldInsertCSS() const {
return false; return false;
} }
void TabsExecuteScriptFunction::OnExecuteCodeFinished(
const std::string& error,
const GURL& on_url,
const base::ListValue& result) {
if (error.empty())
SetResult(result.CreateDeepCopy());
ExecuteCodeInTabFunction::OnExecuteCodeFinished(error, on_url, result);
}
bool TabsInsertCSSFunction::ShouldInsertCSS() const { bool TabsInsertCSSFunction::ShouldInsertCSS() const {
return true; return true;
} }
@@ -264,10 +257,31 @@ content::WebContents* ZoomAPIFunction::GetWebContents(int tab_id) {
return browser->web_contents(); return browser->web_contents();
} }
void ZoomAPIFunction::SendResponse(bool success) {
ResponseValue response;
if (success) {
response = ArgumentList(std::move(results_));
} else {
response = results_ ? ErrorWithArguments(std::move(results_), error_)
: Error(error_);
}
Respond(std::move(response));
}
ExtensionFunction::ResponseAction ZoomAPIFunction::Run() {
if (RunAsync())
return RespondLater();
// TODO(devlin): Track these down and eliminate them if possible. We
// shouldn't return results and an error.
if (results_)
return RespondNow(ErrorWithArguments(std::move(results_), error_));
return RespondNow(Error(error_));
}
bool TabsSetZoomFunction::RunAsync() { bool TabsSetZoomFunction::RunAsync() {
std::unique_ptr<tabs::SetZoom::Params> params( std::unique_ptr<tabs::SetZoom::Params> params(
tabs::SetZoom::Params::Create(*args_)); tabs::SetZoom::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params); EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1; int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id); content::WebContents* web_contents = GetWebContents(tab_id);
@@ -299,7 +313,7 @@ bool TabsSetZoomFunction::RunAsync() {
bool TabsGetZoomFunction::RunAsync() { bool TabsGetZoomFunction::RunAsync() {
std::unique_ptr<tabs::GetZoom::Params> params( std::unique_ptr<tabs::GetZoom::Params> params(
tabs::GetZoom::Params::Create(*args_)); tabs::GetZoom::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params); EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1; int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id); content::WebContents* web_contents = GetWebContents(tab_id);
@@ -319,7 +333,7 @@ bool TabsSetZoomSettingsFunction::RunAsync() {
std::unique_ptr<tabs::SetZoomSettings::Params> params( std::unique_ptr<tabs::SetZoomSettings::Params> params(
tabs::SetZoomSettings::Params::Create(*args_)); tabs::SetZoomSettings::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params); EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1; int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id); content::WebContents* web_contents = GetWebContents(tab_id);
@@ -370,7 +384,7 @@ bool TabsSetZoomSettingsFunction::RunAsync() {
bool TabsGetZoomSettingsFunction::RunAsync() { bool TabsGetZoomSettingsFunction::RunAsync() {
std::unique_ptr<tabs::GetZoomSettings::Params> params( std::unique_ptr<tabs::GetZoomSettings::Params> params(
tabs::GetZoomSettings::Params::Create(*args_)); tabs::GetZoomSettings::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params); EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1; int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id); content::WebContents* web_contents = GetWebContents(tab_id);

View File

@@ -55,11 +55,11 @@ class ExecuteCodeInTabFunction : public ExecuteCodeFunction {
// Initializes |execute_tab_id_| and |details_|. // Initializes |execute_tab_id_| and |details_|.
InitResult Init() override; InitResult Init() override;
bool CanExecuteScriptOnPage() override; bool CanExecuteScriptOnPage(std::string* error) override;
ScriptExecutor* GetScriptExecutor() override; ScriptExecutor* GetScriptExecutor(std::string* error) override;
bool IsWebView() const override; bool IsWebView() const override;
const GURL& GetWebViewSrc() const override; const GURL& GetWebViewSrc() const override;
bool LoadFile(const std::string& file) override; bool LoadFile(const std::string& file, std::string* error) override;
private: private:
const CefExtensionFunctionDetails cef_details_; const CefExtensionFunctionDetails cef_details_;
@@ -78,10 +78,6 @@ class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction {
private: private:
~TabsExecuteScriptFunction() override {} ~TabsExecuteScriptFunction() override {}
void OnExecuteCodeFinished(const std::string& error,
const GURL& on_url,
const base::ListValue& script_result) override;
DECLARE_EXTENSION_FUNCTION("tabs.executeScript", TABS_EXECUTESCRIPT) DECLARE_EXTENSION_FUNCTION("tabs.executeScript", TABS_EXECUTESCRIPT)
}; };
@@ -94,7 +90,8 @@ class TabsInsertCSSFunction : public ExecuteCodeInTabFunction {
DECLARE_EXTENSION_FUNCTION("tabs.insertCSS", TABS_INSERTCSS) DECLARE_EXTENSION_FUNCTION("tabs.insertCSS", TABS_INSERTCSS)
}; };
class ZoomAPIFunction : public AsyncExtensionFunction { // Based on ChromeAsyncExtensionFunction.
class ZoomAPIFunction : public UIThreadExtensionFunction {
public: public:
ZoomAPIFunction(); ZoomAPIFunction();
@@ -103,10 +100,26 @@ class ZoomAPIFunction : public AsyncExtensionFunction {
// Gets the WebContents for |tab_id| if it is specified. Otherwise get the // Gets the WebContents for |tab_id| if it is specified. Otherwise get the
// WebContents for the active tab in the current window. Calling this function // WebContents for the active tab in the current window. Calling this function
// may set error_. // may set |error_|.
content::WebContents* GetWebContents(int tab_id); content::WebContents* GetWebContents(int tab_id);
virtual bool RunAsync() = 0;
// Responds with success/failure. |results_| or |error_| should be set
// accordingly.
void SendResponse(bool success);
// Exposed versions of ExtensionFunction::results_ and
// ExtensionFunction::error_ that are curried into the response.
// These need to keep the same name to avoid breaking existing
// implementations, but this should be temporary with crbug.com/648275
// and crbug.com/634140.
std::unique_ptr<base::ListValue> results_;
std::string error_;
private: private:
ResponseAction Run() final;
const CefExtensionFunctionDetails cef_details_; const CefExtensionFunctionDetails cef_details_;
}; };

View File

@@ -415,36 +415,36 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::CreateTabObject(
content::WebContents* contents = new_browser->web_contents(); content::WebContents* contents = new_browser->web_contents();
bool is_loading = contents->IsLoading(); bool is_loading = contents->IsLoading();
auto tab_object = base::MakeUnique<api::tabs::Tab>(); auto tab_object = std::make_unique<api::tabs::Tab>();
tab_object->id = base::MakeUnique<int>(new_browser->GetIdentifier()); tab_object->id = std::make_unique<int>(new_browser->GetIdentifier());
tab_object->index = index; tab_object->index = index;
tab_object->window_id = *tab_object->id; tab_object->window_id = *tab_object->id;
tab_object->status = base::MakeUnique<std::string>( tab_object->status = std::make_unique<std::string>(
is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete); is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete);
tab_object->active = active; tab_object->active = active;
tab_object->selected = true; tab_object->selected = true;
tab_object->highlighted = true; tab_object->highlighted = true;
tab_object->pinned = false; tab_object->pinned = false;
tab_object->audible = base::MakeUnique<bool>(contents->WasRecentlyAudible()); tab_object->audible = std::make_unique<bool>(contents->WasRecentlyAudible());
tab_object->discarded = false; tab_object->discarded = false;
tab_object->auto_discardable = false; tab_object->auto_discardable = false;
tab_object->muted_info = CreateMutedInfo(contents); tab_object->muted_info = CreateMutedInfo(contents);
tab_object->incognito = false; tab_object->incognito = false;
gfx::Size contents_size = contents->GetContainerBounds().size(); gfx::Size contents_size = contents->GetContainerBounds().size();
tab_object->width = base::MakeUnique<int>(contents_size.width()); tab_object->width = std::make_unique<int>(contents_size.width());
tab_object->height = base::MakeUnique<int>(contents_size.height()); tab_object->height = std::make_unique<int>(contents_size.height());
tab_object->url = base::MakeUnique<std::string>(contents->GetURL().spec()); tab_object->url = std::make_unique<std::string>(contents->GetURL().spec());
tab_object->title = tab_object->title =
base::MakeUnique<std::string>(base::UTF16ToUTF8(contents->GetTitle())); std::make_unique<std::string>(base::UTF16ToUTF8(contents->GetTitle()));
content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
if (entry && entry->GetFavicon().valid) { if (entry && entry->GetFavicon().valid) {
tab_object->fav_icon_url = tab_object->fav_icon_url =
base::MakeUnique<std::string>(entry->GetFavicon().url.spec()); std::make_unique<std::string>(entry->GetFavicon().url.spec());
} }
if (opener_browser_id >= 0) if (opener_browser_id >= 0)
tab_object->opener_tab_id = base::MakeUnique<int>(opener_browser_id); tab_object->opener_tab_id = std::make_unique<int>(opener_browser_id);
return tab_object; return tab_object;
} }

View File

@@ -47,7 +47,7 @@ void CefExtensionHostDelegate::ProcessMediaAccessRequest(
} }
bool CefExtensionHostDelegate::CheckMediaAccessPermission( bool CefExtensionHostDelegate::CheckMediaAccessPermission(
content::WebContents* web_contents, content::RenderFrameHost* render_frame_host,
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType type, content::MediaStreamType type,
const Extension* extension) { const Extension* extension) {

View File

@@ -30,7 +30,7 @@ class CefExtensionHostDelegate : public ExtensionHostDelegate {
const content::MediaStreamRequest& request, const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback, const content::MediaResponseCallback& callback,
const Extension* extension) override; const Extension* extension) override;
bool CheckMediaAccessPermission(content::WebContents* web_contents, bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType type, content::MediaStreamType type,
const Extension* extension) override; const Extension* extension) override;

View File

@@ -20,7 +20,6 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/string_tokenizer.h" #include "base/strings/string_tokenizer.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
@@ -112,7 +111,7 @@ void LoadExtensionWithManifest(base::WeakPtr<CefExtensionSystem> context,
bool internal, bool internal,
CefRefPtr<CefRequestContext> loader_context, CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) { CefRefPtr<CefExtensionHandler> handler) {
base::AssertBlockingAllowed(); CEF_REQUIRE_BLOCKING();
std::unique_ptr<base::DictionaryValue> manifest = std::unique_ptr<base::DictionaryValue> manifest =
ParseManifest(manifest_contents); ParseManifest(manifest_contents);
@@ -131,7 +130,7 @@ void LoadExtensionFromDisk(base::WeakPtr<CefExtensionSystem> context,
bool internal, bool internal,
CefRefPtr<CefRequestContext> loader_context, CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) { CefRefPtr<CefExtensionHandler> handler) {
base::AssertBlockingAllowed(); CEF_REQUIRE_BLOCKING();
base::FilePath manifest_path = root_directory.AppendASCII("manifest.json"); base::FilePath manifest_path = root_directory.AppendASCII("manifest.json");
std::string manifest_contents; std::string manifest_contents;
@@ -239,8 +238,7 @@ void CefExtensionSystem::LoadExtension(
CefRefPtr<CefRequestContext> loader_context, CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) { CefRefPtr<CefExtensionHandler> handler) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
base::PostTaskWithTraits( CEF_POST_USER_VISIBLE_TASK(
FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()},
base::BindOnce(LoadExtensionFromDisk, weak_ptr_factory_.GetWeakPtr(), base::BindOnce(LoadExtensionFromDisk, weak_ptr_factory_.GetWeakPtr(),
root_directory, internal, loader_context, handler)); root_directory, internal, loader_context, handler));
} }
@@ -252,11 +250,9 @@ void CefExtensionSystem::LoadExtension(
CefRefPtr<CefRequestContext> loader_context, CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) { CefRefPtr<CefExtensionHandler> handler) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
base::PostTaskWithTraits( CEF_POST_USER_VISIBLE_TASK(base::BindOnce(
FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()}, LoadExtensionWithManifest, weak_ptr_factory_.GetWeakPtr(),
base::BindOnce(LoadExtensionWithManifest, weak_ptr_factory_.GetWeakPtr(), manifest_contents, root_directory, internal, loader_context, handler));
manifest_contents, root_directory, internal,
loader_context, handler));
} }
// Implementation based on ComponentLoader::Add. // Implementation based on ComponentLoader::Add.
@@ -453,7 +449,7 @@ ContentVerifier* CefExtensionSystem::content_verifier() {
std::unique_ptr<ExtensionSet> CefExtensionSystem::GetDependentExtensions( std::unique_ptr<ExtensionSet> CefExtensionSystem::GetDependentExtensions(
const Extension* extension) { const Extension* extension) {
return base::MakeUnique<ExtensionSet>(); return std::make_unique<ExtensionSet>();
} }
void CefExtensionSystem::InstallUpdate( void CefExtensionSystem::InstallUpdate(
@@ -465,6 +461,13 @@ void CefExtensionSystem::InstallUpdate(
base::DeleteFile(temp_dir, true /* recursive */); base::DeleteFile(temp_dir, true /* recursive */);
} }
bool CefExtensionSystem::FinishDelayedInstallationIfReady(
const std::string& extension_id,
bool install_immediately) {
NOTREACHED();
return false;
}
CefExtensionSystem::ComponentExtensionInfo::ComponentExtensionInfo( CefExtensionSystem::ComponentExtensionInfo::ComponentExtensionInfo(
const base::DictionaryValue* manifest, const base::DictionaryValue* manifest,
const base::FilePath& directory, const base::FilePath& directory,

View File

@@ -115,6 +115,8 @@ class CefExtensionSystem : public ExtensionSystem {
const std::string& public_key, const std::string& public_key,
const base::FilePath& temp_dir, const base::FilePath& temp_dir,
InstallUpdateCallback install_update_callback) override; InstallUpdateCallback install_update_callback) override;
bool FinishDelayedInstallationIfReady(const std::string& extension_id,
bool install_immediately) override;
bool initialized() const { return initialized_; } bool initialized() const { return initialized_; }

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/WebKit/public/platform/WebGestureEvent.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

@@ -21,6 +21,16 @@ CefExtensionWebContentsObserver::CefExtensionWebContentsObserver(
CefExtensionWebContentsObserver::~CefExtensionWebContentsObserver() {} CefExtensionWebContentsObserver::~CefExtensionWebContentsObserver() {}
// static
void CefExtensionWebContentsObserver::CreateForWebContents(
content::WebContents* web_contents) {
content::WebContentsUserData<
CefExtensionWebContentsObserver>::CreateForWebContents(web_contents);
// Initialize this instance if necessary.
FromWebContents(web_contents)->Initialize();
}
void CefExtensionWebContentsObserver::RenderFrameCreated( void CefExtensionWebContentsObserver::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) { content::RenderFrameHost* render_frame_host) {
ExtensionWebContentsObserver::RenderFrameCreated(render_frame_host); ExtensionWebContentsObserver::RenderFrameCreated(render_frame_host);

View File

@@ -22,6 +22,10 @@ class CefExtensionWebContentsObserver
public: public:
~CefExtensionWebContentsObserver() override; ~CefExtensionWebContentsObserver() override;
// Creates and initializes an instance of this class for the given
// |web_contents|, if it doesn't already exist.
static void CreateForWebContents(content::WebContents* web_contents);
ScriptExecutor* script_executor() { return script_executor_.get(); } ScriptExecutor* script_executor() { return script_executor_.get(); }
private: private:

View File

@@ -123,6 +123,25 @@ CefExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob(
send_cors_header); send_cors_header);
} }
base::FilePath CefExtensionsBrowserClient::GetBundleResourcePath(
const network::ResourceRequest& request,
const base::FilePath& extension_resources_path,
int* resource_id) const {
*resource_id = 0;
return base::FilePath();
}
void CefExtensionsBrowserClient::LoadResourceFromResourceBundle(
const network::ResourceRequest& request,
network::mojom::URLLoaderRequest loader,
const base::FilePath& resource_relative_path,
int resource_id,
const std::string& content_security_policy,
network::mojom::URLLoaderClientPtr client,
bool send_cors_header) {
NOTREACHED() << "Load resources from bundles not supported.";
}
bool CefExtensionsBrowserClient::AllowCrossRendererResourceLoad( bool CefExtensionsBrowserClient::AllowCrossRendererResourceLoad(
const GURL& url, const GURL& url,
content::ResourceType resource_type, content::ResourceType resource_type,
@@ -239,6 +258,11 @@ bool CefExtensionsBrowserClient::IsRunningInForcedAppMode() {
return false; return false;
} }
bool CefExtensionsBrowserClient::IsAppModeForcedForApp(
const ExtensionId& extension_id) {
return false;
}
bool CefExtensionsBrowserClient::IsLoggedInAsPublicAccount() { bool CefExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
return false; return false;
} }

View File

@@ -51,6 +51,18 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
const base::FilePath& directory_path, const base::FilePath& directory_path,
const std::string& content_security_policy, const std::string& content_security_policy,
bool send_cors_header) override; bool send_cors_header) override;
base::FilePath GetBundleResourcePath(
const network::ResourceRequest& request,
const base::FilePath& extension_resources_path,
int* resource_id) const override;
void LoadResourceFromResourceBundle(
const network::ResourceRequest& request,
network::mojom::URLLoaderRequest loader,
const base::FilePath& resource_relative_path,
int resource_id,
const std::string& content_security_policy,
network::mojom::URLLoaderClientPtr client,
bool send_cors_header) override;
bool AllowCrossRendererResourceLoad(const GURL& url, bool AllowCrossRendererResourceLoad(const GURL& url,
content::ResourceType resource_type, content::ResourceType resource_type,
ui::PageTransition page_transition, ui::PageTransition page_transition,
@@ -73,6 +85,7 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
bool DidVersionUpdate(content::BrowserContext* context) override; bool DidVersionUpdate(content::BrowserContext* context) override;
void PermitExternalProtocolHandler() override; void PermitExternalProtocolHandler() override;
bool IsRunningInForcedAppMode() override; bool IsRunningInForcedAppMode() override;
bool IsAppModeForcedForApp(const ExtensionId& extension_id) override;
bool IsLoggedInAsPublicAccount() override; bool IsLoggedInAsPublicAccount() override;
ExtensionSystemProvider* GetExtensionSystemFactory() override; ExtensionSystemProvider* GetExtensionSystemFactory() override;
void RegisterExtensionFunctions( void RegisterExtensionFunctions(

View File

@@ -79,12 +79,14 @@ void CefJavaScriptDialogManager::Destroy() {
void CefJavaScriptDialogManager::RunJavaScriptDialog( void CefJavaScriptDialogManager::RunJavaScriptDialog(
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& origin_url, content::RenderFrameHost* render_frame_host,
content::JavaScriptDialogType message_type, content::JavaScriptDialogType message_type,
const base::string16& message_text, const base::string16& message_text,
const base::string16& default_prompt_text, const base::string16& default_prompt_text,
DialogClosedCallback callback, DialogClosedCallback callback,
bool* did_suppress_message) { bool* did_suppress_message) {
const GURL& origin_url = render_frame_host->GetLastCommittedURL();
CefRefPtr<CefClient> client = browser_->GetClient(); CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) { if (client.get()) {
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler(); CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();

View File

@@ -29,7 +29,7 @@ class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
// JavaScriptDialogManager methods. // JavaScriptDialogManager methods.
void RunJavaScriptDialog(content::WebContents* web_contents, void RunJavaScriptDialog(content::WebContents* web_contents,
const GURL& origin_url, content::RenderFrameHost* render_frame_host,
content::JavaScriptDialogType message_type, content::JavaScriptDialogType message_type,
const base::string16& message_text, const base::string16& message_text,
const base::string16& default_prompt_text, const base::string16& default_prompt_text,

View File

@@ -384,4 +384,6 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateMouseEvent(
// timestamp // timestamp
result.SetTimeStampSeconds(GetSystemUptime()); result.SetTimeStampSeconds(GetSystemUptime());
result.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
} }

View File

@@ -20,9 +20,9 @@
#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/WebKit/public/platform/WebInputEvent.h" #include "third_party/blink/public/platform/web_input_event.h"
#include "third_party/WebKit/public/platform/WebMouseEvent.h" #include "third_party/blink/public/platform/web_mouse_event.h"
#include "third_party/WebKit/public/platform/WebMouseWheelEvent.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/keycodes/keyboard_codes_posix.h" #include "ui/events/keycodes/keyboard_codes_posix.h"
@@ -469,4 +469,6 @@ void CefBrowserPlatformDelegateNativeMac::TranslateMouseEvent(
// timestamp - Mac OSX specific // timestamp - Mac OSX specific
result.SetTimeStampSeconds(currentEventTimestamp()); result.SetTimeStampSeconds(currentEventTimestamp());
result.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
} }

View File

@@ -20,9 +20,10 @@
#include "base/memory/ref_counted_memory.h" #include "base/memory/ref_counted_memory.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/win/registry.h" #include "base/win/registry.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/WebKit/public/platform/WebMouseEvent.h" #include "third_party/blink/public/platform/web_mouse_event.h"
#include "third_party/WebKit/public/platform/WebMouseWheelEvent.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"
@@ -41,7 +42,7 @@
namespace { namespace {
void WriteTempFileAndView(scoped_refptr<base::RefCountedString> str) { void WriteTempFileAndView(scoped_refptr<base::RefCountedString> str) {
CEF_REQUIRE_FILET(); CEF_REQUIRE_BLOCKING();
base::FilePath tmp_file; base::FilePath tmp_file;
if (!base::CreateTemporaryFile(&tmp_file)) if (!base::CreateTemporaryFile(&tmp_file))
@@ -83,7 +84,7 @@ bool HasExternalHandler(const std::string& scheme) {
} }
void ExecuteExternalProtocol(const GURL& url) { void ExecuteExternalProtocol(const GURL& url) {
CEF_REQUIRE_FILET(); CEF_REQUIRE_BLOCKING();
if (!HasExternalHandler(url.scheme())) if (!HasExternalHandler(url.scheme()))
return; return;
@@ -95,6 +96,31 @@ void ExecuteExternalProtocol(const GURL& url) {
ShellExecuteA(NULL, "open", address.c_str(), NULL, NULL, SW_SHOWNORMAL); ShellExecuteA(NULL, "open", address.c_str(), NULL, NULL, SW_SHOWNORMAL);
} }
// DPI value for 1x scale factor.
#define DPI_1X 96.0f
float GetWindowScaleFactor(HWND hwnd) {
DCHECK(hwnd);
if (base::win::IsProcessPerMonitorDpiAware()) {
// Let Windows tell us the correct DPI.
static auto get_dpi_for_window_func = []() {
return reinterpret_cast<decltype(::GetDpiForWindow)*>(
GetProcAddress(GetModuleHandle(L"user32.dll"), "GetDpiForWindow"));
}();
if (get_dpi_for_window_func)
return static_cast<float>(get_dpi_for_window_func(hwnd)) / DPI_1X;
}
// Fallback to the monitor that contains the window center point.
RECT cr;
GetWindowRect(hwnd, &cr);
return display::Screen::GetScreen()
->GetDisplayNearestPoint(
gfx::Point((cr.right - cr.left) / 2, (cr.bottom - cr.top) / 2))
.device_scale_factor();
}
} // namespace } // namespace
CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin( CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin(
@@ -117,40 +143,49 @@ void CefBrowserPlatformDelegateNativeWin::BrowserDestroyed(
bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() { bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
RegisterWindowClass(); RegisterWindowClass();
has_frame_ = !(window_info_.style & WS_CHILD);
std::wstring windowName(CefString(&window_info_.window_name)); std::wstring windowName(CefString(&window_info_.window_name));
// Create the new browser window. // Create the new browser window.
window_info_.window = CreateWindowEx( CreateWindowEx(window_info_.ex_style, GetWndClass(), windowName.c_str(),
window_info_.ex_style, GetWndClass(), windowName.c_str(), window_info_.style, window_info_.x, window_info_.y,
window_info_.style, window_info_.x, window_info_.y, window_info_.width, window_info_.width, window_info_.height,
window_info_.height, window_info_.parent_window, window_info_.menu, window_info_.parent_window, window_info_.menu,
::GetModuleHandle(NULL), NULL); ::GetModuleHandle(NULL), this);
// It's possible for CreateWindowEx to fail if the parent window was // It's possible for CreateWindowEx to fail if the parent window was
// destroyed between the call to CreateBrowser and the above one. // destroyed between the call to CreateBrowser and the above one.
DCHECK(window_info_.window != NULL); DCHECK(window_info_.window);
if (!window_info_.window) if (!window_info_.window)
return false; return false;
host_window_created_ = true; host_window_created_ = true;
// Set window user data to this object for future reference from the window
// procedure.
gfx::SetWindowUserData(window_info_.window, this);
// Add a reference that will later be released in DestroyBrowser(). // Add a reference that will later be released in DestroyBrowser().
browser_->AddRef(); browser_->AddRef();
RECT cr; if (!called_enable_non_client_dpi_scaling_ && has_frame_ &&
GetClientRect(window_info_.window, &cr); base::win::IsProcessPerMonitorDpiAware()) {
// This call gets Windows to scale the non-client area when WM_DPICHANGED
// is fired on Windows versions < 10.0.14393.0.
// Derived signature; not available in headers.
static auto enable_child_window_dpi_message_func = []() {
using EnableChildWindowDpiMessagePtr = LRESULT(WINAPI*)(HWND, BOOL);
return reinterpret_cast<EnableChildWindowDpiMessagePtr>(GetProcAddress(
GetModuleHandle(L"user32.dll"), "EnableChildWindowDpiMessage"));
}();
if (enable_child_window_dpi_message_func)
enable_child_window_dpi_message_func(window_info_.window, TRUE);
}
DCHECK(!window_widget_); DCHECK(!window_widget_);
// Adjust for potential display scaling. // Convert from device coordinates to logical coordinates.
RECT cr;
GetClientRect(window_info_.window, &cr);
gfx::Point point = gfx::Point(cr.right, cr.bottom); gfx::Point point = gfx::Point(cr.right, cr.bottom);
float scale = display::Screen::GetScreen() const float scale = GetWindowScaleFactor(window_info_.window);
->GetDisplayNearestPoint(point)
.device_scale_factor();
point = point =
gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(point), 1.0f / scale)); gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(point), 1.0f / scale));
@@ -270,26 +305,26 @@ gfx::Point CefBrowserPlatformDelegateNativeWin::GetScreenPoint(
if (windowless_handler_) if (windowless_handler_)
return windowless_handler_->GetParentScreenPoint(view); return windowless_handler_->GetParentScreenPoint(view);
if (!window_widget_) if (!window_info_.window)
return view; return view;
aura::Window* window = window_widget_->GetNativeView(); // Convert from logical coordinates to device coordinates.
const gfx::Rect& bounds_in_screen = window->GetBoundsInScreen(); const float scale = GetWindowScaleFactor(window_info_.window);
const gfx::Point& screen_point = gfx::Point(bounds_in_screen.x() + view.x(), const gfx::Point& device_pt =
bounds_in_screen.y() + view.y()); gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(view), scale));
// Adjust for potential display scaling. // Convert from client coordinates to screen coordinates.
float scale = display::Screen::GetScreen() POINT screen_pt = {device_pt.x(), device_pt.y()};
->GetDisplayNearestPoint(screen_point) ClientToScreen(window_info_.window, &screen_pt);
.device_scale_factor();
return gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(screen_point), scale)); return gfx::Point(screen_pt.x, screen_pt.y);
} }
void CefBrowserPlatformDelegateNativeWin::ViewText(const std::string& text) { void CefBrowserPlatformDelegateNativeWin::ViewText(const std::string& text) {
std::string str = text; std::string str = text;
scoped_refptr<base::RefCountedString> str_ref = scoped_refptr<base::RefCountedString> str_ref =
base::RefCountedString::TakeString(&str); base::RefCountedString::TakeString(&str);
CEF_POST_TASK(CEF_FILET, base::Bind(WriteTempFileAndView, str_ref)); CEF_POST_USER_VISIBLE_TASK(base::Bind(WriteTempFileAndView, str_ref));
} }
void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent( void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
@@ -335,8 +370,7 @@ void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
void CefBrowserPlatformDelegateNativeWin::HandleExternalProtocol( void CefBrowserPlatformDelegateNativeWin::HandleExternalProtocol(
const GURL& url) { const GURL& url) {
// Execute on the FILE thread. CEF_POST_USER_VISIBLE_TASK(base::Bind(ExecuteExternalProtocol, url));
CEF_POST_TASK(CEF_FILET, base::Bind(ExecuteExternalProtocol, url));
} }
void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent( void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
@@ -524,6 +558,8 @@ void CefBrowserPlatformDelegateNativeWin::TranslateMouseEvent(
// timestamp // timestamp
result.SetTimeStampSeconds(GetMessageTime() / 1000.0); result.SetTimeStampSeconds(GetMessageTime() / 1000.0);
result.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
} }
// static // static
@@ -562,12 +598,15 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
UINT message, UINT message,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) { LPARAM lParam) {
CefBrowserPlatformDelegateNativeWin* platform_delegate = CefBrowserPlatformDelegateNativeWin* platform_delegate = nullptr;
static_cast<CefBrowserPlatformDelegateNativeWin*>(
gfx::GetWindowUserData(hwnd));
CefBrowserHostImpl* browser = nullptr; CefBrowserHostImpl* browser = nullptr;
if (platform_delegate)
browser = platform_delegate->browser_; if (message != WM_NCCREATE) {
platform_delegate = static_cast<CefBrowserPlatformDelegateNativeWin*>(
gfx::GetWindowUserData(hwnd));
if (platform_delegate)
browser = platform_delegate->browser_;
}
switch (message) { switch (message) {
case WM_CLOSE: case WM_CLOSE:
@@ -579,6 +618,31 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
// Allow the close. // Allow the close.
break; break;
case WM_NCCREATE: {
CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(lParam);
platform_delegate =
reinterpret_cast<CefBrowserPlatformDelegateNativeWin*>(
cs->lpCreateParams);
DCHECK(platform_delegate);
// Associate |platform_delegate| with the window handle.
gfx::SetWindowUserData(hwnd, platform_delegate);
platform_delegate->window_info_.window = hwnd;
if (platform_delegate->has_frame_ &&
base::win::IsProcessPerMonitorDpiAware()) {
// This call gets Windows to scale the non-client area when
// WM_DPICHANGED is fired on Windows versions >= 10.0.14393.0.
static auto enable_non_client_dpi_scaling_func = []() {
return reinterpret_cast<decltype(::EnableNonClientDpiScaling)*>(
GetProcAddress(GetModuleHandle(L"user32.dll"),
"EnableNonClientDpiScaling"));
}();
platform_delegate->called_enable_non_client_dpi_scaling_ =
!!(enable_non_client_dpi_scaling_func &&
enable_non_client_dpi_scaling_func(hwnd));
}
} break;
case WM_NCDESTROY: case WM_NCDESTROY:
if (platform_delegate) { if (platform_delegate) {
// Clear the user data pointer. // Clear the user data pointer.
@@ -617,6 +681,17 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
case WM_ERASEBKGND: case WM_ERASEBKGND:
return 0; return 0;
case WM_DPICHANGED:
if (platform_delegate && platform_delegate->has_frame_) {
// Suggested size and position of the current window scaled for the
// new DPI.
const RECT* rect = reinterpret_cast<RECT*>(lParam);
SetWindowPos(platform_delegate->GetHostWindowHandle(), NULL, rect->left,
rect->top, rect->right - rect->left,
rect->bottom - rect->top, SWP_NOZORDER | SWP_NOACTIVATE);
}
break;
} }
return DefWindowProc(hwnd, message, wParam, lParam); return DefWindowProc(hwnd, message, wParam, lParam);

View File

@@ -68,6 +68,9 @@ class CefBrowserPlatformDelegateNativeWin
// Widget hosting the web contents. It will be deleted automatically when the // Widget hosting the web contents. It will be deleted automatically when the
// associated root window is destroyed. // associated root window is destroyed.
views::Widget* window_widget_; views::Widget* window_widget_;
bool has_frame_ = false;
bool called_enable_non_client_dpi_scaling_ = false;
}; };
#endif // CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_WIN_H_ #endif // CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_WIN_H_

View File

@@ -647,7 +647,7 @@ void CefNativeMenuWin::AddMenuItemAt(int menu_index, int model_index) {
else else
mii.fType = MFT_OWNERDRAW; mii.fType = MFT_OWNERDRAW;
std::unique_ptr<ItemData> item_data = base::MakeUnique<ItemData>(); std::unique_ptr<ItemData> item_data = std::make_unique<ItemData>();
item_data->label = base::string16(); item_data->label = base::string16();
ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); ui::MenuModel::ItemType type = model_->GetTypeAt(model_index);
if (type == ui::MenuModel::TYPE_SUBMENU) { if (type == ui::MenuModel::TYPE_SUBMENU) {
@@ -676,7 +676,7 @@ void CefNativeMenuWin::AddSeparatorItemAt(int menu_index, int model_index) {
mii.fType = MFT_SEPARATOR; mii.fType = MFT_SEPARATOR;
// Insert a dummy entry into our label list so we can index directly into it // Insert a dummy entry into our label list so we can index directly into it
// using item indices if need be. // using item indices if need be.
items_.insert(items_.begin() + model_index, base::MakeUnique<ItemData>()); items_.insert(items_.begin() + model_index, std::make_unique<ItemData>());
InsertMenuItem(menu_, menu_index, TRUE, &mii); InsertMenuItem(menu_, menu_index, TRUE, &mii);
} }

View File

@@ -26,7 +26,7 @@ const char kNetWMPing[] = "_NET_WM_PING";
const char kNetWMState[] = "_NET_WM_STATE"; const char kNetWMState[] = "_NET_WM_STATE";
const char kXdndProxy[] = "XdndProxy"; const char kXdndProxy[] = "XdndProxy";
::Window FindEventTarget(const base::NativeEvent& xev) { ::Window FindEventTarget(const ui::PlatformEvent& xev) {
::Window target = xev->xany.window; ::Window target = xev->xany.window;
if (xev->type == GenericEvent) if (xev->type == GenericEvent)
target = static_cast<XIDeviceEvent*>(xev->xcookie.data)->event; target = static_cast<XIDeviceEvent*>(xev->xcookie.data)->event;
@@ -333,7 +333,7 @@ uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
} }
break; break;
} }
case FocusIn: case x11::FocusIn:
// This message is received first followed by a "_NET_ACTIVE_WINDOW" // This message is received first followed by a "_NET_ACTIVE_WINDOW"
// message sent to the root window. When X11DesktopHandler handles the // message sent to the root window. When X11DesktopHandler handles the
// "_NET_ACTIVE_WINDOW" message it will erroneously mark the WebView // "_NET_ACTIVE_WINDOW" message it will erroneously mark the WebView
@@ -347,7 +347,7 @@ uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
100); 100);
} }
break; break;
case FocusOut: case x11::FocusOut:
// Cancel the pending focus change if some other window has gained focus // Cancel the pending focus change if some other window has gained focus
// while waiting for the async task to run. Otherwise we can get stuck in // while waiting for the async task to run. Otherwise we can get stuck in
// a focus change loop. // a focus change loop.

View File

@@ -72,7 +72,6 @@ const char* kAllowedWebUIHosts[] = {
chrome::kChromeUINetInternalsHost, chrome::kChromeUINetInternalsHost,
content::kChromeUINetworkErrorHost, content::kChromeUINetworkErrorHost,
content::kChromeUINetworkErrorsListingHost, content::kChromeUINetworkErrorsListingHost,
content::kChromeUINetworkViewCacheHost,
content::kChromeUIResourcesHost, content::kChromeUIResourcesHost,
content::kChromeUIServiceWorkerInternalsHost, content::kChromeUIServiceWorkerInternalsHost,
chrome::kChromeUISystemInfoHost, chrome::kChromeUISystemInfoHost,
@@ -794,6 +793,7 @@ void DidFinishChromeLoad(CefRefPtr<CefFrame> frame, const GURL& validated_url) {
switch (host_id) { switch (host_id) {
case CHROME_VERSION: case CHROME_VERSION:
DidFinishChromeVersionLoad(frame); DidFinishChromeVersionLoad(frame);
break;
default: default:
break; break;
} }

View File

@@ -11,6 +11,38 @@
#include "base/logging.h" #include "base/logging.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
namespace {
class NullCookieChangeDispatcher : public net::CookieChangeDispatcher {
public:
NullCookieChangeDispatcher() {}
~NullCookieChangeDispatcher() override {}
// net::CookieChangeDispatcher
std::unique_ptr<net::CookieChangeSubscription> AddCallbackForCookie(
const GURL& url,
const std::string& name,
net::CookieChangeCallback callback) override {
return nullptr;
}
std::unique_ptr<net::CookieChangeSubscription> AddCallbackForUrl(
const GURL& url,
net::CookieChangeCallback callback) override {
return nullptr;
}
std::unique_ptr<net::CookieChangeSubscription> AddCallbackForAllChanges(
net::CookieChangeCallback callback) override {
return nullptr;
}
private:
DISALLOW_COPY_AND_ASSIGN(NullCookieChangeDispatcher);
};
} // namespace
CefCookieStoreProxy::CefCookieStoreProxy( CefCookieStoreProxy::CefCookieStoreProxy(
CefURLRequestContextImpl* parent, CefURLRequestContextImpl* parent,
CefRefPtr<CefRequestContextHandler> handler) CefRefPtr<CefRequestContextHandler> handler)
@@ -33,6 +65,8 @@ void CefCookieStoreProxy::SetCookieWithOptionsAsync(
if (cookie_store) { if (cookie_store) {
cookie_store->SetCookieWithOptionsAsync(url, cookie_line, options, cookie_store->SetCookieWithOptionsAsync(url, cookie_line, options,
std::move(callback)); std::move(callback));
} else if (!callback.is_null()) {
std::move(callback).Run(false);
} }
} }
@@ -46,48 +80,53 @@ void CefCookieStoreProxy::SetCanonicalCookieAsync(
cookie_store->SetCanonicalCookieAsync(std::move(cookie), secure_source, cookie_store->SetCanonicalCookieAsync(std::move(cookie), secure_source,
modify_http_only, modify_http_only,
std::move(callback)); std::move(callback));
} else if (!callback.is_null()) {
std::move(callback).Run(false);
} }
} }
void CefCookieStoreProxy::GetCookiesWithOptionsAsync(
const GURL& url,
const net::CookieOptions& options,
GetCookiesCallback callback) {
net::CookieStore* cookie_store = GetCookieStore();
if (cookie_store)
cookie_store->GetCookiesWithOptionsAsync(url, options, std::move(callback));
}
void CefCookieStoreProxy::GetCookieListWithOptionsAsync( void CefCookieStoreProxy::GetCookieListWithOptionsAsync(
const GURL& url, const GURL& url,
const net::CookieOptions& options, const net::CookieOptions& options,
GetCookieListCallback callback) { GetCookieListCallback callback) {
net::CookieStore* cookie_store = GetCookieStore(); net::CookieStore* cookie_store = GetCookieStore();
if (cookie_store) if (cookie_store) {
cookie_store->GetCookieListWithOptionsAsync(url, options, cookie_store->GetCookieListWithOptionsAsync(url, options,
std::move(callback)); std::move(callback));
} else if (!callback.is_null()) {
std::move(callback).Run(net::CookieList());
}
} }
void CefCookieStoreProxy::GetAllCookiesAsync(GetCookieListCallback callback) { void CefCookieStoreProxy::GetAllCookiesAsync(GetCookieListCallback callback) {
net::CookieStore* cookie_store = GetCookieStore(); net::CookieStore* cookie_store = GetCookieStore();
if (cookie_store) if (cookie_store) {
cookie_store->GetAllCookiesAsync(std::move(callback)); cookie_store->GetAllCookiesAsync(std::move(callback));
} else if (!callback.is_null()) {
std::move(callback).Run(net::CookieList());
}
} }
void CefCookieStoreProxy::DeleteCookieAsync(const GURL& url, void CefCookieStoreProxy::DeleteCookieAsync(const GURL& url,
const std::string& cookie_name, const std::string& cookie_name,
base::OnceClosure callback) { base::OnceClosure callback) {
net::CookieStore* cookie_store = GetCookieStore(); net::CookieStore* cookie_store = GetCookieStore();
if (cookie_store) if (cookie_store) {
cookie_store->DeleteCookieAsync(url, cookie_name, std::move(callback)); cookie_store->DeleteCookieAsync(url, cookie_name, std::move(callback));
} else if (!callback.is_null()) {
std::move(callback).Run();
}
} }
void CefCookieStoreProxy::DeleteCanonicalCookieAsync( void CefCookieStoreProxy::DeleteCanonicalCookieAsync(
const net::CanonicalCookie& cookie, const net::CanonicalCookie& cookie,
DeleteCallback callback) { DeleteCallback callback) {
net::CookieStore* cookie_store = GetCookieStore(); net::CookieStore* cookie_store = GetCookieStore();
if (cookie_store) if (cookie_store) {
cookie_store->DeleteCanonicalCookieAsync(cookie, std::move(callback)); cookie_store->DeleteCanonicalCookieAsync(cookie, std::move(callback));
} else if (!callback.is_null()) {
std::move(callback).Run(0);
}
} }
void CefCookieStoreProxy::DeleteAllCreatedBetweenAsync( void CefCookieStoreProxy::DeleteAllCreatedBetweenAsync(
@@ -98,6 +137,8 @@ void CefCookieStoreProxy::DeleteAllCreatedBetweenAsync(
if (cookie_store) { if (cookie_store) {
cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end, cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end,
std::move(callback)); std::move(callback));
} else if (!callback.is_null()) {
std::move(callback).Run(0);
} }
} }
@@ -110,39 +151,37 @@ void CefCookieStoreProxy::DeleteAllCreatedBetweenWithPredicateAsync(
if (cookie_store) { if (cookie_store) {
cookie_store->DeleteAllCreatedBetweenWithPredicateAsync( cookie_store->DeleteAllCreatedBetweenWithPredicateAsync(
delete_begin, delete_end, predicate, std::move(callback)); delete_begin, delete_end, predicate, std::move(callback));
} else if (!callback.is_null()) {
std::move(callback).Run(0);
} }
} }
void CefCookieStoreProxy::DeleteSessionCookiesAsync(DeleteCallback callback) { void CefCookieStoreProxy::DeleteSessionCookiesAsync(DeleteCallback callback) {
net::CookieStore* cookie_store = GetCookieStore(); net::CookieStore* cookie_store = GetCookieStore();
if (cookie_store) if (cookie_store) {
cookie_store->DeleteSessionCookiesAsync(std::move(callback)); cookie_store->DeleteSessionCookiesAsync(std::move(callback));
} else if (!callback.is_null()) {
std::move(callback).Run(0);
}
} }
void CefCookieStoreProxy::FlushStore(base::OnceClosure callback) { void CefCookieStoreProxy::FlushStore(base::OnceClosure callback) {
net::CookieStore* cookie_store = GetCookieStore(); net::CookieStore* cookie_store = GetCookieStore();
if (cookie_store) if (cookie_store) {
cookie_store->FlushStore(std::move(callback)); cookie_store->FlushStore(std::move(callback));
} else if (!callback.is_null()) {
std::move(callback).Run();
}
} }
std::unique_ptr<net::CookieStore::CookieChangedSubscription> net::CookieChangeDispatcher& CefCookieStoreProxy::GetChangeDispatcher() {
CefCookieStoreProxy::AddCallbackForCookie(
const GURL& url,
const std::string& name,
const CookieChangedCallback& callback) {
net::CookieStore* cookie_store = GetCookieStore(); net::CookieStore* cookie_store = GetCookieStore();
if (cookie_store) if (cookie_store)
return cookie_store->AddCallbackForCookie(url, name, callback); return cookie_store->GetChangeDispatcher();
return nullptr;
}
std::unique_ptr<net::CookieStore::CookieChangedSubscription> if (!null_dispatcher_)
CefCookieStoreProxy::AddCallbackForAllChanges( null_dispatcher_.reset(new NullCookieChangeDispatcher());
const CookieChangedCallback& callback) { return *null_dispatcher_;
net::CookieStore* cookie_store = GetCookieStore();
if (cookie_store)
return cookie_store->AddCallbackForAllChanges(callback);
return nullptr;
} }
bool CefCookieStoreProxy::IsEphemeral() { bool CefCookieStoreProxy::IsEphemeral() {
@@ -155,25 +194,23 @@ bool CefCookieStoreProxy::IsEphemeral() {
net::CookieStore* CefCookieStoreProxy::GetCookieStore() { net::CookieStore* CefCookieStoreProxy::GetCookieStore() {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
net::CookieStore* cookie_store = nullptr;
CefRefPtr<CefCookieManager> manager = handler_->GetCookieManager(); CefRefPtr<CefCookieManager> manager = handler_->GetCookieManager();
if (manager.get()) { if (manager.get()) {
// Use the cookie store provided by the manager. // Use the cookie store provided by the manager. May be nullptr if the
cookie_store = reinterpret_cast<CefCookieManagerImpl*>(manager.get()) // cookie manager is blocking.
->GetExistingCookieStore(); return reinterpret_cast<CefCookieManagerImpl*>(manager.get())
DCHECK(cookie_store); ->GetExistingCookieStore();
return cookie_store;
} }
DCHECK(parent_); DCHECK(parent_);
if (parent_) { if (parent_) {
// Use the cookie store from the parent. // Use the cookie store from the parent.
cookie_store = parent_->cookie_store(); net::CookieStore* cookie_store = parent_->cookie_store();
DCHECK(cookie_store); DCHECK(cookie_store);
if (!cookie_store) if (!cookie_store)
LOG(ERROR) << "Cookie store does not exist"; LOG(ERROR) << "Cookie store does not exist";
return cookie_store;
} }
return cookie_store; return nullptr;
} }

View File

@@ -30,9 +30,6 @@ class CefCookieStoreProxy : public net::CookieStore {
bool secure_source, bool secure_source,
bool modify_http_only, bool modify_http_only,
SetCookiesCallback callback) override; SetCookiesCallback callback) override;
void GetCookiesWithOptionsAsync(const GURL& url,
const net::CookieOptions& options,
GetCookiesCallback callback) override;
void GetCookieListWithOptionsAsync(const GURL& url, void GetCookieListWithOptionsAsync(const GURL& url,
const net::CookieOptions& options, const net::CookieOptions& options,
GetCookieListCallback callback) override; GetCookieListCallback callback) override;
@@ -52,12 +49,7 @@ class CefCookieStoreProxy : public net::CookieStore {
DeleteCallback callback) override; DeleteCallback callback) override;
void DeleteSessionCookiesAsync(DeleteCallback callback) override; void DeleteSessionCookiesAsync(DeleteCallback callback) override;
void FlushStore(base::OnceClosure callback) override; void FlushStore(base::OnceClosure callback) override;
std::unique_ptr<CookieChangedSubscription> AddCallbackForCookie( net::CookieChangeDispatcher& GetChangeDispatcher() override;
const GURL& url,
const std::string& name,
const CookieChangedCallback& callback) override;
std::unique_ptr<CookieChangedSubscription> AddCallbackForAllChanges(
const CookieChangedCallback& callback) override;
bool IsEphemeral() override; bool IsEphemeral() override;
private: private:
@@ -68,6 +60,8 @@ class CefCookieStoreProxy : public net::CookieStore {
CefURLRequestContextImpl* parent_; CefURLRequestContextImpl* parent_;
CefRefPtr<CefRequestContextHandler> handler_; CefRefPtr<CefRequestContextHandler> handler_;
std::unique_ptr<net::CookieChangeDispatcher> null_dispatcher_;
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy); DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy);
}; };

View File

@@ -9,10 +9,8 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "net/cert/crl_set.h" #include "net/cert/crl_set.h"
#include "net/cert/crl_set_storage.h"
#include "net/ssl/ssl_config_service.h" #include "net/ssl/ssl_config_service.h"
namespace { namespace {
@@ -25,7 +23,7 @@ void SetCRLSetIfNewer(scoped_refptr<net::CRLSet> crl_set) {
} }
void LoadFromDisk(const base::FilePath& path) { void LoadFromDisk(const base::FilePath& path) {
base::AssertBlockingAllowed(); CEF_REQUIRE_BLOCKING();
std::string crl_set_bytes; std::string crl_set_bytes;
if (!base::ReadFileToString(path, &crl_set_bytes)) { if (!base::ReadFileToString(path, &crl_set_bytes)) {
@@ -34,7 +32,7 @@ void LoadFromDisk(const base::FilePath& path) {
} }
scoped_refptr<net::CRLSet> crl_set; scoped_refptr<net::CRLSet> crl_set;
if (!net::CRLSetStorage::Parse(crl_set_bytes, &crl_set)) { if (!net::CRLSet::Parse(crl_set_bytes, &crl_set)) {
LOG(WARNING) << "Failed to parse CRL set from " << path.MaybeAsASCII(); LOG(WARNING) << "Failed to parse CRL set from " << path.MaybeAsASCII();
return; return;
} }
@@ -51,7 +49,5 @@ void CefLoadCRLSetsFile(const CefString& path) {
return; return;
} }
base::PostTaskWithTraits(FROM_HERE, CEF_POST_USER_VISIBLE_TASK(base::BindOnce(&LoadFromDisk, path));
{base::TaskPriority::BACKGROUND, base::MayBlock()},
base::BindOnce(&LoadFromDisk, path));
} }

View File

@@ -272,7 +272,7 @@ std::unique_ptr<net::SourceStream> CefNetworkDelegate::CreateSourceStream(
} }
if (cef_filter && cef_filter->InitFilter()) if (cef_filter && cef_filter->InitFilter())
return base::MakeUnique<CefSourceStream>(cef_filter, std::move(upstream)); return std::make_unique<CefSourceStream>(cef_filter, std::move(upstream));
return upstream; return upstream;
} }

View File

@@ -328,6 +328,22 @@ bool CefResourceRequestJob::GetMimeType(std::string* mime_type) const {
return true; return true;
} }
bool CefResourceRequestJob::GetCharset(std::string* charset) {
CEF_REQUIRE_IOT();
if (net::HttpResponseHeaders* headers = GetResponseHeaders())
return headers->GetCharset(charset);
return false;
}
int CefResourceRequestJob::GetResponseCode() const {
CEF_REQUIRE_IOT();
if (response_.get())
return response_->GetStatus();
return -1;
}
void CefResourceRequestJob::SendHeaders() { void CefResourceRequestJob::SendHeaders() {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
@@ -403,7 +419,7 @@ void CefResourceRequestJob::AddCookieHeaderAndStart() {
void CefResourceRequestJob::DoLoadCookies() { void CefResourceRequestJob::DoLoadCookies() {
net::CookieOptions options; net::CookieOptions options;
options.set_include_httponly(); options.set_include_httponly();
request_->context()->cookie_store()->GetCookiesWithOptionsAsync( request_->context()->cookie_store()->GetCookieListWithOptionsAsync(
request_->url(), options, request_->url(), options,
base::Bind(&CefResourceRequestJob::OnCookiesLoaded, base::Bind(&CefResourceRequestJob::OnCookiesLoaded,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
@@ -430,8 +446,11 @@ void CefResourceRequestJob::CheckCookiePolicyAndLoad(
DoStartTransaction(); DoStartTransaction();
} }
void CefResourceRequestJob::OnCookiesLoaded(const std::string& cookie_line) { void CefResourceRequestJob::OnCookiesLoaded(
if (!cookie_line.empty()) { const net::CookieList& cookie_list) {
if (!cookie_list.empty()) {
const std::string& cookie_line =
net::CanonicalCookie::BuildCookieLine(cookie_list);
CefRequest::HeaderMap headerMap; CefRequest::HeaderMap headerMap;
cef_request_->GetHeaderMap(headerMap); cef_request_->GetHeaderMap(headerMap);
headerMap.insert( headerMap.insert(

View File

@@ -20,7 +20,7 @@
namespace net { namespace net {
class HttpResponseHeaders; class HttpResponseHeaders;
class URLRequest; class URLRequest;
} } // namespace net
class CefResourceRequestJobCallback; class CefResourceRequestJobCallback;
@@ -40,6 +40,8 @@ class CefResourceRequestJob : public net::URLRequestJob {
void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override; void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override;
bool IsRedirectResponse(GURL* location, int* http_status_code) override; bool IsRedirectResponse(GURL* location, int* http_status_code) override;
bool GetMimeType(std::string* mime_type) const override; bool GetMimeType(std::string* mime_type) const override;
bool GetCharset(std::string* charset) override;
int GetResponseCode() const override;
void SendHeaders(); void SendHeaders();
@@ -47,7 +49,7 @@ class CefResourceRequestJob : public net::URLRequestJob {
void AddCookieHeaderAndStart(); void AddCookieHeaderAndStart();
void DoLoadCookies(); void DoLoadCookies();
void CheckCookiePolicyAndLoad(const net::CookieList& cookie_list); void CheckCookiePolicyAndLoad(const net::CookieList& cookie_list);
void OnCookiesLoaded(const std::string& cookie_line); void OnCookiesLoaded(const net::CookieList& cookie_list);
void DoStartTransaction(); void DoStartTransaction();
void StartTransaction(); void StartTransaction();

View File

@@ -14,7 +14,7 @@
#include "base/task_scheduler/post_task.h" #include "base/task_scheduler/post_task.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "net/net_features.h" #include "net/net_buildflags.h"
#include "net/url_request/data_protocol_handler.h" #include "net/url_request/data_protocol_handler.h"
#include "net/url_request/file_protocol_handler.h" #include "net/url_request/file_protocol_handler.h"
#include "net/url_request/ftp_protocol_handler.h" #include "net/url_request/ftp_protocol_handler.h"
@@ -29,19 +29,16 @@ void InstallInternalProtectedHandlers(
content::ProtocolHandlerMap* protocol_handlers, content::ProtocolHandlerMap* protocol_handlers,
net::HostResolver* host_resolver) { net::HostResolver* host_resolver) {
protocol_handlers->insert(std::make_pair( protocol_handlers->insert(std::make_pair(
url::kDataScheme, linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( url::kDataScheme, std::make_unique<net::DataProtocolHandler>()));
new net::DataProtocolHandler)));
protocol_handlers->insert(std::make_pair( protocol_handlers->insert(std::make_pair(
url::kFileScheme, url::kFileScheme,
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( std::make_unique<net::FileProtocolHandler>(
new net::FileProtocolHandler(base::CreateTaskRunnerWithTraits( base::CreateTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BACKGROUND, {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}))))); base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}))));
#if !BUILDFLAG(DISABLE_FTP_SUPPORT) #if !BUILDFLAG(DISABLE_FTP_SUPPORT)
protocol_handlers->insert(std::make_pair( protocol_handlers->insert(std::make_pair(
url::kFtpScheme, url::kFtpScheme, net::FtpProtocolHandler::Create(host_resolver)));
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
net::FtpProtocolHandler::Create(host_resolver).release())));
#endif #endif
for (content::ProtocolHandlerMap::iterator it = protocol_handlers->begin(); for (content::ProtocolHandlerMap::iterator it = protocol_handlers->begin();

View File

@@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/cookie_manager_impl.h" #include "libcef/browser/cookie_manager_impl.h"
#include "libcef/browser/net/network_delegate.h" #include "libcef/browser/net/network_delegate.h"
#include "libcef/browser/net/scheme_handler.h" #include "libcef/browser/net/scheme_handler.h"
@@ -31,7 +32,6 @@
#include "components/network_session_configurator/browser/network_session_configurator.h" #include "components/network_session_configurator/browser/network_session_configurator.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "content/network/proxy_service_mojo.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
@@ -51,9 +51,9 @@
#include "net/http/http_server_properties_impl.h" #include "net/http/http_server_properties_impl.h"
#include "net/http/http_util.h" #include "net/http/http_util.h"
#include "net/http/transport_security_state.h" #include "net/http/transport_security_state.h"
#include "net/proxy/dhcp_proxy_script_fetcher_factory.h" #include "net/proxy_resolution/dhcp_pac_file_fetcher_factory.h"
#include "net/proxy/proxy_script_fetcher_impl.h" #include "net/proxy_resolution/pac_file_fetcher_impl.h"
#include "net/proxy/proxy_service.h" #include "net/proxy_resolution/proxy_resolution_service.h"
#include "net/ssl/ssl_config_service_defaults.h" #include "net/ssl/ssl_config_service_defaults.h"
#include "net/url_request/http_user_agent_settings.h" #include "net/url_request/http_user_agent_settings.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
@@ -62,6 +62,7 @@
#include "net/url_request/url_request_intercepting_job_factory.h" #include "net/url_request/url_request_intercepting_job_factory.h"
#include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_job_factory_impl.h"
#include "net/url_request/url_request_job_manager.h" #include "net/url_request/url_request_job_manager.h"
#include "services/network/proxy_service_mojo.h"
#include "url/url_constants.h" #include "url/url_constants.h"
#if defined(OS_WIN) #if defined(OS_WIN)
@@ -108,9 +109,9 @@ class CefHttpUserAgentSettings : public net::HttpUserAgentSettings {
DISALLOW_COPY_AND_ASSIGN(CefHttpUserAgentSettings); DISALLOW_COPY_AND_ASSIGN(CefHttpUserAgentSettings);
}; };
// Based on ProxyServiceFactory::CreateProxyService which was deleted in // Based on ProxyResolutionServiceFactory::CreateProxyResolutionService which
// http://crrev.com/1c261ff4. // was deleted in http://crrev.com/1c261ff4.
std::unique_ptr<net::ProxyService> CreateProxyService( std::unique_ptr<net::ProxyResolutionService> CreateProxyResolutionService(
net::NetLog* net_log, net::NetLog* net_log,
net::URLRequestContext* context, net::URLRequestContext* context,
net::NetworkDelegate* network_delegate, net::NetworkDelegate* network_delegate,
@@ -129,27 +130,27 @@ std::unique_ptr<net::ProxyService> CreateProxyService(
use_v8 = false; // Fallback to non-v8 implementation. use_v8 = false; // Fallback to non-v8 implementation.
} }
std::unique_ptr<net::ProxyService> proxy_service; std::unique_ptr<net::ProxyResolutionService> proxy_service;
if (use_v8) { if (use_v8) {
std::unique_ptr<net::DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher; std::unique_ptr<net::DhcpPacFileFetcher> dhcp_pac_file_fetcher;
net::DhcpProxyScriptFetcherFactory dhcp_factory; net::DhcpPacFileFetcherFactory dhcp_factory;
dhcp_proxy_script_fetcher = dhcp_factory.Create(context); dhcp_pac_file_fetcher = dhcp_factory.Create(context);
proxy_service = content::CreateProxyServiceUsingMojoFactory( proxy_service = network::CreateProxyResolutionServiceUsingMojoFactory(
std::move(proxy_resolver_factory), std::move(proxy_config_service), std::move(proxy_resolver_factory), std::move(proxy_config_service),
base::MakeUnique<net::ProxyScriptFetcherImpl>(context), std::make_unique<net::PacFileFetcherImpl>(context),
std::move(dhcp_proxy_script_fetcher), context->host_resolver(), net_log, std::move(dhcp_pac_file_fetcher), context->host_resolver(), net_log,
network_delegate); network_delegate);
} else { } else {
proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( proxy_service = net::ProxyResolutionService::CreateUsingSystemProxyResolver(
std::move(proxy_config_service), net_log); std::move(proxy_config_service), net_log);
} }
proxy_service->set_quick_check_enabled(quick_check_enabled); proxy_service->set_quick_check_enabled(quick_check_enabled);
proxy_service->set_sanitize_url_policy( proxy_service->set_sanitize_url_policy(
pac_https_url_stripping_enabled pac_https_url_stripping_enabled
? net::ProxyService::SanitizeUrlPolicy::SAFE ? net::ProxyResolutionService::SanitizeUrlPolicy::SAFE
: net::ProxyService::SanitizeUrlPolicy::UNSAFE); : net::ProxyResolutionService::SanitizeUrlPolicy::UNSAFE);
return proxy_service; return proxy_service;
} }
@@ -163,7 +164,7 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
content::ProtocolHandlerMap* protocol_handlers, content::ProtocolHandlerMap* protocol_handlers,
std::unique_ptr<net::ProxyConfigService> proxy_config_service, std::unique_ptr<net::ProxyConfigService> proxy_config_service,
content::URLRequestInterceptorScopedVector request_interceptors) content::URLRequestInterceptorScopedVector request_interceptors)
: settings_(settings), io_state_(base::MakeUnique<IOState>()) { : settings_(settings), io_state_(std::make_unique<IOState>()) {
// Must first be created on the UI thread. // Must first be created on the UI thread.
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
@@ -246,9 +247,9 @@ void CefURLRequestContextGetterImpl::ShutdownOnIOThread() {
shutting_down_ = true; shutting_down_ = true;
// Delete the ProxyService object here so that any pending requests will be // Delete the ProxyResolutionService object here so that any pending requests
// canceled before the URLRequestContext is destroyed. // will be canceled before the URLRequestContext is destroyed.
io_state_->storage_->set_proxy_service(NULL); io_state_->storage_->set_proxy_resolution_service(NULL);
io_state_.reset(); io_state_.reset();
@@ -315,15 +316,16 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
settings_.enable_net_security_expiration ? true : false); settings_.enable_net_security_expiration ? true : false);
io_state_->storage_->set_ct_policy_enforcer(std::move(ct_policy_enforcer)); io_state_->storage_->set_ct_policy_enforcer(std::move(ct_policy_enforcer));
std::unique_ptr<net::ProxyService> system_proxy_service = std::unique_ptr<net::ProxyResolutionService> system_proxy_service =
CreateProxyService(io_state_->net_log_, CreateProxyResolutionService(
io_state_->url_request_context_.get(), io_state_->net_log_, io_state_->url_request_context_.get(),
io_state_->url_request_context_->network_delegate(), io_state_->url_request_context_->network_delegate(),
std::move(io_state_->proxy_resolver_factory_), std::move(io_state_->proxy_resolver_factory_),
std::move(io_state_->proxy_config_service_), std::move(io_state_->proxy_config_service_), *command_line,
*command_line, quick_check_enabled_.GetValue(), quick_check_enabled_.GetValue(),
pac_https_url_stripping_enabled_.GetValue()); pac_https_url_stripping_enabled_.GetValue());
io_state_->storage_->set_proxy_service(std::move(system_proxy_service)); io_state_->storage_->set_proxy_resolution_service(
std::move(system_proxy_service));
io_state_->storage_->set_ssl_config_service( io_state_->storage_->set_ssl_config_service(
new net::SSLConfigServiceDefaults); new net::SSLConfigServiceDefaults);
@@ -372,8 +374,8 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
io_state_->url_request_context_->cert_transparency_verifier(); io_state_->url_request_context_->cert_transparency_verifier();
network_session_context.ct_policy_enforcer = network_session_context.ct_policy_enforcer =
io_state_->url_request_context_->ct_policy_enforcer(); io_state_->url_request_context_->ct_policy_enforcer();
network_session_context.proxy_service = network_session_context.proxy_resolution_service =
io_state_->url_request_context_->proxy_service(); io_state_->url_request_context_->proxy_resolution_service();
network_session_context.ssl_config_service = network_session_context.ssl_config_service =
io_state_->url_request_context_->ssl_config_service(); io_state_->url_request_context_->ssl_config_service();
network_session_context.http_auth_handler_factory = network_session_context.http_auth_handler_factory =
@@ -414,7 +416,7 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
scheme::RegisterInternalHandlers(io_state_->url_request_manager_.get()); scheme::RegisterInternalHandlers(io_state_->url_request_manager_.get());
io_state_->request_interceptors_.push_back( io_state_->request_interceptors_.push_back(
base::MakeUnique<CefRequestInterceptor>()); std::make_unique<CefRequestInterceptor>());
// Set up interceptors in the reverse order. // Set up interceptors in the reverse order.
std::unique_ptr<net::URLRequestJobFactory> top_job_factory = std::unique_ptr<net::URLRequestJobFactory> top_job_factory =
@@ -472,7 +474,10 @@ void CefURLRequestContextGetterImpl::SetCookieStoragePath(
const base::FilePath& cookie_path = path.AppendASCII("Cookies"); const base::FilePath& cookie_path = path.AppendASCII("Cookies");
persistent_store = new net::SQLitePersistentCookieStore( persistent_store = new net::SQLitePersistentCookieStore(
cookie_path, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), cookie_path, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
BrowserThread::GetTaskRunnerForThread(BrowserThread::DB), // Intentionally using the background task runner exposed by CEF to
// facilitate unit test expectations. This task runner MUST be
// configured with BLOCK_SHUTDOWN.
CefContentBrowserClient::Get()->background_task_runner(),
persist_session_cookies, NULL); persist_session_cookies, NULL);
} else { } else {
NOTREACHED() << "The cookie storage directory could not be created"; NOTREACHED() << "The cookie storage directory could not be created";

View File

@@ -28,7 +28,7 @@ CefURLRequestContextProxy::CefURLRequestContextProxy(
set_cert_transparency_verifier(parent->cert_transparency_verifier()); set_cert_transparency_verifier(parent->cert_transparency_verifier());
set_ct_policy_enforcer(parent->ct_policy_enforcer()); set_ct_policy_enforcer(parent->ct_policy_enforcer());
set_channel_id_service(parent->channel_id_service()); set_channel_id_service(parent->channel_id_service());
set_proxy_service(parent->proxy_service()); set_proxy_resolution_service(parent->proxy_resolution_service());
set_ssl_config_service(parent->ssl_config_service()); set_ssl_config_service(parent->ssl_config_service());
set_http_auth_handler_factory(parent->http_auth_handler_factory()); set_http_auth_handler_factory(parent->http_auth_handler_factory());
set_http_transaction_factory(parent->http_transaction_factory()); set_http_transaction_factory(parent->http_transaction_factory());

View File

@@ -12,7 +12,8 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "content/public/browser/ax_event_notification_details.h" #include "content/public/browser/ax_event_notification_details.h"
#include "ui/accessibility/ax_enums.h" #include "ui/accessibility/ax_enum_util.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_text_utils.h" #include "ui/accessibility/ax_text_utils.h"
#include "ui/accessibility/ax_tree_update.h" #include "ui/accessibility/ax_tree_update.h"
#include "ui/gfx/transform.h" #include "ui/gfx/transform.h"
@@ -39,9 +40,10 @@ CefRefPtr<CefListValue> ToCefValue(uint32_t state) {
int index = 0; int index = 0;
// Iterate and find which states are set. // Iterate and find which states are set.
for (unsigned i = ui::AX_STATE_NONE; i <= ui::AX_STATE_LAST; i++) { for (unsigned i = static_cast<unsigned>(ax::mojom::Role::kMinValue) + 1;
i <= static_cast<unsigned>(ax::mojom::Role::kMaxValue); i++) {
if (state & (1 << i)) if (state & (1 << i))
value->SetString(index++, ToString(static_cast<ui::AXState>(i))); value->SetString(index++, ToString(static_cast<ax::mojom::State>(i)));
} }
return value; return value;
} }
@@ -65,127 +67,124 @@ struct PopulateAxNodeAttributes {
: attributes(attrs) {} : attributes(attrs) {}
// Int Attributes // Int Attributes
void operator()(const std::pair<ui::AXIntAttribute, int32_t> attr) { void operator()(const std::pair<ax::mojom::IntAttribute, int32_t> attr) {
if (attr.first == ui::AX_INT_ATTRIBUTE_NONE) if (attr.first == ax::mojom::IntAttribute::kNone)
return; return;
switch (attr.first) { switch (attr.first) {
case ui::AX_INT_ATTRIBUTE_NONE: case ax::mojom::IntAttribute::kNone:
break; break;
case ui::AX_ATTR_SCROLL_X: case ax::mojom::IntAttribute::kScrollX:
case ui::AX_ATTR_SCROLL_X_MIN: case ax::mojom::IntAttribute::kScrollXMin:
case ui::AX_ATTR_SCROLL_X_MAX: case ax::mojom::IntAttribute::kScrollXMax:
case ui::AX_ATTR_SCROLL_Y: case ax::mojom::IntAttribute::kScrollY:
case ui::AX_ATTR_SCROLL_Y_MIN: case ax::mojom::IntAttribute::kScrollYMin:
case ui::AX_ATTR_SCROLL_Y_MAX: case ax::mojom::IntAttribute::kScrollYMax:
case ui::AX_ATTR_HIERARCHICAL_LEVEL: case ax::mojom::IntAttribute::kHierarchicalLevel:
case ui::AX_ATTR_TEXT_SEL_START: case ax::mojom::IntAttribute::kTextSelStart:
case ui::AX_ATTR_TEXT_SEL_END: case ax::mojom::IntAttribute::kTextSelEnd:
case ui::AX_ATTR_ARIA_COLUMN_COUNT: case ax::mojom::IntAttribute::kAriaColumnCount:
case ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX: case ax::mojom::IntAttribute::kAriaCellColumnIndex:
case ui::AX_ATTR_ARIA_ROW_COUNT: case ax::mojom::IntAttribute::kAriaRowCount:
case ui::AX_ATTR_ARIA_CELL_ROW_INDEX: case ax::mojom::IntAttribute::kAriaCellRowIndex:
case ui::AX_ATTR_TABLE_ROW_COUNT: case ax::mojom::IntAttribute::kTableRowCount:
case ui::AX_ATTR_TABLE_COLUMN_COUNT: case ax::mojom::IntAttribute::kTableColumnCount:
case ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX: case ax::mojom::IntAttribute::kTableCellColumnIndex:
case ui::AX_ATTR_TABLE_CELL_ROW_INDEX: case ax::mojom::IntAttribute::kTableCellRowIndex:
case ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN: case ax::mojom::IntAttribute::kTableCellColumnSpan:
case ui::AX_ATTR_TABLE_CELL_ROW_SPAN: case ax::mojom::IntAttribute::kTableCellRowSpan:
case ui::AX_ATTR_TABLE_COLUMN_HEADER_ID: case ax::mojom::IntAttribute::kTableColumnHeaderId:
case ui::AX_ATTR_TABLE_COLUMN_INDEX: case ax::mojom::IntAttribute::kTableColumnIndex:
case ui::AX_ATTR_TABLE_HEADER_ID: case ax::mojom::IntAttribute::kTableHeaderId:
case ui::AX_ATTR_TABLE_ROW_HEADER_ID: case ax::mojom::IntAttribute::kTableRowHeaderId:
case ui::AX_ATTR_TABLE_ROW_INDEX: case ax::mojom::IntAttribute::kTableRowIndex:
case ui::AX_ATTR_ACTIVEDESCENDANT_ID: case ax::mojom::IntAttribute::kActivedescendantId:
case ui::AX_ATTR_IN_PAGE_LINK_TARGET_ID: case ax::mojom::IntAttribute::kInPageLinkTargetId:
case ui::AX_ATTR_ERRORMESSAGE_ID: case ax::mojom::IntAttribute::kErrormessageId:
case ui::AX_ATTR_DETAILS_ID: case ax::mojom::IntAttribute::kDetailsId:
case ui::AX_ATTR_MEMBER_OF_ID: case ax::mojom::IntAttribute::kMemberOfId:
case ui::AX_ATTR_NEXT_FOCUS_ID: case ax::mojom::IntAttribute::kNextFocusId:
case ui::AX_ATTR_NEXT_ON_LINE_ID: case ax::mojom::IntAttribute::kNextOnLineId:
case ui::AX_ATTR_PREVIOUS_FOCUS_ID: case ax::mojom::IntAttribute::kPreviousFocusId:
case ui::AX_ATTR_PREVIOUS_ON_LINE_ID: case ax::mojom::IntAttribute::kPreviousOnLineId:
case ui::AX_ATTR_CHILD_TREE_ID: case ax::mojom::IntAttribute::kChildTreeId:
case ui::AX_ATTR_SET_SIZE: case ax::mojom::IntAttribute::kSetSize:
case ui::AX_ATTR_POS_IN_SET: case ax::mojom::IntAttribute::kPosInSet:
attributes->SetInt(ToString(attr.first), attr.second); attributes->SetInt(ToString(attr.first), attr.second);
break; break;
case ui::AX_ATTR_DEFAULT_ACTION_VERB: case ax::mojom::IntAttribute::kDefaultActionVerb:
attributes->SetString( attributes->SetString(
ToString(attr.first), ToString(attr.first),
ui::ActionVerbToUnlocalizedString( ui::ActionVerbToUnlocalizedString(
static_cast<ui::AXDefaultActionVerb>(attr.second))); static_cast<ax::mojom::DefaultActionVerb>(attr.second)));
break; break;
case ui::AX_ATTR_INVALID_STATE: case ax::mojom::IntAttribute::kInvalidState: {
if (ui::AX_INVALID_STATE_NONE != attr.second) { auto state = static_cast<ax::mojom::InvalidState>(attr.second);
attributes->SetString( if (ax::mojom::InvalidState::kNone != state) {
ToString(attr.first), attributes->SetString(ToString(attr.first), ToString(state));
ToString(static_cast<ui::AXInvalidState>(attr.second)));
} }
break; } break;
case ui::AX_ATTR_CHECKED_STATE: case ax::mojom::IntAttribute::kCheckedState: {
if (ui::AX_CHECKED_STATE_NONE != attr.second) { auto state = static_cast<ax::mojom::CheckedState>(attr.second);
attributes->SetString( if (ax::mojom::CheckedState::kNone != state) {
ToString(attr.first), attributes->SetString(ToString(attr.first), ToString(state));
ToString(static_cast<ui::AXCheckedState>(attr.second)));
} }
break; } break;
case ui::AX_ATTR_RESTRICTION: case ax::mojom::IntAttribute::kRestriction:
attributes->SetString( attributes->SetString(
ToString(attr.first), ToString(attr.first),
ToString(static_cast<ui::AXRestriction>(attr.second))); ToString(static_cast<ax::mojom::Restriction>(attr.second)));
break; break;
case ui::AX_ATTR_SORT_DIRECTION: case ax::mojom::IntAttribute::kSortDirection: {
if (ui::AX_SORT_DIRECTION_NONE != attr.second) { auto state = static_cast<ax::mojom::SortDirection>(attr.second);
attributes->SetString( if (ax::mojom::SortDirection::kNone != state) {
ToString(attr.first), attributes->SetString(ToString(attr.first), ToString(state));
ToString(static_cast<ui::AXSortDirection>(attr.second)));
} }
break; } break;
case ui::AX_ATTR_NAME_FROM: case ax::mojom::IntAttribute::kNameFrom:
attributes->SetString( attributes->SetString(
ToString(attr.first), ToString(attr.first),
ToString(static_cast<ui::AXNameFrom>(attr.second))); ToString(static_cast<ax::mojom::NameFrom>(attr.second)));
break; break;
case ui::AX_ATTR_COLOR_VALUE: case ax::mojom::IntAttribute::kColorValue:
case ui::AX_ATTR_BACKGROUND_COLOR: case ax::mojom::IntAttribute::kBackgroundColor:
case ui::AX_ATTR_COLOR: case ax::mojom::IntAttribute::kColor:
attributes->SetString(ToString(attr.first), attributes->SetString(ToString(attr.first),
base::StringPrintf("0x%X", attr.second)); base::StringPrintf("0x%X", attr.second));
break; break;
case ui::AX_ATTR_DESCRIPTION_FROM: case ax::mojom::IntAttribute::kDescriptionFrom:
attributes->SetString( attributes->SetString(
ToString(attr.first), ToString(attr.first),
ToString(static_cast<ui::AXDescriptionFrom>(attr.second))); ToString(static_cast<ax::mojom::DescriptionFrom>(attr.second)));
break; break;
case ui::AX_ATTR_ARIA_CURRENT_STATE: case ax::mojom::IntAttribute::kAriaCurrentState: {
if (ui::AX_ARIA_CURRENT_STATE_NONE != attr.second) { auto state = static_cast<ax::mojom::AriaCurrentState>(attr.second);
attributes->SetString( if (ax::mojom::AriaCurrentState::kNone != state) {
ToString(attr.first), attributes->SetString(ToString(attr.first), ToString(state));
ToString(static_cast<ui::AXAriaCurrentState>(attr.second)));
} }
break; } break;
case ui::AX_ATTR_TEXT_DIRECTION: case ax::mojom::IntAttribute::kTextDirection: {
if (ui::AX_TEXT_DIRECTION_NONE != attr.second) { auto state = static_cast<ax::mojom::TextDirection>(attr.second);
attributes->SetString( if (ax::mojom::TextDirection::kNone != state) {
ToString(attr.first), attributes->SetString(ToString(attr.first), ToString(state));
ToString(static_cast<ui::AXTextDirection>(attr.second)));
} }
break; } break;
case ui::AX_ATTR_TEXT_STYLE: { case ax::mojom::IntAttribute::kTextStyle: {
auto text_style = static_cast<ui::AXTextStyle>(attr.second); auto text_style = static_cast<ax::mojom::TextStyle>(attr.second);
if (text_style == ui::AX_TEXT_STYLE_NONE) if (text_style == ax::mojom::TextStyle::kNone)
break; break;
static ui::AXTextStyle textStyleArr[] = { static ax::mojom::TextStyle textStyleArr[] = {
ui::AX_TEXT_STYLE_BOLD, ui::AX_TEXT_STYLE_ITALIC, ax::mojom::TextStyle::kTextStyleBold,
ui::AX_TEXT_STYLE_UNDERLINE, ui::AX_TEXT_STYLE_LINE_THROUGH}; ax::mojom::TextStyle::kTextStyleItalic,
ax::mojom::TextStyle::kTextStyleUnderline,
ax::mojom::TextStyle::kTextStyleLineThrough};
CefRefPtr<CefListValue> list = CefListValue::Create(); CefRefPtr<CefListValue> list = CefListValue::Create();
int index = 0; int index = 0;
// Iterate and find which states are set. // Iterate and find which states are set.
for (unsigned i = 0; i < arraysize(textStyleArr); i++) { for (unsigned i = 0; i < arraysize(textStyleArr); i++) {
if (text_style & textStyleArr[i]) if (attr.second & static_cast<int>(textStyleArr[i]))
list->SetString(index++, ToString(textStyleArr[i])); list->SetString(index++, ToString(textStyleArr[i]));
} }
attributes->SetList(ToString(attr.first), list); attributes->SetList(ToString(attr.first), list);
@@ -194,43 +193,44 @@ struct PopulateAxNodeAttributes {
} }
// Set Bool Attributes. // Set Bool Attributes.
void operator()(const std::pair<ui::AXBoolAttribute, bool> attr) { void operator()(const std::pair<ax::mojom::BoolAttribute, bool> attr) {
if (attr.first != ui::AX_BOOL_ATTRIBUTE_NONE) if (attr.first != ax::mojom::BoolAttribute::kNone)
attributes->SetBool(ToString(attr.first), attr.second); attributes->SetBool(ToString(attr.first), attr.second);
} }
// Set String Attributes. // Set String Attributes.
void operator()(const std::pair<ui::AXStringAttribute, std::string>& attr) { void operator()(
if (attr.first != ui::AX_STRING_ATTRIBUTE_NONE) const std::pair<ax::mojom::StringAttribute, std::string>& attr) {
if (attr.first != ax::mojom::StringAttribute::kNone)
attributes->SetString(ToString(attr.first), attr.second); attributes->SetString(ToString(attr.first), attr.second);
} }
// Set Float attributes. // Set Float attributes.
void operator()(const std::pair<ui::AXFloatAttribute, float>& attr) { void operator()(const std::pair<ax::mojom::FloatAttribute, float>& attr) {
if (attr.first != ui::AX_FLOAT_ATTRIBUTE_NONE) if (attr.first != ax::mojom::FloatAttribute::kNone)
attributes->SetDouble(ToString(attr.first), attr.second); attributes->SetDouble(ToString(attr.first), attr.second);
} }
// Set Int list attributes. // Set Int list attributes.
void operator()( void operator()(const std::pair<ax::mojom::IntListAttribute,
const std::pair<ui::AXIntListAttribute, std::vector<int32_t>>& attr) { std::vector<int32_t>>& attr) {
if (attr.first != ui::AX_INT_LIST_ATTRIBUTE_NONE) { if (attr.first != ax::mojom::IntListAttribute::kNone) {
CefRefPtr<CefListValue> list; CefRefPtr<CefListValue> list;
if (ui::AX_ATTR_MARKER_TYPES == attr.first) { if (ax::mojom::IntListAttribute::kMarkerTypes == attr.first) {
list = CefListValue::Create(); list = CefListValue::Create();
int index = 0; int index = 0;
for (size_t i = 0; i < attr.second.size(); ++i) { for (size_t i = 0; i < attr.second.size(); ++i) {
auto type = static_cast<ui::AXMarkerType>(attr.second[i]); auto type = static_cast<ax::mojom::MarkerType>(attr.second[i]);
if (type == ui::AX_MARKER_TYPE_NONE) if (type == ax::mojom::MarkerType::kNone)
continue; continue;
static ui::AXMarkerType marktypeArr[] = { static ax::mojom::MarkerType marktypeArr[] = {
ui::AX_MARKER_TYPE_SPELLING, ui::AX_MARKER_TYPE_GRAMMAR, ax::mojom::MarkerType::kSpelling, ax::mojom::MarkerType::kGrammar,
ui::AX_MARKER_TYPE_TEXT_MATCH}; ax::mojom::MarkerType::kTextMatch};
// Iterate and find which markers are set. // Iterate and find which markers are set.
for (unsigned j = 0; j < arraysize(marktypeArr); j++) { for (unsigned j = 0; j < arraysize(marktypeArr); j++) {
if (type & marktypeArr[j]) if (attr.second[i] & static_cast<int>(marktypeArr[j]))
list->SetString(index++, ToString(marktypeArr[j])); list->SetString(index++, ToString(marktypeArr[j]));
} }
} }
@@ -267,9 +267,10 @@ CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXNodeData& node) {
CefRefPtr<CefListValue> actions_strings; CefRefPtr<CefListValue> actions_strings;
size_t actions_idx = 0; size_t actions_idx = 0;
for (int action_index = ui::AX_ACTION_NONE + 1; for (int action_index = static_cast<int>(ax::mojom::Action::kMinValue) + 1;
action_index <= ui::AX_ACTION_LAST; ++action_index) { action_index <= static_cast<int>(ax::mojom::Action::kMaxValue);
auto action = static_cast<ui::AXAction>(action_index); ++action_index) {
auto action = static_cast<ax::mojom::Action>(action_index);
if (node.HasAction(action)) { if (node.HasAction(action)) {
if (!actions_strings) if (!actions_strings)
actions_strings = CefListValue::Create(); actions_strings = CefListValue::Create();
@@ -383,10 +384,10 @@ CefRefPtr<CefDictionaryValue> ToCefValue(
if (eventData.ax_tree_id != -1) if (eventData.ax_tree_id != -1)
value->SetInt("ax_tree_id", eventData.ax_tree_id); value->SetInt("ax_tree_id", eventData.ax_tree_id);
if (eventData.event_type != ui::AX_EVENT_NONE) if (eventData.event_type != ax::mojom::Event::kNone)
value->SetString("event_type", ToString(eventData.event_type)); value->SetString("event_type", ToString(eventData.event_type));
if (eventData.event_from != ui::AX_EVENT_FROM_NONE) if (eventData.event_from != ax::mojom::EventFrom::kNone)
value->SetString("event_from", ToString(eventData.event_from)); value->SetString("event_from", ToString(eventData.event_from));
value->SetDictionary("update", ToCefValue(eventData.update)); value->SetDictionary("update", ToCefValue(eventData.update));

View File

@@ -17,7 +17,9 @@
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "cc/base/switches.h" #include "cc/base/switches.h"
#include "components/viz/common/features.h"
#include "components/viz/common/frame_sinks/copy_output_request.h" #include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/delay_based_time_source.h" #include "components/viz/common/frame_sinks/delay_based_time_source.h"
#include "components/viz/common/gl_helper.h" #include "components/viz/common/gl_helper.h"
@@ -28,14 +30,15 @@
#include "content/browser/renderer_host/dip_util.h" #include "content/browser/renderer_host/dip_util.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h" #include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_frame_subscriber.h"
#include "content/common/input_messages.h" #include "content/common/input_messages.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/context_factory.h" #include "content/public/browser/context_factory.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
#include "ui/compositor/compositor_vsync_manager.h"
#include "ui/gfx/geometry/dip_util.h" #include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/size_conversions.h" #include "ui/gfx/geometry/size_conversions.h"
@@ -91,7 +94,7 @@ class CefCopyFrameGenerator {
&CefCopyFrameGenerator::CopyFromCompositingSurfaceHasResult, &CefCopyFrameGenerator::CopyFromCompositingSurfaceHasResult,
weak_ptr_factory_.GetWeakPtr(), damage_rect)); weak_ptr_factory_.GetWeakPtr(), damage_rect));
request->set_area(gfx::Rect(view_->GetPhysicalBackingSize())); request->set_area(gfx::Rect(view_->GetCompositorViewportPixelSize()));
view_->GetRootLayer()->RequestCopyOfOutput(std::move(request)); view_->GetRootLayer()->RequestCopyOfOutput(std::move(request));
} }
@@ -203,7 +206,8 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
content::RenderWidgetHost* widget, content::RenderWidgetHost* widget,
CefRenderWidgetHostViewOSR* parent_host_view, CefRenderWidgetHostViewOSR* parent_host_view,
bool is_guest_view_hack) bool is_guest_view_hack)
: background_color_(background_color), : content::RenderWidgetHostViewBase(widget),
background_color_(background_color),
frame_rate_threshold_us_(0), frame_rate_threshold_us_(0),
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
compositor_widget_(gfx::kNullAcceleratedWidget), compositor_widget_(gfx::kNullAcceleratedWidget),
@@ -236,10 +240,16 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
local_surface_id_ = local_surface_id_allocator_.GenerateId(); local_surface_id_ = local_surface_id_allocator_.GenerateId();
// Surface synchronization is not supported with OSR.
DCHECK(!features::IsSurfaceSynchronizationEnabled());
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
delegated_frame_host_ = base::MakeUnique<content::DelegatedFrameHost>( // Matching the attributes from BrowserCompositorMac.
delegated_frame_host_ = std::make_unique<content::DelegatedFrameHost>(
AllocateFrameSinkId(is_guest_view_hack), this, AllocateFrameSinkId(is_guest_view_hack), this,
false /* enable_surface_synchronization */, false /* enable_viz */); features::IsSurfaceSynchronizationEnabled(),
base::FeatureList::IsEnabled(features::kVizDisplayCompositor),
true /* should_register_frame_sink_id */);
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
#endif #endif
@@ -256,11 +266,12 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
content::ImageTransportFactory::GetInstance(); content::ImageTransportFactory::GetInstance();
ui::ContextFactoryPrivate* context_factory_private = ui::ContextFactoryPrivate* context_factory_private =
factory->GetContextFactoryPrivate(); factory->GetContextFactoryPrivate();
// Matching the attributes from RecyclableCompositorMac.
compositor_.reset( compositor_.reset(
new ui::Compositor(context_factory_private->AllocateFrameSinkId(), new ui::Compositor(context_factory_private->AllocateFrameSinkId(),
content::GetContextFactory(), context_factory_private, content::GetContextFactory(), context_factory_private,
base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
false /* enable_surface_synchronization */, features::IsSurfaceSynchronizationEnabled(),
false /* enable_pixel_canvas */)); false /* enable_pixel_canvas */));
compositor_->SetAcceleratedWidget(compositor_widget_); compositor_->SetAcceleratedWidget(compositor_widget_);
compositor_->SetDelegate(this); compositor_->SetDelegate(this);
@@ -326,10 +337,6 @@ void CefRenderWidgetHostViewOSR::SetSize(const gfx::Size& size) {}
void CefRenderWidgetHostViewOSR::SetBounds(const gfx::Rect& rect) {} void CefRenderWidgetHostViewOSR::SetBounds(const gfx::Rect& rect) {}
gfx::Vector2dF CefRenderWidgetHostViewOSR::GetLastScrollOffset() const {
return last_scroll_offset_;
}
gfx::NativeView CefRenderWidgetHostViewOSR::GetNativeView() const { gfx::NativeView CefRenderWidgetHostViewOSR::GetNativeView() const {
return gfx::NativeView(); return gfx::NativeView();
} }
@@ -359,9 +366,12 @@ void CefRenderWidgetHostViewOSR::Show() {
browser_compositor_->SetRenderWidgetHostIsHidden(false); browser_compositor_->SetRenderWidgetHostIsHidden(false);
#else #else
delegated_frame_host_->SetCompositor(compositor_.get()); delegated_frame_host_->SetCompositor(compositor_.get());
delegated_frame_host_->WasShown(ui::LatencyInfo()); delegated_frame_host_->WasShown(
GetLocalSurfaceId(), GetRootLayer()->bounds().size(), ui::LatencyInfo());
#endif #endif
// Note that |render_widget_host_| will retrieve size parameters from the
// DelegatedFrameHost, so it must have WasShown called after.
if (render_widget_host_) if (render_widget_host_)
render_widget_host_->WasShown(ui::LatencyInfo()); render_widget_host_->WasShown(ui::LatencyInfo());
} }
@@ -428,6 +438,22 @@ bool CefRenderWidgetHostViewOSR::LockMouse() {
void CefRenderWidgetHostViewOSR::UnlockMouse() {} void CefRenderWidgetHostViewOSR::UnlockMouse() {}
void CefRenderWidgetHostViewOSR::TakeFallbackContentFrom(
content::RenderWidgetHostView* view) {
DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)
->IsRenderWidgetHostViewChildFrame());
DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)
->IsRenderWidgetHostViewGuest());
CefRenderWidgetHostViewOSR* view_cef =
static_cast<CefRenderWidgetHostViewOSR*>(view);
SetBackgroundColor(view_cef->background_color());
if (GetDelegatedFrameHost() && view_cef->GetDelegatedFrameHost()) {
GetDelegatedFrameHost()->TakeFallbackContentFrom(
view_cef->GetDelegatedFrameHost());
}
host()->GetContentRenderingTimeoutFrom(view_cef->host());
}
void CefRenderWidgetHostViewOSR::DidCreateNewRendererCompositorFrameSink( void CefRenderWidgetHostViewOSR::DidCreateNewRendererCompositorFrameSink(
viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) { viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) {
renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;
@@ -652,44 +678,55 @@ gfx::Size CefRenderWidgetHostViewOSR::GetRequestedRendererSize() const {
return GetDelegatedFrameHost()->GetRequestedRendererSize(); return GetDelegatedFrameHost()->GetRequestedRendererSize();
} }
gfx::Size CefRenderWidgetHostViewOSR::GetPhysicalBackingSize() const { gfx::Size CefRenderWidgetHostViewOSR::GetCompositorViewportPixelSize() const {
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), return gfx::ScaleToCeiledSize(GetRequestedRendererSize(),
current_device_scale_factor_); current_device_scale_factor_);
} }
void CefRenderWidgetHostViewOSR::CopyFromSurface( void CefRenderWidgetHostViewOSR::CopyFromSurface(
const gfx::Rect& src_subrect, const gfx::Rect& src_rect,
const gfx::Size& dst_size, const gfx::Size& output_size,
const content::ReadbackRequestCallback& callback, base::OnceCallback<void(const SkBitmap&)> callback) {
const SkColorType color_type) { GetDelegatedFrameHost()->CopyFromCompositingSurface(src_rect, output_size,
GetDelegatedFrameHost()->CopyFromCompositingSurface(src_subrect, dst_size, std::move(callback));
callback, color_type);
} }
void CefRenderWidgetHostViewOSR::CopyFromSurfaceToVideoFrame( void CefRenderWidgetHostViewOSR::GetScreenInfo(
const gfx::Rect& src_subrect, content::ScreenInfo* results) const {
scoped_refptr<media::VideoFrame> target, if (!browser_impl_.get())
const base::Callback<void(const gfx::Rect&, bool)>& callback) { return;
GetDelegatedFrameHost()->CopyFromCompositingSurfaceToVideoFrame(
src_subrect, target, callback); CefScreenInfo screen_info(kDefaultScaleFactor, 0, 0, false, CefRect(),
CefRect());
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
if (handler.get() &&
(!handler->GetScreenInfo(browser_impl_.get(), screen_info) ||
screen_info.rect.width == 0 || screen_info.rect.height == 0 ||
screen_info.available_rect.width == 0 ||
screen_info.available_rect.height == 0)) {
// If a screen rectangle was not provided, try using the view rectangle
// instead. Otherwise, popup views may be drawn incorrectly, or not at all.
CefRect screenRect;
if (!handler->GetViewRect(browser_impl_.get(), screenRect)) {
NOTREACHED();
screenRect = CefRect();
}
if (screen_info.rect.width == 0 && screen_info.rect.height == 0)
screen_info.rect = screenRect;
if (screen_info.available_rect.width == 0 &&
screen_info.available_rect.height == 0)
screen_info.available_rect = screenRect;
}
*results = ScreenInfoFrom(screen_info);
} }
void CefRenderWidgetHostViewOSR::BeginFrameSubscription( gfx::Vector2d CefRenderWidgetHostViewOSR::GetOffsetFromRootSurface() {
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber> subscriber) { return gfx::Vector2d();
GetDelegatedFrameHost()->BeginFrameSubscription(std::move(subscriber));
}
void CefRenderWidgetHostViewOSR::EndFrameSubscription() {
GetDelegatedFrameHost()->EndFrameSubscription();
}
bool CefRenderWidgetHostViewOSR::HasAcceleratedSurface(
const gfx::Size& desired_size) {
// CEF doesn't use GetBackingStore for accelerated pages, so it doesn't
// matter what is returned here as GetBackingStore is the only caller of this
// method.
NOTREACHED();
return false;
} }
gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() { gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() {
@@ -704,11 +741,6 @@ gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() {
return GetViewBounds(); return GetViewBounds();
} }
content::RenderWidgetHostImpl*
CefRenderWidgetHostViewOSR::GetRenderWidgetHostImpl() const {
return render_widget_host_;
}
viz::SurfaceId CefRenderWidgetHostViewOSR::GetCurrentSurfaceId() const { viz::SurfaceId CefRenderWidgetHostViewOSR::GetCurrentSurfaceId() const {
return GetDelegatedFrameHost() return GetDelegatedFrameHost()
? GetDelegatedFrameHost()->GetCurrentSurfaceId() ? GetDelegatedFrameHost()->GetCurrentSurfaceId()
@@ -742,7 +774,9 @@ void CefRenderWidgetHostViewOSR::ImeSetComposition(
for (const CefCompositionUnderline& line : underlines) { for (const CefCompositionUnderline& line : underlines) {
web_underlines.push_back(ui::ImeTextSpan( web_underlines.push_back(ui::ImeTextSpan(
ui::ImeTextSpan::Type::kComposition, line.range.from, line.range.to, ui::ImeTextSpan::Type::kComposition, line.range.from, line.range.to,
line.color, line.thick ? true : false, line.background_color)); line.thick ? ui::ImeTextSpan::Thickness::kThick
: ui::ImeTextSpan::Thickness::kThin,
line.color, line.background_color, std::vector<std::string>()));
} }
gfx::Range range(replacement_range.from, replacement_range.to); gfx::Range range(replacement_range.from, replacement_range.to);
@@ -791,6 +825,31 @@ void CefRenderWidgetHostViewOSR::ImeCancelComposition() {
RequestImeCompositionUpdate(false); RequestImeCompositionUpdate(false);
} }
void CefRenderWidgetHostViewOSR::SelectionChanged(const base::string16& text,
size_t offset,
const gfx::Range& range) {
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
if (!browser_impl_.get())
return;
CefString selected_text;
if (!range.is_empty() && !text.empty()) {
size_t pos = range.GetMin() - offset;
size_t n = range.length();
if (pos + n <= text.length())
selected_text = text.substr(pos, n);
}
CefRefPtr<CefRenderHandler> handler =
browser_impl_->GetClient()->GetRenderHandler();
if (handler.get()) {
CefRange cef_range(range.start(), range.end());
handler->OnTextSelectionChanged(browser_impl_.get(), selected_text,
cef_range);
}
}
void CefRenderWidgetHostViewOSR::SetNeedsBeginFrames(bool enabled) { void CefRenderWidgetHostViewOSR::SetNeedsBeginFrames(bool enabled) {
SetFrameRate(); SetFrameRate();
@@ -844,6 +903,16 @@ bool CefRenderWidgetHostViewOSR::TransformPointToCoordSpaceForView(
point, target_view, transformed_point); point, target_view, transformed_point);
} }
void CefRenderWidgetHostViewOSR::DidNavigate() {
#if defined(OS_MACOSX)
browser_compositor_->DidNavigate();
#else
ResizeRootLayer();
if (delegated_frame_host_)
delegated_frame_host_->DidNavigate();
#endif
}
std::unique_ptr<viz::SoftwareOutputDevice> std::unique_ptr<viz::SoftwareOutputDevice>
CefRenderWidgetHostViewOSR::CreateSoftwareOutputDevice( CefRenderWidgetHostViewOSR::CreateSoftwareOutputDevice(
ui::Compositor* compositor) { ui::Compositor* compositor) {
@@ -878,11 +947,6 @@ SkColor CefRenderWidgetHostViewOSR::DelegatedFrameHostGetGutterColor() const {
return background_color_; return background_color_;
} }
gfx::Size CefRenderWidgetHostViewOSR::DelegatedFrameHostDesiredSizeInDIP()
const {
return GetRootLayer()->bounds().size();
}
bool CefRenderWidgetHostViewOSR::DelegatedFrameCanCreateResizeLock() const { bool CefRenderWidgetHostViewOSR::DelegatedFrameCanCreateResizeLock() const {
return !render_widget_host_->auto_resize_enabled(); return !render_widget_host_->auto_resize_enabled();
} }
@@ -892,13 +956,16 @@ CefRenderWidgetHostViewOSR::DelegatedFrameHostCreateResizeLock() {
HoldResize(); HoldResize();
const gfx::Size& desired_size = GetRootLayer()->bounds().size(); const gfx::Size& desired_size = GetRootLayer()->bounds().size();
return base::MakeUnique<content::CompositorResizeLock>(this, desired_size); return std::make_unique<content::CompositorResizeLock>(this, desired_size);
} }
viz::LocalSurfaceId CefRenderWidgetHostViewOSR::GetLocalSurfaceId() const { viz::LocalSurfaceId CefRenderWidgetHostViewOSR::GetLocalSurfaceId() const {
return local_surface_id_; return local_surface_id_;
} }
void CefRenderWidgetHostViewOSR::OnFirstSurfaceActivation(
const viz::SurfaceInfo& surface_info) {}
void CefRenderWidgetHostViewOSR::OnBeginFrame(base::TimeTicks frame_time) { void CefRenderWidgetHostViewOSR::OnBeginFrame(base::TimeTicks frame_time) {
// TODO(cef): Maybe we can use this method in combination with // TODO(cef): Maybe we can use this method in combination with
// OnSetNeedsBeginFrames() instead of using CefBeginFrameTimer. // OnSetNeedsBeginFrames() instead of using CefBeginFrameTimer.
@@ -913,6 +980,10 @@ void CefRenderWidgetHostViewOSR::OnFrameTokenChanged(uint32_t frame_token) {
render_widget_host_->DidProcessFrame(frame_token); render_widget_host_->DidProcessFrame(frame_token);
} }
void CefRenderWidgetHostViewOSR::DidReceiveFirstFrameAfterNavigation() {
render_widget_host_->DidReceiveFirstFrameAfterNavigation();
}
std::unique_ptr<ui::CompositorLock> std::unique_ptr<ui::CompositorLock>
CefRenderWidgetHostViewOSR::GetCompositorLock( CefRenderWidgetHostViewOSR::GetCompositorLock(
ui::CompositorLockClient* client) { ui::CompositorLockClient* client) {
@@ -946,42 +1017,6 @@ void CefRenderWidgetHostViewOSR::WasResized() {
} }
ResizeRootLayer(); ResizeRootLayer();
if (render_widget_host_)
render_widget_host_->WasResized();
GetDelegatedFrameHost()->WasResized();
}
void CefRenderWidgetHostViewOSR::GetScreenInfo(content::ScreenInfo* results) {
if (!browser_impl_.get())
return;
CefScreenInfo screen_info(kDefaultScaleFactor, 0, 0, false, CefRect(),
CefRect());
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
if (handler.get() &&
(!handler->GetScreenInfo(browser_impl_.get(), screen_info) ||
screen_info.rect.width == 0 || screen_info.rect.height == 0 ||
screen_info.available_rect.width == 0 ||
screen_info.available_rect.height == 0)) {
// If a screen rectangle was not provided, try using the view rectangle
// instead. Otherwise, popup views may be drawn incorrectly, or not at all.
CefRect screenRect;
if (!handler->GetViewRect(browser_impl_.get(), screenRect)) {
NOTREACHED();
screenRect = CefRect();
}
if (screen_info.rect.width == 0 && screen_info.rect.height == 0)
screen_info.rect = screenRect;
if (screen_info.available_rect.width == 0 &&
screen_info.available_rect.height == 0)
screen_info.available_rect = screenRect;
}
*results = ScreenInfoFrom(screen_info);
} }
void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() { void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() {
@@ -991,7 +1026,22 @@ void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() {
// TODO(OSR): Update the backing store. // TODO(OSR): Update the backing store.
if (render_widget_host_->delegate())
render_widget_host_->delegate()->SendScreenRects();
else
render_widget_host_->SendScreenRects();
#if defined(OS_MACOSX)
// RenderWidgetHostImpl will query BrowserCompositorMac for the dimensions
// to send to the renderer, so it is required that BrowserCompositorMac be
// updated first. Only notify RenderWidgetHostImpl of the update if any
// properties it will query have changed.
if (UpdateNSViewAndDisplay())
render_widget_host_->NotifyScreenInfoChanged();
#else
render_widget_host_->NotifyScreenInfoChanged(); render_widget_host_->NotifyScreenInfoChanged();
#endif
// We might want to change the cursor scale factor here as well - see the // We might want to change the cursor scale factor here as well - see the
// cache for the current_cursor_, as passed by UpdateCursor from the renderer // cache for the current_cursor_, as passed by UpdateCursor from the renderer
// in the rwhv_aura (current_cursor_.SetScaleFactor) // in the rwhv_aura (current_cursor_.SetScaleFactor)
@@ -1011,7 +1061,7 @@ void CefRenderWidgetHostViewOSR::Invalidate(
return; return;
} }
InvalidateInternal(gfx::Rect(GetPhysicalBackingSize())); InvalidateInternal(gfx::Rect(GetCompositorViewportPixelSize()));
} }
void CefRenderWidgetHostViewOSR::SendKeyEvent( void CefRenderWidgetHostViewOSR::SendKeyEvent(
@@ -1246,9 +1296,11 @@ void CefRenderWidgetHostViewOSR::SetFrameRate() {
osr_util::ClampFrameRate(browser->settings().windowless_frame_rate); osr_util::ClampFrameRate(browser->settings().windowless_frame_rate);
frame_rate_threshold_us_ = 1000000 / frame_rate; frame_rate_threshold_us_ = 1000000 / frame_rate;
// Configure the VSync interval for the browser process. if (GetCompositor()) {
GetCompositor()->vsync_manager()->SetAuthoritativeVSyncInterval( // Configure the VSync interval for the browser process.
base::TimeDelta::FromMicroseconds(frame_rate_threshold_us_)); GetCompositor()->vsync_manager()->SetAuthoritativeVSyncInterval(
base::TimeDelta::FromMicroseconds(frame_rate_threshold_us_));
}
if (copy_frame_generator_.get()) { if (copy_frame_generator_.get()) {
copy_frame_generator_->set_frame_rate_threshold_us( copy_frame_generator_->set_frame_rate_threshold_us(
@@ -1314,9 +1366,24 @@ void CefRenderWidgetHostViewOSR::ResizeRootLayer() {
local_surface_id_ = local_surface_id_allocator_.GenerateId(); local_surface_id_ = local_surface_id_allocator_.GenerateId();
GetRootLayer()->SetBounds(gfx::Rect(size)); GetRootLayer()->SetBounds(gfx::Rect(size));
GetCompositor()->SetScaleAndSize(current_device_scale_factor_, size_in_pixels, if (GetCompositor()) {
local_surface_id_); GetCompositor()->SetScaleAndSize(current_device_scale_factor_,
size_in_pixels, local_surface_id_);
}
PlatformResizeCompositorWidget(size_in_pixels); PlatformResizeCompositorWidget(size_in_pixels);
#if defined(OS_MACOSX)
bool resized = UpdateNSViewAndDisplay();
#else
bool resized = true;
GetDelegatedFrameHost()->WasResized(local_surface_id_, size,
cc::DeadlinePolicy::UseDefaultDeadline());
#endif
// Note that |render_widget_host_| will retrieve resize parameters from the
// DelegatedFrameHost, so it must have WasResized called after.
if (resized && render_widget_host_)
render_widget_host_->WasResized();
} }
void CefRenderWidgetHostViewOSR::OnBeginFrameTimerTick() { void CefRenderWidgetHostViewOSR::OnBeginFrameTimerTick() {
@@ -1416,10 +1483,9 @@ void CefRenderWidgetHostViewOSR::RemoveGuestHostView(
void CefRenderWidgetHostViewOSR::RegisterGuestViewFrameSwappedCallback( void CefRenderWidgetHostViewOSR::RegisterGuestViewFrameSwappedCallback(
content::RenderWidgetHostViewGuest* guest_host_view) { content::RenderWidgetHostViewGuest* guest_host_view) {
guest_host_view->RegisterFrameSwappedCallback( guest_host_view->RegisterFrameSwappedCallback(base::BindOnce(
base::MakeUnique<base::Closure>(base::Bind( &CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped,
&CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped, weak_ptr_factory_.GetWeakPtr(), base::Unretained(guest_host_view)));
weak_ptr_factory_.GetWeakPtr(), base::Unretained(guest_host_view))));
guest_host_view->set_current_device_scale_factor( guest_host_view->set_current_device_scale_factor(
current_device_scale_factor_); current_device_scale_factor_);
} }

View File

@@ -102,7 +102,6 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
void InitAsChild(gfx::NativeView parent_view) override; void InitAsChild(gfx::NativeView parent_view) override;
void SetSize(const gfx::Size& size) override; void SetSize(const gfx::Size& size) override;
void SetBounds(const gfx::Rect& rect) override; void SetBounds(const gfx::Rect& rect) override;
gfx::Vector2dF GetLastScrollOffset() const override;
gfx::NativeView GetNativeView() const override; gfx::NativeView GetNativeView() const override;
gfx::NativeViewAccessible GetNativeViewAccessible() override; gfx::NativeViewAccessible GetNativeViewAccessible() override;
void Focus() override; void Focus() override;
@@ -116,14 +115,13 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
SkColor background_color() const override; SkColor background_color() const override;
bool LockMouse() override; bool LockMouse() override;
void UnlockMouse() override; void UnlockMouse() override;
void TakeFallbackContentFrom(content::RenderWidgetHostView* view) override;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
void SetActive(bool active) override; void SetActive(bool active) override;
void ShowDefinitionForSelection() override; void ShowDefinitionForSelection() override;
bool SupportsSpeech() const override;
void SpeakSelection() override; void SpeakSelection() override;
bool IsSpeaking() const override; bool ShouldContinueToPauseForFrame() override;
void StopSpeaking() override;
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
// RenderWidgetHostViewBase implementation. // RenderWidgetHostViewBase implementation.
@@ -149,22 +147,14 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
void SetTooltipText(const base::string16& tooltip_text) override; void SetTooltipText(const base::string16& tooltip_text) override;
gfx::Size GetRequestedRendererSize() const override; gfx::Size GetRequestedRendererSize() const override;
gfx::Size GetPhysicalBackingSize() const override; gfx::Size GetCompositorViewportPixelSize() const override;
void CopyFromSurface(const gfx::Rect& src_subrect, void CopyFromSurface(
const gfx::Size& dst_size, const gfx::Rect& src_rect,
const content::ReadbackRequestCallback& callback, const gfx::Size& output_size,
const SkColorType color_type) override; base::OnceCallback<void(const SkBitmap&)> callback) override;
void CopyFromSurfaceToVideoFrame( void GetScreenInfo(content::ScreenInfo* results) const override;
const gfx::Rect& src_subrect, gfx::Vector2d GetOffsetFromRootSurface() override;
scoped_refptr<media::VideoFrame> target,
const base::Callback<void(const gfx::Rect&, bool)>& callback) override;
void BeginFrameSubscription(
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber> subscriber)
override;
void EndFrameSubscription() override;
bool HasAcceleratedSurface(const gfx::Size& desired_size) override;
gfx::Rect GetBoundsInRootWindow() override; gfx::Rect GetBoundsInRootWindow() override;
content::RenderWidgetHostImpl* GetRenderWidgetHostImpl() const override;
viz::SurfaceId GetCurrentSurfaceId() const override; viz::SurfaceId GetCurrentSurfaceId() const override;
content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager( content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(
content::BrowserAccessibilityDelegate* delegate, content::BrowserAccessibilityDelegate* delegate,
@@ -188,6 +178,11 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
const gfx::PointF& point, const gfx::PointF& point,
RenderWidgetHostViewBase* target_view, RenderWidgetHostViewBase* target_view,
gfx::PointF* transformed_point) override; gfx::PointF* transformed_point) override;
void DidNavigate() override;
void SelectionChanged(const base::string16& text,
size_t offset,
const gfx::Range& range) override;
// ui::CompositorDelegate implementation. // ui::CompositorDelegate implementation.
std::unique_ptr<viz::SoftwareOutputDevice> CreateSoftwareOutputDevice( std::unique_ptr<viz::SoftwareOutputDevice> CreateSoftwareOutputDevice(
@@ -198,14 +193,15 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
ui::Layer* DelegatedFrameHostGetLayer() const override; ui::Layer* DelegatedFrameHostGetLayer() const override;
bool DelegatedFrameHostIsVisible() const override; bool DelegatedFrameHostIsVisible() const override;
SkColor DelegatedFrameHostGetGutterColor() const override; SkColor DelegatedFrameHostGetGutterColor() const override;
gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override;
bool DelegatedFrameCanCreateResizeLock() const override; bool DelegatedFrameCanCreateResizeLock() const override;
std::unique_ptr<content::CompositorResizeLock> std::unique_ptr<content::CompositorResizeLock>
DelegatedFrameHostCreateResizeLock() override; DelegatedFrameHostCreateResizeLock() override;
viz::LocalSurfaceId GetLocalSurfaceId() const override; viz::LocalSurfaceId GetLocalSurfaceId() const override;
void OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) override;
void OnBeginFrame(base::TimeTicks frame_time) override; void OnBeginFrame(base::TimeTicks frame_time) override;
bool IsAutoResizeEnabled() const override; bool IsAutoResizeEnabled() const override;
void OnFrameTokenChanged(uint32_t frame_token) override; void OnFrameTokenChanged(uint32_t frame_token) override;
void DidReceiveFirstFrameAfterNavigation() override;
// CompositorResizeLockClient implementation. // CompositorResizeLockClient implementation.
std::unique_ptr<ui::CompositorLock> GetCompositorLock( std::unique_ptr<ui::CompositorLock> GetCompositorLock(
@@ -216,7 +212,6 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
bool InstallTransparency(); bool InstallTransparency();
void WasResized(); void WasResized();
void GetScreenInfo(content::ScreenInfo* results);
void OnScreenInfoChanged(); void OnScreenInfoChanged();
void Invalidate(CefBrowserHost::PaintElementType type); void Invalidate(CefBrowserHost::PaintElementType type);
void SendKeyEvent(const content::NativeWebKeyboardEvent& event); void SendKeyEvent(const content::NativeWebKeyboardEvent& event);
@@ -303,7 +298,9 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
friend class MacHelper; friend class MacHelper;
#endif bool UpdateNSViewAndDisplay();
#endif // defined(OS_MACOSX)
void PlatformCreateCompositorWidget(bool is_guest_view_hack); void PlatformCreateCompositorWidget(bool is_guest_view_hack);
void PlatformResizeCompositorWidget(const gfx::Size& size); void PlatformResizeCompositorWidget(const gfx::Size& size);
void PlatformDestroyCompositorWidget(); void PlatformDestroyCompositorWidget();

View File

@@ -11,7 +11,7 @@
#include "libcef/browser/native/window_x11.h" #include "libcef/browser/native/window_x11.h"
#include "third_party/WebKit/public/platform/WebCursorInfo.h" #include "third_party/blink/public/platform/web_cursor_info.h"
#include "ui/base/x/x11_util.h" #include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_types.h" #include "ui/gfx/x/x11_types.h"

View File

@@ -17,6 +17,16 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h" #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#include "ui/display/screen.h"
namespace {
display::Display GetDisplay() {
// TODO(cef): Get display info from callbacks.
return display::Screen::GetScreen()->GetDisplayNearestView(nullptr);
}
} // namespace
class MacHelper : public content::BrowserCompositorMacClient, class MacHelper : public content::BrowserCompositorMacClient,
public ui::AcceleratedWidgetMacNSView { public ui::AcceleratedWidgetMacNSView {
@@ -37,7 +47,7 @@ class MacHelper : public content::BrowserCompositorMacClient,
return view_->background_color(); return view_->background_color();
} }
void BrowserCompositorMacOnBeginFrame() override {} void BrowserCompositorMacOnBeginFrame(base::TimeTicks frame_time) override {}
void OnFrameTokenChanged(uint32_t frame_token) override { void OnFrameTokenChanged(uint32_t frame_token) override {
view_->render_widget_host()->DidProcessFrame(frame_token); view_->render_widget_host()->DidProcessFrame(frame_token);
@@ -60,6 +70,14 @@ class MacHelper : public content::BrowserCompositorMacClient,
void AcceleratedWidgetSwapCompleted() override {} void AcceleratedWidgetSwapCompleted() override {}
void DidReceiveFirstFrameAfterNavigation() override {
view_->render_widget_host()->DidReceiveFirstFrameAfterNavigation();
}
void DestroyCompositorForShutdown() override {}
void WasResized() override { view_->render_widget_host()->WasResized(); }
private: private:
// Guaranteed to outlive this object. // Guaranteed to outlive this object.
CefRenderWidgetHostViewOSR* view_; CefRenderWidgetHostViewOSR* view_;
@@ -71,18 +89,12 @@ void CefRenderWidgetHostViewOSR::SetActive(bool active) {}
void CefRenderWidgetHostViewOSR::ShowDefinitionForSelection() {} void CefRenderWidgetHostViewOSR::ShowDefinitionForSelection() {}
bool CefRenderWidgetHostViewOSR::SupportsSpeech() const {
return false;
}
void CefRenderWidgetHostViewOSR::SpeakSelection() {} void CefRenderWidgetHostViewOSR::SpeakSelection() {}
bool CefRenderWidgetHostViewOSR::IsSpeaking() const { bool CefRenderWidgetHostViewOSR::ShouldContinueToPauseForFrame() {
return false; return browser_compositor_->ShouldContinueToPauseForFrame();
} }
void CefRenderWidgetHostViewOSR::StopSpeaking() {}
ui::Compositor* CefRenderWidgetHostViewOSR::GetCompositor() const { ui::Compositor* CefRenderWidgetHostViewOSR::GetCompositor() const {
return browser_compositor_->GetCompositor(); return browser_compositor_->GetCompositor();
} }
@@ -96,6 +108,11 @@ content::DelegatedFrameHost* CefRenderWidgetHostViewOSR::GetDelegatedFrameHost()
return browser_compositor_->GetDelegatedFrameHost(); return browser_compositor_->GetDelegatedFrameHost();
} }
bool CefRenderWidgetHostViewOSR::UpdateNSViewAndDisplay() {
return browser_compositor_->UpdateNSViewAndDisplay(
GetRootLayer()->bounds().size(), GetDisplay());
}
void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget( void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget(
bool is_guest_view_hack) { bool is_guest_view_hack) {
// Create a borderless non-visible 1x1 window. // Create a borderless non-visible 1x1 window.
@@ -114,7 +131,7 @@ void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget(
mac_helper_ = new MacHelper(this); mac_helper_ = new MacHelper(this);
browser_compositor_.reset(new content::BrowserCompositorMac( browser_compositor_.reset(new content::BrowserCompositorMac(
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true, mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true,
AllocateFrameSinkId(is_guest_view_hack))); GetDisplay(), AllocateFrameSinkId(is_guest_view_hack)));
} }
void CefRenderWidgetHostViewOSR::PlatformResizeCompositorWidget( void CefRenderWidgetHostViewOSR::PlatformResizeCompositorWidget(

View File

@@ -10,7 +10,7 @@
#include "libcef/browser/browser_host_impl.h" #include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/content_browser_client.h" #include "libcef/browser/content_browser_client.h"
#include "third_party/WebKit/public/platform/WebCursorInfo.h" #include "third_party/blink/public/platform/web_cursor_info.h"
#include "ui/resources/grit/ui_unscaled_resources.h" #include "ui/resources/grit/ui_unscaled_resources.h"
namespace { namespace {

View File

@@ -41,14 +41,6 @@ gfx::NativeWindow CefWebContentsViewOSR::GetTopLevelNativeWindow() const {
return gfx::NativeWindow(); return gfx::NativeWindow();
} }
void CefWebContentsViewOSR::GetScreenInfo(content::ScreenInfo* results) const {
CefRenderWidgetHostViewOSR* view = GetView();
if (view)
view->GetScreenInfo(results);
else
WebContentsView::GetDefaultScreenInfo(results);
}
void CefWebContentsViewOSR::GetContainerBounds(gfx::Rect* out) const { void CefWebContentsViewOSR::GetContainerBounds(gfx::Rect* out) const {
*out = GetViewBounds(); *out = GetViewBounds();
} }
@@ -135,9 +127,10 @@ CefWebContentsViewOSR::CreateViewForPopupWidget(
void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) {} void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) {}
void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) { void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) {
// |view| will be nullptr the first time this method is called for popup if (!host)
// browsers. return;
CefRenderWidgetHostViewOSR* view = GetView(); CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(host->GetWidget()->GetView());
if (view) if (view)
view->InstallTransparency(); view->InstallTransparency();
} }

View File

@@ -33,7 +33,6 @@ class CefWebContentsViewOSR : public content::WebContentsView,
gfx::NativeView GetNativeView() const override; gfx::NativeView GetNativeView() const override;
gfx::NativeView GetContentNativeView() const override; gfx::NativeView GetContentNativeView() const override;
gfx::NativeWindow GetTopLevelNativeWindow() const override; gfx::NativeWindow GetTopLevelNativeWindow() const override;
void GetScreenInfo(content::ScreenInfo* screen_info) const override;
void GetContainerBounds(gfx::Rect* out) const override; void GetContainerBounds(gfx::Rect* out) const override;
void SizeContents(const gfx::Size& size) override; void SizeContents(const gfx::Size& size) override;
void Focus() override; void Focus() override;

View File

@@ -43,7 +43,7 @@
#include "components/update_client/update_client.h" #include "components/update_client/update_client.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/features/features.h" #include "extensions/buildflags/buildflags.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
namespace browser_prefs { namespace browser_prefs {

View File

@@ -131,15 +131,15 @@ void CefPrefStore::ReportValueChanged(const std::string& key, uint32_t flags) {
} }
void CefPrefStore::SetString(const std::string& key, const std::string& value) { void CefPrefStore::SetString(const std::string& key, const std::string& value) {
SetValue(key, base::MakeUnique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS); SetValue(key, std::make_unique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS);
} }
void CefPrefStore::SetInteger(const std::string& key, int value) { void CefPrefStore::SetInteger(const std::string& key, int value) {
SetValue(key, base::MakeUnique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS); SetValue(key, std::make_unique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS);
} }
void CefPrefStore::SetBoolean(const std::string& key, bool value) { void CefPrefStore::SetBoolean(const std::string& key, bool value) {
SetValue(key, base::MakeUnique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS); SetValue(key, std::make_unique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS);
} }
bool CefPrefStore::GetString(const std::string& key, std::string* value) const { bool CefPrefStore::GetString(const std::string& key, std::string* value) const {

View File

@@ -36,7 +36,7 @@
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/view_type_utils.h" #include "extensions/browser/view_type_utils.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "media/media_features.h" #include "media/media_buildflags.h"
namespace renderer_prefs { namespace renderer_prefs {

View File

@@ -183,16 +183,16 @@ bool CefPrintDialogLinux::UpdateSettings(printing::PrintSettings* settings) {
void CefPrintDialogLinux::ShowDialog( void CefPrintDialogLinux::ShowDialog(
gfx::NativeView parent_view, gfx::NativeView parent_view,
bool has_selection, bool has_selection,
const PrintingContextLinux::PrintSettingsCallback& callback) { PrintingContextLinux::PrintSettingsCallback callback) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
SetHandler(); SetHandler();
if (!handler_.get()) { if (!handler_.get()) {
callback.Run(PrintingContextLinux::CANCEL); std::move(callback).Run(PrintingContextLinux::CANCEL);
return; return;
} }
callback_ = callback; callback_ = std::move(callback);
CefRefPtr<CefPrintDialogCallbackImpl> callback_impl( CefRefPtr<CefPrintDialogCallbackImpl> callback_impl(
new CefPrintDialogCallbackImpl(this)); new CefPrintDialogCallbackImpl(this));
@@ -310,18 +310,15 @@ void CefPrintDialogLinux::OnPrintContinue(
CefValueController::AutoLock lock_scope(impl->controller()); CefValueController::AutoLock lock_scope(impl->controller());
context_->InitWithSettings(impl->print_settings()); context_->InitWithSettings(impl->print_settings());
} }
callback_.Run(PrintingContextLinux::OK); std::move(callback_).Run(PrintingContextLinux::OK);
callback_.Reset();
} }
void CefPrintDialogLinux::OnPrintCancel() { void CefPrintDialogLinux::OnPrintCancel() {
callback_.Run(PrintingContextLinux::CANCEL); std::move(callback_).Run(PrintingContextLinux::CANCEL);
callback_.Reset();
} }
void CefPrintDialogLinux::OnJobCompleted() { void CefPrintDialogLinux::OnJobCompleted() {
content::BrowserThread::PostTask( CEF_POST_BACKGROUND_TASK(
content::BrowserThread::FILE, FROM_HERE,
base::Bind(base::IgnoreResult(&base::DeleteFile), path_to_pdf_, false)); base::Bind(base::IgnoreResult(&base::DeleteFile), path_to_pdf_, false));
// Printing finished. Matches AddRef() in PrintDocument(); // Printing finished. Matches AddRef() in PrintDocument();

View File

@@ -40,13 +40,13 @@ class CefPrintDialogLinux : public printing::PrintDialogGtkInterface,
// Notify the client when printing has started. // Notify the client when printing has started.
static void OnPrintStart(int render_process_id, int render_routing_id); static void OnPrintStart(int render_process_id, int render_routing_id);
// printing::CefPrintDialogLinuxInterface implementation. // PrintDialogGtkInterface implementation.
void UseDefaultSettings() override; void UseDefaultSettings() override;
bool UpdateSettings(printing::PrintSettings* settings) override; bool UpdateSettings(printing::PrintSettings* settings) override;
void ShowDialog( void ShowDialog(
gfx::NativeView parent_view, gfx::NativeView parent_view,
bool has_selection, bool has_selection,
const PrintingContextLinux::PrintSettingsCallback& callback) override; PrintingContextLinux::PrintSettingsCallback callback) override;
void PrintDocument(const printing::MetafilePlayer& metafile, void PrintDocument(const printing::MetafilePlayer& metafile,
const base::string16& document_name) override; const base::string16& document_name) override;
void AddRefToDialog() override; void AddRefToDialog() override;

View File

@@ -22,6 +22,8 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "printing/pdf_metafile_skia.h" #include "printing/pdf_metafile_skia.h"
#include "libcef/browser/thread_util.h"
using content::BrowserThread; using content::BrowserThread;
DEFINE_WEB_CONTENTS_USER_DATA_KEY(printing::CefPrintViewManager); DEFINE_WEB_CONTENTS_USER_DATA_KEY(printing::CefPrintViewManager);
@@ -130,7 +132,7 @@ scoped_refptr<base::RefCountedBytes> GetDataFromHandle(
base::SharedMemoryHandle handle, base::SharedMemoryHandle handle,
uint32_t data_size) { uint32_t data_size) {
std::unique_ptr<base::SharedMemory> shared_buf = std::unique_ptr<base::SharedMemory> shared_buf =
base::MakeUnique<base::SharedMemory>(handle, true); std::make_unique<base::SharedMemory>(handle, true);
if (!shared_buf->Map(data_size)) { if (!shared_buf->Map(data_size)) {
NOTREACHED(); NOTREACHED();
@@ -146,10 +148,10 @@ scoped_refptr<base::RefCountedBytes> GetDataFromHandle(
void SavePdfFile(scoped_refptr<base::RefCountedBytes> data, void SavePdfFile(scoped_refptr<base::RefCountedBytes> data,
const base::FilePath& path, const base::FilePath& path,
const CefPrintViewManager::PdfPrintCallback& callback) { const CefPrintViewManager::PdfPrintCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE); CEF_REQUIRE_BLOCKING();
DCHECK_GT(data->size(), 0U); DCHECK_GT(data->size(), 0U);
PdfMetafileSkia metafile(SkiaDocumentType::PDF); PdfMetafileSkia metafile;
metafile.InitFromData(static_cast<const void*>(data->front()), data->size()); metafile.InitFromData(static_cast<const void*>(data->front()), data->size());
base::File file(path, base::File file(path,
@@ -265,8 +267,8 @@ void CefPrintViewManager::OnMetafileReadyForPrinting(
if (!pdf_print_state_) if (!pdf_print_state_)
return; return;
scoped_refptr<base::RefCountedBytes> data_bytes = scoped_refptr<base::RefCountedBytes> data_bytes = GetDataFromHandle(
GetDataFromHandle(params.metafile_data_handle, params.data_size); params.content.metafile_data_handle, params.content.data_size);
if (!data_bytes || !data_bytes->size()) { if (!data_bytes || !data_bytes->size()) {
TerminatePdfPrintJob(); TerminatePdfPrintJob();
return; return;
@@ -279,8 +281,7 @@ void CefPrintViewManager::OnMetafileReadyForPrinting(
pdf_print_state_.reset(); pdf_print_state_.reset();
// Save the PDF file to disk and then execute the callback. // Save the PDF file to disk and then execute the callback.
BrowserThread::PostTask( CEF_POST_USER_VISIBLE_TASK(
BrowserThread::FILE, FROM_HERE,
base::Bind(&SavePdfFile, data_bytes, output_path, print_callback)); base::Bind(&SavePdfFile, data_bytes, output_path, print_callback));
} }

View File

@@ -10,7 +10,7 @@
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h" #include "base/location.h"
#include "base/memory/ptr_util.h" #include "base/memory/ref_counted_memory.h"
#include "base/memory/shared_memory.h" #include "base/memory/shared_memory.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
@@ -27,11 +27,13 @@
#include "chrome/browser/printing/printer_query.h" #include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/printing/browser/print_composite_client.h" #include "components/printing/browser/print_composite_client.h"
#include "components/printing/browser/print_manager_utils.h" #include "components/printing/browser/print_manager_utils.h"
#include "components/printing/common/print_messages.h" #include "components/printing/common/print_messages.h"
#include "components/printing/service/public/cpp/pdf_service_mojo_types.h"
#include "components/printing/service/public/cpp/pdf_service_mojo_utils.h" #include "components/printing/service/public/cpp/pdf_service_mojo_utils.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
@@ -41,12 +43,14 @@
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "extensions/common/constants.h"
#include "mojo/public/cpp/system/buffer.h" #include "mojo/public/cpp/system/buffer.h"
#include "printing/features/features.h" #include "printing/buildflags/buildflags.h"
#include "printing/pdf_metafile_skia.h" #include "printing/pdf_metafile_skia.h"
#include "printing/print_settings.h" #include "printing/print_settings.h"
#include "printing/printed_document.h" #include "printing/printed_document.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/command_line.h" #include "base/command_line.h"
@@ -58,6 +62,18 @@ using content::BrowserThread;
namespace printing { namespace printing {
namespace {
bool PrintingPdfContent(content::RenderFrameHost* rfh) {
GURL url = rfh->GetLastCommittedURL();
// Whether it is inside print preview or pdf plugin extension.
return url.GetOrigin() == chrome::kChromeUIPrintURL ||
(url.SchemeIs(extensions::kExtensionScheme) &&
url.host_piece() == extension_misc::kPdfExtensionId);
}
} // namespace
CefPrintViewManagerBase::CefPrintViewManagerBase( CefPrintViewManagerBase::CefPrintViewManagerBase(
content::WebContents* web_contents) content::WebContents* web_contents)
: PrintManager(web_contents), : PrintManager(web_contents),
@@ -86,13 +102,13 @@ bool CefPrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
SetPrintingRFH(rfh); SetPrintingRFH(rfh);
int32_t id = rfh->GetRoutingID(); int32_t id = rfh->GetRoutingID();
return PrintNowInternal(rfh, base::MakeUnique<PrintMsg_PrintPages>(id)); return PrintNowInternal(rfh, std::make_unique<PrintMsg_PrintPages>(id));
} }
#endif #endif
void CefPrintViewManagerBase::PrintDocument( void CefPrintViewManagerBase::PrintDocument(
PrintedDocument* document, PrintedDocument* document,
const scoped_refptr<base::RefCountedBytes>& print_data, const scoped_refptr<base::RefCountedMemory>& print_data,
const gfx::Size& page_size, const gfx::Size& page_size,
const gfx::Rect& content_area, const gfx::Rect& content_area,
const gfx::Point& offsets) { const gfx::Point& offsets) {
@@ -120,9 +136,14 @@ void CefPrintViewManagerBase::PrintDocument(
print_job_->StartPdfToEmfConversion(print_data, page_size, content_area, print_job_->StartPdfToEmfConversion(print_data, page_size, content_area,
print_text_with_gdi); print_text_with_gdi);
} }
// Indicate that the PDF is fully rendered and we no longer need the renderer
// and web contents, so the print job does not need to be cancelled if they
// die. This is needed on Windows because the PrintedDocument will not be
// considered complete until PDF conversion finishes.
document->SetConvertingPdf();
#else #else
std::unique_ptr<PdfMetafileSkia> metafile = std::unique_ptr<PdfMetafileSkia> metafile =
std::make_unique<PdfMetafileSkia>(SkiaDocumentType::PDF); std::make_unique<PdfMetafileSkia>();
CHECK(metafile->InitFromData(print_data->front(), print_data->size())); CHECK(metafile->InitFromData(print_data->front(), print_data->size()));
// Update the rendered document. It will send notifications to the listener. // Update the rendered document. It will send notifications to the listener.
@@ -186,48 +207,50 @@ void CefPrintViewManagerBase::OnComposePdfDone(
std::unique_ptr<base::SharedMemory> shared_buf = std::unique_ptr<base::SharedMemory> shared_buf =
GetShmFromMojoHandle(std::move(handle)); GetShmFromMojoHandle(std::move(handle));
scoped_refptr<base::RefCountedBytes> bytes = if (!shared_buf)
base::MakeRefCounted<base::RefCountedBytes>( return;
reinterpret_cast<const unsigned char*>(shared_buf->memory()),
shared_buf->mapped_size()); size_t size = shared_buf->mapped_size();
PrintDocument(document, bytes, params.page_size, params.content_area, auto data = base::MakeRefCounted<base::RefCountedSharedMemory>(
std::move(shared_buf), size);
PrintDocument(document, data, params.page_size, params.content_area,
params.physical_offsets); params.physical_offsets);
} }
void CefPrintViewManagerBase::OnDidPrintDocument( void CefPrintViewManagerBase::OnDidPrintDocument(
content::RenderFrameHost* render_frame_host,
const PrintHostMsg_DidPrintDocument_Params& params) { const PrintHostMsg_DidPrintDocument_Params& params) {
PrintedDocument* document = GetDocument(params.document_cookie); PrintedDocument* document = GetDocument(params.document_cookie);
if (!document) if (!document)
return; return;
if (!base::SharedMemory::IsHandleValid(params.metafile_data_handle)) { const PrintHostMsg_DidPrintContent_Params& content = params.content;
if (!base::SharedMemory::IsHandleValid(content.metafile_data_handle)) {
NOTREACHED() << "invalid memory handle"; NOTREACHED() << "invalid memory handle";
web_contents()->Stop(); web_contents()->Stop();
return; return;
} }
auto* client = PrintCompositeClient::FromWebContents(web_contents()); auto* client = PrintCompositeClient::FromWebContents(web_contents());
if (IsOopifEnabled() && !client->for_preview() && if (IsOopifEnabled() && !PrintingPdfContent(render_frame_host)) {
!document->settings().is_modifiable()) { client->DoCompositeDocumentToPdf(
client->DoComposite( params.document_cookie, render_frame_host, content.metafile_data_handle,
params.metafile_data_handle, params.data_size, content.data_size, content.subframe_content_info,
base::BindOnce(&CefPrintViewManagerBase::OnComposePdfDone, base::BindOnce(&CefPrintViewManagerBase::OnComposePdfDone,
weak_ptr_factory_.GetWeakPtr(), params)); weak_ptr_factory_.GetWeakPtr(), params));
return; return;
} }
auto shared_buf =
std::unique_ptr<base::SharedMemory> shared_buf = std::make_unique<base::SharedMemory>(content.metafile_data_handle, true);
std::make_unique<base::SharedMemory>(params.metafile_data_handle, true); if (!shared_buf->Map(content.data_size)) {
if (!shared_buf->Map(params.data_size)) {
NOTREACHED() << "couldn't map"; NOTREACHED() << "couldn't map";
web_contents()->Stop(); web_contents()->Stop();
return; return;
} }
scoped_refptr<base::RefCountedBytes> bytes =
base::MakeRefCounted<base::RefCountedBytes>( auto data = base::MakeRefCounted<base::RefCountedSharedMemory>(
reinterpret_cast<const unsigned char*>(shared_buf->memory()), std::move(shared_buf), content.data_size);
params.data_size); PrintDocument(document, data, params.page_size, params.content_area,
PrintDocument(document, bytes, params.page_size, params.content_area,
params.physical_offsets); params.physical_offsets);
} }
@@ -275,8 +298,16 @@ bool CefPrintViewManagerBase::OnMessageReceived(
const IPC::Message& message, const IPC::Message& message,
content::RenderFrameHost* render_frame_host) { content::RenderFrameHost* render_frame_host) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(CefPrintViewManagerBase, message) IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(CefPrintViewManagerBase, message,
render_frame_host)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintDocument, OnDidPrintDocument) IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintDocument, OnDidPrintDocument)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
if (handled)
return true;
handled = true;
IPC_BEGIN_MESSAGE_MAP(CefPrintViewManagerBase, message)
IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError, IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError,
OnShowInvalidPrinterSettingsError) OnShowInvalidPrinterSettingsError)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
@@ -346,18 +377,18 @@ bool CefPrintViewManagerBase::RenderAllMissingPagesNow() {
if (!print_job_.get() || !print_job_->is_job_pending()) if (!print_job_.get() || !print_job_->is_job_pending())
return false; return false;
// We can't print if there is no renderer.
if (!web_contents() || !web_contents()->GetRenderViewHost() ||
!web_contents()->GetRenderViewHost()->IsRenderViewLive()) {
return false;
}
// Is the document already complete? // Is the document already complete?
if (print_job_->document() && print_job_->document()->IsComplete()) { if (print_job_->document() && print_job_->document()->IsComplete()) {
printing_succeeded_ = true; printing_succeeded_ = true;
return true; return true;
} }
// We can't print if there is no renderer.
if (!web_contents() || !web_contents()->GetRenderViewHost() ||
!web_contents()->GetRenderViewHost()->IsRenderViewLive()) {
return false;
}
// WebContents is either dying or a second consecutive request to print // WebContents is either dying or a second consecutive request to print
// happened before the first had time to finish. We need to render all the // happened before the first had time to finish. We need to render all the
// pages in an hurry if a print_job_ is still pending. No need to wait for it // pages in an hurry if a print_job_ is still pending. No need to wait for it
@@ -401,14 +432,12 @@ bool CefPrintViewManagerBase::CreateNewPrintJob(PrintJobWorkerOwner* job) {
return false; return false;
} }
// Ask the renderer to generate the print preview, create the print preview
// view and switch to it, initialize the printer and show the print dialog.
DCHECK(!print_job_.get()); DCHECK(!print_job_.get());
DCHECK(job); DCHECK(job);
if (!job) if (!job)
return false; return false;
print_job_ = new PrintJob(); print_job_ = base::MakeRefCounted<PrintJob>();
print_job_->Initialize(job, RenderSourceName(), number_pages_); print_job_->Initialize(job, RenderSourceName(), number_pages_);
registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(print_job_.get())); content::Source<PrintJob>(print_job_.get()));
@@ -461,7 +490,7 @@ void CefPrintViewManagerBase::ReleasePrintJob() {
return; return;
if (rfh) { if (rfh) {
auto msg = base::MakeUnique<PrintMsg_PrintingDone>(rfh->GetRoutingID(), auto msg = std::make_unique<PrintMsg_PrintingDone>(rfh->GetRoutingID(),
printing_succeeded_); printing_succeeded_);
rfh->Send(msg.release()); rfh->Send(msg.release());
} }

View File

@@ -8,7 +8,7 @@
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "build/build_config.h" #include "build/build_config.h"
@@ -18,12 +18,12 @@
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "mojo/public/cpp/system/platform_handle.h" #include "mojo/public/cpp/system/platform_handle.h"
#include "printing/features/features.h" #include "printing/buildflags/buildflags.h"
struct PrintHostMsg_DidPrintDocument_Params; struct PrintHostMsg_DidPrintDocument_Params;
namespace base { namespace base {
class RefCountedBytes; class RefCountedMemory;
} }
namespace content { namespace content {
@@ -74,6 +74,15 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
// Cancels the print job. // Cancels the print job.
void NavigationStopped() override; void NavigationStopped() override;
// Creates a new empty print job. It has no settings loaded. If there is
// currently a print job, safely disconnect from it. Returns false if it is
// impossible to safely disconnect from the current print job or it is
// impossible to create a new print job.
virtual bool CreateNewPrintJob(PrintJobWorkerOwner* job);
// Manages the low-level talk to the printer.
scoped_refptr<PrintJob> print_job_;
private: private:
// content::NotificationObserver implementation. // content::NotificationObserver implementation.
void Observe(int type, void Observe(int type,
@@ -87,7 +96,8 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
void OnDidGetPrintedPagesCount(int cookie, int number_pages) override; void OnDidGetPrintedPagesCount(int cookie, int number_pages) override;
void OnPrintingFailed(int cookie) override; void OnPrintingFailed(int cookie) override;
void OnShowInvalidPrinterSettingsError(); void OnShowInvalidPrinterSettingsError();
void OnDidPrintDocument(const PrintHostMsg_DidPrintDocument_Params& params); void OnDidPrintDocument(content::RenderFrameHost* render_frame_host,
const PrintHostMsg_DidPrintDocument_Params& params);
// IPC message handlers for service. // IPC message handlers for service.
void OnComposePdfDone(const PrintHostMsg_DidPrintDocument_Params& params, void OnComposePdfDone(const PrintHostMsg_DidPrintDocument_Params& params,
@@ -109,7 +119,7 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
// Starts printing |document| with the given |print_data|. This method assumes // Starts printing |document| with the given |print_data|. This method assumes
// |print_data| contains valid data. // |print_data| contains valid data.
void PrintDocument(PrintedDocument* document, void PrintDocument(PrintedDocument* document,
const scoped_refptr<base::RefCountedBytes>& print_data, const scoped_refptr<base::RefCountedMemory>& print_data,
const gfx::Size& page_size, const gfx::Size& page_size,
const gfx::Rect& content_area, const gfx::Rect& content_area,
const gfx::Point& offsets); const gfx::Point& offsets);
@@ -121,12 +131,6 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
// RenderAllMissingPagesNow(). // RenderAllMissingPagesNow().
void ShouldQuitFromInnerMessageLoop(); void ShouldQuitFromInnerMessageLoop();
// Creates a new empty print job. It has no settings loaded. If there is
// currently a print job, safely disconnect from it. Returns false if it is
// impossible to safely disconnect from the current print job or it is
// impossible to create a new print job.
bool CreateNewPrintJob(PrintJobWorkerOwner* job);
// Makes sure the current print_job_ has all its data before continuing, and // Makes sure the current print_job_ has all its data before continuing, and
// disconnect from it. // disconnect from it.
void DisconnectFromCurrentPrintJob(); void DisconnectFromCurrentPrintJob();
@@ -162,9 +166,6 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
// The current RFH that is printing with a system printing dialog. // The current RFH that is printing with a system printing dialog.
content::RenderFrameHost* printing_rfh_; content::RenderFrameHost* printing_rfh_;
// Manages the low-level talk to the printer.
scoped_refptr<PrintJob> print_job_;
// Indication of success of the print job. // Indication of success of the print job.
bool printing_succeeded_; bool printing_succeeded_;

View File

@@ -23,7 +23,6 @@
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/child_process_host.h" #include "content/public/common/child_process_host.h"
#include "printing/features/features.h"
#if defined(OS_LINUX) #if defined(OS_LINUX)
#include "libcef/browser/printing/print_dialog_linux.h" #include "libcef/browser/printing/print_dialog_linux.h"
@@ -215,7 +214,7 @@ void CefPrintingMessageFilter::OnScriptedPrintReply(
} }
PrintHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params); PrintHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params);
Send(reply_msg); Send(reply_msg);
if (params.params.dpi && params.params.document_cookie) { if (!params.params.dpi.IsEmpty() && params.params.document_cookie) {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
int file_descriptor; int file_descriptor;
const base::string16& device_name = printer_query->settings().device_name(); const base::string16& device_name = printer_query->settings().device_name();

View File

@@ -15,7 +15,7 @@
#include "components/keyed_service/core/keyed_service_shutdown_notifier.h" #include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
#include "components/prefs/pref_member.h" #include "components/prefs/pref_member.h"
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#include "printing/features/features.h" #include "printing/buildflags/buildflags.h"
struct PrintHostMsg_ScriptedPrint_Params; struct PrintHostMsg_ScriptedPrint_Params;
class Profile; class Profile;

View File

@@ -7,7 +7,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/process/launch.h" #include "base/process/launch.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_launcher_utils.h"
bool CefLaunchProcess(CefRefPtr<CefCommandLine> command_line) { bool CefLaunchProcess(CefRefPtr<CefCommandLine> command_line) {
if (!command_line.get()) { if (!command_line.get()) {
@@ -15,8 +15,7 @@ bool CefLaunchProcess(CefRefPtr<CefCommandLine> command_line) {
return false; return false;
} }
if (!content::BrowserThread::CurrentlyOn( if (!content::CurrentlyOnProcessLauncherTaskRunner()) {
content::BrowserThread::PROCESS_LAUNCHER)) {
NOTREACHED() << "called on invalid thread"; NOTREACHED() << "called on invalid thread";
return false; return false;
} }

View File

@@ -293,7 +293,8 @@ CefString CefRequestContextImpl::GetCachePath() {
CefRefPtr<CefCookieManager> CefRequestContextImpl::GetDefaultCookieManager( CefRefPtr<CefCookieManager> CefRequestContextImpl::GetDefaultCookieManager(
CefRefPtr<CefCompletionCallback> callback) { CefRefPtr<CefCompletionCallback> callback) {
CefRefPtr<CefCookieManagerImpl> cookie_manager = new CefCookieManagerImpl(); CefRefPtr<CefCookieManagerImpl> cookie_manager =
new CefCookieManagerImpl(false);
cookie_manager->Initialize(this, CefString(), false, callback); cookie_manager->Initialize(this, CefString(), false, callback);
return cookie_manager.get(); return cookie_manager.get();
} }

View File

@@ -30,70 +30,14 @@
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
namespace {
void SendExecuteMimeTypeHandlerEvent(
std::unique_ptr<content::StreamInfo> stream,
int64_t expected_content_size,
const std::string& extension_id,
const std::string& view_id,
bool embedded,
int frame_tree_node_id,
int render_process_id,
int render_frame_id) {
CEF_REQUIRE_UIT();
content::WebContents* web_contents = nullptr;
if (frame_tree_node_id != -1) {
web_contents =
content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);
} else {
web_contents = content::WebContents::FromRenderFrameHost(
content::RenderFrameHost::FromID(render_process_id, render_frame_id));
}
if (!web_contents)
return;
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForContents(web_contents);
if (!browser.get())
return;
content::BrowserContext* browser_context = web_contents->GetBrowserContext();
extensions::StreamsPrivateAPI* streams_private =
extensions::StreamsPrivateAPI::Get(browser_context);
if (!streams_private)
return;
streams_private->ExecuteMimeTypeHandler(
extension_id, std::move(stream), view_id, expected_content_size, embedded,
frame_tree_node_id, render_process_id, render_frame_id);
}
} // namespace
CefResourceDispatcherHostDelegate::CefResourceDispatcherHostDelegate() {} CefResourceDispatcherHostDelegate::CefResourceDispatcherHostDelegate() {}
CefResourceDispatcherHostDelegate::~CefResourceDispatcherHostDelegate() {} CefResourceDispatcherHostDelegate::~CefResourceDispatcherHostDelegate() {}
bool CefResourceDispatcherHostDelegate::HandleExternalProtocol(
const GURL& url,
content::ResourceRequestInfo* info) {
CEF_POST_TASK(
CEF_UIT,
base::Bind(base::IgnoreResult(&CefResourceDispatcherHostDelegate::
HandleExternalProtocolOnUIThread),
base::Unretained(this), url,
info->GetWebContentsGetterForRequest()));
return false;
}
// Implementation based on // Implementation based on
// ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream. // ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream.
bool CefResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( bool CefResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
net::URLRequest* request, net::URLRequest* request,
const base::FilePath& plugin_path,
const std::string& mime_type, const std::string& mime_type,
GURL* origin, GURL* origin,
std::string* payload) { std::string* payload) {
@@ -125,29 +69,14 @@ bool CefResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
if (!handler) if (!handler)
continue; continue;
// If a plugin path is provided then a stream is being intercepted for the if (handler->CanHandleMIMEType(mime_type)) {
// mimeHandlerPrivate API. Otherwise a stream is being intercepted for the StreamTargetInfo target_info;
// streamsPrivate API. *origin = extensions::Extension::GetBaseURLFromExtensionId(extension_id);
if (!plugin_path.empty()) { target_info.extension_id = extension_id;
if (handler->HasPlugin() && plugin_path == handler->GetPluginPath()) { target_info.view_id = base::GenerateGUID();
StreamTargetInfo target_info; *payload = target_info.view_id;
*origin = stream_target_info_[request] = target_info;
extensions::Extension::GetBaseURLFromExtensionId(extension_id); return true;
target_info.extension_id = extension_id;
target_info.view_id = base::GenerateGUID();
*payload = target_info.view_id;
stream_target_info_[request] = target_info;
return true;
}
} else {
if (!handler->HasPlugin() && handler->CanHandleMIMEType(mime_type)) {
StreamTargetInfo target_info;
*origin =
extensions::Extension::GetBaseURLFromExtensionId(extension_id);
target_info.extension_id = extension_id;
stream_target_info_[request] = target_info;
return true;
}
} }
} }
@@ -166,12 +95,14 @@ void CefResourceDispatcherHostDelegate::OnStreamCreated(
stream_target_info_.find(request); stream_target_info_.find(request);
CHECK(ix != stream_target_info_.end()); CHECK(ix != stream_target_info_.end());
bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME; bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME;
CEF_POST_TASK( content::BrowserThread::PostTask(
CEF_UIT, content::BrowserThread::UI, FROM_HERE,
base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream), base::BindOnce(
request->GetExpectedContentSize(), ix->second.extension_id, &extensions::StreamsPrivateAPI::SendExecuteMimeTypeHandlerEvent,
ix->second.view_id, embedded, info->GetFrameTreeNodeId(), request->GetExpectedContentSize(), ix->second.extension_id,
info->GetChildID(), info->GetRenderFrameID())); ix->second.view_id, embedded, info->GetFrameTreeNodeId(),
info->GetChildID(), info->GetRenderFrameID(), std::move(stream),
nullptr /* transferrable_loader */, GURL()));
stream_target_info_.erase(request); stream_target_info_.erase(request);
} }
@@ -194,24 +125,3 @@ void CefResourceDispatcherHostDelegate::OnRequestRedirected(
response->head.headers->AddHeader("Access-Control-Allow-Credentials: true"); response->head.headers->AddHeader("Access-Control-Allow-Credentials: true");
} }
} }
std::unique_ptr<net::ClientCertStore>
CefResourceDispatcherHostDelegate::CreateClientCertStore(
content::ResourceContext* resource_context) {
return static_cast<CefResourceContext*>(resource_context)
->CreateClientCertStore();
}
void CefResourceDispatcherHostDelegate::HandleExternalProtocolOnUIThread(
const GURL& url,
const content::ResourceRequestInfo::WebContentsGetter&
web_contents_getter) {
CEF_REQUIRE_UIT();
content::WebContents* web_contents = web_contents_getter.Run();
if (web_contents) {
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForContents(web_contents);
if (browser.get())
browser->HandleExternalProtocol(url);
}
}

View File

@@ -21,10 +21,7 @@ class CefResourceDispatcherHostDelegate
~CefResourceDispatcherHostDelegate() override; ~CefResourceDispatcherHostDelegate() override;
// ResourceDispatcherHostDelegate methods. // ResourceDispatcherHostDelegate methods.
bool HandleExternalProtocol(const GURL& url,
content::ResourceRequestInfo* info) override;
bool ShouldInterceptResourceAsStream(net::URLRequest* request, bool ShouldInterceptResourceAsStream(net::URLRequest* request,
const base::FilePath& plugin_path,
const std::string& mime_type, const std::string& mime_type,
GURL* origin, GURL* origin,
std::string* payload) override; std::string* payload) override;
@@ -34,8 +31,6 @@ class CefResourceDispatcherHostDelegate
net::URLRequest* request, net::URLRequest* request,
content::ResourceContext* resource_context, content::ResourceContext* resource_context,
network::ResourceResponse* response) override; network::ResourceResponse* response) override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
content::ResourceContext* resource_context) override;
private: private:
void HandleExternalProtocolOnUIThread( void HandleExternalProtocolOnUIThread(

View File

@@ -12,7 +12,6 @@
#include "base/format_macros.h" #include "base/format_macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
@@ -20,6 +19,7 @@
#include "net/server/http_server_response_info.h" #include "net/server/http_server_response_info.h"
#include "net/socket/server_socket.h" #include "net/socket/server_socket.h"
#include "net/socket/tcp_server_socket.h" #include "net/socket/tcp_server_socket.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#define CEF_CURRENTLY_ON_HT() CurrentlyOnHandlerThread() #define CEF_CURRENTLY_ON_HT() CurrentlyOnHandlerThread()
#define CEF_REQUIRE_HT() DCHECK(CEF_CURRENTLY_ON_HT()) #define CEF_REQUIRE_HT() DCHECK(CEF_CURRENTLY_ON_HT())
@@ -237,7 +237,7 @@ void CefServerImpl::SendHttp404Response(int connection_id) {
return; return;
} }
server_->Send404(connection_id); server_->Send404(connection_id, NO_TRAFFIC_ANNOTATION_YET);
server_->Close(connection_id); server_->Close(connection_id);
} }
@@ -262,7 +262,7 @@ void CefServerImpl::SendHttp500Response(int connection_id,
return; return;
} }
server_->Send500(connection_id, error_message); server_->Send500(connection_id, error_message, NO_TRAFFIC_ANNOTATION_YET);
server_->Close(connection_id); server_->Close(connection_id);
} }
@@ -305,7 +305,7 @@ void CefServerImpl::SendHttpResponse(int connection_id,
base::StringPrintf("%" PRIuS, static_cast<size_t>(content_length))); base::StringPrintf("%" PRIuS, static_cast<size_t>(content_length)));
} }
server_->SendResponse(connection_id, response); server_->SendResponse(connection_id, response, NO_TRAFFIC_ANNOTATION_YET);
if (content_length == 0) { if (content_length == 0) {
server_->Close(connection_id); server_->Close(connection_id);
} }
@@ -366,7 +366,8 @@ void CefServerImpl::ContinueWebSocketRequest(
info->is_websocket_pending = false; info->is_websocket_pending = false;
if (allow) { if (allow) {
server_->AcceptWebSocket(connection_id, request_info); server_->AcceptWebSocket(connection_id, request_info,
NO_TRAFFIC_ANNOTATION_YET);
handler_->OnWebSocketConnected(this, connection_id); handler_->OnWebSocketConnected(this, connection_id);
} else { } else {
server_->Close(connection_id); server_->Close(connection_id);
@@ -397,7 +398,8 @@ void CefServerImpl::SendHttp200ResponseInternal(
return; return;
} }
server_->Send200(connection_id, *data, content_type); server_->Send200(connection_id, *data, content_type,
NO_TRAFFIC_ANNOTATION_YET);
server_->Close(connection_id); server_->Close(connection_id);
} }
@@ -416,7 +418,7 @@ void CefServerImpl::SendRawDataInternal(int connection_id,
if (!GetConnectionInfo(connection_id)) if (!GetConnectionInfo(connection_id))
return; return;
server_->SendRaw(connection_id, *data); server_->SendRaw(connection_id, *data, NO_TRAFFIC_ANNOTATION_YET);
} }
void CefServerImpl::SendWebSocketMessageInternal( void CefServerImpl::SendWebSocketMessageInternal(
@@ -442,7 +444,7 @@ void CefServerImpl::SendWebSocketMessageInternal(
return; return;
} }
server_->SendOverWebSocket(connection_id, *data); server_->SendOverWebSocket(connection_id, *data, NO_TRAFFIC_ANNOTATION_YET);
} }
void CefServerImpl::OnConnect(int connection_id) { void CefServerImpl::OnConnect(int connection_id) {
@@ -595,8 +597,7 @@ void CefServerImpl::ShutdownOnUIThread() {
if (thread_) { if (thread_) {
// Stop the handler thread as a background task so the UI thread isn't // Stop the handler thread as a background task so the UI thread isn't
// blocked. // blocked.
base::PostTaskWithTraits( CEF_POST_BACKGROUND_TASK(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
BindOnce([](std::unique_ptr<base::Thread>) {}, std::move(thread_))); BindOnce([](std::unique_ptr<base::Thread>) {}, std::move(thread_)));
// Release the reference that was added in StartupOnUIThread(). // Release the reference that was added in StartupOnUIThread().

View File

@@ -28,101 +28,6 @@ using content::BrowserThread;
using content::SpeechRecognitionManager; using content::SpeechRecognitionManager;
using content::WebContents; using content::WebContents;
// Simple utility to get notified when a WebContents is closed or crashes.
// Both the callback site and the callback thread are passed by the caller in
// the constructor. There is no restriction on the constructor, however this
// class must be destroyed on the UI thread, due to the NotificationRegistrar
// dependency.
class CefSpeechRecognitionManagerDelegate::WebContentsWatcher
: public base::RefCountedThreadSafe<WebContentsWatcher>,
public content::NotificationObserver {
public:
typedef base::Callback<void(int render_process_id, int render_view_id)>
WebContentsClosedCallback;
WebContentsWatcher(WebContentsClosedCallback web_contents_closed_callback,
BrowserThread::ID callback_thread)
: web_contents_closed_callback_(web_contents_closed_callback),
callback_thread_(callback_thread) {}
// Starts monitoring the WebContents corresponding to the given
// |render_process_id|, |render_view_id| pair, invoking
// |web_contents_closed_callback_| if closed/unloaded.
void Watch(int render_process_id, int render_view_id) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&WebContentsWatcher::Watch, this,
render_process_id, render_view_id));
return;
}
WebContents* web_contents = NULL;
content::RenderViewHost* render_view_host =
content::RenderViewHost::FromID(render_process_id, render_view_id);
if (render_view_host)
web_contents = WebContents::FromRenderViewHost(render_view_host);
DCHECK(web_contents);
// Avoid multiple registrations on |registrar_| for the same |web_contents|.
if (registered_web_contents_.find(web_contents) !=
registered_web_contents_.end()) {
return;
}
registered_web_contents_.insert(web_contents);
// Lazy initialize the registrar.
if (!registrar_.get())
registrar_.reset(new content::NotificationRegistrar());
registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
content::Source<WebContents>(web_contents));
}
// content::NotificationObserver implementation.
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, type);
WebContents* web_contents = content::Source<WebContents>(source).ptr();
int render_process_id =
web_contents->GetRenderViewHost()->GetProcess()->GetID();
int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
registrar_->Remove(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
content::Source<WebContents>(web_contents));
registered_web_contents_.erase(web_contents);
BrowserThread::PostTask(callback_thread_, FROM_HERE,
base::Bind(web_contents_closed_callback_,
render_process_id, render_view_id));
}
private:
friend class base::RefCountedThreadSafe<WebContentsWatcher>;
~WebContentsWatcher() override {
// Must be destroyed on the UI thread due to |registrar_| non thread-safety.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
// Lazy-initialized and used on the UI thread to handle web contents
// notifications (tab closing).
std::unique_ptr<content::NotificationRegistrar> registrar_;
// Keeps track of which WebContent(s) have been registered, in order to avoid
// double registrations on |registrar_|
std::set<content::WebContents*> registered_web_contents_;
// Callback used to notify, on the thread specified by |callback_thread_| the
// closure of a registered tab.
WebContentsClosedCallback web_contents_closed_callback_;
content::BrowserThread::ID callback_thread_;
DISALLOW_COPY_AND_ASSIGN(WebContentsWatcher);
};
CefSpeechRecognitionManagerDelegate ::CefSpeechRecognitionManagerDelegate() { CefSpeechRecognitionManagerDelegate ::CefSpeechRecognitionManagerDelegate() {
const base::CommandLine* command_line = const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess(); base::CommandLine::ForCurrentProcess();
@@ -132,37 +37,7 @@ CefSpeechRecognitionManagerDelegate ::CefSpeechRecognitionManagerDelegate() {
CefSpeechRecognitionManagerDelegate ::~CefSpeechRecognitionManagerDelegate() {} CefSpeechRecognitionManagerDelegate ::~CefSpeechRecognitionManagerDelegate() {}
void CefSpeechRecognitionManagerDelegate::WebContentsClosedCallback( void CefSpeechRecognitionManagerDelegate::OnRecognitionStart(int session_id) {}
int render_process_id,
int render_view_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
SpeechRecognitionManager* manager = SpeechRecognitionManager::GetInstance();
// |manager| becomes NULL if a browser shutdown happens between the post of
// this task (from the UI thread) and this call (on the IO thread). In this
// case we just return.
if (!manager)
return;
manager->AbortAllSessionsForRenderView(render_process_id, render_view_id);
}
void CefSpeechRecognitionManagerDelegate::OnRecognitionStart(int session_id) {
const content::SpeechRecognitionSessionContext& context =
SpeechRecognitionManager::GetInstance()->GetSessionContext(session_id);
// Register callback to auto abort session on tab closure.
// |web_contents_watcher_| is lazyly istantiated on the first call.
if (!web_contents_watcher_.get()) {
web_contents_watcher_ = new WebContentsWatcher(
base::Bind(
&CefSpeechRecognitionManagerDelegate::WebContentsClosedCallback,
base::Unretained(this)),
BrowserThread::IO);
}
web_contents_watcher_->Watch(context.render_process_id,
context.render_view_id);
}
void CefSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) {} void CefSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) {}

View File

@@ -48,13 +48,6 @@ class CefSpeechRecognitionManagerDelegate
bool FilterProfanities(int render_process_id) override; bool FilterProfanities(int render_process_id) override;
private: private:
class WebContentsWatcher;
// Callback called by |web_contents_watcher_| on the IO thread to signal
// web contents closure.
void WebContentsClosedCallback(int render_process_id, int render_view_id);
scoped_refptr<WebContentsWatcher> web_contents_watcher_;
bool filter_profanities_; bool filter_profanities_;
DISALLOW_COPY_AND_ASSIGN(CefSpeechRecognitionManagerDelegate); DISALLOW_COPY_AND_ASSIGN(CefSpeechRecognitionManagerDelegate);

View File

@@ -30,11 +30,16 @@ network::mojom::NetworkContext* CefStoragePartitionProxy::GetNetworkContext() {
return parent_->GetNetworkContext(); return parent_->GetNetworkContext();
} }
network::mojom::URLLoaderFactory* scoped_refptr<network::SharedURLLoaderFactory>
CefStoragePartitionProxy::GetURLLoaderFactoryForBrowserProcess() { CefStoragePartitionProxy::GetURLLoaderFactoryForBrowserProcess() {
return parent_->GetURLLoaderFactoryForBrowserProcess(); return parent_->GetURLLoaderFactoryForBrowserProcess();
} }
std::unique_ptr<network::SharedURLLoaderFactoryInfo>
CefStoragePartitionProxy::GetURLLoaderFactoryForBrowserProcessIOThread() {
return parent_->GetURLLoaderFactoryForBrowserProcessIOThread();
}
network::mojom::CookieManager* network::mojom::CookieManager*
CefStoragePartitionProxy::GetCookieManagerForBrowserProcess() { CefStoragePartitionProxy::GetCookieManagerForBrowserProcess() {
return parent_->GetCookieManagerForBrowserProcess(); return parent_->GetCookieManagerForBrowserProcess();
@@ -101,6 +106,10 @@ CefStoragePartitionProxy::GetPlatformNotificationContext() {
return parent_->GetPlatformNotificationContext(); return parent_->GetPlatformNotificationContext();
} }
content::WebPackageContext* CefStoragePartitionProxy::GetWebPackageContext() {
return parent_->GetWebPackageContext();
}
void CefStoragePartitionProxy::ClearDataForOrigin( void CefStoragePartitionProxy::ClearDataForOrigin(
uint32_t remove_mask, uint32_t remove_mask,
uint32_t quota_storage_remove_mask, uint32_t quota_storage_remove_mask,
@@ -154,6 +163,10 @@ void CefStoragePartitionProxy::FlushNetworkInterfaceForTesting() {
parent_->FlushNetworkInterfaceForTesting(); parent_->FlushNetworkInterfaceForTesting();
} }
void CefStoragePartitionProxy::WaitForDeletionTasksForTesting() {
parent_->WaitForDeletionTasksForTesting();
}
content::BackgroundFetchContext* content::BackgroundFetchContext*
CefStoragePartitionProxy::GetBackgroundFetchContext() { CefStoragePartitionProxy::GetBackgroundFetchContext() {
return parent_->GetBackgroundFetchContext(); return parent_->GetBackgroundFetchContext();
@@ -188,6 +201,11 @@ content::BlobRegistryWrapper* CefStoragePartitionProxy::GetBlobRegistry() {
return parent_->GetBlobRegistry(); return parent_->GetBlobRegistry();
} }
content::PrefetchURLLoaderService*
CefStoragePartitionProxy::GetPrefetchURLLoaderService() {
return parent_->GetPrefetchURLLoaderService();
}
content::URLLoaderFactoryGetter* content::URLLoaderFactoryGetter*
CefStoragePartitionProxy::url_loader_factory_getter() { CefStoragePartitionProxy::url_loader_factory_getter() {
return parent_->url_loader_factory_getter(); return parent_->url_loader_factory_getter();

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