Compare commits

...

71 Commits
2743 ... 2785

Author SHA1 Message Date
Marshall Greenblatt
8c4ba9f2d8 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:34:38 -05:00
Marshall Greenblatt
2b5c3a7185 Add Widevine plugin to binary distribution (issue #2009)
Mac: Check in widevinecdmadapter.plugin binary until Widevine GN
build errors are resolved (https://crbug.com/626436).
2016-10-11 14:14:44 -04:00
Marshall Greenblatt
37a29e36b3 Mac: Fix compile error due to issue #2009 changes 2016-10-11 13:43:11 -04:00
Marshall Greenblatt
150a22a49c Add CefRegisterWidevineCdm function and remove component updater support (issue #2009) 2016-10-07 17:51:56 -04:00
Marshall Greenblatt
16e49fb8af Update to Chromium version 53.0.2785.116 2016-09-27 13:45:11 -04:00
Marshall Greenblatt
c3a7e2cdec Mac: Remove registration of selector methods that were deleted in e7ddc933 2016-09-19 11:57:13 -04:00
Marshall Greenblatt
162e9a9190 Add SSL certificate transparency support (issue #1994) 2016-09-16 12:37:34 -04:00
Marshall Greenblatt
15d09c7592 Fix debug assertion on right-click context menu. 2016-09-16 12:00:34 -04:00
Marshall Greenblatt
aab55437e2 Update to Chromium version 53.0.2785.101 2016-09-12 16:10:48 -04:00
Marshall Greenblatt
58b5209269 Fix display of select popups with OSR (issue #1988) 2016-09-09 13:23:22 -04:00
Marshall Greenblatt
dfdcf403a8 Windows: Add /LARGEADDRESSAWARE to CMake configuration (issue #1855) 2016-09-08 16:55:07 -04:00
Marshall Greenblatt
aead0852b3 List files in directories recursively (issue #1987) 2016-09-08 11:39:59 -04:00
Marshall Greenblatt
4a88e6738a Mac: Set rpath instead of using install_name_tool from CMake (issue #1403) 2016-09-02 17:15:59 +03:00
Marshall Greenblatt
c7e062b773 Update to Chromium version 53.0.2785.89 2016-09-01 20:07:03 +03:00
Marshall Greenblatt
14084aaf41 Windows: Add compiler settings to CMake for official build sandbox compatibility (issue #1961) 2016-09-01 16:36:44 +03:00
Marshall Greenblatt
d811450a32 Use DCHECK_IS_ON() instead of !NDEBUG for debug logic (issue #1961) 2016-09-01 14:48:31 +03:00
Marshall Greenblatt
71d9d35fc3 Fix decoding of about:credits HTML (issue #1980) 2016-09-01 13:19:20 +03:00
Marshall Greenblatt
3e763188b5 Mac: Fix dSYM processing and add debug dSYM in make_distrib.py (issue #1403) 2016-08-31 15:13:41 +03:00
Marshall Greenblatt
cb3e183d78 Mac: Fix dSYM path in make_distrib.py (issue #1403) 2016-08-30 18:39:31 +03:00
Marshall Greenblatt
8949b13120 Fix documentation errors 2016-08-26 13:21:40 +03:00
Marshall Greenblatt
80e473edf2 Windows: Clarify custom toolchain env variable requirements (issue #1403) 2016-08-26 12:54:17 +03:00
Marshall Greenblatt
87ce1497b9 Windows: Don't copy DLLs when using custom toolchain (issue #1403) 2016-08-25 18:33:16 +03:00
Marshall Greenblatt
e33dd88cd4 Fix typo on gn_args.py 2016-08-25 16:55:12 +03:00
Marshall Greenblatt
67bb846748 Linux: Fix copying of libcef.so in make_distrib.py (issue #1403) 2016-08-25 16:20:47 +03:00
Marshall Greenblatt
1dac96f3e2 Fix DEPOT_TOOLS_WIN_TOOLCHAIN value check (issue #1403) 2016-08-25 16:01:55 +03:00
Marshall Greenblatt
0974f72478 Add missing visual_studio_runtime_dirs value (issue #1403) 2016-08-25 15:25:27 +03:00
Marshall Greenblatt
1e15b76262 Change official debug builds to release + dcheck_always_on (issue #1961) 2016-08-25 14:39:28 +03:00
Marshall Greenblatt
9f1bd36e74 Linux: Remove deleted key from make_distrib.py (issue #1403) 2016-08-25 13:20:07 +03:00
Marshall Greenblatt
a9f5c8bfb2 Fix crash when scrolling to the bottom of an iframe with --root-layer-scrolls 2016-08-22 17:17:23 +03:00
Marshall Greenblatt
d538cf683e cefclient: Allow dragging of fragments and show message when blocking URLs/files (issue #1976) 2016-08-19 14:02:09 +02:00
Marshall Greenblatt
a99ebd38a0 Update to Chromium version 53.0.2785.70 2016-08-18 13:17:06 +02:00
Marshall Greenblatt
39b9b98b5c Windows: Resize offscreen compositor window to match view size (issue #1933) 2016-08-17 17:31:05 +02:00
Marshall Greenblatt
3bd9c18309 Linux: Flush display after showing window (issue #1946) 2016-08-17 17:00:10 +02:00
Marshall Greenblatt
e0a22fe9fa Check that platform_delegate_ is non-NULL 2016-08-15 12:31:17 +03:00
Marshall Greenblatt
cc24f60779 views: Restore hover state on menu buttons 2016-08-08 19:17:14 +03:00
Marshall Greenblatt
5edb3bf62d Fix incorrect scaling of drag regions on HiDPI display. 2016-08-08 16:17:31 +03:00
Marshall Greenblatt
e90b99171b Fix debug assertion in CefImageImpl::AddBitmap. 2016-08-08 16:17:24 +03:00
Marshall Greenblatt
4cf33c94e8 Windows: Add VS2015 Update 3 build support for GYP 2016-08-05 18:29:45 +03:00
Marshall Greenblatt
8a0e29ecf6 Update to Chromium version 53.0.2785.46 2016-08-05 17:59:24 +03:00
Marshall Greenblatt
eac4425c21 Windows: Add VS2015 Update 3 build support 2016-08-05 13:40:07 +03:00
Marshall Greenblatt
6b6edcc19c Remove variable references from cef_path2.gypi to fix VS project generation with GN (issue #1403) 2016-07-20 17:22:49 -04:00
Marshall Greenblatt
06ebf2b0a4 Generate pack header files using GN (issue #1403) 2016-07-20 17:03:20 -04:00
Marshall Greenblatt
6560d03ab0 Windows: Fix widevine copy step for binary distribution (issue #1948) 2016-07-20 14:28:01 -04:00
Marshall Greenblatt
7686007c1a Fix Widevine CDM download (issue #1950) 2016-07-15 13:40:31 -04:00
Marshall Greenblatt
da265f6a2d Update component updater configurator to match chrome (issue #1950) 2016-07-15 13:18:28 -04:00
Marshall Greenblatt
39e62853cc Move HTTP cache to a subfolder of CefSettings.cache_path (issue #1940) 2016-07-12 15:01:48 -04:00
Marshall Greenblatt
9bfcca74f2 Pass transition type to CefLoadHandler::OnLoadStart (issue #1943) 2016-07-12 12:13:29 -04:00
Marshall Greenblatt
7641240f2e Mac: Remove duplicate focus change notification 2016-07-11 17:15:46 -04:00
Marshall Greenblatt
2627733710 Update to Chromium version 53.0.2785.8 2016-07-08 17:38:36 -04:00
Marshall Greenblatt
a22b11d764 Fix crash in CefResourceDispatcherHostDelegate::HandleExternalProtocol when destroying a browser during redirect (issue #1941) 2016-07-08 15:28:53 -04:00
Marshall Greenblatt
8a5e7a1270 CefBrowserHost::Invalidate should call OnPaint unconditionally (issue #1871) 2016-07-08 11:45:47 -04:00
Marshall Greenblatt
a60bb077a3 Update to Chromium revision 68623971 (#403382) 2016-07-07 16:24:12 -04:00
Marshall Greenblatt
d0a2e217a0 Add GN configuration (issue #1403) 2016-07-05 17:32:01 -04:00
Marshall Greenblatt
05ee60b7b4 Update to Chromium revision 318e6f54 (#400326) 2016-06-21 12:41:21 -04:00
Marshall Greenblatt
66425def4a Fix crash in CefTaskRunnerImpl::GetTaskRunner when CEF is not initialized (issue #1925) 2016-06-15 14:11:30 -04:00
Marshall Greenblatt
262e327c74 Mac: Fix file dialog behavior (issue #1919) 2016-06-15 13:43:58 -04:00
Marshall Greenblatt
f5b910326d Improve binary distribution CMake macros (issue #1923) 2016-06-14 18:29:34 -04:00
Marshall Greenblatt
eb199b2547 README.md edited online with Bitbucket 2016-06-14 18:53:35 +00:00
Marshall Greenblatt
80f5a35668 Linux: Don't add version script in Debug build (issue #1765) 2016-06-14 13:46:49 -04:00
Marshall Greenblatt
18d882b5d2 cefclient: Don't create multiple DevTools windows (issue #1920) 2016-06-10 14:33:07 -04:00
Marshall Greenblatt
b23c0f1097 ShowDevTools should inspect element in existing window (issue #1487) 2016-06-10 12:59:32 -04:00
Marshall Greenblatt
acdb4bb564 Mac: Fix window sharing type (issue #1884) 2016-06-09 14:48:59 -04:00
Marshall Greenblatt
e41a763307 Linux: Don't add version script when using ASAN build (issue #1765) 2016-06-07 12:03:13 -07:00
Marshall Greenblatt
a356ee9ca1 Add Google SafeSearch support (issue #1917) 2016-06-07 14:44:59 -04:00
Marshall Greenblatt
fe9c24e307 Linux: Include cefsimple instead of cefclient in client distribution (issue #1916) 2016-06-07 11:27:40 -04:00
Marshall Greenblatt
76a40cafe3 Linux: Include cefsimple instead of cefclient in client distribution (issue #1916) 2016-06-06 18:23:15 -04:00
Marshall Greenblatt
754638846e cefbuilds: Linux: Include cefsimple instead of cefclient in client distribution (issue #1916).
cefbuilds: Fix CEF source URL.
2016-06-06 18:03:17 -04:00
Marshall Greenblatt
733ff6ffff Windows: Remove wow_helper.exe which is no longer required (issue #1915) 2016-06-06 12:47:59 -04:00
Marshall Greenblatt
f1fec0933e Linux: Add version script to restrict exported symbols (issue #1765) 2016-06-06 12:31:24 -04:00
Marshall Greenblatt
e0fd09ed20 Linux: Fix warn_unused_result error (issue #1911) 2016-06-03 11:33:06 -04:00
Marshall Greenblatt
99bf1b8458 Windows: Set CEF_VCVARS=none when using a custom VS install location 2016-05-28 22:00:28 -04:00
469 changed files with 6721 additions and 2117 deletions

2101
BUILD.gn Normal file

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -10,7 +10,7 @@ The Chromium Embedded Framework (CEF) is a simple framework for embedding Chromi
* Support Forum - http://www.magpcss.org/ceforum/
* CEF1 C++ API Docs - http://magpcss.org/ceforum/apidocs/
* CEF3 C++ API Docs - http://magpcss.org/ceforum/apidocs3/
* Downloads - http://www.magpcss.net/cef_downloads/ and http://cefbuilds.com (automated nightly builds)
* Downloads - http://www.magpcss.net/cef_downloads/ and http://cefbuilds.com
* Donations - http://www.magpcss.org/ceforum/donate.php
# Introduction
@@ -24,15 +24,15 @@ CEF is a BSD-licensed open source project founded by Marshall Greenblatt in 2008
CEF supports a wide range of programming languages and operating systems and can be easily integrated into both new and existing applications. It was designed from the ground up with both performance and ease of use in mind. The base framework includes C and C++ programming interfaces exposed via native libraries that insulate the host application from Chromium and Blink implementation details. It provides close integration between the browser and the host application including support for custom plugins, protocols, JavaScript objects and JavaScript extensions. The host application can optionally control resource loading, navigation, context menus, printing and more, while taking advantage of the same performance and HTML5 technologies available in the Google Chrome Web browser.
Users new to CEF development should start by reading the [Tutorial](https://bitbucket.org/chromiumembedded/cef/wiki/Tutorial) Wiki page for an overview of CEF usage and then proceed to the [GeneralUsage](https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage) Wiki page for a more in-depth discussion or architectural and usage issues. Complete API documentation is available [here](http://magpcss.org/ceforum/apidocs3/). CEF support and related discussion is available on the [CEF Forum](http://www.magpcss.org/ceforum/).
Numerous individuals and organizations contribute time and resources to support CEF development, but more involvement from the community is always welcome. This includes support for both the core CEF project and external projects that integrate CEF with additional programming languages and frameworks (see the "External Projects" section below). If you are interested in donating time to help with CEF development please see the "Helping Out" section below. If you are interested in donating money to support general CEF development and infrastructure efforts please visit the [CEF Donations](http://www.magpcss.org/ceforum/donate.php) page.
# Getting Started
Users new to CEF development should start by reading the [Tutorial](https://bitbucket.org/chromiumembedded/cef/wiki/Tutorial) Wiki page for an overview of CEF usage and then proceed to the [GeneralUsage](https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage) Wiki page for a more in-depth discussion or architectural and usage issues. Complete API documentation is available [here](http://magpcss.org/ceforum/apidocs3/). CEF support and related discussion is available on the [CEF Forum](http://www.magpcss.org/ceforum/).
# Binary Distributions
Binary distributions, which include all files necessary to build a CEF-based application, are available on the [Downloads](http://www.magpcss.net/cef_downloads/) page. Automated nightly builds, available from http://cefbuilds.com, include the newest changes but may not be fully tested. Binary distributions are stand-alone and do not require the download of CEF or Chromium source code. Symbol files for debugging binary distributions of libcef can also be downloaded from the above links.
Release notes for past and current CEF binary distributions are available [here](https://bitbucket.org/chromiumembedded/cef/wiki/ReleaseNotes).
Binary distributions, which include all files necessary to build a CEF-based application, are available on the [Downloads](http://www.magpcss.net/cef_downloads/) page and http://cefbuilds.com. Binary distributions are stand-alone and do not require the download of CEF or Chromium source code. Symbol files for debugging binary distributions of libcef can also be downloaded from the above links.
# Source Distributions

72
cef.gyp
View File

@@ -18,6 +18,7 @@
},
'includes': [
# Bring in the source file lists.
'cef_paths.gypi',
'cef_paths2.gypi',
],
'targets': [
@@ -37,10 +38,12 @@
],
'sources': [
'<@(includes_common)',
'<@(autogen_cpp_includes)',
'<@(includes_wrapper)',
],
'mac_bundle_resources': [
'<@(cefclient_bundle_resources_mac)',
'<@(cefclient_sources_resources)',
],
'mac_bundle_resources!': [
# TODO(mark): Come up with a fancier way to do this (mac_info_plist?)
@@ -97,6 +100,10 @@
'sources': [
'<@(includes_win)',
'<@(cefclient_sources_win)',
'<@(cefclient_sources_browser)',
'<@(cefclient_sources_common)',
'<@(cefclient_sources_renderer)',
'<@(cefclient_sources_resources)',
],
}],
[ 'OS=="mac"', {
@@ -162,6 +169,8 @@
'sources': [
'<@(includes_mac)',
'<@(cefclient_sources_mac)',
'<@(cefclient_sources_browser)',
'<@(cefclient_sources_common)',
],
}],
[ '(OS=="linux" or OS=="freebsd" or OS=="openbsd") and use_sysroot==0', {
@@ -181,12 +190,15 @@
'sources': [
'<@(includes_linux)',
'<@(cefclient_sources_linux)',
'<@(cefclient_sources_browser)',
'<@(cefclient_sources_common)',
'<@(cefclient_sources_renderer)',
],
'copies': [
{
'destination': '<(PRODUCT_DIR)/files',
'files': [
'<@(cefclient_bundle_resources_linux)',
'<@(cefclient_sources_resources)',
],
},
],
@@ -209,6 +221,7 @@
],
'sources': [
'<@(includes_common)',
'<@(autogen_cpp_includes)',
'<@(includes_wrapper)',
'<@(cefsimple_sources_common)',
],
@@ -469,6 +482,8 @@
'.',
# Necessary to allow unittest files to access cefclient files.
'tests',
# For generated include headers.
'<(PRODUCT_DIR)/includes',
],
'conditions': [
[ 'OS=="win"', {
@@ -618,10 +633,13 @@
],
'sources': [
'<@(includes_common)',
'<@(autogen_cpp_includes)',
'<@(includes_capi)',
'<@(autogen_capi_includes)',
'<@(includes_wrapper)',
'<@(libcef_dll_wrapper_sources_base)',
'<@(libcef_dll_wrapper_sources_common)',
'<@(autogen_client_side)',
],
'conditions': [
[ 'OS=="mac"', {
@@ -658,9 +676,12 @@
],
'sources': [
'<@(includes_common)',
'<@(autogen_cpp_includes)',
'<@(includes_capi)',
'<@(autogen_capi_includes)',
'<@(includes_wrapper)',
'<@(libcef_dll_wrapper_sources_common)',
'<@(autogen_client_side)',
],
'conditions': [
[ 'OS=="mac"', {
@@ -885,7 +906,7 @@
'<@(header_inputs)',
],
'outputs': [
'include/cef_pack_resources.h',
'<(PRODUCT_DIR)/includes/include/cef_pack_resources.h',
],
'action': ['python', '<(make_pack_header_path)', '<@(_outputs)',
'<@(header_inputs)'],
@@ -907,7 +928,7 @@
'<@(header_inputs)',
],
'outputs': [
'include/cef_pack_strings.h',
'<(PRODUCT_DIR)/includes/include/cef_pack_strings.h',
],
'action': ['python', '<(make_pack_header_path)', '<@(_outputs)',
'<@(header_inputs)'],
@@ -940,9 +961,6 @@
'<(DEPTH)/cef/libcef/resources/grit_stub/chrome',
'<(grit_out_dir)',
'<(SHARED_INTERMEDIATE_DIR)/chrome',
'<(SHARED_INTERMEDIATE_DIR)/components',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources',
'<(SHARED_INTERMEDIATE_DIR)/ui/strings',
],
'dependencies': [
'<(DEPTH)/base/base.gyp:base',
@@ -960,7 +978,6 @@
# chrome/common/chrome_contants.cc
'<(DEPTH)/chrome/common_constants.gyp:version_header',
'<(DEPTH)/components/components.gyp:cdm_renderer',
'<(DEPTH)/components/components.gyp:component_updater',
'<(DEPTH)/components/components.gyp:content_settings_core_browser',
'<(DEPTH)/components/components.gyp:content_settings_core_common',
'<(DEPTH)/components/components.gyp:crash_component_breakpad_to_be_deleted',
@@ -968,9 +985,11 @@
'<(DEPTH)/components/components.gyp:data_use_measurement_core',
'<(DEPTH)/components/components.gyp:devtools_discovery',
'<(DEPTH)/components/components.gyp:devtools_http_handler',
'<(DEPTH)/components/components.gyp:google_core_browser',
'<(DEPTH)/components/components.gyp:keyed_service_content',
'<(DEPTH)/components/components.gyp:keyed_service_core',
'<(DEPTH)/components/components.gyp:navigation_interception',
'<(DEPTH)/components/components.gyp:network_session_configurator_switches',
'<(DEPTH)/components/components.gyp:pdf_browser',
'<(DEPTH)/components/components.gyp:pdf_renderer',
'<(DEPTH)/components/components.gyp:plugins_renderer',
@@ -1017,7 +1036,8 @@
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/storage/storage_browser.gyp:storage',
'<(DEPTH)/sync/sync.gyp:sync',
'<(DEPTH)/third_party/cld_2/cld_2.gyp:cld2_platform_impl',
'<(DEPTH)/third_party/brotli/brotli.gyp:brotli',
'<(DEPTH)/third_party/cld_2/cld_2.gyp:cld_2',
'<(DEPTH)/third_party/hunspell/hunspell.gyp:hunspell',
'<(DEPTH)/third_party/libxml/libxml.gyp:libxml',
'<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
@@ -1037,6 +1057,7 @@
],
'sources': [
'<@(includes_common)',
'<@(autogen_cpp_includes)',
'libcef/browser/browser_context.cc',
'libcef/browser/browser_context.h',
'libcef/browser/browser_context_impl.cc',
@@ -1066,8 +1087,6 @@
'libcef/browser/chrome_browser_process_stub.h',
'libcef/browser/chrome_profile_stub.cc',
'libcef/browser/chrome_profile_stub.h',
'libcef/browser/component_updater/cef_component_updater_configurator.cc',
'libcef/browser/component_updater/cef_component_updater_configurator.h',
'libcef/browser/content_browser_client.cc',
'libcef/browser/content_browser_client.h',
'libcef/browser/context.cc',
@@ -1301,6 +1320,8 @@
'libcef/common/value_base.h',
'libcef/common/values_impl.cc',
'libcef/common/values_impl.h',
'libcef/common/widevine_loader.cc',
'libcef/common/widevine_loader.h',
'libcef/renderer/browser_impl.cc',
'libcef/renderer/browser_impl.h',
'libcef/renderer/content_renderer_client.cc',
@@ -1461,9 +1482,6 @@
'<(DEPTH)/extensions/shell/browser/shell_display_info_provider.h',
'<(DEPTH)/extensions/shell/browser/shell_web_contents_modal_dialog_manager.cc',
'<(grit_out_dir)/grit/component_extension_resources_map.cc',
# Include sources for component-updater support.
'<(DEPTH)/chrome/browser/component_updater/widevine_cdm_component_installer.cc',
'<(DEPTH)/chrome/browser/component_updater/widevine_cdm_component_installer.h',
# Include sources for widevine support.
'<(DEPTH)/chrome/common/widevine_cdm_constants.cc',
'<(DEPTH)/chrome/common/widevine_cdm_constants.h',
@@ -1505,6 +1523,9 @@
# Include sources for permissions support.
'<(DEPTH)/chrome/browser/permissions/permission_request_id.h',
'<(DEPTH)/chrome/browser/permissions/permission_request_id.cc',
# Include sources for SafeSearch support.
'<(DEPTH)/chrome/browser/net/safe_search_util.cc',
'<(DEPTH)/chrome/browser/net/safe_search_util.h',
],
'conditions': [
['OS=="win"', {
@@ -1748,8 +1769,11 @@
],
'sources': [
'<@(includes_common)',
'<@(autogen_cpp_includes)',
'<@(includes_capi)',
'<@(autogen_capi_includes)',
'<@(libcef_sources_common)',
'<@(autogen_library_side)',
],
'postbuilds': [
{
@@ -1795,7 +1819,7 @@
'.',
# cefclient includes are relative to the tests directory to make
# creation of binary releases easier.
'tests'
'tests',
],
'link_settings': {
'libraries': [
@@ -1804,6 +1828,8 @@
},
'sources': [
'<@(cefclient_sources_mac_helper)',
'<@(cefclient_sources_common)',
'<@(cefclient_sources_renderer)',
],
# TODO(mark): Come up with a fancier way to do this. It should only
# be necessary to list helper-Info.plist once, not the three times it
@@ -1944,6 +1970,8 @@
'.',
# Necessary to allow unittest files to access cefclient files.
'tests',
# For generated include headers.
'<(PRODUCT_DIR)/includes',
],
'sources': [
'tests/cefclient/browser/resource_util.cc',
@@ -2052,8 +2080,11 @@
],
'sources': [
'<@(includes_common)',
'<@(autogen_cpp_includes)',
'<@(includes_capi)',
'<@(autogen_capi_includes)',
'<@(libcef_sources_common)',
'<@(autogen_library_side)',
],
'conditions': [
['OS=="win"', {
@@ -2090,6 +2121,19 @@
},
},
}],
[ '(OS=="linux" or OS=="freebsd" or OS=="openbsd") and asan==0 and use_allocator=="none"', {
'link_settings': {
'configurations': {
'Release': {
'ldflags': [
# Only export necessary symbols from libcef.so.
# Don't do this in Debug builds because it causes the resulting application to crash.
'-Wl,--version-script=<!(cd <(DEPTH) && pwd -P)/cef/libcef_dll/libcef.lst',
],
},
},
},
}],
],
}],
}], # OS!="mac"

View File

@@ -314,6 +314,8 @@
'libcef_dll/cpptoc/process_message_cpptoc.h',
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
'libcef_dll/ctocpp/read_handler_ctocpp.h',
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.cc',
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.h',
'libcef_dll/ctocpp/render_handler_ctocpp.cc',
'libcef_dll/ctocpp/render_handler_ctocpp.h',
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
@@ -562,6 +564,8 @@
'libcef_dll/ctocpp/process_message_ctocpp.h',
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
'libcef_dll/cpptoc/read_handler_cpptoc.h',
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.cc',
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.h',
'libcef_dll/cpptoc/render_handler_cpptoc.cc',
'libcef_dll/cpptoc/render_handler_cpptoc.h',
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',

View File

@@ -3,10 +3,6 @@
# can be found in the LICENSE file.
{
'includes': [
# Bring in the autogenerated source file lists.
'cef_paths.gypi',
],
'variables': {
'includes_common': [
'include/base/cef_atomic_ref_count.h',
@@ -40,8 +36,6 @@
'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h',
'include/base/internal/cef_thread_checker_impl.h',
'include/cef_base.h',
'include/cef_pack_resources.h',
'include/cef_pack_strings.h',
'include/cef_version.h',
'include/internal/cef_export.h',
'include/internal/cef_logging_internal.h',
@@ -57,11 +51,9 @@
'include/internal/cef_trace_event_internal.h',
'include/internal/cef_types.h',
'include/internal/cef_types_wrappers.h',
'<@(autogen_cpp_includes)',
],
'includes_capi': [
'include/capi/cef_base_capi.h',
'<@(autogen_capi_includes)',
],
'includes_wrapper': [
'include/wrapper/cef_byte_read_handler.h',
@@ -104,7 +96,6 @@
'libcef_dll/transfer_util.cc',
'libcef_dll/transfer_util.h',
'libcef_dll/wrapper_types.h',
'<@(autogen_library_side)',
],
'libcef_dll_wrapper_sources_base': [
'libcef_dll/base/cef_atomicops_x86_gcc.cc',
@@ -138,7 +129,6 @@
'libcef_dll/wrapper/cef_zip_archive.cc',
'libcef_dll/wrapper/libcef_dll_wrapper.cc',
'libcef_dll/wrapper/libcef_dll_wrapper2.cc',
'<@(autogen_client_side)',
],
'cefclient_sources_browser': [
'tests/cefclient/browser/binding_test.cc',
@@ -159,6 +149,8 @@
'tests/cefclient/browser/client_types.h',
'tests/cefclient/browser/dialog_test.cc',
'tests/cefclient/browser/dialog_test.h',
'tests/cefclient/browser/drm_test.cc',
'tests/cefclient/browser/drm_test.h',
'tests/cefclient/browser/geometry_util.cc',
'tests/cefclient/browser/geometry_util.h',
'tests/cefclient/browser/main_context.cc',
@@ -224,6 +216,7 @@
'tests/cefclient/resources/binding.html',
'tests/cefclient/resources/dialogs.html',
'tests/cefclient/resources/draggable.html',
'tests/cefclient/resources/drm.html',
'tests/cefclient/resources/localstorage.html',
'tests/cefclient/resources/logo.png',
'tests/cefclient/resources/menu_icon.1x.png',
@@ -276,10 +269,6 @@
'tests/cefclient/resources/win/cefclient.ico',
'tests/cefclient/resources/win/cefclient.rc',
'tests/cefclient/resources/win/small.ico',
'<@(cefclient_sources_browser)',
'<@(cefclient_sources_common)',
'<@(cefclient_sources_renderer)',
'<@(cefclient_sources_resources)',
],
'cefclient_sources_mac': [
'tests/cefclient/browser/browser_window_osr_mac.h',
@@ -297,20 +286,15 @@
'tests/cefclient/browser/window_test_runner_mac.h',
'tests/cefclient/browser/window_test_runner_mac.mm',
'tests/cefclient/cefclient_mac.mm',
'<@(cefclient_sources_browser)',
'<@(cefclient_sources_common)',
],
'cefclient_sources_mac_helper': [
'tests/cefclient/process_helper_mac.cc',
'<@(cefclient_sources_common)',
'<@(cefclient_sources_renderer)',
],
'cefclient_bundle_resources_mac': [
'tests/cefclient/resources/mac/cefclient.icns',
'tests/cefclient/resources/mac/English.lproj/InfoPlist.strings',
'tests/cefclient/resources/mac/English.lproj/MainMenu.xib',
'tests/cefclient/resources/mac/Info.plist',
'<@(cefclient_sources_resources)',
],
'cefclient_sources_linux': [
'tests/cefclient/browser/browser_window_osr_gtk.cc',
@@ -338,12 +322,6 @@
'tests/cefclient/browser/window_test_runner_views.cc',
'tests/cefclient/browser/window_test_runner_views.h',
'tests/cefclient/cefclient_gtk.cc',
'<@(cefclient_sources_browser)',
'<@(cefclient_sources_common)',
'<@(cefclient_sources_renderer)',
],
'cefclient_bundle_resources_linux': [
'<@(cefclient_sources_resources)',
],
'cefsimple_sources_common': [
'tests/cefsimple/simple_app.cc',

123
cef_repack_locales.gni Normal file
View File

@@ -0,0 +1,123 @@
# Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
# 2014 the Chromium Authors. All rights reserved. Use of this source code is
# governed by a BSD-style license that can be found in the LICENSE file.
#
# This is a copy of src/chrome/chrome_repack_locales.gni with the necessary
# modifications to meet CEF's requirements.
import("//build/config/chrome_build.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//tools/grit/repack.gni")
# Arguments:
#
# locale
# Internal name of locale. e.g. "pt-BR"
#
# output
# Output file name.
#
# visibility
# Normal meaning.
template("_repack_one_locale") {
locale = invoker.locale
repack(target_name) {
visibility = invoker.visibility
# Each input pak file should also have a deps line for completeness.
sources = [
"${root_gen_dir}/cef/cef_strings_${locale}.pak",
"${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak",
"${root_gen_dir}/components/strings/components_locale_settings_${locale}.pak",
"${root_gen_dir}/components/strings/components_strings_${locale}.pak",
"${root_gen_dir}/content/app/strings/content_strings_${locale}.pak",
"${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak",
"${root_gen_dir}/ui/strings/app_locale_settings_${locale}.pak",
"${root_gen_dir}/ui/strings/ui_strings_${locale}.pak",
]
# Use public_deps so that generated grit headers are discoverable from
# the libcef_static target. Grit deps that generate .cc files must be
# listed both here and in the libcef_static target.
public_deps = [
":cef_strings",
"//chrome/app/resources:platform_locale_settings",
"//components/strings:components_locale_settings",
"//components/strings:components_strings",
"//content/app/strings",
"//extensions/strings",
"//ui/strings:app_locale_settings",
"//ui/strings:ui_strings",
]
output = invoker.output
}
}
# Creates an action to call the repack_locales script.
#
# The GYP version generates the locales in the "gen" directory and then copies
# it to the root build directory. This isn't easy to express in a GN copy
# rule since the files on Mac have a complex structure. So we generate the
# files into the final place and skip the "gen" directory.
#
# This template uses GN's looping constructs to avoid the complex call to
# chrome/tools/build/repack_locales.py which wraps the repack commands in the
# GYP build.
#
# Arguments
#
# input_locales
# List of locale names to use as inputs.
#
# output_locales
# A list containing the corresponding output names for each of the
# input names. Mac uses different names in some cases.
#
# visibility
template("cef_repack_locales") {
# This is the name of the group below that will collect all the invidual
# locale targets. External targets will depend on this.
group_target_name = target_name
# GN's subscript is too stupid to do invoker.output_locales[foo] so we need
# to make a copy and do output_locales[foo].
output_locales = invoker.output_locales
# Collects all targets the loop generates.
locale_targets = []
# This loop iterates over the input locales and also keeps a counter so it
# can simultaneously iterate over the output locales (using GN's very
# limited looping capabilities).
current_index = 0
foreach(input_locale, invoker.input_locales) {
output_locale = output_locales[current_index]
# Compute the name of the target for the current file. Save it for the deps.
current_name = "${target_name}_${input_locale}"
locale_targets += [ ":$current_name" ]
_repack_one_locale(current_name) {
visibility = [ ":$group_target_name" ]
locale = input_locale
# Compute the output name. Mac uses a different location.
if (is_mac || is_ios) {
output = "${root_gen_dir}/repack/locales/${output_locale}.pak"
} else {
output = "${root_out_dir}/locales/${output_locale}.pak"
}
}
current_index = current_index + 1
}
# The group that external targets depend on which collects all deps.
group(group_target_name) {
forward_variables_from(invoker, [ "visibility" ])
public_deps = locale_targets
}
}

View File

@@ -81,11 +81,15 @@ endmacro()
# Determine the target output directory based on platform and generator.
macro(SET_CEF_TARGET_OUT_DIR)
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
# Ninja does not create a subdirectory named after the configuration.
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
elseif(OS_LINUX)
if(${CMAKE_GENERATOR} STREQUAL "Ninja" OR
${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
# By default Ninja and Make builds don't create a subdirectory named after
# the configuration.
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
# Output binaries (executables, libraries) to the correct directory.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR})
else()
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>")
endif()
@@ -181,26 +185,20 @@ endif(OS_LINUX)
if(OS_MACOSX)
# Fix the framework link in the helper executable.
macro(FIX_MACOSX_HELPER_FRAMEWORK_LINK target app_path)
add_custom_command(TARGET ${target}
POST_BUILD
COMMAND install_name_tool -change "@executable_path/Chromium Embedded Framework"
"@executable_path/../../../../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework"
"${app_path}/Contents/MacOS/${target}"
VERBATIM
)
# Fix the framework rpath in the helper executable.
macro(FIX_MACOSX_HELPER_FRAMEWORK_RPATH target)
# The helper is in $app_name.app/Contents/Frameworks/$app_name Helper.app/Contents/MacOS/
# so set rpath up to Contents/ so that the loader can find Frameworks/.
set_target_properties(${target} PROPERTIES INSTALL_RPATH "@executable_path/../../../..")
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
endmacro()
# Fix the framework link in the main executable.
macro(FIX_MACOSX_MAIN_FRAMEWORK_LINK target app_path)
add_custom_command(TARGET ${target}
POST_BUILD
COMMAND install_name_tool -change "@executable_path/Chromium Embedded Framework"
"@executable_path/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework"
"${app_path}/Contents/MacOS/${target}"
VERBATIM
)
# Fix the framework rpath in the main executable.
macro(FIX_MACOSX_MAIN_FRAMEWORK_RPATH target)
# The main app is at $app_name.app/Contents/MacOS/$app_name
# so set rpath up to Contents/ so that the loader can find Frameworks/.
set_target_properties(${target} PROPERTIES INSTALL_RPATH "@executable_path/..")
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
endmacro()
# Manually process and copy over resource files.
@@ -256,13 +254,13 @@ endif(OS_MACOSX)
if(OS_WINDOWS)
# Add custom manifest files to an executable target.
macro(ADD_WINDOWS_MANIFEST manifest_path target)
macro(ADD_WINDOWS_MANIFEST manifest_path target extension)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND "mt.exe" -nologo
-manifest \"${manifest_path}/${target}.exe.manifest\" \"${manifest_path}/compatibility.manifest\"
-outputresource:"${CEF_TARGET_OUT_DIR}/${target}.exe"\;\#1
-manifest \"${manifest_path}/${target}.${extension}.manifest\" \"${manifest_path}/compatibility.manifest\"
-outputresource:"${CEF_TARGET_OUT_DIR}/${target}.${extension}"\;\#1
COMMENT "Adding manifest..."
)
endmacro()

View File

@@ -305,6 +305,24 @@ endif()
#
if(OS_WINDOWS)
# Configure use of the sandbox.
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
if(USE_SANDBOX AND NOT MSVC_VERSION EQUAL 1900)
# The cef_sandbox.lib static library is currently built with VS2015. It will
# not link successfully with other VS versions.
set(USE_SANDBOX OFF)
endif()
# Configure use of official build compiler settings.
# When using an official build the "Debug" build is actually a Release build
# with DCHECKs enabled. In order to link the sandbox the Debug build must
# be configured with some Release-related compiler settings.
option(USE_OFFICIAL_BUILD_SANDBOX "Enable or disable use of an official build sandbox." ON)
if(NOT USE_SANDBOX)
# Don't need official build settings when the sandbox is off.
set(USE_OFFICIAL_BUILD_SANDBOX OFF)
endif()
# Consumers who run into LNK4099 warnings can pass /Z7 instead (see issue #385).
set(CEF_DEBUG_INFO_FLAG "/Zi" CACHE STRING "Optional flag specifying specific /Z flag to use")
@@ -326,11 +344,22 @@ if(OS_WINDOWS)
/wd4996 # Ignore "function or variable may be unsafe" warning
${CEF_DEBUG_INFO_FLAG}
)
list(APPEND CEF_COMPILER_FLAGS_DEBUG
/MTd # Multithreaded debug runtime
/RTC1 # Disable optimizations
/Od # Enable basic run-time checks
)
if(USE_OFFICIAL_BUILD_SANDBOX)
# CMake adds /RTC1, /D"_DEBUG" and a few other values by default for Debug
# builds. We can't link the sandbox with those values so clear the CMake
# defaults here.
set(CMAKE_CXX_FLAGS_DEBUG "")
list(APPEND CEF_COMPILER_FLAGS_DEBUG
/MT # Multithreaded release runtime
)
else()
list(APPEND CEF_COMPILER_FLAGS_DEBUG
/MTd # Multithreaded debug runtime
/RTC1 # Disable optimizations
/Od # Enable basic run-time checks
)
endif()
list(APPEND CEF_COMPILER_FLAGS_RELEASE
/MT # Multithreaded release runtime
/O2 # Optimize for maximum speed
@@ -341,7 +370,8 @@ if(OS_WINDOWS)
/DEBUG # Generate debug information
)
list(APPEND CEF_EXE_LINKER_FLAGS
/MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage)
/MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage)
/LARGEADDRESSAWARE # Allow 32-bit processes to access 3GB of RAM
)
list(APPEND CEF_COMPILER_DEFINES
WIN32 _WIN32 _WINDOWS # Windows platform
@@ -351,6 +381,12 @@ if(OS_WINDOWS)
WIN32_LEAN_AND_MEAN # Exclude less common API declarations
_HAS_EXCEPTIONS=0 # Disable exceptions
)
if(USE_OFFICIAL_BUILD_SANDBOX)
list(APPEND CEF_COMPILER_DEFINES_DEBUG
NDEBUG _NDEBUG # Not a debug build
DCHECK_ALWAYS_ON=1 # DCHECKs are enabled
)
endif()
list(APPEND CEF_COMPILER_DEFINES_RELEASE
NDEBUG _NDEBUG # Not a debug build
)
@@ -383,12 +419,6 @@ if(OS_WINDOWS)
natives_blob.bin
snapshot_blob.bin
)
if(PROJECT_ARCH STREQUAL "x86")
# Only used on 32-bit platforms.
list(APPEND CEF_BINARY_FILES
wow_helper.exe
)
endif()
# List of CEF resource files.
set(CEF_RESOURCE_FILES
@@ -401,14 +431,6 @@ if(OS_WINDOWS)
locales
)
# Configure use of the sandbox.
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
if(USE_SANDBOX AND NOT MSVC_VERSION EQUAL 1900)
# The cef_sandbox.lib static library is currently built with VS2015. It will
# not link successfully with other VS versions.
set(USE_SANDBOX OFF)
endif()
if(USE_SANDBOX)
list(APPEND CEF_COMPILER_DEFINES
PSAPI_VERSION=1 # Required by cef_sandbox.lib

View File

@@ -45,6 +45,7 @@
// If the Chromium implementation diverges the below implementation should be
// updated to match.
#include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
#include "include/base/cef_platform_thread.h"
#include "include/base/internal/cef_lock_impl.h"
@@ -57,7 +58,7 @@ namespace cef_internal {
// AssertAcquired() method.
class Lock {
public:
#if defined(NDEBUG) // Optimized wrapper implementation
#if !DCHECK_IS_ON() // Optimized wrapper implementation
Lock() : lock_() {}
~Lock() {}
void Acquire() { lock_.Lock(); }
@@ -96,10 +97,10 @@ class Lock {
}
void AssertAcquired() const;
#endif // NDEBUG
#endif // !DCHECK_IS_ON()
private:
#if !defined(NDEBUG)
#if DCHECK_IS_ON()
// Members and routines taking care of locks assertions.
// Note that this checks for recursive locks and allows them
// if the variable is set. This is allowed by the underlying implementation
@@ -111,7 +112,7 @@ class Lock {
// All private data is implicitly protected by lock_.
// Be VERY careful to only access members under that lock.
base::PlatformThreadRef owning_thread_ref_;
#endif // NDEBUG
#endif // DCHECK_IS_ON()
// Platform specific underlying lock implementation.
LockImpl lock_;

View File

@@ -50,9 +50,7 @@
#include "include/base/cef_atomic_ref_count.h"
#include "include/base/cef_build.h"
#ifndef NDEBUG
#include "include/base/cef_logging.h"
#endif
#include "include/base/cef_thread_collision_warner.h"
namespace base {
@@ -66,14 +64,14 @@ class RefCountedBase {
protected:
RefCountedBase()
: ref_count_(0)
#ifndef NDEBUG
#if DCHECK_IS_ON()
, in_dtor_(false)
#endif
{
}
~RefCountedBase() {
#ifndef NDEBUG
#if DCHECK_IS_ON()
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
#endif
}
@@ -84,7 +82,7 @@ class RefCountedBase {
// Current thread books the critical section "AddRelease"
// without release it.
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
#ifndef NDEBUG
#if DCHECK_IS_ON()
DCHECK(!in_dtor_);
#endif
++ref_count_;
@@ -96,11 +94,11 @@ class RefCountedBase {
// Current thread books the critical section "AddRelease"
// without release it.
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
#ifndef NDEBUG
#if DCHECK_IS_ON()
DCHECK(!in_dtor_);
#endif
if (--ref_count_ == 0) {
#ifndef NDEBUG
#if DCHECK_IS_ON()
in_dtor_ = true;
#endif
return true;
@@ -110,7 +108,7 @@ class RefCountedBase {
private:
mutable int ref_count_;
#ifndef NDEBUG
#if DCHECK_IS_ON()
mutable bool in_dtor_;
#endif
@@ -134,7 +132,7 @@ class RefCountedThreadSafeBase {
private:
mutable AtomicRefCount ref_count_;
#ifndef NDEBUG
#if DCHECK_IS_ON()
mutable bool in_dtor_;
#endif

View File

@@ -50,6 +50,7 @@
#include "include/base/cef_atomicops.h"
#include "include/base/cef_basictypes.h"
#include "include/base/cef_build.h"
#include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
// A helper class alongside macros to be used to verify assumptions about thread
@@ -139,7 +140,7 @@
// };
#if !defined(NDEBUG)
#if DCHECK_IS_ON()
// Defines a class member that acts like a mutex. It is used only as a
// verification tool.

View File

@@ -448,10 +448,13 @@ typedef struct _cef_browser_host_t {
int clearSelection);
///
// Open developer tools in its own window. If |inspect_element_at| is non-
// NULL the element at the specified (x,y) location will be inspected. The
// |windowInfo| parameter will be ignored if this browser is wrapped in a
// cef_browser_view_t.
// Open developer tools (DevTools) in its own browser. The DevTools browser
// will remain associated with this browser. If the DevTools browser is
// already open then it will be focused, in which case the |windowInfo|,
// |client| and |settings| parameters will be ignored. If |inspect_element_at|
// is non-NULL then the element at the specified (x,y) location will be
// inspected. The |windowInfo| parameter will be ignored if this browser is
// wrapped in a cef_browser_view_t.
///
void (CEF_CALLBACK *show_dev_tools)(struct _cef_browser_host_t* self,
const struct _cef_window_info_t* windowInfo,
@@ -460,11 +463,16 @@ typedef struct _cef_browser_host_t {
const cef_point_t* inspect_element_at);
///
// Explicitly close the developer tools window if one exists for this browser
// instance.
// Explicitly close the associated DevTools browser, if any.
///
void (CEF_CALLBACK *close_dev_tools)(struct _cef_browser_host_t* self);
///
// Returns true (1) if this browser currently has an associated DevTools
// browser. Must be called on the browser process UI thread.
///
int (CEF_CALLBACK *has_dev_tools)(struct _cef_browser_host_t* self);
///
// Retrieve a snapshot of current navigation entries as values sent to the
// specified visitor. If |current_only| is true (1) only the current

View File

@@ -72,14 +72,17 @@ typedef struct _cef_load_handler_t {
///
// Called when the browser begins loading a frame. The |frame| value will
// never be NULL -- call the is_main() function to check if this frame is the
// main frame. Multiple frames may be loading at the same time. Sub-frames may
// start or continue loading after the main frame load has ended. This
// function will always be called for all frames irrespective of whether the
// request completes successfully. For notification of overall browser load
// status use OnLoadingStateChange instead.
// main frame. |transition_type| provides information about the source of the
// navigation and an accurate value is only available in the browser process.
// Multiple frames may be loading at the same time. Sub-frames may start or
// continue loading after the main frame load has ended. This function will
// always be called for all frames irrespective of whether the request
// completes successfully. For notification of overall browser load status use
// OnLoadingStateChange instead.
///
void (CEF_CALLBACK *on_load_start)(struct _cef_load_handler_t* self,
struct _cef_browser_t* browser, struct _cef_frame_t* frame);
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
cef_transition_type_t transition_type);
///
// Called when the browser is done loading a frame. The |frame| value will

View File

@@ -279,7 +279,7 @@ CEF_EXPORT cef_request_context_t* cef_request_context_create_context(
// Creates a new context object that shares storage with |other| and uses an
// optional |handler|.
///
CEF_EXPORT cef_request_context_t* create_context_shared(
CEF_EXPORT cef_request_context_t* cef_create_context_shared(
cef_request_context_t* other,
struct _cef_request_context_handler_t* handler);

View File

@@ -127,6 +127,29 @@ typedef struct _cef_web_plugin_unstable_callback_t {
} cef_web_plugin_unstable_callback_t;
///
// Implement this structure to receive notification when CDM registration is
// complete. The functions of this structure will be called on the browser
// process UI thread.
///
typedef struct _cef_register_cdm_callback_t {
///
// Base structure.
///
cef_base_t base;
///
// Method that will be called when CDM registration is complete. |result| will
// be CEF_CDM_REGISTRATION_ERROR_NONE if registration completed successfully.
// Otherwise, |result| and |error_message| will contain additional information
// about why registration failed.
///
void (CEF_CALLBACK *on_cdm_registration_complete)(
struct _cef_register_cdm_callback_t* self,
cef_cdm_registration_error_t result, const cef_string_t* error_message);
} cef_register_cdm_callback_t;
///
// Visit web plugin information. Can be called on any thread in the browser
// process.
@@ -161,6 +184,54 @@ CEF_EXPORT void cef_register_web_plugin_crash(const cef_string_t* path);
CEF_EXPORT void cef_is_web_plugin_unstable(const cef_string_t* path,
cef_web_plugin_unstable_callback_t* callback);
///
// Register the Widevine CDM plugin.
//
// The client application is responsible for downloading an appropriate
// platform-specific CDM binary distribution from Google, extracting the
// contents, and building the required directory structure on the local machine.
// The cef_browser_host_t::StartDownload function and CefZipArchive structure
// can be used to implement this functionality in CEF. Contact Google via
// https://www.widevine.com/contact.html for details on CDM download.
//
// |path| is a directory that must contain the following files:
// 1. manifest.json file from the CDM binary distribution (see below).
// 2. widevinecdm file from the CDM binary distribution (e.g.
// widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X,
// libwidevinecdm.so on Linux).
// 3. widevidecdmadapter file from the CEF binary distribution (e.g.
// widevinecdmadapter.dll on Windows, widevinecdmadapter.plugin on OS X,
// libwidevinecdmadapter.so on Linux).
//
// If any of these files are missing or if the manifest file has incorrect
// contents the registration will fail and |callback| will receive a |result|
// value of CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS.
//
// The manifest.json file must contain the following keys:
// A. "os": Supported OS (e.g. "mac", "win" or "linux").
// B. "arch": Supported architecture (e.g. "ia32" or "x64").
// C. "x-cdm-module-versions": Module API version (e.g. "4").
// D. "x-cdm-interface-versions": Interface API version (e.g. "8").
// E. "x-cdm-host-versions": Host API version (e.g. "8").
// F. "version": CDM version (e.g. "1.4.8.903").
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1").
//
// A through E are used to verify compatibility with the current Chromium
// version. If the CDM is not compatible the registration will fail and
// |callback| will receive a |result| value of
// CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE.
//
// |callback| will be executed asynchronously once registration is complete.
//
// On Linux this function must be called before cef_initialize() and the
// registration cannot be changed during runtime. If registration is not
// supported at the time that cef_register_widevine_cdm() is called then
// |callback| will receive a |result| value of
// CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED.
///
CEF_EXPORT void cef_register_widevine_cdm(const cef_string_t* path,
cef_register_cdm_callback_t* callback);
#ifdef __cplusplus
}
#endif

View File

@@ -490,24 +490,34 @@ class CefBrowserHost : public virtual CefBase {
virtual void StopFinding(bool clearSelection) =0;
///
// Open developer tools in its own window. If |inspect_element_at| is non-
// empty the element at the specified (x,y) location will be inspected. The
// |windowInfo| parameter will be ignored if this browser is wrapped in a
// CefBrowserView.
// Open developer tools (DevTools) in its own browser. The DevTools browser
// will remain associated with this browser. If the DevTools browser is
// already open then it will be focused, in which case the |windowInfo|,
// |client| and |settings| parameters will be ignored. If |inspect_element_at|
// is non-empty then the element at the specified (x,y) location will be
// inspected. The |windowInfo| parameter will be ignored if this browser is
// wrapped in a CefBrowserView.
///
/*--cef(optional_param=inspect_element_at)--*/
/*--cef(optional_param=windowInfo,optional_param=client,
optional_param=settings,optional_param=inspect_element_at)--*/
virtual void ShowDevTools(const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at) =0;
///
// Explicitly close the developer tools window if one exists for this browser
// instance.
// Explicitly close the associated DevTools browser, if any.
///
/*--cef()--*/
virtual void CloseDevTools() =0;
///
// Returns true if this browser currently has an associated DevTools browser.
// Must be called on the browser process UI thread.
///
/*--cef()--*/
virtual bool HasDevTools() =0;
///
// Retrieve a snapshot of current navigation entries as values sent to the
// specified visitor. If |current_only| is true only the current navigation

View File

@@ -51,6 +51,7 @@
class CefLoadHandler : public virtual CefBase {
public:
typedef cef_errorcode_t ErrorCode;
typedef cef_transition_type_t TransitionType;
///
// Called when the loading state has changed. This callback will be executed
@@ -68,15 +69,18 @@ class CefLoadHandler : public virtual CefBase {
///
// Called when the browser begins loading a frame. The |frame| value will
// never be empty -- call the IsMain() method to check if this frame is the
// main frame. Multiple frames may be loading at the same time. Sub-frames may
// start or continue loading after the main frame load has ended. This method
// will always be called for all frames irrespective of whether the request
// main frame. |transition_type| provides information about the source of the
// navigation and an accurate value is only available in the browser process.
// Multiple frames may be loading at the same time. Sub-frames may start or
// continue loading after the main frame load has ended. This method will
// always be called for all frames irrespective of whether the request
// completes successfully. For notification of overall browser load status use
// OnLoadingStateChange instead.
///
/*--cef()--*/
virtual void OnLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {}
CefRefPtr<CefFrame> frame,
TransitionType transition_type) {}
///
// Called when the browser is done loading a frame. The |frame| value will

View File

@@ -104,7 +104,7 @@ class CefRequestContext : public virtual CefBase {
// Creates a new context object that shares storage with |other| and uses an
// optional |handler|.
///
/*--cef(capi_name=create_context_shared,optional_param=handler)--*/
/*--cef(capi_name=cef_create_context_shared,optional_param=handler)--*/
static CefRefPtr<CefRequestContext> CreateContext(
CefRefPtr<CefRequestContext> other,
CefRefPtr<CefRequestContextHandler> handler);

View File

@@ -144,5 +144,71 @@ class CefWebPluginUnstableCallback : public virtual CefBase {
void CefIsWebPluginUnstable(const CefString& path,
CefRefPtr<CefWebPluginUnstableCallback> callback);
///
// Implement this interface to receive notification when CDM registration is
// complete. The methods of this class will be called on the browser process
// UI thread.
///
/*--cef(source=client)--*/
class CefRegisterCdmCallback : public virtual CefBase {
public:
///
// Method that will be called when CDM registration is complete. |result|
// will be CEF_CDM_REGISTRATION_ERROR_NONE if registration completed
// successfully. Otherwise, |result| and |error_message| will contain
// additional information about why registration failed.
///
/*--cef(optional_param=error_message)--*/
virtual void OnCdmRegistrationComplete(cef_cdm_registration_error_t result,
const CefString& error_message) =0;
};
///
// Register the Widevine CDM plugin.
//
// The client application is responsible for downloading an appropriate
// platform-specific CDM binary distribution from Google, extracting the
// contents, and building the required directory structure on the local machine.
// The CefBrowserHost::StartDownload method and CefZipArchive class can be used
// to implement this functionality in CEF. Contact Google via
// https://www.widevine.com/contact.html for details on CDM download.
//
// |path| is a directory that must contain the following files:
// 1. manifest.json file from the CDM binary distribution (see below).
// 2. widevinecdm file from the CDM binary distribution (e.g.
// widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X,
// libwidevinecdm.so on Linux).
// 3. widevidecdmadapter file from the CEF binary distribution (e.g.
// widevinecdmadapter.dll on Windows, widevinecdmadapter.plugin on OS X,
// libwidevinecdmadapter.so on Linux).
//
// If any of these files are missing or if the manifest file has incorrect
// contents the registration will fail and |callback| will receive a |result|
// value of CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS.
//
// The manifest.json file must contain the following keys:
// A. "os": Supported OS (e.g. "mac", "win" or "linux").
// B. "arch": Supported architecture (e.g. "ia32" or "x64").
// C. "x-cdm-module-versions": Module API version (e.g. "4").
// D. "x-cdm-interface-versions": Interface API version (e.g. "8").
// E. "x-cdm-host-versions": Host API version (e.g. "8").
// F. "version": CDM version (e.g. "1.4.8.903").
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1").
//
// A through E are used to verify compatibility with the current Chromium
// version. If the CDM is not compatible the registration will fail and
// |callback| will receive a |result| value of
// CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE.
//
// |callback| will be executed asynchronously once registration is complete.
//
// On Linux this function must be called before CefInitialize() and the
// registration cannot be changed during runtime. If registration is not
// supported at the time that CefRegisterWidevineCdm() is called then |callback|
// will receive a |result| value of CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED.
///
/*--cef(optional_param=callback)--*/
void CefRegisterWidevineCdm(const CefString& path,
CefRefPtr<CefRegisterCdmCallback> callback);
#endif // CEF_INCLUDE_CEF_WEB_PLUGIN_H_

View File

@@ -376,6 +376,19 @@ typedef struct _cef_settings_t {
///
int ignore_certificate_errors;
///
// Set to true (1) to enable date-based expiration of built in network
// security information (i.e. certificate transparency logs, HSTS preloading
// and pinning information). Enabling this option improves network security
// but may cause HTTPS load failures when using CEF binaries built more than
// 10 weeks in the past. See https://www.certificate-transparency.org/ and
// https://www.chromium.org/hsts for details. Also configurable using the
// "enable-net-security-expiration" command-line switch. Can be overridden for
// individual CefRequestContext instances via the
// CefRequestContextSettings.enable_net_security_expiration value.
///
int enable_net_security_expiration;
///
// Opaque background color used for accelerated content. By default the
// background color will be white. Only the RGB compontents of the specified
@@ -443,6 +456,17 @@ typedef struct _cef_request_context_settings_t {
///
int ignore_certificate_errors;
///
// Set to true (1) to enable date-based expiration of built in network
// security information (i.e. certificate transparency logs, HSTS preloading
// and pinning information). Enabling this option improves network security
// but may cause HTTPS load failures when using CEF binaries built more than
// 10 weeks in the past. See https://www.certificate-transparency.org/ and
// https://www.chromium.org/hsts for details. Can be set globally using the
// CefSettings.enable_net_security_expiration value.
///
int enable_net_security_expiration;
///
// Comma delimited ordered list of language codes without any whitespace that
// will be used in the "Accept-Language" HTTP header. Can be set globally
@@ -2635,6 +2659,31 @@ typedef enum {
CEF_MENU_ANCHOR_BOTTOMCENTER,
} cef_menu_anchor_position_t;
///
// Error codes for CDM registration. See cef_web_plugin.h for details.
///
typedef enum {
///
// No error. Registration completed successfully.
///
CEF_CDM_REGISTRATION_ERROR_NONE,
///
// Required files or manifest contents are missing.
///
CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS,
///
// The CDM is incompatible with the current Chromium version.
///
CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE,
///
// CDM registration is not supported at this time.
///
CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED,
} cef_cdm_registration_error_t;
#ifdef __cplusplus
}
#endif

View File

@@ -607,6 +607,8 @@ struct CefSettingsTraits {
target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
target->context_safety_implementation = src->context_safety_implementation;
target->ignore_certificate_errors = src->ignore_certificate_errors;
target->enable_net_security_expiration =
src->enable_net_security_expiration;
target->background_color = src->background_color;
cef_string_set(src->accept_language_list.str,
@@ -639,6 +641,8 @@ struct CefRequestContextSettingsTraits {
target->persist_session_cookies = src->persist_session_cookies;
target->persist_user_preferences = src->persist_user_preferences;
target->ignore_certificate_errors = src->ignore_certificate_errors;
target->enable_net_security_expiration =
src->enable_net_security_expiration;
cef_string_set(src->accept_language_list.str,
src->accept_language_list.length, &target->accept_language_list, copy);
}

View File

@@ -37,6 +37,7 @@
#define CEF_INCLUDE_WRAPPER_CEF_STREAM_RESOURCE_HANDLER_H_
#pragma once
#include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
#include "include/base/cef_scoped_ptr.h"
#include "include/cef_base.h"
@@ -91,7 +92,7 @@ class CefStreamResourceHandler : public CefResourceHandler {
class Buffer;
SCOPED_PTR(Buffer) buffer_;
#ifndef NDEBUG
#if DCHECK_IS_ON()
// Used in debug builds to verify that |buffer_| isn't being accessed on
// multiple threads at the same time.
bool buffer_owned_by_file_thread_;

View File

@@ -17,13 +17,13 @@
#include "extensions/browser/extension_protocols.h"
#include "extensions/common/constants.h"
#ifndef NDEBUG
#if DCHECK_IS_ON()
base::AtomicRefCount CefBrowserContext::DebugObjCt = 0;
#endif
CefBrowserContext::CefBrowserContext()
: extension_system_(NULL) {
#ifndef NDEBUG
#if DCHECK_IS_ON()
base::AtomicRefCountInc(&DebugObjCt);
#endif
}
@@ -32,7 +32,7 @@ CefBrowserContext::~CefBrowserContext() {
// Should be cleared in Shutdown().
DCHECK(!resource_context_.get());
#ifndef NDEBUG
#if DCHECK_IS_ON()
base::AtomicRefCountDec(&DebugObjCt);
#endif
}

View File

@@ -158,7 +158,7 @@ class CefBrowserContext
return extension_system_;
}
#ifndef NDEBUG
#if DCHECK_IS_ON()
// Simple tracking of allocated objects.
static base::AtomicRefCount DebugObjCt; // NOLINT(runtime/int)
#endif

View File

@@ -29,9 +29,9 @@
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/prefs/pref_service.h"
#include "components/ui/zoom/zoom_event_manager.h"
#include "components/visitedlink/browser/visitedlink_event_listener.h"
#include "components/visitedlink/browser/visitedlink_master.h"
#include "components/zoom/zoom_event_manager.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
@@ -209,12 +209,14 @@ CefBrowserContextImpl::~CefBrowserContextImpl() {
pref_proxy_config_tracker_->DetachFromPrefService();
if (host_content_settings_map_.get())
if (url_request_getter_)
url_request_getter_->ShutdownOnUIThread();
if (host_content_settings_map_)
host_content_settings_map_->ShutdownOnUIThread();
// Delete the download manager delegate here because otherwise we'll crash
// when it's accessed from the content::BrowserContext destructor.
if (download_manager_delegate_.get())
if (download_manager_delegate_)
download_manager_delegate_.reset(NULL);
g_manager.Get().RemoveImpl(this, cache_path_);
@@ -341,7 +343,7 @@ std::unique_ptr<content::ZoomLevelDelegate>
return base::WrapUnique(new ChromeZoomLevelPrefs(
GetPrefs(), cache_path_, partition_path,
ui_zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
}
bool CefBrowserContextImpl::IsOffTheRecord() const {

View File

@@ -596,7 +596,7 @@ void CefBrowserHostImpl::SetFocus(bool focus) {
if (focus)
OnSetFocus(FOCUS_SOURCE_SYSTEM);
else
else if (platform_delegate_)
platform_delegate_->SendFocusEvent(false);
}
@@ -695,7 +695,8 @@ void CefBrowserHostImpl::StartDownload(const CefString& url) {
return;
std::unique_ptr<content::DownloadUrlParameters> params(
content::DownloadUrlParameters::FromWebContents(web_contents(), gurl));
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
web_contents(), gurl));
manager->DownloadUrl(std::move(params));
}
@@ -805,6 +806,10 @@ void CefBrowserHostImpl::ShowDevTools(
return;
if (devtools_frontend_) {
if (!inspect_element_at.IsEmpty()) {
devtools_frontend_->InspectElementAt(inspect_element_at.x,
inspect_element_at.y);
}
devtools_frontend_->Focus();
return;
}
@@ -832,6 +837,15 @@ void CefBrowserHostImpl::CloseDevTools() {
}
}
bool CefBrowserHostImpl::HasDevTools() {
if (!CEF_CURRENTLY_ON_UIT()) {
NOTREACHED() << "called on invalid thread";
return false;
}
return (devtools_frontend_ != nullptr);
}
void CefBrowserHostImpl::GetNavigationEntries(
CefRefPtr<CefNavigationEntryVisitor> visitor,
bool current_only) {
@@ -926,7 +940,7 @@ void CefBrowserHostImpl::WasResized() {
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->WasResized();
@@ -944,7 +958,7 @@ void CefBrowserHostImpl::WasHidden(bool hidden) {
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->WasHidden(hidden);
@@ -962,7 +976,7 @@ void CefBrowserHostImpl::NotifyScreenInfoChanged() {
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->NotifyScreenInfoChanged();
@@ -980,7 +994,7 @@ void CefBrowserHostImpl::Invalidate(PaintElementType type) {
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->Invalidate(type);
@@ -993,7 +1007,7 @@ void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
content::NativeWebKeyboardEvent web_event;
@@ -1010,7 +1024,7 @@ void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event,
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
blink::WebMouseEvent web_event;
@@ -1028,7 +1042,7 @@ void CefBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event,
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
blink::WebMouseEvent web_event;
@@ -1045,7 +1059,7 @@ void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event,
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
blink::WebMouseWheelEvent web_event;
@@ -1064,7 +1078,7 @@ void CefBrowserHostImpl::SendCaptureLostEvent() {
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->SendCaptureLostEvent();
@@ -1078,7 +1092,7 @@ void CefBrowserHostImpl::NotifyMoveOrResizeStarted() {
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->NotifyMoveOrResizeStarted();
@@ -1104,7 +1118,9 @@ void CefBrowserHostImpl::SetWindowlessFrameRate(int frame_rate) {
}
settings_.windowless_frame_rate = frame_rate;
platform_delegate_->SetWindowlessFrameRate(frame_rate);
if (platform_delegate_)
platform_delegate_->SetWindowlessFrameRate(frame_rate);
}
// CefBrowser methods.
@@ -1407,12 +1423,14 @@ void CefBrowserHostImpl::DestroyBrowser() {
#if defined(USE_AURA)
views::Widget* CefBrowserHostImpl::GetWindowWidget() const {
CEF_REQUIRE_UIT();
if (!platform_delegate_)
return nullptr;
return platform_delegate_->GetWindowWidget();
}
CefRefPtr<CefBrowserView> CefBrowserHostImpl::GetBrowserView() const {
CEF_REQUIRE_UIT();
if (IsViewsHosted())
if (IsViewsHosted() && platform_delegate_)
return platform_delegate_->GetBrowserView();
return nullptr;
}
@@ -1651,7 +1669,8 @@ void CefBrowserHostImpl::ViewText(const std::string& text) {
return;
}
platform_delegate_->ViewText(text);
if (platform_delegate_)
platform_delegate_->ViewText(text);
}
void CefBrowserHostImpl::HandleExternalProtocol(const GURL& url) {
@@ -1664,7 +1683,7 @@ void CefBrowserHostImpl::HandleExternalProtocol(const GURL& url) {
handler->OnProtocolExecution(this, url.spec(), allow_os_execution);
}
if (allow_os_execution)
if (allow_os_execution && platform_delegate_)
platform_delegate_->HandleExternalProtocol(url);
} else {
CEF_POST_TASK(CEF_UIT,
@@ -1694,7 +1713,8 @@ void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
}
}
platform_delegate_->SendFocusEvent(true);
if (platform_delegate_)
platform_delegate_->SendFocusEvent(true);
} else {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::OnSetFocus, this, source));
@@ -1766,7 +1786,7 @@ CefTextInputContext CefBrowserHostImpl::GetNSTextInputContext() {
return nullptr;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return nullptr;
return platform_delegate_->GetNSTextInputContext();
@@ -1788,7 +1808,7 @@ void CefBrowserHostImpl::HandleKeyEventBeforeTextInputClient(
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->HandleKeyEventBeforeTextInputClient(keyEvent);
@@ -1808,7 +1828,7 @@ void CefBrowserHostImpl::HandleKeyEventAfterTextInputClient(
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
return platform_delegate_->HandleKeyEventAfterTextInputClient(keyEvent);
@@ -1835,7 +1855,7 @@ void CefBrowserHostImpl::DragTargetDragEnter(CefRefPtr<CefDragData> drag_data,
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->DragTargetDragEnter(drag_data, event, allowed_ops);
@@ -1855,7 +1875,7 @@ void CefBrowserHostImpl::DragTargetDragOver(const CefMouseEvent& event,
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->DragTargetDragOver(event, allowed_ops);
@@ -1873,7 +1893,7 @@ void CefBrowserHostImpl::DragTargetDragLeave() {
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->DragTargetDragLeave();
@@ -1891,7 +1911,7 @@ void CefBrowserHostImpl::DragTargetDrop(const CefMouseEvent& event) {
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->DragTargetDrop(event);
@@ -1909,6 +1929,9 @@ void CefBrowserHostImpl::DragSourceSystemDragEnded() {
return;
}
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->DragSourceSystemDragEnded();
}
@@ -1925,7 +1948,7 @@ void CefBrowserHostImpl::DragSourceEndedAt(
return;
}
if (!web_contents())
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->DragSourceEndedAt(x, y, op);
@@ -2095,6 +2118,9 @@ bool CefBrowserHostImpl::PreHandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) {
if (!platform_delegate_)
return false;
if (client_.get()) {
CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler();
if (handler.get()) {
@@ -2120,6 +2146,9 @@ void CefBrowserHostImpl::HandleKeyboardEvent(
if (event.skip_in_browser)
return;
if (!platform_delegate_)
return;
if (client_.get()) {
CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler();
if (handler.get()) {
@@ -2221,7 +2250,7 @@ void CefBrowserHostImpl::DidNavigateMainFramePostCommit(
content::JavaScriptDialogManager*
CefBrowserHostImpl::GetJavaScriptDialogManager(
content::WebContents* source) {
if (!javascript_dialog_manager_.get()) {
if (!javascript_dialog_manager_.get() && platform_delegate_) {
javascript_dialog_manager_.reset(
new CefJavaScriptDialogManager(this,
platform_delegate_->CreateJavaScriptDialogRunner()));
@@ -2230,17 +2259,17 @@ content::JavaScriptDialogManager*
}
void CefBrowserHostImpl::RunFileChooser(
content::WebContents* web_contents,
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) {
EnsureFileDialogManager();
file_dialog_manager_->RunFileChooser(web_contents, params);
file_dialog_manager_->RunFileChooser(render_frame_host, params);
}
bool CefBrowserHostImpl::HandleContextMenu(
content::WebContents* web_contents,
const content::ContextMenuParams& params) {
CEF_REQUIRE_UIT();
if (!menu_manager_.get()) {
if (!menu_manager_.get() && platform_delegate_) {
menu_manager_.reset(
new CefMenuManager(this,
platform_delegate_->CreateMenuRunner()));
@@ -2252,7 +2281,8 @@ void CefBrowserHostImpl::UpdatePreferredSize(content::WebContents* source,
const gfx::Size& pref_size) {
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX))
CEF_REQUIRE_UIT();
platform_delegate_->SizeTo(pref_size.width(), pref_size.height());
if (platform_delegate_)
platform_delegate_->SizeTo(pref_size.width(), pref_size.height());
#endif
}
@@ -2918,7 +2948,7 @@ void CefBrowserHostImpl::SetFocusedFrame(int64 frame_id) {
gfx::Point CefBrowserHostImpl::GetScreenPoint(const gfx::Point& view) const {
CEF_REQUIRE_UIT();
if (platform_delegate_.get())
if (platform_delegate_)
return platform_delegate_->GetScreenPoint(view);
return gfx::Point();
}
@@ -2941,7 +2971,8 @@ void CefBrowserHostImpl::OnLoadStart(CefRefPtr<CefFrame> frame,
CefRefPtr<CefLoadHandler> handler = client_->GetLoadHandler();
if (handler.get()) {
// Notify the handler that loading has started.
handler->OnLoadStart(this, frame);
handler->OnLoadStart(this, frame,
static_cast<cef_transition_type_t>(transition_type));
}
}
}
@@ -3003,7 +3034,7 @@ void CefBrowserHostImpl::OnDevToolsWebContentsDestroyed() {
void CefBrowserHostImpl::EnsureFileDialogManager() {
CEF_REQUIRE_UIT();
if (!file_dialog_manager_.get()) {
if (!file_dialog_manager_.get() && platform_delegate_) {
file_dialog_manager_.reset(
new CefFileDialogManager(this,
platform_delegate_->CreateFileDialogRunner()));

View File

@@ -180,6 +180,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at) override;
void CloseDevTools() override;
bool HasDevTools() override;
void GetNavigationEntries(
CefRefPtr<CefNavigationEntryVisitor> visitor,
bool current_only) override;
@@ -403,7 +404,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
content::WebContents* source) override;
void RunFileChooser(
content::WebContents* web_contents,
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) override;
bool EmbedsFullscreenWidget() const override;
void EnterFullscreenModeForTab(content::WebContents* web_contents,

View File

@@ -347,7 +347,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
return;
}
#ifndef NDEBUG
#if DCHECK_IS_ON()
// Verify that no request for the same route is currently queued.
{
PendingNewBrowserInfoList::const_iterator it =
@@ -408,7 +408,7 @@ void CefBrowserInfoManager::DestroyAllBrowsers() {
}
}
#ifndef NDEBUG
#if DCHECK_IS_ON()
{
// Verify that all browser windows have been destroyed.
base::AutoLock lock_scope(browser_info_lock_);

View File

@@ -69,7 +69,6 @@ void CefBrowserMainParts::PreMainMessageLoopStart() {
if (!base::MessageLoop::current()) {
// Create the browser message loop.
message_loop_.reset(new CefBrowserMessageLoop());
message_loop_->set_thread_name("CrBrowserMain");
}
}
@@ -179,7 +178,7 @@ void CefBrowserMainParts::PostMainMessageLoopRun() {
global_browser_context_ = NULL;
#ifndef NDEBUG
#if DCHECK_IS_ON()
// No CefBrowserContext instances should exist at this point.
DCHECK_EQ(0, CefBrowserContext::DebugObjCt);
#endif
@@ -191,7 +190,7 @@ void CefBrowserMainParts::PostDestroyThreads() {
delete views::ViewsDelegate::GetInstance();
#endif
#ifndef NDEBUG
#if DCHECK_IS_ON()
// No CefURLRequestContext instances should exist at this point.
DCHECK_EQ(0, CefURLRequestContext::DebugObjCt);
#endif

View File

@@ -8,10 +8,10 @@
#include "libcef/browser/browser_main.h"
#include "cef/grit/cef_strings.h"
#include "chrome/common/chrome_utility_messages.h"
#include "content/public/browser/utility_process_host.h"
#include "content/public/browser/utility_process_host_client.h"
#include "grit/cef_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/win/direct_write.h"

View File

@@ -208,6 +208,12 @@ safe_browsing::ClientSideDetectionService*
return NULL;
}
subresource_filter::RulesetService*
ChromeBrowserProcessStub::subresource_filter_ruleset_service() {
NOTIMPLEMENTED();
return NULL;
}
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
void ChromeBrowserProcessStub::StartAutoupdateTimer() {
}
@@ -220,7 +226,7 @@ net_log::ChromeNetLog* ChromeBrowserProcessStub::net_log() {
component_updater::ComponentUpdateService*
ChromeBrowserProcessStub::component_updater() {
return CefContext::Get()->component_updater();
return NULL;
}
CRLSetFetcher* ChromeBrowserProcessStub::crl_set_fetcher() {

View File

@@ -72,6 +72,8 @@ class ChromeBrowserProcessStub : public BrowserProcess {
safe_browsing::SafeBrowsingService* safe_browsing_service() override;
safe_browsing::ClientSideDetectionService*
safe_browsing_detection_service() override;
subresource_filter::RulesetService*
subresource_filter_ruleset_service() override;
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
void StartAutoupdateTimer() override;

View File

@@ -1,304 +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/component_updater/cef_component_updater_configurator.h"
#include "include/cef_version.h"
#include <algorithm>
#include <string>
#include <vector>
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/strings/stringprintf.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/version.h"
#include "build/build_config.h"
#include "chrome/browser/update_client/chrome_update_query_params_delegate.h"
#include "components/update_client/component_patcher_operation.h"
#include "components/component_updater/component_updater_switches.h"
#include "components/component_updater/component_updater_url_constants.h"
#include "components/update_client/configurator.h"
#include "content/public/browser/browser_thread.h"
#include "net/url_request/url_request_context_getter.h"
#include "url/gurl.h"
#if defined(OS_WIN)
#include "base/win/win_util.h"
#endif // OS_WIN
using update_client::Configurator;
namespace component_updater {
namespace {
// Default time constants.
const int kDelayOneMinute = 60;
const int kDelayOneHour = kDelayOneMinute * 60;
// Debug values you can pass to --component-updater=value1,value2.
// Speed up component checking.
const char kSwitchFastUpdate[] = "fast-update";
// Add "testrequest=1" attribute to the update check request.
const char kSwitchRequestParam[] = "test-request";
// Disables pings. Pings are the requests sent to the update server that report
// the success or the failure of component install or update attempts.
extern const char kSwitchDisablePings[] = "disable-pings";
// Sets the URL for updates.
const char kSwitchUrlSource[] = "url-source";
// Disables differential updates.
const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates";
#if defined(OS_WIN)
// Disables background downloads.
const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads";
#endif // defined(OS_WIN)
// Returns true if and only if |test| is contained in |vec|.
bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) {
if (vec.empty())
return 0;
return (std::find(vec.begin(), vec.end(), test) != vec.end());
}
// If there is an element of |vec| of the form |test|=.*, returns the right-
// hand side of that assignment. Otherwise, returns an empty string.
// The right-hand side may contain additional '=' characters, allowing for
// further nesting of switch arguments.
std::string GetSwitchArgument(const std::vector<std::string>& vec,
const char* test) {
if (vec.empty())
return std::string();
for (std::vector<std::string>::const_iterator it = vec.begin();
it != vec.end();
++it) {
const std::size_t found = it->find("=");
if (found != std::string::npos) {
if (it->substr(0, found) == test) {
return it->substr(found + 1);
}
}
}
return std::string();
}
class CefConfigurator : public Configurator {
public:
CefConfigurator(const base::CommandLine* cmdline,
net::URLRequestContextGetter* url_request_getter,
PrefService* pref_service);
int InitialDelay() const override;
int NextCheckDelay() const override;
int StepDelay() const override;
int OnDemandDelay() const override;
int UpdateDelay() const override;
std::vector<GURL> UpdateUrl() const override;
std::vector<GURL> PingUrl() const override;
base::Version GetBrowserVersion() const override;
std::string GetChannel() const override;
std::string GetBrand() const override;
std::string GetLang() const override;
std::string GetOSLongName() const override;
std::string ExtraRequestParams() const override;
std::string GetDownloadPreference() const override;
net::URLRequestContextGetter* RequestContext() const override;
scoped_refptr<update_client::OutOfProcessPatcher>
CreateOutOfProcessPatcher() const override;
bool DeltasEnabled() const override;
bool UseBackgroundDownloader() const override;
bool UseCupSigning() const override;
scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
const override;
PrefService* GetPrefService() const override;
private:
friend class base::RefCountedThreadSafe<CefConfigurator>;
~CefConfigurator() override {}
net::URLRequestContextGetter* url_request_getter_;
PrefService* pref_service_;
std::string extra_info_;
GURL url_source_override_;
bool fast_update_;
bool pings_enabled_;
bool deltas_enabled_;
bool background_downloads_enabled_;
};
CefConfigurator::CefConfigurator(
const base::CommandLine* cmdline,
net::URLRequestContextGetter* url_request_getter,
PrefService* pref_service)
: url_request_getter_(url_request_getter),
pref_service_(pref_service),
fast_update_(false),
pings_enabled_(false),
deltas_enabled_(false),
background_downloads_enabled_(false) {
// Parse comma-delimited debug flags.
std::vector<std::string> switch_values = base::SplitString(
cmdline->GetSwitchValueASCII(switches::kComponentUpdater),
",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate);
pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings);
deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates);
// TODO(dberger): Pull this (and possibly the various hard-coded
// delay params in this file) from cef settings.
fast_update_ = true;
#if defined(OS_WIN)
background_downloads_enabled_ =
!HasSwitchValue(switch_values, kSwitchDisableBackgroundDownloads);
#else
background_downloads_enabled_ = false;
#endif
const std::string switch_url_source =
GetSwitchArgument(switch_values, kSwitchUrlSource);
if (!switch_url_source.empty()) {
url_source_override_ = GURL(switch_url_source);
DCHECK(url_source_override_.is_valid());
}
if (HasSwitchValue(switch_values, kSwitchRequestParam))
extra_info_ += "testrequest=\"1\"";
}
int CefConfigurator::InitialDelay() const {
return fast_update_ ? 10 : (6 * kDelayOneMinute);
}
int CefConfigurator::NextCheckDelay() const {
return fast_update_ ? 60 : (6 * kDelayOneHour);
}
int CefConfigurator::StepDelay() const {
return fast_update_ ? 1 : 1;
}
int CefConfigurator::OnDemandDelay() const {
return fast_update_ ? 2 : (30 * kDelayOneMinute);
}
int CefConfigurator::UpdateDelay() const {
return fast_update_ ? 10 : (15 * kDelayOneMinute);
}
std::vector<GURL> CefConfigurator::UpdateUrl() const {
std::vector<GURL> urls;
if (url_source_override_.is_valid()) {
urls.push_back(GURL(url_source_override_));
} else {
urls.push_back(GURL(kUpdaterDefaultUrl));
}
return urls;
}
std::vector<GURL> CefConfigurator::PingUrl() const {
return pings_enabled_ ? UpdateUrl() : std::vector<GURL>();
}
base::Version CefConfigurator::GetBrowserVersion() const {
return base::Version(base::StringPrintf("%d.%d.%d.%d",
CHROME_VERSION_MAJOR,
CHROME_VERSION_MINOR,
CHROME_VERSION_BUILD,
CHROME_VERSION_PATCH));
}
std::string CefConfigurator::GetChannel() const {
return "";
}
std::string CefConfigurator::GetBrand() const {
return "";
}
std::string CefConfigurator::GetLang() const {
return "";
}
std::string CefConfigurator::GetOSLongName() const {
#if defined(OS_WIN)
return "Windows";
#elif defined(OS_MACOSX)
return "Mac OS X";
#elif defined(OS_CHROMEOS)
return "Chromium OS";
#elif defined(OS_ANDROID)
return "Android";
#elif defined(OS_LINUX)
return "Linux";
#elif defined(OS_FREEBSD)
return "FreeBSD";
#elif defined(OS_OPENBSD)
return "OpenBSD";
#elif defined(OS_SOLARIS)
return "Solaris";
#else
return "Unknown";
#endif
}
std::string CefConfigurator::ExtraRequestParams() const {
return extra_info_;
}
std::string CefConfigurator::GetDownloadPreference() const {
return std::string();
}
net::URLRequestContextGetter* CefConfigurator::RequestContext() const {
return url_request_getter_;
}
scoped_refptr<update_client::OutOfProcessPatcher>
CefConfigurator::CreateOutOfProcessPatcher() const {
return NULL;
}
bool CefConfigurator::DeltasEnabled() const {
return deltas_enabled_;
}
bool CefConfigurator::UseBackgroundDownloader() const {
return background_downloads_enabled_;
}
bool CefConfigurator::UseCupSigning() const {
return true;
}
scoped_refptr<base::SequencedTaskRunner>
CefConfigurator::GetSequencedTaskRunner() const {
return content::BrowserThread::GetBlockingPool()
->GetSequencedTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::GetSequenceToken(),
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
}
PrefService* CefConfigurator::GetPrefService() const {
return pref_service_;
}
} // namespace
scoped_refptr<update_client::Configurator>
MakeCefComponentUpdaterConfigurator(
const base::CommandLine* cmdline,
net::URLRequestContextGetter* context_getter,
PrefService* pref_service) {
return new CefConfigurator(cmdline, context_getter, pref_service);
}
} // namespace component_updater

View File

@@ -1,31 +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.
#ifndef LIBCEF_BROWSER_COMPONENT_UPDATER_CEF_COMPONENT_UPDATER_CONFIGURATOR_H_
#define LIBCEF_BROWSER_COMPONENT_UPDATER_CEF_COMPONENT_UPDATER_CONFIGURATOR_H_
#include "base/memory/ref_counted.h"
#include "components/update_client/configurator.h"
namespace base {
class CommandLine;
}
namespace net {
class URLRequestContextGetter;
}
class PrefService;
namespace component_updater {
scoped_refptr<update_client::Configurator>
MakeCefComponentUpdaterConfigurator(
const base::CommandLine* cmdline,
net::URLRequestContextGetter* context_getter,
PrefService* pref_service);
} // namespace component_updater
#endif // LIBCEF_BROWSER_COMPONENT_UPDATER_CEF_COMPONENT_UPDATER_CONFIGURATOR_H_

View File

@@ -51,6 +51,7 @@
#include "content/public/browser/browser_url_handler.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/quota_permission_context.h"
@@ -75,6 +76,10 @@
#include "ui/base/ui_base_switches.h"
#include "url/gurl.h"
#if defined(OS_LINUX)
#include "libcef/common/widevine_loader.h"
#endif
#if defined(OS_MACOSX)
#include "chrome/browser/spellchecker/spellcheck_message_filter_platform.h"
#endif
@@ -116,6 +121,23 @@ class CefAccessTokenStore : public content::AccessTokenStore {
DISALLOW_COPY_AND_ASSIGN(CefAccessTokenStore);
};
// A provider of services for geolocation.
class CefGeolocationDelegate : public content::GeolocationDelegate {
public:
explicit CefGeolocationDelegate(net::URLRequestContextGetter* system_context)
: system_context_(system_context) {}
content::AccessTokenStore* CreateAccessTokenStore() override {
return new CefAccessTokenStore(system_context_);
}
private:
net::URLRequestContextGetter* system_context_;
DISALLOW_COPY_AND_ASSIGN(CefGeolocationDelegate);
};
class CefQuotaCallbackImpl : public CefRequestCallback {
public:
explicit CefQuotaCallbackImpl(
@@ -541,8 +563,6 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kPpapiFlashPath,
switches::kPpapiFlashVersion,
switches::kUncaughtExceptionStackSize,
switches::kWidevineCdmPath,
switches::kWidevineCdmVersion,
};
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
arraysize(kSwitchNames));
@@ -564,17 +584,25 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
#if defined(OS_LINUX)
if (process_type == switches::kZygoteProcess) {
// Propagate the following switches to the zygone command line (along with
// Propagate the following switches to the zygote command line (along with
// any associated values) if present in the browser command line.
static const char* const kSwitchNames[] = {
switches::kPpapiFlashPath,
switches::kPpapiFlashVersion,
switches::kWidevineCdmPath,
switches::kWidevineCdmVersion,
};
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
arraysize(kSwitchNames));
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
if (!browser_cmd->HasSwitch(switches::kNoSandbox)) {
// Pass the Widevine CDM path to the Zygote process. See comments in
// CefWidevineLoader::AddPepperPlugins.
const base::FilePath& cdm_path = CefWidevineLoader::GetInstance()->path();
if (!cdm_path.empty())
command_line->AppendSwitchPath(switches::kWidevineCdmPath, cdm_path);
}
#endif
if (browser_cmd->HasSwitch(switches::kBrowserSubprocessPath)) {
// Force use of the sub-process executable path for the zygote process.
const base::FilePath& subprocess_path =
@@ -674,8 +702,9 @@ void CefContentBrowserClient::SelectClientCertificate(
}
}
content::AccessTokenStore* CefContentBrowserClient::CreateAccessTokenStore() {
return new CefAccessTokenStore(
content::GeolocationDelegate*
CefContentBrowserClient::CreateGeolocationDelegate() {
return new CefGeolocationDelegate(
browser_main_parts_->browser_context()->request_context().get());
}

View File

@@ -66,7 +66,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
content::AccessTokenStore* CreateAccessTokenStore() override;
content::GeolocationDelegate* CreateGeolocationDelegate() override;
bool CanCreateWindow(const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,

View File

@@ -10,12 +10,12 @@
#include "libcef/browser/browser_main.h"
#include "libcef/browser/browser_message_loop.h"
#include "libcef/browser/chrome_browser_process_stub.h"
#include "libcef/browser/component_updater/cef_component_updater_configurator.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/trace_subscriber.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/main_delegate.h"
#include "libcef/common/widevine_loader.h"
#include "libcef/renderer/content_renderer_client.h"
#include "base/base_switches.h"
@@ -24,11 +24,8 @@
#include "base/debug/debugger.h"
#include "base/files/file_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "components/component_updater/component_updater_service.h"
#include "components/update_client/configurator.h"
#include "components/network_session_configurator/switches.h"
#include "content/public/app/content_main.h"
#include "content/public/app/content_main_runner.h"
#include "content/public/browser/notification_service.h"
@@ -326,7 +323,9 @@ void CefContext::Shutdown() {
if (settings_.multi_threaded_message_loop) {
// Events that will be used to signal when shutdown is complete. Start in
// non-signaled mode so that the event will block.
base::WaitableEvent uithread_shutdown_event(false, false);
base::WaitableEvent uithread_shutdown_event(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
// Finish shutdown on the UI thread.
CEF_POST_TASK(CEF_UIT,
@@ -359,25 +358,6 @@ CefTraceSubscriber* CefContext::GetTraceSubscriber() {
return trace_subscriber_.get();
}
component_updater::ComponentUpdateService*
CefContext::component_updater() {
if (!component_updater_.get()) {
CEF_REQUIRE_UIT_RETURN(NULL);
scoped_refptr<CefBrowserContextImpl> browser_context =
CefContentBrowserClient::Get()->browser_context();
scoped_refptr<update_client::Configurator> configurator =
component_updater::MakeCefComponentUpdaterConfigurator(
base::CommandLine::ForCurrentProcess(),
browser_context->request_context().get(),
browser_context->GetPrefs());
// Creating the component updater does not do anything, components
// need to be registered and Start() needs to be called.
component_updater_.reset(component_updater::ComponentUpdateServiceFactory(
configurator).release());
}
return component_updater_.get();
}
void CefContext::PopulateRequestContextSettings(
CefRequestContextSettings* settings) {
CefRefPtr<CefCommandLine> command_line =
@@ -392,34 +372,22 @@ void CefContext::PopulateRequestContextSettings(
settings->ignore_certificate_errors =
settings_.ignore_certificate_errors ||
command_line->HasSwitch(switches::kIgnoreCertificateErrors);
settings->enable_net_security_expiration =
settings_.enable_net_security_expiration ||
command_line->HasSwitch(switches::kEnableNetSecurityExpiration);
CefString(&settings->accept_language_list) =
CefString(&settings_.accept_language_list);
}
void RegisterComponentsForUpdate() {
component_updater::ComponentUpdateService* cus =
CefContext::Get()->component_updater();
// Registration can be before or after cus->Start() so it is ok to post
// a task to the UI thread to do registration once you done the necessary
// file IO to know you existing component version.
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableWidevineCdm)) {
RegisterWidevineCdmComponent(cus);
}
#endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
}
void CefContext::OnContextInitialized() {
CEF_REQUIRE_UIT();
// Must be created after the NotificationService.
print_job_manager_.reset(new printing::PrintJobManager());
bool io_was_allowed = base::ThreadRestrictions::SetIOAllowed(true);
RegisterComponentsForUpdate();
base::ThreadRestrictions::SetIOAllowed(io_was_allowed);
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
CefWidevineLoader::GetInstance()->OnContextInitialized();
#endif
// Notify the handler.
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
@@ -446,9 +414,6 @@ void CefContext::FinishShutdownOnUIThread(
if (trace_subscriber_.get())
trace_subscriber_.reset(NULL);
if (component_updater_.get())
component_updater_.reset(NULL);
if (uithread_shutdown_event)
uithread_shutdown_event->Signal();
}

View File

@@ -18,10 +18,6 @@ namespace base {
class WaitableEvent;
}
namespace component_updater {
class ComponentUpdateService;
}
namespace content {
class ContentMainRunner;
}
@@ -67,8 +63,6 @@ class CefContext {
return print_job_manager_.get();
}
component_updater::ComponentUpdateService* component_updater();
CefTraceSubscriber* GetTraceSubscriber();
// Populate the request context settings based on CefSettings and command-
@@ -101,9 +95,6 @@ class CefContext {
// Only accessed on the UI Thread.
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
// Initially only for Widevine components.
std::unique_ptr<component_updater::ComponentUpdateService> component_updater_;
};
// Helper macro that returns true if the global context is in a valid state.

View File

@@ -18,6 +18,7 @@
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/devtools_agent_host.h"
#include "base/time/time.h"
#include "cef/grit/cef_resources.h"
#include "components/devtools_discovery/basic_target_descriptor.h"
#include "components/devtools_discovery/devtools_discovery_manager.h"
#include "content/public/browser/devtools_frontend_host.h"
@@ -29,7 +30,6 @@
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "grit/cef_resources.h"
#include "net/base/net_errors.h"
#include "net/socket/tcp_server_socket.h"
#include "ui/base/layout.h"

View File

@@ -12,6 +12,7 @@
#include "base/command_line.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/json/string_escape.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
@@ -123,38 +124,28 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
CefBrowserHostImpl::Create(create_params);
content::WebContents* inspected_contents = inspected_browser->web_contents();
if (!inspect_element_at.IsEmpty()) {
scoped_refptr<content::DevToolsAgentHost> agent_host =
content::DevToolsAgentHost::GetOrCreateFor(inspected_contents);
agent_host->InspectElement(inspect_element_at.x, inspect_element_at.y);
}
// CefDevToolsFrontend will delete itself when the frontend WebContents is
// destroyed.
CefDevToolsFrontend* devtools_frontend = new CefDevToolsFrontend(
static_cast<CefBrowserHostImpl*>(frontend_browser.get()),
inspected_contents);
inspected_contents, inspect_element_at);
// Need to load the URL after creating the DevTools objects.
CefDevToolsDelegate* delegate =
CefContentBrowserClient::Get()->devtools_delegate();
frontend_browser->GetMainFrame()->LoadURL(delegate->GetChromeDevToolsURL());
devtools_frontend->Activate();
devtools_frontend->Focus();
return devtools_frontend;
}
void CefDevToolsFrontend::Activate() {
frontend_browser_->ActivateContents(web_contents());
}
void CefDevToolsFrontend::Focus() {
web_contents()->Focus();
frontend_browser_->SetFocus(true);
}
void CefDevToolsFrontend::InspectElementAt(int x, int y) {
if (inspect_element_at_.x != x || inspect_element_at_.y != y)
inspect_element_at_.Set(x, y);
if (agent_host_)
agent_host_->InspectElement(x, y);
}
@@ -168,16 +159,18 @@ void CefDevToolsFrontend::Close() {
void CefDevToolsFrontend::DisconnectFromTarget() {
if (!agent_host_)
return;
agent_host_->DetachClient();
agent_host_->DetachClient(this);
agent_host_ = NULL;
}
CefDevToolsFrontend::CefDevToolsFrontend(
CefRefPtr<CefBrowserHostImpl> frontend_browser,
content::WebContents* inspected_contents)
content::WebContents* inspected_contents,
const CefPoint& inspect_element_at)
: WebContentsObserver(frontend_browser->web_contents()),
frontend_browser_(frontend_browser),
inspected_contents_(inspected_contents),
inspect_element_at_(inspect_element_at),
weak_factory_(this) {
}
@@ -206,12 +199,15 @@ void CefDevToolsFrontend::DocumentAvailableInMainFrame() {
if (agent_host != agent_host_) {
agent_host_ = agent_host;
agent_host_->AttachClient(this);
if (!inspect_element_at_.IsEmpty())
InspectElementAt(inspect_element_at_.x, inspect_element_at_.y);
}
}
void CefDevToolsFrontend::WebContentsDestroyed() {
if (agent_host_)
agent_host_->DetachClient();
agent_host_->DetachClient(this);
delete this;
}
@@ -233,11 +229,12 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
dict->GetList("params", &params);
if (method == "dispatchProtocolMessage" && params && params->GetSize() == 1) {
if (!agent_host_ || !agent_host_->IsAttached())
return;
std::string protocol_message;
if (!params->GetString(0, &protocol_message))
return;
if (agent_host_)
agent_host_->DispatchProtocolMessage(protocol_message);
agent_host_->DispatchProtocolMessage(this, protocol_message);
} else if (method == "loadCompleted") {
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
base::ASCIIToUTF16("DevToolsAPI.setUseSoftMenu(true);"));
@@ -303,23 +300,41 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
content::DevToolsAgentHost* agent_host,
const std::string& message) {
if (message.length() < kMaxMessageChunkSize) {
base::string16 javascript = base::UTF8ToUTF16(
"DevToolsAPI.dispatchMessage(" + message + ");");
std::string param;
base::EscapeJSONString(message, true, &param);
std::string code = "DevToolsAPI.dispatchMessage(" + param + ");";
base::string16 javascript = base::UTF8ToUTF16(code);
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
return;
}
base::FundamentalValue total_size(static_cast<int>(message.length()));
size_t total_size = message.length();
for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
std::string param;
base::JSONWriter::Write(
base::StringValue(message.substr(pos, kMaxMessageChunkSize)), &param);
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");";
base::EscapeJSONString(message.substr(pos, kMaxMessageChunkSize), true,
&param);
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," +
std::to_string(pos ? 0 : total_size) + ");";
base::string16 javascript = base::UTF8ToUTF16(code);
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
}
}
void CefDevToolsFrontend::SetPreferences(const std::string& json) {
preferences_.Clear();
if (json.empty())
return;
base::DictionaryValue* dict = nullptr;
std::unique_ptr<base::Value> parsed = base::JSONReader::Read(json);
if (!parsed || !parsed->GetAsDictionary(&dict))
return;
for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
if (!it.value().IsType(base::Value::TYPE_STRING))
continue;
preferences_.SetWithoutPathExpansion(it.key(), it.value().CreateDeepCopy());
}
}
void CefDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) {
// TODO(pfeldman): this is a copy of chrome's devtools_ui_bindings.cc.
// We should handle some of the commands including this one in content.

View File

@@ -36,7 +36,6 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at);
void Activate();
void Focus();
void InspectElementAt(int x, int y);
void Close();
@@ -54,7 +53,8 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
private:
CefDevToolsFrontend(CefRefPtr<CefBrowserHostImpl> frontend_browser,
content::WebContents* inspected_contents);
content::WebContents* inspected_contents,
const CefPoint& inspect_element_at);
~CefDevToolsFrontend() override;
// content::DevToolsAgentHostClient implementation.
@@ -62,7 +62,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
bool replaced) override;
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
const std::string& message) override;
base::DictionaryValue* preferences() { return &preferences_; }
void SetPreferences(const std::string& json);
// WebContentsObserver overrides
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
@@ -79,6 +79,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
CefRefPtr<CefBrowserHostImpl> frontend_browser_;
content::WebContents* inspected_contents_;
CefPoint inspect_element_at_;
scoped_refptr<content::DevToolsAgentHost> agent_host_;
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
using PendingRequestsMap = std::map<const net::URLFetcher*, int>;

View File

@@ -122,17 +122,19 @@ void CefExtensionSystem::Init() {
// 5. A MimeHandlerViewGuest and CefMimeHandlerViewGuestDelegate is created in
// the browser process.
// 6. MimeHandlerViewGuest navigates to the PDF extension URL.
// 7. PDF extension resources are provided from bundle via
// 7. Access to PDF extension resources is checked by
// CefExtensionsBrowserClient::AllowCrossRendererResourceLoad.
// 8. PDF extension resources are provided from bundle via
// CefExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob and
// CefComponentExtensionResourceManager.
// 8. The PDF extension communicates via the chrome.mimeHandlerPrivate Mojo
// 9. The PDF extension communicates via the chrome.mimeHandlerPrivate Mojo
// API which is implemented as described in
// libcef/common/extensions/api/README.txt.
// 9. The PDF extension requests a plugin to handle
// 10.The PDF extension requests a plugin to handle
// kPDFPluginOutOfProcessMimeType which loads the PDF PPAPI plugin.
// 10.Routing of print-related commands are handled by ChromePDFPrintClient
// 11.Routing of print-related commands are handled by ChromePDFPrintClient
// and CefPrintWebViewHelperDelegate in the renderer process.
// 11.The PDF extension is granted access to chrome://resources via
// 12.The PDF extension is granted access to chrome://resources via
// CefExtensionWebContentsObserver::RenderViewCreated in the browser
// process.
if (PdfExtensionEnabled()) {

View File

@@ -27,6 +27,7 @@
#include "extensions/browser/extension_host_delegate.h"
#include "extensions/browser/mojo/service_registration.h"
#include "extensions/browser/url_request_util.h"
#include "extensions/common/constants.h"
using content::BrowserContext;
using content::BrowserThread;
@@ -114,6 +115,13 @@ bool CefExtensionsBrowserClient::AllowCrossRendererResourceLoad(
bool is_incognito,
const Extension* extension,
InfoMap* extension_info_map) {
// TODO(cef): This bypasses additional checks added to
// AllowCrossRendererResourceLoad() in https://crrev.com/5cf9d45c. Figure out
// why permission is not being granted based on "web_accessible_resources"
// specified in the PDF extension manifest.json file.
if (extension && extension->id() == extension_misc::kPdfExtensionId)
return true;
bool allowed = false;
if (url_request_util::AllowCrossRendererResourceLoad(
request, is_incognito, extension, extension_info_map, &allowed)) {
@@ -162,12 +170,6 @@ bool CefExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
return false;
}
ApiActivityMonitor* CefExtensionsBrowserClient::GetApiActivityMonitor(
BrowserContext* context) {
// CEF doesn't monitor API function calls or events.
return NULL;
}
ExtensionSystemProvider*
CefExtensionsBrowserClient::GetExtensionSystemFactory() {
return CefExtensionSystemFactory::GetInstance();

View File

@@ -64,8 +64,6 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
void PermitExternalProtocolHandler() override;
bool IsRunningInForcedAppMode() override;
bool IsLoggedInAsPublicAccount() override;
ApiActivityMonitor* GetApiActivityMonitor(
content::BrowserContext* context) override;
ExtensionSystemProvider* GetExtensionSystemFactory() override;
void RegisterExtensionFunctions(
ExtensionFunctionRegistry* registry) const override;

View File

@@ -5,7 +5,7 @@
#include "libcef/browser/extensions/pdf_extension_util.h"
#include "base/strings/string_util.h"
#include "grit/cef_resources.h"
#include "cef/grit/cef_resources.h"
#include "ui/base/resource/resource_bundle.h"
namespace extensions {

View File

@@ -12,7 +12,7 @@
#include "libcef/browser/thread_util.h"
#include "base/threading/worker_pool.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/file_chooser_file_info.h"
#include "net/base/directory_lister.h"
@@ -158,6 +158,7 @@ CefFileDialogManager::CefFileDialogManager(
browser_(browser),
runner_(std::move(runner)),
file_chooser_pending_(false),
render_frame_host_(nullptr),
weak_ptr_factory_(this) {
DCHECK(web_contents());
}
@@ -217,40 +218,41 @@ void CefFileDialogManager::RunFileDialog(
}
void CefFileDialogManager::RunFileChooser(
content::WebContents* web_contents,
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) {
CEF_REQUIRE_UIT();
DCHECK_EQ(web_contents, this->web_contents());
content::RenderViewHost* render_view_host = web_contents->GetRenderViewHost();
if (!render_view_host)
return;
DCHECK(render_frame_host);
CefFileDialogRunner::FileChooserParams cef_params;
static_cast<content::FileChooserParams&>(cef_params) = params;
if (lister_) {
// Cancel the previous upload folder run.
lister_->Cancel();
lister_.reset();
}
CefFileDialogRunner::RunFileChooserCallback callback;
if (params.mode == content::FileChooserParams::UploadFolder) {
RunFileChooser(cef_params,
base::Bind(
&CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode));
return;
callback = base::Bind(
&CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode);
} else {
callback = base::Bind(
&CefFileDialogManager::OnRunFileChooserDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode);
}
RunFileChooser(cef_params,
base::Bind(&CefFileDialogManager::OnRunFileChooserDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode));
RunFileChooserInternal(render_frame_host, cef_params, callback);
}
void CefFileDialogManager::RunFileChooser(
const CefFileDialogRunner::FileChooserParams& params,
const CefFileDialogRunner::RunFileChooserCallback& callback) {
const CefFileDialogRunner::RunFileChooserCallback& host_callback =
base::Bind(&CefFileDialogManager::OnRunFileChooserCallback,
weak_ptr_factory_.GetWeakPtr(), callback);
RunFileChooserInternal(nullptr, params, host_callback);
}
void CefFileDialogManager::RunFileChooserInternal(
content::RenderFrameHost* render_frame_host,
const CefFileDialogRunner::FileChooserParams& params,
const CefFileDialogRunner::RunFileChooserCallback& callback) {
CEF_REQUIRE_UIT();
if (file_chooser_pending_) {
@@ -260,11 +262,7 @@ void CefFileDialogManager::RunFileChooser(
}
file_chooser_pending_ = true;
// Ensure that the |file_chooser_pending_| flag is cleared.
const CefFileDialogRunner::RunFileChooserCallback& host_callback =
base::Bind(&CefFileDialogManager::OnRunFileChooserCallback,
weak_ptr_factory_.GetWeakPtr(), callback);
render_frame_host_ = render_frame_host;
bool handled = false;
@@ -304,7 +302,7 @@ void CefFileDialogManager::RunFileChooser(
accept_filters.push_back(*it);
CefRefPtr<CefFileDialogCallbackImpl> callbackImpl(
new CefFileDialogCallbackImpl(host_callback));
new CefFileDialogCallbackImpl(callback));
handled = handler->OnFileDialog(
browser_,
static_cast<cef_file_dialog_mode_t>(mode),
@@ -327,10 +325,10 @@ void CefFileDialogManager::RunFileChooser(
if (!handled) {
if (runner_.get()) {
runner_->Run(browser_, params, host_callback);
runner_->Run(browser_, params, callback);
} else {
LOG(WARNING) << "No file dialog runner available for this platform";
host_callback.Run(0, std::vector<base::FilePath>());
callback.Run(0, std::vector<base::FilePath>());
}
}
}
@@ -341,7 +339,7 @@ void CefFileDialogManager::OnRunFileChooserCallback(
const std::vector<base::FilePath>& file_paths) {
CEF_REQUIRE_UIT();
file_chooser_pending_ = false;
Cleanup();
// Execute the callback asynchronously.
CEF_POST_TASK(CEF_UIT,
@@ -361,7 +359,7 @@ void CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback(
} else {
lister_.reset(new net::DirectoryLister(
file_paths[0],
net::DirectoryLister::NO_SORT,
net::DirectoryLister::NO_SORT_RECURSIVE,
new UploadFolderHelper(
base::Bind(&CefFileDialogManager::OnRunFileChooserDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), mode))));
@@ -375,17 +373,6 @@ void CefFileDialogManager::OnRunFileChooserDelegateCallback(
const std::vector<base::FilePath>& file_paths) {
CEF_REQUIRE_UIT();
if (lister_.get())
lister_.reset();
if (!web_contents())
return;
content::RenderViewHost* render_view_host =
web_contents()->GetRenderViewHost();
if (!render_view_host)
return;
// Convert FilePath list to SelectedFileInfo list.
std::vector<content::FileChooserFileInfo> selected_files;
for (size_t i = 0; i < file_paths.size(); ++i) {
@@ -395,5 +382,22 @@ void CefFileDialogManager::OnRunFileChooserDelegateCallback(
}
// Notify our RenderViewHost in all cases.
render_view_host->FilesSelectedInChooser(selected_files, mode);
if (render_frame_host_)
render_frame_host_->FilesSelectedInChooser(selected_files, mode);
Cleanup();
}
void CefFileDialogManager::Cleanup() {
if (lister_)
lister_.reset();
render_frame_host_ = nullptr;
file_chooser_pending_ = false;
}
void CefFileDialogManager::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
if (render_frame_host == render_frame_host_)
render_frame_host_ = nullptr;
}

View File

@@ -48,8 +48,8 @@ class CefFileDialogManager : public content::WebContentsObserver {
// Called from CefBrowserHostImpl::RunFileChooser.
// See WebContentsDelegate::RunFileChooser documentation.
void RunFileChooser(
content::WebContents* web_contents,
const content::FileChooserParams& params);
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params);
// Run the file chooser dialog specified by |params|. Only a single dialog may
// be pending at any given time. |callback| will be executed asynchronously
@@ -59,7 +59,13 @@ class CefFileDialogManager : public content::WebContentsObserver {
const CefFileDialogRunner::RunFileChooserCallback& callback);
private:
// Used with RunFileChooser to clear the |file_chooser_pending_| flag.
void RunFileChooserInternal(
content::RenderFrameHost* render_frame_host,
const CefFileDialogRunner::FileChooserParams& params,
const CefFileDialogRunner::RunFileChooserCallback& callback);
// Used with the RunFileChooser variant where the caller specifies a callback
// (no associated RenderFrameHost).
void OnRunFileChooserCallback(
const CefFileDialogRunner::RunFileChooserCallback& callback,
int selected_accept_filter,
@@ -72,12 +78,20 @@ class CefFileDialogManager : public content::WebContentsObserver {
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths);
// Used with WebContentsDelegate::RunFileChooser to notify the WebContents.
// Used with WebContentsDelegate::RunFileChooser to notify the
// RenderFrameHost.
void OnRunFileChooserDelegateCallback(
content::FileChooserParams::Mode mode,
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths);
// Clean up state associated with the last run.
void Cleanup();
// WebContentsObserver methods:
void RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) override;
// CefBrowserHostImpl pointer is guaranteed to outlive this object.
CefBrowserHostImpl* browser_;
@@ -86,6 +100,9 @@ class CefFileDialogManager : public content::WebContentsObserver {
// True if a file chooser is currently pending.
bool file_chooser_pending_;
// RenderFrameHost associated with the pending file chooser. May be nullptr.
content::RenderFrameHost* render_frame_host_;
// Used for asynchronously listing directory contents.
std::unique_ptr<net::DirectoryLister> lister_;

View File

@@ -329,7 +329,12 @@ gfx::ImageSkia CefImageImpl::GetForced1xScaleRepresentation(
bool CefImageImpl::AddBitmap(float scale_factor,
const SkBitmap& bitmap) {
DCHECK(bitmap.readyToDraw());
#if DCHECK_IS_ON()
{
SkAutoLockPixels bitmap_lock(bitmap);
DCHECK(bitmap.readyToDraw());
}
#endif
DCHECK(bitmap.colorType() == kBGRA_8888_SkColorType ||
bitmap.colorType() == kRGBA_8888_SkColorType);

View File

@@ -14,10 +14,10 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "cef/grit/cef_strings.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "grit/cef_strings.h"
namespace {

View File

@@ -762,13 +762,13 @@ void CefMenuModelImpl::InsertItemAt(const Item& item, int index) {
}
void CefMenuModelImpl::ValidateItem(const Item& item) {
#ifndef NDEBUG
#if DCHECK_IS_ON()
if (item.type_ == MENUITEMTYPE_SEPARATOR) {
DCHECK_EQ(item.command_id_, kSeparatorId);
} else {
DCHECK_GE(item.command_id_, 0);
}
#endif // NDEBUG
#endif
}
void CefMenuModelImpl::OnMenuClosed() {

View File

@@ -21,6 +21,11 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/renderer_preferences.h"
#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
#include "ui/events/keycodes/keysym_to_unicode.h"
#include "ui/gfx/font_render_params.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#include "ui/views/widget/widget.h"
@@ -232,7 +237,8 @@ void CefBrowserPlatformDelegateNativeLinux::ViewText(const std::string& text) {
std::string openCommand("xdg-open ");
openCommand += newName;
system(openCommand.c_str());
int result = system(openCommand.c_str());
ALLOW_UNUSED_LOCAL(result);
}
void CefBrowserPlatformDelegateNativeLinux::HandleKeyboardEvent(
@@ -267,6 +273,17 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
NOTREACHED();
}
// Populate DOM values that will be passed to JavaScript handlers via
// KeyboardEvent.
result.domCode =
static_cast<int>(ui::KeycodeConverter::NativeKeycodeToDomCode(
key_event.native_key_code));
int keysym = ui::XKeysymForWindowsKeyCode(
static_cast<ui::KeyboardCode>(key_event.windows_key_code),
!!(key_event.modifiers & EVENTFLAG_SHIFT_DOWN));
base::char16 ch = ui::GetUnicodeCharacterFromXKeySym(keysym);
result.domKey = static_cast<int>(ui::XKeySymToDomKey(keysym, ch));
result.text[0] = key_event.character;
result.unmodifiedText[0] = key_event.unmodified_character;

View File

@@ -70,18 +70,6 @@
browser_ = browser;
[window_ setDelegate:self];
// Register for application hide/unhide notifications.
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(applicationDidHide:)
name:NSApplicationDidHideNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(applicationDidUnhide:)
name:NSApplicationDidUnhideNotification
object:nil];
}
return self;
}
@@ -92,18 +80,6 @@
[super dealloc];
}
// Called when we are activated (when we gain focus).
- (void)windowDidBecomeKey:(NSNotification*)notification {
if (browser_)
browser_->SetFocus(true);
}
// Called when we are deactivated (when we lose focus).
- (void)windowDidResignKey:(NSNotification*)notification {
if (browser_)
browser_->SetFocus(false);
}
- (BOOL)windowShouldClose:(id)window {
if (browser_ && !browser_->TryCloseBrowser()) {
// Cancel the close.
@@ -217,12 +193,12 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
parentView = [newWnd contentView];
window_info_.parent_view = parentView;
}
// Make the content view for the window have a layer. This will make all
// sub-views have layers. This is necessary to ensure correct layer
// ordering of all child views and their layers.
[[[parentView window] contentView] setWantsLayer:YES];
// Make the content view for the window have a layer. This will make all
// sub-views have layers. This is necessary to ensure correct layer
// ordering of all child views and their layers.
[parentView setWantsLayer:YES];
}
host_window_created_ = true;

View File

@@ -17,6 +17,7 @@
#include "libcef/browser/thread_util.h"
#include "base/files/file_util.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/registry.h"
#include "content/public/browser/native_web_keyboard_event.h"
@@ -24,6 +25,10 @@
#include "ui/base/win/shell.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion_win.h"
#include "ui/events/keycodes/platform_key_map_win.h"
#include "ui/gfx/win/hwnd_util.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
#include "ui/views/widget/widget.h"
@@ -381,6 +386,21 @@ void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
NOTREACHED();
}
// Populate DOM values that will be passed to JavaScript handlers via
// KeyboardEvent.
result.domCode =
static_cast<int>(ui::KeycodeConverter::NativeKeycodeToDomCode(
key_event.native_key_code));
if (result.type == blink::WebInputEvent::Char) {
result.domKey = ui::DomKey::FromCharacter(key_event.windows_key_code);
} else {
// TODO(cef): CefKeyEvent does not currently pass extended key status (see
// WM_KEYDOWN docs) which would be necessary to pass EF_IS_EXTENDED_KEY as
// the |flags| parameter to DomKeyFromKeyboardCode().
result.domKey = ui::PlatformKeyMap::DomKeyFromKeyboardCode(
ui::KeyboardCodeForWindowsKeyCode(key_event.windows_key_code), 0);
}
if (result.type == blink::WebInputEvent::Char ||
result.type == blink::WebInputEvent::RawKeyDown) {
result.text[0] = result.windowsKeyCode;

View File

@@ -16,11 +16,11 @@
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "cef/grit/cef_strings.h"
#include "content/public/common/file_chooser_params.h"
#include "grit/cef_strings.h"
#include "grit/ui_strings.h"
#include "net/base/mime_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/strings/grit/ui_strings.h"
namespace {
@@ -235,8 +235,8 @@ namespace {
void RunOpenFileDialog(
const CefFileDialogRunner::FileChooserParams& params,
NSView* view,
int* filter_index,
std::vector<base::FilePath>* files) {
int filter_index,
CefFileDialogRunner::RunFileChooserCallback callback) {
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
base::string16 title;
@@ -277,8 +277,8 @@ void RunOpenFileDialog(
// Add the file filter control.
filter_delegate =
[[CefFilterDelegate alloc] initWithPanel:openPanel
andAcceptFilters:params.accept_types
andFilterIndex:*filter_index];
andAcceptFilters:params.accept_types
andFilterIndex:filter_index];
}
// Further panel configuration.
@@ -294,28 +294,27 @@ void RunOpenFileDialog(
// Show panel.
[openPanel beginSheetModalForWindow:[view window]
completionHandler:^(NSInteger returnCode) {
[NSApp stopModalWithCode:returnCode];
}];
NSInteger result = [NSApp runModalForWindow:[view window]];
if (result == NSFileHandlingPanelOKButton) {
NSArray *urls = [openPanel URLs];
int i, count = [urls count];
for (i=0; i<count; i++) {
NSURL* url = [urls objectAtIndex:i];
if ([url isFileURL])
files->push_back(base::FilePath(base::SysNSStringToUTF8([url path])));
int filter_index_to_use =
(filter_delegate != nil) ? [filter_delegate filter] : filter_index;
if (returnCode == NSFileHandlingPanelOKButton) {
std::vector<base::FilePath> files;
files.reserve(openPanel.URLs.count);
for (NSURL* url in openPanel.URLs) {
if (url.isFileURL)
files.push_back(base::FilePath(url.path.UTF8String));
}
callback.Run(filter_index_to_use, files);
} else {
callback.Run(filter_index_to_use, std::vector<base::FilePath>());
}
}
if (filter_delegate != nil)
*filter_index = [filter_delegate filter];
}];
}
bool RunSaveFileDialog(
void RunSaveFileDialog(
const CefFileDialogRunner::FileChooserParams& params,
NSView* view,
int* filter_index,
base::FilePath* file) {
int filter_index,
CefFileDialogRunner::RunFileChooserCallback callback) {
NSSavePanel* savePanel = [NSSavePanel savePanel];
base::string16 title;
@@ -349,32 +348,27 @@ bool RunSaveFileDialog(
// Add the file filter control.
filter_delegate =
[[CefFilterDelegate alloc] initWithPanel:savePanel
andAcceptFilters:params.accept_types
andFilterIndex:*filter_index];
andAcceptFilters:params.accept_types
andFilterIndex:filter_index];
}
[savePanel setAllowsOtherFileTypes:YES];
[savePanel setShowsHiddenFiles:!params.hidereadonly];
bool success = false;
// Show panel.
[savePanel beginSheetModalForWindow:[view window]
[savePanel beginSheetModalForWindow:view.window
completionHandler:^(NSInteger resultCode) {
[NSApp stopModalWithCode:resultCode];
int filter_index_to_use =
(filter_delegate != nil) ? [filter_delegate filter] : filter_index;
if (resultCode == NSFileHandlingPanelOKButton) {
NSURL* url = savePanel.URL;
const char* path = url.path.UTF8String;
std::vector<base::FilePath> files(1, base::FilePath(path));
callback.Run(filter_index_to_use, files);
} else {
callback.Run(filter_index_to_use, std::vector<base::FilePath>());
}
}];
NSInteger result = [NSApp runModalForWindow:[view window]];
if (result == NSFileHandlingPanelOKButton) {
NSURL* url = [savePanel URL];
NSString* path = [url path];
*file = base::FilePath([path UTF8String]);
success = true;
}
if (filter_delegate != nil)
*filter_index = [filter_delegate filter];
return success;
}
} // namespace
@@ -385,22 +379,16 @@ CefFileDialogRunnerMac::CefFileDialogRunnerMac() {
void CefFileDialogRunnerMac::Run(CefBrowserHostImpl* browser,
const FileChooserParams& params,
RunFileChooserCallback callback) {
std::vector<base::FilePath> files;
int filter_index = params.selected_accept_filter;
NSView* owner = browser->GetWindowHandle();
if (params.mode == content::FileChooserParams::Open ||
params.mode == content::FileChooserParams::OpenMultiple ||
params.mode == content::FileChooserParams::UploadFolder) {
RunOpenFileDialog(params, owner, &filter_index, &files);
RunOpenFileDialog(params, owner, filter_index, callback);
} else if (params.mode == content::FileChooserParams::Save) {
base::FilePath file;
if (RunSaveFileDialog(params, owner, &filter_index, &file)) {
files.push_back(file);
}
RunSaveFileDialog(params, owner, filter_index, callback);
} else {
NOTIMPLEMENTED();
}
callback.Run(filter_index, files);
}

View File

@@ -16,11 +16,11 @@
#include "base/strings/utf_string_conversions.h"
#include "base/win/registry.h"
#include "base/win/scoped_comptr.h"
#include "grit/cef_strings.h"
#include "grit/ui_strings.h"
#include "cef/grit/cef_strings.h"
#include "net/base/mime_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/win/shell.h"
#include "ui/strings/grit/ui_strings.h"
namespace {

View File

@@ -258,16 +258,15 @@ class NativeMenuWin::MenuHostWindow {
gfx::Image icon;
if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) {
// We currently don't support items with both icons and checkboxes.
const gfx::ImageSkia* skia_icon = icon.ToImageSkia();
const gfx::ImageSkia skia_icon = icon.AsImageSkia();
DCHECK(type != ui::MenuModel::TYPE_CHECK);
gfx::Canvas canvas(
skia_icon->GetRepresentation(1.0f),
false);
gfx::Canvas canvas(skia_icon.size(), 1.0f, false);
canvas.DrawImageInt(skia_icon, 0, 0);
skia::DrawToNativeContext(
canvas.sk_canvas(), dc,
draw_item_struct->rcItem.left + kItemLeftMargin,
draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom -
draw_item_struct->rcItem.top - skia_icon->height()) / 2, NULL);
draw_item_struct->rcItem.top - skia_icon.height()) / 2, NULL);
} else if (type == ui::MenuModel::TYPE_CHECK &&
data->native_menu_win->model_->IsItemCheckedAt(
data->model_index)) {

View File

@@ -26,12 +26,12 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "cef/grit/cef_resources.h"
#include "components/grit/components_resources.h"
#include "content/browser/net/view_http_cache_job_factory.h"
#include "content/browser/net/view_blob_internals_job_factory.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/user_agent.h"
#include "grit/cef_resources.h"
#include "grit/components_resources.h"
#include "ipc/ipc_channel.h"
#include "net/url_request/url_request.h"
#include "ui/base/webui/web_ui_util.h"
@@ -281,6 +281,7 @@ class Delegate : public InternalHandlerDelegate {
} else {
action->mime_type = "text/html";
action->resource_id = IDR_ABOUT_UI_CREDITS_HTML;
action->encoding = Action::ENCODING_BROTLI;
}
return true;
}

View File

@@ -11,8 +11,8 @@
#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "blink/grit/devtools_resources_map.h"
#include "content/public/common/url_constants.h"
#include "grit/devtools_resources_map.h"
namespace scheme {

View File

@@ -14,6 +14,7 @@
#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 {
@@ -28,7 +29,7 @@ base::FilePath FilePathFromASCII(const std::string& str) {
#endif
}
static std::string GetMimeType(const std::string& filename) {
std::string GetMimeType(const std::string& filename) {
// Requests should not block on the disk! On POSIX this goes to disk.
// http://code.google.com/p/chromium/issues/detail?id=59849
base::ThreadRestrictions::ScopedAllowIO allow_io;
@@ -48,6 +49,24 @@ static 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)
@@ -153,6 +172,16 @@ 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());
@@ -183,7 +212,8 @@ class InternalHandlerFactory : public CefSchemeHandlerFactory {
InternalHandlerDelegate::Action::Action()
: stream_size(-1),
resource_id(-1) {
resource_id(-1),
encoding(ENCODING_NONE) {
}
CefRefPtr<CefSchemeHandlerFactory> CreateInternalHandlerFactory(

View File

@@ -28,8 +28,13 @@ class InternalHandlerDelegate {
CefRefPtr<CefStreamReader> stream;
int stream_size;
// Option 2: Specify a resource id to load static content.
// 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

@@ -18,6 +18,9 @@
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string_util.h"
#include "chrome/browser/net/safe_search_util.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
#include "content/public/common/content_switches.h"
#include "net/base/net_errors.h"
#include "net/filter/filter.h"
@@ -38,10 +41,12 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
CefRefPtr<CefRequestImpl> cef_request,
GURL* new_url,
net::URLRequest* url_request,
bool force_google_safesearch,
const CallbackType& callback)
: cef_request_(cef_request),
new_url_(new_url),
url_request_(url_request),
force_google_safesearch_(force_google_safesearch),
callback_(callback) {
DCHECK(new_url);
DCHECK(url_request_);
@@ -54,11 +59,13 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
if (!callback_.is_null()) {
// The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_IOT()) {
RunNow(cef_request_, new_url_, url_request_, callback_, false);
RunNow(cef_request_, new_url_, url_request_, callback_,
force_google_safesearch_, false);
} else {
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefBeforeResourceLoadCallbackImpl::RunNow,
cef_request_, new_url_, url_request_, callback_, false));
cef_request_, new_url_, url_request_, callback_,
force_google_safesearch_, false));
}
}
}
@@ -77,7 +84,8 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
void ContinueNow(bool allow) {
CEF_REQUIRE_IOT();
if (!callback_.is_null()) {
RunNow(cef_request_, new_url_, url_request_, callback_, allow);
RunNow(cef_request_, new_url_, url_request_, callback_,
force_google_safesearch_, allow);
Disconnect();
}
}
@@ -115,6 +123,7 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
GURL* new_url,
net::URLRequest* request,
const CallbackType& callback,
bool force_google_safesearch,
bool allow) {
CEF_REQUIRE_IOT();
@@ -139,8 +148,12 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
request->RemoveUserData(UserDataKey());
// Only execute the callback if the request has not been canceled.
if (request->status().status() != net::URLRequestStatus::CANCELED)
if (request->status().status() != net::URLRequestStatus::CANCELED) {
if (force_google_safesearch && allow && new_url->is_empty())
safe_search_util::ForceGoogleSafeSearch(request, new_url);
callback.Run(allow ? net::OK : net::ERR_ABORTED);
}
}
static inline void* UserDataKey() {
@@ -151,6 +164,7 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
const GURL old_url_;
GURL* new_url_;
net::URLRequest* url_request_;
bool force_google_safesearch_;
CallbackType callback_;
// The user data key.
@@ -224,7 +238,8 @@ class CefAuthCallbackImpl : public CefAuthCallback {
} // namespace
CefNetworkDelegate::CefNetworkDelegate() {
CefNetworkDelegate::CefNetworkDelegate()
: force_google_safesearch_(nullptr) {
}
CefNetworkDelegate::~CefNetworkDelegate() {
@@ -255,6 +270,9 @@ int CefNetworkDelegate::OnBeforeURLRequest(
net::URLRequest* request,
const net::CompletionCallback& callback,
GURL* new_url) {
const bool force_google_safesearch =
(force_google_safesearch_ && force_google_safesearch_->GetValue());
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForRequest(request);
if (browser.get()) {
@@ -279,6 +297,7 @@ int CefNetworkDelegate::OnBeforeURLRequest(
CefRefPtr<CefBeforeResourceLoadCallbackImpl> callbackImpl(
new CefBeforeResourceLoadCallbackImpl(requestPtr, new_url, request,
force_google_safesearch,
callback));
// Give the client an opportunity to evaluate the request.
@@ -298,6 +317,9 @@ int CefNetworkDelegate::OnBeforeURLRequest(
}
}
if (force_google_safesearch && new_url->is_empty())
safe_search_util::ForceGoogleSafeSearch(request, new_url);
// Continue the request immediately.
return net::OK;
}

View File

@@ -9,6 +9,9 @@
#include "base/macros.h"
#include "net/base/network_delegate_impl.h"
template<class T> class PrefMember;
typedef PrefMember<bool> BooleanPrefMember;
// Used for intercepting resource requests, redirects and responses. The single
// instance of this class is managed by CefURLRequestContextGetter.
class CefNetworkDelegate : public net::NetworkDelegateImpl {
@@ -21,6 +24,11 @@ class CefNetworkDelegate : public net::NetworkDelegateImpl {
static bool AreExperimentalCookieFeaturesEnabled();
static bool AreStrictSecureCookiesEnabled();
void set_force_google_safesearch(
BooleanPrefMember* force_google_safesearch) {
force_google_safesearch_ = force_google_safesearch;
}
private:
// net::NetworkDelegate methods.
int OnBeforeURLRequest(net::URLRequest* request,
@@ -39,6 +47,9 @@ class CefNetworkDelegate : public net::NetworkDelegateImpl {
net::Filter* SetupFilter(net::URLRequest* request,
net::Filter* filter_list) override;
// Weak, owned by our owner (CefURLRequestContextGetterImpl).
BooleanPrefMember* force_google_safesearch_;
DISALLOW_COPY_AND_ASSIGN(CefNetworkDelegate);
};

View File

@@ -287,15 +287,6 @@ void CefResourceRequestJob::GetLoadTimingInfo(
load_timing_info->receive_headers_end = receive_headers_end_;
}
bool CefResourceRequestJob::GetResponseCookies(
std::vector<std::string>* cookies) {
CEF_REQUIRE_IOT();
cookies->clear();
FetchResponseCookies(cookies);
return true;
}
bool CefResourceRequestJob::IsRedirectResponse(GURL* location,
int* http_status_code) {
CEF_REQUIRE_IOT();

View File

@@ -39,7 +39,6 @@ class CefResourceRequestJob : public net::URLRequestJob {
void GetResponseInfo(net::HttpResponseInfo* info) override;
void GetLoadTimingInfo(
net::LoadTimingInfo* load_timing_info) const override;
bool GetResponseCookies(std::vector<std::string>* cookies) override;
bool IsRedirectResponse(GURL* location, int* http_status_code)
override;
bool GetMimeType(std::string* mime_type) const override;

View File

@@ -4,18 +4,18 @@
#include "libcef/browser/net/url_request_context.h"
#ifndef NDEBUG
#if DCHECK_IS_ON()
base::AtomicRefCount CefURLRequestContext::DebugObjCt = 0;
#endif
CefURLRequestContext::CefURLRequestContext() {
#ifndef NDEBUG
#if DCHECK_IS_ON()
base::AtomicRefCountInc(&DebugObjCt);
#endif
}
CefURLRequestContext::~CefURLRequestContext() {
#ifndef NDEBUG
#if DCHECK_IS_ON()
base::AtomicRefCountDec(&DebugObjCt);
#endif
}

View File

@@ -6,6 +6,7 @@
#define CEF_LIBCEF_BROWSER_NET_URL_REQUEST_CONTEXT_H_
#pragma once
#include "base/logging.h"
#include "net/url_request/url_request_context.h"
// Owns URLRequest instances and provides access to network-related
@@ -18,7 +19,7 @@ class CefURLRequestContext : public net::URLRequestContext {
CefURLRequestContext();
~CefURLRequestContext() override;
#ifndef NDEBUG
#if DCHECK_IS_ON()
// Simple tracking of allocated objects.
static base::AtomicRefCount DebugObjCt; // NOLINT(runtime/int)
#endif

View File

@@ -27,12 +27,17 @@
#include "build/build_config.h"
#include "chrome/browser/net/proxy_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "net/cert/cert_verifier.h"
#include "net/cert/ct_known_logs.h"
#include "net/cert/ct_log_verifier.h"
#include "net/cert/ct_policy_enforcer.h"
#include "net/cert/multi_log_ct_verifier.h"
#include "net/cookies/cookie_monster.h"
#include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
#include "net/dns/host_resolver.h"
@@ -120,6 +125,19 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
std::swap(protocol_handlers_, *protocol_handlers);
auto io_thread_proxy =
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
quick_check_enabled_.Init(prefs::kQuickCheckEnabled, pref_service);
quick_check_enabled_.MoveToThread(io_thread_proxy);
pac_https_url_stripping_enabled_.Init(prefs::kPacHttpsUrlStrippingEnabled,
pref_service);
pac_https_url_stripping_enabled_.MoveToThread(io_thread_proxy);
force_google_safesearch_.Init(prefs::kForceGoogleSafeSearch, pref_service);
force_google_safesearch_.MoveToThread(io_thread_proxy);
#if defined(OS_POSIX) && !defined(OS_ANDROID)
gsapi_library_name_ = pref_service->GetString(prefs::kGSSAPILibraryName);
#endif
@@ -134,6 +152,27 @@ CefURLRequestContextGetterImpl::~CefURLRequestContextGetterImpl() {
storage_->set_proxy_service(NULL);
}
// static
void CefURLRequestContextGetterImpl::RegisterPrefs(
PrefRegistrySimple* registry) {
// Based on IOThread::RegisterPrefs.
#if defined(OS_POSIX) && !defined(OS_ANDROID)
registry->RegisterStringPref(prefs::kGSSAPILibraryName, std::string());
#endif
registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true);
registry->RegisterBooleanPref(prefs::kPacHttpsUrlStrippingEnabled, true);
// Based on ProfileImpl::RegisterProfilePrefs.
registry->RegisterBooleanPref(prefs::kForceGoogleSafeSearch, false);
}
void CefURLRequestContextGetterImpl::ShutdownOnUIThread() {
CEF_REQUIRE_UIT();
quick_check_enabled_.Destroy();
pac_https_url_stripping_enabled_.Destroy();
force_google_safesearch_.Destroy();
}
net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
CEF_REQUIRE_IOT();
@@ -152,7 +191,10 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
SetCookieStoragePath(cache_path,
settings_.persist_session_cookies ? true : false);
storage_->set_network_delegate(base::WrapUnique(new CefNetworkDelegate));
std::unique_ptr<CefNetworkDelegate> network_delegate(
new CefNetworkDelegate());
network_delegate->set_force_google_safesearch(&force_google_safesearch_);
storage_->set_network_delegate(std::move(network_delegate));
storage_->set_channel_id_service(base::WrapUnique(
new net::ChannelIDService(
@@ -167,8 +209,25 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
storage_->set_host_resolver(net::HostResolver::CreateDefaultResolver(NULL));
storage_->set_cert_verifier(net::CertVerifier::CreateDefault());
storage_->set_transport_security_state(
base::WrapUnique(new net::TransportSecurityState));
std::unique_ptr<net::TransportSecurityState> transport_security_state(
new net::TransportSecurityState);
transport_security_state->set_enforce_net_security_expiration(
settings_.enable_net_security_expiration ? true : false);
storage_->set_transport_security_state(std::move(transport_security_state));
std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs(
net::ct::CreateLogVerifiersForKnownLogs());
std::unique_ptr<net::MultiLogCTVerifier> ct_verifier(
new net::MultiLogCTVerifier());
ct_verifier->AddLogs(ct_logs);
storage_->set_cert_transparency_verifier(std::move(ct_verifier));
std::unique_ptr<net::CTPolicyEnforcer> ct_policy_enforcer(
new net::CTPolicyEnforcer);
ct_policy_enforcer->set_enforce_net_security_expiration(
settings_.enable_net_security_expiration ? true : false);
storage_->set_ct_policy_enforcer(std::move(ct_policy_enforcer));
std::unique_ptr<net::ProxyService> system_proxy_service =
ProxyServiceFactory::CreateProxyService(
@@ -177,7 +236,8 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
url_request_context_->network_delegate(),
std::move(proxy_config_service_),
*command_line,
true);
quick_check_enabled_.GetValue(),
pac_https_url_stripping_enabled_.GetValue());
storage_->set_proxy_service(std::move(system_proxy_service));
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
@@ -202,11 +262,14 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
storage_->set_http_server_properties(base::WrapUnique(
new net::HttpServerPropertiesImpl));
base::FilePath http_cache_path;
if (!cache_path.empty())
http_cache_path = cache_path.Append(FILE_PATH_LITERAL("Cache"));
std::unique_ptr<net::HttpCache::DefaultBackend> main_backend(
new net::HttpCache::DefaultBackend(
cache_path.empty() ? net::MEMORY_CACHE : net::DISK_CACHE,
net::CACHE_BACKEND_DEFAULT,
cache_path,
http_cache_path,
0,
BrowserThread::GetMessageLoopProxyForThread(
BrowserThread::CACHE)));
@@ -218,6 +281,10 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
url_request_context_->cert_verifier();
network_session_params.transport_security_state =
url_request_context_->transport_security_state();
network_session_params.cert_transparency_verifier =
url_request_context_->cert_transparency_verifier();
network_session_params.ct_policy_enforcer =
url_request_context_->ct_policy_enforcer();
network_session_params.channel_id_service =
url_request_context_->channel_id_service();
network_session_params.proxy_service =

View File

@@ -17,9 +17,11 @@
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "components/prefs/pref_member.h"
#include "content/public/browser/browser_context.h"
#include "net/url_request/url_request_job_factory.h"
class PrefRegistrySimple;
class PrefService;
namespace base {
@@ -52,6 +54,12 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
content::URLRequestInterceptorScopedVector request_interceptors);
~CefURLRequestContextGetterImpl() override;
// Register preferences. Called from browser_prefs::CreatePrefService().
static void RegisterPrefs(PrefRegistrySimple* registry);
// Called when the BrowserContextImpl is destroyed.
void ShutdownOnUIThread();
// net::URLRequestContextGetter implementation.
net::URLRequestContext* GetURLRequestContext() override;
scoped_refptr<base::SingleThreadTaskRunner>
@@ -102,6 +110,12 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
std::vector<CefRefPtr<CefRequestContextHandler> > handler_list_;
BooleanPrefMember quick_check_enabled_;
BooleanPrefMember pac_https_url_stripping_enabled_;
// Member variables which are pointed to by the various context objects.
mutable BooleanPrefMember force_google_safesearch_;
DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetterImpl);
};

View File

@@ -274,7 +274,7 @@ net::URLRequestJob* CefURLRequestManager::GetRequestJob(
job = GetBuiltinSchemeRequestJob(request, network_delegate, scheme);
}
#ifndef NDEBUG
#if DCHECK_IS_ON()
if (job)
DLOG(INFO) << "CefURLRequestManager hit for " << request->url().spec();
#endif

View File

@@ -217,16 +217,19 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragEnter(
if (!rvh)
return;
drag_data_ = drag_data;
CefDragDataImpl* data_impl = static_cast<CefDragDataImpl*>(drag_data.get());
base::AutoLock lock_scope(data_impl->lock());
const content::DropData& drop_data = data_impl->drop_data();
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->DragTargetDragEnter(drop_data, client_pt, screen_pt, ops, modifiers);
rvh->FilterDropData(drop_data);
rvh->DragTargetDragEnter(*drop_data, client_pt, screen_pt, ops, modifiers);
}
void CefBrowserPlatformDelegateOsr::DragTargetDragOver(
@@ -258,11 +261,19 @@ void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) {
if (!rvh)
return;
const gfx::Point client_pt(event.x, event.y);
const gfx::Point& screen_pt = GetScreenPoint(client_pt);
int modifiers = TranslateModifiers(event.modifiers);
{
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);
int modifiers = TranslateModifiers(event.modifiers);
rvh->DragTargetDrop(client_pt, screen_pt, modifiers);
rvh->DragTargetDrop(*drop_data, client_pt, screen_pt, modifiers);
}
drag_data_ = nullptr;
}
void CefBrowserPlatformDelegateOsr::DragSourceEndedAt(

View File

@@ -83,6 +83,9 @@ class CefBrowserPlatformDelegateOsr :
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate_;
CefWebContentsViewOSR* view_osr_; // Not owned by this class.
// Pending drag/drop data.
CefRefPtr<CefDragData> drag_data_;
};
#endif // CEF_LIBCEF_BROWSER_OSR_BROWSER_PLATFORM_DELEGATE_OSR_H_

View File

@@ -45,12 +45,6 @@ const float kDefaultScaleFactor = 1.0;
// The maximum number of retry counts if frame capture fails.
const int kFrameRetryLimit = 2;
// When accelerated compositing is enabled and a widget resize is pending,
// we delay further resizes of the UI. The following constant is the maximum
// length of time that we should delay further UI resizes while waiting for a
// resized frame from a renderer.
const int kResizeLockTimeoutMs = 67;
static blink::WebScreenInfo webScreenInfoFrom(const CefScreenInfo& src) {
blink::WebScreenInfo webScreenInfo;
webScreenInfo.deviceScaleFactor = src.device_scale_factor;
@@ -67,6 +61,14 @@ static blink::WebScreenInfo webScreenInfoFrom(const CefScreenInfo& src) {
return webScreenInfo;
}
#if !defined(OS_MACOSX)
// When accelerated compositing is enabled and a widget resize is pending,
// we delay further resizes of the UI. The following constant is the maximum
// length of time that we should delay further UI resizes while waiting for a
// resized frame from a renderer.
const int kResizeLockTimeoutMs = 67;
// Used to prevent further resizes while a resize is pending.
class CefResizeLock : public content::ResizeLock {
public:
@@ -104,7 +106,7 @@ class CefResizeLock : public content::ResizeLock {
protected:
void LockCompositor() override {
ResizeLock::LockCompositor();
compositor_lock_ = host_->compositor()->GetCompositorLock();
compositor_lock_ = host_->GetCompositor()->GetCompositorLock();
}
void CancelLock() {
@@ -124,6 +126,8 @@ class CefResizeLock : public content::ResizeLock {
DISALLOW_COPY_AND_ASSIGN(CefResizeLock);
};
#endif // !defined(OS_MACOSX)
} // namespace
// Used for managing copy requests when GPU compositing is enabled. Based on
@@ -202,8 +206,7 @@ class CefCopyFrameGenerator {
damage_rect));
request->set_area(gfx::Rect(view_->GetPhysicalBackingSize()));
view_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput(
std::move(request));
view_->GetRootLayer()->RequestCopyOfOutput(std::move(request));
}
void CopyFromCompositingSurfaceHasResult(
@@ -409,9 +412,11 @@ class CefBeginFrameTimer : public cc::DelayBasedTimeSourceClient {
CefBeginFrameTimer(int frame_rate_threshold_ms,
const base::Closure& callback)
: callback_(callback) {
time_source_ = cc::DelayBasedTimeSource::Create(
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms),
content::BrowserThread::GetMessageLoopProxyForThread(CEF_UIT).get());
time_source_.reset(new cc::DelayBasedTimeSource(
content::BrowserThread::GetMessageLoopProxyForThread(CEF_UIT).get()));
time_source_->SetTimebaseAndInterval(
base::TimeTicks(),
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms));
time_source_->SetClient(this);
}
@@ -449,8 +454,10 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
: transparent_(transparent),
scale_factor_(kDefaultScaleFactor),
frame_rate_threshold_ms_(0),
delegated_frame_host_(new content::DelegatedFrameHost(this)),
#if !defined(OS_MACOSX)
compositor_widget_(gfx::kNullAcceleratedWidget),
delegated_frame_host_(new content::DelegatedFrameHost(this)),
#endif
software_output_device_(NULL),
hold_resize_(false),
pending_resize_(false),
@@ -475,38 +482,48 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
content::RenderViewHost::From(render_widget_host_));
}
#if !defined(OS_MACOSX)
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
#endif
PlatformCreateCompositorWidget();
#if !defined(OS_MACOSX)
// On OS X the ui::Compositor is created/owned by the platform view.
compositor_.reset(
new ui::Compositor(content::GetContextFactory(),
base::ThreadTaskRunnerHandle::Get()));
compositor_->SetAcceleratedWidget(compositor_widget_);
#endif
compositor_->SetDelegate(this);
compositor_->SetRootLayer(root_layer_.get());
#endif
if (browser_impl_.get())
ResizeRootLayer();
}
CefRenderWidgetHostViewOSR::~CefRenderWidgetHostViewOSR() {
#if defined(OS_MACOSX)
if (is_showing_)
browser_compositor_->SetRenderWidgetHostIsHidden(true);
#else
// Marking the DelegatedFrameHost as removed from the window hierarchy is
// necessary to remove all connections to its old ui::Compositor.
if (is_showing_)
delegated_frame_host_->WasHidden();
delegated_frame_host_->ResetCompositor();
#endif
PlatformDestroyCompositorWidget();
if (copy_frame_generator_.get())
copy_frame_generator_.reset(NULL);
#if !defined(OS_MACOSX)
delegated_frame_host_.reset(NULL);
compositor_.reset(NULL);
root_layer_.reset(NULL);
#endif
DCHECK(parent_host_view_ == NULL);
DCHECK(popup_host_view_ == NULL);
@@ -570,7 +587,7 @@ bool CefRenderWidgetHostViewOSR::HasFocus() const {
}
bool CefRenderWidgetHostViewOSR::IsSurfaceAvailableForCopy() const {
return delegated_frame_host_->CanCopyToBitmap();
return GetDelegatedFrameHost()->CanCopyToBitmap();
}
void CefRenderWidgetHostViewOSR::Show() {
@@ -578,10 +595,16 @@ void CefRenderWidgetHostViewOSR::Show() {
return;
is_showing_ = true;
if (render_widget_host_)
render_widget_host_->WasShown(ui::LatencyInfo());
#if defined(OS_MACOSX)
browser_compositor_->SetRenderWidgetHostIsHidden(false);
#else
delegated_frame_host_->SetCompositor(compositor_.get());
delegated_frame_host_->WasShown(ui::LatencyInfo());
#endif
if (render_widget_host_)
render_widget_host_->WasShown(ui::LatencyInfo());
}
void CefRenderWidgetHostViewOSR::Hide() {
@@ -593,8 +616,14 @@ void CefRenderWidgetHostViewOSR::Hide() {
if (render_widget_host_)
render_widget_host_->WasHidden();
delegated_frame_host_->WasHidden();
delegated_frame_host_->ResetCompositor();
#if defined(OS_MACOSX)
browser_compositor_->SetRenderWidgetHostIsHidden(true);
#else
GetDelegatedFrameHost()->WasHidden();
GetDelegatedFrameHost()->ResetCompositor();
#endif
is_showing_ = false;
}
@@ -637,11 +666,11 @@ void CefRenderWidgetHostViewOSR::UnlockMouse() {
void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
uint32_t output_surface_id,
std::unique_ptr<cc::CompositorFrame> frame) {
cc::CompositorFrame frame) {
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::OnSwapCompositorFrame");
if (frame->metadata.root_scroll_offset != last_scroll_offset_) {
last_scroll_offset_ = frame->metadata.root_scroll_offset;
if (frame.metadata.root_scroll_offset != last_scroll_offset_) {
last_scroll_offset_ = frame.metadata.root_scroll_offset;
if (!is_scroll_offset_changed_pending_) {
// Send the notification asnychronously.
@@ -651,7 +680,7 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
}
}
if (frame->delegated_frame_data) {
if (frame.delegated_frame_data) {
if (software_output_device_) {
if (!begin_frame_timer_.get()) {
// If BeginFrame scheduling is enabled SoftwareOutputDevice activity
@@ -662,8 +691,13 @@ 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));
#else
delegated_frame_host_->SwapDelegatedFrame(output_surface_id,
std::move(frame));
#endif
} else {
if (!copy_frame_generator_.get()) {
copy_frame_generator_.reset(
@@ -673,14 +707,19 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
// Determine the damage rectangle for the current frame. This is the same
// calculation that SwapDelegatedFrame uses.
cc::RenderPass* root_pass =
frame->delegated_frame_data->render_pass_list.back().get();
frame.delegated_frame_data->render_pass_list.back().get();
gfx::Size frame_size = root_pass->output_rect.size();
gfx::Rect damage_rect =
gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect));
damage_rect.Intersect(gfx::Rect(frame_size));
#if defined(OS_MACOSX)
browser_compositor_->SwapCompositorFrame(output_surface_id,
std::move(frame));
#else
delegated_frame_host_->SwapDelegatedFrame(output_surface_id,
std::move(frame));
#endif
// Request a copy of the last compositor frame which will eventually call
// OnPaint asynchronously.
@@ -692,7 +731,7 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
}
void CefRenderWidgetHostViewOSR::ClearCompositorFrame() {
delegated_frame_host_->ClearDelegatedFrame();
GetDelegatedFrameHost()->ClearDelegatedFrame();
}
void CefRenderWidgetHostViewOSR::InitAsPopup(
@@ -833,7 +872,7 @@ void CefRenderWidgetHostViewOSR::SetTooltipText(
}
gfx::Size CefRenderWidgetHostViewOSR::GetRequestedRendererSize() const {
return delegated_frame_host_->GetRequestedRendererSize();
return GetDelegatedFrameHost()->GetRequestedRendererSize();
}
gfx::Size CefRenderWidgetHostViewOSR::GetPhysicalBackingSize() const {
@@ -851,7 +890,7 @@ void CefRenderWidgetHostViewOSR::CopyFromCompositingSurface(
const gfx::Size& dst_size,
const content::ReadbackRequestCallback& callback,
const SkColorType color_type) {
delegated_frame_host_->CopyFromCompositingSurface(
GetDelegatedFrameHost()->CopyFromCompositingSurface(
src_subrect, dst_size, callback, color_type);
}
@@ -859,21 +898,21 @@ void CefRenderWidgetHostViewOSR::CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
const scoped_refptr<media::VideoFrame>& target,
const base::Callback<void(const gfx::Rect&, bool)>& callback) {
delegated_frame_host_->CopyFromCompositingSurfaceToVideoFrame(
GetDelegatedFrameHost()->CopyFromCompositingSurfaceToVideoFrame(
src_subrect, target, callback);
}
bool CefRenderWidgetHostViewOSR::CanCopyToVideoFrame() const {
return delegated_frame_host_->CanCopyToVideoFrame();
return GetDelegatedFrameHost()->CanCopyToVideoFrame();
}
void CefRenderWidgetHostViewOSR::BeginFrameSubscription(
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber> subscriber) {
delegated_frame_host_->BeginFrameSubscription(std::move(subscriber));
GetDelegatedFrameHost()->BeginFrameSubscription(std::move(subscriber));
}
void CefRenderWidgetHostViewOSR::EndFrameSubscription() {
delegated_frame_host_->EndFrameSubscription();
GetDelegatedFrameHost()->EndFrameSubscription();
}
bool CefRenderWidgetHostViewOSR::HasAcceleratedSurface(
@@ -919,13 +958,6 @@ void CefRenderWidgetHostViewOSR::GetScreenInfo(blink::WebScreenInfo* results) {
*results = webScreenInfoFrom(screen_info);
}
bool CefRenderWidgetHostViewOSR::GetScreenColorProfile(
std::vector<char>* color_profile) {
DCHECK(color_profile->empty());
// TODO(cef): Maybe expose this method to the client?
return false;
}
gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() {
if (!browser_impl_.get())
return gfx::Rect();
@@ -996,7 +1028,7 @@ void CefRenderWidgetHostViewOSR::OnSetNeedsBeginFrames(bool enabled) {
std::unique_ptr<cc::SoftwareOutputDevice>
CefRenderWidgetHostViewOSR::CreateSoftwareOutputDevice(
ui::Compositor* compositor) {
DCHECK_EQ(compositor_.get(), compositor);
DCHECK_EQ(GetCompositor(), compositor);
DCHECK(!copy_frame_generator_);
DCHECK(!software_output_device_);
software_output_device_ = new CefSoftwareOutputDeviceOSR(
@@ -1006,8 +1038,10 @@ CefRenderWidgetHostViewOSR::CreateSoftwareOutputDevice(
return base::WrapUnique(software_output_device_);
}
#if !defined(OS_MACOSX)
ui::Layer* CefRenderWidgetHostViewOSR::DelegatedFrameHostGetLayer() const {
return root_layer_.get();
return GetRootLayer();
}
bool CefRenderWidgetHostViewOSR::DelegatedFrameHostIsVisible() const {
@@ -1020,8 +1054,7 @@ SkColor CefRenderWidgetHostViewOSR::DelegatedFrameHostGetGutterColor(
// may not match the page's, so use black as the gutter color to avoid
// flashes of brighter colors during the transition.
if (render_widget_host_->delegate() &&
render_widget_host_->delegate()->IsFullscreenForCurrentTab(
render_widget_host_)) {
render_widget_host_->delegate()->IsFullscreenForCurrentTab()) {
return SK_ColorBLACK;
}
return color;
@@ -1029,7 +1062,7 @@ SkColor CefRenderWidgetHostViewOSR::DelegatedFrameHostGetGutterColor(
gfx::Size
CefRenderWidgetHostViewOSR::DelegatedFrameHostDesiredSizeInDIP() const {
return root_layer_->bounds().size();
return GetRootLayer()->bounds().size();
}
bool CefRenderWidgetHostViewOSR::DelegatedFrameCanCreateResizeLock() const {
@@ -1039,7 +1072,7 @@ bool CefRenderWidgetHostViewOSR::DelegatedFrameCanCreateResizeLock() const {
std::unique_ptr<content::ResizeLock>
CefRenderWidgetHostViewOSR::DelegatedFrameHostCreateResizeLock(
bool defer_compositor_lock) {
const gfx::Size& desired_size = root_layer_->bounds().size();
const gfx::Size& desired_size = GetRootLayer()->bounds().size();
return std::unique_ptr<content::ResizeLock>(new CefResizeLock(
this,
desired_size,
@@ -1085,10 +1118,20 @@ void CefRenderWidgetHostViewOSR::SetBeginFrameSource(
// See https://codereview.chromium.org/1841083007.
}
bool CefRenderWidgetHostViewOSR::IsAutoResizeEnabled() const {
return render_widget_host_->auto_resize_enabled();
}
#endif // !defined(OS_MACOSX)
bool CefRenderWidgetHostViewOSR::InstallTransparency() {
if (transparent_) {
SetBackgroundColor(SkColor());
#if defined(OS_MACOSX)
browser_compositor_->SetHasTransparentBackground(true);
#else
compositor_->SetHostHasTransparentBackground(true);
#endif
return true;
}
return false;
@@ -1104,7 +1147,7 @@ void CefRenderWidgetHostViewOSR::WasResized() {
ResizeRootLayer();
if (render_widget_host_)
render_widget_host_->WasResized();
delegated_frame_host_->WasResized();
GetDelegatedFrameHost()->WasResized();
}
void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() {
@@ -1137,13 +1180,7 @@ void CefRenderWidgetHostViewOSR::Invalidate(
const gfx::Rect& bounds_in_pixels = gfx::Rect(GetPhysicalBackingSize());
if (software_output_device_) {
if (IsFramePending()) {
// Include the invalidated region in the next frame generated.
software_output_device_->Invalidate(bounds_in_pixels);
} else {
// Call OnPaint immediately.
software_output_device_->OnPaint(bounds_in_pixels);
}
software_output_device_->OnPaint(bounds_in_pixels);
} else if (copy_frame_generator_.get()) {
copy_frame_generator_->GenerateCopyFrame(true, bounds_in_pixels);
}
@@ -1300,6 +1337,23 @@ void CefRenderWidgetHostViewOSR::RemoveGuestHostView(
guest_host_views_.erase(guest_host);
}
#if !defined(OS_MACOSX)
ui::Compositor* CefRenderWidgetHostViewOSR::GetCompositor() const {
return compositor_.get();
}
ui::Layer* CefRenderWidgetHostViewOSR::GetRootLayer() const {
return root_layer_.get();
}
content::DelegatedFrameHost* CefRenderWidgetHostViewOSR::GetDelegatedFrameHost()
const {
return delegated_frame_host_.get();
}
#endif // !defined(OS_MACOSX)
void CefRenderWidgetHostViewOSR::SetFrameRate() {
CefRefPtr<CefBrowserHostImpl> browser;
if (parent_host_view_) {
@@ -1319,7 +1373,7 @@ void CefRenderWidgetHostViewOSR::SetFrameRate() {
frame_rate_threshold_ms_ = 1000 / frame_rate;
// Configure the VSync interval for the browser process.
compositor_->vsync_manager()->SetAuthoritativeVSyncInterval(
GetCompositor()->vsync_manager()->SetAuthoritativeVSyncInterval(
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms_));
if (copy_frame_generator_.get()) {
@@ -1369,26 +1423,15 @@ void CefRenderWidgetHostViewOSR::ResizeRootLayer() {
else
size = popup_position_.size();
if (!scaleFactorDidChange && size == root_layer_->bounds().size())
if (!scaleFactorDidChange && size == GetRootLayer()->bounds().size())
return;
const gfx::Size& size_in_pixels =
gfx::ConvertSizeToPixel(scale_factor_, size);
root_layer_->SetBounds(gfx::Rect(size));
compositor_->SetScaleAndSize(scale_factor_, size_in_pixels);
}
bool CefRenderWidgetHostViewOSR::IsFramePending() {
if (!IsShowing())
return false;
if (begin_frame_timer_.get())
return begin_frame_timer_->IsActive();
else if (copy_frame_generator_.get())
return copy_frame_generator_->frame_pending();
return false;
GetRootLayer()->SetBounds(gfx::Rect(size));
GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels);
PlatformResizeCompositorWidget(size_in_pixels);
}
void CefRenderWidgetHostViewOSR::OnBeginFrameTimerTick() {

View File

@@ -25,7 +25,6 @@
#if defined(OS_MACOSX)
#include "content/browser/renderer_host/browser_compositor_view_mac.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#endif
#if defined(OS_WIN)
@@ -76,13 +75,17 @@ class CefWindowX11;
// RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
///////////////////////////////////////////////////////////////////////////////
#if defined(OS_MACOSX)
class MacHelper;
#endif
class CefRenderWidgetHostViewOSR
: public content::RenderWidgetHostViewBase,
#if defined(OS_MACOSX)
public ui::AcceleratedWidgetMacNSView,
public ui::CompositorDelegate
#if !defined(OS_MACOSX)
, public content::DelegatedFrameHostClient
#endif
public ui::CompositorDelegate,
public content::DelegatedFrameHostClient {
{
public:
CefRenderWidgetHostViewOSR(const bool transparent,
content::RenderWidgetHost* widget,
@@ -120,9 +123,8 @@ class CefRenderWidgetHostViewOSR
#endif // defined(OS_MACOSX)
// RenderWidgetHostViewBase implementation.
void OnSwapCompositorFrame(
uint32_t output_surface_id,
std::unique_ptr<cc::CompositorFrame> frame) override;
void OnSwapCompositorFrame(uint32_t output_surface_id,
cc::CompositorFrame frame) override;
void ClearCompositorFrame() override;
void InitAsPopup(content::RenderWidgetHostView* parent_host_view,
const gfx::Rect& pos) override;
@@ -163,7 +165,6 @@ class CefRenderWidgetHostViewOSR
void EndFrameSubscription() override;
bool HasAcceleratedSurface(const gfx::Size& desired_size) override;
void GetScreenInfo(blink::WebScreenInfo* results) override;
bool GetScreenColorProfile(std::vector<char>* color_profile) override;
gfx::Rect GetBoundsInRootWindow() override;
content::BrowserAccessibilityManager*
CreateBrowserAccessibilityManager(
@@ -183,14 +184,6 @@ class CefRenderWidgetHostViewOSR
const std::vector<gfx::Rect>& character_bounds) override;
#endif
#if defined(OS_MACOSX)
// AcceleratedWidgetMacNSView implementation.
NSView* AcceleratedWidgetGetNSView() const override;
void AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const override;
void AcceleratedWidgetSwapCompleted() override;
#endif // defined(OS_MACOSX)
bool OnMessageReceived(const IPC::Message& msg) override;
// Message handlers.
@@ -200,6 +193,7 @@ class CefRenderWidgetHostViewOSR
std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(
ui::Compositor* compositor) override;
#if !defined(OS_MACOSX)
// DelegatedFrameHostClient implementation.
ui::Layer* DelegatedFrameHostGetLayer() const override;
bool DelegatedFrameHostIsVisible() const override;
@@ -220,6 +214,8 @@ class CefRenderWidgetHostViewOSR
const base::TimeTicks& timebase,
const base::TimeDelta& interval) override;
void SetBeginFrameSource(cc::BeginFrameSource* source) override;
bool IsAutoResizeEnabled() const override;
#endif // !defined(OS_MACOSX)
bool InstallTransparency();
@@ -273,18 +269,18 @@ class CefRenderWidgetHostViewOSR
child_host_view_ = popup_view;
}
ui::Compositor* compositor() const { return compositor_.get(); }
ui::Compositor* GetCompositor() const;
content::RenderWidgetHostImpl* render_widget_host() const
{ return render_widget_host_; }
ui::Layer* GetRootLayer() const;
private:
content::DelegatedFrameHost* GetDelegatedFrameHost() const;
void SetFrameRate();
void SetDeviceScaleFactor();
void ResizeRootLayer();
// Returns a best guess whether a frame is currently pending.
bool IsFramePending();
// Called by CefBeginFrameTimer to send a BeginFrame request.
void OnBeginFrameTimerTick();
void SendBeginFrame(base::TimeTicks frame_time,
@@ -295,6 +291,8 @@ class CefRenderWidgetHostViewOSR
void OnScrollOffsetChanged();
#if defined(OS_MACOSX)
friend class MacHelper;
// Returns composition character boundary rectangle. The |range| is
// composition based range. Also stores |actual_range| which is corresponding
// to actually used range for returned rectangle.
@@ -317,6 +315,7 @@ class CefRenderWidgetHostViewOSR
#endif // defined(OS_MACOSX)
void PlatformCreateCompositorWidget();
void PlatformResizeCompositorWidget(const gfx::Size& size);
void PlatformDestroyCompositorWidget();
#if defined(USE_AURA)
@@ -328,10 +327,12 @@ class CefRenderWidgetHostViewOSR
float scale_factor_;
int frame_rate_threshold_ms_;
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;
#if !defined(OS_MACOSX)
std::unique_ptr<ui::Compositor> compositor_;
gfx::AcceleratedWidget compositor_widget_;
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;
std::unique_ptr<ui::Layer> root_layer_;
#endif
#if defined(OS_WIN)
std::unique_ptr<gfx::WindowImpl> window_;
@@ -339,6 +340,7 @@ class CefRenderWidgetHostViewOSR
NSWindow* window_;
CALayer* background_layer_;
std::unique_ptr<content::BrowserCompositorMac> browser_compositor_;
MacHelper* mac_helper_;
#elif defined(USE_X11)
CefWindowX11* window_;
std::unique_ptr<ui::XScopedCursor> invisible_cursor_;

View File

@@ -123,6 +123,9 @@ void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget() {
compositor_widget_ = window_->xwindow();
}
void CefRenderWidgetHostViewOSR::PlatformResizeCompositorWidget(const gfx::Size&) {
}
void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() {
DCHECK(window_);
window_->Close();

View File

@@ -17,6 +17,7 @@
#include "base/compiler_specific.h"
#include "base/strings/utf_string_conversions.h"
#include "content/common/view_messages.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#include "ui/events/latency_info.h"
namespace {
@@ -30,10 +31,94 @@ CefTextInputClientOSRMac* GetInputClientFromContext(
} // namespace
class MacHelper :
public content::BrowserCompositorMacClient,
public ui::AcceleratedWidgetMacNSView {
public:
explicit MacHelper(CefRenderWidgetHostViewOSR* view)
: view_(view) {
}
virtual ~MacHelper() {}
// BrowserCompositorMacClient methods:
NSView* BrowserCompositorMacGetNSView() const override {
// Intentionally return nil so that
// BrowserCompositorMac::DelegatedFrameHostDesiredSizeInDIP uses the layer
// size instead of the NSView size.
return nil;
}
SkColor BrowserCompositorMacGetGutterColor(SkColor color) const override {
// When making an element on the page fullscreen the element's background
// may not match the page's, so use black as the gutter color to avoid
// flashes of brighter colors during the transition.
if (view_->render_widget_host()->delegate() &&
view_->render_widget_host()->delegate()->IsFullscreenForCurrentTab()) {
return SK_ColorBLACK;
}
return color;
}
void BrowserCompositorMacSendCompositorSwapAck(
int output_surface_id,
const cc::CompositorFrameAck& ack) override {
view_->render_widget_host()->Send(new ViewMsg_SwapCompositorFrameAck(
view_->render_widget_host()->GetRoutingID(), output_surface_id, ack));
}
void BrowserCompositorMacSendReclaimCompositorResources(
int output_surface_id,
const cc::CompositorFrameAck& ack) override {
view_->render_widget_host()->Send(new ViewMsg_ReclaimCompositorResources(
view_->render_widget_host()->GetRoutingID(), output_surface_id, ack));
}
void BrowserCompositorMacOnLostCompositorResources() override {
view_->render_widget_host()->ScheduleComposite();
}
void BrowserCompositorMacUpdateVSyncParameters(
const base::TimeTicks& timebase,
const base::TimeDelta& interval) override {
view_->render_widget_host()->UpdateVSyncParameters(timebase, interval);
}
void BrowserCompositorMacSendBeginFrame(
const cc::BeginFrameArgs& args) override {
view_->render_widget_host()->Send(
new ViewMsg_BeginFrame(view_->render_widget_host()->GetRoutingID(),
args));
}
// AcceleratedWidgetMacNSView methods:
NSView* AcceleratedWidgetGetNSView() const override {
return [view_->window_ contentView];
}
void AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const override {
*timebase = base::TimeTicks();
*interval = base::TimeDelta();
}
void AcceleratedWidgetSwapCompleted() override {
}
private:
// Guaranteed to outlive this object.
CefRenderWidgetHostViewOSR* view_;
DISALLOW_COPY_AND_ASSIGN(MacHelper);
};
ui::AcceleratedWidgetMac* CefRenderWidgetHostViewOSR::GetAcceleratedWidgetMac()
const {
if (browser_compositor_)
return browser_compositor_->accelerated_widget_mac();
return browser_compositor_->GetAcceleratedWidgetMac();
return nullptr;
}
@@ -109,19 +194,6 @@ void CefRenderWidgetHostViewOSR::SelectionBoundsChanged(
first_selection_rect_ = params.anchor_rect;
}
NSView* CefRenderWidgetHostViewOSR::AcceleratedWidgetGetNSView() const {
return [window_ contentView];
}
void CefRenderWidgetHostViewOSR::AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const {
*timebase = base::TimeTicks();
*interval = base::TimeDelta();
}
void CefRenderWidgetHostViewOSR::AcceleratedWidgetSwapCompleted() {
}
CefTextInputContext CefRenderWidgetHostViewOSR::GetNSTextInputContext() {
if (!text_input_context_osr_mac_) {
CefTextInputClientOSRMac* text_input_client_osr_mac =
@@ -290,6 +362,19 @@ void CefRenderWidgetHostViewOSR::DestroyNSTextInputOSR() {
text_input_context_osr_mac_ = NULL;
}
ui::Compositor* CefRenderWidgetHostViewOSR::GetCompositor() const {
return browser_compositor_->GetCompositor();
}
ui::Layer* CefRenderWidgetHostViewOSR::GetRootLayer() const {
return browser_compositor_->GetRootLayer();
}
content::DelegatedFrameHost* CefRenderWidgetHostViewOSR::GetDelegatedFrameHost()
const {
return browser_compositor_->GetDelegatedFrameHost();
}
void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget() {
// Create a borderless non-visible 1x1 window.
window_ = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1)
@@ -304,35 +389,24 @@ void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget() {
[content_view setLayer:background_layer_];
[content_view setWantsLayer:YES];
browser_compositor_ = content::BrowserCompositorMac::Create();
mac_helper_ = new MacHelper(this);
browser_compositor_.reset(new content::BrowserCompositorMac(
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true));
}
compositor_.reset(browser_compositor_->compositor());
compositor_->SetRootLayer(root_layer_.get());
browser_compositor_->accelerated_widget_mac()->SetNSView(this);
browser_compositor_->compositor()->SetVisible(true);
// CEF needs the browser compositor to remain responsive whereas normal
// rendering on OS X does not. This effectively reverts the changes from
// https://crbug.com/463988#c6
compositor_->SetLocksWillTimeOut(true);
browser_compositor_->Unsuspend();
void CefRenderWidgetHostViewOSR::PlatformResizeCompositorWidget(const gfx::Size&) {
}
void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() {
DCHECK(window_);
// Compositor is owned by and will be freed by BrowserCompositorMac.
ui::Compositor* compositor = compositor_.release();
ALLOW_UNUSED_LOCAL(compositor);
[window_ close];
window_ = nil;
[background_layer_ release];
background_layer_ = nil;
browser_compositor_->accelerated_widget_mac()->ResetNSView();
browser_compositor_->compositor()->SetVisible(false);
browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0));
browser_compositor_->compositor()->SetRootLayer(NULL);
content::BrowserCompositorMac::Recycle(std::move(browser_compositor_));
browser_compositor_.reset();
delete mac_helper_;
mac_helper_ = nullptr;
}

View File

@@ -10,8 +10,8 @@
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/content_browser_client.h"
#include "grit/ui_unscaled_resources.h"
#include "third_party/WebKit/public/platform/WebCursorInfo.h"
#include "ui/resources/grit/ui_unscaled_resources.h"
namespace {
@@ -149,6 +149,12 @@ void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget() {
compositor_widget_ = window_->hwnd();
}
void CefRenderWidgetHostViewOSR::PlatformResizeCompositorWidget(const gfx::Size& size) {
DCHECK(window_);
SetWindowPos(window_->hwnd(), NULL, 0, 0, size.width(), size.height(),
SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE);
}
void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() {
window_.reset(NULL);
compositor_widget_ = gfx::kNullAcceleratedWidget;

View File

@@ -5,6 +5,7 @@
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/net/url_request_context_getter_impl.h"
#include "libcef/browser/prefs/renderer_prefs.h"
#include "libcef/common/cef_switches.h"
@@ -12,6 +13,7 @@
#include "base/files/file_path.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "cef/grit/cef_strings.h"
#include "chrome/browser/prefs/command_line_pref_store.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -28,7 +30,6 @@
#include "components/update_client/update_client.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_prefs.h"
#include "grit/cef_strings.h"
#include "ui/base/l10n/l10n_util.h"
namespace browser_prefs {
@@ -126,6 +127,7 @@ std::unique_ptr<PrefService> CreatePrefService(const base::FilePath& pref_path)
PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get());
extensions::ExtensionPrefs::RegisterProfilePrefs(registry.get());
HostContentSettingsMap::RegisterProfilePrefs(registry.get());
CefURLRequestContextGetterImpl::RegisterPrefs(registry.get());
renderer_prefs::RegisterProfilePrefs(registry.get());
update_client::RegisterPrefs(registry.get());
@@ -160,12 +162,6 @@ std::unique_ptr<PrefService> CreatePrefService(const base::FilePath& pref_path)
registry->RegisterBooleanPref(prefs::kPluginsAllowOutdated, false);
registry->RegisterBooleanPref(prefs::kPluginsAlwaysAuthorize, false);
// Network preferences.
// Based on IOThread::RegisterPrefs.
#if defined(OS_POSIX) && !defined(OS_ANDROID)
registry->RegisterStringPref(prefs::kGSSAPILibraryName, std::string());
#endif
if (command_line->HasSwitch(switches::kEnablePreferenceTesting)) {
// Preferences used with unit tests.
registry->RegisterBooleanPref("test.bool", true);

View File

@@ -140,7 +140,7 @@ void SavePdfFile(scoped_refptr<base::RefCountedBytes> data,
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
DCHECK_GT(data->size(), 0U);
PdfMetafileSkia metafile;
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
metafile.InitFromData(static_cast<const void*>(data->front()), data->size());
base::File file(path,

View File

@@ -11,6 +11,7 @@
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/location.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"
@@ -151,7 +152,8 @@ void PrintViewManagerBase::OnDidPrintPage(
}
}
std::unique_ptr<PdfMetafileSkia> metafile(new PdfMetafileSkia);
std::unique_ptr<PdfMetafileSkia> metafile(
new PdfMetafileSkia(PDF_SKIA_DOCUMENT_TYPE));
if (metafile_must_be_valid) {
if (!metafile->InitFromData(shared_buf->memory(), params.data_size)) {
NOTREACHED() << "Invalid metafile header";
@@ -214,16 +216,8 @@ void PrintViewManagerBase::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_PRINT_JOB_EVENT: {
OnNotifyPrintJobEvent(*content::Details<JobEventDetails>(details).ptr());
break;
}
default: {
NOTREACHED();
break;
}
}
DCHECK_EQ(chrome::NOTIFICATION_PRINT_JOB_EVENT, type);
OnNotifyPrintJobEvent(*content::Details<JobEventDetails>(details).ptr());
}
void PrintViewManagerBase::OnNotifyPrintJobEvent(
@@ -435,7 +429,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
{
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
base::MessageLoop::current()->Run();
base::RunLoop().Run();
}
bool success = true;

View File

@@ -54,7 +54,8 @@ net::URLRequestContext* CefResourceContext::GetRequestContext() {
return getter_->GetURLRequestContext();
}
std::unique_ptr<net::ClientCertStore> CefResourceContext::CreateClientCertStore() {
std::unique_ptr<net::ClientCertStore>
CefResourceContext::CreateClientCertStore() {
#if defined(USE_NSS_CERTS)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS(
net::ClientCertStoreNSS::PasswordDelegateFactory()));

View File

@@ -10,6 +10,7 @@
#include "content/public/browser/resource_context.h"
#include "extensions/browser/info_map.h"
#include "net/ssl/client_cert_store.h"
class CefURLRequestContextGetter;
@@ -31,7 +32,8 @@ class CefResourceContext : public content::ResourceContext {
// ResourceContext implementation.
net::HostResolver* GetHostResolver() override;
net::URLRequestContext* GetRequestContext() override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore() override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore();
void set_url_request_context_getter(
scoped_refptr<CefURLRequestContextGetter> getter);

View File

@@ -84,19 +84,24 @@ bool CefResourceDispatcherHostDelegate::HandleExternalProtocol(
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture) {
if (CEF_CURRENTLY_ON_UIT()) {
content::WebContents* web_contents = web_contents_getter.Run();
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForContents(web_contents);
if (browser.get())
browser->HandleExternalProtocol(url);
} else {
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));
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);
}
return false;
}
@@ -205,3 +210,10 @@ void CefResourceDispatcherHostDelegate::OnRequestRedirected(
response->head.headers->AddHeader("Access-Control-Allow-Credentials: true");
}
}
std::unique_ptr<net::ClientCertStore>
CefResourceDispatcherHostDelegate::CreateClientCertStore(
content::ResourceContext* resource_context) {
return static_cast<CefResourceContext*>(resource_context)->
CreateClientCertStore();
}

View File

@@ -28,7 +28,8 @@ class CefResourceDispatcherHostDelegate
web_contents_getter,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture) override;
bool has_user_gesture,
content::ResourceContext* resource_context) override;
bool ShouldInterceptResourceAsStream(net::URLRequest* request,
const base::FilePath& plugin_path,
const std::string& mime_type,
@@ -41,6 +42,8 @@ class CefResourceDispatcherHostDelegate
net::URLRequest* request,
content::ResourceContext* resource_context,
content::ResourceResponse* response) override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
content::ResourceContext* resource_context) override;
private:
struct StreamTargetInfo {

View File

@@ -162,7 +162,7 @@ bool CefTextfieldImpl::IsCommandEnabled(int command_id) {
void CefTextfieldImpl::ExecuteCommand(int command_id) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (root_view()->IsCommandIdEnabled(command_id))
root_view()->ExecuteCommand(command_id);
root_view()->ExecuteCommand(command_id, ui::EF_NONE);
}
void CefTextfieldImpl::ClearEditHistory() {

View File

@@ -200,7 +200,7 @@ display::Display GetDisplayMatchingBounds(const gfx::Rect& bounds,
find_bounds);
}
#endif
return display::Screen::GetScreen()->GetDisplayMatching(bounds);
return display::Screen::GetScreen()->GetDisplayMatching(find_bounds);
}
void ConvertPointFromPixels(gfx::Point* point,

View File

@@ -3,8 +3,10 @@
// can be found in the LICENSE file.
#include "libcef/browser/web_plugin_impl.h"
#include "libcef/browser/context.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/widevine_loader.h"
#include "base/bind.h"
#include "base/files/file_path.h"
@@ -28,6 +30,22 @@ void PluginsCallbackImpl(
}
}
#if !(defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)) || \
defined(OS_LINUX)
void DeliverWidevineCdmError(const std::string& error_message,
CefRefPtr<CefRegisterCdmCallback> callback) {
LOG(ERROR) << error_message;
if (callback.get()) {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefRegisterCdmCallback::OnCdmRegistrationComplete,
callback.get(), CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED,
error_message));
}
}
#endif
} // namespace
@@ -150,3 +168,24 @@ void CefIsWebPluginUnstable(
CEF_POST_TASK(CEF_IOT, base::Bind(CefIsWebPluginUnstable, path, callback));
}
}
void CefRegisterWidevineCdm(const CefString& path,
CefRefPtr<CefRegisterCdmCallback> callback) {
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
#if defined(OS_LINUX)
// Enforce the requirement that CefRegisterWidevineCdm() is called before
// CefInitialize() on Linux. See comments in
// CefWidevineLoader::AddPepperPlugins for details.
if (CONTEXT_STATE_VALID()) {
DeliverWidevineCdmError(
"Widevine registration is not supported after context initialization",
callback);
return;
}
#endif // defined(OS_LINUX)
CefWidevineLoader::GetInstance()->LoadWidevineCdm(path, callback);
#else
DeliverWidevineCdmError("Widevine registration is not supported", callback);
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
}

View File

@@ -106,15 +106,9 @@ const char kDisableScrollBounce[] = "disable-scroll-bounce";
// Disable the PDF extension.
const char kDisablePdfExtension[] = "disable-pdf-extension";
// Enable Widevine CDM.
const char kEnableWidevineCdm[] = "enable-widevine-cdm";
// Path to Widevine CDM binaries.
const char kWidevineCdmPath[] = "widevine-cdm-path";
// Widevine CDM version.
const char kWidevineCdmVersion[] = "widevine-cdm-version";
// Default plugin policy action.
const char kPluginPolicy[] = "plugin-policy";
// Allow the content. This is the default value.
@@ -128,4 +122,7 @@ const char kPluginPolicy_Block[] = "block";
// Expose preferences used only by unit tests.
const char kEnablePreferenceTesting[] = "enable-preference-testing";
// Enable date-based expiration of built in network security information.
const char kEnableNetSecurityExpiration[] = "enable-net-security-expiration";
} // namespace switches

View File

@@ -45,14 +45,13 @@ extern const char kOverrideSpellCheckLang[];
extern const char kEnableSystemFlash[];
extern const char kDisableScrollBounce[];
extern const char kDisablePdfExtension[];
extern const char kEnableWidevineCdm[];
extern const char kWidevineCdmPath[];
extern const char kWidevineCdmVersion[];
extern const char kPluginPolicy[];
extern const char kPluginPolicy_Allow[];
extern const char kPluginPolicy_Detect[];
extern const char kPluginPolicy_Block[];
extern const char kEnablePreferenceTesting[];
extern const char kEnableNetSecurityExpiration[];
} // namespace switches

View File

@@ -37,12 +37,8 @@
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "ui/base/resource/resource_bundle.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
// The following must be after widevine_cdm_version.h.
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
!defined(WIDEVINE_CDM_IS_COMPONENT)
#include "chrome/common/widevine_cdm_constants.h"
#if defined(OS_LINUX)
#include "libcef/common/widevine_loader.h"
#endif
namespace {
@@ -182,67 +178,6 @@ bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) {
return true;
}
void AddWidevineCdmFromCommandLine(
std::vector<content::PepperPluginInfo>* plugins) {
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
!defined(WIDEVINE_CDM_IS_COMPONENT)
static bool skip_widevine_cdm_file_check = false;
base::FilePath widevine_cdm_path =
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
switches::kWidevineCdmPath);
if (!widevine_cdm_path.empty()) {
widevine_cdm_path =
widevine_cdm_path.AppendASCII(kWidevineCdmAdapterFileName);
}
// Also get the version from the command-line. Should be something like
// 1.4.8.824.
const std::string& widevine_cdm_version =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kWidevineCdmVersion);
if (!widevine_cdm_path.empty() && !widevine_cdm_version.empty()) {
if (skip_widevine_cdm_file_check || base::PathExists(widevine_cdm_path)) {
content::PepperPluginInfo widevine_cdm;
widevine_cdm.is_out_of_process = true;
widevine_cdm.path = widevine_cdm_path;
widevine_cdm.name = kWidevineCdmDisplayName;
widevine_cdm.description = kWidevineCdmDescription +
std::string(" (version: ") +
widevine_cdm_version + ")";
widevine_cdm.version = widevine_cdm_version;
content::WebPluginMimeType widevine_cdm_mime_type(
kWidevineCdmPluginMimeType,
kWidevineCdmPluginExtension,
kWidevineCdmPluginMimeTypeDescription);
// Add the supported codecs as if they came from the component manifest.
// This list must match the CDM that is being shipped with Chrome.
std::vector<std::string> codecs;
codecs.push_back(kCdmSupportedCodecVp8);
codecs.push_back(kCdmSupportedCodecVp9);
#if defined(USE_PROPRIETARY_CODECS)
codecs.push_back(kCdmSupportedCodecAvc1);
#endif // defined(USE_PROPRIETARY_CODECS)
std::string codec_string = base::JoinString(
codecs, std::string(1, kCdmSupportedCodecsValueDelimiter));
widevine_cdm_mime_type.additional_param_names.push_back(
base::ASCIIToUTF16(kCdmSupportedCodecsParamName));
widevine_cdm_mime_type.additional_param_values.push_back(
base::ASCIIToUTF16(codec_string));
widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
widevine_cdm.permissions = kWidevineCdmPluginPermissions;
plugins->push_back(widevine_cdm);
skip_widevine_cdm_file_check = true;
}
}
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
// !defined(WIDEVINE_CDM_IS_COMPONENT)
}
} // namespace
const char CefContentClient::kPDFPluginPath[] = "internal-pdf-viewer";
@@ -269,7 +204,12 @@ void CefContentClient::AddPepperPlugins(
std::vector<content::PepperPluginInfo>* plugins) {
ComputeBuiltInPlugins(plugins);
AddPepperFlashFromCommandLine(plugins);
AddWidevineCdmFromCommandLine(plugins);
#if defined(OS_LINUX)
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
CefWidevineLoader::AddPepperPlugins(plugins);
#endif
#endif
content::PepperPluginInfo plugin;
if (GetSystemPepperFlash(&plugin))

View File

@@ -3,6 +3,9 @@
// found in the LICENSE file.
#include "libcef/common/crash_reporter_client.h"
#include <utility>
#include "libcef/common/cef_switches.h"
#include "include/cef_version.h"
@@ -19,7 +22,7 @@ CefCrashReporterClient::~CefCrashReporterClient() {}
#if defined(OS_WIN)
void CefCrashReporterClient::GetProductNameAndVersion(
const base::FilePath& exe_path,
const base::string16& exe_path,
base::string16* product_name,
base::string16* version,
base::string16* special_build,
@@ -44,18 +47,24 @@ base::FilePath CefCrashReporterClient::GetReporterLogFilename() {
}
#endif
bool CefCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
#if !defined(OS_WIN)
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kCrashDumpsDir))
return false;
*crash_dir = command_line->GetSwitchValuePath(switches::kCrashDumpsDir);
return true;
#if defined(OS_WIN)
bool CefCrashReporterClient::GetCrashDumpLocation(base::string16* crash_dir) {
#else
NOTREACHED();
return false;
bool CefCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
#endif
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kCrashDumpsDir))
return false;
base::FilePath crash_directory =
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
switches::kCrashDumpsDir);
#if defined(OS_WIN)
*crash_dir = crash_directory.value();
#else
*crash_dir = std::move(crash_directory);
#endif
return true;
}
bool CefCrashReporterClient::EnableBreakpadForProcess(

View File

@@ -17,7 +17,7 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient {
#if defined(OS_WIN)
// Returns a textual description of the product type and version to include
// in the crash report.
void GetProductNameAndVersion(const base::FilePath& exe_path,
void GetProductNameAndVersion(const base::string16& exe_path,
base::string16* product_name,
base::string16* version,
base::string16* special_build,
@@ -35,7 +35,11 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient {
// The location where minidump files should be written. Returns true if
// |crash_dir| was set.
#if defined(OS_WIN)
bool GetCrashDumpLocation(base::string16* crash_dir) override;
#else
bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
#endif
bool EnableBreakpadForProcess(const std::string& process_type) override;

View File

@@ -43,8 +43,8 @@ class CefDragDataImpl : public CefDragData {
void AddFile(const CefString& path, const CefString& display_name) override;
// This method is not safe. Use Lock/Unlock to get mutually exclusive access.
const content::DropData& drop_data() {
return data_;
content::DropData* drop_data() {
return &data_;
}
void SetReadOnly(bool read_only);

View File

@@ -0,0 +1,27 @@
# Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
# 2014 the Chromium Authors. All rights reserved. Use of this source code is
# governed by a BSD-style license that can be found in the LICENSE file.
import("//build/json_schema_api.gni")
import("schemas.gni")
json_schema_api("api") {
schemas = true
bundle = true
configs = [ "//build/config:precompiled_headers" ]
bundle_name = "Chrome"
deps = schema_dependencies
}
json_schema_api("api_registration") {
impl_dir = "//cef/libcef/browser/extensions/api"
bundle_registration = true
configs = [ "//build/config:precompiled_headers" ]
bundle_name = "Chrome"
deps = [
":api",
]
deps += schema_dependencies
}

View File

@@ -0,0 +1,16 @@
# Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
# 2014 the Chromium Authors. All rights reserved. Use of this source code is
# governed by a BSD-style license that can be found in the LICENSE file.
gypi_values = exec_script("//build/gypi_to_gn.py",
[ rebase_path("schemas.gypi") ],
"scope",
[ "schemas.gypi" ])
sources = gypi_values.schema_files
uncompiled_sources = gypi_values.non_compiled_schema_files
root_namespace = "extensions::api::%(namespace)s"
schema_include_rules = "//cef/libcef/browser/extensions/api:extensions::api::%(namespace)s"
schema_dependencies = [ "//extensions/common/api" ]

View File

@@ -11,6 +11,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "cef/grit/cef_resources.h"
#include "cef/libcef/common/extensions/api/generated_schemas.h"
#include "extensions/common/api/generated_schemas.h"
#include "extensions/common/common_manifest_handlers.h"
@@ -27,8 +28,7 @@
#include "extensions/common/permissions/permissions_info.h"
#include "extensions/common/permissions/permissions_provider.h"
#include "extensions/common/url_pattern_set.h"
#include "grit/cef_resources.h"
#include "grit/extensions_resources.h"
#include "extensions/grit/extensions_resources.h"
namespace extensions {

View File

@@ -40,8 +40,6 @@
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
#if defined(IPC_MESSAGE_LOG_ENABLED)
@@ -558,22 +556,6 @@ void CefMainDelegate::PreSandboxStartup() {
user_data_path.AppendASCII("Dictionaries"),
false, // May not be an absolute path.
true); // Create if necessary.
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
const base::FilePath& widevine_plugin_path =
GetResourcesFilePath().AppendASCII(kWidevineCdmAdapterFileName);
if (base::PathExists(widevine_plugin_path)) {
PathService::Override(chrome::FILE_WIDEVINE_CDM_ADAPTER,
widevine_plugin_path);
}
#if defined(WIDEVINE_CDM_IS_COMPONENT)
if (command_line->HasSwitch(switches::kEnableWidevineCdm)) {
PathService::Override(
chrome::DIR_COMPONENT_WIDEVINE_CDM,
user_data_path.Append(FILE_PATH_LITERAL("WidevineCDM")));
}
#endif // defined(WIDEVINE_CDM_IS_COMPONENT)
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
}
if (command_line->HasSwitch(switches::kDisablePackLoading))

View File

@@ -438,6 +438,14 @@ void CefRequestImpl::Set(net::URLRequest* request) {
case net::URLRequest::NEVER_CLEAR_REFERRER:
referrer_policy_ = REFERRER_POLICY_ALWAYS;
break;
case net::URLRequest::ORIGIN:
referrer_policy_ = REFERRER_POLICY_ORIGIN;
break;
case net::URLRequest::NO_REFERRER:
referrer_policy_ = REFERRER_POLICY_NEVER;
break;
case net::URLRequest::MAX_REFERRER_POLICY:
break;
}
}

View File

@@ -85,7 +85,8 @@ scoped_refptr<base::SequencedTaskRunner>
break;
};
if (id >= 0 && CefContentClient::Get()->browser() &&
if (id >= 0 && CefContentClient::Get() &&
CefContentClient::Get()->browser() &&
BrowserThread::IsMessageLoopValid(static_cast<BrowserThread::ID>(id))) {
// Don't use BrowserThread::GetMessageLoopProxyForThread because it returns
// a new MessageLoopProxy object for each call and makes pointer equality

View File

@@ -454,7 +454,8 @@ CefBinaryValueImpl::CefBinaryValueImpl(char* data,
size_t data_size,
bool copy)
: CefValueBase<CefBinaryValue, base::BinaryValue>(
copy ? base::BinaryValue::CreateWithCopiedBuffer(data, data_size) :
copy ? base::BinaryValue::CreateWithCopiedBuffer(data,
data_size).release() :
new base::BinaryValue(std::unique_ptr<char[]>(data), data_size),
NULL, kOwnerWillDelete, true, NULL) {
}

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