mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Compare commits
52 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d3e36d052c | ||
|
a27bbfaa0e | ||
|
45d779dc24 | ||
|
185623100e | ||
|
c368dbf5ad | ||
|
238e9184b4 | ||
|
514ced40ce | ||
|
36f9eab712 | ||
|
628b9db317 | ||
|
636f29b188 | ||
|
7b00e05714 | ||
|
5340bb0700 | ||
|
a4b18ef01c | ||
|
c3a31f5f3e | ||
|
71574ceb11 | ||
|
e21d57d8b3 | ||
|
64c0c9fc4c | ||
|
5bf920a639 | ||
|
141869aa17 | ||
|
a3c55f1d26 | ||
|
f6c9a96a12 | ||
|
4b33c17533 | ||
|
0677d0d9de | ||
|
64d86a7397 | ||
|
87e33b1692 | ||
|
4315f3b724 | ||
|
bb28b85bdd | ||
|
90863b8c5d | ||
|
c3f5e6463c | ||
|
b220672c42 | ||
|
acb0922500 | ||
|
b44919e3c5 | ||
|
a1f47abaf6 | ||
|
ff8aa46e5e | ||
|
d4ec164297 | ||
|
e312a35ef3 | ||
|
3018e1866b | ||
|
7a59914f97 | ||
|
4fb6e1ba29 | ||
|
e030236c36 | ||
|
a98c6b1f52 | ||
|
5b136976e9 | ||
|
56bbee8efb | ||
|
cd6ff760dd | ||
|
5caccda56c | ||
|
3b499d3d11 | ||
|
cca0bcc8e0 | ||
|
39ccd85d77 | ||
|
0ac37cefa1 | ||
|
36668efc2f | ||
|
a5a5e7ff08 | ||
|
57b9cf9ddd |
68
BUILD.gn
68
BUILD.gn
@@ -100,11 +100,11 @@ import("//build/config/sanitizers/sanitizers.gni")
|
||||
import("//build/config/ui.gni")
|
||||
import("//cef/cef_repack_locales.gni")
|
||||
import("//chrome/common/features.gni")
|
||||
import("//extensions/features/features.gni")
|
||||
import("//extensions/buildflags/buildflags.gni")
|
||||
import("//media/media_options.gni")
|
||||
import("//mojo/public/tools/bindings/mojom.gni")
|
||||
import("//ppapi/features/features.gni")
|
||||
import("//printing/features/features.gni")
|
||||
import("//ppapi/buildflags/buildflags.gni")
|
||||
import("//printing/buildflags/buildflags.gni")
|
||||
import("//services/catalog/public/tools/catalog.gni")
|
||||
import("//services/service_manager/public/service_manifest.gni")
|
||||
import("//third_party/icu/config.gni")
|
||||
@@ -118,12 +118,13 @@ if (is_clang) {
|
||||
}
|
||||
if (is_linux) {
|
||||
import("//build/config/linux/pkg_config.gni")
|
||||
import("//third_party/fontconfig/fontconfig.gni")
|
||||
}
|
||||
if (is_mac) {
|
||||
import("//build/config/mac/rules.gni")
|
||||
import("//build/mac/tweak_info_plist.gni")
|
||||
import("//build/util/version.gni")
|
||||
import("//media/cdm/ppapi/cdm_paths.gni")
|
||||
import("//media/cdm/library_cdm/cdm_paths.gni")
|
||||
}
|
||||
if (is_win) {
|
||||
import("//build/config/win/console_app.gni")
|
||||
@@ -148,6 +149,12 @@ if (is_clang) {
|
||||
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) {
|
||||
# Always generate dSYM files. The make_distrib script will fail if
|
||||
# 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
|
||||
|
||||
# Required by chrome_switches.cc
|
||||
"//chrome/common:features",
|
||||
"//ppapi/features:features",
|
||||
"//printing/features:features",
|
||||
"//chrome/common:buildflags",
|
||||
"//ppapi/buildflags:buildflags",
|
||||
"//printing/buildflags:buildflags",
|
||||
"//ui/base:ui_features",
|
||||
]
|
||||
}
|
||||
@@ -691,10 +698,9 @@ static_library("libcef_static") {
|
||||
"//device/base",
|
||||
"//extensions/browser",
|
||||
"//extensions/browser/api:api_registration",
|
||||
"//extensions/buildflags",
|
||||
"//extensions/common/api",
|
||||
"//extensions/features",
|
||||
"//extensions/renderer",
|
||||
"//extensions/utility",
|
||||
"//gpu",
|
||||
"//ipc",
|
||||
"//media",
|
||||
@@ -704,23 +710,23 @@ static_library("libcef_static") {
|
||||
"//net:net_utility_services",
|
||||
"//net:net_with_v8",
|
||||
"//pdf",
|
||||
"//ppapi/features",
|
||||
"//printing/features",
|
||||
"//ppapi/buildflags",
|
||||
"//printing/buildflags",
|
||||
"//services/network:network_service",
|
||||
"//services/network/public/cpp",
|
||||
"//services/service_manager/embedder",
|
||||
"//services/service_manager/public/interfaces",
|
||||
"//services/service_manager/public/cpp",
|
||||
"//services/service_manager/runner/common",
|
||||
"//skia",
|
||||
"//storage/browser",
|
||||
"//third_party/blink/public:blink",
|
||||
"//third_party/brotli:dec",
|
||||
"//third_party/cld_3/src/src:cld_3",
|
||||
"//third_party/hunspell",
|
||||
"//third_party/leveldatabase",
|
||||
"//third_party/libxml",
|
||||
"//third_party/WebKit/public:blink",
|
||||
"//third_party/widevine/cdm:headers",
|
||||
"//third_party/widevine/cdm:widevinecdmadapter",
|
||||
"//third_party/widevine/cdm",
|
||||
"//third_party/icu",
|
||||
"//third_party/zlib:minizip",
|
||||
"//ui/base",
|
||||
@@ -1023,6 +1029,7 @@ if (is_win) {
|
||||
|
||||
cef_packaged_services = [
|
||||
"//chrome/app:chrome_manifest", # For spell checking.
|
||||
"//chrome/app:chrome_renderer_manifest", # For spell checking.
|
||||
"//chrome/services/printing:manifest",
|
||||
"//services/metrics: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.
|
||||
# Add associated .h files in the make_pack_header("resources") target.
|
||||
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/components/components_resources_${percent}_percent.pak",
|
||||
"$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak",
|
||||
"$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak",
|
||||
"$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_${percent}_percent.pak",
|
||||
"$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
|
||||
]
|
||||
|
||||
@@ -1079,18 +1086,18 @@ template("cef_pak_scaled") {
|
||||
# the libcef_static target. Grit deps that generate .cc files must be
|
||||
# listed both here and in the libcef_static target.
|
||||
public_deps = [
|
||||
"//third_party/WebKit/public:scaled_resources",
|
||||
"//chrome/renderer:resources",
|
||||
"//components/resources:components_scaled_resources",
|
||||
"//content/app/resources",
|
||||
"//extensions:extensions_browser_resources",
|
||||
"//third_party/blink/public:scaled_resources",
|
||||
"//ui/resources:ui_resources_grd",
|
||||
]
|
||||
|
||||
deps = [
|
||||
# This repack target generates the blink_scaled_resources_*_percent.pak
|
||||
# file but doesn't expose the public_deps required by make_pack_header.
|
||||
"//third_party/WebKit/public:scaled_resources_${percent}_percent",
|
||||
"//third_party/blink/public:scaled_resources_${percent}_percent",
|
||||
]
|
||||
|
||||
if (toolkit_views) {
|
||||
@@ -1207,7 +1214,6 @@ repack("pak") {
|
||||
# Each input pak file should also have a deps line for completeness.
|
||||
# Add associated .h files in the make_pack_header("resources") target.
|
||||
sources = [
|
||||
"$root_gen_dir/blink/public/resources/blink_resources.pak",
|
||||
"$root_gen_dir/chrome/browser_resources.pak",
|
||||
"$root_gen_dir/chrome/net_internals_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/content_resources.pak",
|
||||
"$root_gen_dir/net/net_resources.pak",
|
||||
"$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
|
||||
]
|
||||
|
||||
# Use public_deps so that generated grit headers are discoverable from
|
||||
# the libcef_static target. Grit deps that generate .cc files must be
|
||||
# listed both here and in the libcef_static target.
|
||||
public_deps = [
|
||||
"//third_party/WebKit/public:resources_grit",
|
||||
"//chrome/browser:resources",
|
||||
"//chrome/browser/resources:net_internals_resources",
|
||||
"//chrome/common:resources",
|
||||
@@ -1231,6 +1237,7 @@ repack("pak") {
|
||||
"//content/browser/tracing:resources",
|
||||
"//content:resources",
|
||||
"//net:net_resources",
|
||||
"//third_party/blink/public:resources",
|
||||
]
|
||||
|
||||
output = "$root_out_dir/cef.pak"
|
||||
@@ -1267,9 +1274,6 @@ template("make_pack_header") {
|
||||
make_pack_header("resources") {
|
||||
header = "$root_out_dir/includes/include/cef_pack_resources.h"
|
||||
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/chrome/grit/browser_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_resources.h",
|
||||
"$root_gen_dir/net/grit/net_resources.h",
|
||||
"$root_gen_dir/third_party/blink/public/resources/grit/blink_resources.h",
|
||||
"$root_gen_dir/ui/resources/grit/ui_resources.h",
|
||||
"$root_gen_dir/ui/resources/grit/webui_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_extensions.pak",
|
||||
"$root_out_dir/devtools_resources.pak",
|
||||
"$root_out_dir/$widevine_cdm_path/widevinecdmadapter.plugin",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
@@ -1358,7 +1362,6 @@ if (is_mac) {
|
||||
":pak_200_percent",
|
||||
":pak_devtools",
|
||||
":pak_extensions",
|
||||
"//third_party/widevine/cdm:widevinecdmadapter",
|
||||
]
|
||||
|
||||
if (icu_use_data_file) {
|
||||
@@ -1386,6 +1389,11 @@ if (is_mac) {
|
||||
mac_framework_bundle("cef_framework") {
|
||||
output_name = cef_framework_name
|
||||
|
||||
framework_version = "A"
|
||||
framework_contents = [
|
||||
"Resources",
|
||||
]
|
||||
|
||||
sources = gypi_paths2.includes_common +
|
||||
gypi_paths2.includes_mac +
|
||||
gypi_paths.autogen_cpp_includes +
|
||||
@@ -1421,11 +1429,11 @@ if (is_mac) {
|
||||
if (is_component_build) {
|
||||
# Set up the rpath for the framework so that it can find dylibs in the
|
||||
# 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.
|
||||
ldflags += [
|
||||
"-rpath",
|
||||
"@loader_path/../../../..",
|
||||
"@loader_path/../../../../../..",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1442,6 +1450,7 @@ if (is_mac) {
|
||||
|
||||
deps = [
|
||||
":libcef_static",
|
||||
"//build/config:exe_and_shlib_deps",
|
||||
]
|
||||
|
||||
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.
|
||||
# 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=" +
|
||||
rebase_path("//cef/libcef_dll/libcef.lst") ]
|
||||
}
|
||||
|
@@ -7,5 +7,5 @@
|
||||
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
||||
|
||||
{
|
||||
'chromium_checkout': 'bc084a8b5afa3744a74927344e304c02ae54189f',
|
||||
'chromium_checkout': 'refs/tags/67.0.3396.79',
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
# by hand. See the translator.README.txt file in the tools directory for
|
||||
# more information.
|
||||
#
|
||||
# $hash=bede6f61d0f5b45669b8e924144e4200c41f869b$
|
||||
# $hash=67bc21133e37f5361a39f25dcfe004616d467dbc$
|
||||
#
|
||||
|
||||
{
|
||||
@@ -432,6 +432,8 @@
|
||||
'libcef_dll/ctocpp/urlrequest_client_ctocpp.h',
|
||||
'libcef_dll/ctocpp/v8accessor_ctocpp.cc',
|
||||
'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.h',
|
||||
'libcef_dll/cpptoc/v8exception_cpptoc.cc',
|
||||
@@ -712,6 +714,8 @@
|
||||
'libcef_dll/cpptoc/urlrequest_client_cpptoc.h',
|
||||
'libcef_dll/cpptoc/v8accessor_cpptoc.cc',
|
||||
'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.h',
|
||||
'libcef_dll/ctocpp/v8exception_ctocpp.cc',
|
||||
|
@@ -159,7 +159,6 @@
|
||||
'tests/shared/browser/main_message_loop_std.cc',
|
||||
'tests/shared/browser/main_message_loop_std.h',
|
||||
'tests/shared/browser/resource_util.h',
|
||||
'tests/shared/browser/resource_util.h',
|
||||
],
|
||||
'shared_sources_common': [
|
||||
'tests/shared/common/client_app.cc',
|
||||
|
@@ -86,7 +86,8 @@ if(OS_LINUX)
|
||||
-Werror # Treat warnings as errors
|
||||
-Wno-missing-field-initializers # Don't warn about missing field initializers
|
||||
-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
|
||||
-std=c99 # Use the C99 language standard
|
||||
@@ -198,9 +199,12 @@ if(OS_LINUX)
|
||||
set(CEF_BINARY_FILES
|
||||
chrome-sandbox
|
||||
libcef.so
|
||||
libEGL.so
|
||||
libGLESv2.so
|
||||
natives_blob.bin
|
||||
snapshot_blob.bin
|
||||
v8_context_snapshot.bin
|
||||
swiftshader
|
||||
)
|
||||
|
||||
# List of CEF resource files.
|
||||
@@ -333,12 +337,15 @@ if(OS_WINDOWS)
|
||||
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
|
||||
if(USE_SANDBOX)
|
||||
# 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
|
||||
1900 # VS2015 and updates 1, 2, & 3
|
||||
1910 # VS2017 version 15.1 & 15.2
|
||||
1911 # VS2017 version 15.3 & 15.4
|
||||
1912 # VS2017 version 15.5
|
||||
1913 # VS2017 version 15.6
|
||||
1914 # VS2017 version 15.7
|
||||
)
|
||||
list(FIND supported_msvc_versions ${MSVC_VERSION} _index)
|
||||
if (${_index} EQUAL -1)
|
||||
@@ -350,6 +357,13 @@ if(OS_WINDOWS)
|
||||
# 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")
|
||||
|
||||
# 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.
|
||||
set(CEF_LIBTYPE STATIC)
|
||||
list(APPEND CEF_COMPILER_FLAGS
|
||||
@@ -369,12 +383,10 @@ if(OS_WINDOWS)
|
||||
${CEF_DEBUG_INFO_FLAG}
|
||||
)
|
||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||
/MTd # Multithreaded debug runtime
|
||||
/RTC1 # Disable optimizations
|
||||
/Od # Enable basic run-time checks
|
||||
)
|
||||
list(APPEND CEF_COMPILER_FLAGS_RELEASE
|
||||
/MT # Multithreaded release runtime
|
||||
/O2 # Optimize for maximum speed
|
||||
/Ob2 # Inline any suitable function
|
||||
/GF # Enable string pooling
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=e0605a0c9918e225b9282b6d5e6138a7d697945b$
|
||||
// $hash=00e6d1aa80d5998d89cc272dcb199cde0add12fa$
|
||||
//
|
||||
|
||||
#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(
|
||||
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
|
||||
// only. Otherwise, data will be stored at the specified |path|. To persist
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=ab31ef5d72b4b1c9809698e5fbbdae21918af713$
|
||||
// $hash=c7641e41aca6bf30b9c36092861f061d2b16ff82$
|
||||
//
|
||||
|
||||
#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,
|
||||
struct _cef_browser_t* browser,
|
||||
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;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=3fb1034cb02cfeddcaf02d8fde0dec5b8a18f416$
|
||||
// $hash=f2f3acb1df9815e4ac9bf34010ce260a2496ae5a$
|
||||
//
|
||||
|
||||
#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,
|
||||
size_t character_boundsCount,
|
||||
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;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=b8b5a62b11dbc48f0733c0522864e4dbda8b4f59$
|
||||
// $hash=95e44047a75693dbae0ab6b07b415d188252bfdf$
|
||||
//
|
||||
|
||||
#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
|
||||
// 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
|
||||
// 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,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame,
|
||||
struct _cef_request_t* request,
|
||||
int user_gesture,
|
||||
int is_redirect);
|
||||
|
||||
///
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=561e4711432158fd3da971f3c0240dcf5e8e782a$
|
||||
// $hash=fd2cbc427bccf30298e26dd6c3bcef9551433f8b$
|
||||
//
|
||||
|
||||
#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,
|
||||
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;
|
||||
|
||||
///
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=e9e43167b1cf8033bd7e6ba6931213d7cf4b69b5$
|
||||
// $hash=2303574e76708e5311aede8e66eb7f1f679e0d1f$
|
||||
//
|
||||
|
||||
#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);
|
||||
} 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
|
||||
// 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);
|
||||
|
||||
///
|
||||
// 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.
|
||||
///
|
||||
@@ -639,6 +663,25 @@ typedef struct _cef_v8value_t {
|
||||
///
|
||||
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.
|
||||
|
||||
///
|
||||
@@ -751,6 +794,21 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_object(
|
||||
///
|
||||
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
|
||||
// be called from within the scope of a cef_render_process_handler_t,
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=ec4f722423ff89dd2ff61fd3336bda1776081023$
|
||||
// $hash=8815d0d0778cc210fb6f9ede9dafc5ca51124169$
|
||||
//
|
||||
|
||||
#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.
|
||||
// widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X,
|
||||
// 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
|
||||
// contents the registration will fail and |callback| will receive a |result|
|
||||
|
@@ -50,7 +50,7 @@ class CefAuthCallback : public virtual CefBaseRefCounted {
|
||||
///
|
||||
// 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,
|
||||
const CefString& password) = 0;
|
||||
|
||||
|
@@ -64,6 +64,17 @@ class CefCookieManager : public virtual CefBaseRefCounted {
|
||||
static CefRefPtr<CefCookieManager> GetGlobalManager(
|
||||
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
|
||||
// memory only. Otherwise, data will be stored at the specified |path|. To
|
||||
|
@@ -127,6 +127,14 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
|
||||
const CefSize& new_size) {
|
||||
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_
|
||||
|
@@ -204,6 +204,16 @@ class CefRenderHandler : public virtual CefBaseRefCounted {
|
||||
virtual void OnImeCompositionRangeChanged(CefRefPtr<CefBrowser> browser,
|
||||
const CefRange& selected_range,
|
||||
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_
|
||||
|
@@ -106,12 +106,15 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
|
||||
// If the navigation is allowed CefLoadHandler::OnLoadStart and
|
||||
// CefLoadHandler::OnLoadEnd will be called. If the navigation is canceled
|
||||
// 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()--*/
|
||||
virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
bool user_gesture,
|
||||
bool is_redirect) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -128,6 +128,18 @@ class CefResponse : public virtual CefBaseRefCounted {
|
||||
///
|
||||
/*--cef()--*/
|
||||
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_
|
||||
|
@@ -407,6 +407,21 @@ class CefV8Exception : public virtual CefBaseRefCounted {
|
||||
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
|
||||
// the thread on which they are created. Valid threads for creating a V8 handle
|
||||
@@ -493,6 +508,22 @@ class CefV8Value : public virtual CefBaseRefCounted {
|
||||
/*--cef()--*/
|
||||
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
|
||||
// called from within the scope of a CefRenderProcessHandler, CefV8Handler or
|
||||
@@ -571,6 +602,12 @@ class CefV8Value : public virtual CefBaseRefCounted {
|
||||
/*--cef()--*/
|
||||
virtual bool IsArray() = 0;
|
||||
|
||||
///
|
||||
// True if the value type is an ArrayBuffer.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsArrayBuffer() = 0;
|
||||
|
||||
///
|
||||
// True if the value type is function.
|
||||
///
|
||||
@@ -793,6 +830,25 @@ class CefV8Value : public virtual CefBaseRefCounted {
|
||||
/*--cef()--*/
|
||||
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.
|
||||
|
||||
///
|
||||
|
@@ -179,9 +179,6 @@ class CefRegisterCdmCallback : public virtual CefBaseRefCounted {
|
||||
// 2. widevinecdm file from the CDM binary distribution (e.g.
|
||||
// widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X,
|
||||
// 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
|
||||
// contents the registration will fail and |callback| will receive a |result|
|
||||
|
@@ -1264,6 +1264,12 @@ typedef enum {
|
||||
// originated in the browser process.
|
||||
///
|
||||
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;
|
||||
|
||||
///
|
||||
@@ -1379,23 +1385,41 @@ typedef enum {
|
||||
///
|
||||
// The main thread in the browser. This will be the same as the main
|
||||
// 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,
|
||||
|
||||
///
|
||||
// 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.
|
||||
// Responsiveness of this thread affects users.
|
||||
// Used for blocking tasks (e.g. file system access) that affect UI
|
||||
// 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,
|
||||
|
||||
@@ -1405,12 +1429,10 @@ typedef enum {
|
||||
TID_PROCESS_LAUNCHER,
|
||||
|
||||
///
|
||||
// Used to handle slow HTTP cache operations.
|
||||
///
|
||||
TID_CACHE,
|
||||
|
||||
///
|
||||
// Used to process IPC and network messages.
|
||||
// Used to process IPC and network messages. Do not perform blocking tasks on
|
||||
// this thread. All tasks posted after
|
||||
// CefBrowserProcessHandler::OnContextInitialized() and before CefShutdown()
|
||||
// are guaranteed to run.
|
||||
///
|
||||
TID_IO,
|
||||
|
||||
@@ -1418,6 +1440,10 @@ typedef enum {
|
||||
|
||||
///
|
||||
// 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,
|
||||
} cef_thread_id_t;
|
||||
|
@@ -39,8 +39,8 @@
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "extensions/browser/extension_protocols.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "net/proxy/proxy_config_service.h"
|
||||
#include "net/proxy/proxy_service.h"
|
||||
#include "net/proxy_resolution/proxy_config_service.h"
|
||||
#include "net/proxy_resolution/proxy_resolution_service.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
@@ -162,7 +162,7 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::Listener {
|
||||
|
||||
void CreateListenerForContext(const CefBrowserContext* context) {
|
||||
CEF_REQUIRE_UIT();
|
||||
auto listener = base::MakeUnique<visitedlink::VisitedLinkEventListener>(
|
||||
auto listener = std::make_unique<visitedlink::VisitedLinkEventListener>(
|
||||
const_cast<CefBrowserContext*>(context));
|
||||
listener_map_.insert(std::make_pair(context, std::move(listener)));
|
||||
}
|
||||
@@ -176,11 +176,11 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::Listener {
|
||||
|
||||
// visitedlink::VisitedLinkMaster::Listener methods.
|
||||
|
||||
void NewTable(mojo::SharedBufferHandle table) override {
|
||||
void NewTable(base::ReadOnlySharedMemoryRegion* table_region) override {
|
||||
CEF_REQUIRE_UIT();
|
||||
ListenerMap::iterator it = listener_map_.begin();
|
||||
for (; it != listener_map_.end(); ++it)
|
||||
it->second->NewTable(table);
|
||||
it->second->NewTable(table_region);
|
||||
}
|
||||
|
||||
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
|
||||
// https://crrev.com/d0d0d050
|
||||
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(
|
||||
pref_proxy_config_tracker_->CreateTrackingProxyConfigService(
|
||||
std::move(base_service)));
|
||||
@@ -461,10 +462,8 @@ net::URLRequestContextGetter* CefBrowserContextImpl::CreateRequestContext(
|
||||
// data in its installation directory).
|
||||
extensions::InfoMap* extension_info_map = extension_system()->info_map();
|
||||
(*protocol_handlers)[extensions::kExtensionScheme] =
|
||||
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
|
||||
extensions::CreateExtensionProtocolHandler(IsOffTheRecord(),
|
||||
extension_info_map)
|
||||
.release());
|
||||
extensions::CreateExtensionProtocolHandler(IsOffTheRecord(),
|
||||
extension_info_map);
|
||||
}
|
||||
|
||||
url_request_getter_ = new CefURLRequestContextGetterImpl(
|
||||
|
@@ -53,7 +53,7 @@
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/public/browser/desktop_media_id.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/keyboard_event_processing_result.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
@@ -71,7 +71,7 @@
|
||||
#include "content/public/common/favicon_url.h"
|
||||
#include "extensions/browser/process_manager.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"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
@@ -745,8 +745,8 @@ void CefBrowserHostImpl::StartDownload(const CefString& url) {
|
||||
if (!manager)
|
||||
return;
|
||||
|
||||
std::unique_ptr<content::DownloadUrlParameters> params(
|
||||
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
|
||||
std::unique_ptr<download::DownloadUrlParameters> params(
|
||||
content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(
|
||||
web_contents(), gurl, NO_TRAFFIC_ANNOTATION_YET));
|
||||
manager->DownloadUrl(std::move(params));
|
||||
}
|
||||
@@ -999,16 +999,17 @@ void CefBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents() || !web_contents()->GetRenderViewHost())
|
||||
if (enabled == auto_resize_enabled_)
|
||||
return;
|
||||
|
||||
auto_resize_enabled_ = enabled;
|
||||
if (enabled) {
|
||||
web_contents()->GetRenderViewHost()->EnableAutoResize(
|
||||
gfx::Size(min_size.width, min_size.height),
|
||||
gfx::Size(max_size.width, max_size.height));
|
||||
auto_resize_min_ = gfx::Size(min_size.width, min_size.height);
|
||||
auto_resize_max_ = gfx::Size(max_size.width, max_size.height);
|
||||
} else {
|
||||
web_contents()->GetRenderViewHost()->DisableAutoResize(gfx::Size());
|
||||
auto_resize_min_ = auto_resize_max_ = gfx::Size();
|
||||
}
|
||||
ConfigureAutoResize();
|
||||
}
|
||||
|
||||
CefRefPtr<CefExtension> CefBrowserHostImpl::GetExtension() {
|
||||
@@ -1589,10 +1590,13 @@ CefRefPtr<CefFrame> CefBrowserHostImpl::GetFrameForRequest(
|
||||
content::ResourceRequestInfo::ForRequest(request);
|
||||
if (!info)
|
||||
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(),
|
||||
CefFrameHostImpl::kUnspecifiedFrameId,
|
||||
info->IsMainFrame(), info->IsDownload(),
|
||||
info->IsMainFrame(), is_main_frame_state_flaky,
|
||||
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) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
@@ -2573,7 +2587,7 @@ void CefBrowserHostImpl::RequestMediaAccessPermission(
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::CheckMediaAccessPermission(
|
||||
content::WebContents* web_contents,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType type) {
|
||||
// Check media access permission without prompting the user. This is called
|
||||
@@ -2691,6 +2705,8 @@ void CefBrowserHostImpl::RenderViewDeleted(
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::RenderViewReady() {
|
||||
ConfigureAutoResize();
|
||||
|
||||
// Send the queued messages.
|
||||
queue_messages_ = false;
|
||||
while (!queued_messages_.empty()) {
|
||||
@@ -3211,7 +3227,7 @@ CefRefPtr<CefFrame> CefBrowserHostImpl::GetOrCreateFrame(
|
||||
int frame_tree_node_id,
|
||||
int64 parent_frame_id,
|
||||
bool is_main_frame,
|
||||
bool is_download,
|
||||
bool is_main_frame_state_flaky,
|
||||
base::string16 frame_name,
|
||||
const GURL& frame_url) {
|
||||
// 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) {
|
||||
// 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) {
|
||||
// Operating in the main frame. Continue using the existing main frame
|
||||
// object until the new renderer process representation is created.
|
||||
frame_id = main_frame_id_;
|
||||
} 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.
|
||||
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);
|
||||
|
||||
#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) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(
|
||||
|
@@ -407,6 +407,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
bool* was_blocked) override;
|
||||
void LoadingStateChanged(content::WebContents* source,
|
||||
bool to_different_document) override;
|
||||
void LoadProgressChanged(content::WebContents* source,
|
||||
double progress) override;
|
||||
void CloseContents(content::WebContents* source) override;
|
||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||
bool DidAddMessageToConsole(content::WebContents* source,
|
||||
@@ -471,14 +473,13 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
content::WebContents* web_contents,
|
||||
const content::MediaStreamRequest& request,
|
||||
const content::MediaResponseCallback& callback) override;
|
||||
bool CheckMediaAccessPermission(content::WebContents* web_contents,
|
||||
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType type) override;
|
||||
bool IsNeverVisible(content::WebContents* web_contents) override;
|
||||
|
||||
// content::WebContentsObserver methods.
|
||||
using content::WebContentsObserver::BeforeUnloadFired;
|
||||
using content::WebContentsObserver::WasHidden;
|
||||
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
|
||||
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
|
||||
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
|
||||
// CefFrameHostImpl::kUnspecifiedFrameId if unknown. In cases where |frame_id|
|
||||
// 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
|
||||
// value of |is_main_frame| cannot be relied on.
|
||||
// returned depending on current state. If |is_main_frame_state_flaky| is true
|
||||
// then the value of |is_main_frame| cannot be relied on.
|
||||
CefRefPtr<CefFrame> GetOrCreateFrame(int64 frame_id,
|
||||
int frame_tree_node_id,
|
||||
int64 parent_frame_id,
|
||||
bool is_main_frame,
|
||||
bool is_download,
|
||||
bool is_main_frame_state_flaky,
|
||||
base::string16 frame_name,
|
||||
const GURL& frame_url);
|
||||
|
||||
@@ -625,6 +626,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// Create the CefFileDialogManager if it doesn't already exist.
|
||||
void EnsureFileDialogManager();
|
||||
|
||||
void ConfigureAutoResize();
|
||||
|
||||
// Send a message to the RenderViewHost associated with this browser.
|
||||
// TODO(cef): With the introduction of OOPIFs, WebContents can span multiple
|
||||
// processes. Messages should be sent to specific RenderFrameHosts instead.
|
||||
@@ -726,6 +729,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
CefRefPtr<CefExtension> extension_;
|
||||
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);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserHostImpl);
|
||||
};
|
||||
|
@@ -154,7 +154,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
window_info->SetAsPopup(NULL, CefString());
|
||||
#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->opener_process_id = opener->GetProcess()->GetID();
|
||||
pending_popup->opener_frame_id = opener->GetRoutingID();
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "base/synchronization/lock.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 "url/gurl.h"
|
||||
|
||||
|
@@ -26,6 +26,8 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/message_loop/message_loop.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 "content/public/browser/gpu_data_manager.h"
|
||||
#include "content/public/common/result_codes.h"
|
||||
@@ -58,13 +60,14 @@ CefBrowserMainParts::CefBrowserMainParts(
|
||||
const content::MainFunctionParams& parameters)
|
||||
: 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() {
|
||||
if (!base::MessageLoop::current()) {
|
||||
// Create the browser message loop.
|
||||
message_loop_.reset(new CefBrowserMessageLoop());
|
||||
}
|
||||
void CefBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
|
||||
chrome_extra_parts_.push_back(parts);
|
||||
}
|
||||
|
||||
int CefBrowserMainParts::PreEarlyInitialization() {
|
||||
@@ -73,9 +76,18 @@ int CefBrowserMainParts::PreEarlyInitialization() {
|
||||
// views::LinuxUI::SetInstance.
|
||||
ui::InitializeInputMethodForTesting();
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
||||
chrome_extra_parts_[i]->PreEarlyInitialization();
|
||||
|
||||
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() {
|
||||
#if defined(USE_AURA)
|
||||
CHECK(aura::Env::GetInstance());
|
||||
@@ -89,6 +101,19 @@ void CefBrowserMainParts::ToolkitInitialized() {
|
||||
CefContentBrowserClient::Get()->GetResourceDllName());
|
||||
#endif
|
||||
#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() {
|
||||
@@ -98,6 +123,9 @@ void CefBrowserMainParts::PostMainMessageLoopStart() {
|
||||
printing::PrintingContextLinux::SetPdfPaperSizeFunction(
|
||||
&CefPrintDialogLinux::GetPdfPaperSize);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
||||
chrome_extra_parts_[i]->PostMainMessageLoopStart();
|
||||
}
|
||||
|
||||
int CefBrowserMainParts::PreCreateThreads() {
|
||||
@@ -111,14 +139,26 @@ int CefBrowserMainParts::PreCreateThreads() {
|
||||
// before the IO thread is started.
|
||||
content::GpuDataManager::GetInstance();
|
||||
|
||||
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
||||
chrome_extra_parts_[i]->PreCreateThreads();
|
||||
|
||||
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() {
|
||||
#if defined(USE_AURA)
|
||||
display::Screen::SetScreenInstance(views::CreateDesktopScreen());
|
||||
#endif
|
||||
|
||||
// CEF's profile is a BrowserContext.
|
||||
PreProfileInit();
|
||||
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
// Initialize extension global objects before creating the global
|
||||
// BrowserContext.
|
||||
@@ -137,6 +177,16 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
|
||||
|
||||
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;
|
||||
CefContext::Get()->PopulateRequestContextSettings(&settings);
|
||||
|
||||
@@ -146,12 +196,21 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
|
||||
CefBrowserContextImpl* browser_context = static_cast<CefBrowserContextImpl*>(
|
||||
global_request_context_->GetBrowserContext());
|
||||
|
||||
PostProfileInit();
|
||||
|
||||
CefDevToolsManagerDelegate::StartHttpHandler(browser_context);
|
||||
|
||||
// Triggers initialization of the singleton instance on UI thread.
|
||||
PluginFinder::GetInstance()->Init();
|
||||
|
||||
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() {
|
||||
@@ -167,6 +226,9 @@ void CefBrowserMainParts::PostMainMessageLoopRun() {
|
||||
extensions::ExtensionsBrowserClient::Set(NULL);
|
||||
extensions_browser_client_.reset();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
||||
chrome_extra_parts_[i]->PostMainMessageLoopRun();
|
||||
}
|
||||
|
||||
void CefBrowserMainParts::PostDestroyThreads() {
|
||||
@@ -175,3 +237,23 @@ void CefBrowserMainParts::PostDestroyThreads() {
|
||||
delete views::ViewsDelegate::GetInstance();
|
||||
#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();
|
||||
}
|
||||
|
@@ -37,26 +37,51 @@ class WMState;
|
||||
#endif
|
||||
|
||||
class CefDevToolsDelegate;
|
||||
class ChromeBrowserMainExtraParts;
|
||||
|
||||
class CefBrowserMainParts : public content::BrowserMainParts {
|
||||
public:
|
||||
explicit CefBrowserMainParts(const content::MainFunctionParams& parameters);
|
||||
~CefBrowserMainParts() override;
|
||||
|
||||
// Add additional ChromeBrowserMainExtraParts.
|
||||
void AddParts(ChromeBrowserMainExtraParts* parts);
|
||||
|
||||
int PreEarlyInitialization() override;
|
||||
void PostEarlyInitialization() override;
|
||||
void ToolkitInitialized() override;
|
||||
void PreMainMessageLoopStart() override;
|
||||
void PostMainMessageLoopStart() override;
|
||||
int PreEarlyInitialization() override;
|
||||
void ToolkitInitialized() override;
|
||||
int PreCreateThreads() override;
|
||||
void ServiceManagerConnectionStarted(
|
||||
content::ServiceManagerConnection* connection);
|
||||
void PreMainMessageLoopRun() override;
|
||||
void PostMainMessageLoopRun() 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 {
|
||||
return global_request_context_;
|
||||
}
|
||||
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:
|
||||
#if defined(OS_WIN)
|
||||
void PlatformInitialize();
|
||||
@@ -70,10 +95,22 @@ class CefBrowserMainParts : public content::BrowserMainParts {
|
||||
std::unique_ptr<extensions::ExtensionsBrowserClient>
|
||||
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)
|
||||
std::unique_ptr<wm::WMState> wm_state_;
|
||||
#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);
|
||||
};
|
||||
|
||||
|
@@ -8,11 +8,7 @@
|
||||
|
||||
#include "libcef/browser/browser_main.h"
|
||||
|
||||
#include "cef/grit/cef_strings.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"
|
||||
#include "base/logging.h"
|
||||
|
||||
void CefBrowserMainParts::PlatformInitialize() {
|
||||
HRESULT res;
|
||||
|
@@ -36,13 +36,13 @@ std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
|
||||
const CefWindowInfo& window_info,
|
||||
SkColor background_color) {
|
||||
#if defined(OS_WIN)
|
||||
return base::MakeUnique<CefBrowserPlatformDelegateNativeWin>(
|
||||
return std::make_unique<CefBrowserPlatformDelegateNativeWin>(
|
||||
window_info, background_color);
|
||||
#elif defined(OS_MACOSX)
|
||||
return base::MakeUnique<CefBrowserPlatformDelegateNativeMac>(
|
||||
return std::make_unique<CefBrowserPlatformDelegateNativeMac>(
|
||||
window_info, background_color);
|
||||
#elif defined(OS_LINUX)
|
||||
return base::MakeUnique<CefBrowserPlatformDelegateNativeLinux>(
|
||||
return std::make_unique<CefBrowserPlatformDelegateNativeLinux>(
|
||||
window_info, background_color);
|
||||
#endif
|
||||
}
|
||||
@@ -50,13 +50,13 @@ std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
|
||||
std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate) {
|
||||
#if defined(OS_WIN)
|
||||
return base::MakeUnique<CefBrowserPlatformDelegateOsrWin>(
|
||||
return std::make_unique<CefBrowserPlatformDelegateOsrWin>(
|
||||
std::move(native_delegate));
|
||||
#elif defined(OS_MACOSX)
|
||||
return base::MakeUnique<CefBrowserPlatformDelegateOsrMac>(
|
||||
return std::make_unique<CefBrowserPlatformDelegateOsrMac>(
|
||||
std::move(native_delegate));
|
||||
#elif defined(OS_LINUX)
|
||||
return base::MakeUnique<CefBrowserPlatformDelegateOsrLinux>(
|
||||
return std::make_unique<CefBrowserPlatformDelegateOsrLinux>(
|
||||
std::move(native_delegate));
|
||||
#endif
|
||||
}
|
||||
@@ -85,7 +85,7 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
||||
// Creating a background extension host without a window.
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
||||
CreateNativeDelegate(CefWindowInfo(), background_color);
|
||||
return base::MakeUnique<CefBrowserPlatformDelegateBackground>(
|
||||
return std::make_unique<CefBrowserPlatformDelegateBackground>(
|
||||
std::move(native_delegate));
|
||||
}
|
||||
#if defined(USE_AURA)
|
||||
@@ -93,7 +93,7 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
||||
// CefWindowInfo is not used in this case.
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
||||
CreateNativeDelegate(CefWindowInfo(), background_color);
|
||||
return base::MakeUnique<CefBrowserPlatformDelegateViews>(
|
||||
return std::make_unique<CefBrowserPlatformDelegateViews>(
|
||||
std::move(native_delegate),
|
||||
static_cast<CefBrowserViewImpl*>(create_params.browser_view.get()));
|
||||
}
|
||||
|
@@ -356,6 +356,9 @@ class CefBrowserURLRequest::Context
|
||||
CefResponseImpl* responseImpl =
|
||||
static_cast<CefResponseImpl*>(response_.get());
|
||||
|
||||
responseImpl->SetURL(fetcher_->GetURL().spec());
|
||||
responseImpl->SetStatus(fetcher_->GetResponseCode());
|
||||
|
||||
net::HttpResponseHeaders* headers = fetcher_->GetResponseHeaders();
|
||||
if (headers)
|
||||
responseImpl->SetResponseHeaders(*headers);
|
||||
|
@@ -15,7 +15,7 @@
|
||||
#include "chrome/browser/printing/print_job_manager.h"
|
||||
#include "components/net_log/chrome_net_log.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()
|
||||
: initialized_(false),
|
||||
@@ -165,11 +165,6 @@ ChromeBrowserProcessStub::notification_platform_bridge() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
message_center::MessageCenter* ChromeBrowserProcessStub::message_center() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
policy::ChromeBrowserPolicyConnector*
|
||||
ChromeBrowserProcessStub::browser_policy_connector() {
|
||||
NOTREACHED();
|
||||
@@ -191,9 +186,7 @@ GpuModeManager* ChromeBrowserProcessStub::gpu_mode_manager() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ChromeBrowserProcessStub::CreateDevToolsHttpProtocolHandler(
|
||||
const std::string& ip,
|
||||
uint16_t port) {
|
||||
void ChromeBrowserProcessStub::CreateDevToolsProtocolHandler() {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
@@ -296,10 +289,10 @@ net_log::ChromeNetLog* ChromeBrowserProcessStub::net_log() {
|
||||
if (!net_log_) {
|
||||
const base::CommandLine& command_line =
|
||||
*base::CommandLine::ForCurrentProcess();
|
||||
net_log_ = base::MakeUnique<net_log::ChromeNetLog>();
|
||||
if (command_line.HasSwitch(switches::kLogNetLog)) {
|
||||
net_log_ = std::make_unique<net_log::ChromeNetLog>();
|
||||
if (command_line.HasSwitch(network::switches::kLogNetLog)) {
|
||||
net_log_->StartWritingToFile(
|
||||
command_line.GetSwitchValuePath(switches::kLogNetLog),
|
||||
command_line.GetSwitchValuePath(network::switches::kLogNetLog),
|
||||
GetNetCaptureModeFromCommandLine(command_line),
|
||||
command_line.GetCommandLineString(), std::string());
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/extensions/event_router_forwarder.h"
|
||||
#include "chrome/browser/profiles/incognito_helpers.h"
|
||||
#include "media/media_features.h"
|
||||
#include "media/media_buildflags.h"
|
||||
|
||||
class ChromeProfileManagerStub;
|
||||
|
||||
@@ -59,13 +59,11 @@ class ChromeBrowserProcessStub : public BrowserProcess,
|
||||
extensions::EventRouterForwarder* extension_event_router_forwarder() override;
|
||||
NotificationUIManager* notification_ui_manager() override;
|
||||
NotificationPlatformBridge* notification_platform_bridge() override;
|
||||
message_center::MessageCenter* message_center() override;
|
||||
policy::ChromeBrowserPolicyConnector* browser_policy_connector() override;
|
||||
policy::PolicyService* policy_service() override;
|
||||
IconManager* icon_manager() override;
|
||||
GpuModeManager* gpu_mode_manager() override;
|
||||
void CreateDevToolsHttpProtocolHandler(const std::string& ip,
|
||||
uint16_t port) override;
|
||||
void CreateDevToolsProtocolHandler() override;
|
||||
void CreateDevToolsAutoOpener() override;
|
||||
bool IsShuttingDown() override;
|
||||
printing::PrintJobManager* print_job_manager() override;
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include "base/json/json_reader.h"
|
||||
#include "base/path_service.h"
|
||||
#include "cef/grit/cef_resources.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/chrome_service.h"
|
||||
#include "chrome/browser/plugins/plugin_info_host_impl.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
@@ -49,7 +50,7 @@
|
||||
#include "chrome/common/constants.mojom.h"
|
||||
#include "chrome/grit/browser_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/navigation_params.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/storage_quota_params.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_protocols.h"
|
||||
#include "extensions/browser/extension_registry.h"
|
||||
#include "extensions/browser/extensions_browser_client.h"
|
||||
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
|
||||
@@ -84,9 +87,9 @@
|
||||
#include "extensions/common/switches.h"
|
||||
#include "net/ssl/ssl_cert_request_info.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 "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/resource/resource_bundle.h"
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
@@ -96,10 +99,6 @@
|
||||
#include "libcef/common/widevine_loader.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include "components/spellcheck/browser/spellcheck_message_filter_platform.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||
#include "base/debug/leak_annotations.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
@@ -430,7 +429,8 @@ bool NavigationOnUIThread(
|
||||
request->SetReadOnly(true);
|
||||
|
||||
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
|
||||
CefContentBrowserClient* CefContentBrowserClient::Get() {
|
||||
if (!CefContentClient::Get())
|
||||
return nullptr;
|
||||
return static_cast<CefContentBrowserClient*>(
|
||||
CefContentClient::Get()->browser());
|
||||
}
|
||||
@@ -457,25 +459,20 @@ CefContentBrowserClient* CefContentBrowserClient::Get() {
|
||||
content::BrowserMainParts* CefContentBrowserClient::CreateBrowserMainParts(
|
||||
const content::MainFunctionParams& parameters) {
|
||||
browser_main_parts_ = new CefBrowserMainParts(parameters);
|
||||
browser_main_parts_->AddParts(
|
||||
ChromeService::GetInstance()->CreateExtraParts());
|
||||
return browser_main_parts_;
|
||||
}
|
||||
|
||||
void CefContentBrowserClient::RenderProcessWillLaunch(
|
||||
content::RenderProcessHost* host) {
|
||||
content::RenderProcessHost* host,
|
||||
service_manager::mojom::ServiceRequest* service_request) {
|
||||
const int id = host->GetID();
|
||||
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
|
||||
|
||||
host->AddFilter(new CefBrowserMessageFilter(id));
|
||||
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()) {
|
||||
host->AddFilter(new extensions::ExtensionMessageFilter(id, profile));
|
||||
host->AddFilter(
|
||||
@@ -492,6 +489,16 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
|
||||
|
||||
host->Send(
|
||||
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(
|
||||
@@ -594,7 +601,7 @@ void CefContentBrowserClient::RegisterInProcessServices(
|
||||
{
|
||||
// For spell checking.
|
||||
service_manager::EmbeddedServiceInfo info;
|
||||
info.factory = base::Bind(&ChromeService::Create);
|
||||
info.factory = ChromeService::GetInstance()->CreateChromeServiceFactory();
|
||||
services->insert(std::make_pair(chrome::mojom::kServiceName, info));
|
||||
}
|
||||
}
|
||||
@@ -633,6 +640,8 @@ std::vector<content::ContentBrowserClient::ServiceManifestInfo>
|
||||
CefContentBrowserClient::GetExtraServiceManifests() {
|
||||
return std::vector<ServiceManifestInfo>({
|
||||
{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 (!browser_cmd->HasSwitch(switches::kNoSandbox)) {
|
||||
// Pass the Widevine CDM path to the Zygote process. See comments in
|
||||
// CefWidevineLoader::AddPepperPlugins.
|
||||
// CefWidevineLoader::AddContentDecryptionModules.
|
||||
const base::FilePath& cdm_path = CefWidevineLoader::GetInstance()->path();
|
||||
if (!cdm_path.empty())
|
||||
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*
|
||||
CefContentBrowserClient::CreateQuotaPermissionContext() {
|
||||
return new CefQuotaPermissionContext();
|
||||
@@ -958,7 +971,7 @@ CefContentBrowserClient::CreateThrottlesForNavigation(
|
||||
}
|
||||
|
||||
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,
|
||||
frame_id, parent_frame_id));
|
||||
throttles.push_back(std::move(throttle));
|
||||
@@ -1010,6 +1023,77 @@ void CefContentBrowserClient::ExposeInterfacesToRenderer(
|
||||
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) {
|
||||
// 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
|
||||
@@ -1029,6 +1113,21 @@ CefDevToolsDelegate* CefContentBrowserClient::devtools_delegate() const {
|
||||
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(
|
||||
content::SiteInstance* site_instance) {
|
||||
extensions::ExtensionRegistry* registry =
|
||||
@@ -1038,3 +1137,18 @@ const extensions::Extension* CefContentBrowserClient::GetExtension(
|
||||
return registry->enabled_extensions().GetExtensionOrAppByURL(
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,9 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
// ContentBrowserClient implementation.
|
||||
content::BrowserMainParts* CreateBrowserMainParts(
|
||||
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,
|
||||
const GURL& effective_url) override;
|
||||
bool IsHandledURL(const GURL& url) override;
|
||||
@@ -58,6 +60,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
content::BrowserContext* context2) override;
|
||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
||||
int child_process_id) override;
|
||||
std::string GetApplicationLocale() override;
|
||||
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
|
||||
void GetQuotaSettings(
|
||||
content::BrowserContext* context,
|
||||
@@ -122,17 +125,50 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
blink::AssociatedInterfaceRegistry* associated_registry,
|
||||
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.
|
||||
void RegisterCustomScheme(const std::string& scheme);
|
||||
|
||||
CefRefPtr<CefRequestContextImpl> request_context() 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:
|
||||
// Returns the extension or app associated with |site_instance| or NULL.
|
||||
const extensions::Extension* GetExtension(
|
||||
content::SiteInstance* site_instance);
|
||||
|
||||
static void HandleExternalProtocolOnUIThread(
|
||||
const GURL& url,
|
||||
const content::ResourceRequestInfo::WebContentsGetter&
|
||||
web_contents_getter);
|
||||
|
||||
CefBrowserMainParts* browser_main_parts_;
|
||||
|
||||
std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_;
|
||||
|
@@ -120,7 +120,8 @@ net::CookieStore* GetExistingCookieStoreHelper(
|
||||
|
||||
} // namespace
|
||||
|
||||
CefCookieManagerImpl::CefCookieManagerImpl() : weak_ptr_factory_(this) {}
|
||||
CefCookieManagerImpl::CefCookieManagerImpl(bool is_blocking)
|
||||
: is_blocking_(is_blocking), weak_ptr_factory_(this) {}
|
||||
|
||||
CefCookieManagerImpl::~CefCookieManagerImpl() {
|
||||
CEF_REQUIRE_IOT();
|
||||
@@ -131,6 +132,7 @@ void CefCookieManagerImpl::Initialize(
|
||||
const CefString& path,
|
||||
bool persist_session_cookies,
|
||||
CefRefPtr<CefCompletionCallback> callback) {
|
||||
CHECK(!is_blocking_);
|
||||
if (request_context.get()) {
|
||||
request_context_ = request_context;
|
||||
request_context_->GetRequestContextImpl(
|
||||
@@ -160,7 +162,7 @@ void CefCookieManagerImpl::GetCookieStore(
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK(cookie_store_.get());
|
||||
DCHECK(is_blocking_ || cookie_store_.get());
|
||||
|
||||
// Binding ref-counted |this| to CookieStoreGetter may result in
|
||||
// heap-use-after-free if (a) the CookieStoreGetter contains the last
|
||||
@@ -192,7 +194,9 @@ net::CookieStore* CefCookieManagerImpl::GetExistingCookieStore() {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -299,7 +303,10 @@ bool CefCookieManagerImpl::SetStoragePath(
|
||||
const base::FilePath& cookie_path = new_path.AppendASCII("Cookies");
|
||||
persistent_store = new net::SQLitePersistentCookieStore(
|
||||
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);
|
||||
} else {
|
||||
NOTREACHED() << "The cookie storage directory could not be created";
|
||||
@@ -495,12 +502,11 @@ void CefCookieManagerImpl::SetSupportedSchemesInternal(
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK(cookie_store_.get());
|
||||
if (!cookie_store_.get())
|
||||
return;
|
||||
|
||||
supported_schemes_ = schemes;
|
||||
SetCookieMonsterSchemes(cookie_store_.get(), supported_schemes_);
|
||||
DCHECK(is_blocking_ || cookie_store_.get());
|
||||
if (cookie_store_) {
|
||||
supported_schemes_ = schemes;
|
||||
SetCookieMonsterSchemes(cookie_store_.get(), supported_schemes_);
|
||||
}
|
||||
|
||||
RunAsyncCompletionOnIOThread(callback);
|
||||
}
|
||||
@@ -552,8 +558,13 @@ void CefCookieManagerImpl::SetCookieInternal(
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
std::string name = CefString(&cookie.name).ToString();
|
||||
std::string value = CefString(&cookie.value).ToString();
|
||||
@@ -584,8 +595,13 @@ void CefCookieManagerImpl::DeleteCookiesInternal(
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (url.is_empty()) {
|
||||
// Delete all cookies.
|
||||
@@ -610,8 +626,10 @@ void CefCookieManagerImpl::FlushStoreInternal(
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
||||
if (!cookie_store)
|
||||
if (!cookie_store) {
|
||||
RunAsyncCompletionOnIOThread(callback);
|
||||
return;
|
||||
}
|
||||
|
||||
cookie_store->FlushStore(base::Bind(RunAsyncCompletionOnIOThread, callback));
|
||||
}
|
||||
@@ -631,6 +649,11 @@ CefRefPtr<CefCookieManager> CefCookieManager::GetGlobalManager(
|
||||
callback);
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefCookieManager> CefCookieManager::GetBlockingManager() {
|
||||
return new CefCookieManagerImpl(true);
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
|
||||
const CefString& path,
|
||||
@@ -642,7 +665,8 @@ CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefCookieManagerImpl> cookie_manager = new CefCookieManagerImpl();
|
||||
CefRefPtr<CefCookieManagerImpl> cookie_manager =
|
||||
new CefCookieManagerImpl(false);
|
||||
cookie_manager->Initialize(NULL, path, persist_session_cookies, callback);
|
||||
return cookie_manager.get();
|
||||
}
|
||||
|
@@ -18,10 +18,11 @@
|
||||
// Implementation of the CefCookieManager interface.
|
||||
class CefCookieManagerImpl : public CefCookieManager {
|
||||
public:
|
||||
CefCookieManagerImpl();
|
||||
explicit CefCookieManagerImpl(bool is_blocking);
|
||||
~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,
|
||||
const CefString& path,
|
||||
bool persist_session_cookies,
|
||||
@@ -113,6 +114,9 @@ class CefCookieManagerImpl : public CefCookieManager {
|
||||
void FlushStoreInternal(CefRefPtr<CefCompletionCallback> callback,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
|
||||
// If true all cookies will be blocked.
|
||||
const bool is_blocking_;
|
||||
|
||||
// Used for cookie monsters owned by the context.
|
||||
CefRefPtr<CefRequestContextImpl> request_context_;
|
||||
scoped_refptr<CefURLRequestContextGetterImpl> request_context_impl_;
|
||||
|
@@ -100,7 +100,7 @@ int ResponseWriter::Finish(int net_error,
|
||||
}
|
||||
|
||||
static std::string GetFrontendURL() {
|
||||
return base::StringPrintf("%s://%s/inspector.html",
|
||||
return base::StringPrintf("%s://%s/devtools_app.html",
|
||||
content::kChromeDevToolsScheme,
|
||||
scheme::kChromeDevToolsHost);
|
||||
}
|
||||
@@ -163,7 +163,7 @@ void CefDevToolsFrontend::InspectElementAt(int x, int y) {
|
||||
if (inspect_element_at_.x != x || inspect_element_at_.y != y)
|
||||
inspect_element_at_.Set(x, y);
|
||||
if (agent_host_)
|
||||
agent_host_->InspectElement(this, x, y);
|
||||
agent_host_->InspectElement(inspected_contents_->GetFocusedFrame(), x, y);
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::Close() {
|
||||
@@ -226,8 +226,8 @@ void CefDevToolsFrontend::DocumentAvailableInMainFrame() {
|
||||
agent_host_ = agent_host;
|
||||
agent_host_->AttachClient(this);
|
||||
if (!inspect_element_at_.IsEmpty()) {
|
||||
agent_host_->InspectElement(this, inspect_element_at_.x,
|
||||
inspect_element_at_.y);
|
||||
agent_host_->InspectElement(inspected_contents_->GetFocusedFrame(),
|
||||
inspect_element_at_.x, inspect_element_at_.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,7 +392,7 @@ void CefDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
DCHECK(it != pending_requests_.end());
|
||||
|
||||
base::DictionaryValue response;
|
||||
auto headers = base::MakeUnique<base::DictionaryValue>();
|
||||
auto headers = std::make_unique<base::DictionaryValue>();
|
||||
net::HttpResponseHeaders* rh = source->GetResponseHeaders();
|
||||
response.SetInteger("statusCode", rh ? rh->response_code() : 200);
|
||||
|
||||
|
@@ -105,8 +105,7 @@ void CefDevToolsManagerDelegate::StartHttpHandler(
|
||||
if (!socket_factory)
|
||||
return;
|
||||
content::DevToolsAgentHost::StartRemoteDebuggingServer(
|
||||
std::move(socket_factory), std::string(), browser_context->GetPath(),
|
||||
base::FilePath());
|
||||
std::move(socket_factory), browser_context->GetPath(), base::FilePath());
|
||||
|
||||
const base::CommandLine& command_line =
|
||||
*base::CommandLine::ForCurrentProcess();
|
||||
@@ -138,7 +137,6 @@ std::string CefDevToolsManagerDelegate::GetDiscoveryPageHTML() {
|
||||
.as_string();
|
||||
}
|
||||
|
||||
std::string CefDevToolsManagerDelegate::GetFrontendResource(
|
||||
const std::string& path) {
|
||||
return content::DevToolsFrontendHost::GetFrontendResource(path).as_string();
|
||||
bool CefDevToolsManagerDelegate::HasBundledFrontendResources() {
|
||||
return true;
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ class CefDevToolsManagerDelegate : public content::DevToolsManagerDelegate {
|
||||
scoped_refptr<content::DevToolsAgentHost> CreateNewTarget(
|
||||
const GURL& url) override;
|
||||
std::string GetDiscoveryPageHTML() override;
|
||||
std::string GetFrontendResource(const std::string& path) override;
|
||||
bool HasBundledFrontendResources() override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(CefDevToolsManagerDelegate);
|
||||
|
@@ -6,11 +6,11 @@
|
||||
|
||||
#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"
|
||||
|
||||
CefDownloadItemImpl::CefDownloadItemImpl(content::DownloadItem* value)
|
||||
: CefValueBase<CefDownloadItem, content::DownloadItem>(
|
||||
CefDownloadItemImpl::CefDownloadItemImpl(download::DownloadItem* value)
|
||||
: CefValueBase<CefDownloadItem, download::DownloadItem>(
|
||||
value,
|
||||
NULL,
|
||||
kOwnerNoDelete,
|
||||
@@ -26,17 +26,17 @@ bool CefDownloadItemImpl::IsValid() {
|
||||
|
||||
bool CefDownloadItemImpl::IsInProgress() {
|
||||
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() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return const_value().GetState() == content::DownloadItem::COMPLETE;
|
||||
return const_value().GetState() == download::DownloadItem::COMPLETE;
|
||||
}
|
||||
|
||||
bool CefDownloadItemImpl::IsCanceled() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return const_value().GetState() == content::DownloadItem::CANCELLED;
|
||||
return const_value().GetState() == download::DownloadItem::CANCELLED;
|
||||
}
|
||||
|
||||
int64 CefDownloadItemImpl::GetCurrentSpeed() {
|
||||
|
@@ -9,15 +9,15 @@
|
||||
#include "include/cef_download_item.h"
|
||||
#include "libcef/common/value_base.h"
|
||||
|
||||
namespace content {
|
||||
namespace download {
|
||||
class DownloadItem;
|
||||
}
|
||||
|
||||
// CefDownloadItem implementation
|
||||
class CefDownloadItemImpl
|
||||
: public CefValueBase<CefDownloadItem, content::DownloadItem> {
|
||||
: public CefValueBase<CefDownloadItem, download::DownloadItem> {
|
||||
public:
|
||||
explicit CefDownloadItemImpl(content::DownloadItem* value);
|
||||
explicit CefDownloadItemImpl(download::DownloadItem* value);
|
||||
|
||||
// CefDownloadItem methods.
|
||||
bool IsValid() override;
|
||||
|
@@ -15,11 +15,12 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.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/common/file_chooser_params.h"
|
||||
#include "net/base/filename_util.h"
|
||||
|
||||
using content::DownloadItem;
|
||||
using download::DownloadItem;
|
||||
using content::DownloadManager;
|
||||
using content::WebContents;
|
||||
|
||||
@@ -53,11 +54,9 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
|
||||
if (manager_) {
|
||||
base::FilePath path = base::FilePath(download_path);
|
||||
CEF_POST_TASK(
|
||||
CEF_FILET,
|
||||
base::Bind(&CefBeforeDownloadCallbackImpl::GenerateFilename,
|
||||
manager_, download_id_, suggested_name_, path,
|
||||
show_dialog, callback_));
|
||||
CEF_POST_USER_VISIBLE_TASK(base::Bind(
|
||||
&CefBeforeDownloadCallbackImpl::GenerateFilename, manager_,
|
||||
download_id_, suggested_name_, path, show_dialog, callback_));
|
||||
}
|
||||
|
||||
download_id_ = 0;
|
||||
@@ -77,6 +76,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
const base::FilePath& download_path,
|
||||
bool show_dialog,
|
||||
const content::DownloadTargetCallback& callback) {
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
|
||||
base::FilePath suggested_path = download_path;
|
||||
if (!suggested_path.empty()) {
|
||||
// Create the directory if necessary.
|
||||
@@ -114,13 +115,14 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
return;
|
||||
|
||||
DownloadItem* item = manager->GetDownload(download_id);
|
||||
if (!item || item->GetState() != content::DownloadItem::IN_PROGRESS)
|
||||
if (!item || item->GetState() != DownloadItem::IN_PROGRESS)
|
||||
return;
|
||||
|
||||
bool handled = false;
|
||||
|
||||
if (show_dialog) {
|
||||
WebContents* web_contents = item->GetWebContents();
|
||||
WebContents* web_contents =
|
||||
content::DownloadItemUtils::GetWebContents(item);
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
if (browser.get()) {
|
||||
@@ -146,8 +148,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
|
||||
if (!handled) {
|
||||
callback.Run(suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, suggested_path,
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, suggested_path,
|
||||
download::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,8 +165,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
|
||||
// The download will be cancelled if |path| is empty.
|
||||
callback.Run(path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
|
||||
download::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
}
|
||||
|
||||
base::WeakPtr<DownloadManager> manager_;
|
||||
@@ -206,7 +208,7 @@ class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
|
||||
|
||||
if (manager_) {
|
||||
DownloadItem* item = manager_->GetDownload(download_id_);
|
||||
if (item && item->GetState() == content::DownloadItem::IN_PROGRESS)
|
||||
if (item && item->GetState() == DownloadItem::IN_PROGRESS)
|
||||
item->Cancel(true);
|
||||
}
|
||||
|
||||
@@ -219,7 +221,7 @@ class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
|
||||
|
||||
if (manager_) {
|
||||
DownloadItem* item = manager_->GetDownload(download_id_);
|
||||
if (item && item->GetState() == content::DownloadItem::IN_PROGRESS)
|
||||
if (item && item->GetState() == DownloadItem::IN_PROGRESS)
|
||||
item->Pause();
|
||||
}
|
||||
}
|
||||
@@ -316,7 +318,8 @@ void CefDownloadManagerDelegate::OnDownloadDestroyed(DownloadItem* item) {
|
||||
void CefDownloadManagerDelegate::OnDownloadCreated(DownloadManager* manager,
|
||||
DownloadItem* item) {
|
||||
CefBrowserHostImpl* browser = nullptr;
|
||||
content::WebContents* contents = item->GetWebContents();
|
||||
content::WebContents* contents =
|
||||
content::DownloadItemUtils::GetWebContents(item);
|
||||
if (contents) {
|
||||
browser = CefBrowserHostImpl::GetBrowserForContents(contents).get();
|
||||
DCHECK(browser);
|
||||
@@ -360,8 +363,8 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
|
||||
if (!item->GetForcedFilePath().empty()) {
|
||||
callback.Run(
|
||||
item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, item->GetForcedFilePath(),
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, item->GetForcedFilePath(),
|
||||
download::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -419,6 +422,6 @@ CefBrowserHostImpl* CefDownloadManagerDelegate::GetBrowser(DownloadItem* item) {
|
||||
// StartDownloadWithId (originating from CreateInterruptedDownload) with no
|
||||
// associated WebContents and consequently no associated CEF browser. In that
|
||||
// case DetermineDownloadTarget will be called before OnDownloadCreated.
|
||||
DCHECK(!item->GetWebContents());
|
||||
DCHECK(!content::DownloadItemUtils::GetWebContents(item));
|
||||
return nullptr;
|
||||
}
|
||||
|
@@ -12,11 +12,11 @@
|
||||
|
||||
#include "base/compiler_specific.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_delegate.h"
|
||||
|
||||
class CefDownloadManagerDelegate : public content::DownloadItem::Observer,
|
||||
class CefDownloadManagerDelegate : public download::DownloadItem::Observer,
|
||||
public content::DownloadManager::Observer,
|
||||
public content::DownloadManagerDelegate,
|
||||
public CefBrowserHostImpl::Observer {
|
||||
@@ -26,24 +26,24 @@ class CefDownloadManagerDelegate : public content::DownloadItem::Observer,
|
||||
|
||||
private:
|
||||
// DownloadItem::Observer methods.
|
||||
void OnDownloadUpdated(content::DownloadItem* item) override;
|
||||
void OnDownloadDestroyed(content::DownloadItem* item) override;
|
||||
void OnDownloadUpdated(download::DownloadItem* item) override;
|
||||
void OnDownloadDestroyed(download::DownloadItem* item) override;
|
||||
|
||||
// DownloadManager::Observer methods.
|
||||
void OnDownloadCreated(content::DownloadManager* manager,
|
||||
content::DownloadItem* item) override;
|
||||
download::DownloadItem* item) override;
|
||||
void ManagerGoingDown(content::DownloadManager* manager) override;
|
||||
|
||||
// DownloadManagerDelegate methods.
|
||||
bool DetermineDownloadTarget(
|
||||
content::DownloadItem* item,
|
||||
download::DownloadItem* item,
|
||||
const content::DownloadTargetCallback& callback) override;
|
||||
void GetNextId(const content::DownloadIdCallback& callback) override;
|
||||
|
||||
// CefBrowserHostImpl::Observer methods.
|
||||
void OnBrowserDestroyed(CefBrowserHostImpl* browser) override;
|
||||
|
||||
CefBrowserHostImpl* GetBrowser(content::DownloadItem* item);
|
||||
CefBrowserHostImpl* GetBrowser(download::DownloadItem* item);
|
||||
|
||||
content::DownloadManager* manager_;
|
||||
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 is necessary because DownloadItem::GetWebContents() may return NULL if
|
||||
// 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_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefDownloadManagerDelegate);
|
||||
|
@@ -142,11 +142,11 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
|
||||
return set_init_result(SUCCESS);
|
||||
}
|
||||
|
||||
bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage() {
|
||||
bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage(std::string* error) {
|
||||
CHECK_GE(execute_tab_id_, 0);
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, &error_);
|
||||
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, error);
|
||||
if (!browser)
|
||||
return false;
|
||||
|
||||
@@ -156,7 +156,7 @@ bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage() {
|
||||
ExtensionApiFrameIdMap::GetRenderFrameHostById(browser->web_contents(),
|
||||
frame_id);
|
||||
if (!rfh) {
|
||||
error_ = ErrorUtils::FormatErrorMessage(keys::kFrameNotFoundError,
|
||||
*error = ErrorUtils::FormatErrorMessage(keys::kFrameNotFoundError,
|
||||
base::IntToString(frame_id),
|
||||
base::IntToString(execute_tab_id_));
|
||||
return false;
|
||||
@@ -181,11 +181,11 @@ bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage() {
|
||||
// NOTE: This can give the wrong answer due to race conditions, but it is OK,
|
||||
// we check again in the renderer.
|
||||
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 &&
|
||||
extension()->permissions_data()->active_permissions().HasAPIPermission(
|
||||
APIPermission::kTab)) {
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
manifest_errors::kCannotAccessAboutUrl,
|
||||
rfh->GetLastCommittedURL().spec(),
|
||||
rfh->GetLastCommittedOrigin().Serialize());
|
||||
@@ -196,11 +196,12 @@ bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
ScriptExecutor* ExecuteCodeInTabFunction::GetScriptExecutor() {
|
||||
ScriptExecutor* ExecuteCodeInTabFunction::GetScriptExecutor(
|
||||
std::string* error) {
|
||||
CHECK_GE(execute_tab_id_, 0);
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, &error_);
|
||||
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, error);
|
||||
if (!browser)
|
||||
return nullptr;
|
||||
|
||||
@@ -217,7 +218,8 @@ const GURL& ExecuteCodeInTabFunction::GetWebViewSrc() const {
|
||||
return GURL::EmptyGURL();
|
||||
}
|
||||
|
||||
bool ExecuteCodeInTabFunction::LoadFile(const std::string& file) {
|
||||
bool ExecuteCodeInTabFunction::LoadFile(const std::string& file,
|
||||
std::string* error) {
|
||||
if (cef_details_.LoadFile(
|
||||
file, base::BindOnce(&ExecuteCodeInTabFunction::LoadFileComplete,
|
||||
this, file))) {
|
||||
@@ -225,7 +227,7 @@ bool ExecuteCodeInTabFunction::LoadFile(const std::string& file) {
|
||||
}
|
||||
|
||||
// Default handling.
|
||||
return ExecuteCodeFunction::LoadFile(file);
|
||||
return ExecuteCodeFunction::LoadFile(file, error);
|
||||
}
|
||||
|
||||
void ExecuteCodeInTabFunction::LoadFileComplete(
|
||||
@@ -239,15 +241,6 @@ bool TabsExecuteScriptFunction::ShouldInsertCSS() const {
|
||||
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 {
|
||||
return true;
|
||||
}
|
||||
@@ -264,10 +257,31 @@ content::WebContents* ZoomAPIFunction::GetWebContents(int tab_id) {
|
||||
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() {
|
||||
std::unique_ptr<tabs::SetZoom::Params> params(
|
||||
tabs::SetZoom::Params::Create(*args_));
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
@@ -299,7 +313,7 @@ bool TabsSetZoomFunction::RunAsync() {
|
||||
bool TabsGetZoomFunction::RunAsync() {
|
||||
std::unique_ptr<tabs::GetZoom::Params> params(
|
||||
tabs::GetZoom::Params::Create(*args_));
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
@@ -319,7 +333,7 @@ bool TabsSetZoomSettingsFunction::RunAsync() {
|
||||
|
||||
std::unique_ptr<tabs::SetZoomSettings::Params> params(
|
||||
tabs::SetZoomSettings::Params::Create(*args_));
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
@@ -370,7 +384,7 @@ bool TabsSetZoomSettingsFunction::RunAsync() {
|
||||
bool TabsGetZoomSettingsFunction::RunAsync() {
|
||||
std::unique_ptr<tabs::GetZoomSettings::Params> params(
|
||||
tabs::GetZoomSettings::Params::Create(*args_));
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
|
@@ -55,11 +55,11 @@ class ExecuteCodeInTabFunction : public ExecuteCodeFunction {
|
||||
|
||||
// Initializes |execute_tab_id_| and |details_|.
|
||||
InitResult Init() override;
|
||||
bool CanExecuteScriptOnPage() override;
|
||||
ScriptExecutor* GetScriptExecutor() override;
|
||||
bool CanExecuteScriptOnPage(std::string* error) override;
|
||||
ScriptExecutor* GetScriptExecutor(std::string* error) override;
|
||||
bool IsWebView() 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:
|
||||
const CefExtensionFunctionDetails cef_details_;
|
||||
@@ -78,10 +78,6 @@ class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction {
|
||||
private:
|
||||
~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)
|
||||
};
|
||||
|
||||
@@ -94,7 +90,8 @@ class TabsInsertCSSFunction : public ExecuteCodeInTabFunction {
|
||||
DECLARE_EXTENSION_FUNCTION("tabs.insertCSS", TABS_INSERTCSS)
|
||||
};
|
||||
|
||||
class ZoomAPIFunction : public AsyncExtensionFunction {
|
||||
// Based on ChromeAsyncExtensionFunction.
|
||||
class ZoomAPIFunction : public UIThreadExtensionFunction {
|
||||
public:
|
||||
ZoomAPIFunction();
|
||||
|
||||
@@ -103,10 +100,26 @@ class ZoomAPIFunction : public AsyncExtensionFunction {
|
||||
|
||||
// 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
|
||||
// may set error_.
|
||||
// may set |error_|.
|
||||
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:
|
||||
ResponseAction Run() final;
|
||||
|
||||
const CefExtensionFunctionDetails cef_details_;
|
||||
};
|
||||
|
||||
|
@@ -415,36 +415,36 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::CreateTabObject(
|
||||
content::WebContents* contents = new_browser->web_contents();
|
||||
|
||||
bool is_loading = contents->IsLoading();
|
||||
auto tab_object = base::MakeUnique<api::tabs::Tab>();
|
||||
tab_object->id = base::MakeUnique<int>(new_browser->GetIdentifier());
|
||||
auto tab_object = std::make_unique<api::tabs::Tab>();
|
||||
tab_object->id = std::make_unique<int>(new_browser->GetIdentifier());
|
||||
tab_object->index = index;
|
||||
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);
|
||||
tab_object->active = active;
|
||||
tab_object->selected = true;
|
||||
tab_object->highlighted = true;
|
||||
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->auto_discardable = false;
|
||||
tab_object->muted_info = CreateMutedInfo(contents);
|
||||
tab_object->incognito = false;
|
||||
gfx::Size contents_size = contents->GetContainerBounds().size();
|
||||
tab_object->width = base::MakeUnique<int>(contents_size.width());
|
||||
tab_object->height = base::MakeUnique<int>(contents_size.height());
|
||||
tab_object->url = base::MakeUnique<std::string>(contents->GetURL().spec());
|
||||
tab_object->width = std::make_unique<int>(contents_size.width());
|
||||
tab_object->height = std::make_unique<int>(contents_size.height());
|
||||
tab_object->url = std::make_unique<std::string>(contents->GetURL().spec());
|
||||
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();
|
||||
if (entry && entry->GetFavicon().valid) {
|
||||
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)
|
||||
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;
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ void CefExtensionHostDelegate::ProcessMediaAccessRequest(
|
||||
}
|
||||
|
||||
bool CefExtensionHostDelegate::CheckMediaAccessPermission(
|
||||
content::WebContents* web_contents,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType type,
|
||||
const Extension* extension) {
|
||||
|
@@ -30,7 +30,7 @@ class CefExtensionHostDelegate : public ExtensionHostDelegate {
|
||||
const content::MediaStreamRequest& request,
|
||||
const content::MediaResponseCallback& callback,
|
||||
const Extension* extension) override;
|
||||
bool CheckMediaAccessPermission(content::WebContents* web_contents,
|
||||
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType type,
|
||||
const Extension* extension) override;
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/string_tokenizer.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task_scheduler/post_task.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
@@ -112,7 +111,7 @@ void LoadExtensionWithManifest(base::WeakPtr<CefExtensionSystem> context,
|
||||
bool internal,
|
||||
CefRefPtr<CefRequestContext> loader_context,
|
||||
CefRefPtr<CefExtensionHandler> handler) {
|
||||
base::AssertBlockingAllowed();
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> manifest =
|
||||
ParseManifest(manifest_contents);
|
||||
@@ -131,7 +130,7 @@ void LoadExtensionFromDisk(base::WeakPtr<CefExtensionSystem> context,
|
||||
bool internal,
|
||||
CefRefPtr<CefRequestContext> loader_context,
|
||||
CefRefPtr<CefExtensionHandler> handler) {
|
||||
base::AssertBlockingAllowed();
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
|
||||
base::FilePath manifest_path = root_directory.AppendASCII("manifest.json");
|
||||
std::string manifest_contents;
|
||||
@@ -239,8 +238,7 @@ void CefExtensionSystem::LoadExtension(
|
||||
CefRefPtr<CefRequestContext> loader_context,
|
||||
CefRefPtr<CefExtensionHandler> handler) {
|
||||
CEF_REQUIRE_UIT();
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()},
|
||||
CEF_POST_USER_VISIBLE_TASK(
|
||||
base::BindOnce(LoadExtensionFromDisk, weak_ptr_factory_.GetWeakPtr(),
|
||||
root_directory, internal, loader_context, handler));
|
||||
}
|
||||
@@ -252,11 +250,9 @@ void CefExtensionSystem::LoadExtension(
|
||||
CefRefPtr<CefRequestContext> loader_context,
|
||||
CefRefPtr<CefExtensionHandler> handler) {
|
||||
CEF_REQUIRE_UIT();
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()},
|
||||
base::BindOnce(LoadExtensionWithManifest, weak_ptr_factory_.GetWeakPtr(),
|
||||
manifest_contents, root_directory, internal,
|
||||
loader_context, handler));
|
||||
CEF_POST_USER_VISIBLE_TASK(base::BindOnce(
|
||||
LoadExtensionWithManifest, weak_ptr_factory_.GetWeakPtr(),
|
||||
manifest_contents, root_directory, internal, loader_context, handler));
|
||||
}
|
||||
|
||||
// Implementation based on ComponentLoader::Add.
|
||||
@@ -453,7 +449,7 @@ ContentVerifier* CefExtensionSystem::content_verifier() {
|
||||
|
||||
std::unique_ptr<ExtensionSet> CefExtensionSystem::GetDependentExtensions(
|
||||
const Extension* extension) {
|
||||
return base::MakeUnique<ExtensionSet>();
|
||||
return std::make_unique<ExtensionSet>();
|
||||
}
|
||||
|
||||
void CefExtensionSystem::InstallUpdate(
|
||||
@@ -465,6 +461,13 @@ void CefExtensionSystem::InstallUpdate(
|
||||
base::DeleteFile(temp_dir, true /* recursive */);
|
||||
}
|
||||
|
||||
bool CefExtensionSystem::FinishDelayedInstallationIfReady(
|
||||
const std::string& extension_id,
|
||||
bool install_immediately) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
CefExtensionSystem::ComponentExtensionInfo::ComponentExtensionInfo(
|
||||
const base::DictionaryValue* manifest,
|
||||
const base::FilePath& directory,
|
||||
|
@@ -115,6 +115,8 @@ class CefExtensionSystem : public ExtensionSystem {
|
||||
const std::string& public_key,
|
||||
const base::FilePath& temp_dir,
|
||||
InstallUpdateCallback install_update_callback) override;
|
||||
bool FinishDelayedInstallationIfReady(const std::string& extension_id,
|
||||
bool install_immediately) override;
|
||||
|
||||
bool initialized() const { return initialized_; }
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#include "extensions/browser/extension_system.h"
|
||||
#include "extensions/browser/notification_types.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::OpenURLParams;
|
||||
|
@@ -21,6 +21,16 @@ 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(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
ExtensionWebContentsObserver::RenderFrameCreated(render_frame_host);
|
||||
|
@@ -22,6 +22,10 @@ class CefExtensionWebContentsObserver
|
||||
public:
|
||||
~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(); }
|
||||
|
||||
private:
|
||||
|
@@ -123,6 +123,25 @@ CefExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob(
|
||||
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(
|
||||
const GURL& url,
|
||||
content::ResourceType resource_type,
|
||||
@@ -239,6 +258,11 @@ bool CefExtensionsBrowserClient::IsRunningInForcedAppMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefExtensionsBrowserClient::IsAppModeForcedForApp(
|
||||
const ExtensionId& extension_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
|
||||
return false;
|
||||
}
|
||||
|
@@ -51,6 +51,18 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
|
||||
const base::FilePath& directory_path,
|
||||
const std::string& content_security_policy,
|
||||
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,
|
||||
content::ResourceType resource_type,
|
||||
ui::PageTransition page_transition,
|
||||
@@ -73,6 +85,7 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
|
||||
bool DidVersionUpdate(content::BrowserContext* context) override;
|
||||
void PermitExternalProtocolHandler() override;
|
||||
bool IsRunningInForcedAppMode() override;
|
||||
bool IsAppModeForcedForApp(const ExtensionId& extension_id) override;
|
||||
bool IsLoggedInAsPublicAccount() override;
|
||||
ExtensionSystemProvider* GetExtensionSystemFactory() override;
|
||||
void RegisterExtensionFunctions(
|
||||
|
@@ -79,12 +79,14 @@ void CefJavaScriptDialogManager::Destroy() {
|
||||
|
||||
void CefJavaScriptDialogManager::RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
DialogClosedCallback callback,
|
||||
bool* did_suppress_message) {
|
||||
const GURL& origin_url = render_frame_host->GetLastCommittedURL();
|
||||
|
||||
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||
if (client.get()) {
|
||||
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();
|
||||
|
@@ -29,7 +29,7 @@ class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
|
||||
// JavaScriptDialogManager methods.
|
||||
void RunJavaScriptDialog(content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
|
@@ -384,4 +384,6 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateMouseEvent(
|
||||
|
||||
// timestamp
|
||||
result.SetTimeStampSeconds(GetSystemUptime());
|
||||
|
||||
result.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
|
||||
}
|
||||
|
@@ -20,9 +20,9 @@
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
||||
#include "third_party/WebKit/public/platform/WebMouseEvent.h"
|
||||
#include "third_party/WebKit/public/platform/WebMouseWheelEvent.h"
|
||||
#include "third_party/blink/public/platform/web_input_event.h"
|
||||
#include "third_party/blink/public/platform/web_mouse_event.h"
|
||||
#include "third_party/blink/public/platform/web_mouse_wheel_event.h"
|
||||
#import "ui/base/cocoa/cocoa_base_utils.h"
|
||||
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
||||
#include "ui/events/keycodes/keyboard_codes_posix.h"
|
||||
@@ -469,4 +469,6 @@ void CefBrowserPlatformDelegateNativeMac::TranslateMouseEvent(
|
||||
|
||||
// timestamp - Mac OSX specific
|
||||
result.SetTimeStampSeconds(currentEventTimestamp());
|
||||
|
||||
result.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
|
||||
}
|
||||
|
@@ -20,9 +20,10 @@
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/win/registry.h"
|
||||
#include "base/win/win_util.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "third_party/WebKit/public/platform/WebMouseEvent.h"
|
||||
#include "third_party/WebKit/public/platform/WebMouseWheelEvent.h"
|
||||
#include "third_party/blink/public/platform/web_mouse_event.h"
|
||||
#include "third_party/blink/public/platform/web_mouse_wheel_event.h"
|
||||
#include "ui/aura/window.h"
|
||||
#include "ui/base/win/shell.h"
|
||||
#include "ui/display/display.h"
|
||||
@@ -41,7 +42,7 @@
|
||||
namespace {
|
||||
|
||||
void WriteTempFileAndView(scoped_refptr<base::RefCountedString> str) {
|
||||
CEF_REQUIRE_FILET();
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
|
||||
base::FilePath tmp_file;
|
||||
if (!base::CreateTemporaryFile(&tmp_file))
|
||||
@@ -83,7 +84,7 @@ bool HasExternalHandler(const std::string& scheme) {
|
||||
}
|
||||
|
||||
void ExecuteExternalProtocol(const GURL& url) {
|
||||
CEF_REQUIRE_FILET();
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
|
||||
if (!HasExternalHandler(url.scheme()))
|
||||
return;
|
||||
@@ -95,6 +96,31 @@ void ExecuteExternalProtocol(const GURL& url) {
|
||||
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
|
||||
|
||||
CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin(
|
||||
@@ -117,40 +143,49 @@ void CefBrowserPlatformDelegateNativeWin::BrowserDestroyed(
|
||||
bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
RegisterWindowClass();
|
||||
|
||||
has_frame_ = !(window_info_.style & WS_CHILD);
|
||||
|
||||
std::wstring windowName(CefString(&window_info_.window_name));
|
||||
|
||||
// Create the new browser window.
|
||||
window_info_.window = CreateWindowEx(
|
||||
window_info_.ex_style, GetWndClass(), windowName.c_str(),
|
||||
window_info_.style, window_info_.x, window_info_.y, window_info_.width,
|
||||
window_info_.height, window_info_.parent_window, window_info_.menu,
|
||||
::GetModuleHandle(NULL), NULL);
|
||||
CreateWindowEx(window_info_.ex_style, GetWndClass(), windowName.c_str(),
|
||||
window_info_.style, window_info_.x, window_info_.y,
|
||||
window_info_.width, window_info_.height,
|
||||
window_info_.parent_window, window_info_.menu,
|
||||
::GetModuleHandle(NULL), this);
|
||||
|
||||
// It's possible for CreateWindowEx to fail if the parent window was
|
||||
// destroyed between the call to CreateBrowser and the above one.
|
||||
DCHECK(window_info_.window != NULL);
|
||||
DCHECK(window_info_.window);
|
||||
if (!window_info_.window)
|
||||
return false;
|
||||
|
||||
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().
|
||||
browser_->AddRef();
|
||||
|
||||
RECT cr;
|
||||
GetClientRect(window_info_.window, &cr);
|
||||
if (!called_enable_non_client_dpi_scaling_ && 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.
|
||||
// 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_);
|
||||
|
||||
// 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);
|
||||
float scale = display::Screen::GetScreen()
|
||||
->GetDisplayNearestPoint(point)
|
||||
.device_scale_factor();
|
||||
const float scale = GetWindowScaleFactor(window_info_.window);
|
||||
point =
|
||||
gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(point), 1.0f / scale));
|
||||
|
||||
@@ -270,26 +305,26 @@ gfx::Point CefBrowserPlatformDelegateNativeWin::GetScreenPoint(
|
||||
if (windowless_handler_)
|
||||
return windowless_handler_->GetParentScreenPoint(view);
|
||||
|
||||
if (!window_widget_)
|
||||
if (!window_info_.window)
|
||||
return view;
|
||||
|
||||
aura::Window* window = window_widget_->GetNativeView();
|
||||
const gfx::Rect& bounds_in_screen = window->GetBoundsInScreen();
|
||||
const gfx::Point& screen_point = gfx::Point(bounds_in_screen.x() + view.x(),
|
||||
bounds_in_screen.y() + view.y());
|
||||
// Convert from logical coordinates to device coordinates.
|
||||
const float scale = GetWindowScaleFactor(window_info_.window);
|
||||
const gfx::Point& device_pt =
|
||||
gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(view), scale));
|
||||
|
||||
// Adjust for potential display scaling.
|
||||
float scale = display::Screen::GetScreen()
|
||||
->GetDisplayNearestPoint(screen_point)
|
||||
.device_scale_factor();
|
||||
return gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(screen_point), scale));
|
||||
// Convert from client coordinates to screen coordinates.
|
||||
POINT screen_pt = {device_pt.x(), device_pt.y()};
|
||||
ClientToScreen(window_info_.window, &screen_pt);
|
||||
|
||||
return gfx::Point(screen_pt.x, screen_pt.y);
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::ViewText(const std::string& text) {
|
||||
std::string str = text;
|
||||
scoped_refptr<base::RefCountedString> str_ref =
|
||||
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(
|
||||
@@ -335,8 +370,7 @@ void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::HandleExternalProtocol(
|
||||
const GURL& url) {
|
||||
// Execute on the FILE thread.
|
||||
CEF_POST_TASK(CEF_FILET, base::Bind(ExecuteExternalProtocol, url));
|
||||
CEF_POST_USER_VISIBLE_TASK(base::Bind(ExecuteExternalProtocol, url));
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
|
||||
@@ -524,6 +558,8 @@ void CefBrowserPlatformDelegateNativeWin::TranslateMouseEvent(
|
||||
|
||||
// timestamp
|
||||
result.SetTimeStampSeconds(GetMessageTime() / 1000.0);
|
||||
|
||||
result.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -562,12 +598,15 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
CefBrowserPlatformDelegateNativeWin* platform_delegate =
|
||||
static_cast<CefBrowserPlatformDelegateNativeWin*>(
|
||||
gfx::GetWindowUserData(hwnd));
|
||||
CefBrowserPlatformDelegateNativeWin* platform_delegate = 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) {
|
||||
case WM_CLOSE:
|
||||
@@ -579,6 +618,31 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
|
||||
// Allow the close.
|
||||
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:
|
||||
if (platform_delegate) {
|
||||
// Clear the user data pointer.
|
||||
@@ -617,6 +681,17 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
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);
|
||||
|
@@ -68,6 +68,9 @@ class CefBrowserPlatformDelegateNativeWin
|
||||
// Widget hosting the web contents. It will be deleted automatically when the
|
||||
// associated root window is destroyed.
|
||||
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_
|
||||
|
@@ -647,7 +647,7 @@ void CefNativeMenuWin::AddMenuItemAt(int menu_index, int model_index) {
|
||||
else
|
||||
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();
|
||||
ui::MenuModel::ItemType type = model_->GetTypeAt(model_index);
|
||||
if (type == ui::MenuModel::TYPE_SUBMENU) {
|
||||
@@ -676,7 +676,7 @@ void CefNativeMenuWin::AddSeparatorItemAt(int menu_index, int model_index) {
|
||||
mii.fType = MFT_SEPARATOR;
|
||||
// Insert a dummy entry into our label list so we can index directly into it
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ const char kNetWMPing[] = "_NET_WM_PING";
|
||||
const char kNetWMState[] = "_NET_WM_STATE";
|
||||
const char kXdndProxy[] = "XdndProxy";
|
||||
|
||||
::Window FindEventTarget(const base::NativeEvent& xev) {
|
||||
::Window FindEventTarget(const ui::PlatformEvent& xev) {
|
||||
::Window target = xev->xany.window;
|
||||
if (xev->type == GenericEvent)
|
||||
target = static_cast<XIDeviceEvent*>(xev->xcookie.data)->event;
|
||||
@@ -333,7 +333,7 @@ uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FocusIn:
|
||||
case x11::FocusIn:
|
||||
// This message is received first followed by a "_NET_ACTIVE_WINDOW"
|
||||
// message sent to the root window. When X11DesktopHandler handles the
|
||||
// "_NET_ACTIVE_WINDOW" message it will erroneously mark the WebView
|
||||
@@ -347,7 +347,7 @@ uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
|
||||
100);
|
||||
}
|
||||
break;
|
||||
case FocusOut:
|
||||
case x11::FocusOut:
|
||||
// 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
|
||||
// a focus change loop.
|
||||
|
@@ -72,7 +72,6 @@ const char* kAllowedWebUIHosts[] = {
|
||||
chrome::kChromeUINetInternalsHost,
|
||||
content::kChromeUINetworkErrorHost,
|
||||
content::kChromeUINetworkErrorsListingHost,
|
||||
content::kChromeUINetworkViewCacheHost,
|
||||
content::kChromeUIResourcesHost,
|
||||
content::kChromeUIServiceWorkerInternalsHost,
|
||||
chrome::kChromeUISystemInfoHost,
|
||||
@@ -794,6 +793,7 @@ void DidFinishChromeLoad(CefRefPtr<CefFrame> frame, const GURL& validated_url) {
|
||||
switch (host_id) {
|
||||
case CHROME_VERSION:
|
||||
DidFinishChromeVersionLoad(frame);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@@ -11,6 +11,38 @@
|
||||
#include "base/logging.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(
|
||||
CefURLRequestContextImpl* parent,
|
||||
CefRefPtr<CefRequestContextHandler> handler)
|
||||
@@ -33,6 +65,8 @@ void CefCookieStoreProxy::SetCookieWithOptionsAsync(
|
||||
if (cookie_store) {
|
||||
cookie_store->SetCookieWithOptionsAsync(url, cookie_line, options,
|
||||
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,
|
||||
modify_http_only,
|
||||
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(
|
||||
const GURL& url,
|
||||
const net::CookieOptions& options,
|
||||
GetCookieListCallback callback) {
|
||||
net::CookieStore* cookie_store = GetCookieStore();
|
||||
if (cookie_store)
|
||||
if (cookie_store) {
|
||||
cookie_store->GetCookieListWithOptionsAsync(url, options,
|
||||
std::move(callback));
|
||||
} else if (!callback.is_null()) {
|
||||
std::move(callback).Run(net::CookieList());
|
||||
}
|
||||
}
|
||||
|
||||
void CefCookieStoreProxy::GetAllCookiesAsync(GetCookieListCallback callback) {
|
||||
net::CookieStore* cookie_store = GetCookieStore();
|
||||
if (cookie_store)
|
||||
if (cookie_store) {
|
||||
cookie_store->GetAllCookiesAsync(std::move(callback));
|
||||
} else if (!callback.is_null()) {
|
||||
std::move(callback).Run(net::CookieList());
|
||||
}
|
||||
}
|
||||
|
||||
void CefCookieStoreProxy::DeleteCookieAsync(const GURL& url,
|
||||
const std::string& cookie_name,
|
||||
base::OnceClosure callback) {
|
||||
net::CookieStore* cookie_store = GetCookieStore();
|
||||
if (cookie_store)
|
||||
if (cookie_store) {
|
||||
cookie_store->DeleteCookieAsync(url, cookie_name, std::move(callback));
|
||||
} else if (!callback.is_null()) {
|
||||
std::move(callback).Run();
|
||||
}
|
||||
}
|
||||
|
||||
void CefCookieStoreProxy::DeleteCanonicalCookieAsync(
|
||||
const net::CanonicalCookie& cookie,
|
||||
DeleteCallback callback) {
|
||||
net::CookieStore* cookie_store = GetCookieStore();
|
||||
if (cookie_store)
|
||||
if (cookie_store) {
|
||||
cookie_store->DeleteCanonicalCookieAsync(cookie, std::move(callback));
|
||||
} else if (!callback.is_null()) {
|
||||
std::move(callback).Run(0);
|
||||
}
|
||||
}
|
||||
|
||||
void CefCookieStoreProxy::DeleteAllCreatedBetweenAsync(
|
||||
@@ -98,6 +137,8 @@ void CefCookieStoreProxy::DeleteAllCreatedBetweenAsync(
|
||||
if (cookie_store) {
|
||||
cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end,
|
||||
std::move(callback));
|
||||
} else if (!callback.is_null()) {
|
||||
std::move(callback).Run(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,39 +151,37 @@ void CefCookieStoreProxy::DeleteAllCreatedBetweenWithPredicateAsync(
|
||||
if (cookie_store) {
|
||||
cookie_store->DeleteAllCreatedBetweenWithPredicateAsync(
|
||||
delete_begin, delete_end, predicate, std::move(callback));
|
||||
} else if (!callback.is_null()) {
|
||||
std::move(callback).Run(0);
|
||||
}
|
||||
}
|
||||
|
||||
void CefCookieStoreProxy::DeleteSessionCookiesAsync(DeleteCallback callback) {
|
||||
net::CookieStore* cookie_store = GetCookieStore();
|
||||
if (cookie_store)
|
||||
if (cookie_store) {
|
||||
cookie_store->DeleteSessionCookiesAsync(std::move(callback));
|
||||
} else if (!callback.is_null()) {
|
||||
std::move(callback).Run(0);
|
||||
}
|
||||
}
|
||||
|
||||
void CefCookieStoreProxy::FlushStore(base::OnceClosure callback) {
|
||||
net::CookieStore* cookie_store = GetCookieStore();
|
||||
if (cookie_store)
|
||||
if (cookie_store) {
|
||||
cookie_store->FlushStore(std::move(callback));
|
||||
} else if (!callback.is_null()) {
|
||||
std::move(callback).Run();
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<net::CookieStore::CookieChangedSubscription>
|
||||
CefCookieStoreProxy::AddCallbackForCookie(
|
||||
const GURL& url,
|
||||
const std::string& name,
|
||||
const CookieChangedCallback& callback) {
|
||||
net::CookieChangeDispatcher& CefCookieStoreProxy::GetChangeDispatcher() {
|
||||
net::CookieStore* cookie_store = GetCookieStore();
|
||||
if (cookie_store)
|
||||
return cookie_store->AddCallbackForCookie(url, name, callback);
|
||||
return nullptr;
|
||||
}
|
||||
return cookie_store->GetChangeDispatcher();
|
||||
|
||||
std::unique_ptr<net::CookieStore::CookieChangedSubscription>
|
||||
CefCookieStoreProxy::AddCallbackForAllChanges(
|
||||
const CookieChangedCallback& callback) {
|
||||
net::CookieStore* cookie_store = GetCookieStore();
|
||||
if (cookie_store)
|
||||
return cookie_store->AddCallbackForAllChanges(callback);
|
||||
return nullptr;
|
||||
if (!null_dispatcher_)
|
||||
null_dispatcher_.reset(new NullCookieChangeDispatcher());
|
||||
return *null_dispatcher_;
|
||||
}
|
||||
|
||||
bool CefCookieStoreProxy::IsEphemeral() {
|
||||
@@ -155,25 +194,23 @@ bool CefCookieStoreProxy::IsEphemeral() {
|
||||
net::CookieStore* CefCookieStoreProxy::GetCookieStore() {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
net::CookieStore* cookie_store = nullptr;
|
||||
|
||||
CefRefPtr<CefCookieManager> manager = handler_->GetCookieManager();
|
||||
if (manager.get()) {
|
||||
// Use the cookie store provided by the manager.
|
||||
cookie_store = reinterpret_cast<CefCookieManagerImpl*>(manager.get())
|
||||
->GetExistingCookieStore();
|
||||
DCHECK(cookie_store);
|
||||
return cookie_store;
|
||||
// Use the cookie store provided by the manager. May be nullptr if the
|
||||
// cookie manager is blocking.
|
||||
return reinterpret_cast<CefCookieManagerImpl*>(manager.get())
|
||||
->GetExistingCookieStore();
|
||||
}
|
||||
|
||||
DCHECK(parent_);
|
||||
if (parent_) {
|
||||
// Use the cookie store from the parent.
|
||||
cookie_store = parent_->cookie_store();
|
||||
net::CookieStore* cookie_store = parent_->cookie_store();
|
||||
DCHECK(cookie_store);
|
||||
if (!cookie_store)
|
||||
LOG(ERROR) << "Cookie store does not exist";
|
||||
return cookie_store;
|
||||
}
|
||||
|
||||
return cookie_store;
|
||||
return nullptr;
|
||||
}
|
||||
|
@@ -30,9 +30,6 @@ class CefCookieStoreProxy : public net::CookieStore {
|
||||
bool secure_source,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) override;
|
||||
void GetCookiesWithOptionsAsync(const GURL& url,
|
||||
const net::CookieOptions& options,
|
||||
GetCookiesCallback callback) override;
|
||||
void GetCookieListWithOptionsAsync(const GURL& url,
|
||||
const net::CookieOptions& options,
|
||||
GetCookieListCallback callback) override;
|
||||
@@ -52,12 +49,7 @@ class CefCookieStoreProxy : public net::CookieStore {
|
||||
DeleteCallback callback) override;
|
||||
void DeleteSessionCookiesAsync(DeleteCallback callback) override;
|
||||
void FlushStore(base::OnceClosure callback) override;
|
||||
std::unique_ptr<CookieChangedSubscription> AddCallbackForCookie(
|
||||
const GURL& url,
|
||||
const std::string& name,
|
||||
const CookieChangedCallback& callback) override;
|
||||
std::unique_ptr<CookieChangedSubscription> AddCallbackForAllChanges(
|
||||
const CookieChangedCallback& callback) override;
|
||||
net::CookieChangeDispatcher& GetChangeDispatcher() override;
|
||||
bool IsEphemeral() override;
|
||||
|
||||
private:
|
||||
@@ -68,6 +60,8 @@ class CefCookieStoreProxy : public net::CookieStore {
|
||||
CefURLRequestContextImpl* parent_;
|
||||
CefRefPtr<CefRequestContextHandler> handler_;
|
||||
|
||||
std::unique_ptr<net::CookieChangeDispatcher> null_dispatcher_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy);
|
||||
};
|
||||
|
||||
|
@@ -9,10 +9,8 @@
|
||||
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/task_scheduler/post_task.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "net/cert/crl_set.h"
|
||||
#include "net/cert/crl_set_storage.h"
|
||||
#include "net/ssl/ssl_config_service.h"
|
||||
|
||||
namespace {
|
||||
@@ -25,7 +23,7 @@ void SetCRLSetIfNewer(scoped_refptr<net::CRLSet> crl_set) {
|
||||
}
|
||||
|
||||
void LoadFromDisk(const base::FilePath& path) {
|
||||
base::AssertBlockingAllowed();
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
|
||||
std::string 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;
|
||||
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();
|
||||
return;
|
||||
}
|
||||
@@ -51,7 +49,5 @@ void CefLoadCRLSetsFile(const CefString& path) {
|
||||
return;
|
||||
}
|
||||
|
||||
base::PostTaskWithTraits(FROM_HERE,
|
||||
{base::TaskPriority::BACKGROUND, base::MayBlock()},
|
||||
base::BindOnce(&LoadFromDisk, path));
|
||||
CEF_POST_USER_VISIBLE_TASK(base::BindOnce(&LoadFromDisk, path));
|
||||
}
|
||||
|
@@ -272,7 +272,7 @@ std::unique_ptr<net::SourceStream> CefNetworkDelegate::CreateSourceStream(
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -328,6 +328,22 @@ bool CefResourceRequestJob::GetMimeType(std::string* mime_type) const {
|
||||
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() {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
@@ -403,7 +419,7 @@ void CefResourceRequestJob::AddCookieHeaderAndStart() {
|
||||
void CefResourceRequestJob::DoLoadCookies() {
|
||||
net::CookieOptions options;
|
||||
options.set_include_httponly();
|
||||
request_->context()->cookie_store()->GetCookiesWithOptionsAsync(
|
||||
request_->context()->cookie_store()->GetCookieListWithOptionsAsync(
|
||||
request_->url(), options,
|
||||
base::Bind(&CefResourceRequestJob::OnCookiesLoaded,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
@@ -430,8 +446,11 @@ void CefResourceRequestJob::CheckCookiePolicyAndLoad(
|
||||
DoStartTransaction();
|
||||
}
|
||||
|
||||
void CefResourceRequestJob::OnCookiesLoaded(const std::string& cookie_line) {
|
||||
if (!cookie_line.empty()) {
|
||||
void CefResourceRequestJob::OnCookiesLoaded(
|
||||
const net::CookieList& cookie_list) {
|
||||
if (!cookie_list.empty()) {
|
||||
const std::string& cookie_line =
|
||||
net::CanonicalCookie::BuildCookieLine(cookie_list);
|
||||
CefRequest::HeaderMap headerMap;
|
||||
cef_request_->GetHeaderMap(headerMap);
|
||||
headerMap.insert(
|
||||
|
@@ -20,7 +20,7 @@
|
||||
namespace net {
|
||||
class HttpResponseHeaders;
|
||||
class URLRequest;
|
||||
}
|
||||
} // namespace net
|
||||
|
||||
class CefResourceRequestJobCallback;
|
||||
|
||||
@@ -40,6 +40,8 @@ class CefResourceRequestJob : public net::URLRequestJob {
|
||||
void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override;
|
||||
bool IsRedirectResponse(GURL* location, int* http_status_code) override;
|
||||
bool GetMimeType(std::string* mime_type) const override;
|
||||
bool GetCharset(std::string* charset) override;
|
||||
int GetResponseCode() const override;
|
||||
|
||||
void SendHeaders();
|
||||
|
||||
@@ -47,7 +49,7 @@ class CefResourceRequestJob : public net::URLRequestJob {
|
||||
void AddCookieHeaderAndStart();
|
||||
void DoLoadCookies();
|
||||
void CheckCookiePolicyAndLoad(const net::CookieList& cookie_list);
|
||||
void OnCookiesLoaded(const std::string& cookie_line);
|
||||
void OnCookiesLoaded(const net::CookieList& cookie_list);
|
||||
void DoStartTransaction();
|
||||
void StartTransaction();
|
||||
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#include "base/task_scheduler/post_task.h"
|
||||
#include "content/public/browser/browser_thread.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/file_protocol_handler.h"
|
||||
#include "net/url_request/ftp_protocol_handler.h"
|
||||
@@ -29,19 +29,16 @@ void InstallInternalProtectedHandlers(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
net::HostResolver* host_resolver) {
|
||||
protocol_handlers->insert(std::make_pair(
|
||||
url::kDataScheme, linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
|
||||
new net::DataProtocolHandler)));
|
||||
url::kDataScheme, std::make_unique<net::DataProtocolHandler>()));
|
||||
protocol_handlers->insert(std::make_pair(
|
||||
url::kFileScheme,
|
||||
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
|
||||
new net::FileProtocolHandler(base::CreateTaskRunnerWithTraits(
|
||||
{base::MayBlock(), base::TaskPriority::BACKGROUND,
|
||||
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})))));
|
||||
std::make_unique<net::FileProtocolHandler>(
|
||||
base::CreateTaskRunnerWithTraits(
|
||||
{base::MayBlock(), base::TaskPriority::USER_VISIBLE,
|
||||
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}))));
|
||||
#if !BUILDFLAG(DISABLE_FTP_SUPPORT)
|
||||
protocol_handlers->insert(std::make_pair(
|
||||
url::kFtpScheme,
|
||||
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
|
||||
net::FtpProtocolHandler::Create(host_resolver).release())));
|
||||
url::kFtpScheme, net::FtpProtocolHandler::Create(host_resolver)));
|
||||
#endif
|
||||
|
||||
for (content::ProtocolHandlerMap::iterator it = protocol_handlers->begin();
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "libcef/browser/content_browser_client.h"
|
||||
#include "libcef/browser/cookie_manager_impl.h"
|
||||
#include "libcef/browser/net/network_delegate.h"
|
||||
#include "libcef/browser/net/scheme_handler.h"
|
||||
@@ -31,7 +32,6 @@
|
||||
#include "components/network_session_configurator/browser/network_session_configurator.h"
|
||||
#include "components/prefs/pref_registry_simple.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "content/network/proxy_service_mojo.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
@@ -51,9 +51,9 @@
|
||||
#include "net/http/http_server_properties_impl.h"
|
||||
#include "net/http/http_util.h"
|
||||
#include "net/http/transport_security_state.h"
|
||||
#include "net/proxy/dhcp_proxy_script_fetcher_factory.h"
|
||||
#include "net/proxy/proxy_script_fetcher_impl.h"
|
||||
#include "net/proxy/proxy_service.h"
|
||||
#include "net/proxy_resolution/dhcp_pac_file_fetcher_factory.h"
|
||||
#include "net/proxy_resolution/pac_file_fetcher_impl.h"
|
||||
#include "net/proxy_resolution/proxy_resolution_service.h"
|
||||
#include "net/ssl/ssl_config_service_defaults.h"
|
||||
#include "net/url_request/http_user_agent_settings.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_job_factory_impl.h"
|
||||
#include "net/url_request/url_request_job_manager.h"
|
||||
#include "services/network/proxy_service_mojo.h"
|
||||
#include "url/url_constants.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -108,9 +109,9 @@ class CefHttpUserAgentSettings : public net::HttpUserAgentSettings {
|
||||
DISALLOW_COPY_AND_ASSIGN(CefHttpUserAgentSettings);
|
||||
};
|
||||
|
||||
// Based on ProxyServiceFactory::CreateProxyService which was deleted in
|
||||
// http://crrev.com/1c261ff4.
|
||||
std::unique_ptr<net::ProxyService> CreateProxyService(
|
||||
// Based on ProxyResolutionServiceFactory::CreateProxyResolutionService which
|
||||
// was deleted in http://crrev.com/1c261ff4.
|
||||
std::unique_ptr<net::ProxyResolutionService> CreateProxyResolutionService(
|
||||
net::NetLog* net_log,
|
||||
net::URLRequestContext* context,
|
||||
net::NetworkDelegate* network_delegate,
|
||||
@@ -129,27 +130,27 @@ std::unique_ptr<net::ProxyService> CreateProxyService(
|
||||
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) {
|
||||
std::unique_ptr<net::DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher;
|
||||
net::DhcpProxyScriptFetcherFactory dhcp_factory;
|
||||
dhcp_proxy_script_fetcher = dhcp_factory.Create(context);
|
||||
std::unique_ptr<net::DhcpPacFileFetcher> dhcp_pac_file_fetcher;
|
||||
net::DhcpPacFileFetcherFactory dhcp_factory;
|
||||
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),
|
||||
base::MakeUnique<net::ProxyScriptFetcherImpl>(context),
|
||||
std::move(dhcp_proxy_script_fetcher), context->host_resolver(), net_log,
|
||||
std::make_unique<net::PacFileFetcherImpl>(context),
|
||||
std::move(dhcp_pac_file_fetcher), context->host_resolver(), net_log,
|
||||
network_delegate);
|
||||
} else {
|
||||
proxy_service = net::ProxyService::CreateUsingSystemProxyResolver(
|
||||
proxy_service = net::ProxyResolutionService::CreateUsingSystemProxyResolver(
|
||||
std::move(proxy_config_service), net_log);
|
||||
}
|
||||
|
||||
proxy_service->set_quick_check_enabled(quick_check_enabled);
|
||||
proxy_service->set_sanitize_url_policy(
|
||||
pac_https_url_stripping_enabled
|
||||
? net::ProxyService::SanitizeUrlPolicy::SAFE
|
||||
: net::ProxyService::SanitizeUrlPolicy::UNSAFE);
|
||||
? net::ProxyResolutionService::SanitizeUrlPolicy::SAFE
|
||||
: net::ProxyResolutionService::SanitizeUrlPolicy::UNSAFE);
|
||||
|
||||
return proxy_service;
|
||||
}
|
||||
@@ -163,7 +164,7 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
std::unique_ptr<net::ProxyConfigService> proxy_config_service,
|
||||
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.
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
@@ -246,9 +247,9 @@ void CefURLRequestContextGetterImpl::ShutdownOnIOThread() {
|
||||
|
||||
shutting_down_ = true;
|
||||
|
||||
// Delete the ProxyService object here so that any pending requests will be
|
||||
// canceled before the URLRequestContext is destroyed.
|
||||
io_state_->storage_->set_proxy_service(NULL);
|
||||
// Delete the ProxyResolutionService object here so that any pending requests
|
||||
// will be canceled before the URLRequestContext is destroyed.
|
||||
io_state_->storage_->set_proxy_resolution_service(NULL);
|
||||
|
||||
io_state_.reset();
|
||||
|
||||
@@ -315,15 +316,16 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
|
||||
settings_.enable_net_security_expiration ? true : false);
|
||||
io_state_->storage_->set_ct_policy_enforcer(std::move(ct_policy_enforcer));
|
||||
|
||||
std::unique_ptr<net::ProxyService> system_proxy_service =
|
||||
CreateProxyService(io_state_->net_log_,
|
||||
io_state_->url_request_context_.get(),
|
||||
io_state_->url_request_context_->network_delegate(),
|
||||
std::move(io_state_->proxy_resolver_factory_),
|
||||
std::move(io_state_->proxy_config_service_),
|
||||
*command_line, quick_check_enabled_.GetValue(),
|
||||
pac_https_url_stripping_enabled_.GetValue());
|
||||
io_state_->storage_->set_proxy_service(std::move(system_proxy_service));
|
||||
std::unique_ptr<net::ProxyResolutionService> system_proxy_service =
|
||||
CreateProxyResolutionService(
|
||||
io_state_->net_log_, io_state_->url_request_context_.get(),
|
||||
io_state_->url_request_context_->network_delegate(),
|
||||
std::move(io_state_->proxy_resolver_factory_),
|
||||
std::move(io_state_->proxy_config_service_), *command_line,
|
||||
quick_check_enabled_.GetValue(),
|
||||
pac_https_url_stripping_enabled_.GetValue());
|
||||
io_state_->storage_->set_proxy_resolution_service(
|
||||
std::move(system_proxy_service));
|
||||
|
||||
io_state_->storage_->set_ssl_config_service(
|
||||
new net::SSLConfigServiceDefaults);
|
||||
@@ -372,8 +374,8 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
|
||||
io_state_->url_request_context_->cert_transparency_verifier();
|
||||
network_session_context.ct_policy_enforcer =
|
||||
io_state_->url_request_context_->ct_policy_enforcer();
|
||||
network_session_context.proxy_service =
|
||||
io_state_->url_request_context_->proxy_service();
|
||||
network_session_context.proxy_resolution_service =
|
||||
io_state_->url_request_context_->proxy_resolution_service();
|
||||
network_session_context.ssl_config_service =
|
||||
io_state_->url_request_context_->ssl_config_service();
|
||||
network_session_context.http_auth_handler_factory =
|
||||
@@ -414,7 +416,7 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
|
||||
scheme::RegisterInternalHandlers(io_state_->url_request_manager_.get());
|
||||
|
||||
io_state_->request_interceptors_.push_back(
|
||||
base::MakeUnique<CefRequestInterceptor>());
|
||||
std::make_unique<CefRequestInterceptor>());
|
||||
|
||||
// Set up interceptors in the reverse order.
|
||||
std::unique_ptr<net::URLRequestJobFactory> top_job_factory =
|
||||
@@ -472,7 +474,10 @@ void CefURLRequestContextGetterImpl::SetCookieStoragePath(
|
||||
const base::FilePath& cookie_path = path.AppendASCII("Cookies");
|
||||
persistent_store = new net::SQLitePersistentCookieStore(
|
||||
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);
|
||||
} else {
|
||||
NOTREACHED() << "The cookie storage directory could not be created";
|
||||
|
@@ -28,7 +28,7 @@ CefURLRequestContextProxy::CefURLRequestContextProxy(
|
||||
set_cert_transparency_verifier(parent->cert_transparency_verifier());
|
||||
set_ct_policy_enforcer(parent->ct_policy_enforcer());
|
||||
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_http_auth_handler_factory(parent->http_auth_handler_factory());
|
||||
set_http_transaction_factory(parent->http_transaction_factory());
|
||||
|
@@ -12,7 +12,8 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/stringprintf.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_tree_update.h"
|
||||
#include "ui/gfx/transform.h"
|
||||
@@ -39,9 +40,10 @@ CefRefPtr<CefListValue> ToCefValue(uint32_t state) {
|
||||
|
||||
int index = 0;
|
||||
// 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))
|
||||
value->SetString(index++, ToString(static_cast<ui::AXState>(i)));
|
||||
value->SetString(index++, ToString(static_cast<ax::mojom::State>(i)));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -65,127 +67,124 @@ struct PopulateAxNodeAttributes {
|
||||
: attributes(attrs) {}
|
||||
|
||||
// Int Attributes
|
||||
void operator()(const std::pair<ui::AXIntAttribute, int32_t> attr) {
|
||||
if (attr.first == ui::AX_INT_ATTRIBUTE_NONE)
|
||||
void operator()(const std::pair<ax::mojom::IntAttribute, int32_t> attr) {
|
||||
if (attr.first == ax::mojom::IntAttribute::kNone)
|
||||
return;
|
||||
|
||||
switch (attr.first) {
|
||||
case ui::AX_INT_ATTRIBUTE_NONE:
|
||||
case ax::mojom::IntAttribute::kNone:
|
||||
break;
|
||||
case ui::AX_ATTR_SCROLL_X:
|
||||
case ui::AX_ATTR_SCROLL_X_MIN:
|
||||
case ui::AX_ATTR_SCROLL_X_MAX:
|
||||
case ui::AX_ATTR_SCROLL_Y:
|
||||
case ui::AX_ATTR_SCROLL_Y_MIN:
|
||||
case ui::AX_ATTR_SCROLL_Y_MAX:
|
||||
case ui::AX_ATTR_HIERARCHICAL_LEVEL:
|
||||
case ui::AX_ATTR_TEXT_SEL_START:
|
||||
case ui::AX_ATTR_TEXT_SEL_END:
|
||||
case ui::AX_ATTR_ARIA_COLUMN_COUNT:
|
||||
case ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX:
|
||||
case ui::AX_ATTR_ARIA_ROW_COUNT:
|
||||
case ui::AX_ATTR_ARIA_CELL_ROW_INDEX:
|
||||
case ui::AX_ATTR_TABLE_ROW_COUNT:
|
||||
case ui::AX_ATTR_TABLE_COLUMN_COUNT:
|
||||
case ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX:
|
||||
case ui::AX_ATTR_TABLE_CELL_ROW_INDEX:
|
||||
case ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN:
|
||||
case ui::AX_ATTR_TABLE_CELL_ROW_SPAN:
|
||||
case ui::AX_ATTR_TABLE_COLUMN_HEADER_ID:
|
||||
case ui::AX_ATTR_TABLE_COLUMN_INDEX:
|
||||
case ui::AX_ATTR_TABLE_HEADER_ID:
|
||||
case ui::AX_ATTR_TABLE_ROW_HEADER_ID:
|
||||
case ui::AX_ATTR_TABLE_ROW_INDEX:
|
||||
case ui::AX_ATTR_ACTIVEDESCENDANT_ID:
|
||||
case ui::AX_ATTR_IN_PAGE_LINK_TARGET_ID:
|
||||
case ui::AX_ATTR_ERRORMESSAGE_ID:
|
||||
case ui::AX_ATTR_DETAILS_ID:
|
||||
case ui::AX_ATTR_MEMBER_OF_ID:
|
||||
case ui::AX_ATTR_NEXT_FOCUS_ID:
|
||||
case ui::AX_ATTR_NEXT_ON_LINE_ID:
|
||||
case ui::AX_ATTR_PREVIOUS_FOCUS_ID:
|
||||
case ui::AX_ATTR_PREVIOUS_ON_LINE_ID:
|
||||
case ui::AX_ATTR_CHILD_TREE_ID:
|
||||
case ui::AX_ATTR_SET_SIZE:
|
||||
case ui::AX_ATTR_POS_IN_SET:
|
||||
case ax::mojom::IntAttribute::kScrollX:
|
||||
case ax::mojom::IntAttribute::kScrollXMin:
|
||||
case ax::mojom::IntAttribute::kScrollXMax:
|
||||
case ax::mojom::IntAttribute::kScrollY:
|
||||
case ax::mojom::IntAttribute::kScrollYMin:
|
||||
case ax::mojom::IntAttribute::kScrollYMax:
|
||||
case ax::mojom::IntAttribute::kHierarchicalLevel:
|
||||
case ax::mojom::IntAttribute::kTextSelStart:
|
||||
case ax::mojom::IntAttribute::kTextSelEnd:
|
||||
case ax::mojom::IntAttribute::kAriaColumnCount:
|
||||
case ax::mojom::IntAttribute::kAriaCellColumnIndex:
|
||||
case ax::mojom::IntAttribute::kAriaRowCount:
|
||||
case ax::mojom::IntAttribute::kAriaCellRowIndex:
|
||||
case ax::mojom::IntAttribute::kTableRowCount:
|
||||
case ax::mojom::IntAttribute::kTableColumnCount:
|
||||
case ax::mojom::IntAttribute::kTableCellColumnIndex:
|
||||
case ax::mojom::IntAttribute::kTableCellRowIndex:
|
||||
case ax::mojom::IntAttribute::kTableCellColumnSpan:
|
||||
case ax::mojom::IntAttribute::kTableCellRowSpan:
|
||||
case ax::mojom::IntAttribute::kTableColumnHeaderId:
|
||||
case ax::mojom::IntAttribute::kTableColumnIndex:
|
||||
case ax::mojom::IntAttribute::kTableHeaderId:
|
||||
case ax::mojom::IntAttribute::kTableRowHeaderId:
|
||||
case ax::mojom::IntAttribute::kTableRowIndex:
|
||||
case ax::mojom::IntAttribute::kActivedescendantId:
|
||||
case ax::mojom::IntAttribute::kInPageLinkTargetId:
|
||||
case ax::mojom::IntAttribute::kErrormessageId:
|
||||
case ax::mojom::IntAttribute::kDetailsId:
|
||||
case ax::mojom::IntAttribute::kMemberOfId:
|
||||
case ax::mojom::IntAttribute::kNextFocusId:
|
||||
case ax::mojom::IntAttribute::kNextOnLineId:
|
||||
case ax::mojom::IntAttribute::kPreviousFocusId:
|
||||
case ax::mojom::IntAttribute::kPreviousOnLineId:
|
||||
case ax::mojom::IntAttribute::kChildTreeId:
|
||||
case ax::mojom::IntAttribute::kSetSize:
|
||||
case ax::mojom::IntAttribute::kPosInSet:
|
||||
attributes->SetInt(ToString(attr.first), attr.second);
|
||||
break;
|
||||
case ui::AX_ATTR_DEFAULT_ACTION_VERB:
|
||||
case ax::mojom::IntAttribute::kDefaultActionVerb:
|
||||
attributes->SetString(
|
||||
ToString(attr.first),
|
||||
ui::ActionVerbToUnlocalizedString(
|
||||
static_cast<ui::AXDefaultActionVerb>(attr.second)));
|
||||
static_cast<ax::mojom::DefaultActionVerb>(attr.second)));
|
||||
break;
|
||||
case ui::AX_ATTR_INVALID_STATE:
|
||||
if (ui::AX_INVALID_STATE_NONE != attr.second) {
|
||||
attributes->SetString(
|
||||
ToString(attr.first),
|
||||
ToString(static_cast<ui::AXInvalidState>(attr.second)));
|
||||
case ax::mojom::IntAttribute::kInvalidState: {
|
||||
auto state = static_cast<ax::mojom::InvalidState>(attr.second);
|
||||
if (ax::mojom::InvalidState::kNone != state) {
|
||||
attributes->SetString(ToString(attr.first), ToString(state));
|
||||
}
|
||||
break;
|
||||
case ui::AX_ATTR_CHECKED_STATE:
|
||||
if (ui::AX_CHECKED_STATE_NONE != attr.second) {
|
||||
attributes->SetString(
|
||||
ToString(attr.first),
|
||||
ToString(static_cast<ui::AXCheckedState>(attr.second)));
|
||||
} break;
|
||||
case ax::mojom::IntAttribute::kCheckedState: {
|
||||
auto state = static_cast<ax::mojom::CheckedState>(attr.second);
|
||||
if (ax::mojom::CheckedState::kNone != state) {
|
||||
attributes->SetString(ToString(attr.first), ToString(state));
|
||||
}
|
||||
break;
|
||||
case ui::AX_ATTR_RESTRICTION:
|
||||
} break;
|
||||
case ax::mojom::IntAttribute::kRestriction:
|
||||
attributes->SetString(
|
||||
ToString(attr.first),
|
||||
ToString(static_cast<ui::AXRestriction>(attr.second)));
|
||||
ToString(static_cast<ax::mojom::Restriction>(attr.second)));
|
||||
break;
|
||||
case ui::AX_ATTR_SORT_DIRECTION:
|
||||
if (ui::AX_SORT_DIRECTION_NONE != attr.second) {
|
||||
attributes->SetString(
|
||||
ToString(attr.first),
|
||||
ToString(static_cast<ui::AXSortDirection>(attr.second)));
|
||||
case ax::mojom::IntAttribute::kSortDirection: {
|
||||
auto state = static_cast<ax::mojom::SortDirection>(attr.second);
|
||||
if (ax::mojom::SortDirection::kNone != state) {
|
||||
attributes->SetString(ToString(attr.first), ToString(state));
|
||||
}
|
||||
break;
|
||||
case ui::AX_ATTR_NAME_FROM:
|
||||
} break;
|
||||
case ax::mojom::IntAttribute::kNameFrom:
|
||||
attributes->SetString(
|
||||
ToString(attr.first),
|
||||
ToString(static_cast<ui::AXNameFrom>(attr.second)));
|
||||
ToString(static_cast<ax::mojom::NameFrom>(attr.second)));
|
||||
break;
|
||||
case ui::AX_ATTR_COLOR_VALUE:
|
||||
case ui::AX_ATTR_BACKGROUND_COLOR:
|
||||
case ui::AX_ATTR_COLOR:
|
||||
case ax::mojom::IntAttribute::kColorValue:
|
||||
case ax::mojom::IntAttribute::kBackgroundColor:
|
||||
case ax::mojom::IntAttribute::kColor:
|
||||
attributes->SetString(ToString(attr.first),
|
||||
base::StringPrintf("0x%X", attr.second));
|
||||
break;
|
||||
case ui::AX_ATTR_DESCRIPTION_FROM:
|
||||
case ax::mojom::IntAttribute::kDescriptionFrom:
|
||||
attributes->SetString(
|
||||
ToString(attr.first),
|
||||
ToString(static_cast<ui::AXDescriptionFrom>(attr.second)));
|
||||
ToString(static_cast<ax::mojom::DescriptionFrom>(attr.second)));
|
||||
break;
|
||||
case ui::AX_ATTR_ARIA_CURRENT_STATE:
|
||||
if (ui::AX_ARIA_CURRENT_STATE_NONE != attr.second) {
|
||||
attributes->SetString(
|
||||
ToString(attr.first),
|
||||
ToString(static_cast<ui::AXAriaCurrentState>(attr.second)));
|
||||
case ax::mojom::IntAttribute::kAriaCurrentState: {
|
||||
auto state = static_cast<ax::mojom::AriaCurrentState>(attr.second);
|
||||
if (ax::mojom::AriaCurrentState::kNone != state) {
|
||||
attributes->SetString(ToString(attr.first), ToString(state));
|
||||
}
|
||||
break;
|
||||
case ui::AX_ATTR_TEXT_DIRECTION:
|
||||
if (ui::AX_TEXT_DIRECTION_NONE != attr.second) {
|
||||
attributes->SetString(
|
||||
ToString(attr.first),
|
||||
ToString(static_cast<ui::AXTextDirection>(attr.second)));
|
||||
} break;
|
||||
case ax::mojom::IntAttribute::kTextDirection: {
|
||||
auto state = static_cast<ax::mojom::TextDirection>(attr.second);
|
||||
if (ax::mojom::TextDirection::kNone != state) {
|
||||
attributes->SetString(ToString(attr.first), ToString(state));
|
||||
}
|
||||
break;
|
||||
case ui::AX_ATTR_TEXT_STYLE: {
|
||||
auto text_style = static_cast<ui::AXTextStyle>(attr.second);
|
||||
if (text_style == ui::AX_TEXT_STYLE_NONE)
|
||||
} break;
|
||||
case ax::mojom::IntAttribute::kTextStyle: {
|
||||
auto text_style = static_cast<ax::mojom::TextStyle>(attr.second);
|
||||
if (text_style == ax::mojom::TextStyle::kNone)
|
||||
break;
|
||||
|
||||
static ui::AXTextStyle textStyleArr[] = {
|
||||
ui::AX_TEXT_STYLE_BOLD, ui::AX_TEXT_STYLE_ITALIC,
|
||||
ui::AX_TEXT_STYLE_UNDERLINE, ui::AX_TEXT_STYLE_LINE_THROUGH};
|
||||
static ax::mojom::TextStyle textStyleArr[] = {
|
||||
ax::mojom::TextStyle::kTextStyleBold,
|
||||
ax::mojom::TextStyle::kTextStyleItalic,
|
||||
ax::mojom::TextStyle::kTextStyleUnderline,
|
||||
ax::mojom::TextStyle::kTextStyleLineThrough};
|
||||
|
||||
CefRefPtr<CefListValue> list = CefListValue::Create();
|
||||
int index = 0;
|
||||
// Iterate and find which states are set.
|
||||
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]));
|
||||
}
|
||||
attributes->SetList(ToString(attr.first), list);
|
||||
@@ -194,43 +193,44 @@ struct PopulateAxNodeAttributes {
|
||||
}
|
||||
|
||||
// Set Bool Attributes.
|
||||
void operator()(const std::pair<ui::AXBoolAttribute, bool> attr) {
|
||||
if (attr.first != ui::AX_BOOL_ATTRIBUTE_NONE)
|
||||
void operator()(const std::pair<ax::mojom::BoolAttribute, bool> attr) {
|
||||
if (attr.first != ax::mojom::BoolAttribute::kNone)
|
||||
attributes->SetBool(ToString(attr.first), attr.second);
|
||||
}
|
||||
// Set String Attributes.
|
||||
void operator()(const std::pair<ui::AXStringAttribute, std::string>& attr) {
|
||||
if (attr.first != ui::AX_STRING_ATTRIBUTE_NONE)
|
||||
void operator()(
|
||||
const std::pair<ax::mojom::StringAttribute, std::string>& attr) {
|
||||
if (attr.first != ax::mojom::StringAttribute::kNone)
|
||||
attributes->SetString(ToString(attr.first), attr.second);
|
||||
}
|
||||
// Set Float attributes.
|
||||
void operator()(const std::pair<ui::AXFloatAttribute, float>& attr) {
|
||||
if (attr.first != ui::AX_FLOAT_ATTRIBUTE_NONE)
|
||||
void operator()(const std::pair<ax::mojom::FloatAttribute, float>& attr) {
|
||||
if (attr.first != ax::mojom::FloatAttribute::kNone)
|
||||
attributes->SetDouble(ToString(attr.first), attr.second);
|
||||
}
|
||||
|
||||
// Set Int list attributes.
|
||||
void operator()(
|
||||
const std::pair<ui::AXIntListAttribute, std::vector<int32_t>>& attr) {
|
||||
if (attr.first != ui::AX_INT_LIST_ATTRIBUTE_NONE) {
|
||||
void operator()(const std::pair<ax::mojom::IntListAttribute,
|
||||
std::vector<int32_t>>& attr) {
|
||||
if (attr.first != ax::mojom::IntListAttribute::kNone) {
|
||||
CefRefPtr<CefListValue> list;
|
||||
|
||||
if (ui::AX_ATTR_MARKER_TYPES == attr.first) {
|
||||
if (ax::mojom::IntListAttribute::kMarkerTypes == attr.first) {
|
||||
list = CefListValue::Create();
|
||||
int index = 0;
|
||||
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;
|
||||
|
||||
static ui::AXMarkerType marktypeArr[] = {
|
||||
ui::AX_MARKER_TYPE_SPELLING, ui::AX_MARKER_TYPE_GRAMMAR,
|
||||
ui::AX_MARKER_TYPE_TEXT_MATCH};
|
||||
static ax::mojom::MarkerType marktypeArr[] = {
|
||||
ax::mojom::MarkerType::kSpelling, ax::mojom::MarkerType::kGrammar,
|
||||
ax::mojom::MarkerType::kTextMatch};
|
||||
|
||||
// Iterate and find which markers are set.
|
||||
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]));
|
||||
}
|
||||
}
|
||||
@@ -267,9 +267,10 @@ CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXNodeData& node) {
|
||||
|
||||
CefRefPtr<CefListValue> actions_strings;
|
||||
size_t actions_idx = 0;
|
||||
for (int action_index = ui::AX_ACTION_NONE + 1;
|
||||
action_index <= ui::AX_ACTION_LAST; ++action_index) {
|
||||
auto action = static_cast<ui::AXAction>(action_index);
|
||||
for (int action_index = static_cast<int>(ax::mojom::Action::kMinValue) + 1;
|
||||
action_index <= static_cast<int>(ax::mojom::Action::kMaxValue);
|
||||
++action_index) {
|
||||
auto action = static_cast<ax::mojom::Action>(action_index);
|
||||
if (node.HasAction(action)) {
|
||||
if (!actions_strings)
|
||||
actions_strings = CefListValue::Create();
|
||||
@@ -383,10 +384,10 @@ CefRefPtr<CefDictionaryValue> ToCefValue(
|
||||
if (eventData.ax_tree_id != -1)
|
||||
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));
|
||||
|
||||
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->SetDictionary("update", ToCefValue(eventData.update));
|
||||
|
@@ -17,7 +17,9 @@
|
||||
#include "base/callback_helpers.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/utf_string_conversions.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/delay_based_time_source.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/render_widget_host_delegate.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/view_messages.h"
|
||||
#include "content/public/browser/browser_thread.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/common/content_switches.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/size_conversions.h"
|
||||
|
||||
@@ -91,7 +94,7 @@ class CefCopyFrameGenerator {
|
||||
&CefCopyFrameGenerator::CopyFromCompositingSurfaceHasResult,
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -203,7 +206,8 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
|
||||
content::RenderWidgetHost* widget,
|
||||
CefRenderWidgetHostViewOSR* parent_host_view,
|
||||
bool is_guest_view_hack)
|
||||
: background_color_(background_color),
|
||||
: content::RenderWidgetHostViewBase(widget),
|
||||
background_color_(background_color),
|
||||
frame_rate_threshold_us_(0),
|
||||
#if !defined(OS_MACOSX)
|
||||
compositor_widget_(gfx::kNullAcceleratedWidget),
|
||||
@@ -236,10 +240,16 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
|
||||
|
||||
local_surface_id_ = local_surface_id_allocator_.GenerateId();
|
||||
|
||||
// Surface synchronization is not supported with OSR.
|
||||
DCHECK(!features::IsSurfaceSynchronizationEnabled());
|
||||
|
||||
#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,
|
||||
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));
|
||||
#endif
|
||||
@@ -256,11 +266,12 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
|
||||
content::ImageTransportFactory::GetInstance();
|
||||
ui::ContextFactoryPrivate* context_factory_private =
|
||||
factory->GetContextFactoryPrivate();
|
||||
// Matching the attributes from RecyclableCompositorMac.
|
||||
compositor_.reset(
|
||||
new ui::Compositor(context_factory_private->AllocateFrameSinkId(),
|
||||
content::GetContextFactory(), context_factory_private,
|
||||
base::ThreadTaskRunnerHandle::Get(),
|
||||
false /* enable_surface_synchronization */,
|
||||
features::IsSurfaceSynchronizationEnabled(),
|
||||
false /* enable_pixel_canvas */));
|
||||
compositor_->SetAcceleratedWidget(compositor_widget_);
|
||||
compositor_->SetDelegate(this);
|
||||
@@ -326,10 +337,6 @@ void CefRenderWidgetHostViewOSR::SetSize(const gfx::Size& size) {}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SetBounds(const gfx::Rect& rect) {}
|
||||
|
||||
gfx::Vector2dF CefRenderWidgetHostViewOSR::GetLastScrollOffset() const {
|
||||
return last_scroll_offset_;
|
||||
}
|
||||
|
||||
gfx::NativeView CefRenderWidgetHostViewOSR::GetNativeView() const {
|
||||
return gfx::NativeView();
|
||||
}
|
||||
@@ -359,9 +366,12 @@ void CefRenderWidgetHostViewOSR::Show() {
|
||||
browser_compositor_->SetRenderWidgetHostIsHidden(false);
|
||||
#else
|
||||
delegated_frame_host_->SetCompositor(compositor_.get());
|
||||
delegated_frame_host_->WasShown(ui::LatencyInfo());
|
||||
delegated_frame_host_->WasShown(
|
||||
GetLocalSurfaceId(), GetRootLayer()->bounds().size(), ui::LatencyInfo());
|
||||
#endif
|
||||
|
||||
// Note that |render_widget_host_| will retrieve size parameters from the
|
||||
// DelegatedFrameHost, so it must have WasShown called after.
|
||||
if (render_widget_host_)
|
||||
render_widget_host_->WasShown(ui::LatencyInfo());
|
||||
}
|
||||
@@ -428,6 +438,22 @@ bool CefRenderWidgetHostViewOSR::LockMouse() {
|
||||
|
||||
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(
|
||||
viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) {
|
||||
renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;
|
||||
@@ -652,44 +678,55 @@ gfx::Size CefRenderWidgetHostViewOSR::GetRequestedRendererSize() const {
|
||||
return GetDelegatedFrameHost()->GetRequestedRendererSize();
|
||||
}
|
||||
|
||||
gfx::Size CefRenderWidgetHostViewOSR::GetPhysicalBackingSize() const {
|
||||
gfx::Size CefRenderWidgetHostViewOSR::GetCompositorViewportPixelSize() const {
|
||||
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(),
|
||||
current_device_scale_factor_);
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::CopyFromSurface(
|
||||
const gfx::Rect& src_subrect,
|
||||
const gfx::Size& dst_size,
|
||||
const content::ReadbackRequestCallback& callback,
|
||||
const SkColorType color_type) {
|
||||
GetDelegatedFrameHost()->CopyFromCompositingSurface(src_subrect, dst_size,
|
||||
callback, color_type);
|
||||
const gfx::Rect& src_rect,
|
||||
const gfx::Size& output_size,
|
||||
base::OnceCallback<void(const SkBitmap&)> callback) {
|
||||
GetDelegatedFrameHost()->CopyFromCompositingSurface(src_rect, output_size,
|
||||
std::move(callback));
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::CopyFromSurfaceToVideoFrame(
|
||||
const gfx::Rect& src_subrect,
|
||||
scoped_refptr<media::VideoFrame> target,
|
||||
const base::Callback<void(const gfx::Rect&, bool)>& callback) {
|
||||
GetDelegatedFrameHost()->CopyFromCompositingSurfaceToVideoFrame(
|
||||
src_subrect, target, callback);
|
||||
void CefRenderWidgetHostViewOSR::GetScreenInfo(
|
||||
content::ScreenInfo* results) const {
|
||||
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::BeginFrameSubscription(
|
||||
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber> subscriber) {
|
||||
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::Vector2d CefRenderWidgetHostViewOSR::GetOffsetFromRootSurface() {
|
||||
return gfx::Vector2d();
|
||||
}
|
||||
|
||||
gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() {
|
||||
@@ -704,11 +741,6 @@ gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() {
|
||||
return GetViewBounds();
|
||||
}
|
||||
|
||||
content::RenderWidgetHostImpl*
|
||||
CefRenderWidgetHostViewOSR::GetRenderWidgetHostImpl() const {
|
||||
return render_widget_host_;
|
||||
}
|
||||
|
||||
viz::SurfaceId CefRenderWidgetHostViewOSR::GetCurrentSurfaceId() const {
|
||||
return GetDelegatedFrameHost()
|
||||
? GetDelegatedFrameHost()->GetCurrentSurfaceId()
|
||||
@@ -742,7 +774,9 @@ void CefRenderWidgetHostViewOSR::ImeSetComposition(
|
||||
for (const CefCompositionUnderline& line : underlines) {
|
||||
web_underlines.push_back(ui::ImeTextSpan(
|
||||
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);
|
||||
|
||||
@@ -791,6 +825,31 @@ void CefRenderWidgetHostViewOSR::ImeCancelComposition() {
|
||||
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) {
|
||||
SetFrameRate();
|
||||
|
||||
@@ -844,6 +903,16 @@ bool CefRenderWidgetHostViewOSR::TransformPointToCoordSpaceForView(
|
||||
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>
|
||||
CefRenderWidgetHostViewOSR::CreateSoftwareOutputDevice(
|
||||
ui::Compositor* compositor) {
|
||||
@@ -878,11 +947,6 @@ SkColor CefRenderWidgetHostViewOSR::DelegatedFrameHostGetGutterColor() const {
|
||||
return background_color_;
|
||||
}
|
||||
|
||||
gfx::Size CefRenderWidgetHostViewOSR::DelegatedFrameHostDesiredSizeInDIP()
|
||||
const {
|
||||
return GetRootLayer()->bounds().size();
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::DelegatedFrameCanCreateResizeLock() const {
|
||||
return !render_widget_host_->auto_resize_enabled();
|
||||
}
|
||||
@@ -892,13 +956,16 @@ CefRenderWidgetHostViewOSR::DelegatedFrameHostCreateResizeLock() {
|
||||
HoldResize();
|
||||
|
||||
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 {
|
||||
return local_surface_id_;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::OnFirstSurfaceActivation(
|
||||
const viz::SurfaceInfo& surface_info) {}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::OnBeginFrame(base::TimeTicks frame_time) {
|
||||
// TODO(cef): Maybe we can use this method in combination with
|
||||
// OnSetNeedsBeginFrames() instead of using CefBeginFrameTimer.
|
||||
@@ -913,6 +980,10 @@ void CefRenderWidgetHostViewOSR::OnFrameTokenChanged(uint32_t frame_token) {
|
||||
render_widget_host_->DidProcessFrame(frame_token);
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::DidReceiveFirstFrameAfterNavigation() {
|
||||
render_widget_host_->DidReceiveFirstFrameAfterNavigation();
|
||||
}
|
||||
|
||||
std::unique_ptr<ui::CompositorLock>
|
||||
CefRenderWidgetHostViewOSR::GetCompositorLock(
|
||||
ui::CompositorLockClient* client) {
|
||||
@@ -946,42 +1017,6 @@ void CefRenderWidgetHostViewOSR::WasResized() {
|
||||
}
|
||||
|
||||
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() {
|
||||
@@ -991,7 +1026,22 @@ void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() {
|
||||
|
||||
// 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();
|
||||
#endif
|
||||
|
||||
// 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
|
||||
// in the rwhv_aura (current_cursor_.SetScaleFactor)
|
||||
@@ -1011,7 +1061,7 @@ void CefRenderWidgetHostViewOSR::Invalidate(
|
||||
return;
|
||||
}
|
||||
|
||||
InvalidateInternal(gfx::Rect(GetPhysicalBackingSize()));
|
||||
InvalidateInternal(gfx::Rect(GetCompositorViewportPixelSize()));
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SendKeyEvent(
|
||||
@@ -1246,9 +1296,11 @@ void CefRenderWidgetHostViewOSR::SetFrameRate() {
|
||||
osr_util::ClampFrameRate(browser->settings().windowless_frame_rate);
|
||||
frame_rate_threshold_us_ = 1000000 / frame_rate;
|
||||
|
||||
// Configure the VSync interval for the browser process.
|
||||
GetCompositor()->vsync_manager()->SetAuthoritativeVSyncInterval(
|
||||
base::TimeDelta::FromMicroseconds(frame_rate_threshold_us_));
|
||||
if (GetCompositor()) {
|
||||
// Configure the VSync interval for the browser process.
|
||||
GetCompositor()->vsync_manager()->SetAuthoritativeVSyncInterval(
|
||||
base::TimeDelta::FromMicroseconds(frame_rate_threshold_us_));
|
||||
}
|
||||
|
||||
if (copy_frame_generator_.get()) {
|
||||
copy_frame_generator_->set_frame_rate_threshold_us(
|
||||
@@ -1314,9 +1366,24 @@ void CefRenderWidgetHostViewOSR::ResizeRootLayer() {
|
||||
local_surface_id_ = local_surface_id_allocator_.GenerateId();
|
||||
|
||||
GetRootLayer()->SetBounds(gfx::Rect(size));
|
||||
GetCompositor()->SetScaleAndSize(current_device_scale_factor_, size_in_pixels,
|
||||
local_surface_id_);
|
||||
if (GetCompositor()) {
|
||||
GetCompositor()->SetScaleAndSize(current_device_scale_factor_,
|
||||
size_in_pixels, local_surface_id_);
|
||||
}
|
||||
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() {
|
||||
@@ -1416,10 +1483,9 @@ void CefRenderWidgetHostViewOSR::RemoveGuestHostView(
|
||||
|
||||
void CefRenderWidgetHostViewOSR::RegisterGuestViewFrameSwappedCallback(
|
||||
content::RenderWidgetHostViewGuest* guest_host_view) {
|
||||
guest_host_view->RegisterFrameSwappedCallback(
|
||||
base::MakeUnique<base::Closure>(base::Bind(
|
||||
&CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped,
|
||||
weak_ptr_factory_.GetWeakPtr(), base::Unretained(guest_host_view))));
|
||||
guest_host_view->RegisterFrameSwappedCallback(base::BindOnce(
|
||||
&CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped,
|
||||
weak_ptr_factory_.GetWeakPtr(), base::Unretained(guest_host_view)));
|
||||
guest_host_view->set_current_device_scale_factor(
|
||||
current_device_scale_factor_);
|
||||
}
|
||||
|
@@ -102,7 +102,6 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
||||
void InitAsChild(gfx::NativeView parent_view) override;
|
||||
void SetSize(const gfx::Size& size) override;
|
||||
void SetBounds(const gfx::Rect& rect) override;
|
||||
gfx::Vector2dF GetLastScrollOffset() const override;
|
||||
gfx::NativeView GetNativeView() const override;
|
||||
gfx::NativeViewAccessible GetNativeViewAccessible() override;
|
||||
void Focus() override;
|
||||
@@ -116,14 +115,13 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
||||
SkColor background_color() const override;
|
||||
bool LockMouse() override;
|
||||
void UnlockMouse() override;
|
||||
void TakeFallbackContentFrom(content::RenderWidgetHostView* view) override;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void SetActive(bool active) override;
|
||||
void ShowDefinitionForSelection() override;
|
||||
bool SupportsSpeech() const override;
|
||||
void SpeakSelection() override;
|
||||
bool IsSpeaking() const override;
|
||||
void StopSpeaking() override;
|
||||
bool ShouldContinueToPauseForFrame() override;
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
// RenderWidgetHostViewBase implementation.
|
||||
@@ -149,22 +147,14 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
||||
void SetTooltipText(const base::string16& tooltip_text) override;
|
||||
|
||||
gfx::Size GetRequestedRendererSize() const override;
|
||||
gfx::Size GetPhysicalBackingSize() const override;
|
||||
void CopyFromSurface(const gfx::Rect& src_subrect,
|
||||
const gfx::Size& dst_size,
|
||||
const content::ReadbackRequestCallback& callback,
|
||||
const SkColorType color_type) override;
|
||||
void CopyFromSurfaceToVideoFrame(
|
||||
const gfx::Rect& src_subrect,
|
||||
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::Size GetCompositorViewportPixelSize() const override;
|
||||
void CopyFromSurface(
|
||||
const gfx::Rect& src_rect,
|
||||
const gfx::Size& output_size,
|
||||
base::OnceCallback<void(const SkBitmap&)> callback) override;
|
||||
void GetScreenInfo(content::ScreenInfo* results) const override;
|
||||
gfx::Vector2d GetOffsetFromRootSurface() override;
|
||||
gfx::Rect GetBoundsInRootWindow() override;
|
||||
content::RenderWidgetHostImpl* GetRenderWidgetHostImpl() const override;
|
||||
viz::SurfaceId GetCurrentSurfaceId() const override;
|
||||
content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(
|
||||
content::BrowserAccessibilityDelegate* delegate,
|
||||
@@ -188,6 +178,11 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
||||
const gfx::PointF& point,
|
||||
RenderWidgetHostViewBase* target_view,
|
||||
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.
|
||||
std::unique_ptr<viz::SoftwareOutputDevice> CreateSoftwareOutputDevice(
|
||||
@@ -198,14 +193,15 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
||||
ui::Layer* DelegatedFrameHostGetLayer() const override;
|
||||
bool DelegatedFrameHostIsVisible() const override;
|
||||
SkColor DelegatedFrameHostGetGutterColor() const override;
|
||||
gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override;
|
||||
bool DelegatedFrameCanCreateResizeLock() const override;
|
||||
std::unique_ptr<content::CompositorResizeLock>
|
||||
DelegatedFrameHostCreateResizeLock() override;
|
||||
viz::LocalSurfaceId GetLocalSurfaceId() const override;
|
||||
void OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) override;
|
||||
void OnBeginFrame(base::TimeTicks frame_time) override;
|
||||
bool IsAutoResizeEnabled() const override;
|
||||
void OnFrameTokenChanged(uint32_t frame_token) override;
|
||||
void DidReceiveFirstFrameAfterNavigation() override;
|
||||
|
||||
// CompositorResizeLockClient implementation.
|
||||
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
|
||||
@@ -216,7 +212,6 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
||||
bool InstallTransparency();
|
||||
|
||||
void WasResized();
|
||||
void GetScreenInfo(content::ScreenInfo* results);
|
||||
void OnScreenInfoChanged();
|
||||
void Invalidate(CefBrowserHost::PaintElementType type);
|
||||
void SendKeyEvent(const content::NativeWebKeyboardEvent& event);
|
||||
@@ -303,7 +298,9 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
friend class MacHelper;
|
||||
#endif
|
||||
bool UpdateNSViewAndDisplay();
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
void PlatformCreateCompositorWidget(bool is_guest_view_hack);
|
||||
void PlatformResizeCompositorWidget(const gfx::Size& size);
|
||||
void PlatformDestroyCompositorWidget();
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
#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/gfx/x/x11_types.h"
|
||||
|
||||
|
@@ -17,6 +17,16 @@
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/common/view_messages.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,
|
||||
public ui::AcceleratedWidgetMacNSView {
|
||||
@@ -37,7 +47,7 @@ class MacHelper : public content::BrowserCompositorMacClient,
|
||||
return view_->background_color();
|
||||
}
|
||||
|
||||
void BrowserCompositorMacOnBeginFrame() override {}
|
||||
void BrowserCompositorMacOnBeginFrame(base::TimeTicks frame_time) override {}
|
||||
|
||||
void OnFrameTokenChanged(uint32_t frame_token) override {
|
||||
view_->render_widget_host()->DidProcessFrame(frame_token);
|
||||
@@ -60,6 +70,14 @@ class MacHelper : public content::BrowserCompositorMacClient,
|
||||
|
||||
void AcceleratedWidgetSwapCompleted() override {}
|
||||
|
||||
void DidReceiveFirstFrameAfterNavigation() override {
|
||||
view_->render_widget_host()->DidReceiveFirstFrameAfterNavigation();
|
||||
}
|
||||
|
||||
void DestroyCompositorForShutdown() override {}
|
||||
|
||||
void WasResized() override { view_->render_widget_host()->WasResized(); }
|
||||
|
||||
private:
|
||||
// Guaranteed to outlive this object.
|
||||
CefRenderWidgetHostViewOSR* view_;
|
||||
@@ -71,18 +89,12 @@ void CefRenderWidgetHostViewOSR::SetActive(bool active) {}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::ShowDefinitionForSelection() {}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::SupportsSpeech() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SpeakSelection() {}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::IsSpeaking() const {
|
||||
return false;
|
||||
bool CefRenderWidgetHostViewOSR::ShouldContinueToPauseForFrame() {
|
||||
return browser_compositor_->ShouldContinueToPauseForFrame();
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::StopSpeaking() {}
|
||||
|
||||
ui::Compositor* CefRenderWidgetHostViewOSR::GetCompositor() const {
|
||||
return browser_compositor_->GetCompositor();
|
||||
}
|
||||
@@ -96,6 +108,11 @@ content::DelegatedFrameHost* CefRenderWidgetHostViewOSR::GetDelegatedFrameHost()
|
||||
return browser_compositor_->GetDelegatedFrameHost();
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::UpdateNSViewAndDisplay() {
|
||||
return browser_compositor_->UpdateNSViewAndDisplay(
|
||||
GetRootLayer()->bounds().size(), GetDisplay());
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget(
|
||||
bool is_guest_view_hack) {
|
||||
// Create a borderless non-visible 1x1 window.
|
||||
@@ -114,7 +131,7 @@ void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget(
|
||||
mac_helper_ = new MacHelper(this);
|
||||
browser_compositor_.reset(new content::BrowserCompositorMac(
|
||||
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true,
|
||||
AllocateFrameSinkId(is_guest_view_hack)));
|
||||
GetDisplay(), AllocateFrameSinkId(is_guest_view_hack)));
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::PlatformResizeCompositorWidget(
|
||||
|
@@ -10,7 +10,7 @@
|
||||
#include "libcef/browser/browser_host_impl.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"
|
||||
|
||||
namespace {
|
||||
|
@@ -41,14 +41,6 @@ gfx::NativeWindow CefWebContentsViewOSR::GetTopLevelNativeWindow() const {
|
||||
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 {
|
||||
*out = GetViewBounds();
|
||||
}
|
||||
@@ -135,9 +127,10 @@ CefWebContentsViewOSR::CreateViewForPopupWidget(
|
||||
void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) {}
|
||||
|
||||
void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) {
|
||||
// |view| will be nullptr the first time this method is called for popup
|
||||
// browsers.
|
||||
CefRenderWidgetHostViewOSR* view = GetView();
|
||||
if (!host)
|
||||
return;
|
||||
CefRenderWidgetHostViewOSR* view =
|
||||
static_cast<CefRenderWidgetHostViewOSR*>(host->GetWidget()->GetView());
|
||||
if (view)
|
||||
view->InstallTransparency();
|
||||
}
|
||||
|
@@ -33,7 +33,6 @@ class CefWebContentsViewOSR : public content::WebContentsView,
|
||||
gfx::NativeView GetNativeView() const override;
|
||||
gfx::NativeView GetContentNativeView() const override;
|
||||
gfx::NativeWindow GetTopLevelNativeWindow() const override;
|
||||
void GetScreenInfo(content::ScreenInfo* screen_info) const override;
|
||||
void GetContainerBounds(gfx::Rect* out) const override;
|
||||
void SizeContents(const gfx::Size& size) override;
|
||||
void Focus() override;
|
||||
|
@@ -43,7 +43,7 @@
|
||||
#include "components/update_client/update_client.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "extensions/browser/extension_prefs.h"
|
||||
#include "extensions/features/features.h"
|
||||
#include "extensions/buildflags/buildflags.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
namespace browser_prefs {
|
||||
|
@@ -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) {
|
||||
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) {
|
||||
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) {
|
||||
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 {
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include "extensions/browser/extension_registry.h"
|
||||
#include "extensions/browser/view_type_utils.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "media/media_features.h"
|
||||
#include "media/media_buildflags.h"
|
||||
|
||||
namespace renderer_prefs {
|
||||
|
||||
|
@@ -183,16 +183,16 @@ bool CefPrintDialogLinux::UpdateSettings(printing::PrintSettings* settings) {
|
||||
void CefPrintDialogLinux::ShowDialog(
|
||||
gfx::NativeView parent_view,
|
||||
bool has_selection,
|
||||
const PrintingContextLinux::PrintSettingsCallback& callback) {
|
||||
PrintingContextLinux::PrintSettingsCallback callback) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
SetHandler();
|
||||
if (!handler_.get()) {
|
||||
callback.Run(PrintingContextLinux::CANCEL);
|
||||
std::move(callback).Run(PrintingContextLinux::CANCEL);
|
||||
return;
|
||||
}
|
||||
|
||||
callback_ = callback;
|
||||
callback_ = std::move(callback);
|
||||
|
||||
CefRefPtr<CefPrintDialogCallbackImpl> callback_impl(
|
||||
new CefPrintDialogCallbackImpl(this));
|
||||
@@ -310,18 +310,15 @@ void CefPrintDialogLinux::OnPrintContinue(
|
||||
CefValueController::AutoLock lock_scope(impl->controller());
|
||||
context_->InitWithSettings(impl->print_settings());
|
||||
}
|
||||
callback_.Run(PrintingContextLinux::OK);
|
||||
callback_.Reset();
|
||||
std::move(callback_).Run(PrintingContextLinux::OK);
|
||||
}
|
||||
|
||||
void CefPrintDialogLinux::OnPrintCancel() {
|
||||
callback_.Run(PrintingContextLinux::CANCEL);
|
||||
callback_.Reset();
|
||||
std::move(callback_).Run(PrintingContextLinux::CANCEL);
|
||||
}
|
||||
|
||||
void CefPrintDialogLinux::OnJobCompleted() {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::FILE, FROM_HERE,
|
||||
CEF_POST_BACKGROUND_TASK(
|
||||
base::Bind(base::IgnoreResult(&base::DeleteFile), path_to_pdf_, false));
|
||||
|
||||
// Printing finished. Matches AddRef() in PrintDocument();
|
||||
|
@@ -40,13 +40,13 @@ class CefPrintDialogLinux : public printing::PrintDialogGtkInterface,
|
||||
// Notify the client when printing has started.
|
||||
static void OnPrintStart(int render_process_id, int render_routing_id);
|
||||
|
||||
// printing::CefPrintDialogLinuxInterface implementation.
|
||||
// PrintDialogGtkInterface implementation.
|
||||
void UseDefaultSettings() override;
|
||||
bool UpdateSettings(printing::PrintSettings* settings) override;
|
||||
void ShowDialog(
|
||||
gfx::NativeView parent_view,
|
||||
bool has_selection,
|
||||
const PrintingContextLinux::PrintSettingsCallback& callback) override;
|
||||
PrintingContextLinux::PrintSettingsCallback callback) override;
|
||||
void PrintDocument(const printing::MetafilePlayer& metafile,
|
||||
const base::string16& document_name) override;
|
||||
void AddRefToDialog() override;
|
||||
|
@@ -22,6 +22,8 @@
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "printing/pdf_metafile_skia.h"
|
||||
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
DEFINE_WEB_CONTENTS_USER_DATA_KEY(printing::CefPrintViewManager);
|
||||
@@ -130,7 +132,7 @@ scoped_refptr<base::RefCountedBytes> GetDataFromHandle(
|
||||
base::SharedMemoryHandle handle,
|
||||
uint32_t data_size) {
|
||||
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)) {
|
||||
NOTREACHED();
|
||||
@@ -146,10 +148,10 @@ scoped_refptr<base::RefCountedBytes> GetDataFromHandle(
|
||||
void SavePdfFile(scoped_refptr<base::RefCountedBytes> data,
|
||||
const base::FilePath& path,
|
||||
const CefPrintViewManager::PdfPrintCallback& callback) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
DCHECK_GT(data->size(), 0U);
|
||||
|
||||
PdfMetafileSkia metafile(SkiaDocumentType::PDF);
|
||||
PdfMetafileSkia metafile;
|
||||
metafile.InitFromData(static_cast<const void*>(data->front()), data->size());
|
||||
|
||||
base::File file(path,
|
||||
@@ -265,8 +267,8 @@ void CefPrintViewManager::OnMetafileReadyForPrinting(
|
||||
if (!pdf_print_state_)
|
||||
return;
|
||||
|
||||
scoped_refptr<base::RefCountedBytes> data_bytes =
|
||||
GetDataFromHandle(params.metafile_data_handle, params.data_size);
|
||||
scoped_refptr<base::RefCountedBytes> data_bytes = GetDataFromHandle(
|
||||
params.content.metafile_data_handle, params.content.data_size);
|
||||
if (!data_bytes || !data_bytes->size()) {
|
||||
TerminatePdfPrintJob();
|
||||
return;
|
||||
@@ -279,8 +281,7 @@ void CefPrintViewManager::OnMetafileReadyForPrinting(
|
||||
pdf_print_state_.reset();
|
||||
|
||||
// Save the PDF file to disk and then execute the callback.
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::FILE, FROM_HERE,
|
||||
CEF_POST_USER_VISIBLE_TASK(
|
||||
base::Bind(&SavePdfFile, data_bytes, output_path, print_callback));
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
#include "base/auto_reset.h"
|
||||
#include "base/bind.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/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
@@ -27,11 +27,13 @@
|
||||
#include "chrome/browser/printing/printer_query.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "chrome/common/webui_url_constants.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/printing/browser/print_composite_client.h"
|
||||
#include "components/printing/browser/print_manager_utils.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 "content/public/browser/browser_thread.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_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "extensions/common/constants.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/print_settings.h"
|
||||
#include "printing/printed_document.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "base/command_line.h"
|
||||
@@ -58,6 +62,18 @@ using content::BrowserThread;
|
||||
|
||||
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(
|
||||
content::WebContents* web_contents)
|
||||
: PrintManager(web_contents),
|
||||
@@ -86,13 +102,13 @@ bool CefPrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
|
||||
|
||||
SetPrintingRFH(rfh);
|
||||
int32_t id = rfh->GetRoutingID();
|
||||
return PrintNowInternal(rfh, base::MakeUnique<PrintMsg_PrintPages>(id));
|
||||
return PrintNowInternal(rfh, std::make_unique<PrintMsg_PrintPages>(id));
|
||||
}
|
||||
#endif
|
||||
|
||||
void CefPrintViewManagerBase::PrintDocument(
|
||||
PrintedDocument* document,
|
||||
const scoped_refptr<base::RefCountedBytes>& print_data,
|
||||
const scoped_refptr<base::RefCountedMemory>& print_data,
|
||||
const gfx::Size& page_size,
|
||||
const gfx::Rect& content_area,
|
||||
const gfx::Point& offsets) {
|
||||
@@ -120,9 +136,14 @@ void CefPrintViewManagerBase::PrintDocument(
|
||||
print_job_->StartPdfToEmfConversion(print_data, page_size, content_area,
|
||||
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
|
||||
std::unique_ptr<PdfMetafileSkia> metafile =
|
||||
std::make_unique<PdfMetafileSkia>(SkiaDocumentType::PDF);
|
||||
std::make_unique<PdfMetafileSkia>();
|
||||
CHECK(metafile->InitFromData(print_data->front(), print_data->size()));
|
||||
|
||||
// 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 =
|
||||
GetShmFromMojoHandle(std::move(handle));
|
||||
scoped_refptr<base::RefCountedBytes> bytes =
|
||||
base::MakeRefCounted<base::RefCountedBytes>(
|
||||
reinterpret_cast<const unsigned char*>(shared_buf->memory()),
|
||||
shared_buf->mapped_size());
|
||||
PrintDocument(document, bytes, params.page_size, params.content_area,
|
||||
if (!shared_buf)
|
||||
return;
|
||||
|
||||
size_t size = shared_buf->mapped_size();
|
||||
auto data = base::MakeRefCounted<base::RefCountedSharedMemory>(
|
||||
std::move(shared_buf), size);
|
||||
PrintDocument(document, data, params.page_size, params.content_area,
|
||||
params.physical_offsets);
|
||||
}
|
||||
|
||||
void CefPrintViewManagerBase::OnDidPrintDocument(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const PrintHostMsg_DidPrintDocument_Params& params) {
|
||||
PrintedDocument* document = GetDocument(params.document_cookie);
|
||||
if (!document)
|
||||
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";
|
||||
web_contents()->Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
auto* client = PrintCompositeClient::FromWebContents(web_contents());
|
||||
if (IsOopifEnabled() && !client->for_preview() &&
|
||||
!document->settings().is_modifiable()) {
|
||||
client->DoComposite(
|
||||
params.metafile_data_handle, params.data_size,
|
||||
if (IsOopifEnabled() && !PrintingPdfContent(render_frame_host)) {
|
||||
client->DoCompositeDocumentToPdf(
|
||||
params.document_cookie, render_frame_host, content.metafile_data_handle,
|
||||
content.data_size, content.subframe_content_info,
|
||||
base::BindOnce(&CefPrintViewManagerBase::OnComposePdfDone,
|
||||
weak_ptr_factory_.GetWeakPtr(), params));
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<base::SharedMemory> shared_buf =
|
||||
std::make_unique<base::SharedMemory>(params.metafile_data_handle, true);
|
||||
if (!shared_buf->Map(params.data_size)) {
|
||||
auto shared_buf =
|
||||
std::make_unique<base::SharedMemory>(content.metafile_data_handle, true);
|
||||
if (!shared_buf->Map(content.data_size)) {
|
||||
NOTREACHED() << "couldn't map";
|
||||
web_contents()->Stop();
|
||||
return;
|
||||
}
|
||||
scoped_refptr<base::RefCountedBytes> bytes =
|
||||
base::MakeRefCounted<base::RefCountedBytes>(
|
||||
reinterpret_cast<const unsigned char*>(shared_buf->memory()),
|
||||
params.data_size);
|
||||
PrintDocument(document, bytes, params.page_size, params.content_area,
|
||||
|
||||
auto data = base::MakeRefCounted<base::RefCountedSharedMemory>(
|
||||
std::move(shared_buf), content.data_size);
|
||||
PrintDocument(document, data, params.page_size, params.content_area,
|
||||
params.physical_offsets);
|
||||
}
|
||||
|
||||
@@ -275,8 +298,16 @@ bool CefPrintViewManagerBase::OnMessageReceived(
|
||||
const IPC::Message& message,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
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_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
if (handled)
|
||||
return true;
|
||||
|
||||
handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(CefPrintViewManagerBase, message)
|
||||
IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError,
|
||||
OnShowInvalidPrinterSettingsError)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
@@ -346,18 +377,18 @@ bool CefPrintViewManagerBase::RenderAllMissingPagesNow() {
|
||||
if (!print_job_.get() || !print_job_->is_job_pending())
|
||||
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?
|
||||
if (print_job_->document() && print_job_->document()->IsComplete()) {
|
||||
printing_succeeded_ = 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
|
||||
// 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
|
||||
@@ -401,14 +432,12 @@ bool CefPrintViewManagerBase::CreateNewPrintJob(PrintJobWorkerOwner* job) {
|
||||
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(job);
|
||||
if (!job)
|
||||
return false;
|
||||
|
||||
print_job_ = new PrintJob();
|
||||
print_job_ = base::MakeRefCounted<PrintJob>();
|
||||
print_job_->Initialize(job, RenderSourceName(), number_pages_);
|
||||
registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT,
|
||||
content::Source<PrintJob>(print_job_.get()));
|
||||
@@ -461,7 +490,7 @@ void CefPrintViewManagerBase::ReleasePrintJob() {
|
||||
return;
|
||||
|
||||
if (rfh) {
|
||||
auto msg = base::MakeUnique<PrintMsg_PrintingDone>(rfh->GetRoutingID(),
|
||||
auto msg = std::make_unique<PrintMsg_PrintingDone>(rfh->GetRoutingID(),
|
||||
printing_succeeded_);
|
||||
rfh->Send(msg.release());
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "build/build_config.h"
|
||||
@@ -18,12 +18,12 @@
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "mojo/public/cpp/system/platform_handle.h"
|
||||
#include "printing/features/features.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
|
||||
struct PrintHostMsg_DidPrintDocument_Params;
|
||||
|
||||
namespace base {
|
||||
class RefCountedBytes;
|
||||
class RefCountedMemory;
|
||||
}
|
||||
|
||||
namespace content {
|
||||
@@ -74,6 +74,15 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
|
||||
// Cancels the print job.
|
||||
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:
|
||||
// content::NotificationObserver implementation.
|
||||
void Observe(int type,
|
||||
@@ -87,7 +96,8 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
|
||||
void OnDidGetPrintedPagesCount(int cookie, int number_pages) override;
|
||||
void OnPrintingFailed(int cookie) override;
|
||||
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.
|
||||
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
|
||||
// |print_data| contains valid data.
|
||||
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::Rect& content_area,
|
||||
const gfx::Point& offsets);
|
||||
@@ -121,12 +131,6 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
|
||||
// RenderAllMissingPagesNow().
|
||||
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
|
||||
// disconnect from it.
|
||||
void DisconnectFromCurrentPrintJob();
|
||||
@@ -162,9 +166,6 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
|
||||
// The current RFH that is printing with a system printing dialog.
|
||||
content::RenderFrameHost* printing_rfh_;
|
||||
|
||||
// Manages the low-level talk to the printer.
|
||||
scoped_refptr<PrintJob> print_job_;
|
||||
|
||||
// Indication of success of the print job.
|
||||
bool printing_succeeded_;
|
||||
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/child_process_host.h"
|
||||
#include "printing/features/features.h"
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
#include "libcef/browser/printing/print_dialog_linux.h"
|
||||
@@ -215,7 +214,7 @@ void CefPrintingMessageFilter::OnScriptedPrintReply(
|
||||
}
|
||||
PrintHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params);
|
||||
Send(reply_msg);
|
||||
if (params.params.dpi && params.params.document_cookie) {
|
||||
if (!params.params.dpi.IsEmpty() && params.params.document_cookie) {
|
||||
#if defined(OS_ANDROID)
|
||||
int file_descriptor;
|
||||
const base::string16& device_name = printer_query->settings().device_name();
|
||||
|
@@ -15,7 +15,7 @@
|
||||
#include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
|
||||
#include "components/prefs/pref_member.h"
|
||||
#include "content/public/browser/browser_message_filter.h"
|
||||
#include "printing/features/features.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
|
||||
struct PrintHostMsg_ScriptedPrint_Params;
|
||||
class Profile;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "base/logging.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) {
|
||||
if (!command_line.get()) {
|
||||
@@ -15,8 +15,7 @@ bool CefLaunchProcess(CefRefPtr<CefCommandLine> command_line) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!content::BrowserThread::CurrentlyOn(
|
||||
content::BrowserThread::PROCESS_LAUNCHER)) {
|
||||
if (!content::CurrentlyOnProcessLauncherTaskRunner()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return false;
|
||||
}
|
||||
|
@@ -293,7 +293,8 @@ CefString CefRequestContextImpl::GetCachePath() {
|
||||
|
||||
CefRefPtr<CefCookieManager> CefRequestContextImpl::GetDefaultCookieManager(
|
||||
CefRefPtr<CefCompletionCallback> callback) {
|
||||
CefRefPtr<CefCookieManagerImpl> cookie_manager = new CefCookieManagerImpl();
|
||||
CefRefPtr<CefCookieManagerImpl> cookie_manager =
|
||||
new CefCookieManagerImpl(false);
|
||||
cookie_manager->Initialize(this, CefString(), false, callback);
|
||||
return cookie_manager.get();
|
||||
}
|
||||
|
@@ -30,70 +30,14 @@
|
||||
#include "net/http/http_response_headers.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() {}
|
||||
|
||||
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
|
||||
// ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream.
|
||||
bool CefResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||
net::URLRequest* request,
|
||||
const base::FilePath& plugin_path,
|
||||
const std::string& mime_type,
|
||||
GURL* origin,
|
||||
std::string* payload) {
|
||||
@@ -125,29 +69,14 @@ bool CefResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||
if (!handler)
|
||||
continue;
|
||||
|
||||
// If a plugin path is provided then a stream is being intercepted for the
|
||||
// mimeHandlerPrivate API. Otherwise a stream is being intercepted for the
|
||||
// streamsPrivate API.
|
||||
if (!plugin_path.empty()) {
|
||||
if (handler->HasPlugin() && plugin_path == handler->GetPluginPath()) {
|
||||
StreamTargetInfo target_info;
|
||||
*origin =
|
||||
extensions::Extension::GetBaseURLFromExtensionId(extension_id);
|
||||
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;
|
||||
}
|
||||
if (handler->CanHandleMIMEType(mime_type)) {
|
||||
StreamTargetInfo target_info;
|
||||
*origin = extensions::Extension::GetBaseURLFromExtensionId(extension_id);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,12 +95,14 @@ void CefResourceDispatcherHostDelegate::OnStreamCreated(
|
||||
stream_target_info_.find(request);
|
||||
CHECK(ix != stream_target_info_.end());
|
||||
bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME;
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT,
|
||||
base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream),
|
||||
request->GetExpectedContentSize(), ix->second.extension_id,
|
||||
ix->second.view_id, embedded, info->GetFrameTreeNodeId(),
|
||||
info->GetChildID(), info->GetRenderFrameID()));
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::BindOnce(
|
||||
&extensions::StreamsPrivateAPI::SendExecuteMimeTypeHandlerEvent,
|
||||
request->GetExpectedContentSize(), ix->second.extension_id,
|
||||
ix->second.view_id, embedded, info->GetFrameTreeNodeId(),
|
||||
info->GetChildID(), info->GetRenderFrameID(), std::move(stream),
|
||||
nullptr /* transferrable_loader */, GURL()));
|
||||
stream_target_info_.erase(request);
|
||||
}
|
||||
|
||||
@@ -194,24 +125,3 @@ void CefResourceDispatcherHostDelegate::OnRequestRedirected(
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -21,10 +21,7 @@ class CefResourceDispatcherHostDelegate
|
||||
~CefResourceDispatcherHostDelegate() override;
|
||||
|
||||
// ResourceDispatcherHostDelegate methods.
|
||||
bool HandleExternalProtocol(const GURL& url,
|
||||
content::ResourceRequestInfo* info) override;
|
||||
bool ShouldInterceptResourceAsStream(net::URLRequest* request,
|
||||
const base::FilePath& plugin_path,
|
||||
const std::string& mime_type,
|
||||
GURL* origin,
|
||||
std::string* payload) override;
|
||||
@@ -34,8 +31,6 @@ class CefResourceDispatcherHostDelegate
|
||||
net::URLRequest* request,
|
||||
content::ResourceContext* resource_context,
|
||||
network::ResourceResponse* response) override;
|
||||
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
|
||||
content::ResourceContext* resource_context) override;
|
||||
|
||||
private:
|
||||
void HandleExternalProtocolOnUIThread(
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include "base/format_macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/task_scheduler/post_task.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
@@ -20,6 +19,7 @@
|
||||
#include "net/server/http_server_response_info.h"
|
||||
#include "net/socket/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_REQUIRE_HT() DCHECK(CEF_CURRENTLY_ON_HT())
|
||||
@@ -237,7 +237,7 @@ void CefServerImpl::SendHttp404Response(int connection_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
server_->Send404(connection_id);
|
||||
server_->Send404(connection_id, NO_TRAFFIC_ANNOTATION_YET);
|
||||
server_->Close(connection_id);
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ void CefServerImpl::SendHttp500Response(int connection_id,
|
||||
return;
|
||||
}
|
||||
|
||||
server_->Send500(connection_id, error_message);
|
||||
server_->Send500(connection_id, error_message, NO_TRAFFIC_ANNOTATION_YET);
|
||||
server_->Close(connection_id);
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ void CefServerImpl::SendHttpResponse(int connection_id,
|
||||
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) {
|
||||
server_->Close(connection_id);
|
||||
}
|
||||
@@ -366,7 +366,8 @@ void CefServerImpl::ContinueWebSocketRequest(
|
||||
info->is_websocket_pending = false;
|
||||
|
||||
if (allow) {
|
||||
server_->AcceptWebSocket(connection_id, request_info);
|
||||
server_->AcceptWebSocket(connection_id, request_info,
|
||||
NO_TRAFFIC_ANNOTATION_YET);
|
||||
handler_->OnWebSocketConnected(this, connection_id);
|
||||
} else {
|
||||
server_->Close(connection_id);
|
||||
@@ -397,7 +398,8 @@ void CefServerImpl::SendHttp200ResponseInternal(
|
||||
return;
|
||||
}
|
||||
|
||||
server_->Send200(connection_id, *data, content_type);
|
||||
server_->Send200(connection_id, *data, content_type,
|
||||
NO_TRAFFIC_ANNOTATION_YET);
|
||||
server_->Close(connection_id);
|
||||
}
|
||||
|
||||
@@ -416,7 +418,7 @@ void CefServerImpl::SendRawDataInternal(int connection_id,
|
||||
if (!GetConnectionInfo(connection_id))
|
||||
return;
|
||||
|
||||
server_->SendRaw(connection_id, *data);
|
||||
server_->SendRaw(connection_id, *data, NO_TRAFFIC_ANNOTATION_YET);
|
||||
}
|
||||
|
||||
void CefServerImpl::SendWebSocketMessageInternal(
|
||||
@@ -442,7 +444,7 @@ void CefServerImpl::SendWebSocketMessageInternal(
|
||||
return;
|
||||
}
|
||||
|
||||
server_->SendOverWebSocket(connection_id, *data);
|
||||
server_->SendOverWebSocket(connection_id, *data, NO_TRAFFIC_ANNOTATION_YET);
|
||||
}
|
||||
|
||||
void CefServerImpl::OnConnect(int connection_id) {
|
||||
@@ -595,8 +597,7 @@ void CefServerImpl::ShutdownOnUIThread() {
|
||||
if (thread_) {
|
||||
// Stop the handler thread as a background task so the UI thread isn't
|
||||
// blocked.
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
|
||||
CEF_POST_BACKGROUND_TASK(
|
||||
BindOnce([](std::unique_ptr<base::Thread>) {}, std::move(thread_)));
|
||||
|
||||
// Release the reference that was added in StartupOnUIThread().
|
||||
|
@@ -28,101 +28,6 @@ using content::BrowserThread;
|
||||
using content::SpeechRecognitionManager;
|
||||
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() {
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
@@ -132,37 +37,7 @@ CefSpeechRecognitionManagerDelegate ::CefSpeechRecognitionManagerDelegate() {
|
||||
|
||||
CefSpeechRecognitionManagerDelegate ::~CefSpeechRecognitionManagerDelegate() {}
|
||||
|
||||
void CefSpeechRecognitionManagerDelegate::WebContentsClosedCallback(
|
||||
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::OnRecognitionStart(int session_id) {}
|
||||
|
||||
void CefSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) {}
|
||||
|
||||
|
@@ -48,13 +48,6 @@ class CefSpeechRecognitionManagerDelegate
|
||||
bool FilterProfanities(int render_process_id) override;
|
||||
|
||||
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_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefSpeechRecognitionManagerDelegate);
|
||||
|
@@ -30,11 +30,16 @@ network::mojom::NetworkContext* CefStoragePartitionProxy::GetNetworkContext() {
|
||||
return parent_->GetNetworkContext();
|
||||
}
|
||||
|
||||
network::mojom::URLLoaderFactory*
|
||||
scoped_refptr<network::SharedURLLoaderFactory>
|
||||
CefStoragePartitionProxy::GetURLLoaderFactoryForBrowserProcess() {
|
||||
return parent_->GetURLLoaderFactoryForBrowserProcess();
|
||||
}
|
||||
|
||||
std::unique_ptr<network::SharedURLLoaderFactoryInfo>
|
||||
CefStoragePartitionProxy::GetURLLoaderFactoryForBrowserProcessIOThread() {
|
||||
return parent_->GetURLLoaderFactoryForBrowserProcessIOThread();
|
||||
}
|
||||
|
||||
network::mojom::CookieManager*
|
||||
CefStoragePartitionProxy::GetCookieManagerForBrowserProcess() {
|
||||
return parent_->GetCookieManagerForBrowserProcess();
|
||||
@@ -101,6 +106,10 @@ CefStoragePartitionProxy::GetPlatformNotificationContext() {
|
||||
return parent_->GetPlatformNotificationContext();
|
||||
}
|
||||
|
||||
content::WebPackageContext* CefStoragePartitionProxy::GetWebPackageContext() {
|
||||
return parent_->GetWebPackageContext();
|
||||
}
|
||||
|
||||
void CefStoragePartitionProxy::ClearDataForOrigin(
|
||||
uint32_t remove_mask,
|
||||
uint32_t quota_storage_remove_mask,
|
||||
@@ -154,6 +163,10 @@ void CefStoragePartitionProxy::FlushNetworkInterfaceForTesting() {
|
||||
parent_->FlushNetworkInterfaceForTesting();
|
||||
}
|
||||
|
||||
void CefStoragePartitionProxy::WaitForDeletionTasksForTesting() {
|
||||
parent_->WaitForDeletionTasksForTesting();
|
||||
}
|
||||
|
||||
content::BackgroundFetchContext*
|
||||
CefStoragePartitionProxy::GetBackgroundFetchContext() {
|
||||
return parent_->GetBackgroundFetchContext();
|
||||
@@ -188,6 +201,11 @@ content::BlobRegistryWrapper* CefStoragePartitionProxy::GetBlobRegistry() {
|
||||
return parent_->GetBlobRegistry();
|
||||
}
|
||||
|
||||
content::PrefetchURLLoaderService*
|
||||
CefStoragePartitionProxy::GetPrefetchURLLoaderService() {
|
||||
return parent_->GetPrefetchURLLoaderService();
|
||||
}
|
||||
|
||||
content::URLLoaderFactoryGetter*
|
||||
CefStoragePartitionProxy::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
Reference in New Issue
Block a user