Compare commits

..

81 Commits
2883 ... 2924

Author SHA1 Message Date
Marshall Greenblatt
97389a92ee Windows: Fix VS2010 compile error 2017-02-28 15:43:38 -05:00
Marshall Greenblatt
73d380a8ec cmake: Update target platform versions (issue #2109)
- macOS: Allow selection of 10.11 SDK and set target version to 10.9 SDK.
- Windows: Set target version to Windows 7.
2017-02-28 15:31:08 -05:00
Marshall Greenblatt
5b69bde650 Fix configuration of CefSettings.framework_dir_path (issue #2110) 2017-02-28 14:41:56 -05:00
Marshall Greenblatt
178f101bfb Windows: Fix AtExitManager assertion in SupervisedUserSettingsServiceFactory on shutdown when running with multi-threaded message loop (issue #1680) 2017-02-27 15:08:15 -05:00
Marshall Greenblatt
cdcdfa9991 Windows: Support crash upload URLs with query component (issue #1995) 2017-02-21 13:42:42 -05:00
Marshall Greenblatt
558741c384 Fix OSR popup transparency (issue #2099) 2017-02-15 16:04:57 -05:00
Marshall Greenblatt
067d91504f Fix error in browser_plugin_guest_1565.patch 2017-02-14 10:45:18 -05:00
Marshall Greenblatt
763ecb484f Fix SupervisedUserSettingsService initialization (issue #2093) 2017-02-13 17:23:50 -05:00
Marshall Greenblatt
4c4ae85089 Simplify OSR guest view implementation 2017-02-13 16:09:16 -05:00
Marshall Greenblatt
a6a3da2d53 Allow empty value param to CefSetCrashKeyValue (issue #1995) 2017-02-08 12:37:29 -05:00
Marshall Greenblatt
80258004b9 macOS: Fix issue with display of auto-hide scrollbars 2017-02-08 11:23:13 -05:00
Marshall Greenblatt
0ba0378d19 macOS: Generate correct framework and Info.plist version numbers (issue #1969) 2017-02-06 18:26:02 -05:00
Marshall Greenblatt
e5105d4e09 macOS: Fix incorrect OSR compositor resize in OnSwapCompositorFrame (issue #2065) 2017-02-06 16:36:22 -05:00
Marshall Greenblatt
d513424026 macOS: Add option for forwarding browser process crashes to the system crash reporter (issue #1995) 2017-02-06 14:23:59 -05:00
Marshall Greenblatt
06fde9995d macOS: Fix issue with display of auto-hide scrollbars 2017-02-03 15:00:54 -05:00
Marshall Greenblatt
271bb8bc31 macOS: Update xib files to 10.9 deployment target 2017-02-02 18:19:05 -05:00
Marshall Greenblatt
e7450f2fbc macOS: cefclient: Create Tests menu with Interface Builder 2017-02-02 15:58:42 -05:00
Marshall Greenblatt
872fbc07b5 Fix localization of default context menu labels (issue #2081) 2017-02-01 15:38:59 -05:00
Marshall Greenblatt
ebb70f94e8 Fix KeyedServiceFactory assertion during shutdown (issue #2083) 2017-01-31 17:43:15 -05:00
Marshall Greenblatt
1758b744b2 Fix crash using WebRTC with TLS certs (issue #2080) 2017-01-31 15:27:31 -05:00
Marshall Greenblatt
0ab2e20d44 Windows: Fix command line parsing for crash handler (issue #1995) 2017-01-30 16:17:03 -05:00
Marshall Greenblatt
d6b6d11ec4 Update to Chromium version 56.0.2924.76 2017-01-30 16:02:53 -05:00
Marshall Greenblatt
3561b8dfdb macOS: Support crash reporting from unbundled apps (issue #1532) 2017-01-27 17:05:41 -05:00
Marshall Greenblatt
da2209a6d8 macOS: Allow configuration of framework path (issue #1532) 2017-01-27 17:05:30 -05:00
Marshall Greenblatt
df1d25f0a9 Standardize product/version/platform crash keys (issue #1995) 2017-01-25 14:14:58 -05:00
Marshall Greenblatt
6d7f90ec51 Fix potential OSR crash on renderer process recreation (issue #2082) 2017-01-25 12:36:32 -05:00
Marshall Greenblatt
4bafa3e155 Add is_main_frame argument to CefRequestContextHandler::OnBeforePluginLoad (issue #2015) 2017-01-24 18:16:15 -05:00
Marshall Greenblatt
8dfe9574c4 Add CefContextMenuParams::GetTitleText method (issue #2030) 2017-01-17 13:21:51 -05:00
Marshall Greenblatt
d22b7ed179 Fix CefRequestHandler::OnCertificateError callback trigger (issue #2019) 2017-01-17 13:09:22 -05:00
Marshall Greenblatt
bb4812691e cefclient: Fix typo in TempWindow comments 2017-01-17 13:09:22 -05:00
Marshall Greenblatt
ff7f70442f Windows: Fix white flash during browser creation (issue #1984) 2017-01-13 16:44:25 -05:00
Marshall Greenblatt
288d2eb2e6 Windows: Fix AppName and ExternalHandler usage in crash_reporter.cfg (issue #1995) 2017-01-13 15:30:26 -05:00
Marshall Greenblatt
650a49b0a7 Add product name and version to crash_reporter.cfg (issue #1995) 2017-01-12 14:05:44 -05:00
Marshall Greenblatt
f7cc01059b Improve crashpad integration (issue #1995)
- Crash reporting is enabled and configured using a "crash_reporter.cfg"
  file. See comments in include/cef_crash_util.h and tools/crash_server.py
  for usage.
2017-01-12 14:05:31 -05:00
Marshall Greenblatt
0da94acdf2 Windows: Add missing crashpad initialization (issue #1995) 2017-01-12 14:05:15 -05:00
Marshall Greenblatt
5c07d06435 Update to Chromium version 56.0.2924.51 2017-01-11 18:22:19 -05:00
Marshall Greenblatt
e63e109489 Update copyright year on generated files 2017-01-10 19:26:34 -05:00
Marshall Greenblatt
bfdeccda52 Windows: Fix behavior of frameless windows with Views.
- Don't set InitParams::TRANSLUCENT_WINDOW. Setting this resulted in
  the WS_EX_COMPOSITED style being added and the WS_THICKFRAME style
  being removed, which disabled Aero Snap.
- Remove the non-client border to get a completely frameless window.
  Having a border is problematic because the top is drawn by Windows
  while the rest is drawn black. Having Windows draw part of the
  border is required to enable the window drop shadow (see
  HWNDMessageHandler::SetDwmFrameExtension).
- Delete the remove_caption patches which are no longer required.
2016-12-14 16:19:50 +01:00
Marshall Greenblatt
cf91961ff2 Windows: Fix missing InsertAllocatorDispatch symbol in cef_sandbox.lib (issue #2044) 2016-11-30 19:52:29 -05:00
Marshall Greenblatt
de18fc4292 Windows: Fix x64 build conversion from 'size_t' to 'int' error (issue #2054) 2016-11-30 15:24:10 -05:00
Marshall Greenblatt
b4216db56c Update to Chromium version 56.0.2924.10 2016-11-29 20:43:33 -05:00
Marshall Greenblatt
12aeeb13f7 Update to Chromium revision 3a87aecc (#433059) 2016-11-29 16:56:29 -05:00
Marshall Greenblatt
c6881fe145 Add option to enable/disable net security expiration (issue #1994)
- Net security (CT, HSTS) expiration based on build age is now
  disabled by default.
- Add new enable_net_security_expiration option to CefSettings and
  CefRequestContextSettings.
2016-11-18 16:11:40 -05:00
Marshall Greenblatt
4ecff1670e Windows: Fix x64 build conversion from 'size_t' to 'int' error (issue #2043) 2016-11-18 14:31:29 -05:00
Marshall Greenblatt
258c588b44 Mac: Fix resource copy when building the binary distrib with Ninja (issue #1632) 2016-11-18 13:34:32 -05:00
Marshall Greenblatt
bd9a2c8069 Rename unittests to ceftests (issue #1632) 2016-11-18 12:44:46 -05:00
Marshall Greenblatt
8fee8ed05d Add unittests target to the binary distribution (issue #1632)
- Move all tests from the top-level directory to tests/.
- Move files shared by cefclient and unittests to tests/shared/.
- Add a fused (single header/source file) version of gtest in
  tests/gtest/ with associated CMake configuration.
- Test-only headers are now exposed in include/test/. Unit test
  targets must define UNIT_TEST in order to access them.
- Replace usage of USING_CEF_SHARED with WRAPPING_CEF_SHARED for
  clarity (only the libcef_dll_wrapper target should define it).
- Remove the RENAME_DIRECTORY CMake macro which is no longer used.
- Remove C++11 usage from unittests sources for compatibility with
  the binary distribution configuration.
- Windows: Fix build errors due to chrome_elf.dll and imm32.lib
  missing from the CMake configuration.
2016-11-18 03:19:17 -05:00
Marshall Greenblatt
f557d325c1 Remove Chromium target dependencies for unit tests (issue #1632) 2016-11-16 12:51:44 -08:00
Marshall Greenblatt
ef6df50bf9 Remove Chromium includes in unit tests (issue #1632) 2016-11-15 18:22:34 -05:00
Marshall Greenblatt
0e65f027d2 Remove usage of ui::KeyboardCode in unit tests (issue #1632) 2016-11-15 17:50:33 -05:00
Marshall Greenblatt
832654689f Add CefWaitableEvent interface for unit tests (issue #1632) 2016-11-15 16:18:41 -05:00
Marshall Greenblatt
04642e0480 Add CefScopedTempDir and file utility functions for unit tests (issue #1632) 2016-11-15 13:47:44 -05:00
Marshall Greenblatt
a7195c0103 Remove usage of gfx in unit tests (issue #1632) 2016-11-14 13:47:31 -05:00
Marshall Greenblatt
9ed17519a9 Remove usage of base::StringPrintf in unit tests (issue #1632) 2016-11-14 13:28:05 -05:00
Marshall Greenblatt
03f3900d75 Remove usage of base::WrapUnique in unit tests (issue #1632) 2016-11-14 13:03:12 -05:00
Marshall Greenblatt
18d56feac0 Add CefThread interface (issue #1632) 2016-11-14 11:30:15 -05:00
Marshall Greenblatt
607d420baf Fix memory leak with IME on macOS (see http://crbug.com/654695) 2016-11-10 19:16:38 -05:00
Marshall Greenblatt
18763fde50 Add initial WebUI support (issue #2037)
- Visit chrome://webui-hosts for the list of supported hosts.
2016-11-08 16:56:11 -08:00
Marshall Greenblatt
659e5af870 Fix cef_time_t.year documentation (issue #1913) 2016-11-04 17:07:54 -04:00
Marshall Greenblatt
cdd2a40469 Change index parameter type from int to size_t (issue #1491) 2016-11-04 15:26:35 -04:00
Marshall Greenblatt
f3a0ff98bb Add test for history navigation of pages containing dynamically created iframes (issue #2022) 2016-11-04 13:56:19 -04:00
Marshall Greenblatt
d6b17a8fb5 Standardize IME callbacks for off-screen rendering (issue #1675) 2016-11-03 21:02:36 -04:00
Marshall Greenblatt
e69de63b15 Fix DCHECK while running PDF unit tests (issue #2032) 2016-11-03 13:11:09 -04:00
Marshall Greenblatt
7543d16cce Disable channel ID support (issue #1912) 2016-11-02 16:14:18 -04:00
Marshall Greenblatt
a87f0975e2 Remove mention of automatic type conversion in cef_v8.h (issue #1089) 2016-10-28 20:52:40 -04:00
Marshall Greenblatt
efd96f342f Mac: Always set enable_dsyms=true (issue #2027) 2016-10-28 20:27:55 -04:00
Marshall Greenblatt
cea55225f0 Remove unhelpful context debug checks (issue #1954) 2016-10-28 14:56:31 -04:00
Marshall Greenblatt
2149a34d0a Fix URL comparison errors in CefRequest (issue #1967) 2016-10-28 14:15:26 -04:00
Marshall Greenblatt
e39accd266 Fix CefMenuModelDelegate methods missing from the CAPI (issue #2006) 2016-10-28 13:20:04 -04:00
Marshall Greenblatt
4adaa2b552 Fix crash when persisting user preferences (issue #2017) 2016-10-28 12:38:38 -04:00
Marshall Greenblatt
ffab334e94 Fix translator error with X509CertificateList (issue #1824) 2016-10-27 15:46:58 -04:00
Marshall Greenblatt
17c2ecd79d Fix missing browser.enable_spellchecking pref registration (issue #1996) 2016-10-27 14:31:53 -04:00
Marshall Greenblatt
29f7953677 Minor fixes for output consistency 2016-10-27 14:24:03 -04:00
Marshall Greenblatt
676cb1f07d Add callback for custom certificate selection (issue #1824) 2016-10-27 14:04:48 -04:00
Marshall Greenblatt
e006ec0ab5 Add V8 interceptor support (issue #1159) 2016-10-27 14:03:53 -04:00
Marshall Greenblatt
917b4a0de5 Fix shutdown assertion with authentication whitelist preferences (issue #1150) 2016-10-27 14:03:53 -04:00
Marshall Greenblatt
d8f943cd94 Add authentication whitelist preferences (issue #1150) 2016-10-27 14:03:53 -04:00
Marshall Greenblatt
0e97c527ae Allow CefV8Context::Eval to bypass CSP (issue #2024) 2016-10-27 14:03:53 -04:00
Marshall Greenblatt
f7a4102978 Windows: Fix crash when AVX instructions are not supported (issue #1999) 2016-10-27 14:03:53 -04:00
Marshall Greenblatt
be15daa844 Add patch tool enhancements (issue #2016) 2016-10-27 14:03:52 -04:00
Marshall Greenblatt
5ec98243a9 Fix PDF rendering with OSR (issue #1689) 2016-10-27 14:03:45 -04:00
160 changed files with 4445 additions and 10918 deletions

View File

@@ -99,8 +99,12 @@ import("//build/config/locales.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni")
import("//cef/cef_repack_locales.gni")
import("//chrome/common/features.gni")
import("//extensions/features/features.gni")
import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//ppapi/features/features.gni")
import("//printing/features/features.gni")
import("//third_party/icu/config.gni")
import("//third_party/widevine/cdm/widevine.gni")
import("//tools/grit/repack.gni")
@@ -116,6 +120,7 @@ if (is_mac) {
import("//build/config/mac/rules.gni")
import("//build_overrides/v8.gni")
import("//build/mac/tweak_info_plist.gni")
import("//build/util/version.gni")
import("//media/cdm/ppapi/cdm_paths.gni")
}
if (is_win) {
@@ -160,8 +165,45 @@ if (is_mac) {
#
if (is_mac) {
# TODO(cef): Generate this value using version.py.
cef_version = "99.77.34.5"
cef_commit_number = exec_script(
"//cef/tools/commit_number.py",
[ rebase_path("//cef", root_build_dir) ],
"trim string", [])
cef_version_file = "//cef/VERSION"
# The tweak_info_plist.py script requires a version number with 4 parts. CEF
# uses a version number with 3 parts so just set the last part to 0.
cef_plist_version = exec_script(
"//build/util/version.py",
[
"-f",
rebase_path(cef_version_file, root_build_dir),
"-f",
rebase_path(chrome_version_file, root_build_dir),
"-t",
"@CEF_MAJOR@.@BUILD@.${cef_commit_number}.0",
],
"trim string",
[ cef_version_file, chrome_version_file ])
# Need to be creative to match dylib version formatting requirements.
cef_dylib_version = exec_script(
"//build/util/version.py",
[
"-f",
rebase_path(cef_version_file, root_build_dir),
"-f",
rebase_path(chrome_version_file, root_build_dir),
"-t",
"@CEF_MAJOR@${cef_commit_number}.@BUILD_HI@.@BUILD_LO@",
"-e",
"BUILD_HI=int(BUILD)/256",
"-e",
"BUILD_LO=int(BUILD)%256",
],
"trim string",
[ cef_version_file, chrome_version_file ])
}
# Read file lists from gypi files. The gypi_to_gn.py script does not support
@@ -318,10 +360,10 @@ static_library("libcef_static") {
"libcef/browser/net/network_delegate.h",
"libcef/browser/net/resource_request_job.cc",
"libcef/browser/net/resource_request_job.h",
"libcef/browser/net/response_filter_wrapper.cc",
"libcef/browser/net/response_filter_wrapper.h",
"libcef/browser/net/scheme_handler.cc",
"libcef/browser/net/scheme_handler.h",
"libcef/browser/net/source_stream.cc",
"libcef/browser/net/source_stream.h",
"libcef/browser/net/url_request_context.cc",
"libcef/browser/net/url_request_context.h",
"libcef/browser/net/url_request_context_getter.h",
@@ -615,12 +657,13 @@ static_library("libcef_static") {
"//content/public/renderer",
"//content/public/utility",
"//crypto",
"//device/core",
"//device/base",
"//device/geolocation",
"//device/hid",
"//extensions/browser",
"//extensions/browser/api:api_registration",
"//extensions/common/api",
"//extensions/common/api:api_registration",
"//extensions/features",
"//extensions/renderer",
"//extensions/utility",
"//gpu",
@@ -631,15 +674,16 @@ static_library("libcef_static") {
"//net:net_browser_services",
"//net:net_with_v8",
"//pdf",
"//ppapi/features",
"//printing/features",
"//skia",
"//storage/browser",
"//third_party/brotli",
"//third_party/cld",
"//third_party/hunspell",
"//third_party/leveldatabase",
"//third_party/libxml",
"//third_party/WebKit/public:blink",
"//third_party/widevine/cdm:version_h",
"//third_party/widevine/cdm:headers",
"//third_party/icu",
"//third_party/zlib:minizip",
"//ui/base",
@@ -681,8 +725,10 @@ static_library("libcef_static") {
"libcef/browser/osr/render_widget_host_view_osr_win.cc",
"libcef/common/crash_reporting_win.cc",
"libcef/common/crash_reporting_win.h",
"libcef/utility/printing_handler.cc",
"libcef/utility/printing_handler.h",
# Part of //chrome/utility.
"//chrome/utility/printing_handler.cc",
"//chrome/utility/printing_handler.h",
]
deps += [
@@ -1168,7 +1214,7 @@ if (is_mac) {
"--keystone=0",
"--scm=1",
"--version",
cef_version,
cef_plist_version,
"--branding",
cef_framework_name,
]
@@ -1255,7 +1301,13 @@ if (is_mac) {
# on one of the executables. However install_name_tool only operates
# in-place, which is problematic to express in GN. Instead, use rpath-based
# loading.
ldflags = [ "-Wl,-install_name,@rpath/Frameworks/$output_name.framework/$output_name" ]
ldflags = [
"-Wl,-install_name,@rpath/Frameworks/$output_name.framework/$output_name",
"-compatibility_version",
cef_dylib_version,
"-current_version",
cef_dylib_version,
]
if (is_component_build) {
# Set up the rpath for the framework so that it can find dylibs in the
@@ -1335,7 +1387,7 @@ if (is_mac) {
"--keystone=0",
"--scm=0",
"--version",
cef_version,
cef_plist_version,
]
}
@@ -1386,7 +1438,7 @@ if (is_mac) {
args = [
"--scm=1",
"--version",
cef_version,
cef_plist_version,
]
}

View File

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

View File

@@ -268,7 +268,7 @@ if(OS_MACOSX)
# Find the newest available base SDK.
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
foreach(OS_VERSION 10.10 10.9 10.8 10.7)
foreach(OS_VERSION 10.11 10.10 10.9)
set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk")
if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}")
set(CMAKE_OSX_SYSROOT ${SDK})
@@ -276,7 +276,7 @@ if(OS_MACOSX)
endforeach()
# Target SDK.
set(CEF_TARGET_SDK "10.7")
set(CEF_TARGET_SDK "10.9")
list(APPEND CEF_COMPILER_FLAGS
-mmacosx-version-min=${CEF_TARGET_SDK}
)
@@ -376,7 +376,7 @@ if(OS_WINDOWS)
list(APPEND CEF_COMPILER_DEFINES
WIN32 _WIN32 _WINDOWS # Windows platform
UNICODE _UNICODE # Unicode build
WINVER=0x0602 _WIN32_WINNT=0x602 # Targeting Windows 8
WINVER=0x0601 _WIN32_WINNT=0x601 # Targeting Windows 7
NOMINMAX # Use the standard's templated min/max
WIN32_LEAN_AND_MEAN # Exclude less common API declarations
_HAS_EXCEPTIONS=0 # Disable exceptions

View File

@@ -61,6 +61,9 @@ extern "C" {
// information; default to "CEF">
// ExternalHandler=<Windows only; Name of the external handler exe to use
// instead of re-launching the main exe; default to empty>
// BrowserCrashForwardingEnabled=<macOS only; True if browser process crashes
// should be forwarded to the system crash
// reporter; default to false>
// ServerURL=<crash server URL; default to empty>
// RateLimitEnabled=<True if uploads should be rate limited; default to true>
// MaxUploadsPerDay=<Max uploads per 24 hours, used if rate limit is enabled;
@@ -92,6 +95,12 @@ extern "C" {
// directory. On Linux the CefSettings.browser_subprocess_path value will be
// used. On macOS the existing subprocess app bundle will be used.
//
// If "BrowserCrashForwardingEnabled" is set to true (1) on macOS then browser
// process crashes will be forwarded to the system crash reporter. This results
// in the crash UI dialog being displayed to the user and crash reports being
// logged under "~/Library/Logs/DiagnosticReports". Forwarding of crash reports
// from non-browser processes and Debug builds is always disabled.
//
// If "ServerURL" is set then crashes will be uploaded as a multi-part POST
// request to the specified URL. Otherwise, reports will only be stored locally
// on disk.

View File

@@ -62,22 +62,35 @@ typedef struct _cef_response_filter_t {
int (CEF_CALLBACK *init_filter)(struct _cef_response_filter_t* self);
///
// Called to filter a chunk of data. |data_in| is the input buffer containing
// |data_in_size| bytes of pre-filter data (|data_in| will be NULL if
// |data_in_size| is zero). |data_out| is the output buffer that can accept up
// to |data_out_size| bytes of filtered output data. Set |data_in_read| to the
// number of bytes that were read from |data_in|. Set |data_out_written| to
// the number of bytes that were written into |data_out|. If some or all of
// the pre-filter data was read successfully but more data is needed in order
// to continue filtering (filtered output is pending) return
// RESPONSE_FILTER_NEED_MORE_DATA. If some or all of the pre-filter data was
// read successfully and all available filtered output has been written return
// RESPONSE_FILTER_DONE. If an error occurs during filtering return
// RESPONSE_FILTER_ERROR. This function will be called repeatedly until there
// is no more data to filter (resource response is complete), |data_in_read|
// matches |data_in_size| (all available pre-filter bytes have been read), and
// the function returns RESPONSE_FILTER_DONE or RESPONSE_FILTER_ERROR. Do not
// keep a reference to the buffers passed to this function.
// Called to filter a chunk of data. Expected usage is as follows:
//
// A. Read input data from |data_in| and set |data_in_read| to the number of
// bytes that were read up to a maximum of |data_in_size|. |data_in| will
// be NULL if |data_in_size| is zero.
// B. Write filtered output data to |data_out| and set |data_out_written| to
// the number of bytes that were written up to a maximum of
// |data_out_size|. If no output data was written then all data must be
// read from |data_in| (user must set |data_in_read| = |data_in_size|).
// C. Return RESPONSE_FILTER_DONE if all output data was written or
// RESPONSE_FILTER_NEED_MORE_DATA if output data is still pending.
//
// This function will be called repeatedly until the input buffer has been
// fully read (user sets |data_in_read| = |data_in_size|) and there is no more
// input data to filter (the resource response is complete). This function may
// then be called an additional time with an NULL input buffer if the user
// filled the output buffer (set |data_out_written| = |data_out_size|) and
// returned RESPONSE_FILTER_NEED_MORE_DATA to indicate that output data is
// still pending.
//
// Calls to this function will stop when one of the following conditions is
// met:
//
// A. There is no more input data to filter (the resource response is
// complete) and the user sets |data_out_written| = 0 or returns
// RESPONSE_FILTER_DONE to indicate that all data has been written, or;
// B. The user returns RESPONSE_FILTER_ERROR to indicate an error.
//
// Do not keep a reference to the buffers passed to this function.
///
cef_response_filter_status_t (CEF_CALLBACK *filter)(
struct _cef_response_filter_t* self, void* data_in, size_t data_in_size,

View File

@@ -54,6 +54,9 @@
// information; default to "CEF">
// ExternalHandler=<Windows only; Name of the external handler exe to use
// instead of re-launching the main exe; default to empty>
// BrowserCrashForwardingEnabled=<macOS only; True if browser process crashes
// should be forwarded to the system crash
// reporter; default to false>
// ServerURL=<crash server URL; default to empty>
// RateLimitEnabled=<True if uploads should be rate limited; default to true>
// MaxUploadsPerDay=<Max uploads per 24 hours, used if rate limit is enabled;
@@ -85,6 +88,12 @@
// directory. On Linux the CefSettings.browser_subprocess_path value will be
// used. On macOS the existing subprocess app bundle will be used.
//
// If "BrowserCrashForwardingEnabled" is set to true on macOS then browser
// process crashes will be forwarded to the system crash reporter. This results
// in the crash UI dialog being displayed to the user and crash reports being
// logged under "~/Library/Logs/DiagnosticReports". Forwarding of crash reports
// from non-browser processes and Debug builds is always disabled.
//
// If "ServerURL" is set then crashes will be uploaded as a multi-part POST
// request to the specified URL. Otherwise, reports will only be stored locally
// on disk.
@@ -129,7 +138,7 @@ bool CefCrashReportingEnabled();
///
// Sets or clears a specific key-value pair from the crash metadata.
///
/*--cef()--*/
/*--cef(optional_param=value)--*/
void CefSetCrashKeyValue(const CefString& key, const CefString& value);
#endif // CEF_INCLUDE_CEF_CRASH_UTIL_H_

View File

@@ -57,22 +57,34 @@ class CefResponseFilter : public virtual CefBase {
virtual bool InitFilter() =0;
///
// Called to filter a chunk of data. |data_in| is the input buffer containing
// |data_in_size| bytes of pre-filter data (|data_in| will be NULL if
// |data_in_size| is zero). |data_out| is the output buffer that can accept up
// to |data_out_size| bytes of filtered output data. Set |data_in_read| to the
// number of bytes that were read from |data_in|. Set |data_out_written| to
// the number of bytes that were written into |data_out|. If some or all of
// the pre-filter data was read successfully but more data is needed in order
// to continue filtering (filtered output is pending) return
// RESPONSE_FILTER_NEED_MORE_DATA. If some or all of the pre-filter data was
// read successfully and all available filtered output has been written return
// RESPONSE_FILTER_DONE. If an error occurs during filtering return
// RESPONSE_FILTER_ERROR. This method will be called repeatedly until there is
// no more data to filter (resource response is complete), |data_in_read|
// matches |data_in_size| (all available pre-filter bytes have been read), and
// the method returns RESPONSE_FILTER_DONE or RESPONSE_FILTER_ERROR. Do not
// keep a reference to the buffers passed to this method.
// Called to filter a chunk of data. Expected usage is as follows:
//
// A. Read input data from |data_in| and set |data_in_read| to the number of
// bytes that were read up to a maximum of |data_in_size|. |data_in| will
// be NULL if |data_in_size| is zero.
// B. Write filtered output data to |data_out| and set |data_out_written| to
// the number of bytes that were written up to a maximum of
// |data_out_size|. If no output data was written then all data must be
// read from |data_in| (user must set |data_in_read| = |data_in_size|).
// C. Return RESPONSE_FILTER_DONE if all output data was written or
// RESPONSE_FILTER_NEED_MORE_DATA if output data is still pending.
//
// This method will be called repeatedly until the input buffer has been
// fully read (user sets |data_in_read| = |data_in_size|) and there is no
// more input data to filter (the resource response is complete). This method
// may then be called an additional time with an empty input buffer if the
// user filled the output buffer (set |data_out_written| = |data_out_size|)
// and returned RESPONSE_FILTER_NEED_MORE_DATA to indicate that output data is
// still pending.
//
// Calls to this method will stop when one of the following conditions is met:
//
// A. There is no more input data to filter (the resource response is
// complete) and the user sets |data_out_written| = 0 or returns
// RESPONSE_FILTER_DONE to indicate that all data has been written, or;
// B. The user returns RESPONSE_FILTER_ERROR to indicate an error.
//
// Do not keep a reference to the buffers passed to this method.
///
/*--cef(optional_param=data_in,default_retval=RESPONSE_FILTER_ERROR)--*/
virtual FilterStatus Filter(void* data_in,

View File

@@ -166,12 +166,23 @@ typedef struct _cef_settings_t {
///
// The path to a separate executable that will be launched for sub-processes.
// By default the browser process executable is used. See the comments on
// CefExecuteProcess() for details. Also configurable using the
// "browser-subprocess-path" command-line switch.
// If this value is empty on Windows or Linux then the main process executable
// will be used. If this value is empty on macOS then a helper executable must
// exist at "Contents/Frameworks/<app> Helper.app/Contents/MacOS/<app> Helper"
// in the top-level app bundle. See the comments on CefExecuteProcess() for
// details. Also configurable using the "browser-subprocess-path" command-line
// switch.
///
cef_string_t browser_subprocess_path;
///
// The path to the CEF framework directory on macOS. If this value is empty
// then the framework must exist at "Contents/Frameworks/Chromium Embedded
// Framework.framework" in the top-level app bundle. Also configurable using
// the "framework-dir-path" command-line switch.
///
cef_string_t framework_dir_path;
///
// Set to true (1) to have the browser process message loop run in a separate
// thread. If false (0) than the CefDoMessageLoopWork() function must be
@@ -563,12 +574,6 @@ typedef struct _cef_browser_settings_t {
///
cef_state_t javascript_dom_paste;
///
// Controls whether the caret position will be drawn. Also configurable using
// the "enable-caret-browsing" command-line switch.
///
cef_state_t caret_browsing;
///
// Controls whether any plugins will be loaded. Also configurable using the
// "disable-plugins" command-line switch.

View File

@@ -555,6 +555,7 @@ struct CefSettingsTraits {
static inline void clear(struct_type* s) {
cef_string_clear(&s->browser_subprocess_path);
cef_string_clear(&s->framework_dir_path);
cef_string_clear(&s->cache_path);
cef_string_clear(&s->user_data_path);
cef_string_clear(&s->user_agent);
@@ -574,6 +575,9 @@ struct CefSettingsTraits {
cef_string_set(src->browser_subprocess_path.str,
src->browser_subprocess_path.length,
&target->browser_subprocess_path, copy);
cef_string_set(src->framework_dir_path.str,
src->framework_dir_path.length,
&target->framework_dir_path, copy);
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
target->external_message_pump = src->external_message_pump;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
@@ -705,7 +709,6 @@ struct CefBrowserSettingsTraits {
target->javascript_close_windows = src->javascript_close_windows;
target->javascript_access_clipboard = src->javascript_access_clipboard;
target->javascript_dom_paste = src->javascript_dom_paste;
target->caret_browsing = src->caret_browsing;
target->plugins = src->plugins;
target->universal_access_from_file_urls =
src->universal_access_from_file_urls;
@@ -983,7 +986,8 @@ struct CefCompositionUnderlineTraits {
typedef cef_composition_underline_t struct_type;
static inline void init(struct_type* s) {
s->range = {0, 0};
s->range.from = 0;
s->range.to = 0;
s->color = 0;
s->background_color = 0;
s->thick = 0;

View File

@@ -741,7 +741,8 @@ void CefBrowserHostImpl::Print() {
if (!actionable_contents)
return;
printing::CefPrintViewManager::FromWebContents(
actionable_contents)->PrintNow();
actionable_contents)->PrintNow(
actionable_contents->GetRenderViewHost()->GetMainFrame());
} else {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::Print, this));
@@ -762,7 +763,8 @@ void CefBrowserHostImpl::PrintToPDF(const CefString& path,
callback.get(), path);
}
printing::CefPrintViewManager::FromWebContents(actionable_contents)->
PrintToPDF(base::FilePath(path), settings, pdf_callback);
PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path),
settings, pdf_callback);
} else {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::PrintToPDF, this, path, settings,
@@ -1413,7 +1415,8 @@ void CefBrowserHostImpl::DestroyBrowser() {
menu_manager_->Destroy();
// Notify any observers that may have state associated with this browser.
FOR_EACH_OBSERVER(Observer, observers_, OnBrowserDestroyed(this));
for (auto& observer : observers_)
observer.OnBrowserDestroyed(this);
// Disassociate the platform delegate from this browser.
platform_delegate_->BrowserDestroyed(this);
@@ -2108,11 +2111,12 @@ void CefBrowserHostImpl::UpdateTargetURL(content::WebContents* source,
}
}
bool CefBrowserHostImpl::AddMessageToConsole(content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) {
bool CefBrowserHostImpl::DidAddMessageToConsole(
content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) {
if (client_.get()) {
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
if (handler.get())
@@ -2229,26 +2233,13 @@ bool CefBrowserHostImpl::CanDragEnter(
return true;
}
bool CefBrowserHostImpl::ShouldCreateWebContents(
void CefBrowserHostImpl::GetCustomWebContentsView(
content::WebContents* web_contents,
int route_id,
int main_frame_route_id,
int32_t main_frame_widget_route_id,
WindowContainerType window_container_type,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace,
content::WebContentsView** view,
content::RenderViewHostDelegateView** delegate_view) {
// In cases where the navigation will occur in a new render process the
// |route_id| value will be MSG_ROUTING_NONE here (because the existing
// renderer will not be able to communicate with the new renderer) and
// OpenURLFromTab will be called after WebContentsCreated.
CefBrowserInfoManager::GetInstance()->ShouldCreateWebContents(
CefBrowserInfoManager::GetInstance()->GetCustomWebContentsView(
web_contents, target_url, view, delegate_view);
return true;
}
void CefBrowserHostImpl::WebContentsCreated(
@@ -2355,28 +2346,21 @@ void CefBrowserHostImpl::RequestMediaAccessPermission(
bool webcam_requested =
(request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE);
if (microphone_requested || webcam_requested) {
switch (request.request_type) {
case content::MEDIA_OPEN_DEVICE_PEPPER_ONLY:
case content::MEDIA_DEVICE_ACCESS:
case content::MEDIA_GENERATE_STREAM:
case content::MEDIA_ENUMERATE_DEVICES:
// Pick the desired device or fall back to the first available of the
// given type.
if (microphone_requested) {
CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
request.requested_audio_device_id,
true,
false,
&devices);
}
if (webcam_requested) {
CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
request.requested_video_device_id,
false,
true,
&devices);
}
break;
// Pick the desired device or fall back to the first available of the
// given type.
if (microphone_requested) {
CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
request.requested_audio_device_id,
true,
false,
&devices);
}
if (webcam_requested) {
CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
request.requested_video_device_id,
false,
true,
&devices);
}
}
@@ -3015,6 +2999,24 @@ gfx::Point CefBrowserHostImpl::GetScreenPoint(const gfx::Point& view) const {
return gfx::Point();
}
void CefBrowserHostImpl::StartDragging(
const content::DropData& drop_data,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) {
if (platform_delegate_) {
platform_delegate_->StartDragging(drop_data, allowed_ops, image,
image_offset, event_info, source_rwh);
}
}
void CefBrowserHostImpl::UpdateDragCursor(blink::WebDragOperation operation) {
if (platform_delegate_)
platform_delegate_->UpdateDragCursor(operation);
}
void CefBrowserHostImpl::OnAddressChange(CefRefPtr<CefFrame> frame,
const GURL& url) {
if (client_.get()) {

View File

@@ -32,6 +32,11 @@
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
namespace content {
struct DragEventSourceInfo;
class RenderWidgetHostImpl;
}
namespace net {
class URLRequest;
}
@@ -323,6 +328,15 @@ class CefBrowserHostImpl : public CefBrowserHost,
// scaling will be applied to the result.
gfx::Point GetScreenPoint(const gfx::Point& view) const;
void StartDragging(
const content::DropData& drop_data,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh);
void UpdateDragCursor(blink::WebDragOperation operation);
// Thread safe accessors.
const CefBrowserSettings& settings() const { return settings_; }
CefRefPtr<CefClient> client() const { return client_; }
@@ -365,11 +379,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
void CloseContents(content::WebContents* source) override;
void UpdateTargetURL(content::WebContents* source,
const GURL& url) override;
bool AddMessageToConsole(content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
bool DidAddMessageToConsole(content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
void BeforeUnloadFired(content::WebContents* source,
bool proceed,
bool* proceed_to_fire_unload) override;
@@ -388,16 +402,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::WebContents* source,
const content::DropData& data,
blink::WebDragOperationsMask operations_allowed) override;
bool ShouldCreateWebContents(
void GetCustomWebContentsView(
content::WebContents* web_contents,
int route_id,
int main_frame_route_id,
int32_t main_frame_widget_route_id,
WindowContainerType window_container_type,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace,
content::WebContentsView** view,
content::RenderViewHostDelegateView** delegate_view) override;
void WebContentsCreated(content::WebContents* source_contents,

View File

@@ -257,7 +257,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
return allow;
}
void CefBrowserInfoManager::ShouldCreateWebContents(
void CefBrowserInfoManager::GetCustomWebContentsView(
content::WebContents* web_contents,
const GURL& target_url,
content::WebContentsView** view,
@@ -276,7 +276,7 @@ void CefBrowserInfoManager::ShouldCreateWebContents(
}
pending_popup->step =
CefBrowserInfoManager::PendingPopup::SHOULD_CREATE_WEB_CONTENTS;
CefBrowserInfoManager::PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW;
PushPendingPopup(std::move(pending_popup));
}
@@ -292,7 +292,7 @@ void CefBrowserInfoManager::WebContentsCreated(
std::unique_ptr<CefBrowserInfoManager::PendingPopup> pending_popup =
PopPendingPopup(
CefBrowserInfoManager::PendingPopup::SHOULD_CREATE_WEB_CONTENTS,
CefBrowserInfoManager::PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW,
source_contents->GetRenderViewHost()->GetProcess()->GetID(),
source_contents->GetRenderViewHost()->GetRoutingID(),
target_url);

View File

@@ -72,9 +72,9 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
int opener_render_frame_id,
bool* no_javascript_access);
// Called from CefBrowserHostImpl::ShouldCreateWebContents. See comments on
// Called from CefBrowserHostImpl::GetCustomWebContentsView. See comments on
// PendingPopup for more information.
void ShouldCreateWebContents(
void GetCustomWebContentsView(
content::WebContents* web_contents,
const GURL& target_url,
content::WebContentsView** view,
@@ -138,7 +138,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// an extension guest view then the popup is canceled and
// CefBrowserHostImpl::OpenURLFromTab is called.
// And then the following calls may occur at the same time:
// - CefBrowserHostImpl::ShouldCreateWebContents (UIT)
// - CefBrowserHostImpl::GetCustomWebContentsView (UIT)
// Creates the OSR views for windowless popups.
// - CefBrowserHostImpl::WebContentsCreated (UIT)
// Creates the CefBrowserHostImpl representation for the popup.
@@ -150,7 +150,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// to differentiate between them at different processing steps.
enum Step {
CAN_CREATE_WINDOW,
SHOULD_CREATE_WEB_CONTENTS
GET_CUSTOM_WEB_CONTENTS_VIEW,
} step;
// Initial state from ViewHostMsg_CreateWindow.
@@ -170,11 +170,11 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate;
};
// Between the calls to CanCreateWindow and ShouldCreateWebContents
// Between the calls to CanCreateWindow and GetCustomWebContentsView
// RenderViewHostImpl::CreateNewWindow() will call
// RenderProcessHostImpl::FilterURL() which, in the case of "javascript:"
// URIs, rewrites the URL to "about:blank". We need to apply the same filter
// otherwise ShouldCreateWebContents will fail to retrieve the PopupInfo.
// otherwise GetCustomWebContentsView will fail to retrieve the PopupInfo.
static void FilterPendingPopupURL(
int render_process_id,
std::unique_ptr<PendingPopup> pending_popup);

View File

@@ -18,6 +18,7 @@
#include "libcef/browser/extensions/extensions_browser_client.h"
#include "libcef/browser/extensions/extension_system_factory.h"
#include "libcef/browser/net/chrome_scheme_handler.h"
#include "libcef/browser/printing/printing_message_filter.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_client.h"
#include "libcef/common/extensions/extensions_util.h"
@@ -181,6 +182,8 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
extensions::CefExtensionSystemFactory::GetInstance();
}
printing::CefPrintingMessageFilter::EnsureShutdownNotifierFactoryBuilt();
CefRequestContextSettings settings;
CefContext::Get()->PopulateRequestContextSettings(&settings);

View File

@@ -177,6 +177,21 @@ void CefBrowserPlatformDelegate::DragTargetDrop(const CefMouseEvent& event) {
NOTREACHED();
}
void CefBrowserPlatformDelegate::StartDragging(
const content::DropData& drop_data,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) {
NOTREACHED();
}
void CefBrowserPlatformDelegate::UpdateDragCursor(
blink::WebDragOperation operation) {
NOTREACHED();
}
void CefBrowserPlatformDelegate::DragSourceEndedAt(
int x, int y,
cef_drag_operations_mask_t op) {

View File

@@ -244,6 +244,14 @@ class CefBrowserPlatformDelegate {
cef_drag_operations_mask_t allowed_ops);
virtual void DragTargetDragLeave();
virtual void DragTargetDrop(const CefMouseEvent& event);
virtual void StartDragging(
const content::DropData& drop_data,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh);
virtual void UpdateDragCursor(blink::WebDragOperation operation);
virtual void DragSourceEndedAt(int x, int y,
cef_drag_operations_mask_t op);
virtual void DragSourceSystemDragEnded();

View File

@@ -22,7 +22,6 @@ std::string ChromeProfileStub::GetProfileUserName() const {
}
Profile::ProfileType ChromeProfileStub::GetProfileType() const {
NOTREACHED();
return REGULAR_PROFILE;
}

View File

@@ -39,7 +39,9 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/json/json_reader.h"
#include "base/path_service.h"
#include "cef/grit/cef_resources.h"
#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
#include "chrome/common/chrome_switches.h"
#include "components/navigation_interception/intercept_navigation_throttle.h"
@@ -60,6 +62,7 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/service_names.mojom.h"
#include "content/public/common/storage_quota_params.h"
#include "content/public/common/web_preferences.h"
#include "extensions/browser/extensions_browser_client.h"
@@ -72,6 +75,7 @@
#include "net/ssl/ssl_cert_request_info.h"
#include "ppapi/host/ppapi_host.h"
#include "third_party/WebKit/public/web/WebWindowFeatures.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
#include "url/gurl.h"
@@ -459,9 +463,10 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
const int id = host->GetID();
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
host->GetChannel()->AddFilter(new CefBrowserMessageFilter(id));
host->AddFilter(new printing::CefPrintingMessageFilter(id));
host->AddFilter(new printing::CefPrintingMessageFilter(id, profile));
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
host->AddFilter(new SpellCheckMessageFilter(id));
@@ -470,18 +475,16 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
#endif
}
content::BrowserContext* browser_context = host->GetBrowserContext();
host->AddFilter(new CefPluginInfoMessageFilter(id,
static_cast<CefBrowserContext*>(browser_context)));
static_cast<CefBrowserContext*>(profile)));
if (extensions::ExtensionsEnabled()) {
host->AddFilter(
new extensions::ExtensionMessageFilter(id, browser_context));
new extensions::ExtensionMessageFilter(id, profile));
host->AddFilter(
new extensions::IOThreadExtensionMessageFilter(id, browser_context));
new extensions::IOThreadExtensionMessageFilter(id, profile));
host->AddFilter(
new extensions::ExtensionsGuestViewMessageFilter(id, browser_context));
new extensions::ExtensionsGuestViewMessageFilter(id, profile));
}
// If the renderer process crashes then the host may already have
@@ -491,7 +494,7 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
host->AddObserver(CefBrowserInfoManager::GetInstance());
host->Send(new CefProcessMsg_SetIsIncognitoProcess(
browser_context->IsOffTheRecord()));
profile->IsOffTheRecord()));
}
bool CefContentBrowserClient::ShouldUseProcessPerSite(
@@ -589,6 +592,25 @@ void CefContentBrowserClient::SiteInstanceDeleting(
site_instance->GetId()));
}
std::unique_ptr<base::Value>
CefContentBrowserClient::GetServiceManifestOverlay(
const std::string& name) {
int id = -1;
if (name == content::mojom::kBrowserServiceName)
id = IDR_CEF_BROWSER_MANIFEST_OVERLAY;
else if (name == content::mojom::kRendererServiceName)
id = IDR_CEF_RENDERER_MANIFEST_OVERLAY;
else if (name == content::mojom::kUtilityServiceName)
id = IDR_CEF_UTILITY_MANIFEST_OVERLAY;
if (id == -1)
return nullptr;
base::StringPiece manifest_contents =
ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
id, ui::ScaleFactor::SCALE_FACTOR_NONE);
return base::JSONReader::Read(manifest_contents);
}
void CefContentBrowserClient::AppendExtraCommandLineSwitches(
base::CommandLine* command_line, int child_process_id) {
const base::CommandLine* browser_cmd =
@@ -599,6 +621,9 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
// associated values) if present in the browser command line.
static const char* const kSwitchNames[] = {
switches::kDisablePackLoading,
#if defined(OS_MACOSX)
switches::kFrameworkDirPath,
#endif
switches::kLang,
switches::kLocalesDirPath,
switches::kLogFile,
@@ -658,7 +683,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
arraysize(kSwitchNames));
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
if (!browser_cmd->HasSwitch(switches::kNoSandbox)) {
// Pass the Widevine CDM path to the Zygote process. See comments in
// CefWidevineLoader::AddPepperPlugins.

View File

@@ -46,6 +46,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
bool IsHandledURL(const GURL& url) override;
void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
std::unique_ptr<base::Value> GetServiceManifestOverlay(
const std::string& name) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override;
content::QuotaPermissionContext*
@@ -104,7 +106,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
#endif
#if defined(OS_WIN)
const wchar_t* GetResourceDllName() override;
const wchar_t* GetResourceDllName();
bool PreSpawnRenderer(sandbox::TargetPolicy* policy) override;
#endif

View File

@@ -61,7 +61,6 @@ class CefForceShutdown {
} g_force_shutdown;
#if defined(OS_WIN)
#if defined(ARCH_CPU_X86_64)
// VS2013 only checks the existence of FMA3 instructions, not the enabled-ness
// of them at the OS level (this is fixed in VS2015). We force off usage of
@@ -85,7 +84,6 @@ void InitCrashReporter() {
initialized = true;
SignalInitializeCrashReporting();
}
#endif // defined(OS_WIN)
#if defined(OS_MACOSX) || defined(OS_WIN)
@@ -469,7 +467,7 @@ void CefContext::OnContextInitialized() {
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->
OnContextInitialized();
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
CefWidevineLoader::GetInstance()->OnContextInitialized();
#endif

View File

@@ -49,8 +49,7 @@ void CefMimeHandlerViewGuestDelegate::OverrideWebContentsCreateParams(
}
}
bool CefMimeHandlerViewGuestDelegate::OnGuestAttached(
content::WebContentsView* guest_view,
void CefMimeHandlerViewGuestDelegate::OnGuestAttached(
content::WebContentsView* parent_view) {
content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents);
@@ -68,24 +67,9 @@ bool CefMimeHandlerViewGuestDelegate::OnGuestAttached(
info->guest_render_id_manager()->add_render_frame_id(
main_frame_host->GetProcess()->GetID(),
main_frame_host->GetRoutingID());
if (owner_browser->IsWindowless()) {
// Use the OSR view instead of the default WebContentsViewGuest.
content::WebContentsImpl* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents);
CefWebContentsViewOSR* view_osr =
static_cast<CefWebContentsViewOSR*>(
web_contents_impl->GetView());
view_osr->set_web_contents(web_contents);
view_osr->set_guest(web_contents_impl->GetBrowserPluginGuest());
return true;
}
return false;
}
bool CefMimeHandlerViewGuestDelegate::OnGuestDetached(
content::WebContentsView* guest_view,
void CefMimeHandlerViewGuestDelegate::OnGuestDetached(
content::WebContentsView* parent_view) {
content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents);
@@ -113,21 +97,6 @@ bool CefMimeHandlerViewGuestDelegate::OnGuestDetached(
context->OnRenderFrameDeleted(render_process_id, render_frame_id,
is_main_frame, true);
}
// Do nothing when the browser is windowless.
return owner_browser->IsWindowless();
}
bool CefMimeHandlerViewGuestDelegate::CreateViewForWidget(
content::WebContentsView* guest_view,
content::RenderWidgetHost* render_widget_host) {
CefRefPtr<CefBrowserHostImpl> owner_browser = GetOwnerBrowser(guest_);
if (owner_browser->IsWindowless()) {
static_cast<CefWebContentsViewOSR*>(guest_view)->CreateViewForWidget(
render_widget_host, true);
return true;
}
return false;
}
bool CefMimeHandlerViewGuestDelegate::HandleContextMenu(

View File

@@ -22,13 +22,8 @@ class CefMimeHandlerViewGuestDelegate : public MimeHandlerViewGuestDelegate {
// MimeHandlerViewGuestDelegate methods.
void OverrideWebContentsCreateParams(
content::WebContents::CreateParams* params) override;
bool OnGuestAttached(content::WebContentsView* guest_view,
content::WebContentsView* parent_view) override;
bool OnGuestDetached(content::WebContentsView* guest_view,
content::WebContentsView* parent_view) override;
bool CreateViewForWidget(
content::WebContentsView* guest_view,
content::RenderWidgetHost* render_widget_host) override;
void OnGuestAttached(content::WebContentsView* parent_view) override;
void OnGuestDetached(content::WebContentsView* parent_view) override;
bool HandleContextMenu(content::WebContents* web_contents,
const content::ContextMenuParams& params) override;

View File

@@ -195,8 +195,10 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
weak_ptr_factory_.GetWeakPtr(), callback));
}
void CefJavaScriptDialogManager::CancelActiveAndPendingDialogs(
content::WebContents* web_contents) {
void CefJavaScriptDialogManager::CancelDialogs(
content::WebContents* web_contents,
bool suppress_callbacks,
bool reset_state) {
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();
@@ -212,10 +214,6 @@ void CefJavaScriptDialogManager::CancelActiveAndPendingDialogs(
}
}
void CefJavaScriptDialogManager::ResetDialogState(
content::WebContents* web_contents) {
}
void CefJavaScriptDialogManager::DialogClosed(
const DialogClosedCallback& callback,
bool success,

View File

@@ -41,10 +41,9 @@ class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
content::WebContents* web_contents,
bool is_reload,
const DialogClosedCallback& callback) override;
void CancelActiveAndPendingDialogs(
content::WebContents* web_contents) override;
void ResetDialogState(
content::WebContents* web_contents) override;
void CancelDialogs(content::WebContents* web_contents,
bool suppress_callbacks,
bool reset_state) override;
private:
// Method executed by the callback passed to CefJavaScriptDialogRunner::Run.

View File

@@ -318,17 +318,18 @@ void CefMenuManager::CreateDefaultModel() {
if (params_.is_editable) {
// Editable node.
model_->AddItem(MENU_ID_UNDO, GetLabel(IDS_MENU_UNDO));
model_->AddItem(MENU_ID_REDO, GetLabel(IDS_MENU_REDO));
model_->AddItem(MENU_ID_UNDO, GetLabel(IDS_CONTENT_CONTEXT_UNDO));
model_->AddItem(MENU_ID_REDO, GetLabel(IDS_CONTENT_CONTEXT_REDO));
model_->AddSeparator();
model_->AddItem(MENU_ID_CUT, GetLabel(IDS_MENU_CUT));
model_->AddItem(MENU_ID_COPY, GetLabel(IDS_MENU_COPY));
model_->AddItem(MENU_ID_PASTE, GetLabel(IDS_MENU_PASTE));
model_->AddItem(MENU_ID_DELETE, GetLabel(IDS_MENU_DELETE));
model_->AddItem(MENU_ID_CUT, GetLabel(IDS_CONTENT_CONTEXT_CUT));
model_->AddItem(MENU_ID_COPY, GetLabel(IDS_CONTENT_CONTEXT_COPY));
model_->AddItem(MENU_ID_PASTE, GetLabel(IDS_CONTENT_CONTEXT_PASTE));
model_->AddItem(MENU_ID_DELETE, GetLabel(IDS_CONTENT_CONTEXT_DELETE));
model_->AddSeparator();
model_->AddItem(MENU_ID_SELECT_ALL, GetLabel(IDS_MENU_SELECT_ALL));
model_->AddItem(MENU_ID_SELECT_ALL,
GetLabel(IDS_CONTENT_CONTEXT_SELECTALL));
if (!(params_.edit_flags & CM_EDITFLAG_CAN_UNDO))
model_->SetEnabled(MENU_ID_UNDO, false);
@@ -376,15 +377,16 @@ void CefMenuManager::CreateDefaultModel() {
}
} else if (!params_.selection_text.empty()) {
// Something is selected.
model_->AddItem(MENU_ID_COPY, GetLabel(IDS_MENU_COPY));
model_->AddItem(MENU_ID_COPY, GetLabel(IDS_CONTENT_CONTEXT_COPY));
} else if (!params_.page_url.is_empty() || !params_.frame_url.is_empty()) {
// Page or frame.
model_->AddItem(MENU_ID_BACK, GetLabel(IDS_MENU_BACK));
model_->AddItem(MENU_ID_FORWARD, GetLabel(IDS_MENU_FORWARD));
model_->AddItem(MENU_ID_BACK, GetLabel(IDS_CONTENT_CONTEXT_BACK));
model_->AddItem(MENU_ID_FORWARD, GetLabel(IDS_CONTENT_CONTEXT_FORWARD));
model_->AddSeparator();
model_->AddItem(MENU_ID_PRINT, GetLabel(IDS_MENU_PRINT));
model_->AddItem(MENU_ID_VIEW_SOURCE, GetLabel(IDS_MENU_VIEW_SOURCE));
model_->AddItem(MENU_ID_PRINT, GetLabel(IDS_CONTENT_CONTEXT_PRINT));
model_->AddItem(MENU_ID_VIEW_SOURCE,
GetLabel(IDS_CONTENT_CONTEXT_VIEWPAGESOURCE));
if (!browser_->CanGoBack())
model_->SetEnabled(MENU_ID_BACK, false);

View File

@@ -654,7 +654,8 @@ void CefMenuModelImpl::MenuWillShow() {
delegate_->MenuWillShow(this);
if (menu_model_delegate_)
menu_model_delegate_->MenuWillShow(this);
FOR_EACH_OBSERVER(Observer, observers_, MenuWillShow(this));
for (auto& observer : observers_)
observer.MenuWillShow(this);
}
void CefMenuModelImpl::MenuWillClose() {
@@ -776,7 +777,8 @@ void CefMenuModelImpl::OnMenuClosed() {
delegate_->MenuClosed(this);
if (menu_model_delegate_)
menu_model_delegate_->MenuClosed(this);
FOR_EACH_OBSERVER(Observer, observers_, MenuClosed(this));
for (auto& observer : observers_)
observer.MenuClosed(this);
}
bool CefMenuModelImpl::VerifyContext() {

View File

@@ -20,7 +20,7 @@
#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/web/WebInputEvent.h"
#include "third_party/WebKit/public/platform/WebInputEvent.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"

View File

@@ -17,6 +17,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "cef/grit/cef_strings.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/common/file_chooser_params.h"
#include "net/base/mime_util.h"
#include "ui/base/l10n/l10n_util.h"
@@ -30,10 +31,10 @@ base::string16 GetDescriptionFromMimeType(const std::string& mime_type) {
const char* mime_type;
int string_id;
} kWildCardMimeTypes[] = {
{ "audio", IDS_APP_AUDIO_FILES },
{ "image", IDS_APP_IMAGE_FILES },
{ "text", IDS_APP_TEXT_FILES },
{ "video", IDS_APP_VIDEO_FILES },
{ "audio", IDS_AUDIO_FILES },
{ "image", IDS_IMAGE_FILES },
{ "text", IDS_TEXT_FILES },
{ "video", IDS_VIDEO_FILES },
};
for (size_t i = 0; i < arraysize(kWildCardMimeTypes); ++i) {

View File

@@ -17,6 +17,7 @@
#include "base/win/registry.h"
#include "base/win/scoped_comptr.h"
#include "cef/grit/cef_strings.h"
#include "chrome/grit/generated_resources.h"
#include "net/base/mime_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/win/shell.h"
@@ -131,10 +132,10 @@ std::wstring GetDescriptionFromMimeType(const std::string& mime_type) {
const char* mime_type;
int string_id;
} kWildCardMimeTypes[] = {
{ "audio", IDS_APP_AUDIO_FILES },
{ "image", IDS_APP_IMAGE_FILES },
{ "text", IDS_APP_TEXT_FILES },
{ "video", IDS_APP_VIDEO_FILES },
{ "audio", IDS_AUDIO_FILES },
{ "image", IDS_IMAGE_FILES },
{ "text", IDS_TEXT_FILES },
{ "video", IDS_VIDEO_FILES },
};
for (size_t i = 0; i < arraysize(kWildCardMimeTypes); ++i) {

View File

@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
@@ -404,7 +405,6 @@ CefNativeMenuWin::CefNativeMenuWin(ui::MenuModel* model, HWND system_menu_for)
CefNativeMenuWin::~CefNativeMenuWin() {
if (destroyed_flag_)
*destroyed_flag_ = true;
base::STLDeleteContainerPointers(items_.begin(), items_.end());
DestroyMenu(menu_);
}
@@ -485,7 +485,7 @@ void CefNativeMenuWin::Rebuild(MenuInsertionDelegateWin* delegate) {
void CefNativeMenuWin::UpdateStates() {
// A depth-first walk of the menu items, updating states.
int model_index = 0;
std::vector<ItemData*>::const_iterator it;
ItemDataList::const_iterator it;
for (it = items_.begin(); it != items_.end(); ++it, ++model_index) {
int menu_index = model_index + first_item_index_;
SetMenuItemState(menu_index, model_->IsEnabledAt(model_index),
@@ -567,7 +567,8 @@ LRESULT CALLBACK CefNativeMenuWin::MenuMessageHook(
// The first time this hook is called, that means the menu has successfully
// opened, so call the callback function on all of our listeners.
if (!this_ptr->listeners_called_) {
FOR_EACH_OBSERVER(MenuListener, this_ptr->listeners_, OnMenuOpened());
for (auto& observer : this_ptr->listeners_)
observer.OnMenuOpened();
this_ptr->listeners_called_ = true;
}
@@ -622,7 +623,7 @@ void CefNativeMenuWin::AddMenuItemAt(int menu_index, int model_index) {
else
mii.fType = MFT_OWNERDRAW;
ItemData* item_data = new ItemData;
std::unique_ptr<ItemData> item_data = base::MakeUnique<ItemData>();
item_data->label = base::string16();
ui::MenuModel::ItemType type = model_->GetTypeAt(model_index);
if (type == ui::MenuModel::TYPE_SUBMENU) {
@@ -637,8 +638,8 @@ void CefNativeMenuWin::AddMenuItemAt(int menu_index, int model_index) {
}
item_data->native_menu_win = this;
item_data->model_index = model_index;
items_.insert(items_.begin() + model_index, item_data);
mii.dwItemData = reinterpret_cast<ULONG_PTR>(item_data);
mii.dwItemData = reinterpret_cast<ULONG_PTR>(item_data.get());
items_.insert(items_.begin() + model_index, std::move(item_data));
UpdateMenuItemInfoForString(&mii, model_index,
model_->GetLabelAt(model_index));
InsertMenuItem(menu_, menu_index, TRUE, &mii);
@@ -651,7 +652,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, new ItemData);
items_.insert(items_.begin() + model_index, base::MakeUnique<ItemData>());
InsertMenuItem(menu_, menu_index, TRUE, &mii);
}

View File

@@ -5,6 +5,7 @@
#ifndef CEF_LIBCEF_BROWSER_NATIVE_NATIVE_MENU_WIN_H_
#define CEF_LIBCEF_BROWSER_NATIVE_NATIVE_MENU_WIN_H_
#include <memory>
#include <vector>
#include "libcef/browser/native/menu_wrapper.h"
@@ -119,7 +120,8 @@ class CefNativeMenuWin : public MenuWrapper {
// An object that collects all of the data associated with an individual menu
// item.
struct ItemData;
std::vector<ItemData*> items_;
typedef std::vector<std::unique_ptr<ItemData>> ItemDataList;
ItemDataList items_;
// The window that receives notifications from the menu.
class MenuHostWindow;

View File

@@ -14,7 +14,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "net/base/mime_util.h"
#include "third_party/brotli/dec/decode.h"
#include "ui/base/resource/resource_bundle.h"
namespace scheme {
@@ -49,24 +48,6 @@ std::string GetMimeType(const std::string& filename) {
return "text/plain";
}
bool DecodeBrotli(const base::StringPiece& encoded,
std::string& decoded) {
size_t decoded_size;
const uint8_t* encoded_response_buffer =
reinterpret_cast<const uint8_t*>(encoded.data());
if (!BrotliDecompressedSize(encoded.size(), encoded_response_buffer,
&decoded_size)) {
return false;
}
decoded.resize(decoded_size);
return BrotliDecompressBuffer(encoded.size(), encoded_response_buffer,
&decoded_size,
reinterpret_cast<uint8_t*>(&decoded[0])) ==
BROTLI_RESULT_SUCCESS;
}
class RedirectHandler : public CefResourceHandler {
public:
explicit RedirectHandler(const GURL& url)
@@ -172,16 +153,6 @@ class InternalHandlerFactory : public CefSchemeHandlerFactory {
base::StringPiece piece = CefContentClient::Get()->GetDataResource(
action.resource_id, ui::SCALE_FACTOR_NONE);
if (!piece.empty()) {
std::string decoded;
if (action.encoding ==
InternalHandlerDelegate::Action::ENCODING_BROTLI &&
!DecodeBrotli(piece, decoded)) {
decoded = "Unable to decode content!";
}
if (!decoded.empty())
piece = base::StringPiece(decoded);
action.stream =
CefStreamReader::CreateForData(const_cast<char*>(piece.data()),
piece.size());
@@ -212,8 +183,7 @@ class InternalHandlerFactory : public CefSchemeHandlerFactory {
InternalHandlerDelegate::Action::Action()
: stream_size(-1),
resource_id(-1),
encoding(ENCODING_NONE) {
resource_id(-1) {
}
CefRefPtr<CefSchemeHandlerFactory> CreateInternalHandlerFactory(

View File

@@ -31,10 +31,6 @@ class InternalHandlerDelegate {
// Option 2: Specify a resource id to load static content. May include an
// optional encoding type.
int resource_id;
enum Encoding {
ENCODING_NONE,
ENCODING_BROTLI,
} encoding;
// Option 3: Redirect to the specified URL.
GURL redirect_url;

View File

@@ -9,7 +9,7 @@
#include "include/cef_urlrequest.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/net/response_filter_wrapper.h"
#include "libcef/browser/net/source_stream.h"
#include "libcef/browser/net/url_request_user_data.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/request_impl.h"
@@ -23,16 +23,11 @@
#include "components/prefs/pref_service.h"
#include "content/public/common/content_switches.h"
#include "net/base/net_errors.h"
#include "net/filter/filter.h"
#include "net/http/http_util.h"
#include "net/url_request/url_request.h"
namespace {
// Buffer size allocated when filtering data.
// Should match the value in net/filter/filter.cc.
const int kFilterBufSize = 32 * 1024;
class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
public:
typedef net::CompletionCallback CallbackType;
@@ -266,6 +261,41 @@ bool CefNetworkDelegate::AreStrictSecureCookiesEnabled() {
base::CompareCase::INSENSITIVE_ASCII);
}
std::unique_ptr<net::SourceStream> CefNetworkDelegate::CreateSourceStream(
net::URLRequest* request,
std::unique_ptr<net::SourceStream> upstream) {
CefRefPtr<CefResponseFilter> cef_filter;
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForRequest(request);
if (browser.get()) {
CefRefPtr<CefClient> client = browser->GetClient();
if (client.get()) {
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
if (handler.get()) {
CefRefPtr<CefFrame> frame = browser->GetFrameForRequest(request);
CefRefPtr<CefRequestImpl> cefRequest = new CefRequestImpl();
cefRequest->Set(request);
cefRequest->SetReadOnly(true);
CefRefPtr<CefResponseImpl> cefResponse = new CefResponseImpl();
cefResponse->Set(request);
cefResponse->SetReadOnly(true);
cef_filter = handler->GetResourceResponseFilter(browser.get(), frame,
cefRequest.get(),
cefResponse.get());
}
}
}
if (cef_filter && cef_filter->InitFilter())
return base::MakeUnique<CefSourceStream>(cef_filter, std::move(upstream));
return upstream;
}
int CefNetworkDelegate::OnBeforeURLRequest(
net::URLRequest* request,
const net::CompletionCallback& callback,
@@ -442,55 +472,3 @@ bool CefNetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const {
bool CefNetworkDelegate::OnAreStrictSecureCookiesEnabled() const {
return AreStrictSecureCookiesEnabled();
}
net::Filter* CefNetworkDelegate::SetupFilter(net::URLRequest* request,
net::Filter* filter_list) {
CefRefPtr<CefResponseFilter> cef_filter;
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForRequest(request);
if (browser.get()) {
CefRefPtr<CefClient> client = browser->GetClient();
if (client.get()) {
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
if (handler.get()) {
CefRefPtr<CefFrame> frame = browser->GetFrameForRequest(request);
CefRefPtr<CefRequestImpl> cefRequest = new CefRequestImpl();
cefRequest->Set(request);
cefRequest->SetReadOnly(true);
CefRefPtr<CefResponseImpl> cefResponse = new CefResponseImpl();
cefResponse->Set(request);
cefResponse->SetReadOnly(true);
cef_filter = handler->GetResourceResponseFilter(browser.get(), frame,
cefRequest.get(),
cefResponse.get());
}
}
}
if (cef_filter.get() && cef_filter->InitFilter()) {
std::unique_ptr<CefResponseFilterWrapper> wrapper(
new CefResponseFilterWrapper(cef_filter, filter_list != nullptr));
wrapper->InitBuffer(kFilterBufSize);
if (filter_list) {
// Install the wrapper at the end of the filter list.
net::Filter* last_filter = filter_list;
do {
if (!last_filter->next_filter_.get()) {
last_filter->next_filter_ = std::move(wrapper);
break;
}
last_filter = last_filter->next_filter_.get();
} while (last_filter);
} else {
// Only the wrapper exists.
filter_list = wrapper.release();
}
}
return filter_list;
}

View File

@@ -31,6 +31,9 @@ class CefNetworkDelegate : public net::NetworkDelegateImpl {
private:
// net::NetworkDelegate methods.
std::unique_ptr<net::SourceStream> CreateSourceStream(
net::URLRequest* request,
std::unique_ptr<net::SourceStream> upstream) override;
int OnBeforeURLRequest(net::URLRequest* request,
const net::CompletionCallback& callback,
GURL* new_url) override;
@@ -44,8 +47,6 @@ class CefNetworkDelegate : public net::NetworkDelegateImpl {
const base::FilePath& path) const override;
bool OnAreExperimentalCookieFeaturesEnabled() const override;
bool OnAreStrictSecureCookiesEnabled() const override;
net::Filter* SetupFilter(net::URLRequest* request,
net::Filter* filter_list) override;
// Weak, owned by our owner (CefURLRequestContextGetterImpl).
BooleanPrefMember* force_google_safesearch_;

View File

@@ -1,71 +0,0 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/net/response_filter_wrapper.h"
#include "base/logging.h"
// FilterType is used for logging purposes only.
CefResponseFilterWrapper::CefResponseFilterWrapper(
CefRefPtr<CefResponseFilter> cef_filter,
bool has_other_filters)
: Filter(Filter::FILTER_TYPE_UNSUPPORTED),
cef_filter_(cef_filter),
has_other_filters_(has_other_filters) {
DCHECK(cef_filter_.get());
}
CefResponseFilterWrapper::~CefResponseFilterWrapper() {
}
net::Filter::FilterStatus CefResponseFilterWrapper::ReadFilteredData(
char* dest_buffer,
int* dest_len) {
if (!dest_buffer || !dest_len || *dest_len <= 0)
return net::Filter::FILTER_ERROR;
size_t data_in_size = static_cast<size_t>(stream_data_len_);
size_t data_in_read = 0;
size_t data_out_size = static_cast<size_t>(*dest_len);
size_t data_out_write = 0;
cef_response_filter_status_t cef_status = cef_filter_->Filter(
next_stream_data_, data_in_size, data_in_read,
dest_buffer, data_out_size, data_out_write);
// Return early if there's an error.
if (cef_status == RESPONSE_FILTER_ERROR)
return net::Filter::FILTER_ERROR;
// Normalize the out values.
if (data_in_read > data_in_size) {
LOG(ERROR) <<
"potential buffer overflow; data_in_read exceeds data_in_size";
data_in_read = data_in_size;
}
if (data_out_write > data_out_size) {
LOG(ERROR) <<
"potential buffer overflow; data_out_write exceeds data_out_size";
data_out_write = data_out_size;
}
// Output the number of bytes written.
*dest_len = static_cast<int>(data_out_write);
if (data_in_size - data_in_read > 0U) {
// There are bytes left so adjust the stream pointer and return FILTER_OK.
next_stream_data_ += data_in_read;
stream_data_len_ -= static_cast<int>(data_in_read);
return Filter::FILTER_OK;
}
// No bytes left. Might need more data or might be done.
// If |has_other_filters_| is true then we must return FILTER_NEED_MORE_DATA
// or additional data will not be sent.
next_stream_data_ = nullptr;
stream_data_len_ = 0;
if (cef_status == RESPONSE_FILTER_NEED_MORE_DATA || has_other_filters_)
return Filter::FILTER_NEED_MORE_DATA;
return Filter::FILTER_DONE;
}

View File

@@ -1,41 +0,0 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_NET_RESPONSE_FILTER_WRAPPER_H_
#define CEF_LIBCEF_BROWSER_NET_RESPONSE_FILTER_WRAPPER_H_
#include "include/cef_response_filter.h"
#include "base/macros.h"
#include "net/filter/filter.h"
class CefResponseFilterWrapper : public net::Filter {
public:
CefResponseFilterWrapper(CefRefPtr<CefResponseFilter> cef_filter,
bool has_other_filters);
~CefResponseFilterWrapper() override;
// Decodes the pre-filter data and writes the output into the dest_buffer
// passed in.
// The function returns FilterStatus. See filter.h for its description.
//
// Upon entry, *dest_len is the total size (in number of chars) of the
// destination buffer. Upon exit, *dest_len is the actual number of chars
// written into the destination buffer.
//
// This function will fail if there is no pre-filter data in the
// stream_buffer_. On the other hand, *dest_len can be 0 upon successful
// return. For example, the internal filter may process some pre-filter data
// but not produce output yet.
FilterStatus ReadFilteredData(char* dest_buffer, int* dest_len) override;
private:
CefRefPtr<CefResponseFilter> cef_filter_;
const bool has_other_filters_;
DISALLOW_COPY_AND_ASSIGN(CefResponseFilterWrapper);
};
#endif // CEF_LIBCEF_BROWSER_NET_RESPONSE_FILTER_WRAPPER_H_

View File

@@ -14,6 +14,7 @@
#include "base/threading/sequenced_worker_pool.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/url_constants.h"
#include "net/net_features.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"
@@ -26,7 +27,7 @@ void InstallInternalProtectedHandlers(
net::URLRequestJobFactoryImpl* job_factory,
CefURLRequestManager* request_manager,
content::ProtocolHandlerMap* protocol_handlers,
net::FtpTransactionFactory* ftp_transaction_factory) {
net::HostResolver* host_resolver) {
protocol_handlers->insert(
std::make_pair(url::kDataScheme,
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
@@ -38,11 +39,11 @@ void InstallInternalProtectedHandlers(
content::BrowserThread::GetBlockingPool()->
GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))));
#if !defined(DISABLE_FTP_SUPPORT)
#if !BUILDFLAG(DISABLE_FTP_SUPPORT)
protocol_handlers->insert(
std::make_pair(url::kFtpScheme,
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
new net::FtpProtocolHandler(ftp_transaction_factory))));
net::FtpProtocolHandler::Create(host_resolver).release())));
#endif
for (content::ProtocolHandlerMap::iterator it =

View File

@@ -12,7 +12,7 @@
#include "url/gurl.h"
namespace net {
class FtpTransactionFactory;
class HostResolver;
class URLRequestJobFactoryImpl;
}
@@ -26,7 +26,7 @@ void InstallInternalProtectedHandlers(
net::URLRequestJobFactoryImpl* job_factory,
CefURLRequestManager* request_manager,
content::ProtocolHandlerMap* protocol_handlers,
net::FtpTransactionFactory* ftp_transaction_factory);
net::HostResolver* host_resolver);
// Register the internal scheme handlers that can be overridden.
void RegisterInternalHandlers(CefURLRequestManager* request_manager);

View File

@@ -0,0 +1,77 @@
// Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/net/source_stream.h"
#include <utility>
#include "net/base/io_buffer.h"
// Use TYPE_INVALID so that URLRequestJob::NotifyHeadersComplete() doesn't
// assume that the "content-length" header is accurate.
CefSourceStream::CefSourceStream(
CefRefPtr<CefResponseFilter> cef_filter,
std::unique_ptr<net::SourceStream> upstream)
: net::FilterSourceStream(net::SourceStream::TYPE_INVALID,
std::move(upstream)),
cef_filter_(cef_filter) {
}
int CefSourceStream::FilterData(net::IOBuffer* output_buffer,
int output_buffer_size,
net::IOBuffer* input_buffer,
int input_buffer_size,
int* consumed_bytes,
bool upstream_eof_reached) {
if (!output_buffer || output_buffer_size <= 0)
return net::ERR_CONTENT_DECODING_FAILED;
if (input_buffer_size == 0 && last_status_ == RESPONSE_FILTER_DONE) {
// No more input data. Respect the client's desire to be done with
// outputting data.
*consumed_bytes = 0;
return 0;
}
size_t data_in_size = static_cast<size_t>(input_buffer_size);
size_t data_in_read = 0;
size_t data_out_size = static_cast<size_t>(output_buffer_size);
size_t data_out_written = 0;
last_status_ = cef_filter_->Filter(
data_in_size > 0 ? input_buffer->data() : nullptr,
data_in_size, data_in_read,
output_buffer->data(), data_out_size, data_out_written);
// Return early if there's an error.
if (last_status_ == RESPONSE_FILTER_ERROR)
return net::ERR_CONTENT_DECODING_FAILED;
// Validate the out values.
if (data_in_read > data_in_size) {
LOG(ERROR) << "potential buffer overflow; data_in_read > data_in_size";
return net::ERR_CONTENT_DECODING_FAILED;
}
if (data_out_written > data_out_size) {
LOG(ERROR) << "potential buffer overflow; data_out_written > data_out_size";
return net::ERR_CONTENT_DECODING_FAILED;
}
// If FilterData() returns 0, *|consumed_bytes| must be equal to
// |input_buffer_size|.
if (data_out_written == 0 && data_in_read != data_in_size) {
LOG(ERROR) << "when no data is written all input must be consumed; "
"data_out_written == 0 && data_in_read != data_in_size";
return net::ERR_CONTENT_DECODING_FAILED;
}
*consumed_bytes = static_cast<int>(data_in_read);
// Output the number of bytes written.
return static_cast<int>(data_out_written);
}
std::string CefSourceStream::GetTypeAsString() const {
return "cef_filter";
}

View File

@@ -0,0 +1,34 @@
// Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_NET_SOURCE_STREAM_H_
#define CEF_LIBCEF_BROWSER_NET_SOURCE_STREAM_H_
#include "include/cef_response_filter.h"
#include "base/macros.h"
#include "net/filter/filter_source_stream.h"
class CefSourceStream : public net::FilterSourceStream {
public:
CefSourceStream(CefRefPtr<CefResponseFilter> cef_filter,
std::unique_ptr<net::SourceStream> upstream);
int FilterData(net::IOBuffer* output_buffer,
int output_buffer_size,
net::IOBuffer* input_buffer,
int input_buffer_size,
int* consumed_bytes,
bool upstream_eof_reached) override;
std::string GetTypeAsString() const override;
private:
CefRefPtr<CefResponseFilter> cef_filter_;
cef_response_filter_status_t last_status_ = RESPONSE_FILTER_NEED_MORE_DATA;
DISALLOW_COPY_AND_ASSIGN(CefSourceStream);
};
#endif // CEF_LIBCEF_BROWSER_NET_SOURCE_STREAM_H_

View File

@@ -322,20 +322,16 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
std::move(main_backend),
true /* set_up_quic_server_info */)));
#if !defined(DISABLE_FTP_SUPPORT)
ftp_transaction_factory_.reset(
new net::FtpNetworkLayer(network_session_params.host_resolver));
#endif
std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory(
new net::URLRequestJobFactoryImpl());
url_request_manager_.reset(new CefURLRequestManager(job_factory.get()));
// Install internal scheme handlers that cannot be overridden.
scheme::InstallInternalProtectedHandlers(job_factory.get(),
url_request_manager_.get(),
&protocol_handlers_,
ftp_transaction_factory_.get());
scheme::InstallInternalProtectedHandlers(
job_factory.get(),
url_request_manager_.get(),
&protocol_handlers_,
network_session_params.host_resolver);
protocol_handlers_.clear();
// Register internal scheme handlers that can be overridden.

View File

@@ -105,7 +105,6 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
std::unique_ptr<net::HttpAuthPreferences> http_auth_preferences_;
std::unique_ptr<CefURLRequestContextImpl> url_request_context_;
std::unique_ptr<CefURLRequestManager> url_request_manager_;
std::unique_ptr<net::FtpTransactionFactory> ftp_transaction_factory_;
content::ProtocolHandlerMap protocol_handlers_;
content::URLRequestInterceptorScopedVector request_interceptors_;

View File

@@ -24,6 +24,8 @@ CefURLRequestContextProxy::CefURLRequestContextProxy(
set_host_resolver(parent->host_resolver());
set_cert_verifier(parent->cert_verifier());
set_transport_security_state(parent->transport_security_state());
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_ssl_config_service(parent->ssl_config_service());

View File

@@ -11,6 +11,8 @@
#include "libcef/browser/osr/web_contents_view_osr.h"
#include "libcef/common/drag_data_impl.h"
#include "content/browser/renderer_host/render_widget_host_input_event_router.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_view_host.h"
CefBrowserPlatformDelegateOsr::CefBrowserPlatformDelegateOsr(
@@ -38,7 +40,7 @@ void CefBrowserPlatformDelegateOsr::WebContentsCreated(
DCHECK(!view_osr_->web_contents());
// Associate the WebContents with the OSR view.
view_osr_->set_web_contents(web_contents);
view_osr_->WebContentsCreated(web_contents);
}
void CefBrowserPlatformDelegateOsr::BrowserCreated(
@@ -247,52 +249,119 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragEnter(
CefRefPtr<CefDragData> drag_data,
const CefMouseEvent& event,
cef_drag_operations_mask_t allowed_ops) {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(browser_->web_contents());
if (!web_contents)
return;
if (current_rvh_for_drag_)
DragTargetDragLeave();
const gfx::Point client_pt(event.x, event.y);
gfx::Point transformed_pt;
current_rwh_for_drag_ =
web_contents->GetInputEventRouter()->GetRenderWidgetHostAtPoint(
web_contents->GetRenderViewHost()->GetWidget()->GetView(),
client_pt, &transformed_pt)->GetWeakPtr();
current_rvh_for_drag_ = web_contents->GetRenderViewHost();
drag_data_ = drag_data;
drag_allowed_ops_ = allowed_ops;
CefDragDataImpl* data_impl = static_cast<CefDragDataImpl*>(drag_data.get());
base::AutoLock lock_scope(data_impl->lock());
content::DropData* drop_data = data_impl->drop_data();
const gfx::Point client_pt(event.x, event.y);
const gfx::Point& screen_pt = GetScreenPoint(client_pt);
blink::WebDragOperationsMask ops =
static_cast<blink::WebDragOperationsMask>(allowed_ops);
int modifiers = TranslateModifiers(event.modifiers);
rvh->FilterDropData(drop_data);
rvh->DragTargetDragEnter(*drop_data, client_pt, screen_pt, ops, modifiers);
current_rwh_for_drag_->FilterDropData(drop_data);
// Give the delegate an opportunity to cancel the drag.
if (web_contents->GetDelegate() &&
!web_contents->GetDelegate()->CanDragEnter(
web_contents, *drop_data, ops)) {
drag_data_ = nullptr;
return;
}
current_rwh_for_drag_->DragTargetDragEnter(
*drop_data, transformed_pt, screen_pt, ops, modifiers);
}
void CefBrowserPlatformDelegateOsr::DragTargetDragOver(
const CefMouseEvent& event,
cef_drag_operations_mask_t allowed_ops) {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
if (!drag_data_)
return;
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(browser_->web_contents());
if (!web_contents)
return;
const gfx::Point client_pt(event.x, event.y);
gfx::Point transformed_pt;
content::RenderWidgetHostImpl* target_rwh =
web_contents->GetInputEventRouter()->GetRenderWidgetHostAtPoint(
web_contents->GetRenderViewHost()->GetWidget()->GetView(),
client_pt, &transformed_pt);
if (target_rwh != current_rwh_for_drag_.get()) {
if (current_rwh_for_drag_)
current_rwh_for_drag_->DragTargetDragLeave();
DragTargetDragEnter(drag_data_, event, drag_allowed_ops_);
}
if (!drag_data_)
return;
const gfx::Point& screen_pt = GetScreenPoint(client_pt);
blink::WebDragOperationsMask ops =
static_cast<blink::WebDragOperationsMask>(allowed_ops);
int modifiers = TranslateModifiers(event.modifiers);
rvh->DragTargetDragOver(client_pt, screen_pt, ops, modifiers);
target_rwh->DragTargetDragOver(transformed_pt, screen_pt, ops, modifiers);
}
void CefBrowserPlatformDelegateOsr::DragTargetDragLeave() {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
if (current_rvh_for_drag_ != browser_->web_contents()->GetRenderViewHost() ||
!drag_data_) {
return;
}
rvh->DragTargetDragLeave();
if (current_rwh_for_drag_) {
current_rwh_for_drag_->DragTargetDragLeave();
current_rwh_for_drag_.reset();
}
drag_data_ = nullptr;
}
void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
if (!drag_data_)
return;
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(browser_->web_contents());
if (!web_contents)
return;
gfx::Point client_pt(event.x, event.y);
gfx::Point transformed_pt;
content::RenderWidgetHostImpl* target_rwh =
web_contents->GetInputEventRouter()->GetRenderWidgetHostAtPoint(
web_contents->GetRenderViewHost()->GetWidget()->GetView(),
client_pt, &transformed_pt);
if (target_rwh != current_rwh_for_drag_.get()) {
if (current_rwh_for_drag_)
current_rwh_for_drag_->DragTargetDragLeave();
DragTargetDragEnter(drag_data_, event, drag_allowed_ops_);
}
if (!drag_data_)
return;
{
@@ -300,35 +369,85 @@ void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) {
static_cast<CefDragDataImpl*>(drag_data_.get());
base::AutoLock lock_scope(data_impl->lock());
content::DropData* drop_data = data_impl->drop_data();
const gfx::Point client_pt(event.x, event.y);
const gfx::Point& screen_pt = GetScreenPoint(client_pt);
int modifiers = TranslateModifiers(event.modifiers);
rvh->DragTargetDrop(*drop_data, client_pt, screen_pt, modifiers);
target_rwh->DragTargetDrop(*drop_data, transformed_pt, screen_pt,
modifiers);
}
drag_data_ = nullptr;
}
void CefBrowserPlatformDelegateOsr::StartDragging(
const content::DropData& drop_data,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) {
drag_start_rwh_ = source_rwh->GetWeakPtr();
bool handled = false;
CefRefPtr<CefRenderHandler> handler =
browser_->GetClient()->GetRenderHandler();
if (handler.get()) {
CefRefPtr<CefDragDataImpl> drag_data(new CefDragDataImpl(drop_data));
drag_data->SetReadOnly(true);
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
handled = handler->StartDragging(
browser_,
drag_data.get(),
static_cast<CefRenderHandler::DragOperationsMask>(allowed_ops),
event_info.event_location.x(),
event_info.event_location.y());
}
if (!handled)
DragSourceSystemDragEnded();
}
void CefBrowserPlatformDelegateOsr::UpdateDragCursor(
blink::WebDragOperation operation) {
CefRefPtr<CefRenderHandler> handler =
browser_->GetClient()->GetRenderHandler();
if (handler.get()) {
handler->UpdateDragCursor(
browser_, static_cast<CefRenderHandler::DragOperation>(operation));
}
}
void CefBrowserPlatformDelegateOsr::DragSourceEndedAt(
int x, int y,
cef_drag_operations_mask_t op) {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
if (!drag_start_rwh_)
return;
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(browser_->web_contents());
if (!web_contents)
return;
const gfx::Point& screen_pt = GetScreenPoint(gfx::Point(x, y));
blink::WebDragOperation drag_op = static_cast<blink::WebDragOperation>(op);
rvh->DragSourceEndedAt(x, y, screen_pt.x(), screen_pt.y(), drag_op);
web_contents->DragSourceEndedAt(x, y, screen_pt.x(), screen_pt.y(), drag_op,
drag_start_rwh_.get());
}
void CefBrowserPlatformDelegateOsr::DragSourceSystemDragEnded() {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
if (!drag_start_rwh_)
return;
rvh->DragSourceSystemDragEnded();
content::WebContents* web_contents = browser_->web_contents();
if (!web_contents)
return;
web_contents->SystemDragEnded(drag_start_rwh_.get());
drag_start_rwh_ = nullptr;
}
CefWindowHandle CefBrowserPlatformDelegateOsr::GetParentWindowHandle() const {

View File

@@ -11,6 +11,10 @@
class CefRenderWidgetHostViewOSR;
class CefWebContentsViewOSR;
namespace content {
class RenderWidgetHostImpl;
}
// Base implementation of windowless browser functionality.
class CefBrowserPlatformDelegateOsr :
public CefBrowserPlatformDelegate,
@@ -72,6 +76,14 @@ class CefBrowserPlatformDelegateOsr :
cef_drag_operations_mask_t allowed_ops) override;
void DragTargetDragLeave() override;
void DragTargetDrop(const CefMouseEvent& event) override;
void StartDragging(
const content::DropData& drop_data,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) override;
void UpdateDragCursor(blink::WebDragOperation operation) override;
void DragSourceEndedAt(int x, int y,
cef_drag_operations_mask_t op) override;
void DragSourceSystemDragEnded() override;
@@ -95,6 +107,20 @@ class CefBrowserPlatformDelegateOsr :
// Pending drag/drop data.
CefRefPtr<CefDragData> drag_data_;
cef_drag_operations_mask_t drag_allowed_ops_;
// We keep track of the RenderWidgetHost we're dragging over. If it changes
// during a drag, we need to re-send the DragEnter message.
base::WeakPtr<content::RenderWidgetHostImpl> current_rwh_for_drag_;
// We also keep track of the RenderViewHost we're dragging over to avoid
// sending the drag exited message after leaving the current
// view. |current_rvh_for_drag_| should not be dereferenced.
void* current_rvh_for_drag_;
// We keep track of the RenderWidgetHost from which the current drag started,
// in order to properly route the drag end message to it.
base::WeakPtr<content::RenderWidgetHostImpl> drag_start_rwh_;
};
#endif // CEF_LIBCEF_BROWSER_OSR_BROWSER_PLATFORM_DELEGATE_OSR_H_

View File

@@ -473,8 +473,11 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
DCHECK(render_widget_host_);
DCHECK(!render_widget_host_->GetView());
// CefBrowserHostImpl might not be created at this time for popups.
if (content::RenderViewHost::From(render_widget_host_)) {
if (parent_host_view_) {
browser_impl_ = parent_host_view_->browser_impl();
DCHECK(browser_impl_);
} else if (content::RenderViewHost::From(render_widget_host_)) {
// CefBrowserHostImpl might not be created at this time for popups.
browser_impl_ = CefBrowserHostImpl::GetBrowserForHost(
content::RenderViewHost::From(render_widget_host_));
}
@@ -539,8 +542,7 @@ CefRenderWidgetHostViewOSR::~CefRenderWidgetHostViewOSR() {
// Called for full-screen widgets.
void CefRenderWidgetHostViewOSR::InitAsChild(gfx::NativeView parent_view) {
DCHECK(parent_host_view_);
browser_impl_ = parent_host_view_->browser_impl();
DCHECK(browser_impl_.get());
DCHECK(browser_impl_);
if (parent_host_view_->child_host_view_) {
// Cancel the previous popup widget.
@@ -693,8 +695,11 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
// The compositor will draw directly to the SoftwareOutputDevice which
// then calls OnPaint.
#if defined(OS_MACOSX)
browser_compositor_->SwapCompositorFrame(output_surface_id,
std::move(frame));
// We would normally call BrowserCompositorMac::SwapCompositorFrame,
// however it contains compositor resize logic that we don't want.
// Consequently we instead call the SwapDelegatedFrame method directly.
browser_compositor_->GetDelegatedFrameHost()->SwapDelegatedFrame(
output_surface_id, std::move(frame));
#else
delegated_frame_host_->SwapDelegatedFrame(output_surface_id,
std::move(frame));
@@ -715,8 +720,11 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
damage_rect.Intersect(gfx::Rect(frame_size));
#if defined(OS_MACOSX)
browser_compositor_->SwapCompositorFrame(output_surface_id,
std::move(frame));
// We would normally call BrowserCompositorMac::SwapCompositorFrame,
// however it contains compositor resize logic that we don't want.
// Consequently we instead call the SwapDelegatedFrame method directly.
browser_compositor_->GetDelegatedFrameHost()->SwapDelegatedFrame(
output_surface_id, std::move(frame));
#else
delegated_frame_host_->SwapDelegatedFrame(output_surface_id,
std::move(frame));
@@ -739,8 +747,7 @@ void CefRenderWidgetHostViewOSR::InitAsPopup(
content::RenderWidgetHostView* parent_host_view,
const gfx::Rect& pos) {
DCHECK_EQ(parent_host_view_, parent_host_view);
browser_impl_ = parent_host_view_->browser_impl();
DCHECK(browser_impl_.get());
DCHECK(browser_impl_);
if (parent_host_view_->popup_host_view_) {
// Cancel the previous popup widget.
@@ -769,6 +776,18 @@ void CefRenderWidgetHostViewOSR::InitAsFullscreen(
NOTREACHED() << "Fullscreen widgets are not supported in OSR";
}
// Called for the "platform view" created by WebContentsViewGuest and owned by
// RenderWidgetHostViewGuest.
void CefRenderWidgetHostViewOSR::InitAsGuest(
content::RenderWidgetHostView* parent_host_view,
content::RenderWidgetHostViewGuest* guest_view) {
DCHECK_EQ(parent_host_view_, parent_host_view);
DCHECK(browser_impl_);
parent_host_view_->AddGuestHostView(this);
parent_host_view_->RegisterGuestViewFrameSwappedCallback(guest_view);
}
void CefRenderWidgetHostViewOSR::UpdateCursor(
const content::WebCursor& cursor) {
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::UpdateCursor");
@@ -1092,10 +1111,6 @@ CefRenderWidgetHostViewOSR::DelegatedFrameHostSendReclaimCompositorResources(
resources));
}
void CefRenderWidgetHostViewOSR::DelegatedFrameHostOnLostCompositorResources() {
render_widget_host_->ScheduleComposite();
}
void CefRenderWidgetHostViewOSR::SetBeginFrameSource(
cc::BeginFrameSource* source) {
// TODO(cef): Maybe we can use this method in combination with
@@ -1340,24 +1355,6 @@ void CefRenderWidgetHostViewOSR::OnPaint(
ReleaseResize();
}
void CefRenderWidgetHostViewOSR::AddGuestHostView(
CefRenderWidgetHostViewOSR* guest_host) {
guest_host_views_.insert(guest_host);
}
void CefRenderWidgetHostViewOSR::RemoveGuestHostView(
CefRenderWidgetHostViewOSR* guest_host) {
guest_host_views_.erase(guest_host);
}
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))));
}
#if !defined(OS_MACOSX)
ui::Compositor* CefRenderWidgetHostViewOSR::GetCompositor() const {
@@ -1540,6 +1537,24 @@ void CefRenderWidgetHostViewOSR::OnScrollOffsetChanged() {
is_scroll_offset_changed_pending_ = false;
}
void CefRenderWidgetHostViewOSR::AddGuestHostView(
CefRenderWidgetHostViewOSR* guest_host) {
guest_host_views_.insert(guest_host);
}
void CefRenderWidgetHostViewOSR::RemoveGuestHostView(
CefRenderWidgetHostViewOSR* guest_host) {
guest_host_views_.erase(guest_host);
}
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))));
}
void CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped(
content::RenderWidgetHostViewGuest* guest_host_view) {
InvalidateInternal(

View File

@@ -130,6 +130,8 @@ class CefRenderWidgetHostViewOSR
const gfx::Rect& pos) override;
void InitAsFullscreen(
content::RenderWidgetHostView* reference_host_view) override;
void InitAsGuest(content::RenderWidgetHostView* parent_host_view,
content::RenderWidgetHostViewGuest* guest_view) override;
void UpdateCursor(const content::WebCursor& cursor) override;
void SetIsLoading(bool is_loading) override;
void RenderProcessGone(base::TerminationStatus status,
@@ -190,7 +192,6 @@ class CefRenderWidgetHostViewOSR
int output_surface_id,
bool is_swap_ack,
const cc::ReturnedResourceArray& resources) override;
void DelegatedFrameHostOnLostCompositorResources() override;
void SetBeginFrameSource(cc::BeginFrameSource* source) override;
bool IsAutoResizeEnabled() const override;
#endif // !defined(OS_MACOSX)
@@ -230,14 +231,6 @@ class CefRenderWidgetHostViewOSR
void ImeFinishComposingText(bool keep_selection);
void ImeCancelComposition();
void AddGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
void RemoveGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
// Register a callback that will be executed when |guest_host_view| receives
// OnSwapCompositorFrame. The callback triggers repaint of the embedder view.
void RegisterGuestViewFrameSwappedCallback(
content::RenderWidgetHostViewGuest* guest_host_view);
CefRefPtr<CefBrowserHostImpl> browser_impl() const { return browser_impl_; }
void set_browser_impl(CefRefPtr<CefBrowserHostImpl> browser) {
browser_impl_ = browser;
@@ -271,6 +264,14 @@ class CefRenderWidgetHostViewOSR
void OnScrollOffsetChanged();
void AddGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
void RemoveGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
// Register a callback that will be executed when |guest_host_view| receives
// OnSwapCompositorFrame. The callback triggers repaint of the embedder view.
void RegisterGuestViewFrameSwappedCallback(
content::RenderWidgetHostViewGuest* guest_host_view);
void OnGuestViewFrameSwapped(
content::RenderWidgetHostViewGuest* guest_host_view);

View File

@@ -58,10 +58,6 @@ class MacHelper :
is_swap_ack, resources));
}
void BrowserCompositorMacOnLostCompositorResources() override {
view_->render_widget_host()->ScheduleComposite();
}
void BrowserCompositorMacSendBeginFrame(
const cc::BeginFrameArgs& args) override {
view_->render_widget_host()->Send(

View File

@@ -32,8 +32,6 @@ void CefSoftwareOutputDeviceOSR::Resize(const gfx::Size& viewport_pixel_size,
float scale_factor) {
CEF_REQUIRE_UIT();
scale_factor_ = scale_factor;
if (viewport_pixel_size_ == viewport_pixel_size)
return;

View File

@@ -18,23 +18,19 @@
CefWebContentsViewOSR::CefWebContentsViewOSR(bool transparent)
: transparent_(transparent),
web_contents_(NULL),
view_(NULL),
guest_(NULL) {
web_contents_(NULL) {
}
CefWebContentsViewOSR::~CefWebContentsViewOSR() {
}
void CefWebContentsViewOSR::set_web_contents(
void CefWebContentsViewOSR::WebContentsCreated(
content::WebContents* web_contents) {
DCHECK(!web_contents_);
web_contents_ = web_contents;
}
void CefWebContentsViewOSR::set_guest(content::BrowserPluginGuest* guest) {
DCHECK(!guest_);
guest_ = guest;
// Call this again for popup browsers now that the view should exist.
RenderViewCreated(web_contents_->GetRenderViewHost());
}
gfx::NativeView CefWebContentsViewOSR::GetNativeView() const {
@@ -50,39 +46,18 @@ gfx::NativeWindow CefWebContentsViewOSR::GetTopLevelNativeWindow() const {
}
void CefWebContentsViewOSR::GetScreenInfo(content::ScreenInfo* results) const {
if (view_)
view_->GetScreenInfo(results);
CefRenderWidgetHostViewOSR* view = GetView();
if (view)
view->GetScreenInfo(results);
else
WebContentsView::GetDefaultScreenInfo(results);
}
void CefWebContentsViewOSR::GetContainerBounds(gfx::Rect* out) const {
if (guest_) {
// Based on WebContentsViewGuest::GetContainerBounds.
if (guest_->embedder_web_contents()) {
// We need embedder container's bounds to calculate our bounds.
guest_->embedder_web_contents()->GetView()->GetContainerBounds(out);
gfx::Point guest_coordinates = guest_->GetScreenCoordinates(gfx::Point());
out->Offset(guest_coordinates.x(), guest_coordinates.y());
} else {
out->set_origin(gfx::Point());
}
out->set_size(size_);
return;
}
*out = GetViewBounds();
}
void CefWebContentsViewOSR::SizeContents(const gfx::Size& size) {
if (guest_) {
// Based on WebContentsViewGuest::SizeContents.
size_ = size;
content::RenderWidgetHostView* rwhv =
web_contents_->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetSize(size);
}
}
void CefWebContentsViewOSR::Focus() {
@@ -102,71 +77,51 @@ content::DropData* CefWebContentsViewOSR::GetDropData() const {
}
gfx::Rect CefWebContentsViewOSR::GetViewBounds() const {
if (guest_) {
// Based on WebContentsViewGuest::GetViewBounds.
return gfx::Rect(size_);
}
return view_ ? view_->GetViewBounds() : gfx::Rect();
CefRenderWidgetHostViewOSR* view = GetView();
return view ? view->GetViewBounds() : gfx::Rect();
}
void CefWebContentsViewOSR::CreateView(const gfx::Size& initial_size,
gfx::NativeView context) {
if (guest_) {
// Based on WebContentsViewGuest::CreateView.
size_ = initial_size;
}
}
content::RenderWidgetHostViewBase* CefWebContentsViewOSR::CreateViewForWidget(
content::RenderWidgetHost* render_widget_host,
bool is_guest_view_hack) {
content::RenderWidgetHost* embedder_render_widget_host) {
if (render_widget_host->GetView()) {
return static_cast<content::RenderWidgetHostViewBase*>(
render_widget_host->GetView());
}
if (guest_) {
// Based on WebContentsViewGuest::CreateViewForWidget.
content::WebContents* embedder_web_contents =
guest_->embedder_web_contents();
CefRenderWidgetHostViewOSR* embedder_host_view =
static_cast<CefRenderWidgetHostViewOSR*>(
embedder_web_contents->GetRenderViewHost()->GetWidget()->GetView());
CefRenderWidgetHostViewOSR* platform_widget =
new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
embedder_host_view);
embedder_host_view->AddGuestHostView(platform_widget);
content::RenderWidgetHostViewGuest* guest_host_view =
content::RenderWidgetHostViewGuest::Create(
render_widget_host,
guest_,
platform_widget->GetWeakPtr());
embedder_host_view->RegisterGuestViewFrameSwappedCallback(guest_host_view);
return guest_host_view;
CefRenderWidgetHostViewOSR* embedder_host_view = nullptr;
if (embedder_render_widget_host) {
embedder_host_view = static_cast<CefRenderWidgetHostViewOSR*>(
embedder_render_widget_host->GetView());
}
view_ = new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
NULL);
return view_;
return new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
embedder_host_view);
}
// Called for popup and fullscreen widgets.
content::RenderWidgetHostViewBase*
CefWebContentsViewOSR::CreateViewForPopupWidget(
content::RenderWidgetHost* render_widget_host) {
return new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
view_);
CefRenderWidgetHostViewOSR* view = GetView();
CHECK(view);
return new CefRenderWidgetHostViewOSR(transparent_, render_widget_host, view);
}
void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) {
}
void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) {
if (view_)
view_->InstallTransparency();
// |view| will be nullptr the first time this method is called for popup
// browsers.
CefRenderWidgetHostViewOSR* view = GetView();
if (view)
view->InstallTransparency();
}
void CefWebContentsViewOSR::RenderViewSwappedIn(
@@ -197,80 +152,35 @@ void CefWebContentsViewOSR::StartDragging(
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info) {
if (guest_) {
// Based on WebContentsViewGuest::StartDragging.
content::WebContentsImpl* embedder_web_contents =
guest_->embedder_web_contents();
embedder_web_contents->GetBrowserPluginEmbedder()->StartDrag(guest_);
content::RenderViewHostImpl* embedder_render_view_host =
static_cast<content::RenderViewHostImpl*>(
embedder_web_contents->GetRenderViewHost());
CHECK(embedder_render_view_host);
content::RenderViewHostDelegateView* view =
embedder_render_view_host->GetDelegate()->GetDelegateView();
if (view) {
content::RecordAction(
base::UserMetricsAction("BrowserPlugin.Guest.StartDrag"));
view->StartDragging(drop_data, allowed_ops, image, image_offset,
event_info);
} else {
embedder_web_contents->SystemDragEnded();
}
return;
const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) {
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser();
if (browser.get()) {
browser->StartDragging(drop_data, allowed_ops, image, image_offset,
event_info, source_rwh);
} else if (web_contents_) {
web_contents_->SystemDragEnded(source_rwh);
}
CefRefPtr<CefBrowserHostImpl> browser;
CefRefPtr<CefRenderHandler> handler;
bool handled = false;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(view_);
if (view)
browser = view->browser_impl();
if (browser.get())
handler = browser->GetClient()->GetRenderHandler();
if (handler.get()) {
CefRefPtr<CefDragDataImpl> drag_data(new CefDragDataImpl(drop_data));
drag_data->SetReadOnly(true);
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
handled = handler->StartDragging(
browser.get(),
drag_data.get(),
static_cast<CefRenderHandler::DragOperationsMask>(allowed_ops),
event_info.event_location.x(),
event_info.event_location.y());
}
if (!handled && web_contents_)
web_contents_->SystemDragEnded();
}
void CefWebContentsViewOSR::UpdateDragCursor(
blink::WebDragOperation operation) {
if (guest_) {
// Based on WebContentsViewGuest::UpdateDragCursor.
content::RenderViewHostImpl* embedder_render_view_host =
static_cast<content::RenderViewHostImpl*>(
guest_->embedder_web_contents()->GetRenderViewHost());
CHECK(embedder_render_view_host);
content::RenderViewHostDelegateView* view =
embedder_render_view_host->GetDelegate()->GetDelegateView();
if (view)
view->UpdateDragCursor(operation);
return;
}
CefRefPtr<CefBrowserHostImpl> browser;
CefRefPtr<CefRenderHandler> handler;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(view_);
if (view)
browser = view->browser_impl();
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser();
if (browser.get())
handler = browser->GetClient()->GetRenderHandler();
if (handler.get()) {
handler->UpdateDragCursor(
browser.get(),
static_cast<CefRenderHandler::DragOperation>(operation));
}
browser->UpdateDragCursor(operation);
}
CefRenderWidgetHostViewOSR* CefWebContentsViewOSR::GetView() const {
if (web_contents_) {
return static_cast<CefRenderWidgetHostViewOSR*>(
web_contents_->GetRenderViewHost()->GetWidget()->GetView());
}
return nullptr;
}
CefBrowserHostImpl* CefWebContentsViewOSR::GetBrowser() const {
CefRenderWidgetHostViewOSR* view = GetView();
if (view)
return view->browser_impl().get();
return nullptr;
}

View File

@@ -15,6 +15,7 @@ class WebContents;
class WebContentsViewDelegate;
}
class CefBrowserHostImpl;
class CefRenderWidgetHostViewOSR;
// An implementation of WebContentsView for off-screen rendering.
@@ -24,9 +25,8 @@ class CefWebContentsViewOSR : public content::WebContentsView,
explicit CefWebContentsViewOSR(bool transparent);
~CefWebContentsViewOSR() override;
void set_web_contents(content::WebContents* web_contents);
void WebContentsCreated(content::WebContents* web_contents);
content::WebContents* web_contents() const { return web_contents_; }
void set_guest(content::BrowserPluginGuest* guest);
// WebContentsView methods.
gfx::NativeView GetNativeView() const override;
@@ -45,7 +45,7 @@ class CefWebContentsViewOSR : public content::WebContentsView,
gfx::NativeView context) override;
content::RenderWidgetHostViewBase* CreateViewForWidget(
content::RenderWidgetHost* render_widget_host,
bool is_guest_view_hack) override;
content::RenderWidgetHost* embedder_render_widget_host) override;
content::RenderWidgetHostViewBase* CreateViewForPopupWidget(
content::RenderWidgetHost* render_widget_host) override;
void SetPageTitle(const base::string16& title) override;
@@ -66,17 +66,17 @@ class CefWebContentsViewOSR : public content::WebContentsView,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info) override;
const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) override;
void UpdateDragCursor(blink::WebDragOperation operation) override;
private:
CefRenderWidgetHostViewOSR* GetView() const;
CefBrowserHostImpl* GetBrowser() const;
const bool transparent_;
content::WebContents* web_contents_;
CefRenderWidgetHostViewOSR* view_;
content::BrowserPluginGuest* guest_;
gfx::Size size_;
DISALLOW_COPY_AND_ASSIGN(CefWebContentsViewOSR);
};

View File

@@ -20,8 +20,10 @@
#include "build/build_config.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/plugins/plugins_field_trial.h"
#include "chrome/common/features.h"
#include "chrome/common/pref_names.h"
#include "components/content_settings/core/browser/content_settings_utils.h"
#include "components/keyed_service/content/browser_context_keyed_service_shutdown_notifier_factory.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/plugin_service.h"
@@ -47,6 +49,39 @@ using content::WebPluginInfo;
namespace {
// There's a race condition between deletion of the CefPluginInfoMessageFilter
// object on the UI thread and deletion of the PrefService (owned by Profile)
// on the UI thread. If the PrefService will be deleted first then
// PrefMember::Destroy() must be called from ShutdownOnUIThread() to avoid
// heap-use-after-free on CefPluginInfoMessageFilter destruction (due to
// ~PrefMember trying to access the already-deleted PrefService).
// ShutdownNotifierFactory makes sure that ShutdownOnUIThread() is called in
// this case.
class ShutdownNotifierFactory
: public BrowserContextKeyedServiceShutdownNotifierFactory {
public:
static ShutdownNotifierFactory* GetInstance();
private:
friend struct base::DefaultLazyInstanceTraits<ShutdownNotifierFactory>;
ShutdownNotifierFactory()
: BrowserContextKeyedServiceShutdownNotifierFactory(
"CefPluginInfoMessageFilter") {
}
~ShutdownNotifierFactory() override {}
DISALLOW_COPY_AND_ASSIGN(ShutdownNotifierFactory);
};
base::LazyInstance<ShutdownNotifierFactory>::Leaky
g_shutdown_notifier_factory = LAZY_INSTANCE_INITIALIZER;
// static
ShutdownNotifierFactory* ShutdownNotifierFactory::GetInstance() {
return g_shutdown_notifier_factory.Pointer();
}
// For certain sandboxed Pepper plugins, use the JavaScript Content Settings.
bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) {
if (plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS &&
@@ -60,18 +95,18 @@ bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) {
return true;
#endif
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
// Treat CDM invocations like JavaScript.
if (plugin.name == base::ASCIIToUTF16(kWidevineCdmDisplayName)) {
DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS);
return true;
}
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
return false;
}
#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
enum PluginAvailabilityStatusForUMA {
PLUGIN_NOT_REGISTERED,
@@ -92,14 +127,14 @@ static void SendPluginAvailabilityUMA(const std::string& mime_type,
#endif // defined(WIDEVINE_CDM_AVAILABLE)
}
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
void ReportMetrics(const std::string& mime_type,
const GURL& url,
const url::Origin& main_frame_origin) {
}
#if defined(ENABLE_EXTENSIONS)
#if BUILDFLAG(ENABLE_EXTENSIONS)
// Returns whether a request from a plugin to load |resource| from a renderer
// with process id |process_id| is a request for an internal resource by an app
// listed in |accessible_resources| in its manifest.
@@ -129,7 +164,7 @@ bool IsPluginLoadingAccessibleResourceInWebView(
return renderer_state->GetOwnerInfo(process_id, nullptr, &owner_extension) &&
owner_extension == extension_id;
}
#endif // defined(ENABLE_EXTENSIONS)
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
} // namespace
@@ -140,7 +175,7 @@ CefPluginInfoMessageFilter::Context::Context(
resource_context_(
static_cast<CefResourceContext*>(profile->GetResourceContext())),
host_content_settings_map_(profile->GetHostContentSettingsMap()) {
#if defined(ENABLE_EXTENSIONS)
#if BUILDFLAG(ENABLE_EXTENSIONS)
if (extensions::ExtensionsEnabled())
extension_registry_ = extensions::ExtensionRegistry::Get(profile);
#endif
@@ -160,14 +195,29 @@ CefPluginInfoMessageFilter::Context::Context(
CefPluginInfoMessageFilter::Context::~Context() {
}
void CefPluginInfoMessageFilter::Context::ShutdownOnUIThread() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
always_authorize_plugins_.Destroy();
allow_outdated_plugins_.Destroy();
}
CefPluginInfoMessageFilter::CefPluginInfoMessageFilter(
int render_process_id,
CefBrowserContext* profile)
: BrowserMessageFilter(ExtensionMsgStart),
browser_context_(profile),
context_(render_process_id, profile),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_ptr_factory_(this) {
shutdown_notifier_ =
ShutdownNotifierFactory::GetInstance()->Get(profile)->Subscribe(
base::Bind(&CefPluginInfoMessageFilter::ShutdownOnUIThread,
base::Unretained(this)));
}
void CefPluginInfoMessageFilter::ShutdownOnUIThread() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
context_.ShutdownOnUIThread();
shutdown_notifier_.reset();
}
bool CefPluginInfoMessageFilter::OnMessageReceived(
@@ -175,7 +225,7 @@ bool CefPluginInfoMessageFilter::OnMessageReceived(
IPC_BEGIN_MESSAGE_MAP(CefPluginInfoMessageFilter, message)
IPC_MESSAGE_HANDLER_DELAY_REPLY(CefViewHostMsg_GetPluginInfo,
OnGetPluginInfo)
#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
IPC_MESSAGE_HANDLER(
CefViewHostMsg_IsInternalPluginAvailableForMimeType,
OnIsInternalPluginAvailableForMimeType)
@@ -251,7 +301,7 @@ void CefPluginInfoMessageFilter::PluginsLoaded(
}
}
#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
void CefPluginInfoMessageFilter::OnIsInternalPluginAvailableForMimeType(
const std::string& mime_type,
@@ -287,7 +337,7 @@ void CefPluginInfoMessageFilter::OnIsInternalPluginAvailableForMimeType(
mime_type, is_plugin_disabled ? PLUGIN_DISABLED : PLUGIN_NOT_REGISTERED);
}
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
void CefPluginInfoMessageFilter::Context::DecidePluginStatus(
const GetPluginInfo_Params& params,
@@ -320,7 +370,7 @@ void CefPluginInfoMessageFilter::Context::DecidePluginStatus(
DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT);
DCHECK(plugin_setting != CONTENT_SETTING_ASK);
#if defined(ENABLE_PLUGIN_INSTALLATION)
#if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION)
// Check if the plugin is outdated.
if (plugin_status == PluginMetadata::SECURITY_STATUS_OUT_OF_DATE &&
!allow_outdated_plugins_.GetValue()) {
@@ -342,7 +392,7 @@ void CefPluginInfoMessageFilter::Context::DecidePluginStatus(
return;
}
#if defined(ENABLE_EXTENSIONS)
#if BUILDFLAG(ENABLE_EXTENSIONS)
// If an app has explicitly made internal resources available by listing them
// in |accessible_resources| in the manifest, then allow them to be loaded by
// plugins inside a guest-view.
@@ -353,7 +403,7 @@ void CefPluginInfoMessageFilter::Context::DecidePluginStatus(
extension_registry_, render_process_id_, params.url)) {
plugin_setting = CONTENT_SETTING_ALLOW;
}
#endif // defined(ENABLE_EXTENSIONS)
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
if (plugin_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) {
*status = CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
@@ -365,7 +415,7 @@ void CefPluginInfoMessageFilter::Context::DecidePluginStatus(
: CefViewHostMsg_GetPluginInfo_Status::kBlocked;
}
#if defined(ENABLE_EXTENSIONS)
#if BUILDFLAG(ENABLE_EXTENSIONS)
// Allow an embedder of <webview> to block a plugin from being loaded inside
// the guest. In order to do this, set the status to 'Unauthorized' here,
// and update the status as appropriate depending on the response from the

View File

@@ -16,8 +16,11 @@
#include "chrome/browser/plugins/plugin_metadata.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#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 "extensions/features/features.h"
#include "ppapi/features/features.h"
class CefBrowserContext;
class CefResourceContext;
@@ -48,6 +51,7 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter {
Context(int render_process_id, CefBrowserContext* profile);
~Context();
void ShutdownOnUIThread();
void DecidePluginStatus(
const GetPluginInfo_Params& params,
@@ -72,7 +76,7 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter {
private:
int render_process_id_;
CefResourceContext* resource_context_;
#if defined(ENABLE_EXTENSIONS)
#if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::ExtensionRegistry* extension_registry_;
#endif
const HostContentSettingsMap* host_content_settings_map_;
@@ -93,6 +97,7 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter {
content::BrowserThread::UI>;
friend class base::DeleteHelper<CefPluginInfoMessageFilter>;
void ShutdownOnUIThread();
~CefPluginInfoMessageFilter() override;
void OnGetPluginInfo(int render_frame_id,
@@ -108,7 +113,7 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter {
IPC::Message* reply_msg,
const std::vector<content::WebPluginInfo>& plugins);
#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
// Returns whether any internal plugin supporting |mime_type| is registered
// and enabled. Does not determine whether the plugin can actually be
// instantiated (e.g. whether it has all its dependencies).
@@ -123,12 +128,9 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter {
std::vector<base::string16>* additional_param_values);
#endif
scoped_refptr<CefBrowserContext> browser_context_;
// Members will be destroyed in reverse order of declaration. Due to Context
// depending on the PrefService owned by CefBrowserContext the Context object
// must be destroyed before the CefBrowserContext object.
Context context_;
std::unique_ptr<KeyedServiceShutdownNotifier::Subscription>
shutdown_notifier_;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
base::WeakPtrFactory<CefPluginInfoMessageFilter> weak_ptr_factory_;

View File

@@ -14,7 +14,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "chrome/browser/net/prediction_options.h"
#include "chrome/browser/prefs/command_line_pref_store.h"
#include "chrome/browser/prefs/chrome_command_line_pref_store.h"
#include "chrome/browser/supervised_user/supervised_user_pref_store.h"
#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
@@ -33,11 +33,12 @@
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/proxy_config/proxy_config_dictionary.h"
#include "components/spellcheck/browser/pref_names.h"
#include "components/syncable_prefs/pref_service_syncable.h"
#include "components/syncable_prefs/pref_service_syncable_factory.h"
#include "components/sync_preferences/pref_service_syncable.h"
#include "components/sync_preferences/pref_service_syncable_factory.h"
#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 "ui/base/l10n/l10n_util.h"
namespace browser_prefs {
@@ -102,13 +103,13 @@ std::unique_ptr<PrefService> CreatePrefService(
// Use of PrefServiceSyncable is required by Chrome code such as
// HostContentSettingsMapFactory that calls PrefServiceSyncableFromProfile.
syncable_prefs::PrefServiceSyncableFactory factory;
sync_preferences::PrefServiceSyncableFactory factory;
// Used to store command-line preferences, most of which will be evaluated in
// the CommandLinePrefStore constructor. Preferences set in this manner cannot
// be overridden by the user.
scoped_refptr<CommandLinePrefStore> command_line_pref_store(
new CommandLinePrefStore(command_line));
scoped_refptr<ChromeCommandLinePrefStore> command_line_pref_store(
new ChromeCommandLinePrefStore(command_line));
renderer_prefs::SetCommandLinePrefDefaults(command_line_pref_store.get());
factory.set_command_line_prefs(command_line_pref_store);
@@ -139,7 +140,7 @@ std::unique_ptr<PrefService> CreatePrefService(
factory.set_user_prefs(testing_pref_store.get());
}
#if defined(ENABLE_SUPERVISED_USERS)
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
// Used to store supervised user preferences.
SupervisedUserSettingsService* supervised_user_settings =
SupervisedUserSettingsServiceFactory::GetForProfile(profile);
@@ -157,7 +158,7 @@ std::unique_ptr<PrefService> CreatePrefService(
new SupervisedUserPrefStore(supervised_user_settings));
DCHECK(supervised_user_prefs->IsInitializationComplete());
factory.set_supervised_user_prefs(supervised_user_prefs);
#endif // ENABLE_SUPERVISED_USERS
#endif // BUILDFLAG(ENABLE_SUPERVISED_USERS)
// Registry that will be populated with all known preferences. Preferences
// are registered with default values that may be changed via a *PrefStore.

View File

@@ -20,10 +20,10 @@
#include "chrome/browser/defaults.h"
#include "chrome/browser/extensions/extension_webkit_preferences.h"
#include "chrome/browser/font_family_cache.h"
#include "chrome/browser/prefs/command_line_pref_store.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/command_line_pref_store.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/pref_store.h"
#include "components/pref_registry/pref_registry_syncable.h"
@@ -52,8 +52,6 @@ void SetDefaultPrefs(content::WebPreferences& web) {
!command_line->HasSwitch(switches::kDisableJavascriptCloseWindows);
web.javascript_can_access_clipboard =
!command_line->HasSwitch(switches::kDisableJavascriptAccessClipboard);
web.caret_browsing_enabled =
command_line->HasSwitch(switches::kEnableCaretBrowsing);
web.allow_universal_access_from_file_urls =
command_line->HasSwitch(switches::kAllowUniversalAccessFromFileUrls);
web.shrinks_standalone_images_to_fit =
@@ -247,7 +245,6 @@ void SetCefPrefs(const CefBrowserSettings& cef,
SET_STATE(cef.javascript_access_clipboard,
web.javascript_can_access_clipboard);
SET_STATE(cef.javascript_dom_paste, web.dom_paste_enabled);
SET_STATE(cef.caret_browsing, web.caret_browsing_enabled);
SET_STATE(cef.plugins, web.plugins_enabled);
SET_STATE(cef.universal_access_from_file_urls,
web.allow_universal_access_from_file_urls);

View File

@@ -5,20 +5,20 @@
#include "include/internal/cef_types_wrappers.h"
#include "libcef/browser/printing/print_view_manager.h"
#include <stdint.h>
#include <map>
#include <utility>
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted_memory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#include "chrome/browser/printing/printer_query.h"
#include "components/printing/common/print_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "printing/pdf_metafile_skia.h"
@@ -47,6 +47,7 @@ void FillInDictionaryFromPdfPrintSettings(
print_settings.SetInteger(kSettingCopies, 1);
print_settings.SetBoolean(kSettingCollate, false);
print_settings.SetString(kSettingDeviceName, "");
print_settings.SetInteger(kSettingScaleFactor, 100);
print_settings.SetBoolean(kSettingGenerateDraftData, false);
print_settings.SetBoolean(kSettingPreviewModifiable, false);
@@ -119,9 +120,9 @@ void StopWorker(int document_cookie) {
}
scoped_refptr<base::RefCountedBytes>
GetDataFromHandle(base::SharedMemoryHandle handle, uint32_t data_size) {
std::unique_ptr<base::SharedMemory> shared_buf(
new base::SharedMemory(handle, true));
GetDataFromHandle(base::SharedMemoryHandle handle, uint32_t data_size) {
std::unique_ptr<base::SharedMemory> shared_buf =
base::MakeUnique<base::SharedMemory>(handle, true);
if (!shared_buf->Map(data_size)) {
NOTREACHED();
@@ -156,6 +157,13 @@ void SavePdfFile(scoped_refptr<base::RefCountedBytes> data,
} // namespace
struct CefPrintViewManager::PdfPrintState {
content::RenderFrameHost* printing_rfh_ = nullptr;
base::FilePath output_path_;
base::DictionaryValue settings_;
PdfPrintCallback callback_;
};
CefPrintViewManager::CefPrintViewManager(content::WebContents* web_contents)
: CefPrintViewManagerBase(web_contents) {
}
@@ -164,15 +172,62 @@ CefPrintViewManager::~CefPrintViewManager() {
TerminatePdfPrintJob();
}
#if defined(ENABLE_BASIC_PRINTING)
bool CefPrintViewManager::PrintForSystemDialogNow() {
return PrintNowInternal(new PrintMsg_PrintForSystemDialog(routing_id()));
}
#endif // ENABLE_BASIC_PRINTING
bool CefPrintViewManager::PrintToPDF(content::RenderFrameHost* rfh,
const base::FilePath& path,
const CefPdfPrintSettings& settings,
const PdfPrintCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
bool CefPrintViewManager::OnMessageReceived(const IPC::Message& message) {
// Don't start print again while printing is currently in progress.
if (pdf_print_state_)
return false;
// Don't print interstitials or crashed tabs.
if (!web_contents() || web_contents()->ShowingInterstitialPage() ||
web_contents()->IsCrashed()) {
return false;
}
pdf_print_state_.reset(new PdfPrintState);
pdf_print_state_->printing_rfh_ = rfh;
pdf_print_state_->output_path_ = path;
pdf_print_state_->callback_ = callback;
FillInDictionaryFromPdfPrintSettings(settings,
++next_pdf_request_id_,
pdf_print_state_->settings_);
rfh->Send(new PrintMsg_InitiatePrintPreview(rfh->GetRoutingID(),
!!settings.selection_only));
return true;
}
void CefPrintViewManager::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
if (pdf_print_state_ &&
render_frame_host == pdf_print_state_->printing_rfh_) {
TerminatePdfPrintJob();
}
CefPrintViewManagerBase::RenderFrameDeleted(render_frame_host);
}
void CefPrintViewManager::NavigationStopped() {
TerminatePdfPrintJob();
CefPrintViewManagerBase::NavigationStopped();
}
void CefPrintViewManager::RenderProcessGone(base::TerminationStatus status) {
TerminatePdfPrintJob();
CefPrintViewManagerBase::RenderProcessGone(status);
}
bool CefPrintViewManager::OnMessageReceived(
const IPC::Message& message,
content::RenderFrameHost* render_frame_host) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(CefPrintViewManager, message)
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(CefPrintViewManager, message,
render_frame_host)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidShowPrintDialog, OnDidShowPrintDialog)
IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview,
OnRequestPrintPreview)
@@ -181,48 +236,22 @@ bool CefPrintViewManager::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled || CefPrintViewManagerBase::OnMessageReceived(message);
return handled ||
CefPrintViewManagerBase::OnMessageReceived(message, render_frame_host);
}
void CefPrintViewManager::NavigationStopped() {
CefPrintViewManagerBase::NavigationStopped();
TerminatePdfPrintJob();
}
void CefPrintViewManager::RenderProcessGone(base::TerminationStatus status) {
CefPrintViewManagerBase::RenderProcessGone(status);
TerminatePdfPrintJob();
}
void CefPrintViewManager::PrintToPDF(const base::FilePath& path,
const CefPdfPrintSettings& settings,
const PdfPrintCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!web_contents() || pdf_print_settings_)
return;
pdf_output_path_ = path;
pdf_print_callback_ = callback;
pdf_print_settings_.reset(new base::DictionaryValue);
FillInDictionaryFromPdfPrintSettings(settings,
++next_pdf_request_id_,
*pdf_print_settings_);
Send(new PrintMsg_InitiatePrintPreview(routing_id(),
!!settings.selection_only));
}
void CefPrintViewManager::OnDidShowPrintDialog() {
void CefPrintViewManager::OnDidShowPrintDialog(content::RenderFrameHost* rfh) {
}
void CefPrintViewManager::OnRequestPrintPreview(
const PrintHostMsg_RequestPrintPreview_Params&) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!web_contents() || !pdf_print_settings_)
if (!pdf_print_state_)
return;
Send(new PrintMsg_PrintPreview(routing_id(), *pdf_print_settings_));
pdf_print_state_->printing_rfh_->Send(new PrintMsg_PrintPreview(
pdf_print_state_->printing_rfh_->GetRoutingID(),
pdf_print_state_->settings_));
}
void CefPrintViewManager::OnMetafileReadyForPrinting(
@@ -230,6 +259,9 @@ void CefPrintViewManager::OnMetafileReadyForPrinting(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
StopWorker(params.document_cookie);
if (!pdf_print_state_)
return;
scoped_refptr<base::RefCountedBytes> data_bytes =
GetDataFromHandle(params.metafile_data_handle, params.data_size);
if (!data_bytes || !data_bytes->size()) {
@@ -237,37 +269,32 @@ void CefPrintViewManager::OnMetafileReadyForPrinting(
return;
}
base::FilePath pdf_output_path = pdf_output_path_;
PdfPrintCallback pdf_print_callback = pdf_print_callback_;
const base::FilePath output_path = pdf_print_state_->output_path_;
const PdfPrintCallback print_callback = pdf_print_state_->callback_;
// Reset state information.
pdf_output_path_.clear();
pdf_print_callback_.Reset();
pdf_print_settings_.reset();
pdf_print_state_.reset();
// Save the PDF file to disk and then execute the callback.
BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE,
base::Bind(&SavePdfFile, data_bytes, pdf_output_path,
pdf_print_callback));
base::Bind(&SavePdfFile, data_bytes, output_path, print_callback));
}
void CefPrintViewManager::TerminatePdfPrintJob() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!pdf_print_settings_.get())
if (!pdf_print_state_)
return;
if (!pdf_print_callback_.is_null()) {
if (!pdf_print_state_->callback_.is_null()) {
// Execute the callback.
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
base::Bind(pdf_print_callback_, false));
base::Bind(pdf_print_state_->callback_, false));
}
// Reset state information.
pdf_output_path_.clear();
pdf_print_callback_.Reset();
pdf_print_settings_.reset();
pdf_print_state_.reset();
}
} // namespace printing

View File

@@ -10,13 +10,14 @@
#include "base/macros.h"
#include "content/public/browser/web_contents_user_data.h"
struct PrintHostMsg_DidPreviewDocument_Params;
struct PrintHostMsg_RequestPrintPreview_Params;
namespace content {
class RenderFrameHost;
class RenderProcessHost;
}
struct PrintHostMsg_DidPreviewDocument_Params;
struct PrintHostMsg_RequestPrintPreview_Params;
namespace printing {
// Manages the print commands for a WebContents.
@@ -26,35 +27,28 @@ class CefPrintViewManager :
public:
~CefPrintViewManager() override;
#if defined(ENABLE_BASIC_PRINTING)
// Same as PrintNow(), but for the case where a user prints with the system
// dialog from print preview.
bool PrintForSystemDialogNow();
#endif // ENABLE_BASIC_PRINTING
// content::WebContentsObserver implementation.
bool OnMessageReceived(const IPC::Message& message) override;
// content::WebContentsObserver implementation.
// Cancels the print job.
void NavigationStopped() override;
// Terminates or cancels the print job if one was pending.
void RenderProcessGone(base::TerminationStatus status) override;
// Callback executed on PDF printing completion.
typedef base::Callback<void(bool /*ok*/)> PdfPrintCallback;
// Print the current document to a PDF file. Execute |callback| on completion.
void PrintToPDF(const base::FilePath& path,
bool PrintToPDF(content::RenderFrameHost* rfh,
const base::FilePath& path,
const CefPdfPrintSettings& settings,
const PdfPrintCallback& callback);
// content::WebContentsObserver implementation.
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
void NavigationStopped() override;
void RenderProcessGone(base::TerminationStatus status) override;
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
private:
explicit CefPrintViewManager(content::WebContents* web_contents);
friend class content::WebContentsUserData<CefPrintViewManager>;
// IPC Message handlers.
void OnDidShowPrintDialog();
void OnDidShowPrintDialog(content::RenderFrameHost* rfh);
void OnRequestPrintPreview(const PrintHostMsg_RequestPrintPreview_Params&);
void OnMetafileReadyForPrinting(
const PrintHostMsg_DidPreviewDocument_Params&);
@@ -63,9 +57,8 @@ class CefPrintViewManager :
// Used for printing to PDF. Only accessed on the browser process UI thread.
int next_pdf_request_id_ = -1;
base::FilePath pdf_output_path_;
std::unique_ptr<base::DictionaryValue> pdf_print_settings_;
PdfPrintCallback pdf_print_callback_;
struct PdfPrintState;
std::unique_ptr<PdfPrintState> pdf_print_state_;
DISALLOW_COPY_AND_ASSIGN(CefPrintViewManager);
};

View File

@@ -4,23 +4,25 @@
#include "libcef/browser/printing/print_view_manager_base.h"
#include <memory>
#include <utility>
#include "libcef/browser/content_browser_client.h"
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
@@ -29,8 +31,10 @@
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "printing/features/features.h"
#include "printing/pdf_metafile_skia.h"
#include "printing/printed_document.h"
#include "ui/base/l10n/l10n_util.h"
@@ -48,6 +52,7 @@ namespace printing {
CefPrintViewManagerBase::CefPrintViewManagerBase(
content::WebContents* web_contents)
: PrintManager(web_contents),
printing_rfh_(nullptr),
printing_succeeded_(false),
inside_inner_message_loop_(false),
#if !defined(OS_MACOSX)
@@ -55,13 +60,11 @@ CefPrintViewManagerBase::CefPrintViewManagerBase(
#endif
queue_(g_browser_process->print_job_manager()->queue()) {
DCHECK(queue_.get());
PrefService* pref_service =
static_cast<CefBrowserContext*>(web_contents->GetBrowserContext())->
GetPrefs();
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
printing_enabled_.Init(
prefs::kPrintingEnabled,
pref_service,
base::Bind(&CefPrintViewManagerBase::UpdateScriptedPrintingBlocked,
prefs::kPrintingEnabled, profile->GetPrefs(),
base::Bind(&CefPrintViewManagerBase::UpdatePrintingEnabled,
base::Unretained(this)));
}
@@ -70,16 +73,20 @@ CefPrintViewManagerBase::~CefPrintViewManagerBase() {
DisconnectFromCurrentPrintJob();
}
#if defined(ENABLE_BASIC_PRINTING)
bool CefPrintViewManagerBase::PrintNow() {
return PrintNowInternal(new PrintMsg_PrintPages(routing_id()));
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
bool CefPrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
DisconnectFromCurrentPrintJob();
SetPrintingRFH(rfh);
int32_t id = rfh->GetRoutingID();
return PrintNowInternal(rfh, base::MakeUnique<PrintMsg_PrintPages>(id));
}
#endif
void CefPrintViewManagerBase::UpdateScriptedPrintingBlocked() {
Send(new PrintMsg_SetScriptedPrintingBlocked(
routing_id(),
!printing_enabled_.GetValue()));
void CefPrintViewManagerBase::UpdatePrintingEnabled() {
web_contents()->ForEachFrame(
base::Bind(&CefPrintViewManagerBase::SendPrintingEnabled,
base::Unretained(this), printing_enabled_.GetValue()));
}
void CefPrintViewManagerBase::NavigationStopped() {
@@ -87,23 +94,6 @@ void CefPrintViewManagerBase::NavigationStopped() {
TerminatePrintJob(true);
}
void CefPrintViewManagerBase::RenderProcessGone(
base::TerminationStatus status) {
PrintManager::RenderProcessGone(status);
ReleasePrinterQuery();
if (!print_job_.get())
return;
scoped_refptr<PrintedDocument> document(print_job_->document());
if (document.get()) {
// If IsComplete() returns false, the document isn't completely rendered.
// Since our renderer is gone, there's nothing to do, cancel it. Otherwise,
// the print job may finish without problem.
TerminatePrintJob(!document->IsComplete());
}
}
base::string16 CefPrintViewManagerBase::RenderSourceName() {
base::string16 name(web_contents()->GetTitle());
if (name.empty())
@@ -173,24 +163,24 @@ void CefPrintViewManagerBase::OnDidPrintPage(
#if defined(OS_WIN)
print_job_->AppendPrintedPage(params.page_number);
if (metafile_must_be_valid) {
// TODO(thestig): Figure out why rendering text with GDI results in random
// missing characters for some users. https://crbug.com/658606
bool print_text_with_gdi =
document->settings().print_text_with_gdi() &&
!document->settings().printer_is_xps() &&
!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableGDITextPrinting);
switches::GDITextPrintingEnabled();
scoped_refptr<base::RefCountedBytes> bytes = new base::RefCountedBytes(
reinterpret_cast<const unsigned char*>(shared_buf->memory()),
params.data_size);
document->DebugDumpData(bytes.get(), FILE_PATH_LITERAL(".pdf"));
print_job_->StartPdfToEmfConversion(
bytes, params.page_size, params.content_area, print_text_with_gdi);
bytes, params.page_size, params.content_area,
print_text_with_gdi);
}
#else
// Update the rendered document. It will send notifications to the listener.
document->SetPage(params.page_number,
std::move(metafile),
params.page_size,
document->SetPage(params.page_number, std::move(metafile), params.page_size,
params.content_area);
ShouldQuitFromInnerMessageLoop();
@@ -212,18 +202,43 @@ void CefPrintViewManagerBase::OnShowInvalidPrinterSettingsError() {
}
void CefPrintViewManagerBase::DidStartLoading() {
UpdateScriptedPrintingBlocked();
UpdatePrintingEnabled();
}
bool CefPrintViewManagerBase::OnMessageReceived(const IPC::Message& message) {
void CefPrintViewManagerBase::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
// Terminates or cancels the print job if one was pending.
if (render_frame_host != printing_rfh_)
return;
printing_rfh_ = nullptr;
PrintManager::PrintingRenderFrameDeleted();
ReleasePrinterQuery();
if (!print_job_.get())
return;
scoped_refptr<PrintedDocument> document(print_job_->document());
if (document.get()) {
// If IsComplete() returns false, the document isn't completely rendered.
// Since our renderer is gone, there's nothing to do, cancel it. Otherwise,
// the print job may finish without problem.
TerminatePrintJob(!document->IsComplete());
}
}
bool CefPrintViewManagerBase::OnMessageReceived(
const IPC::Message& message,
content::RenderFrameHost* render_frame_host) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(CefPrintViewManagerBase, message)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage)
IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError,
OnShowInvalidPrinterSettingsError);
OnShowInvalidPrinterSettingsError)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled || PrintManager::OnMessageReceived(message);
return handled || PrintManager::OnMessageReceived(message, render_frame_host);
}
void CefPrintViewManagerBase::Observe(
@@ -335,7 +350,7 @@ void CefPrintViewManagerBase::ShouldQuitFromInnerMessageLoop() {
bool CefPrintViewManagerBase::CreateNewPrintJob(PrintJobWorkerOwner* job) {
DCHECK(!inside_inner_message_loop_);
// Disconnect the current print_job_.
// Disconnect the current |print_job_|.
DisconnectFromCurrentPrintJob();
// We can't print if there is no renderer.
@@ -380,12 +395,6 @@ void CefPrintViewManagerBase::DisconnectFromCurrentPrintJob() {
#endif
}
void CefPrintViewManagerBase::PrintingDone(bool success) {
if (!print_job_.get())
return;
Send(new PrintMsg_PrintingDone(routing_id(), success));
}
void CefPrintViewManagerBase::TerminatePrintJob(bool cancel) {
if (!print_job_.get())
return;
@@ -407,16 +416,23 @@ void CefPrintViewManagerBase::TerminatePrintJob(bool cancel) {
}
void CefPrintViewManagerBase::ReleasePrintJob() {
content::RenderFrameHost* rfh = printing_rfh_;
printing_rfh_ = nullptr;
if (!print_job_.get())
return;
PrintingDone(printing_succeeded_);
if (rfh) {
auto msg = base::MakeUnique<PrintMsg_PrintingDone>(rfh->GetRoutingID(),
printing_succeeded_);
rfh->Send(msg.release());
}
registrar_.Remove(this, chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(print_job_.get()));
print_job_->DisconnectSource();
// Don't close the worker thread.
print_job_ = NULL;
print_job_ = nullptr;
}
bool CefPrintViewManagerBase::RunInnerMessageLoop() {
@@ -485,14 +501,18 @@ bool CefPrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) {
return true;
}
bool CefPrintViewManagerBase::PrintNowInternal(IPC::Message* message) {
bool CefPrintViewManagerBase::PrintNowInternal(
content::RenderFrameHost* rfh,
std::unique_ptr<IPC::Message> message) {
// Don't print / print preview interstitials or crashed tabs.
if (web_contents()->ShowingInterstitialPage() ||
web_contents()->IsCrashed()) {
delete message;
if (web_contents()->ShowingInterstitialPage() || web_contents()->IsCrashed())
return false;
}
return Send(message);
return rfh->Send(message.release());
}
void CefPrintViewManagerBase::SetPrintingRFH(content::RenderFrameHost* rfh) {
DCHECK(!printing_rfh_);
printing_rfh_ = rfh;
}
void CefPrintViewManagerBase::ReleasePrinterQuery() {
@@ -502,13 +522,12 @@ void CefPrintViewManagerBase::ReleasePrinterQuery() {
int cookie = cookie_;
cookie_ = 0;
printing::PrintJobManager* print_job_manager =
g_browser_process->print_job_manager();
PrintJobManager* print_job_manager = g_browser_process->print_job_manager();
// May be NULL in tests.
if (!print_job_manager)
return;
scoped_refptr<printing::PrinterQuery> printer_query;
scoped_refptr<PrinterQuery> printer_query;
printer_query = queue_->PopPrinterQuery(cookie);
if (!printer_query.get())
return;
@@ -517,4 +536,10 @@ void CefPrintViewManagerBase::ReleasePrinterQuery() {
base::Bind(&PrinterQuery::StopWorker, printer_query));
}
void CefPrintViewManagerBase::SendPrintingEnabled(
bool enabled,
content::RenderFrameHost* rfh) {
rfh->Send(new PrintMsg_SetPrintingEnabled(rfh->GetRoutingID(), enabled));
}
} // namespace printing

View File

@@ -5,6 +5,8 @@
#ifndef CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_
#define CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
@@ -13,12 +15,13 @@
#include "components/printing/browser/print_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "printing/features/features.h"
#include "printing/printed_pages_source.h"
struct PrintHostMsg_DidPrintPage_Params;
namespace content {
class RenderViewHost;
class RenderFrameHost;
}
namespace printing {
@@ -36,15 +39,15 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
public:
~CefPrintViewManagerBase() override;
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Prints the current document immediately. Since the rendering is
// asynchronous, the actual printing will not be completed on the return of
// this function. Returns false if printing is impossible at the moment.
virtual bool PrintNow();
virtual bool PrintNow(content::RenderFrameHost* rfh);
#endif // ENABLE_BASIC_PRINTING
// Whether to block scripted printing for our tab or not.
void UpdateScriptedPrintingBlocked();
// Whether printing is enabled or not.
void UpdatePrintingEnabled();
// PrintedPagesSource implementation.
base::string16 RenderSourceName() override;
@@ -53,17 +56,19 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
explicit CefPrintViewManagerBase(content::WebContents* web_contents);
// Helper method for Print*Now().
bool PrintNowInternal(IPC::Message* message);
bool PrintNowInternal(content::RenderFrameHost* rfh,
std::unique_ptr<IPC::Message> message);
void SetPrintingRFH(content::RenderFrameHost* rfh);
// content::WebContentsObserver implementation.
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
// Cancels the print job.
void NavigationStopped() override;
// Terminates or cancels the print job if one was pending.
void RenderProcessGone(base::TerminationStatus status) override;
// content::WebContentsObserver implementation.
bool OnMessageReceived(const IPC::Message& message) override;
private:
// content::NotificationObserver implementation.
void Observe(int type,
@@ -104,9 +109,6 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
// disconnect from it.
void DisconnectFromCurrentPrintJob();
// Notify that the printing is done.
void PrintingDone(bool success);
// Terminates the print job. No-op if no print job has been created. If
// |cancel| is true, cancel it instead of waiting for the job to finish. Will
// call ReleasePrintJob().
@@ -130,8 +132,14 @@ class CefPrintViewManagerBase : public content::NotificationObserver,
// Release the PrinterQuery associated with our |cookie_|.
void ReleasePrinterQuery();
// Helper method for UpdatePrintingEnabled().
void SendPrintingEnabled(bool enabled, content::RenderFrameHost* rfh);
content::NotificationRegistrar registrar_;
// 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_;

View File

@@ -4,19 +4,25 @@
#include "libcef/browser/printing/printing_message_filter.h"
#include <memory>
#include <string>
#include <utility>
#include "base/bind.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_keyed_service_shutdown_notifier_factory.h"
#include "components/printing/browser/print_manager_utils.h"
#include "components/printing/common/print_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#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"
@@ -26,24 +32,90 @@ using content::BrowserThread;
namespace printing {
CefPrintingMessageFilter::CefPrintingMessageFilter(int render_process_id)
namespace {
// There's a race condition between deletion of the CefPrintingMessageFilter
// object on the UI thread and deletion of the PrefService (owned by Profile)
// on the UI thread. If the PrefService will be deleted first then
// PrefMember::Destroy() must be called from ShutdownOnUIThread() to avoid
// heap-use-after-free on CefPrintingMessageFilter destruction (due to
// ~PrefMember trying to access the already-deleted PrefService).
// ShutdownNotifierFactory makes sure that ShutdownOnUIThread() is called in
// this case.
class ShutdownNotifierFactory
: public BrowserContextKeyedServiceShutdownNotifierFactory {
public:
static ShutdownNotifierFactory* GetInstance();
private:
friend struct base::DefaultLazyInstanceTraits<ShutdownNotifierFactory>;
ShutdownNotifierFactory()
: BrowserContextKeyedServiceShutdownNotifierFactory(
"CefPrintingMessageFilter") {
}
~ShutdownNotifierFactory() override {}
DISALLOW_COPY_AND_ASSIGN(ShutdownNotifierFactory);
};
base::LazyInstance<ShutdownNotifierFactory>::Leaky
g_shutdown_notifier_factory = LAZY_INSTANCE_INITIALIZER;
// static
ShutdownNotifierFactory* ShutdownNotifierFactory::GetInstance() {
return g_shutdown_notifier_factory.Pointer();
}
} // namespace
CefPrintingMessageFilter::CefPrintingMessageFilter(int render_process_id,
Profile* profile)
: content::BrowserMessageFilter(PrintMsgStart),
render_process_id_(render_process_id),
queue_(g_browser_process->print_job_manager()->queue()) {
DCHECK(queue_.get());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
shutdown_notifier_ =
ShutdownNotifierFactory::GetInstance()->Get(profile)->Subscribe(
base::Bind(&CefPrintingMessageFilter::ShutdownOnUIThread,
base::Unretained(this)));
is_printing_enabled_.Init(prefs::kPrintingEnabled, profile->GetPrefs());
is_printing_enabled_.MoveToThread(
content::BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
}
void CefPrintingMessageFilter::EnsureShutdownNotifierFactoryBuilt() {
ShutdownNotifierFactory::GetInstance();
}
CefPrintingMessageFilter::~CefPrintingMessageFilter() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
void CefPrintingMessageFilter::ShutdownOnUIThread() {
is_printing_enabled_.Destroy();
shutdown_notifier_.reset();
}
void CefPrintingMessageFilter::OverrideThreadForMessage(
const IPC::Message& message, BrowserThread::ID* thread) {
#if defined(OS_ANDROID)
if (message.type() == PrintHostMsg_AllocateTempFileForPrinting::ID ||
message.type() == PrintHostMsg_TempFileForPrintingWritten::ID) {
*thread = BrowserThread::UI;
}
#endif
}
void CefPrintingMessageFilter::OnDestruct() const {
BrowserThread::DeleteOnUIThread::Destruct(this);
}
bool CefPrintingMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(CefPrintingMessageFilter, message)
IPC_MESSAGE_HANDLER(PrintHostMsg_IsPrintingEnabled, OnIsPrintingEnabled)
IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_GetDefaultPrintSettings,
OnGetDefaultPrintSettings)
IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_ScriptedPrint, OnScriptedPrint)
@@ -55,11 +127,6 @@ bool CefPrintingMessageFilter::OnMessageReceived(const IPC::Message& message) {
return handled;
}
void CefPrintingMessageFilter::OnIsPrintingEnabled(bool* is_enabled) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
*is_enabled = true;
}
void CefPrintingMessageFilter::OnGetDefaultPrintSettings(
IPC::Message* reply_msg) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -70,6 +137,11 @@ void CefPrintingMessageFilter::OnGetDefaultPrintSettings(
#endif
scoped_refptr<PrinterQuery> printer_query;
if (!is_printing_enabled_.GetValue()) {
// Reply with NULL query.
OnGetDefaultPrintSettingsReply(printer_query, reply_msg);
return;
}
printer_query = queue_->PopPrinterQuery(0);
if (!printer_query.get()) {
printer_query =
@@ -168,16 +240,19 @@ void CefPrintingMessageFilter::OnUpdatePrintSettings(
std::unique_ptr<base::DictionaryValue> new_settings(job_settings.DeepCopy());
scoped_refptr<PrinterQuery> printer_query;
if (!is_printing_enabled_.GetValue()) {
// Reply with NULL query.
OnUpdatePrintSettingsReply(printer_query, reply_msg);
return;
}
printer_query = queue_->PopPrinterQuery(document_cookie);
if (!printer_query.get()) {
int host_id = render_process_id_;
int routing_id = reply_msg->routing_id();
if (!new_settings->GetInteger(printing::kPreviewInitiatorHostId,
&host_id) ||
!new_settings->GetInteger(printing::kPreviewInitiatorRoutingId,
&routing_id)) {
int host_id;
int routing_id;
if (!new_settings->GetInteger(kPreviewInitiatorHostId, &host_id) ||
!new_settings->GetInteger(kPreviewInitiatorRoutingId, &routing_id)) {
host_id = content::ChildProcessHost::kInvalidUniqueID;
routing_id = content::ChildProcessHost::kInvalidUniqueID;
routing_id = MSG_ROUTING_NONE;
}
printer_query = queue_->CreatePrinterQuery(host_id, routing_id);
}
@@ -199,11 +274,10 @@ void CefPrintingMessageFilter::OnUpdatePrintSettingsReply(
params.params.document_cookie = printer_query->cookie();
params.pages = PageRange::GetPages(printer_query->settings().ranges());
}
PrintHostMsg_UpdatePrintSettings::WriteReplyParams(
reply_msg,
params,
printer_query.get() &&
(printer_query->last_status() == printing::PrintingContext::CANCEL));
bool canceled = printer_query.get() &&
(printer_query->last_status() == PrintingContext::CANCEL);
PrintHostMsg_UpdatePrintSettings::WriteReplyParams(reply_msg, params,
canceled);
Send(reply_msg);
// If user hasn't cancelled.
if (printer_query.get()) {

View File

@@ -7,31 +7,25 @@
#include <stdint.h>
#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
#include "components/prefs/pref_member.h"
#include "content/public/browser/browser_message_filter.h"
#if defined(OS_WIN)
#include "base/memory/shared_memory.h"
#endif
#include "printing/features/features.h"
struct PrintHostMsg_ScriptedPrint_Params;
class Profile;
namespace base {
class DictionaryValue;
class FilePath;
}
namespace content {
class WebContents;
}
namespace printing {
class PrintJobManager;
class PrintQueriesQueue;
class PrinterQuery;
@@ -39,24 +33,23 @@ class PrinterQuery;
// renderer process on the IPC thread.
class CefPrintingMessageFilter : public content::BrowserMessageFilter {
public:
explicit CefPrintingMessageFilter(int render_process_id);
CefPrintingMessageFilter(int render_process_id, Profile* profile);
static void EnsureShutdownNotifierFactoryBuilt();
// content::BrowserMessageFilter methods.
void OverrideThreadForMessage(const IPC::Message& message,
content::BrowserThread::ID* thread) override;
void OnDestruct() const override;
bool OnMessageReceived(const IPC::Message& message) override;
private:
friend class base::DeleteHelper<CefPrintingMessageFilter>;
friend class content::BrowserThread;
~CefPrintingMessageFilter() override;
// GetPrintSettingsForRenderView must be called via PostTask and
// base::Bind. Collapse the settings-specific params into a
// struct to avoid running into issues with too many params
// to base::Bind.
struct GetPrintSettingsForRenderViewParams;
// Checks if printing is enabled.
void OnIsPrintingEnabled(bool* is_enabled);
void ShutdownOnUIThread();
// Get the default print setting.
void OnGetDefaultPrintSettings(IPC::Message* reply_msg);
@@ -80,14 +73,20 @@ class CefPrintingMessageFilter : public content::BrowserMessageFilter {
void OnUpdatePrintSettingsReply(scoped_refptr<PrinterQuery> printer_query,
IPC::Message* reply_msg);
// Check to see if print preview has been cancelled.
void OnCheckForCancel(int32_t preview_ui_id,
int preview_request_id,
bool* cancel);
BooleanPrefMember is_printing_enabled_;
const int render_process_id_;
scoped_refptr<PrintQueriesQueue> queue_;
std::unique_ptr<KeyedServiceShutdownNotifier::Subscription>
shutdown_notifier_;
DISALLOW_COPY_AND_ASSIGN(CefPrintingMessageFilter);
};

View File

@@ -81,29 +81,12 @@ CefResourceDispatcherHostDelegate::~CefResourceDispatcherHostDelegate() {
bool CefResourceDispatcherHostDelegate::HandleExternalProtocol(
const GURL& url,
int child_id,
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
content::ResourceContext* resource_context) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::Bind(base::IgnoreResult(&CefResourceDispatcherHostDelegate::
HandleExternalProtocol),
base::Unretained(this), url, child_id, web_contents_getter,
is_main_frame, page_transition, has_user_gesture,
resource_context));
return false;
}
content::WebContents* web_contents = web_contents_getter.Run();
if (web_contents) {
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForContents(web_contents);
if (browser.get())
browser->HandleExternalProtocol(url);
}
content::ResourceRequestInfo* info) {
CEF_POST_TASK(CEF_UIT,
base::Bind(base::IgnoreResult(&CefResourceDispatcherHostDelegate::
HandleExternalProtocolOnUIThread),
base::Unretained(this), url,
info->GetWebContentsGetterForRequest()));
return false;
}
@@ -218,3 +201,17 @@ std::unique_ptr<net::ClientCertStore>
return static_cast<CefResourceContext*>(resource_context)->
CreateClientCertStore();
}
void CefResourceDispatcherHostDelegate::HandleExternalProtocolOnUIThread(
const GURL& url,
const content::ResourceRequestInfo::WebContentsGetter&
web_contents_getter) {
CEF_REQUIRE_UIT();
content::WebContents* web_contents = web_contents_getter.Run();
if (web_contents) {
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForContents(web_contents);
if (browser.get())
browser->HandleExternalProtocol(url);
}
}

View File

@@ -23,13 +23,7 @@ class CefResourceDispatcherHostDelegate
// ResourceDispatcherHostDelegate methods.
bool HandleExternalProtocol(
const GURL& url,
int child_id,
const content::ResourceRequestInfo::WebContentsGetter&
web_contents_getter,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
content::ResourceContext* resource_context) override;
content::ResourceRequestInfo* info) override;
bool ShouldInterceptResourceAsStream(net::URLRequest* request,
const base::FilePath& plugin_path,
const std::string& mime_type,
@@ -46,6 +40,11 @@ class CefResourceDispatcherHostDelegate
content::ResourceContext* resource_context) override;
private:
void HandleExternalProtocolOnUIThread(
const GURL& url,
const content::ResourceRequestInfo::WebContentsGetter&
web_contents_getter);
struct StreamTargetInfo {
std::string extension_id;
std::string view_id;

View File

@@ -81,6 +81,10 @@ CefStoragePartitionProxy::GetBackgroundSyncContext() {
return parent_->GetBackgroundSyncContext();
}
content::PaymentAppContext* CefStoragePartitionProxy::GetPaymentAppContext() {
return parent_->GetPaymentAppContext();
}
content::BroadcastChannelProvider*
CefStoragePartitionProxy::GetBroadcastChannelProvider() {
return parent_->GetBroadcastChannelProvider();

View File

@@ -37,6 +37,7 @@ class CefStoragePartitionProxy : public content::StoragePartition {
content::PlatformNotificationContext* GetPlatformNotificationContext()
override;
content::BackgroundSyncContext* GetBackgroundSyncContext() override;
content::PaymentAppContext* GetPaymentAppContext() override;
content::BroadcastChannelProvider* GetBroadcastChannelProvider() override;
void ClearDataForOrigin(uint32_t remove_mask,
uint32_t quota_storage_remove_mask,

View File

@@ -30,7 +30,7 @@ void PluginsCallbackImpl(
}
}
#if !(defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)) || \
#if !(defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)) || \
defined(OS_LINUX)
void DeliverWidevineCdmError(const std::string& error_message,
@@ -171,7 +171,7 @@ void CefIsWebPluginUnstable(
void CefRegisterWidevineCdm(const CefString& path,
CefRefPtr<CefRegisterCdmCallback> callback) {
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
#if defined(OS_LINUX)
// Enforce the requirement that CefRegisterWidevineCdm() is called before
// CefInitialize() on Linux. See comments in
@@ -187,5 +187,5 @@ void CefRegisterWidevineCdm(const CefString& path,
CefWidevineLoader::GetInstance()->LoadWidevineCdm(path, callback);
#else
DeliverWidevineCdmError("Widevine registration is not supported", callback);
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
}

View File

@@ -50,9 +50,6 @@ const char kDisableJavascriptAccessClipboard[] =
// Disable DOM paste via JavaScript execCommand("paste").
const char kDisableJavascriptDomPaste[] = "disable-javascript-dom-paste";
// Enable caret browsing.
const char kEnableCaretBrowsing[] = "enable-caret-browsing";
// Allow universal access from file URLs.
const char kAllowUniversalAccessFromFileUrls[] =
"allow-universal-access-from-files";
@@ -122,4 +119,9 @@ const char kEnablePreferenceTesting[] = "enable-preference-testing";
// Enable date-based expiration of built in network security information.
const char kEnableNetSecurityExpiration[] = "enable-net-security-expiration";
#if defined(OS_MACOSX)
// Path to the framework directory.
const char kFrameworkDirPath[] = "framework-dir-path";
#endif
} // namespace switches

View File

@@ -8,6 +8,8 @@
#define CEF_LIBCEF_COMMON_CEF_SWITCHES_H_
#pragma once
#include "build/build_config.h"
namespace switches {
extern const char kLogFile[];
@@ -27,7 +29,6 @@ extern const char kDisableJavascriptOpenWindows[];
extern const char kDisableJavascriptCloseWindows[];
extern const char kDisableJavascriptAccessClipboard[];
extern const char kDisableJavascriptDomPaste[];
extern const char kEnableCaretBrowsing[];
extern const char kAllowUniversalAccessFromFileUrls[];
extern const char kDisableImageLoading[];
extern const char kImageShrinkStandaloneToFit[];
@@ -52,6 +53,10 @@ extern const char kPluginPolicy_Block[];
extern const char kEnablePreferenceTesting[];
extern const char kEnableNetSecurityExpiration[];
#if defined(OS_MACOSX)
extern const char kFrameworkDirPath[];
#endif
} // namespace switches
#endif // CEF_LIBCEF_COMMON_CEF_SWITCHES_H_

View File

@@ -206,7 +206,7 @@ void CefContentClient::AddPepperPlugins(
AddPepperFlashFromCommandLine(plugins);
#if defined(OS_LINUX)
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
CefWidevineLoader::AddPepperPlugins(plugins);
#endif
#endif

View File

@@ -20,7 +20,7 @@
#include "chrome/common/crash_keys.h"
#if defined(OS_MACOSX)
#include "base/mac/foundation_util.h"
#include "libcef/common/util_mac.h"
#endif
#if defined(OS_POSIX)
@@ -73,22 +73,20 @@ PathString GetCrashConfigPath() {
config_path += L"crash_reporter.cfg";
return config_path;
#elif defined(OS_POSIX)
// Start with the path to the running executable.
base::FilePath config_path;
if (!PathService::Get(base::DIR_EXE, &config_path))
return PathString();
#if defined(OS_MACOSX)
// Get the main app bundle path.
config_path = base::mac::GetAppBundlePath(config_path);
if (config_path.empty())
return PathString();
// Go into the Contents/Resources directory.
config_path = config_path.Append(FILE_PATH_LITERAL("Contents"))
.Append(FILE_PATH_LITERAL("Resources"));
// Start with the path to the main app Resources directory. May be empty if
// not running in an app bundle.
config_path = util_mac::GetMainResourcesDirectory();
#endif
if (config_path.empty()) {
// Start with the path to the running executable.
if (!PathService::Get(base::DIR_EXE, &config_path))
return PathString();
}
return config_path.Append(FILE_PATH_LITERAL("crash_reporter.cfg")).value();
#endif // defined(OS_POSIX)
}
@@ -382,6 +380,12 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
if (!val_str.empty())
app_name_ = sanitizePathComponent(val_str);
}
#elif defined(OS_MACOSX)
else if (name_str == "BrowserCrashForwardingEnabled") {
enable_browser_crash_forwarding_ =
(base::EqualsCaseInsensitiveASCII(val_str, "true") ||
val_str == "1");
}
#endif
} else if (current_section == kCrashKeysSection) {
size_t max_size = 0;
@@ -631,3 +635,9 @@ bool CefCrashReporterClient::HasCrashExternalHandler() const {
}
#endif // defined(OS_WIN)
#if defined(OS_MACOSX)
bool CefCrashReporterClient::EnableBrowserCrashForwarding() {
return enable_browser_crash_forwarding_;
}
#endif

View File

@@ -85,6 +85,10 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient {
bool HasCrashExternalHandler() const;
#endif
#if defined(OS_MACOSX)
bool EnableBrowserCrashForwarding() override;
#endif
private:
bool has_crash_config_file_ = false;
@@ -109,6 +113,10 @@ private:
std::string external_handler_;
#endif
#if defined(OS_MACOSX)
bool enable_browser_crash_forwarding_ = false;
#endif
DISALLOW_COPY_AND_ASSIGN(CefCrashReporterClient);
};

View File

@@ -59,24 +59,26 @@ void InitCrashReporter(const base::CommandLine& command_line,
// framework dylib is even loaded, to catch potential early crashes.
crash_reporter::InitializeCrashpad(process_type.empty(), process_type);
// Mac Chrome is packaged with a main app bundle and a helper app bundle.
// The main app bundle should only be used for the browser process, so it
// should never see a --type switch (switches::kProcessType). Likewise,
// the helper should always have a --type switch.
//
// This check is done this late so there is already a call to
// base::mac::IsBackgroundOnlyProcess(), so there is no change in
// startup/initialization order.
if (base::mac::AmIBundled()) {
// Mac Chrome is packaged with a main app bundle and a helper app bundle.
// The main app bundle should only be used for the browser process, so it
// should never see a --type switch (switches::kProcessType). Likewise,
// the helper should always have a --type switch.
//
// This check is done this late so there is already a call to
// base::mac::IsBackgroundOnlyProcess(), so there is no change in
// startup/initialization order.
// The helper's Info.plist marks it as a background only app.
if (base::mac::IsBackgroundOnlyProcess()) {
CHECK(command_line.HasSwitch(switches::kProcessType) &&
!process_type.empty())
<< "Helper application requires --type.";
} else {
CHECK(!command_line.HasSwitch(switches::kProcessType) &&
process_type.empty())
<< "Main application forbids --type, saw " << process_type;
// The helper's Info.plist marks it as a background only app.
if (base::mac::IsBackgroundOnlyProcess()) {
CHECK(command_line.HasSwitch(switches::kProcessType) &&
!process_type.empty())
<< "Helper application requires --type.";
} else {
CHECK(!command_line.HasSwitch(switches::kProcessType) &&
process_type.empty())
<< "Main application forbids --type, saw " << process_type;
}
}
g_crash_reporting_enabled = true;

View File

@@ -2,8 +2,8 @@
# 2014 the Chromium Authors. All rights reserved. Use of this source code is
# governed by a BSD-style license that can be found in the LICENSE file.
import("//build/json_schema_api.gni")
import("//tools/json_schema_compiler/json_features.gni")
#import("//tools/json_schema_compiler/json_schema_api.gni")
# TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See README.txt for
# details.

View File

@@ -10,20 +10,22 @@ To add a new extension API implemented only in CEF ***:
API.
2. Add <api>.idl or .json to the 'schema_sources' list in
libcef/common/extensions/api/BUILD.gn. Serialization code will be
generated based on this list in step 5.
3. Add an entry in the libcef/common/extensions/api/_*_features.json files if
necessary [1].
4. Add libcef/browser/extensions/api/<api>/<api>_api.[h|cc] class implementation
generated based on this list in step 4.
3. Add libcef/browser/extensions/api/<api>/<api>_api.[h|cc] class implementation
files and associated entries to the 'libcef_static' target in BUILD.gn.
5. Run the cef_create_projects script and build to generate the
4. Run the cef_create_projects script and build to generate the
cef/libcef/common/extensions/api/<api>.h file and other serialization code
required by the extensions system.
6. Call `<class>::GetInstance();` or `<class>Factory::GetFactoryInstance();` [2]
5. Add an entry in the libcef/common/extensions/api/_*_features.json files if
necessary [1].
6. Add an entry in the libcef/common/extensions/api/*_manifest_overlay.json
files if necessary [2].
7. Call `<class>::GetInstance();` or `<class>Factory::GetFactoryInstance();` [3]
from EnsureBrowserContextKeyedServiceFactoriesBuilt in
libcef/browser/extensions/browser_context_keyed_service_factories.cc.
7. Call `DependsOn(<class>Factory::GetInstance());` from
8. Call `DependsOn(<class>Factory::GetInstance());` from
CefExtensionSystemFactory::CefExtensionSystemFactory in
libcef/browser/extensions/extension_system_factory.cc if necessary [2].
libcef/browser/extensions/extension_system_factory.cc if necessary [3].
*** Note that CEF does not currently expose its own Mojo APIs. Related code is
commented out in:
@@ -36,7 +38,7 @@ commented out in:
To add a new extension API implemented in Chrome:
1. Register the API in libcef/browser/extensions/chrome_api_registration.cc
2. Perform steps 3, 6 and 7 above.
2. Perform steps 5 through 8 above.
See https://www.chromium.org/developers/design-documents/mojo for more
information.
@@ -46,7 +48,17 @@ information.
additional details. For Chrome extensions this should match the definitions
in the chrome/common/extensions/api/_*_features.json files.
[2] Some Mojo APIs use singleton Factory objects that create a one-to-one
[2] Service Manifest InterfaceProviderSpecs control interfaces exposed between
processes. Mojo interfaces exposed at the frame level are controlled by the
"navigation:frame" dictionary. Those exposed at the process level are
controlled by the "service_manager:connector" dictionary. Failure to specify
this correctly may result in a console error like the following:
InterfaceProviderSpec "navigation:frame" prevented service:
service:content_renderer from binding interface:
mojom::Foo exposed by: service:content_browser
[3] Some Mojo APIs use singleton Factory objects that create a one-to-one
relationship between a service and a BrowserContext. This is used primarily
to control shutdown/destruction order and implementors must explicitly state
which services are depended on. See comments in

View File

@@ -0,0 +1,14 @@
{
"name": "content_browser",
"display_name": "CEF",
"interface_provider_specs": {
"navigation:frame": {
"provides": {
"renderer": [
"extensions::KeepAlive",
"extensions::mime_handler::MimeHandlerService"
]
}
}
}
}

View File

@@ -0,0 +1,5 @@
{
"display_name": "Chrome Render Process",
"interface_provider_specs": {
}
}

View File

@@ -0,0 +1,12 @@
{
"name": "content_utility",
"interface_provider_specs": {
"service_manager:connector": {
"provides": {
"browser": [
"net::interfaces::ProxyResolverFactory"
]
}
}
}
}

View File

@@ -17,10 +17,12 @@
#include "cef/libcef/common/extensions/api/cef_behavior_features.h"
#include "cef/libcef/common/extensions/api/cef_manifest_features.h"
#include "cef/libcef/common/extensions/api/cef_permission_features.h"
#include "chrome/common/extensions/chrome_aliases.h"
#include "chrome/common/extensions/chrome_manifest_handlers.h"
#include "chrome/grit/common_resources.h"
#include "extensions/common/api/generated_schemas.h"
#include "extensions/common/common_manifest_handlers.h"
#include "extensions/common/extensions_aliases.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/features/api_feature.h"
#include "extensions/common/features/behavior_feature.h"
@@ -59,8 +61,10 @@ void CefExtensionsClient::Initialize() {
// TODO(jamescook): Do we need to whitelist any extensions?
// Set up permissions.
PermissionsInfo::GetInstance()->AddProvider(chrome_api_permissions_);
PermissionsInfo::GetInstance()->AddProvider(extensions_api_permissions_);
PermissionsInfo::GetInstance()->AddProvider(chrome_api_permissions_,
GetChromePermissionAliases());
PermissionsInfo::GetInstance()->AddProvider(extensions_api_permissions_,
GetExtensionsPermissionAliases());
}
const PermissionMessageProvider&
@@ -177,8 +181,10 @@ std::string CefExtensionsClient::GetWebstoreBaseURL() const {
return extension_urls::kChromeWebstoreBaseURL;
}
std::string CefExtensionsClient::GetWebstoreUpdateURL() const {
return extension_urls::kChromeWebstoreUpdateURL;
const GURL& CefExtensionsClient::GetWebstoreUpdateURL() const {
if (webstore_update_url_.is_empty())
webstore_update_url_ = GURL(extension_urls::GetWebstoreUpdateUrl());
return webstore_update_url_;
}
bool CefExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const {

View File

@@ -12,6 +12,7 @@
#include "chrome/common/extensions/permissions/chrome_permission_message_provider.h"
#include "extensions/common/extensions_client.h"
#include "extensions/common/permissions/extensions_api_permissions.h"
#include "url/gurl.h"
namespace extensions {
@@ -44,7 +45,7 @@ class CefExtensionsClient : public ExtensionsClient {
bool ShouldSuppressFatalErrors() const override;
void RecordDidSuppressFatalError() override;
std::string GetWebstoreBaseURL() const override;
std::string GetWebstoreUpdateURL() const override;
const GURL& GetWebstoreUpdateURL() const override;
bool IsBlacklistUpdateURL(const GURL& url) const override;
private:
@@ -54,6 +55,9 @@ class CefExtensionsClient : public ExtensionsClient {
ScriptingWhitelist scripting_whitelist_;
// Mutable to allow caching in a const method.
mutable GURL webstore_update_url_;
DISALLOW_COPY_AND_ASSIGN(CefExtensionsClient);
};

View File

@@ -70,57 +70,38 @@ namespace {
#if defined(OS_MACOSX)
base::FilePath GetFrameworksPath() {
// Start out with the path to the running executable.
base::FilePath execPath;
PathService::Get(base::FILE_EXE, &execPath);
// Get the main bundle path.
base::FilePath bundlePath = base::mac::GetAppBundlePath(execPath);
// Go into the Contents/Frameworks directory.
return bundlePath.Append(FILE_PATH_LITERAL("Contents"))
.Append(FILE_PATH_LITERAL("Frameworks"));
}
// The framework bundle path is used for loading resources, libraries, etc.
base::FilePath GetFrameworkBundlePath() {
return GetFrameworksPath().Append(
FILE_PATH_LITERAL("Chromium Embedded Framework.framework"));
}
base::FilePath GetResourcesFilePath() {
return GetFrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources"));
}
// Retrieve the name of the running executable.
std::string GetExecutableName() {
base::FilePath path;
PathService::Get(base::FILE_EXE, &path);
return path.BaseName().value();
return util_mac::GetFrameworkResourcesDirectory();
}
// Use a "~/Library/Logs/<app name>_debug.log" file where <app name> is the name
// of the running executable.
base::FilePath GetDefaultLogFile() {
std::string exe_name = util_mac::GetMainProcessPath().BaseName().value();
return base::mac::GetUserLibraryPath()
.Append(FILE_PATH_LITERAL("Logs"))
.Append(FILE_PATH_LITERAL(GetExecutableName() + "_debug.log"));
.Append(FILE_PATH_LITERAL(exe_name + "_debug.log"));
}
void OverrideFrameworkBundlePath() {
base::mac::SetOverrideFrameworkBundlePath(GetFrameworkBundlePath());
base::FilePath framework_path = util_mac::GetFrameworkDirectory();
DCHECK(!framework_path.empty());
base::mac::SetOverrideFrameworkBundlePath(framework_path);
}
void OverrideChildProcessPath() {
const std::string& exe_name = GetExecutableName();
base::FilePath helper_path = GetFrameworksPath()
.Append(FILE_PATH_LITERAL(exe_name + " Helper.app"))
.Append(FILE_PATH_LITERAL("Contents"))
.Append(FILE_PATH_LITERAL("MacOS"))
.Append(FILE_PATH_LITERAL(exe_name + " Helper"));
base::FilePath child_process_path =
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
switches::kBrowserSubprocessPath);
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
if (child_process_path.empty()) {
child_process_path = util_mac::GetChildProcessPath();
DCHECK(!child_process_path.empty());
}
// Used by ChildProcessHost::GetChildPath and PlatformCrashpadInitialization.
PathService::Override(content::CHILD_PROCESS_EXE, child_process_path);
}
#else // !defined(OS_MACOSX)
@@ -306,10 +287,6 @@ CefMainDelegate::~CefMainDelegate() {
}
bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
#if defined(OS_MACOSX)
OverrideFrameworkBundlePath();
#endif
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
std::string process_type =
command_line->GetSwitchValueASCII(switches::kProcessType);
@@ -354,6 +331,15 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
}
}
#if defined(OS_MACOSX)
if (settings.framework_dir_path.length > 0) {
base::FilePath file_path =
base::FilePath(CefString(&settings.framework_dir_path));
if (!file_path.empty())
command_line->AppendSwitchPath(switches::kFrameworkDirPath, file_path);
}
#endif
if (no_sandbox)
command_line->AppendSwitch(switches::kNoSandbox);
@@ -508,6 +494,10 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
content::SetContentClient(&content_client_);
#if defined(OS_MACOSX)
OverrideFrameworkBundlePath();
#endif
return false;
}

View File

@@ -7,6 +7,7 @@
#include "libcef/common/content_client.h"
#include "content/public/common/url_constants.h"
#include "net/net_features.h"
#include "extensions/common/constants.h"
#include "url/url_constants.h"
@@ -65,7 +66,7 @@ bool IsInternalProtectedScheme(const std::string& scheme) {
url::kDataScheme,
url::kFileScheme,
url::kFileSystemScheme,
#if !defined(DISABLE_FTP_SUPPORT)
#if !BUILDFLAG(DISABLE_FTP_SUPPORT)
url::kFtpScheme,
#endif
};

View File

@@ -786,7 +786,7 @@ void CefRequestImpl::Get(net::URLFetcher& fetcher,
}
if (!first_party_for_cookies_.is_empty())
fetcher.SetInitiatorURL(first_party_for_cookies_);
fetcher.SetInitiator(url::Origin(first_party_for_cookies_));
if (flags_ & UR_FLAG_NO_RETRY_ON_5XX)
fetcher.SetAutomaticallyRetryOn5xx(false);

View File

@@ -88,14 +88,8 @@ scoped_refptr<base::SequencedTaskRunner>
if (id >= 0 && CefContentClient::Get() &&
CefContentClient::Get()->browser() &&
BrowserThread::IsMessageLoopValid(static_cast<BrowserThread::ID>(id))) {
// Don't use BrowserThread::GetTaskRunnerForThread because it returns
// a new MessageLoopProxy object for each call and makes pointer equality
// testing impossible.
base::MessageLoop* message_loop =
BrowserThread::UnsafeGetMessageLoopForThread(
static_cast<BrowserThread::ID>(id));
if (message_loop)
return message_loop->task_runner();
return BrowserThread::GetTaskRunnerForThread(
static_cast<BrowserThread::ID>(id));
}
return NULL;
@@ -106,9 +100,19 @@ scoped_refptr<base::SequencedTaskRunner>
CefTaskRunnerImpl::GetCurrentTaskRunner() {
scoped_refptr<base::SequencedTaskRunner> task_runner;
// Check for a MessageLoopProxy. This covers all of the named browser and
// render process threads, plus a few extra.
task_runner = base::ThreadTaskRunnerHandle::Get();
// For named browser process threads return the same TaskRunner as
// GetTaskRunner(). Otherwise BelongsToThread() will return incorrect results.
BrowserThread::ID current_id;
if (BrowserThread::GetCurrentThreadIdentifier(&current_id) &&
BrowserThread::IsMessageLoopValid(current_id)) {
task_runner = BrowserThread::GetTaskRunnerForThread(current_id);
}
if (!task_runner.get()) {
// Check for a MessageLoopProxy. This covers all of the named browser and
// render process threads, plus a few extra.
task_runner = base::ThreadTaskRunnerHandle::Get();
}
if (!task_runner.get()) {
// Check for a WebWorker thread.

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Copyright 2017 The Chromium Embedded Framework Authors. Portions copyright
// 2011 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#ifndef CEF_LIBCEF_COMMON_UTIL_MAC_H_
#define CEF_LIBCEF_COMMON_UTIL_MAC_H_
@@ -12,8 +12,35 @@ class FilePath;
namespace util_mac {
// Returns the path to the NSLibraryDirectory (e.g. "~/Library").
bool GetLocalLibraryDirectory(base::FilePath* result);
// Returns the path to the CEF framework directory inside the top-level app
// bundle (e.g. "myapp.app/Contents/Frameworks/Chromium Embedded
// Framework.framework"). May return an empty value if not running in an app
// bundle.
base::FilePath GetFrameworkDirectory();
// Returns the path to the Resources directory inside the CEF framework
// directory (e.g. "myapp.app/Contents/Frameworks/Chromium Embedded
// Framework.framework/Resources"). May return an empty value if not running in
// an app bundle.
base::FilePath GetFrameworkResourcesDirectory();
// Returns the path to the main (running) process executable (e.g.
// "myapp.app/Contents/MacOS/myapp").
base::FilePath GetMainProcessPath();
// Returns the path to the Resources directory inside the top-level app bundle
// (e.g. "myapp.app/Contents/Resources"). May return an empty value if not
// running in an app bundle.
base::FilePath GetMainResourcesDirectory();
// Returns the path to the child process executable (e.g. "myapp.app/
// Contents/Frameworks/myapp Helper.app/Contents/MacOS/myapp Helper"). May
// return an empty value if not running in an app bundle.
base::FilePath GetChildProcessPath();
} // namespace util_mac
#endif // CEF_LIBCEF_COMMON_UTIL_MAC_H_

View File

@@ -1,15 +1,92 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Copyright 2017 The Chromium Embedded Framework Authors. Portions copyright
// 2011 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "libcef/common/util_mac.h"
#include "libcef/common/cef_switches.h"
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/mac/foundation_util.h"
#include "base/path_service.h"
namespace util_mac {
namespace {
// Returns the path to the top-level app bundle that contains the main process
// executable.
base::FilePath GetMainBundlePath() {
return base::mac::GetAppBundlePath(GetMainProcessPath());
}
// Returns the path to the Frameworks directory inside the top-level app bundle.
base::FilePath GetFrameworksPath() {
base::FilePath bundle_path = GetMainBundlePath();
if (bundle_path.empty())
return base::FilePath();
return bundle_path.Append(FILE_PATH_LITERAL("Contents"))
.Append(FILE_PATH_LITERAL("Frameworks"));
}
} // namespace
bool GetLocalLibraryDirectory(base::FilePath* result) {
return base::mac::GetLocalDirectory(NSLibraryDirectory, result);
}
base::FilePath GetFrameworkDirectory() {
base::FilePath frameworks_path =
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
switches::kFrameworkDirPath);
if (!frameworks_path.empty())
return frameworks_path;
frameworks_path = GetFrameworksPath();
if (frameworks_path.empty())
return base::FilePath();
return frameworks_path.Append(
FILE_PATH_LITERAL("Chromium Embedded Framework.framework"));
}
base::FilePath GetFrameworkResourcesDirectory() {
base::FilePath frameworks_path = GetFrameworkDirectory();
if (frameworks_path.empty())
return base::FilePath();
return frameworks_path.Append(FILE_PATH_LITERAL("Resources"));
}
base::FilePath GetMainProcessPath() {
base::FilePath path;
PathService::Get(base::FILE_EXE, &path);
DCHECK(!path.empty());
return path;
}
base::FilePath GetMainResourcesDirectory() {
base::FilePath bundle_path = GetMainBundlePath();
if (bundle_path.empty())
return base::FilePath();
return bundle_path.Append(FILE_PATH_LITERAL("Contents"))
.Append(FILE_PATH_LITERAL("Resources"));
}
base::FilePath GetChildProcessPath() {
base::FilePath frameworks_path = GetFrameworksPath();
if (frameworks_path.empty())
return base::FilePath();
std::string exe_name = GetMainProcessPath().BaseName().value();
return frameworks_path.Append(FILE_PATH_LITERAL(exe_name + " Helper.app"))
.Append(FILE_PATH_LITERAL("Contents"))
.Append(FILE_PATH_LITERAL("MacOS"))
.Append(FILE_PATH_LITERAL(exe_name + " Helper"));
}
} // namespace util_mac

View File

@@ -4,7 +4,7 @@
#include "libcef/common/widevine_loader.h"
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
#include "libcef/browser/context.h"
#include "libcef/browser/thread_util.h"
@@ -403,4 +403,4 @@ CefWidevineLoader::CefWidevineLoader() {
CefWidevineLoader::~CefWidevineLoader() {
}
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)

View File

@@ -10,7 +10,7 @@
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
#include <vector>
@@ -59,6 +59,6 @@ class CefWidevineLoader {
~CefWidevineLoader();
};
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
#endif // CEF_LIBCEF_COMMON_WIDEVINE_LOADER_H_

View File

@@ -68,7 +68,7 @@ CefRefPtr<CefBrowserImpl> CefBrowserImpl::GetBrowserForMainFrame(
CefRefPtr<CefBrowserHost> CefBrowserImpl::GetHost() {
NOTREACHED() << "GetHost cannot be called from the render process";
return NULL;
return nullptr;
}
bool CefBrowserImpl::CanGoBack() {
@@ -157,31 +157,31 @@ bool CefBrowserImpl::HasDocument() {
}
CefRefPtr<CefFrame> CefBrowserImpl::GetMainFrame() {
CEF_REQUIRE_RT_RETURN(NULL);
CEF_REQUIRE_RT_RETURN(nullptr);
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame())
return GetWebFrameImpl(render_view()->GetWebView()->mainFrame()).get();
return NULL;
return nullptr;
}
CefRefPtr<CefFrame> CefBrowserImpl::GetFocusedFrame() {
CEF_REQUIRE_RT_RETURN(NULL);
CEF_REQUIRE_RT_RETURN(nullptr);
if (render_view()->GetWebView() &&
render_view()->GetWebView()->focusedFrame()) {
return GetWebFrameImpl(render_view()->GetWebView()->focusedFrame()).get();
}
return NULL;
return nullptr;
}
CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(int64 identifier) {
CEF_REQUIRE_RT_RETURN(NULL);
CEF_REQUIRE_RT_RETURN(nullptr);
return GetWebFrameImpl(identifier).get();
}
CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(const CefString& name) {
CEF_REQUIRE_RT_RETURN(NULL);
CEF_REQUIRE_RT_RETURN(nullptr);
blink::WebView* web_view = render_view()->GetWebView();
if (web_view) {
@@ -198,7 +198,7 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(const CefString& name) {
return GetWebFrameImpl(frame).get();
}
return NULL;
return nullptr;
}
size_t CefBrowserImpl::GetFrameCount() {
@@ -207,13 +207,9 @@ size_t CefBrowserImpl::GetFrameCount() {
int count = 0;
if (render_view()->GetWebView()) {
WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
if (main_frame) {
WebFrame* cur = main_frame;
do {
count++;
cur = cur->traverseNext(true);
} while (cur != main_frame);
for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame;
frame = frame->traverseNext()) {
count++;
}
}
@@ -227,13 +223,9 @@ void CefBrowserImpl::GetFrameIdentifiers(std::vector<int64>& identifiers) {
identifiers.clear();
if (render_view()->GetWebView()) {
WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
if (main_frame) {
WebFrame* cur = main_frame;
do {
identifiers.push_back(webkit_glue::GetIdentifier(cur));
cur = cur->traverseNext(true);
} while (cur != main_frame);
for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame;
frame = frame->traverseNext()) {
identifiers.push_back(webkit_glue::GetIdentifier(frame));
}
}
}
@@ -245,13 +237,9 @@ void CefBrowserImpl::GetFrameNames(std::vector<CefString>& names) {
names.clear();
if (render_view()->GetWebView()) {
WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
if (main_frame) {
WebFrame* cur = main_frame;
do {
names.push_back(CefString(cur->uniqueName().utf8()));
cur = cur->traverseNext(true);
} while (cur != main_frame);
for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame;
frame = frame->traverseNext()) {
names.push_back(CefString(frame->uniqueName().utf8()));
}
}
}
@@ -347,7 +335,7 @@ CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(int64_t frame_id) {
if (frame_id == webkit_glue::kInvalidFrameId) {
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame())
return GetWebFrameImpl(render_view()->GetWebView()->mainFrame());
return NULL;
return nullptr;
}
// Check if we already know about the frame.
@@ -357,18 +345,14 @@ CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(int64_t frame_id) {
if (render_view()->GetWebView()) {
// Check if the frame exists but we don't know about it yet.
WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
if (main_frame) {
WebFrame* cur = main_frame;
do {
if (webkit_glue::GetIdentifier(cur) == frame_id)
return GetWebFrameImpl(cur);
cur = cur->traverseNext(true);
} while (cur != main_frame);
for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame;
frame = frame->traverseNext()) {
if (webkit_glue::GetIdentifier(frame) == frame_id)
return GetWebFrameImpl(frame);
}
}
return NULL;
return nullptr;
}
void CefBrowserImpl::AddFrameObject(int64_t frame_id,
@@ -409,7 +393,7 @@ void CefBrowserImpl::OnDestruct() {
handler->OnBrowserDestroyed(this);
}
response_manager_.reset(NULL);
response_manager_.reset();
CefContentRendererClient::Get()->OnBrowserDestroyed(this);
}
@@ -552,7 +536,7 @@ void CefBrowserImpl::OnRequest(const Cef_Request_Params& params) {
false, true));
success = handler->OnProcessMessageReceived(this, PID_BROWSER,
message.get());
message->Detach(NULL);
message->Detach(nullptr);
}
}
} else if (params.name == "execute-code") {

View File

@@ -106,6 +106,7 @@ class CefPrerenderingSupport : public blink::WebPrerenderingSupport {
void add(const blink::WebPrerender& prerender) override {}
void cancel(const blink::WebPrerender& prerender) override {}
void abandon(const blink::WebPrerender& prerender) override {}
void prefetchFinished() override {}
};
// Stub implementation of blink::WebPrerendererClient.
@@ -186,9 +187,8 @@ CefContentRendererClient::CefContentRendererClient()
extensions::ExtensionsRendererClient::Set(
extensions_renderer_client_.get());
}
#if defined(ENABLE_PRINTING)
printing::SetAgent(CefContentClient::Get()->GetUserAgent());
#endif
}
CefContentRendererClient::~CefContentRendererClient() {
@@ -467,6 +467,9 @@ void CefContentRendererClient::RenderFrameCreated(
content::RenderFrame* render_frame) {
new CefRenderFrameObserver(render_frame);
new CefPepperHelper(render_frame);
new printing::PrintWebViewHelper(
render_frame,
base::WrapUnique(new extensions::CefPrintWebViewHelperDelegate()));
if (extensions::ExtensionsEnabled())
extensions_renderer_client_->RenderFrameCreated(render_frame);
@@ -477,9 +480,6 @@ void CefContentRendererClient::RenderFrameCreated(
void CefContentRendererClient::RenderViewCreated(
content::RenderView* render_view) {
new CefPrerendererClient(render_view);
new printing::PrintWebViewHelper(
render_view,
base::WrapUnique(new extensions::CefPrintWebViewHelperDelegate()));
if (extensions::ExtensionsEnabled())
extensions_renderer_client_->RenderViewCreated(render_view);
@@ -598,8 +598,7 @@ bool CefContentRendererClient::ShouldFork(blink::WebLocalFrame* frame,
bool CefContentRendererClient::WillSendRequest(
blink::WebFrame* frame,
ui::PageTransition transition_type,
const GURL& url,
const GURL& first_party_for_cookies,
const blink::WebURL& url,
GURL* new_url) {
if (extensions::ExtensionsEnabled()) {
return extensions_renderer_client_->WillSendRequest(frame, transition_type,

View File

@@ -113,8 +113,7 @@ class CefContentRendererClient : public content::ContentRendererClient,
bool* send_referrer) override;
bool WillSendRequest(blink::WebFrame* frame,
ui::PageTransition transition_type,
const GURL& url,
const GURL& first_party_for_cookies,
const blink::WebURL& url,
GURL* new_url) override;
unsigned long long VisitedLinkHash(const char* canonical_url,
size_t length) override;
@@ -176,6 +175,8 @@ class CefContentRendererClient : public content::ContentRendererClient,
// Access must be protected by |single_process_cleanup_lock_|.
bool single_process_cleanup_complete_;
base::Lock single_process_cleanup_lock_;
DISALLOW_COPY_AND_ASSIGN(CefContentRendererClient);
};
#endif // CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_

View File

@@ -78,7 +78,7 @@ bool CefDOMNodeImpl::IsEditable() {
if (node_.isElementNode()) {
const WebElement& element = node_.toConst<WebElement>();
if (element.isTextFormControlElement())
if (webkit_glue::IsTextControlElement(element))
return true;
// Also return true if it has an ARIA role of 'textbox'.

View File

@@ -170,18 +170,18 @@ bool CefExtensionsRendererClient::OverrideCreatePlugin(
bool CefExtensionsRendererClient::WillSendRequest(
blink::WebFrame* frame,
ui::PageTransition transition_type,
const GURL& url,
const blink::WebURL& url,
GURL* new_url) {
// Check whether the request should be allowed. If not allowed, we reset the
// URL to something invalid to prevent the request and cause an error.
if (url.SchemeIs(extensions::kExtensionScheme) &&
!resource_request_policy_->CanRequestResource(url, frame,
if (url.protocolIs(extensions::kExtensionScheme) &&
!resource_request_policy_->CanRequestResource(GURL(url), frame,
transition_type)) {
*new_url = GURL(chrome::kExtensionInvalidRequestURL);
return true;
}
if (url.SchemeIs(extensions::kExtensionResourceScheme) &&
if (url.protocolIs(extensions::kExtensionResourceScheme) &&
!resource_request_policy_->CanRequestExtensionResourceScheme(url,
frame)) {
*new_url = GURL(chrome::kExtensionResourceInvalidRequestURL);
@@ -239,7 +239,7 @@ bool CefExtensionsRendererClient::ShouldFork(blink::WebLocalFrame* frame,
// for subframes, so this check only makes sense for top-level frames.
// TODO(alexmos,nasko): Figure out how this check should work when reloading
// subframes in --site-per-process mode.
if (!frame->parent() && frame->document().url() == url) {
if (!frame->parent() && GURL(frame->document().url()) == url) {
if (is_extension_url != IsStandaloneExtensionProcess())
return true;
}

View File

@@ -18,6 +18,7 @@ namespace blink {
class WebFrame;
class WebLocalFrame;
struct WebPluginParams;
class WebURL;
}
namespace content {
@@ -50,7 +51,7 @@ class CefExtensionsRendererClient : public ExtensionsRendererClient {
const blink::WebPluginParams& params);
bool WillSendRequest(blink::WebFrame* frame,
ui::PageTransition transition_type,
const GURL& url,
const blink::WebURL& url,
GURL* new_url);
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame);
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame);

View File

@@ -22,7 +22,7 @@ CefPrintWebViewHelperDelegate::~CefPrintWebViewHelperDelegate(){
}
bool CefPrintWebViewHelperDelegate::CancelPrerender(
content::RenderView* render_view, int routing_id) {
content::RenderFrame* render_frame) {
return false;
}

View File

@@ -14,8 +14,7 @@ class CefPrintWebViewHelperDelegate
public:
~CefPrintWebViewHelperDelegate() override;
bool CancelPrerender(content::RenderView* render_view,
int routing_id) override;
bool CancelPrerender(content::RenderFrame* render_frame) override;
blink::WebElement GetPdfElement(blink::WebLocalFrame* frame) override;
bool IsPrintPreviewEnabled() override;
bool OverridePrint(blink::WebLocalFrame* frame) override;

View File

@@ -16,6 +16,7 @@
#include "libcef/common/cef_messages.h"
#include "media/base/eme_constants.h"
#include "media/base/key_system_properties.h"
#include "ppapi/features/features.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
@@ -31,7 +32,7 @@ using media::SupportedCodecs;
namespace {
#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
bool IsPepperCdmAvailable(
const std::string& pepper_type,
std::vector<base::string16>* additional_param_names,
@@ -135,15 +136,15 @@ void AddPepperBasedWidevine(
media::EmeFeatureSupport::NOT_SUPPORTED)); // Distinctive identifier.
}
#endif // defined(WIDEVINE_CDM_AVAILABLE)
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
} // namespace
void AddCefKeySystems(
std::vector<std::unique_ptr<KeySystemProperties>>* key_systems_properties) {
#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE)
AddPepperBasedWidevine(key_systems_properties);
#endif // defined(WIDEVINE_CDM_AVAILABLE)
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
}

View File

@@ -24,8 +24,8 @@
#include "content/public/renderer/render_thread.h"
#include "gin/object_template_builder.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h"

View File

@@ -11,7 +11,7 @@
#include "components/visitedlink/renderer/visitedlink_slave.h"
#include "content/public/renderer/render_thread.h"
#include "net/base/net_module.h"
#include "services/shell/public/cpp/interface_registry.h"
#include "services/service_manager/public/cpp/interface_registry.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"

View File

@@ -186,6 +186,11 @@ v8::MaybeLocal<v8::Value> CallV8Function(v8::Local<v8::Context> context,
return func_rv;
}
bool IsTextControlElement(const blink::WebElement& element) {
const blink::Element* web_element = element.constUnwrap<blink::Element>();
return web_element->isTextControl();
}
v8::MaybeLocal<v8::Value> ExecuteV8ScriptAndReturnValue(
const blink::WebString& source,
const blink::WebString& source_url,

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