Compare commits

..

81 Commits
2357 ... 2454

Author SHA1 Message Date
Marshall Greenblatt
2782fb8fc8 Mac: Fix positioning of default open/save dialog (issue #1740) 2015-10-22 10:03:51 -04:00
Marshall Greenblatt
3d84012926 CTRL + left click on a link in a PDF document should call OnOpenURLFromTab (issue #1737) 2015-10-21 17:10:13 -04:00
Marshall Greenblatt
4e94f47071 Restore previous CefFrame::GetText behavior (issue #1743) 2015-10-15 13:18:37 -04:00
Marshall Greenblatt
96263d6729 Add missing touch menu resources (issue #1739) 2015-10-15 10:38:09 -04:00
Marshall Greenblatt
22e1e09eb0 Remove unused function ShouldUseJavaScriptSettingForPlugin (issue #1734). 2015-10-14 13:28:45 -07:00
Marshall Greenblatt
11807d5951 Linux: Fix focus/activation handling and keyboard input (issue #1679). 2015-10-14 12:39:22 -07:00
Marshall Greenblatt
b5294956bf Linux: Fix BadWindow error when creating popup windows (issue #1717). 2015-10-14 12:33:41 -07:00
Marshall Greenblatt
71ec85c445 Fix use-after-return in ReleaseAndWaitForDestructor if it times out
while running unit tests.
2015-10-14 12:33:09 -07:00
Marshall Greenblatt
b40a009e40 Fix navigation from inside PDF files (issue #1737) 2015-10-14 15:26:43 -04:00
Marshall Greenblatt
4737056482 Remove HostContentSettingsMap usage due to UI thread blockage when creating multiple request contexts (issue #1734) 2015-10-14 11:18:33 -04:00
Marshall Greenblatt
3e9c8df55f Add CefPrintHandler::OnPrintStart callback (issue #1736) 2015-10-13 14:07:09 -04:00
Marshall Greenblatt
a594fe2ca4 Fix extension resource access permissions (issue #1719) 2015-10-12 14:29:30 -04:00
Marshall Greenblatt
ed378a48a5 Remove final keyword to fix builds with non-C++11 compilers (issue #1725) 2015-10-12 12:44:08 -04:00
Marshall Greenblatt
2d2ca9c6c5 Linux: Fix NSS handler loading (issue #1727) 2015-10-09 14:07:59 -04:00
Marshall Greenblatt
b976ee18d2 Fix crash when passing the --disable-extensions command-line flag (issue #1721) 2015-10-09 11:37:35 -04:00
Marshall Greenblatt
29055f6b5b Update to Chromium version 45.0.2454.101 2015-10-06 12:40:36 -04:00
Marshall Greenblatt
c45b7de7f9 cefclient: Remove accidental change disabling plugin load (issue #1708) 2015-10-01 11:32:19 -04:00
Marshall Greenblatt
0ea96ca4b9 Call OnBeforePluginLoad when building the plugin list (issue #1708) 2015-09-30 18:10:33 -04:00
Marshall Greenblatt
0f8bf81d5a Don't create Widevine-related folders when Widevine support is disabled (issue #1713) 2015-09-24 11:36:50 +03:00
Marshall Greenblatt
35164e672e Mac: Fix background color (issue #1161) 2015-09-22 13:20:04 +02:00
Marshall Greenblatt
b6e560e2ea Add plugin placeholder and policy support (issue #1708)
- Default plugin loading policy can be specified using the new
  `--plugin-policy=[allow|block|detect]` command-line flag.
- Move CefRequestHandler::OnBeforePluginLoad to
  CefRequestContextHandler and add a new policy argument that
  supports different actions (allow, block, detect, disable) on a
  per-plugin-instance basis.
- Add CefContextMenuHandler::RunContextMenu for providing a custom
  context menu implementation.
- Add CefResourceBundleHandler::GetDataResourceForScale for
  returning scaled resources (issue #1272).
- Add CefResourceBundle for retrieving resources from the resource
  bundle (*.pak) files loaded by CEF during startup or via the
  CefResourceBundleHandler.
- Linux: Fix Debug build IO access warning with CefGetMimeType.
- cef_unittests: Move the refcounting implementation from TestHandler
  to subclasses in order to support interface inheritance from
  subclasses.
2015-09-22 12:29:21 +03:00
Marshall Greenblatt
71c7271d1f Windows: Fix warning treated as error with Widevine CDM 64-bit build (issue #1631) 2015-09-16 13:36:48 +03:00
Marshall Greenblatt
bc7ad8d852 Fix PDF extension loading with custom request context handler (issue #1710) 2015-09-11 14:23:32 +02:00
Marshall Greenblatt
32222c1a51 Fix crash with OSR when the render process terminates (issue #1702) 2015-09-07 15:22:40 +02:00
Marshall Greenblatt
807de3c161 Update to Chromium version 45.0.2454.85 2015-09-04 17:41:58 +02:00
Marshall Greenblatt
b977814248 Add Widevine CDM support (issue #1631)
- Windows/Mac: Use `--enable-widevine-cdm` command-line flag to
  enable download of CDM binaries via the component updater.
- Linux: Use `--widevide-cdm-path` and `--widevine-cdm-version`
  command-line flags to load CDM binaries that already exist on
  the system.
- A cache-path value is usually required when CDM is enabled.
2015-09-01 14:11:44 +02:00
Marshall Greenblatt
8b21103181 Mac: Fix 10.10 SDK compile and test errors (issue #1414) 2015-08-26 16:50:50 -04:00
Marshall Greenblatt
c22b77dcc4 Update to Chromium version 45.0.2454.62 2015-08-25 12:20:10 -04:00
Marshall Greenblatt
29bd7d2c53 Always save cookies for http, https, ws and wss schemes (issue #1684) 2015-08-21 16:39:34 -04:00
Marshall Greenblatt
8c79ecbb0c Windows: Fix warning C4267: 'argument' : conversion from 'size_t' to 'int' (issue #1695) 2015-08-21 13:54:29 -04:00
Marshall Greenblatt
e88b64b1c7 Don't execute URLRequest callback for already canceled requests (issue #1685) 2015-08-21 13:36:35 -04:00
Marshall Greenblatt
9ea7b0d9b3 Don't render the OSR parent view when a full-screen view is visible (issue #1694) 2015-08-20 15:32:49 -04:00
Marshall Greenblatt
50f89c1a08 Windows: Fix incorrect usage of MAKEINTRESOURCE (issue #1692) 2015-08-20 13:16:05 -04:00
Marshall Greenblatt
2fbfdc797a Remove C++11 "= default" to maintain compatibility with older VS versions (issue #1693) 2015-08-20 10:49:15 -04:00
Marshall Greenblatt
2e2154c784 Windows: Fix VS2015 build errors in the binary distribution (issue #1692) 2015-08-20 10:20:21 -04:00
Marshall Greenblatt
a566e4600e Fix rendering of the PDF extension with OSR when the device scale factor is not 1 (issue #1687) 2015-08-20 10:07:33 -04:00
Marshall Greenblatt
85e11f95a4 Fix duplicate/incorrect type defines (issue #1683) 2015-08-17 21:12:46 -04:00
Marshall Greenblatt
2d0c79ec29 Add missing OVERRIDE specifier to avoid compile errors with clang 3.6 (issue #1688) 2015-08-17 19:08:14 -04:00
Marshall Greenblatt
e3c1d8632e cefclient: Set recommended command-line switches for off-screen rendering 2015-08-17 18:17:13 -04:00
Marshall Greenblatt
0e7223b8fb Fix assertion when loading the PDF extension with begin-frame-scheduling and OSR (issue #1686) 2015-08-17 15:48:57 -04:00
Marshall Greenblatt
e979611ea6 Update to Chromium version 45.0.2454.26 2015-08-12 11:14:17 -04:00
Marshall Greenblatt
33f860863e cefclient: Support dynamic configuration of the device scale factor with off-screen rendering (issue #1674) 2015-08-11 14:24:30 -04:00
Marshall Greenblatt
8d1aa37b84 Windows: cefclient: Improve high-dpi display (issue #1674).
- Add high-dpi support to the OSR example.
- Apply DPI scaling to the buttons and URL bar.
2015-08-10 14:11:35 -04:00
Marshall Greenblatt
295a66c401 Windows: Add CefEnableHighDPISupport function and fix high-dpi scaling issues (issue #1674) 2015-08-07 16:06:26 -04:00
Marshall Greenblatt
97ba8b5fbd Add missing kSpellCheckDictionaries preference (issue #1682) 2015-08-07 15:11:45 -04:00
Marshall Greenblatt
6f8a6f1c40 Linux: Fix Debug build IO access warning (issue #1565) 2015-08-06 14:50:33 -04:00
Marshall Greenblatt
59878cbd01 Linux: Fix undefined reference to 'AtomicOps_Internalx86CPUFeatures' (issue #1681) 2015-08-06 14:49:56 -04:00
Marshall Greenblatt
e699b31e87 Windows: Fix crash on startup with multi-threaded-message-loop (issue #1678) 2015-08-05 13:25:42 -04:00
Marshall Greenblatt
faa8d0c9ba Windows: Fix focus/blur handling (issue #1677) 2015-08-04 14:07:10 -04:00
Marshall Greenblatt
d3276ed40b Fix loading of the DevTools window.
- The devtools.html file has been renamed to inspector.html.
2015-07-31 16:57:09 -04:00
Marshall Greenblatt
7d01f373fb Windows: Fix multiple handling of WM_MOUSEWHEEL messages (issue #1481) 2015-07-31 14:47:57 -04:00
Marshall Greenblatt
91a2cd050d Add CHECK() to verify that the resources directory is an absolute path (issue #1673) 2015-07-29 12:14:38 -04:00
Marshall Greenblatt
2471bb5821 Linux: Remove DCHECK hit when initializing CEF from a non-main thread (issue #1639) 2015-07-29 12:08:01 -04:00
Marshall Greenblatt
21e9c612c1 Update to Chromium version 45.0.2454.15 2015-07-24 18:23:33 -04:00
Marshall Greenblatt
8da8a4fbf1 Update to Chromium revision 12bfc336 (#338390).
- The ffmpeg library is now statically linked (see https://codereview.chromium.org/1141703002).
- Off-screen rendering of the PDF viewer does not work in combination with surfaces. Pass the
  `--disable-surfaces` command-line flag if GPU is enabled (see https://codereview.chromium.org/1169983006).
2015-07-24 16:11:13 -04:00
Marshall Greenblatt
50a9343cec Fix warning C4267: 'argument' : conversion from 'size_t' to 'int' (issue #1647) 2015-07-23 14:29:54 -04:00
Marshall Greenblatt
b7a56d9343 Add PDF extension support (issue #1565) 2015-07-23 14:02:03 -04:00
Marshall Greenblatt
aefb5ccce8 Fix unknown type when logging IPC messages (issue #963) 2015-06-12 13:54:42 -04:00
Marshall Greenblatt
272ecc3047 Windows: Fix sandbox permissions for Flash video playback (issue #1650) 2015-06-11 19:00:09 -04:00
Marshall Greenblatt
ee90dc0915 Windows: Add DirectWrite font cache support (issue #1652) 2015-06-11 18:08:33 -04:00
Marshall Greenblatt
de05577c86 Support full-screen Flash with off-screen rendering (issue #1648) 2015-06-11 11:00:05 -04:00
Marshall Greenblatt
378a64b39a Update to Chromium revision 14bd12d6 (#333041)
- Remove CefNavigationEntry::GetFrameName() (see http://crbug.com/477150#c5).
- Devirtualize base::BindState (see http://crbug.com/486594).
- Move Tuple to the base namespace.
2015-06-08 17:31:50 -04:00
Marshall Greenblatt
d820080479 Add fullscreen API support (issue #562) 2015-06-04 18:33:24 -04:00
Alexei Bykov
85f83680d7 Add PDF printing support (issue #1478). 2015-06-04 13:15:26 -04:00
Marshall Greenblatt
b6e5310bce Add CefResourceManager class for mapping requests to data providers (issue #1640). 2015-06-03 15:21:40 -04:00
Yu-Teh Shen
d02f03a71a Add JSON parsing support (issue #1188). 2015-06-03 15:03:41 -04:00
Marshall Greenblatt
373180fef2 Windows: Add default extension to file name in save dialog (issue #1646) 2015-06-03 14:51:09 -04:00
Felix Bruns
c5b8b8b9c8 Add support for draggable regions (issue #1645).
Regions are defined using the '-webkit-app-region: drag/no-drag'
CSS property and passed to the CefDragHandler::
OnDraggableRegionsChanged callback.
2015-06-03 14:48:28 -04:00
Marshall Greenblatt
ead921a3f6 Mac: Use NSColor function available in older SDKs (issue #1605) 2015-05-19 14:54:39 -04:00
Marshall Greenblatt
0d905e3744 - Add support for client SSL certificates (issue #1608).
- Remember OnCertificateError approvals (issue #1590).
2015-05-19 14:39:45 -04:00
Marshall Greenblatt
2a308f2a05 Linux: Disable ODR detection for cef_unittests target (issue #1604) 2015-05-14 08:10:22 -07:00
Marshall Greenblatt
483a841348 Add a new CefBrowserHost::SetWindowlessFrameRate method to support
dynamic configuration of the windowless frame rate (issue #1629).
2015-05-13 20:42:40 +03:00
Marshall Greenblatt
42341b40fa Fix crash when calling LoadURL from OnRenderProcessTerminated (issue #1161) 2015-05-13 09:18:46 -04:00
Marshall Greenblatt
a388a69356 Fix incorrct DCHECK in CefAllowCertificateErrorCallbackImpl::RunNow (issue #1626) 2015-05-07 10:37:50 -04:00
Marshall Greenblatt
b849e7fb70 Return CefTime instead of time_t from CefZipReader::GetFileLastModified (issue #1625) 2015-05-05 19:12:10 -04:00
Marshall Greenblatt
616fdbf3ff Improve inheritance support in the CEF API (issue #1623).
- Support single parent inheritance in CEF API classes.
- Support non-virtual inheritance in CEF API classes.
- Support translation of CEF API sub-directories.
- Add test sub-directories for testing-only functionality that will be
  available to unit tests but not exposed via the binary distribution.
- Add unit tests for the translator tool.
- Fix parsing of template parameter types that include commas.
2015-05-05 17:16:44 -04:00
Marshall Greenblatt
4715a1644e Windows: Fix IME window placement and dismissal in password fields (issue #1377) 2015-04-24 18:33:27 +03:00
Marshall Greenblatt
b6f09f3865 Improve documentation for CefSettings.multi_threaded_message_loop 2015-04-24 14:53:57 +03:00
Marshall Greenblatt
ab50008595 Windows: Fix placement of IME window (issue #1610) 2015-04-24 14:25:50 +03:00
Marshall Greenblatt
faafdd2cd7 Update to Chromium revision c03558c9 (#326273) 2015-04-24 11:04:30 +03:00
Marshall Greenblatt
aeb35d2f36 Fix typo in automate-git.py (issue #1612) 2015-04-22 16:01:55 +03:00
752 changed files with 28445 additions and 6940 deletions

View File

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

View File

@@ -278,7 +278,6 @@ if(OS_LINUX)
# List of CEF binary files.
set(CEF_BINARY_FILES
chrome-sandbox
libffmpegsumo.so
libcef.so
natives_blob.bin
snapshot_blob.bin
@@ -289,6 +288,7 @@ if(OS_LINUX)
cef.pak
cef_100_percent.pak
cef_200_percent.pak
cef_extensions.pak
devtools_resources.pak
icudtl.dat
locales
@@ -437,7 +437,6 @@ if(OS_WINDOWS)
set(CEF_BINARY_FILES
d3dcompiler_43.dll
d3dcompiler_47.dll
ffmpegsumo.dll
libcef.dll
libEGL.dll
libGLESv2.dll
@@ -457,6 +456,7 @@ if(OS_WINDOWS)
cef.pak
cef_100_percent.pak
cef_200_percent.pak
cef_extensions.pak
devtools_resources.pak
icudtl.dat
locales

223
cef.gyp
View File

@@ -409,6 +409,8 @@
'tests/cefclient/renderer/client_app_renderer.cc',
'tests/cefclient/renderer/client_app_renderer.h',
'tests/cefclient/resources/osr_test.html',
'tests/cefclient/resources/pdf.html',
'tests/cefclient/resources/pdf.pdf',
'tests/unittests/browser_info_map_unittest.cc',
'tests/unittests/command_line_unittest.cc',
'tests/unittests/cookie_unittest.cc',
@@ -425,6 +427,7 @@
'tests/unittests/navigation_unittest.cc',
'tests/unittests/os_rendering_unittest.cc',
'tests/unittests/parser_unittest.cc',
'tests/unittests/plugin_unittest.cc',
'tests/unittests/print_unittest.cc',
'tests/unittests/process_message_unittest.cc',
'tests/unittests/request_context_unittest.cc',
@@ -447,6 +450,7 @@
'tests/unittests/test_util.cc',
'tests/unittests/test_util.h',
'tests/unittests/tracing_unittest.cc',
'tests/unittests/translator_unittest.cc',
'tests/unittests/urlrequest_unittest.cc',
'tests/unittests/v8_unittest.cc',
'tests/unittests/values_unittest.cc',
@@ -456,6 +460,8 @@
],
'mac_bundle_resources': [
'tests/cefclient/resources/osr_test.html',
'tests/cefclient/resources/pdf.html',
'tests/cefclient/resources/pdf.pdf',
'tests/unittests/mac/unittests.icns',
'tests/unittests/mac/English.lproj/InfoPlist.strings',
'tests/unittests/mac/English.lproj/MainMenu.xib',
@@ -594,6 +600,8 @@
'destination': '<(PRODUCT_DIR)/files',
'files': [
'tests/cefclient/resources/osr_test.html',
'tests/cefclient/resources/pdf.html',
'tests/cefclient/resources/pdf.pdf',
],
},
],
@@ -655,6 +663,7 @@
'<(DEPTH)/ui/strings/ui_strings.gyp:ui_strings',
'<(DEPTH)/components/components_strings.gyp:components_strings',
'<(DEPTH)/content/app/strings/content_strings.gyp:content_strings',
'<(DEPTH)/extensions/extensions_strings.gyp:extensions_strings',
'cef_strings',
],
'actions': [
@@ -732,6 +741,59 @@
},
],
},
{
# Create the pack file for component extension resources.
'target_name': 'component_extension_resources',
'type': 'none',
'actions': [
{
'action_name': 'component_extension_resources',
'variables': {
'grit_grd_file': '../chrome/browser/resources/component_extension_resources.grd',
},
'includes': [ '../build/grit_action.gypi' ],
},
],
'includes': [ '../build/grit_target.gypi' ],
'copies': [
{
'destination': '<(PRODUCT_DIR)',
'files': [
'<(grit_out_dir)/component_extension_resources.pak'
],
},
],
},
{
# Combine all extensions-related non-localized pack file resources into a
# single CEF pack file. Scaled resources are still in cef_pak.
'target_name': 'cef_extensions_pak',
'type': 'none',
'dependencies': [
'<(DEPTH)/extensions/extensions_resources.gyp:extensions_resources',
'<(DEPTH)/extensions/extensions_strings.gyp:extensions_strings',
'<(DEPTH)/ui/resources/ui_resources.gyp:ui_resources',
'component_extension_resources',
],
'variables': {
'make_pack_header_path': 'tools/make_pack_header.py',
},
'actions': [
{
'action_name': 'repack_cef_extensions_pack',
'variables': {
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/extensions/extensions_renderer_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/extensions/extensions_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/webui_resources.pak',
'<(grit_out_dir)/component_extension_resources.pak',
],
'pak_output': '<(PRODUCT_DIR)/cef_extensions.pak',
},
'includes': [ '../build/repack_action.gypi' ],
},
],
},
{
# Combine all non-localized pack file resources into a single CEF pack file.
'target_name': 'cef_pak',
@@ -744,6 +806,8 @@
'<(DEPTH)/content/browser/devtools/devtools_resources.gyp:devtools_resources',
'<(DEPTH)/net/net.gyp:net_resources',
'<(DEPTH)/ui/resources/ui_resources.gyp:ui_resources',
'<(DEPTH)/ui/views/resources/views_resources.gyp:views_resources',
'cef_extensions_pak',
'cef_locales',
'cef_resources',
],
@@ -772,7 +836,9 @@
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_image_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/extensions/extensions_browser_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/views/resources/views_resources_100_percent.pak',
],
'pak_output': '<(PRODUCT_DIR)/cef_100_percent.pak',
},
@@ -785,7 +851,9 @@
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_image_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/extensions/extensions_browser_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/views/resources/views_resources_200_percent.pak',
],
'pak_output': '<(PRODUCT_DIR)/cef_200_percent.pak',
},
@@ -798,9 +866,15 @@
'<(SHARED_INTERMEDIATE_DIR)/blink/grit/devtools_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/grit/blink_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/content/grit/content_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/extensions/grit/extensions_browser_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/extensions/grit/extensions_renderer_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/extensions/grit/extensions_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/net/grit/net_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/grit/ui_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/grit/webui_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/views/resources/grit/views_resources.h',
'<(grit_out_dir)/grit/cef_resources.h',
'<(grit_out_dir)/grit/component_extension_resources.h',
],
},
'inputs': [
@@ -819,6 +893,7 @@
'header_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/components/strings/grit/components_strings.h',
'<(SHARED_INTERMEDIATE_DIR)/content/app/strings/grit/content_strings.h',
'<(SHARED_INTERMEDIATE_DIR)/extensions/strings/grit/extensions_strings.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/strings/grit/ui_strings.h',
'<(grit_out_dir)/grit/cef_strings.h',
],
@@ -857,6 +932,7 @@
'<(DEPTH)/third_party/WebKit/public/web',
# CEF grit resource includes
'<(DEPTH)/cef/libcef/resources/grit_stub',
'<(DEPTH)/cef/libcef/resources/grit_stub/chrome',
'<(grit_out_dir)',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources',
'<(SHARED_INTERMEDIATE_DIR)/ui/strings',
@@ -872,14 +948,25 @@
# Generate chrome/common/safe_browsing/csd.pb.h required by
# zip_analyzer_results.h via chrome_utility_messages.h
'<(DEPTH)/chrome/chrome.gyp:safe_browsing_proto',
'<(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_mac_to_be_deleted',
'<(DEPTH)/components/components.gyp:crx_file',
'<(DEPTH)/components/components.gyp:devtools_discovery',
'<(DEPTH)/components/components.gyp:devtools_http_handler',
'<(DEPTH)/components/components.gyp:keyed_service_content',
'<(DEPTH)/components/components.gyp:keyed_service_core',
'<(DEPTH)/components/components.gyp:navigation_interception',
'<(DEPTH)/components/components.gyp:pdf_browser',
'<(DEPTH)/components/components.gyp:pdf_renderer',
'<(DEPTH)/components/components.gyp:plugins_renderer',
'<(DEPTH)/components/components.gyp:pref_registry',
'<(DEPTH)/components/components.gyp:printing_common',
'<(DEPTH)/components/components.gyp:printing_renderer',
'<(DEPTH)/components/components.gyp:proxy_config',
'<(DEPTH)/components/components.gyp:update_client',
'<(DEPTH)/components/components.gyp:user_prefs',
'<(DEPTH)/components/components.gyp:web_cache_renderer',
'<(DEPTH)/content/content.gyp:content_app_both',
@@ -892,6 +979,14 @@
'<(DEPTH)/content/content.gyp:content_resources',
'<(DEPTH)/content/content.gyp:content_utility',
'<(DEPTH)/crypto/crypto.gyp:crypto',
'<(DEPTH)/device/core/core.gyp:device_core',
'<(DEPTH)/device/hid/hid.gyp:device_hid',
'<(DEPTH)/extensions/browser/api/api_registration.gyp:extensions_api_registration',
'<(DEPTH)/extensions/common/api/api.gyp:extensions_api',
'<(DEPTH)/extensions/extensions.gyp:extensions_browser',
'<(DEPTH)/extensions/extensions.gyp:extensions_renderer',
'<(DEPTH)/extensions/extensions.gyp:extensions_utility',
'<(DEPTH)/extensions/extensions_resources.gyp:extensions_resources',
'<(DEPTH)/gpu/gpu.gyp:gpu',
'<(DEPTH)/ipc/ipc.gyp:ipc',
'<(DEPTH)/media/blink/media_blink.gyp:media_blink',
@@ -899,6 +994,7 @@
'<(DEPTH)/net/net.gyp:net',
'<(DEPTH)/net/net.gyp:net_browser_services',
'<(DEPTH)/net/net.gyp:net_with_v8',
'<(DEPTH)/pdf/pdf.gyp:pdf',
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/storage/storage_browser.gyp:storage',
'<(DEPTH)/sync/sync.gyp:sync',
@@ -906,6 +1002,8 @@
'<(DEPTH)/third_party/libxml/libxml.gyp:libxml',
'<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
'<(DEPTH)/third_party/WebKit/Source/core/core.gyp:webcore',
'<(DEPTH)/third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter',
'<(DEPTH)/third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h',
'<(DEPTH)/third_party/zlib/zlib.gyp:minizip',
'<(DEPTH)/ui/gl/gl.gyp:gl',
'<(DEPTH)/ui/base/ime/ui_base_ime.gyp:ui_base_ime',
@@ -913,6 +1011,9 @@
'<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
# Necessary to generate the grit include files.
'cef_pak',
# Necessary to generate API bindings for extensions.
'libcef/browser/extensions/api/api_registration.gyp:cef_api_registration',
'libcef/common/extensions/api/api.gyp:cef_api',
],
'sources': [
'<@(includes_common)',
@@ -962,6 +1063,38 @@
'libcef/browser/download_item_impl.h',
'libcef/browser/download_manager_delegate.cc',
'libcef/browser/download_manager_delegate.h',
'libcef/browser/component_updater/cef_component_updater_configurator.cc',
'libcef/browser/component_updater/cef_component_updater_configurator.h',
'libcef/browser/component_updater/widevine_cdm_component_installer.cc',
'libcef/browser/component_updater/widevine_cdm_component_installer.h',
'libcef/browser/extensions/api/streams_private/streams_private_api.cc',
'libcef/browser/extensions/api/streams_private/streams_private_api.h',
'libcef/browser/extensions/browser_context_keyed_service_factories.cc',
'libcef/browser/extensions/browser_context_keyed_service_factories.h',
'libcef/browser/extensions/browser_extensions_util.cc',
'libcef/browser/extensions/browser_extensions_util.h',
'libcef/browser/extensions/component_extension_resource_manager.cc',
'libcef/browser/extensions/component_extension_resource_manager.h',
'libcef/browser/extensions/event_router_forwarder.cc',
'libcef/browser/extensions/event_router_forwarder.h',
'libcef/browser/extensions/extensions_api_client.cc',
'libcef/browser/extensions/extensions_api_client.h',
'libcef/browser/extensions/extensions_browser_client.cc',
'libcef/browser/extensions/extensions_browser_client.h',
'libcef/browser/extensions/extension_system.cc',
'libcef/browser/extensions/extension_system.h',
'libcef/browser/extensions/extension_system_factory.cc',
'libcef/browser/extensions/extension_system_factory.h',
'libcef/browser/extensions/extension_web_contents_observer.cc',
'libcef/browser/extensions/extension_web_contents_observer.h',
'libcef/browser/extensions/mime_handler_view_guest_delegate.cc',
'libcef/browser/extensions/mime_handler_view_guest_delegate.h',
'libcef/browser/extensions/pdf_extension_util.cc',
'libcef/browser/extensions/pdf_extension_util.h',
'libcef/browser/extensions/pdf_web_contents_helper_client.cc',
'libcef/browser/extensions/pdf_web_contents_helper_client.h',
'libcef/browser/extensions/url_request_util.cc',
'libcef/browser/extensions/url_request_util.h',
'libcef/browser/frame_host_impl.cc',
'libcef/browser/frame_host_impl.h',
'libcef/browser/geolocation_impl.cc',
@@ -987,9 +1120,15 @@
'libcef/browser/pepper/browser_pepper_host_factory.h',
'libcef/browser/pepper/pepper_flash_browser_host.cc',
'libcef/browser/pepper/pepper_flash_browser_host.h',
'libcef/browser/pepper/pepper_isolated_file_system_message_filter.cc',
'libcef/browser/pepper/pepper_isolated_file_system_message_filter.h',
'libcef/browser/pepper/device_id_fetcher.cc',
'libcef/browser/permission_manager.cc',
'libcef/browser/permission_manager.h',
'libcef/browser/plugins/plugin_info_message_filter.cc',
'libcef/browser/plugins/plugin_info_message_filter.h',
'libcef/browser/plugins/plugin_service_filter.cc',
'libcef/browser/plugins/plugin_service_filter.h',
'libcef/browser/print_settings_impl.cc',
'libcef/browser/print_settings_impl.h',
'libcef/browser/printing/printing_message_filter.cc',
@@ -1070,6 +1209,10 @@
'libcef/common/crash_reporter_client.h',
'libcef/common/drag_data_impl.cc',
'libcef/common/drag_data_impl.h',
'libcef/common/extensions/extensions_client.cc',
'libcef/common/extensions/extensions_client.h',
'libcef/common/extensions/extensions_util.cc',
'libcef/common/extensions/extensions_util.h',
'libcef/common/http_header_utils.cc',
'libcef/common/http_header_utils.h',
'libcef/common/json_impl.cc',
@@ -1082,6 +1225,8 @@
'libcef/common/process_message_impl.h',
'libcef/common/request_impl.cc',
'libcef/common/request_impl.h',
'libcef/common/resource_bundle_impl.cc',
'libcef/common/resource_bundle_impl.h',
'libcef/common/response_impl.cc',
'libcef/common/response_impl.h',
'libcef/common/response_manager.cc',
@@ -1097,6 +1242,7 @@
'libcef/common/task_impl.cc',
'libcef/common/task_runner_impl.cc',
'libcef/common/task_runner_impl.h',
'libcef/common/test/translator_test_impl.cc',
'libcef/common/time_impl.cc',
'libcef/common/time_util.h',
'libcef/common/tracker.cc',
@@ -1118,12 +1264,23 @@
'libcef/renderer/dom_document_impl.h',
'libcef/renderer/dom_node_impl.cc',
'libcef/renderer/dom_node_impl.h',
'libcef/renderer/extensions/extensions_renderer_client.cc',
'libcef/renderer/extensions/extensions_renderer_client.h',
'libcef/renderer/extensions/print_web_view_helper_delegate.cc',
'libcef/renderer/extensions/print_web_view_helper_delegate.h',
'libcef/renderer/frame_impl.cc',
'libcef/renderer/frame_impl.h',
'libcef/renderer/media/cef_key_systems.cc',
'libcef/renderer/media/cef_key_systems.h',
'libcef/renderer/pepper/pepper_helper.cc',
'libcef/renderer/pepper/pepper_helper.h',
'libcef/renderer/pepper/pepper_uma_host.cc',
'libcef/renderer/pepper/renderer_pepper_host_factory.cc',
'libcef/renderer/pepper/renderer_pepper_host_factory.h',
'libcef/renderer/plugins/cef_plugin_placeholder.cc',
'libcef/renderer/plugins/cef_plugin_placeholder.h',
'libcef/renderer/plugins/plugin_preroller.cc',
'libcef/renderer/plugins/plugin_preroller.h',
'libcef/renderer/render_frame_observer.cc',
'libcef/renderer/render_frame_observer.h',
'libcef/renderer/render_message_filter.cc',
@@ -1154,10 +1311,6 @@
'<(DEPTH)/chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h',
'<(DEPTH)/chrome/browser/prefs/command_line_pref_store.cc',
'<(DEPTH)/chrome/browser/prefs/command_line_pref_store.h',
'<(DEPTH)/chrome/browser/prefs/proxy_config_dictionary.cc',
'<(DEPTH)/chrome/browser/prefs/proxy_config_dictionary.h',
'<(DEPTH)/chrome/browser/prefs/proxy_prefs.cc',
'<(DEPTH)/chrome/browser/prefs/proxy_prefs.h',
'<(DEPTH)/chrome/common/pref_names.cc',
'<(DEPTH)/chrome/common/pref_names.h',
'<(DEPTH)/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc',
@@ -1180,8 +1333,6 @@
'<(DEPTH)/chrome/browser/printing/printer_query.h',
'<(DEPTH)/chrome/common/extensions/extension_constants.cc',
'<(DEPTH)/chrome/common/extensions/extension_constants.h',
'<(DEPTH)/extensions/common/constants.cc',
'<(DEPTH)/extensions/common/constants.h',
# Include header for stub creation (BrowserProcess) so print_job_worker can
# determine the current locale.
'<(DEPTH)/chrome/browser/browser_process.cc',
@@ -1250,13 +1401,45 @@
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_menu_host.h',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_renderer_host.cc',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_renderer_host.h',
# Include sources required by chrome_utility_messages.h.
'<(DEPTH)/chrome/common/safe_browsing/zip_analyzer_results.h',
'<(DEPTH)/chrome/common/safe_browsing/zip_analyzer_results.cc',
# Include sources for pepper PDF support.
'<(DEPTH)/chrome/child/pdf_child_init.cc',
'<(DEPTH)/chrome/child/pdf_child_init.h',
'<(DEPTH)/chrome/renderer/pepper/chrome_pdf_print_client.cc',
'<(DEPTH)/chrome/renderer/pepper/chrome_pdf_print_client.h',
# Include sources for extensions support.
'<(DEPTH)/chrome/common/extensions/chrome_manifest_url_handlers.cc',
'<(DEPTH)/chrome/common/extensions/chrome_manifest_url_handlers.h',
'<(DEPTH)/chrome/common/extensions/extension_process_policy.cc',
'<(DEPTH)/chrome/common/extensions/extension_process_policy.h',
'<(DEPTH)/chrome/common/pepper_permission_util.cc',
'<(DEPTH)/chrome/common/pepper_permission_util.h',
'<(DEPTH)/chrome/common/url_constants.cc',
'<(DEPTH)/chrome/common/url_constants.h',
'<(DEPTH)/chrome/renderer/extensions/resource_request_policy.cc',
'<(DEPTH)/chrome/renderer/extensions/resource_request_policy.h',
'<(DEPTH)/extensions/shell/browser/shell_display_info_provider.cc',
'<(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/component_updater_url_constants.cc',
'<(DEPTH)/chrome/browser/component_updater/component_updater_url_constants.h',
# Include sources for widevine support.
'<(DEPTH)/chrome/common/widevine_cdm_constants.cc',
'<(DEPTH)/chrome/common/widevine_cdm_constants.h',
# Include sources for plugin placeholder support.
'<(DEPTH)/chrome/browser/plugins/plugin_finder.cc',
'<(DEPTH)/chrome/browser/plugins/plugin_finder.h',
'<(DEPTH)/chrome/browser/plugins/plugin_metadata.cc',
'<(DEPTH)/chrome/browser/plugins/plugin_metadata.h',
'<(DEPTH)/components/nacl/common/nacl_constants.cc',
'<(DEPTH)/components/nacl/common/nacl_constants.h',
],
'conditions': [
['OS=="win"', {
'dependencies': [
# For printing using PDF.
'<(DEPTH)/pdf/pdf.gyp:pdf',
],
'sources': [
'<@(includes_win)',
'libcef/browser/browser_host_impl_win.cc',
@@ -1271,13 +1454,15 @@
'<(DEPTH)/chrome/browser/printing/pdf_to_emf_converter.cc',
'<(DEPTH)/chrome/browser/printing/pdf_to_emf_converter.h',
'<(DEPTH)/chrome/common/chrome_utility_printing_messages.h',
# Include sources for font cache.
'<(DEPTH)/chrome/utility/font_cache_handler_win.cc',
'<(DEPTH)/chrome/utility/font_cache_handler_win.h',
],
}],
[ 'OS=="mac"', {
'sources': [
'<@(includes_mac)',
'libcef/browser/browser_host_impl_mac.mm',
'libcef/browser/browser_main_mac.mm',
'libcef/browser/javascript_dialog_mac.mm',
'libcef/browser/menu_creator_runner_mac.h',
'libcef/browser/menu_creator_runner_mac.mm',
@@ -1302,7 +1487,6 @@
'sources': [
'<@(includes_linux)',
'libcef/browser/browser_host_impl_linux.cc',
'libcef/browser/browser_main_linux.cc',
'libcef/browser/javascript_dialog_linux.cc',
'libcef/browser/menu_creator_runner_linux.cc',
'libcef/browser/menu_creator_runner_linux.h',
@@ -1313,7 +1497,7 @@
'libcef/browser/window_x11.h',
],
}],
['os_posix == 1 and OS != "mac" and android_webview_build != 1', {
['os_posix == 1 and OS != "mac"', {
'dependencies': [
'<(DEPTH)/components/components.gyp:breakpad_host',
],
@@ -1354,10 +1538,12 @@
'<(PRODUCT_DIR)/cef.pak',
'<(PRODUCT_DIR)/cef_100_percent.pak',
'<(PRODUCT_DIR)/cef_200_percent.pak',
'<(PRODUCT_DIR)/cef_extensions.pak',
'<(PRODUCT_DIR)/devtools_resources.pak',
'<(PRODUCT_DIR)/icudtl.dat',
'<(PRODUCT_DIR)/natives_blob.bin',
'<(PRODUCT_DIR)/snapshot_blob.bin',
'<(PRODUCT_DIR)/widevinecdmadapter.plugin',
'libcef/resources/framework-Info.plist',
],
'mac_bundle_resources!': [
@@ -1413,13 +1599,6 @@
},
],
'copies': [
{
# Copy binaries for HTML5 audio/video support.
'destination': '<(PRODUCT_DIR)/$(CONTENTS_FOLDER_PATH)/Libraries',
'files': [
'<(PRODUCT_DIR)/ffmpegsumo.so',
],
},
{
# Copy binaries for breakpad support.
'destination': '<(PRODUCT_DIR)/$(CONTENTS_FOLDER_PATH)/Resources',
@@ -1604,6 +1783,9 @@
'sources': [
'tests/cefclient/browser/client_app_browser.cc',
'tests/cefclient/browser/client_app_browser.h',
'tests/cefclient/browser/resource_util.h',
'tests/cefclient/browser/resource_util_mac.mm',
'tests/cefclient/browser/resource_util_posix.cc',
'tests/cefclient/common/client_app.cc',
'tests/cefclient/common/client_app.h',
'tests/cefclient/common/client_app_other.cc',
@@ -1619,6 +1801,7 @@
'tests/unittests/frame_unittest.cc',
'tests/unittests/message_router_unittest.cc',
'tests/unittests/navigation_unittest.cc',
'tests/unittests/plugin_unittest.cc',
'tests/unittests/process_message_unittest.cc',
'tests/unittests/request_handler_unittest.cc',
'tests/unittests/request_unittest.cc',

View File

@@ -9,6 +9,10 @@
# Set ENABLE_PRINTING=1 ENABLE_BASIC_PRINTING=1.
'enable_basic_printing': 1,
'enable_print_preview': 0,
# Enable support for Widevine CDM.
'enable_widevine': 1,
# Disable support for plugin installation.
'enable_plugin_installation': 0,
'conditions': [
# Directory for CEF source files.
[ 'OS=="win"', {

View File

@@ -52,6 +52,7 @@
'include/cef_request_context.h',
'include/cef_request_context_handler.h',
'include/cef_request_handler.h',
'include/cef_resource_bundle.h',
'include/cef_resource_bundle_handler.h',
'include/cef_resource_handler.h',
'include/cef_response.h',
@@ -67,6 +68,7 @@
'include/cef_web_plugin.h',
'include/cef_xml_reader.h',
'include/cef_zip_reader.h',
'include/test/cef_translator_test.h',
],
'autogen_capi_includes': [
'include/capi/cef_app_capi.h',
@@ -109,6 +111,7 @@
'include/capi/cef_request_context_capi.h',
'include/capi/cef_request_context_handler_capi.h',
'include/capi/cef_request_handler_capi.h',
'include/capi/cef_resource_bundle_capi.h',
'include/capi/cef_resource_bundle_handler_capi.h',
'include/capi/cef_resource_handler_capi.h',
'include/capi/cef_response_capi.h',
@@ -124,6 +127,7 @@
'include/capi/cef_web_plugin_capi.h',
'include/capi/cef_xml_reader_capi.h',
'include/capi/cef_zip_reader_capi.h',
'include/capi/test/cef_translator_test_capi.h',
],
'autogen_library_side': [
'libcef_dll/ctocpp/app_ctocpp.cc',
@@ -214,6 +218,8 @@
'libcef_dll/cpptoc/navigation_entry_cpptoc.h',
'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.cc',
'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.h',
'libcef_dll/ctocpp/pdf_print_callback_ctocpp.cc',
'libcef_dll/ctocpp/pdf_print_callback_ctocpp.h',
'libcef_dll/cpptoc/post_data_cpptoc.cc',
'libcef_dll/cpptoc/post_data_cpptoc.h',
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
@@ -244,12 +250,16 @@
'libcef_dll/ctocpp/request_context_handler_ctocpp.h',
'libcef_dll/ctocpp/request_handler_ctocpp.cc',
'libcef_dll/ctocpp/request_handler_ctocpp.h',
'libcef_dll/cpptoc/resource_bundle_cpptoc.cc',
'libcef_dll/cpptoc/resource_bundle_cpptoc.h',
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.cc',
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h',
'libcef_dll/ctocpp/resource_handler_ctocpp.cc',
'libcef_dll/ctocpp/resource_handler_ctocpp.h',
'libcef_dll/cpptoc/response_cpptoc.cc',
'libcef_dll/cpptoc/response_cpptoc.h',
'libcef_dll/cpptoc/run_context_menu_callback_cpptoc.cc',
'libcef_dll/cpptoc/run_context_menu_callback_cpptoc.h',
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc',
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h',
'libcef_dll/cpptoc/sslcert_principal_cpptoc.cc',
@@ -272,6 +282,18 @@
'libcef_dll/ctocpp/task_ctocpp.h',
'libcef_dll/cpptoc/task_runner_cpptoc.cc',
'libcef_dll/cpptoc/task_runner_cpptoc.h',
'libcef_dll/cpptoc/test/translator_test_cpptoc.cc',
'libcef_dll/cpptoc/test/translator_test_cpptoc.h',
'libcef_dll/ctocpp/test/translator_test_handler_ctocpp.cc',
'libcef_dll/ctocpp/test/translator_test_handler_ctocpp.h',
'libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.cc',
'libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.h',
'libcef_dll/cpptoc/test/translator_test_object_cpptoc.cc',
'libcef_dll/cpptoc/test/translator_test_object_cpptoc.h',
'libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.cc',
'libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.h',
'libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.cc',
'libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.h',
'libcef_dll/cpptoc/urlrequest_cpptoc.cc',
'libcef_dll/cpptoc/urlrequest_cpptoc.h',
'libcef_dll/ctocpp/urlrequest_client_ctocpp.cc',
@@ -394,6 +416,8 @@
'libcef_dll/ctocpp/navigation_entry_ctocpp.h',
'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.cc',
'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.h',
'libcef_dll/cpptoc/pdf_print_callback_cpptoc.cc',
'libcef_dll/cpptoc/pdf_print_callback_cpptoc.h',
'libcef_dll/ctocpp/post_data_ctocpp.cc',
'libcef_dll/ctocpp/post_data_ctocpp.h',
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
@@ -424,12 +448,16 @@
'libcef_dll/cpptoc/request_context_handler_cpptoc.h',
'libcef_dll/cpptoc/request_handler_cpptoc.cc',
'libcef_dll/cpptoc/request_handler_cpptoc.h',
'libcef_dll/ctocpp/resource_bundle_ctocpp.cc',
'libcef_dll/ctocpp/resource_bundle_ctocpp.h',
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.cc',
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h',
'libcef_dll/cpptoc/resource_handler_cpptoc.cc',
'libcef_dll/cpptoc/resource_handler_cpptoc.h',
'libcef_dll/ctocpp/response_ctocpp.cc',
'libcef_dll/ctocpp/response_ctocpp.h',
'libcef_dll/ctocpp/run_context_menu_callback_ctocpp.cc',
'libcef_dll/ctocpp/run_context_menu_callback_ctocpp.h',
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc',
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h',
'libcef_dll/ctocpp/sslcert_principal_ctocpp.cc',
@@ -452,6 +480,18 @@
'libcef_dll/cpptoc/task_cpptoc.h',
'libcef_dll/ctocpp/task_runner_ctocpp.cc',
'libcef_dll/ctocpp/task_runner_ctocpp.h',
'libcef_dll/ctocpp/test/translator_test_ctocpp.cc',
'libcef_dll/ctocpp/test/translator_test_ctocpp.h',
'libcef_dll/cpptoc/test/translator_test_handler_cpptoc.cc',
'libcef_dll/cpptoc/test/translator_test_handler_cpptoc.h',
'libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.cc',
'libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.h',
'libcef_dll/ctocpp/test/translator_test_object_ctocpp.cc',
'libcef_dll/ctocpp/test/translator_test_object_ctocpp.h',
'libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.cc',
'libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.h',
'libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.cc',
'libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.h',
'libcef_dll/ctocpp/urlrequest_ctocpp.cc',
'libcef_dll/ctocpp/urlrequest_ctocpp.h',
'libcef_dll/cpptoc/urlrequest_client_cpptoc.cc',

View File

@@ -96,12 +96,15 @@
],
'libcef_sources_common': [
'libcef_dll/cpptoc/cpptoc.h',
'libcef_dll/ctocpp/base_ctocpp.cc',
'libcef_dll/ctocpp/base_ctocpp.h',
'libcef_dll/ctocpp/ctocpp.h',
'libcef_dll/libcef_dll.cc',
'libcef_dll/libcef_dll2.cc',
'libcef_dll/resource.h',
'libcef_dll/transfer_util.cc',
'libcef_dll/transfer_util.h',
'libcef_dll/wrapper_types.h',
'<@(autogen_library_side)',
],
'libcef_dll_wrapper_sources_common': [
@@ -117,12 +120,13 @@
'libcef_dll/base/cef_thread_checker_impl.cc',
'libcef_dll/base/cef_thread_collision_warner.cc',
'libcef_dll/base/cef_weak_ptr.cc',
'libcef_dll/cpptoc/base_cpptoc.cc',
'libcef_dll/cpptoc/base_cpptoc.h',
'libcef_dll/cpptoc/cpptoc.h',
'libcef_dll/ctocpp/base_ctocpp.h',
'libcef_dll/ctocpp/ctocpp.h',
'libcef_dll/transfer_util.cc',
'libcef_dll/transfer_util.h',
'libcef_dll/wrapper_types.h',
'libcef_dll/wrapper/cef_browser_info_map.h',
'libcef_dll/wrapper/cef_byte_read_handler.cc',
'libcef_dll/wrapper/cef_closure_task.cc',
@@ -154,6 +158,8 @@
'tests/cefclient/browser/client_types.h',
'tests/cefclient/browser/dialog_test.cc',
'tests/cefclient/browser/dialog_test.h',
'tests/cefclient/browser/geometry_util.cc',
'tests/cefclient/browser/geometry_util.h',
'tests/cefclient/browser/main_context.cc',
'tests/cefclient/browser/main_context.h',
'tests/cefclient/browser/main_context_impl.cc',
@@ -210,6 +216,8 @@
'tests/cefclient/resources/logo.png',
'tests/cefclient/resources/osr_test.html',
'tests/cefclient/resources/other_tests.html',
'tests/cefclient/resources/pdf.html',
'tests/cefclient/resources/pdf.pdf',
'tests/cefclient/resources/performance.html',
'tests/cefclient/resources/performance2.html',
'tests/cefclient/resources/transparency.html',

View File

@@ -72,15 +72,16 @@ typedef int int32;
typedef unsigned int uint32;
#endif
// UTF-16 character type
#endif // !BUILDING_CEF_SHARED
// UTF-16 character type.
// This should be kept synchronized with base/strings/string16.h
#ifndef char16
#if defined(WIN32)
#if defined(WCHAR_T_IS_UTF16)
typedef wchar_t char16;
#else
#elif defined(WCHAR_T_IS_UTF32)
typedef unsigned short char16;
#endif
#endif
#endif // !BUILDING_CEF_SHARED
#endif // CEF_INCLUDE_BASE_CEF_BASICTYPES_H_

View File

@@ -57,7 +57,7 @@
namespace base {
namespace subtle {
namespace cef_subtle {
class RefCountedBase {
public:
@@ -141,7 +141,7 @@ class RefCountedThreadSafeBase {
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
};
} // namespace subtle
} // namespace cef_subtle
//
// A base class for reference counted classes. Otherwise, known as a cheap
@@ -158,16 +158,16 @@ class RefCountedThreadSafeBase {
// You should always make your destructor private, to avoid any code deleting
// the object accidently while there are references to it.
template <class T>
class RefCounted : public subtle::RefCountedBase {
class RefCounted : public cef_subtle::RefCountedBase {
public:
RefCounted() {}
void AddRef() const {
subtle::RefCountedBase::AddRef();
cef_subtle::RefCountedBase::AddRef();
}
void Release() const {
if (subtle::RefCountedBase::Release()) {
if (cef_subtle::RefCountedBase::Release()) {
delete static_cast<const T*>(this);
}
}
@@ -208,16 +208,16 @@ struct DefaultRefCountedThreadSafeTraits {
// friend class base::RefCountedThreadSafe<MyFoo>;
// ~MyFoo();
template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T> >
class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase {
class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
public:
RefCountedThreadSafe() {}
void AddRef() const {
subtle::RefCountedThreadSafeBase::AddRef();
cef_subtle::RefCountedThreadSafeBase::AddRef();
}
void Release() const {
if (subtle::RefCountedThreadSafeBase::Release()) {
if (cef_subtle::RefCountedThreadSafeBase::Release()) {
Traits::Destruct(static_cast<const T*>(this));
}
}

View File

@@ -56,7 +56,7 @@
#define CEF_INCLUDE_BASE_CEF_TUPLE_H_
#pragma once
#if defined(BASE_TUPLE_H__)
#if defined(BASE_TUPLE_H_)
// The Chromium header has already been included.
// This can happen in cases where Chromium code is used directly by the
// client application. When using Chromium code directly always include
@@ -65,6 +65,8 @@
// For legacy compatibility, we name the first 8 tuple elements "a", "b", ...
// TODO(cef): Remove this code when cef_runnable.h is deleted.
namespace base {
#define DEFINE_TUPLE_LEAF(N, x) \
template <typename T> \
struct TupleLeaf<N, T> { \
@@ -127,6 +129,8 @@ template <typename A,
typename H>
using Tuple8 = Tuple<A, B, C, D, E, F, G, H>;
} // namespace base
#elif defined(BUILDING_CEF_SHARED)
// When building CEF include the Chromium header directly.
#include "base/tuple.h"
@@ -137,6 +141,8 @@ using Tuple8 = Tuple<A, B, C, D, E, F, G, H>;
#include "include/base/cef_bind_helpers.h"
namespace base {
// Traits ----------------------------------------------------------------------
//
// A simple traits class for tuple arguments.
@@ -1394,6 +1400,8 @@ inline void DispatchToMethod(ObjT* obj, Method method,
&out->e);
}
} // namespace base
#endif // !BUILDING_CEF_SHARED
#endif // CEF_INCLUDE_BASE_CEF_TUPLE_H_

View File

@@ -2560,10 +2560,15 @@ struct BindState<Runnable, RunType, void()> : public BindStateBase {
typedef Invoker<0, BindState, RunType> InvokerType;
typedef typename InvokerType::UnboundRunType UnboundRunType;
explicit BindState(const Runnable& runnable)
: runnable_(runnable) {
: BindStateBase(&Destroy),
runnable_(runnable) {
}
virtual ~BindState() { }
~BindState() { }
static void Destroy(BindStateBase* self) {
delete static_cast<BindState*>(self);
}
RunnableType runnable_;
};
@@ -2579,14 +2584,19 @@ struct BindState<Runnable, RunType, void(P1)> : public BindStateBase {
typedef UnwrapTraits<P1> Bound1UnwrapTraits;
BindState(const Runnable& runnable, const P1& p1)
: runnable_(runnable),
: BindStateBase(&Destroy),
runnable_(runnable),
p1_(p1) {
MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
}
virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
P1>::Release(p1_); }
static void Destroy(BindStateBase* self) {
delete static_cast<BindState*>(self);
}
RunnableType runnable_;
P1 p1_;
};
@@ -2603,15 +2613,20 @@ struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase {
typedef UnwrapTraits<P2> Bound2UnwrapTraits;
BindState(const Runnable& runnable, const P1& p1, const P2& p2)
: runnable_(runnable),
: BindStateBase(&Destroy),
runnable_(runnable),
p1_(p1),
p2_(p2) {
MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
}
virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
P1>::Release(p1_); }
static void Destroy(BindStateBase* self) {
delete static_cast<BindState*>(self);
}
RunnableType runnable_;
P1 p1_;
P2 p2_;
@@ -2619,7 +2634,8 @@ struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase {
template <typename Runnable, typename RunType, typename P1, typename P2,
typename P3>
struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase {
struct BindState<Runnable, RunType, void(P1, P2, P3)>
: public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
typedef Invoker<3, BindState, RunType> InvokerType;
@@ -2631,16 +2647,21 @@ struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase {
typedef UnwrapTraits<P3> Bound3UnwrapTraits;
BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3)
: runnable_(runnable),
: BindStateBase(&Destroy),
runnable_(runnable),
p1_(p1),
p2_(p2),
p3_(p3) {
MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
}
virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
P1>::Release(p1_); }
static void Destroy(BindStateBase* self) {
delete static_cast<BindState*>(self);
}
RunnableType runnable_;
P1 p1_;
P2 p2_;
@@ -2649,8 +2670,8 @@ struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase {
template <typename Runnable, typename RunType, typename P1, typename P2,
typename P3, typename P4>
struct BindState<Runnable, RunType, void(P1, P2, P3,
P4)> : public BindStateBase {
struct BindState<Runnable, RunType, void(P1, P2, P3, P4)>
: public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
typedef Invoker<4, BindState, RunType> InvokerType;
@@ -2664,7 +2685,8 @@ struct BindState<Runnable, RunType, void(P1, P2, P3,
BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
const P4& p4)
: runnable_(runnable),
: BindStateBase(&Destroy),
runnable_(runnable),
p1_(p1),
p2_(p2),
p3_(p3),
@@ -2672,9 +2694,13 @@ struct BindState<Runnable, RunType, void(P1, P2, P3,
MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
}
virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
P1>::Release(p1_); }
static void Destroy(BindStateBase* self) {
delete static_cast<BindState*>(self);
}
RunnableType runnable_;
P1 p1_;
P2 p2_;
@@ -2684,8 +2710,8 @@ struct BindState<Runnable, RunType, void(P1, P2, P3,
template <typename Runnable, typename RunType, typename P1, typename P2,
typename P3, typename P4, typename P5>
struct BindState<Runnable, RunType, void(P1, P2, P3, P4,
P5)> : public BindStateBase {
struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5)>
: public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
typedef Invoker<5, BindState, RunType> InvokerType;
@@ -2700,7 +2726,8 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4,
BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
const P4& p4, const P5& p5)
: runnable_(runnable),
: BindStateBase(&Destroy),
runnable_(runnable),
p1_(p1),
p2_(p2),
p3_(p3),
@@ -2709,9 +2736,13 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4,
MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
}
virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
P1>::Release(p1_); }
static void Destroy(BindStateBase* self) {
delete static_cast<BindState*>(self);
}
RunnableType runnable_;
P1 p1_;
P2 p2_;
@@ -2722,8 +2753,8 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4,
template <typename Runnable, typename RunType, typename P1, typename P2,
typename P3, typename P4, typename P5, typename P6>
struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5,
P6)> : public BindStateBase {
struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6)>
: public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
typedef Invoker<6, BindState, RunType> InvokerType;
@@ -2739,7 +2770,8 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5,
BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
const P4& p4, const P5& p5, const P6& p6)
: runnable_(runnable),
: BindStateBase(&Destroy),
runnable_(runnable),
p1_(p1),
p2_(p2),
p3_(p3),
@@ -2749,9 +2781,13 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5,
MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
}
virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
P1>::Release(p1_); }
static void Destroy(BindStateBase* self) {
delete static_cast<BindState*>(self);
}
RunnableType runnable_;
P1 p1_;
P2 p2_;
@@ -2763,8 +2799,8 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5,
template <typename Runnable, typename RunType, typename P1, typename P2,
typename P3, typename P4, typename P5, typename P6, typename P7>
struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6,
P7)> : public BindStateBase {
struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6, P7)>
: public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
typedef Invoker<7, BindState, RunType> InvokerType;
@@ -2781,7 +2817,8 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6,
BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
const P4& p4, const P5& p5, const P6& p6, const P7& p7)
: runnable_(runnable),
: BindStateBase(&Destroy),
runnable_(runnable),
p1_(p1),
p2_(p2),
p3_(p3),
@@ -2792,9 +2829,13 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6,
MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
}
virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
P1>::Release(p1_); }
static void Destroy(BindStateBase* self) {
delete static_cast<BindState*>(self);
}
RunnableType runnable_;
P1 p1_;
P2 p2_;

View File

@@ -38,25 +38,43 @@
#include <stddef.h>
#include "include/base/cef_atomic_ref_count.h"
#include "include/base/cef_macros.h"
#include "include/base/cef_ref_counted.h"
#include "include/base/cef_scoped_ptr.h"
#include "include/base/cef_template_util.h"
template <typename T>
class ScopedVector;
namespace base {
namespace cef_internal {
class CallbackBase;
// BindStateBase is used to provide an opaque handle that the Callback
// class can use to represent a function object with bound arguments. It
// behaves as an existential type that is used by a corresponding
// DoInvoke function to perform the function execution. This allows
// us to shield the Callback class from the types of the bound argument via
// "type erasure."
class BindStateBase : public RefCountedThreadSafe<BindStateBase> {
// At the base level, the only task is to add reference counting data. Don't use
// RefCountedThreadSafe since it requires the destructor to be a virtual method.
// Creating a vtable for every BindState template instantiation results in a lot
// of bloat. Its only task is to call the destructor which can be done with a
// function pointer.
class BindStateBase {
protected:
friend class RefCountedThreadSafe<BindStateBase>;
virtual ~BindStateBase() {}
explicit BindStateBase(void (*destructor)(BindStateBase*))
: ref_count_(0), destructor_(destructor) {}
~BindStateBase() {}
private:
friend class scoped_refptr<BindStateBase>;
friend class CallbackBase;
void AddRef();
void Release();
AtomicRefCount ref_count_;
// Pointer to a function that will properly destroy |this|.
void (*destructor_)(BindStateBase*);
DISALLOW_COPY_AND_ASSIGN(BindStateBase);
};
// Holds the Callback methods that don't require specialization to reduce

View File

@@ -77,7 +77,8 @@ typedef struct _cef_base_t {
// Check that the structure |s|, which is defined with a cef_base_t member named
// |base|, is large enough to contain the specified member |f|.
#define CEF_MEMBER_EXISTS(s, f) \
((intptr_t)&((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= (s)->base.size)
((intptr_t)&((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= \
reinterpret_cast<cef_base_t*>(s)->size)
#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))

View File

@@ -230,6 +230,27 @@ typedef struct _cef_navigation_entry_visitor_t {
} cef_navigation_entry_visitor_t;
///
// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this
// structure will be called on the browser process UI thread.
///
typedef struct _cef_pdf_print_callback_t {
///
// Base structure.
///
cef_base_t base;
///
// Method that will be executed when the PDF printing has completed. |path| is
// the output path. |ok| will be true (1) if the printing completed
// successfully or false (0) otherwise.
///
void (CEF_CALLBACK *on_pdf_print_finished)(
struct _cef_pdf_print_callback_t* self, const cef_string_t* path,
int ok);
} cef_pdf_print_callback_t;
///
// Structure used to represent the browser process aspects of a browser window.
// The functions of this structure can only be called in the browser process.
@@ -346,6 +367,17 @@ typedef struct _cef_browser_host_t {
///
void (CEF_CALLBACK *print)(struct _cef_browser_host_t* self);
///
// Print the current browser contents to the PDF file specified by |path| and
// execute |callback| on completion. The caller is responsible for deleting
// |path| when done. For PDF printing to work on Linux you must implement the
// cef_print_handler_t::GetPdfPaperSize function.
///
void (CEF_CALLBACK *print_to_pdf)(struct _cef_browser_host_t* self,
const cef_string_t* path,
const struct _cef_pdf_print_settings_t* settings,
struct _cef_pdf_print_callback_t* callback);
///
// Search for |searchText|. |identifier| can be used to have multiple searches
// running simultaniously. |forward| indicates whether to search forward or
@@ -505,6 +537,26 @@ typedef struct _cef_browser_host_t {
void (CEF_CALLBACK *notify_move_or_resize_started)(
struct _cef_browser_host_t* self);
///
// Returns the maximum rate in frames per second (fps) that
// cef_render_handler_t:: OnPaint will be called for a windowless browser. The
// actual fps may be lower if the browser cannot generate frames at the
// requested rate. The minimum value is 1 and the maximum value is 60 (default
// 30). This function can only be called on the UI thread.
///
int (CEF_CALLBACK *get_windowless_frame_rate)(
struct _cef_browser_host_t* self);
///
// Set the maximum rate in frames per second (fps) that cef_render_handler_t::
// OnPaint will be called for a windowless browser. The actual fps may be
// lower if the browser cannot generate frames at the requested rate. The
// minimum value is 1 and the maximum value is 60 (default 30). Can also be
// set at browser creation via cef_browser_tSettings.windowless_frame_rate.
///
void (CEF_CALLBACK *set_windowless_frame_rate)(
struct _cef_browser_host_t* self, int frame_rate);
///
// Get the NSTextInputContext implementation for enabling IME on Mac when
// window rendering is disabled.

View File

@@ -49,6 +49,29 @@ extern "C" {
struct _cef_context_menu_params_t;
///
// Callback structure used for continuation of custom context menu display.
///
typedef struct _cef_run_context_menu_callback_t {
///
// Base structure.
///
cef_base_t base;
///
// Complete context menu display by selecting the specified |command_id| and
// |event_flags|.
///
void (CEF_CALLBACK *cont)(struct _cef_run_context_menu_callback_t* self,
int command_id, cef_event_flags_t event_flags);
///
// Cancel context menu display.
///
void (CEF_CALLBACK *cancel)(struct _cef_run_context_menu_callback_t* self);
} cef_run_context_menu_callback_t;
///
// Implement this structure to handle context menu events. The functions of this
// structure will be called on the UI thread.
@@ -71,6 +94,20 @@ typedef struct _cef_context_menu_handler_t {
struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params,
struct _cef_menu_model_t* model);
///
// Called to allow custom display of the context menu. |params| provides
// information about the context menu state. |model| contains the context menu
// model resulting from OnBeforeContextMenu. For custom display return true
// (1) and execute |callback| either synchronously or asynchronously with the
// selected command ID. For default display return false (0). Do not keep
// references to |params| or |model| outside of this callback.
///
int (CEF_CALLBACK *run_context_menu)(struct _cef_context_menu_handler_t* self,
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
struct _cef_context_menu_params_t* params,
struct _cef_menu_model_t* model,
struct _cef_run_context_menu_callback_t* callback);
///
// Called to execute a command selected from the context menu. Return true (1)
// if the command was handled or false (0) for the default implementation. See
@@ -232,6 +269,18 @@ typedef struct _cef_context_menu_params_t {
///
cef_context_menu_edit_state_flags_t (CEF_CALLBACK *get_edit_state_flags)(
struct _cef_context_menu_params_t* self);
///
// Returns true (1) if the context menu contains items specified by the
// renderer process (for example, plugin placeholder or pepper plugin menu
// items).
///
int (CEF_CALLBACK *is_custom_menu)(struct _cef_context_menu_params_t* self);
///
// Returns true (1) if the context menu was invoked from a pepper plugin.
///
int (CEF_CALLBACK *is_pepper_menu)(struct _cef_context_menu_params_t* self);
} cef_context_menu_params_t;

View File

@@ -60,10 +60,10 @@ typedef struct _cef_cookie_manager_t {
cef_base_t base;
///
// Set the schemes supported by this manager. By default only "http" and
// "https" schemes are supported. If |callback| is non-NULL it will be
// executed asnychronously on the IO thread after the change has been applied.
// Must be called before any cookies are accessed.
// Set the schemes supported by this manager. The default schemes ("http",
// "https", "ws" and "wss") will always be supported. If |callback| is non-
// NULL it will be executed asnychronously on the IO thread after the change
// has been applied. Must be called before any cookies are accessed.
///
void (CEF_CALLBACK *set_supported_schemes)(struct _cef_cookie_manager_t* self,
cef_string_list_t schemes, struct _cef_completion_callback_t* callback);

View File

@@ -76,6 +76,17 @@ typedef struct _cef_display_handler_t {
void (CEF_CALLBACK *on_favicon_urlchange)(struct _cef_display_handler_t* self,
struct _cef_browser_t* browser, cef_string_list_t icon_urls);
///
// Called when web content in the page has toggled fullscreen mode. If
// |fullscreen| is true (1) the content will automatically be sized to fill
// the browser content area. If |fullscreen| is false (0) the content will
// automatically return to its original size and position. The client is
// responsible for resizing the browser if desired.
///
void (CEF_CALLBACK *on_fullscreen_mode_change)(
struct _cef_display_handler_t* self, struct _cef_browser_t* browser,
int fullscreen);
///
// Called when the browser is about to display a tooltip. |text| contains the
// text that will be displayed in the tooltip. To handle the display of the

View File

@@ -101,14 +101,6 @@ typedef struct _cef_navigation_entry_t {
///
int (CEF_CALLBACK *has_post_data)(struct _cef_navigation_entry_t* self);
///
// Returns the name of the sub-frame that navigated or an NULL value if the
// main frame navigated.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_frame_name)(
struct _cef_navigation_entry_t* self);
///
// Returns the time for the last known successful navigation completion. A
// navigation may be completed more than once if the page is reloaded. May be

View File

@@ -95,6 +95,15 @@ typedef struct _cef_print_handler_t {
///
cef_base_t base;
///
// Called when printing has started for the specified |browser|. This function
// will be called before the other OnPrint*() functions and irrespective of
// how printing was initiated (e.g. cef_browser_host_t::print(), JavaScript
// window.print() or PDF extension print button).
///
void (CEF_CALLBACK *on_print_start)(struct _cef_print_handler_t* self,
struct _cef_browser_t* browser);
///
// Synchronize |settings| with client state. If |get_defaults| is true (1)
// then populate |settings| with the default print settings. Do not keep a
@@ -124,6 +133,13 @@ typedef struct _cef_print_handler_t {
// Reset client state related to printing.
///
void (CEF_CALLBACK *on_print_reset)(struct _cef_print_handler_t* self);
///
// Return the PDF paper size in device units. Used in combination with
// cef_browser_host_t::print_to_pdf().
///
cef_size_t (CEF_CALLBACK *get_pdf_paper_size)(
struct _cef_print_handler_t* self, int device_units_per_inch);
} cef_print_handler_t;

View File

@@ -140,6 +140,16 @@ typedef struct _cef_request_context_t {
///
int (CEF_CALLBACK *clear_scheme_handler_factories)(
struct _cef_request_context_t* self);
///
// Tells all renderer processes associated with this context to throw away
// their plugin list cache. If |reload_pages| is true (1) they will also
// reload all pages with plugins.
// cef_request_tContextHandler::OnBeforePluginLoad may be called to rebuild
// the plugin list cache.
///
void (CEF_CALLBACK *purge_plugin_list_cache)(
struct _cef_request_context_t* self, int reload_pages);
} cef_request_context_t;

View File

@@ -40,6 +40,7 @@
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_cookie_capi.h"
#include "include/capi/cef_web_plugin_capi.h"
#ifdef __cplusplus
extern "C" {
@@ -58,12 +59,36 @@ typedef struct _cef_request_context_handler_t {
cef_base_t base;
///
// Called on the IO thread to retrieve the cookie manager. If this function
// returns NULL the default cookie manager retrievable via
// Called on the browser process IO thread to retrieve the cookie manager. If
// this function returns NULL the default cookie manager retrievable via
// cef_request_tContext::get_default_cookie_manager() will be used.
///
struct _cef_cookie_manager_t* (CEF_CALLBACK *get_cookie_manager)(
struct _cef_request_context_handler_t* self);
///
// Called on multiple browser process threads before a plugin instance is
// loaded. |mime_type| is the mime type of the plugin that will be loaded.
// |plugin_url| is the content URL that the plugin will load and may be NULL.
// |top_origin_url| is the URL for the top-level frame that contains the
// plugin when loading a specific plugin instance or NULL when building the
// initial list of enabled plugins for 'navigator.plugins' JavaScript state.
// |plugin_info| includes additional information about the plugin that will be
// loaded. |plugin_policy| is the recommended policy. Modify |plugin_policy|
// and return true (1) to change the policy. Return false (0) to use the
// recommended policy. The default plugin policy can be set at runtime using
// the `--plugin-policy=[allow|detect|block]` command-line flag. Decisions to
// mark a plugin as disabled by setting |plugin_policy| to
// PLUGIN_POLICY_DISABLED may be cached when |top_origin_url| is NULL. To
// purge the plugin list cache and potentially trigger new calls to this
// function call cef_request_tContext::PurgePluginListCache.
///
int (CEF_CALLBACK *on_before_plugin_load)(
struct _cef_request_context_handler_t* self,
const cef_string_t* mime_type, const cef_string_t* plugin_url,
const cef_string_t* top_origin_url,
struct _cef_web_plugin_info_t* plugin_info,
cef_plugin_policy_t* plugin_policy);
} cef_request_context_handler_t;

View File

@@ -46,7 +46,6 @@
#include "include/capi/cef_resource_handler_capi.h"
#include "include/capi/cef_response_capi.h"
#include "include/capi/cef_ssl_info_capi.h"
#include "include/capi/cef_web_plugin_capi.h"
#ifdef __cplusplus
extern "C" {
@@ -214,14 +213,6 @@ typedef struct _cef_request_handler_t {
const cef_string_t* request_url, struct _cef_sslinfo_t* ssl_info,
struct _cef_request_callback_t* callback);
///
// Called on the browser process IO thread before a plugin is loaded. Return
// true (1) to block loading of the plugin.
///
int (CEF_CALLBACK *on_before_plugin_load)(struct _cef_request_handler_t* self,
struct _cef_browser_t* browser, const cef_string_t* url,
const cef_string_t* policy_url, struct _cef_web_plugin_info_t* info);
///
// Called on the browser process UI thread when a plugin has crashed.
// |plugin_path| is the path of the plugin that crashed.

View File

@@ -0,0 +1,107 @@
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Structure used for retrieving resources from the resource bundle (*.pak)
// files loaded by CEF during startup or via the cef_resource_bundle_tHandler
// returned from cef_app_t::GetResourceBundleHandler. See CefSettings for
// additional options related to resource bundle loading. The functions of this
// structure may be called on any thread unless otherwise indicated.
///
typedef struct _cef_resource_bundle_t {
///
// Base structure.
///
cef_base_t base;
///
// Returns the localized string for the specified |string_id| or an NULL
// string if the value is not found. Include cef_pack_strings.h for a listing
// of valid string ID values.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_localized_string)(
struct _cef_resource_bundle_t* self, int string_id);
///
// Retrieves the contents of the specified scale independent |resource_id|. If
// the value is found then |data| and |data_size| will be populated and this
// function will return true (1). If the value is not found then this function
// will return false (0). The returned |data| pointer will remain resident in
// memory and should not be freed. Include cef_pack_resources.h for a listing
// of valid resource ID values.
///
int (CEF_CALLBACK *get_data_resource)(struct _cef_resource_bundle_t* self,
int resource_id, void** data, size_t* data_size);
///
// Retrieves the contents of the specified |resource_id| nearest the scale
// factor |scale_factor|. Use a |scale_factor| value of SCALE_FACTOR_NONE for
// scale independent resources or call GetDataResource instead. If the value
// is found then |data| and |data_size| will be populated and this function
// will return true (1). If the value is not found then this function will
// return false (0). The returned |data| pointer will remain resident in
// memory and should not be freed. Include cef_pack_resources.h for a listing
// of valid resource ID values.
///
int (CEF_CALLBACK *get_data_resource_for_scale)(
struct _cef_resource_bundle_t* self, int resource_id,
cef_scale_factor_t scale_factor, void** data, size_t* data_size);
} cef_resource_bundle_t;
///
// Returns the global resource bundle instance.
///
CEF_EXPORT cef_resource_bundle_t* cef_resource_bundle_get_global();
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_

View File

@@ -46,8 +46,9 @@ extern "C" {
///
// Structure used to implement a custom resource bundle structure. The functions
// of this structure may be called on multiple threads.
// Structure used to implement a custom resource bundle structure. See
// CefSettings for additional options related to resource bundle loading. The
// functions of this structure may be called on multiple threads.
///
typedef struct _cef_resource_bundle_handler_t {
///
@@ -56,26 +57,38 @@ typedef struct _cef_resource_bundle_handler_t {
cef_base_t base;
///
// Called to retrieve a localized translation for the string specified by
// |message_id|. To provide the translation set |string| to the translation
// string and return true (1). To use the default translation return false
// (0). Supported message IDs are listed in cef_pack_strings.h.
// Called to retrieve a localized translation for the specified |string_id|.
// To provide the translation set |string| to the translation string and
// return true (1). To use the default translation return false (0). Include
// cef_pack_strings.h for a listing of valid string ID values.
///
int (CEF_CALLBACK *get_localized_string)(
struct _cef_resource_bundle_handler_t* self, int message_id,
struct _cef_resource_bundle_handler_t* self, int string_id,
cef_string_t* string);
///
// Called to retrieve data for the resource specified by |resource_id|. To
// provide the resource data set |data| and |data_size| to the data pointer
// Called to retrieve data for the specified scale independent |resource_id|.
// To provide the resource data set |data| and |data_size| to the data pointer
// and size respectively and return true (1). To use the default resource data
// return false (0). The resource data will not be copied and must remain
// resident in memory. Supported resource IDs are listed in
// cef_pack_resources.h.
// resident in memory. Include cef_pack_resources.h for a listing of valid
// resource ID values.
///
int (CEF_CALLBACK *get_data_resource)(
struct _cef_resource_bundle_handler_t* self, int resource_id, void** data,
size_t* data_size);
///
// Called to retrieve data for the specified |resource_id| nearest the scale
// factor |scale_factor|. To provide the resource data set |data| and
// |data_size| to the data pointer and size respectively and return true (1).
// To use the default resource data return false (0). The resource data will
// not be copied and must remain resident in memory. Include
// cef_pack_resources.h for a listing of valid resource ID values.
///
int (CEF_CALLBACK *get_data_resource_for_scale)(
struct _cef_resource_bundle_handler_t* self, int resource_id,
cef_scale_factor_t scale_factor, void** data, size_t* data_size);
} cef_resource_bundle_handler_t;

View File

@@ -39,12 +39,12 @@
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_browser_t;
///
// Information about a specific web plugin.

View File

@@ -101,7 +101,8 @@ typedef struct _cef_zip_reader_t {
///
// Returns the last modified timestamp for the file.
///
time_t (CEF_CALLBACK *get_file_last_modified)(struct _cef_zip_reader_t* self);
cef_time_t (CEF_CALLBACK *get_file_last_modified)(
struct _cef_zip_reader_t* self);
///
// Opens the file for reading of uncompressed data. A read password may

View File

@@ -0,0 +1,493 @@
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef CEF_INCLUDE_CAPI_TEST_CEF_TRANSLATOR_TEST_CAPI_H_
#define CEF_INCLUDE_CAPI_TEST_CEF_TRANSLATOR_TEST_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_translator_test_handler_child_t;
struct _cef_translator_test_handler_t;
struct _cef_translator_test_object_child_t;
struct _cef_translator_test_object_t;
///
// Structure for testing all of the possible data transfer types.
///
typedef struct _cef_translator_test_t {
///
// Base structure.
///
cef_base_t base;
// PRIMITIVE VALUES
///
// Return a void value.
///
void (CEF_CALLBACK *get_void)(struct _cef_translator_test_t* self);
///
// Return a bool value.
///
int (CEF_CALLBACK *get_bool)(struct _cef_translator_test_t* self);
///
// Return an int value.
///
int (CEF_CALLBACK *get_int)(struct _cef_translator_test_t* self);
///
// Return a double value.
///
double (CEF_CALLBACK *get_double)(struct _cef_translator_test_t* self);
///
// Return a long value.
///
long (CEF_CALLBACK *get_long)(struct _cef_translator_test_t* self);
///
// Return a size_t value.
///
size_t (CEF_CALLBACK *get_sizet)(struct _cef_translator_test_t* self);
///
// Set a void value.
///
int (CEF_CALLBACK *set_void)(struct _cef_translator_test_t* self);
///
// Set a bool value.
///
int (CEF_CALLBACK *set_bool)(struct _cef_translator_test_t* self, int val);
///
// Set an int value.
///
int (CEF_CALLBACK *set_int)(struct _cef_translator_test_t* self, int val);
///
// Set a double value.
///
int (CEF_CALLBACK *set_double)(struct _cef_translator_test_t* self,
double val);
///
// Set a long value.
///
int (CEF_CALLBACK *set_long)(struct _cef_translator_test_t* self, long val);
///
// Set a size_t value.
///
int (CEF_CALLBACK *set_sizet)(struct _cef_translator_test_t* self,
size_t val);
///
// Set a int list value.
///
int (CEF_CALLBACK *set_int_list)(struct _cef_translator_test_t* self,
size_t valCount, int const* val);
///
// Return an int list value by out-param.
///
int (CEF_CALLBACK *get_int_list_by_ref)(struct _cef_translator_test_t* self,
size_t* valCount, int* val);
///
// Return the number of points that will be output above.
///
size_t (CEF_CALLBACK *get_int_list_size)(struct _cef_translator_test_t* self);
// STRING VALUES
///
// Return a string value.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_string)(
struct _cef_translator_test_t* self);
///
// Set a string value.
///
int (CEF_CALLBACK *set_string)(struct _cef_translator_test_t* self,
const cef_string_t* val);
///
// Return a string value by out-param.
///
void (CEF_CALLBACK *get_string_by_ref)(struct _cef_translator_test_t* self,
cef_string_t* val);
///
// Set a string list value.
///
int (CEF_CALLBACK *set_string_list)(struct _cef_translator_test_t* self,
cef_string_list_t val);
///
// Return a string list value by out-param.
///
int (CEF_CALLBACK *get_string_list_by_ref)(
struct _cef_translator_test_t* self, cef_string_list_t val);
///
// Set a string map value.
///
int (CEF_CALLBACK *set_string_map)(struct _cef_translator_test_t* self,
cef_string_map_t val);
///
// Return a string map value by out-param.
///
int (CEF_CALLBACK *get_string_map_by_ref)(struct _cef_translator_test_t* self,
cef_string_map_t val);
///
// Set a string multimap value.
///
int (CEF_CALLBACK *set_string_multimap)(struct _cef_translator_test_t* self,
cef_string_multimap_t val);
///
// Return a string multimap value by out-param.
///
int (CEF_CALLBACK *get_string_multimap_by_ref)(
struct _cef_translator_test_t* self, cef_string_multimap_t val);
// STRUCT VALUES
///
// Return a point value.
///
cef_point_t (CEF_CALLBACK *get_point)(struct _cef_translator_test_t* self);
///
// Set a point value.
///
int (CEF_CALLBACK *set_point)(struct _cef_translator_test_t* self,
const cef_point_t* val);
///
// Return a point value by out-param.
///
void (CEF_CALLBACK *get_point_by_ref)(struct _cef_translator_test_t* self,
cef_point_t* val);
///
// Set a point list vlaue.
///
int (CEF_CALLBACK *set_point_list)(struct _cef_translator_test_t* self,
size_t valCount, cef_point_t const* val);
///
// Return a point list value by out-param.
///
int (CEF_CALLBACK *get_point_list_by_ref)(struct _cef_translator_test_t* self,
size_t* valCount, cef_point_t* val);
///
// Return the number of points that will be output above.
///
size_t (CEF_CALLBACK *get_point_list_size)(
struct _cef_translator_test_t* self);
// LIBRARY-SIDE OBJECT VALUES
///
// Return an new library-side object.
///
struct _cef_translator_test_object_t* (CEF_CALLBACK *get_object)(
struct _cef_translator_test_t* self, int val);
///
// Set an object. Returns the value from
// cef_translator_test_object_t::get_value(). This tests input and execution
// of a library-side object type.
///
int (CEF_CALLBACK *set_object)(struct _cef_translator_test_t* self,
struct _cef_translator_test_object_t* val);
///
// Set an object. Returns the object passed in. This tests input and output of
// a library-side object type.
///
struct _cef_translator_test_object_t* (CEF_CALLBACK *set_object_and_return)(
struct _cef_translator_test_t* self,
struct _cef_translator_test_object_t* val);
///
// Set a child object. Returns the value from
// cef_translator_test_object_t::get_value(). This tests input of a library-
// side child object type and execution as the parent type.
///
int (CEF_CALLBACK *set_child_object)(struct _cef_translator_test_t* self,
struct _cef_translator_test_object_child_t* val);
///
// Set a child object. Returns the object as the parent type. This tests input
// of a library-side child object type and return as the parent type.
///
struct _cef_translator_test_object_t* (
CEF_CALLBACK *set_child_object_and_return_parent)(
struct _cef_translator_test_t* self,
struct _cef_translator_test_object_child_t* val);
///
// Set an object list vlaue.
///
int (CEF_CALLBACK *set_object_list)(struct _cef_translator_test_t* self,
size_t valCount, struct _cef_translator_test_object_t* const* val,
int val1, int val2);
///
// Return an object list value by out-param.
///
int (CEF_CALLBACK *get_object_list_by_ref)(
struct _cef_translator_test_t* self, size_t* valCount,
struct _cef_translator_test_object_t** val, int val1, int val2);
///
// Return the number of object that will be output above.
///
size_t (CEF_CALLBACK *get_object_list_size)(
struct _cef_translator_test_t* self);
// CLIENT-SIDE OBJECT VALUES
///
// Set an object. Returns the value from
// cef_translator_test_handler_t::get_value(). This tests input and execution
// of a client-side object type.
///
int (CEF_CALLBACK *set_handler)(struct _cef_translator_test_t* self,
struct _cef_translator_test_handler_t* val);
///
// Set an object. Returns the handler passed in. This tests input and output
// of a client-side object type.
///
struct _cef_translator_test_handler_t* (CEF_CALLBACK *set_handler_and_return)(
struct _cef_translator_test_t* self,
struct _cef_translator_test_handler_t* val);
///
// Set a child object. Returns the value from
// cef_translator_test_handler_t::get_value(). This tests input of a client-
// side child object type and execution as the parent type.
///
int (CEF_CALLBACK *set_child_handler)(struct _cef_translator_test_t* self,
struct _cef_translator_test_handler_child_t* val);
///
// Set a child object. Returns the object as the parent type. This tests input
// of a client-side child object type and return as the parent type.
///
struct _cef_translator_test_handler_t* (
CEF_CALLBACK *set_child_handler_and_return_parent)(
struct _cef_translator_test_t* self,
struct _cef_translator_test_handler_child_t* val);
///
// Set an object list vlaue.
///
int (CEF_CALLBACK *set_handler_list)(struct _cef_translator_test_t* self,
size_t valCount, struct _cef_translator_test_handler_t* const* val,
int val1, int val2);
///
// Return an object list value by out-param.
///
int (CEF_CALLBACK *get_handler_list_by_ref)(
struct _cef_translator_test_t* self, size_t* valCount,
struct _cef_translator_test_handler_t** val,
struct _cef_translator_test_handler_t* val1,
struct _cef_translator_test_handler_t* val2);
///
// Return the number of object that will be output above.
///
size_t (CEF_CALLBACK *get_handler_list_size)(
struct _cef_translator_test_t* self);
} cef_translator_test_t;
///
// Create the test object.
///
CEF_EXPORT cef_translator_test_t* cef_translator_test_create();
///
// Library-side test object.
///
typedef struct _cef_translator_test_object_t {
///
// Base structure.
///
cef_base_t base;
///
// Return a value.
///
int (CEF_CALLBACK *get_value)(struct _cef_translator_test_object_t* self);
///
// Set a value.
///
void (CEF_CALLBACK *set_value)(struct _cef_translator_test_object_t* self,
int value);
} cef_translator_test_object_t;
///
// Create the test object.
///
CEF_EXPORT cef_translator_test_object_t* cef_translator_test_object_create(
int value);
///
// Library-side child test object.
///
typedef struct _cef_translator_test_object_child_t {
///
// Base structure.
///
cef_translator_test_object_t base;
///
// Return a value.
///
int (CEF_CALLBACK *get_other_value)(
struct _cef_translator_test_object_child_t* self);
///
// Set a value.
///
void (CEF_CALLBACK *set_other_value)(
struct _cef_translator_test_object_child_t* self, int value);
} cef_translator_test_object_child_t;
///
// Create the test object.
///
CEF_EXPORT cef_translator_test_object_child_t* cef_translator_test_object_child_create(
int value, int other_value);
///
// Another library-side child test object.
///
typedef struct _cef_translator_test_object_child_child_t {
///
// Base structure.
///
cef_translator_test_object_child_t base;
///
// Return a value.
///
int (CEF_CALLBACK *get_other_other_value)(
struct _cef_translator_test_object_child_child_t* self);
///
// Set a value.
///
void (CEF_CALLBACK *set_other_other_value)(
struct _cef_translator_test_object_child_child_t* self, int value);
} cef_translator_test_object_child_child_t;
///
// Create the test object.
///
CEF_EXPORT cef_translator_test_object_child_child_t* cef_translator_test_object_child_child_create(
int value, int other_value, int other_other_value);
///
// Client-side test object.
///
typedef struct _cef_translator_test_handler_t {
///
// Base structure.
///
cef_base_t base;
///
// Return a value.
///
int (CEF_CALLBACK *get_value)(struct _cef_translator_test_handler_t* self);
} cef_translator_test_handler_t;
///
// Client-side child test object.
///
typedef struct _cef_translator_test_handler_child_t {
///
// Base structure.
///
cef_translator_test_handler_t base;
///
// Return a value.
///
int (CEF_CALLBACK *get_other_value)(
struct _cef_translator_test_handler_child_t* self);
} cef_translator_test_handler_child_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_TEST_CEF_TRANSLATOR_TEST_CAPI_H_

View File

@@ -234,6 +234,23 @@ class CefNavigationEntryVisitor : public virtual CefBase {
};
///
// Callback interface for CefBrowserHost::PrintToPDF. The methods of this class
// will be called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefPdfPrintCallback : public virtual CefBase {
public:
///
// Method that will be executed when the PDF printing has completed. |path|
// is the output path. |ok| will be true if the printing completed
// successfully or false otherwise.
///
/*--cef()--*/
virtual void OnPdfPrintFinished(const CefString& path, bool ok) =0;
};
///
// Class used to represent the browser process aspects of a browser window. The
// methods of this class can only be called in the browser process. They may be
@@ -389,6 +406,17 @@ class CefBrowserHost : public virtual CefBase {
/*--cef()--*/
virtual void Print() =0;
///
// Print the current browser contents to the PDF file specified by |path| and
// execute |callback| on completion. The caller is responsible for deleting
// |path| when done. For PDF printing to work on Linux you must implement the
// CefPrintHandler::GetPdfPaperSize method.
///
/*--cef(optional_param=callback)--*/
virtual void PrintToPDF(const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback) =0;
///
// Search for |searchText|. |identifier| can be used to have multiple searches
// running simultaniously. |forward| indicates whether to search forward or
@@ -555,6 +583,26 @@ class CefBrowserHost : public virtual CefBase {
/*--cef()--*/
virtual void NotifyMoveOrResizeStarted() =0;
///
// Returns the maximum rate in frames per second (fps) that CefRenderHandler::
// OnPaint will be called for a windowless browser. The actual fps may be
// lower if the browser cannot generate frames at the requested rate. The
// minimum value is 1 and the maximum value is 60 (default 30). This method
// can only be called on the UI thread.
///
/*--cef()--*/
virtual int GetWindowlessFrameRate() =0;
///
// Set the maximum rate in frames per second (fps) that CefRenderHandler::
// OnPaint will be called for a windowless browser. The actual fps may be
// lower if the browser cannot generate frames at the requested rate. The
// minimum value is 1 and the maximum value is 60 (default 30). Can also be
// set at browser creation via CefBrowserSettings.windowless_frame_rate.
///
/*--cef()--*/
virtual void SetWindowlessFrameRate(int frame_rate) =0;
///
// Get the NSTextInputContext implementation for enabling IME on Mac when
// window rendering is disabled.

View File

@@ -45,6 +45,30 @@
class CefContextMenuParams;
///
// Callback interface used for continuation of custom context menu display.
///
/*--cef(source=library)--*/
class CefRunContextMenuCallback : public virtual CefBase {
public:
typedef cef_event_flags_t EventFlags;
///
// Complete context menu display by selecting the specified |command_id| and
// |event_flags|.
///
/*--cef(capi_name=cont)--*/
virtual void Continue(int command_id, EventFlags event_flags) =0;
///
// Cancel context menu display.
///
/*--cef()--*/
virtual void Cancel() =0;
};
///
// Implement this interface to handle context menu events. The methods of this
// class will be called on the UI thread.
@@ -67,6 +91,23 @@ class CefContextMenuHandler : public virtual CefBase {
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> model) {}
///
// Called to allow custom display of the context menu. |params| provides
// information about the context menu state. |model| contains the context menu
// model resulting from OnBeforeContextMenu. For custom display return true
// and execute |callback| either synchronously or asynchronously with the
// selected command ID. For default display return false. Do not keep
// references to |params| or |model| outside of this callback.
///
/*--cef()--*/
virtual bool RunContextMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> model,
CefRefPtr<CefRunContextMenuCallback> callback) {
return false;
}
///
// Called to execute a command selected from the context menu. Return true if
// the command was handled or false for the default implementation. See
@@ -226,6 +267,19 @@ class CefContextMenuParams : public virtual CefBase {
///
/*--cef(default_retval=CM_EDITFLAG_NONE)--*/
virtual EditStateFlags GetEditStateFlags() =0;
///
// Returns true if the context menu contains items specified by the renderer
// process (for example, plugin placeholder or pepper plugin menu items).
///
/*--cef()--*/
virtual bool IsCustomMenu() =0;
///
// Returns true if the context menu was invoked from a pepper plugin.
///
/*--cef()--*/
virtual bool IsPepperMenu() =0;
};
#endif // CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_

View File

@@ -80,10 +80,10 @@ class CefCookieManager : public virtual CefBase {
CefRefPtr<CefCompletionCallback> callback);
///
// Set the schemes supported by this manager. By default only "http" and
// "https" schemes are supported. If |callback| is non-NULL it will be
// executed asnychronously on the IO thread after the change has been applied.
// Must be called before any cookies are accessed.
// Set the schemes supported by this manager. The default schemes ("http",
// "https", "ws" and "wss") will always be supported. If |callback| is non-
// NULL it will be executed asnychronously on the IO thread after the change
// has been applied. Must be called before any cookies are accessed.
///
/*--cef(optional_param=callback)--*/
virtual void SetSupportedSchemes(

View File

@@ -71,6 +71,17 @@ class CefDisplayHandler : public virtual CefBase {
virtual void OnFaviconURLChange(CefRefPtr<CefBrowser> browser,
const std::vector<CefString>& icon_urls) {}
///
// Called when web content in the page has toggled fullscreen mode. If
// |fullscreen| is true the content will automatically be sized to fill the
// browser content area. If |fullscreen| is false the content will
// automatically return to its original size and position. The client is
// responsible for resizing the browser if desired.
///
/*--cef()--*/
virtual void OnFullscreenModeChange(CefRefPtr<CefBrowser> browser,
bool fullscreen) {}
///
// Called when the browser is about to display a tooltip. |text| contains the
// text that will be displayed in the tooltip. To handle the display of the

View File

@@ -93,13 +93,6 @@ class CefNavigationEntry : public virtual CefBase {
/*--cef()--*/
virtual bool HasPostData() =0;
///
// Returns the name of the sub-frame that navigated or an empty value if the
// main frame navigated.
///
/*--cef()--*/
virtual CefString GetFrameName() =0;
///
// Returns the time for the last known successful navigation completion. A
// navigation may be completed more than once if the page is reloaded. May be

View File

@@ -82,6 +82,15 @@ class CefPrintJobCallback : public virtual CefBase {
/*--cef(source=client)--*/
class CefPrintHandler : public virtual CefBase {
public:
///
// Called when printing has started for the specified |browser|. This method
// will be called before the other OnPrint*() methods and irrespective of how
// printing was initiated (e.g. CefBrowserHost::Print(), JavaScript
// window.print() or PDF extension print button).
///
/*--cef()--*/
virtual void OnPrintStart(CefRefPtr<CefBrowser> browser) =0;
///
// Synchronize |settings| with client state. If |get_defaults| is true then
// populate |settings| with the default print settings. Do not keep a
@@ -115,6 +124,15 @@ class CefPrintHandler : public virtual CefBase {
///
/*--cef()--*/
virtual void OnPrintReset() =0;
///
// Return the PDF paper size in device units. Used in combination with
// CefBrowserHost::PrintToPDF().
///
/*--cef()--*/
virtual CefSize GetPdfPaperSize(int device_units_per_inch) {
return CefSize();
}
};
#endif // CEF_INCLUDE_CEF_PRINT_HANDLER_H_

View File

@@ -157,6 +157,15 @@ class CefRequestContext : public virtual CefBase {
///
/*--cef()--*/
virtual bool ClearSchemeHandlerFactories() =0;
///
// Tells all renderer processes associated with this context to throw away
// their plugin list cache. If |reload_pages| is true they will also reload
// all pages with plugins. CefRequestContextHandler::OnBeforePluginLoad may
// be called to rebuild the plugin list cache.
///
/*--cef()--*/
virtual void PurgePluginListCache(bool reload_pages) =0;
};
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_

View File

@@ -40,6 +40,7 @@
#include "include/cef_base.h"
#include "include/cef_cookie.h"
#include "include/cef_web_plugin.h"
///
// Implement this interface to provide handler implementations. The handler
@@ -49,13 +50,41 @@
/*--cef(source=client,no_debugct_check)--*/
class CefRequestContextHandler : public virtual CefBase {
public:
typedef cef_plugin_policy_t PluginPolicy;
///
// Called on the IO thread to retrieve the cookie manager. If this method
// returns NULL the default cookie manager retrievable via
// Called on the browser process IO thread to retrieve the cookie manager. If
// this method returns NULL the default cookie manager retrievable via
// CefRequestContext::GetDefaultCookieManager() will be used.
///
/*--cef()--*/
virtual CefRefPtr<CefCookieManager> GetCookieManager() { return NULL; }
///
// Called on multiple browser process threads before a plugin instance is
// loaded. |mime_type| is the mime type of the plugin that will be loaded.
// |plugin_url| is the content URL that the plugin will load and may be empty.
// |top_origin_url| is the URL for the top-level frame that contains the
// plugin when loading a specific plugin instance or empty when building the
// initial list of enabled plugins for 'navigator.plugins' JavaScript state.
// |plugin_info| includes additional information about the plugin that will be
// loaded. |plugin_policy| is the recommended policy. Modify |plugin_policy|
// and return true to change the policy. Return false to use the recommended
// policy. The default plugin policy can be set at runtime using the
// `--plugin-policy=[allow|detect|block]` command-line flag. Decisions to mark
// a plugin as disabled by setting |plugin_policy| to PLUGIN_POLICY_DISABLED
// may be cached when |top_origin_url| is empty. To purge the plugin list
// cache and potentially trigger new calls to this method call
// CefRequestContext::PurgePluginListCache.
///
/*--cef(optional_param=plugin_url,optional_param=top_origin_url)--*/
virtual bool OnBeforePluginLoad(const CefString& mime_type,
const CefString& plugin_url,
const CefString& top_origin_url,
CefRefPtr<CefWebPluginInfo> plugin_info,
PluginPolicy* plugin_policy) {
return false;
}
};
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_HANDLER_H_

View File

@@ -46,7 +46,6 @@
#include "include/cef_response.h"
#include "include/cef_request.h"
#include "include/cef_ssl_info.h"
#include "include/cef_web_plugin.h"
///
@@ -248,18 +247,6 @@ class CefRequestHandler : public virtual CefBase {
return false;
}
///
// Called on the browser process IO thread before a plugin is loaded. Return
// true to block loading of the plugin.
///
/*--cef(optional_param=url,optional_param=policy_url)--*/
virtual bool OnBeforePluginLoad(CefRefPtr<CefBrowser> browser,
const CefString& url,
const CefString& policy_url,
CefRefPtr<CefWebPluginInfo> info) {
return false;
}
///
// Called on the browser process UI thread when a plugin has crashed.
// |plugin_path| is the path of the plugin that crashed.

View File

@@ -0,0 +1,99 @@
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_RESOURCE_BUNDLE_H_
#define CEF_INCLUDE_CEF_RESOURCE_BUNDLE_H_
#pragma once
#include "include/cef_base.h"
///
// Class used for retrieving resources from the resource bundle (*.pak) files
// loaded by CEF during startup or via the CefResourceBundleHandler returned
// from CefApp::GetResourceBundleHandler. See CefSettings for additional options
// related to resource bundle loading. The methods of this class may be called
// on any thread unless otherwise indicated.
///
/*--cef(source=library,no_debugct_check)--*/
class CefResourceBundle : public virtual CefBase {
public:
typedef cef_scale_factor_t ScaleFactor;
///
// Returns the global resource bundle instance.
///
/*--cef()--*/
static CefRefPtr<CefResourceBundle> GetGlobal();
///
// Returns the localized string for the specified |string_id| or an empty
// string if the value is not found. Include cef_pack_strings.h for a listing
// of valid string ID values.
///
/*--cef()--*/
virtual CefString GetLocalizedString(int string_id) =0;
///
// Retrieves the contents of the specified scale independent |resource_id|.
// If the value is found then |data| and |data_size| will be populated and
// this method will return true. If the value is not found then this method
// will return false. The returned |data| pointer will remain resident in
// memory and should not be freed. Include cef_pack_resources.h for a listing
// of valid resource ID values.
///
/*--cef()--*/
virtual bool GetDataResource(int resource_id,
void*& data,
size_t& data_size) =0;
///
// Retrieves the contents of the specified |resource_id| nearest the scale
// factor |scale_factor|. Use a |scale_factor| value of SCALE_FACTOR_NONE for
// scale independent resources or call GetDataResource instead. If the value
// is found then |data| and |data_size| will be populated and this method will
// return true. If the value is not found then this method will return false.
// The returned |data| pointer will remain resident in memory and should not
// be freed. Include cef_pack_resources.h for a listing of valid resource ID
// values.
///
/*--cef()--*/
virtual bool GetDataResourceForScale(int resource_id,
ScaleFactor scale_factor,
void*& data,
size_t& data_size) =0;
};
#endif // CEF_INCLUDE_CEF_RESOURCE_BUNDLE_H_

View File

@@ -41,33 +41,51 @@
#include "include/cef_base.h"
///
// Class used to implement a custom resource bundle interface. The methods of
// Class used to implement a custom resource bundle interface. See CefSettings
// for additional options related to resource bundle loading. The methods of
// this class may be called on multiple threads.
///
/*--cef(source=client)--*/
class CefResourceBundleHandler : public virtual CefBase {
public:
typedef cef_scale_factor_t ScaleFactor;
///
// Called to retrieve a localized translation for the string specified by
// |message_id|. To provide the translation set |string| to the translation
// string and return true. To use the default translation return false.
// Supported message IDs are listed in cef_pack_strings.h.
// Called to retrieve a localized translation for the specified |string_id|.
// To provide the translation set |string| to the translation string and
// return true. To use the default translation return false. Include
// cef_pack_strings.h for a listing of valid string ID values.
///
/*--cef()--*/
virtual bool GetLocalizedString(int message_id,
virtual bool GetLocalizedString(int string_id,
CefString& string) =0;
///
// Called to retrieve data for the resource specified by |resource_id|. To
// provide the resource data set |data| and |data_size| to the data pointer
// Called to retrieve data for the specified scale independent |resource_id|.
// To provide the resource data set |data| and |data_size| to the data pointer
// and size respectively and return true. To use the default resource data
// return false. The resource data will not be copied and must remain resident
// in memory. Supported resource IDs are listed in cef_pack_resources.h.
// in memory. Include cef_pack_resources.h for a listing of valid resource ID
// values.
///
/*--cef()--*/
virtual bool GetDataResource(int resource_id,
void*& data,
size_t& data_size) =0;
///
// Called to retrieve data for the specified |resource_id| nearest the scale
// factor |scale_factor|. To provide the resource data set |data| and
// |data_size| to the data pointer and size respectively and return true. To
// use the default resource data return false. The resource data will not be
// copied and must remain resident in memory. Include cef_pack_resources.h for
// a listing of valid resource ID values.
///
/*--cef()--*/
virtual bool GetDataResourceForScale(int resource_id,
ScaleFactor scale_factor,
void*& data,
size_t& data_size) =0;
};
#endif // CEF_INCLUDE_CEF_RESOURCE_BUNDLE_HANDLER_H_

View File

@@ -164,41 +164,38 @@ class CefRunnableMethod : public CefTask {
template <class T, class Method>
inline CefRefPtr<CefTask> NewCefRunnableMethod(T* object, Method method) {
return new CefRunnableMethod<T, Method, Tuple0>(object, method, MakeTuple());
return new CefRunnableMethod<T, Method, base::Tuple0>(
object, method, base::MakeTuple());
}
template <class T, class Method, class A>
inline CefRefPtr<CefTask> NewCefRunnableMethod(T* object, Method method,
const A& a) {
return new CefRunnableMethod<T, Method, Tuple1<A> >(object,
method,
MakeTuple(a));
return new CefRunnableMethod<T, Method, base::Tuple1<A> >(
object, method, base::MakeTuple(a));
}
template <class T, class Method, class A, class B>
inline CefRefPtr<CefTask> NewCefRunnableMethod(T* object, Method method,
const A& a, const B& b) {
return new CefRunnableMethod<T, Method, Tuple2<A, B> >(object, method,
MakeTuple(a, b));
return new CefRunnableMethod<T, Method, base::Tuple2<A, B> >(
object, method, base::MakeTuple(a, b));
}
template <class T, class Method, class A, class B, class C>
inline CefRefPtr<CefTask> NewCefRunnableMethod(T* object, Method method,
const A& a, const B& b,
const C& c) {
return new CefRunnableMethod<T, Method, Tuple3<A, B, C> >(object, method,
MakeTuple(a, b,
c));
return new CefRunnableMethod<T, Method, base::Tuple3<A, B, C> >(
object, method, base::MakeTuple(a, b, c));
}
template <class T, class Method, class A, class B, class C, class D>
inline CefRefPtr<CefTask> NewCefRunnableMethod(T* object, Method method,
const A& a, const B& b,
const C& c, const D& d) {
return new CefRunnableMethod<T, Method, Tuple4<A, B, C, D> >(object, method,
MakeTuple(a, b,
c,
d));
return new CefRunnableMethod<T, Method, base::Tuple4<A, B, C, D> >(
object, method, base::MakeTuple(a, b, c, d));
}
template <class T, class Method, class A, class B, class C, class D, class E>
@@ -206,12 +203,8 @@ inline CefRefPtr<CefTask> NewCefRunnableMethod(T* object, Method method,
const A& a, const B& b,
const C& c, const D& d,
const E& e) {
return new CefRunnableMethod<T,
Method,
Tuple5<A, B, C, D, E> >(object,
method,
MakeTuple(a, b, c, d,
e));
return new CefRunnableMethod<T, Method, base::Tuple5<A, B, C, D, E> >(
object, method, base::MakeTuple(a, b, c, d, e));
}
template <class T, class Method, class A, class B, class C, class D, class E,
@@ -220,12 +213,8 @@ inline CefRefPtr<CefTask> NewCefRunnableMethod(T* object, Method method,
const A& a, const B& b,
const C& c, const D& d,
const E& e, const F& f) {
return new CefRunnableMethod<T,
Method,
Tuple6<A, B, C, D, E, F> >(object,
method,
MakeTuple(a, b, c, d,
e, f));
return new CefRunnableMethod<T, Method, base::Tuple6<A, B, C, D, E, F> >(
object, method, base::MakeTuple(a, b, c, d, e, f));
}
template <class T, class Method, class A, class B, class C, class D, class E,
@@ -235,13 +224,8 @@ inline CefRefPtr<CefTask> NewCefRunnableMethod(T* object, Method method,
const C& c, const D& d,
const E& e, const F& f,
const G& g) {
return new CefRunnableMethod<T,
Method,
Tuple7<A, B, C, D, E, F, G> >(object,
method,
MakeTuple(a, b, c,
d, e, f,
g));
return new CefRunnableMethod<T, Method, base::Tuple7<A, B, C, D, E, F, G> >(
object, method, base::MakeTuple(a, b, c, d, e, f, g));
}
// CefRunnableFunction and NewCefRunnableFunction implementation --------------
@@ -270,39 +254,38 @@ class CefRunnableFunction : public CefTask {
template <class Function>
inline CefRefPtr<CefTask> NewCefRunnableFunction(Function function) {
return new CefRunnableFunction<Function, Tuple0>(function, MakeTuple());
return new CefRunnableFunction<Function, base::Tuple0>(
function, base::MakeTuple());
}
template <class Function, class A>
inline CefRefPtr<CefTask> NewCefRunnableFunction(Function function,
const A& a) {
return new CefRunnableFunction<Function, Tuple1<A> >(function, MakeTuple(a));
return new CefRunnableFunction<Function, base::Tuple1<A> >(
function, base::MakeTuple(a));
}
template <class Function, class A, class B>
inline CefRefPtr<CefTask> NewCefRunnableFunction(Function function,
const A& a, const B& b) {
return new CefRunnableFunction<Function, Tuple2<A, B> >(function,
MakeTuple(a, b));
return new CefRunnableFunction<Function, base::Tuple2<A, B> >(
function, base::MakeTuple(a, b));
}
template <class Function, class A, class B, class C>
inline CefRefPtr<CefTask> NewCefRunnableFunction(Function function,
const A& a, const B& b,
const C& c) {
return new CefRunnableFunction<Function, Tuple3<A, B, C> >(function,
MakeTuple(a, b,
c));
return new CefRunnableFunction<Function, base::Tuple3<A, B, C> >(
function, base::MakeTuple(a, b, c));
}
template <class Function, class A, class B, class C, class D>
inline CefRefPtr<CefTask> NewCefRunnableFunction(Function function,
const A& a, const B& b,
const C& c, const D& d) {
return new CefRunnableFunction<Function, Tuple4<A, B, C, D> >(function,
MakeTuple(a, b,
c,
d));
return new CefRunnableFunction<Function, base::Tuple4<A, B, C, D> >(
function, base::MakeTuple(a, b, c, d));
}
template <class Function, class A, class B, class C, class D, class E>
@@ -310,8 +293,8 @@ inline CefRefPtr<CefTask> NewCefRunnableFunction(Function function,
const A& a, const B& b,
const C& c, const D& d,
const E& e) {
return new CefRunnableFunction<Function, Tuple5<A, B, C, D, E> >(function,
MakeTuple(a, b, c, d, e));
return new CefRunnableFunction<Function, base::Tuple5<A, B, C, D, E> >(
function, base::MakeTuple(a, b, c, d, e));
}
template <class Function, class A, class B, class C, class D, class E,
@@ -320,8 +303,8 @@ inline CefRefPtr<CefTask> NewCefRunnableFunction(Function function,
const A& a, const B& b,
const C& c, const D& d,
const E& e, const F& f) {
return new CefRunnableFunction<Function, Tuple6<A, B, C, D, E, F> >(function,
MakeTuple(a, b, c, d, e, f));
return new CefRunnableFunction<Function, base::Tuple6<A, B, C, D, E, F> >(
function, base::MakeTuple(a, b, c, d, e, f));
}
template <class Function, class A, class B, class C, class D, class E,
@@ -331,8 +314,8 @@ inline CefRefPtr<CefTask> NewCefRunnableFunction(Function function,
const C& c, const D& d,
const E& e, const F& f,
const G& g) {
return new CefRunnableFunction<Function, Tuple7<A, B, C, D, E, F, G> >(
function, MakeTuple(a, b, c, d, e, f, g));
return new CefRunnableFunction<Function, base::Tuple7<A, B, C, D, E, F, G> >(
function, base::MakeTuple(a, b, c, d, e, f, g));
}
template <class Function, class A, class B, class C, class D, class E,
@@ -342,8 +325,9 @@ inline CefRefPtr<CefTask> NewCefRunnableFunction(Function function,
const C& c, const D& d,
const E& e, const F& f,
const G& g, const H& h) {
return new CefRunnableFunction<Function, Tuple8<A, B, C, D, E, F, G, H> >(
function, MakeTuple(a, b, c, d, e, f, g, h));
return new CefRunnableFunction<Function,
base::Tuple8<A, B, C, D, E, F, G, H> >(
function, base::MakeTuple(a, b, c, d, e, f, g, h));
}
#endif // CEF_INCLUDE_CEF_RUNNABLE_H_

View File

@@ -38,7 +38,8 @@
#define CEF_INCLUDE_CEF_WEB_PLUGIN_H_
#include "include/cef_base.h"
#include "include/cef_browser.h"
class CefBrowser;
///
// Information about a specific web plugin.

View File

@@ -103,7 +103,7 @@ class CefZipReader : public virtual CefBase {
// Returns the last modified timestamp for the file.
///
/*--cef()--*/
virtual time_t GetFileLastModified() =0;
virtual CefTime GetFileLastModified() =0;
///
// Opens the file for reading of uncompressed data. A read password may

View File

@@ -38,26 +38,13 @@
#include <stddef.h>
#include "include/base/cef_build.h"
#include "include/base/cef_basictypes.h"
#include "include/internal/cef_export.h"
#ifdef __cplusplus
extern "C" {
#endif
// CEF character type definitions. wchar_t is 2 bytes on Windows and 4 bytes on
// most other platforms.
#if defined(OS_WIN)
typedef wchar_t char16;
#else // !OS_WIN
typedef unsigned short char16; // NOLINT (runtime/int)
#ifndef WCHAR_T_IS_UTF32
#define WCHAR_T_IS_UTF32
#endif // WCHAR_T_IS_UTF32
#endif // !OS_WIN
// CEF string type definitions. Whomever allocates |str| is responsible for
// providing an appropriate |dtor| implementation that will free the string in
// the same memory space. When reusing an existing string structure make sure

View File

@@ -37,6 +37,10 @@
#include "include/base/cef_string16.h"
#include "include/internal/cef_string_types.h"
#if defined(BUILDING_CEF_SHARED)
#include "base/files/file_path.h"
#endif
///
// Traits implementation for wide character strings.
///
@@ -692,6 +696,17 @@ class CefStringBase {
return *this;
}
#endif // WCHAR_T_IS_UTF32
#if defined(BUILDING_CEF_SHARED)
// The base::FilePath constructor is marked as explicit so provide the
// conversion here for convenience.
operator base::FilePath() const {
#if defined(OS_WIN)
return base::FilePath(ToWString());
#else
return base::FilePath(ToString());
#endif
}
#endif // BUILDING_CEF_SHARED
private:
// Allocate the string structure if it doesn't already exist.

View File

@@ -32,7 +32,7 @@
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_H_
#pragma once
#include "include/base/cef_build.h"
#include "include/base/cef_basictypes.h"
#include "include/internal/cef_string.h"
#include "include/internal/cef_string_list.h"
#include "include/internal/cef_time.h"
@@ -46,45 +46,6 @@
#include "include/internal/cef_types_linux.h"
#endif
#include <limits.h> // For UINT_MAX
#include <stddef.h> // For size_t
// The NSPR system headers define 64-bit as |long| when possible, except on
// Mac OS X. In order to not have typedef mismatches, we do the same on LP64.
//
// On Mac OS X, |long long| is used for 64-bit types for compatibility with
// <inttypes.h> format macros even in the LP64 model.
#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
typedef long int64; // NOLINT(runtime/int)
typedef unsigned long uint64; // NOLINT(runtime/int)
#else
typedef long long int64; // NOLINT(runtime/int)
typedef unsigned long long uint64; // NOLINT(runtime/int)
#endif
// TODO: Remove these type guards. These are to avoid conflicts with
// obsolete/protypes.h in the Gecko SDK.
#ifndef _INT32
#define _INT32
typedef int int32;
#endif
// TODO: Remove these type guards. These are to avoid conflicts with
// obsolete/protypes.h in the Gecko SDK.
#ifndef _UINT32
#define _UINT32
typedef unsigned int uint32;
#endif
// UTF-16 character type
#ifndef char16
#if defined(WIN32)
typedef wchar_t char16;
#else
typedef unsigned short char16;
#endif
#endif
// 32-bit ARGB color value, not premultiplied. The color components are always
// in a known order. Equivalent to the SkColor type.
typedef uint32 cef_color_t;
@@ -214,7 +175,8 @@ typedef struct _cef_settings_t {
///
// Set to true (1) to have the browser process message loop run in a separate
// thread. If false (0) than the CefDoMessageLoopWork() function must be
// called from your application message loop.
// called from your application message loop. This option is only supported on
// Windows.
///
int multi_threaded_message_loop;
@@ -476,7 +438,8 @@ typedef struct _cef_browser_settings_t {
// The maximum rate in frames per second (fps) that CefRenderHandler::OnPaint
// will be called for a windowless browser. The actual fps may be lower if
// the browser cannot generate frames at the requested rate. The minimum
// value is 1 and the maximum value is 60 (default 30).
// value is 1 and the maximum value is 60 (default 30). This value can also be
// changed dynamically via CefBrowserHost::SetWindowlessFrameRate.
///
int windowless_frame_rate;
@@ -1460,6 +1423,11 @@ typedef enum {
MENU_ID_NO_SPELLING_SUGGESTIONS = 205,
MENU_ID_ADD_TO_DICTIONARY = 206,
// Custom menu items originating from the renderer process. For example,
// plugin placeholder menu items or Flash menu items.
MENU_ID_CUSTOM_FIRST = 220,
MENU_ID_CUSTOM_LAST = 250,
// All user-defined menu IDs should come between MENU_ID_USER_FIRST and
// MENU_ID_USER_LAST to avoid overlapping the Chromium and CEF ID ranges
// defined in the tools/gritsettings/resource_ids file.
@@ -2192,6 +2160,136 @@ typedef enum {
JSON_WRITER_PRETTY_PRINT = 1 << 2,
} cef_json_writer_options_t;
///
// Margin type for PDF printing.
///
typedef enum {
///
// Default margins.
///
PDF_PRINT_MARGIN_DEFAULT,
///
// No margins.
///
PDF_PRINT_MARGIN_NONE,
///
// Minimum margins.
///
PDF_PRINT_MARGIN_MINIMUM,
///
// Custom margins using the |margin_*| values from cef_pdf_print_settings_t.
///
PDF_PRINT_MARGIN_CUSTOM,
} cef_pdf_print_margin_type_t;
///
// Structure representing PDF print settings.
///
typedef struct _cef_pdf_print_settings_t {
///
// Page title to display in the header. Only used if |header_footer_enabled|
// is set to true (1).
///
cef_string_t header_footer_title;
///
// URL to display in the footer. Only used if |header_footer_enabled| is set
// to true (1).
///
cef_string_t header_footer_url;
///
// Output page size in microns. If either of these values is less than or
// equal to zero then the default paper size (A4) will be used.
///
int page_width;
int page_height;
///
// Margins in millimeters. Only used if |margin_type| is set to
// PDF_PRINT_MARGIN_CUSTOM.
///
double margin_top;
double margin_right;
double margin_bottom;
double margin_left;
///
// Margin type.
///
cef_pdf_print_margin_type_t margin_type;
///
// Set to true (1) to print headers and footers or false (0) to not print
// headers and footers.
///
int header_footer_enabled;
///
// Set to true (1) to print the selection only or false (0) to print all.
///
int selection_only;
///
// Set to true (1) for landscape mode or false (0) for portrait mode.
///
int landscape;
///
// Set to true (1) to print background graphics or false (0) to not print
// background graphics.
///
int backgrounds_enabled;
} cef_pdf_print_settings_t;
///
// Supported UI scale factors for the platform. SCALE_FACTOR_NONE is used for
// density independent resources such as string, html/js files or an image that
// can be used for any scale factors (such as wallpapers).
///
typedef enum {
SCALE_FACTOR_NONE = 0,
SCALE_FACTOR_100P,
SCALE_FACTOR_125P,
SCALE_FACTOR_133P,
SCALE_FACTOR_140P,
SCALE_FACTOR_150P,
SCALE_FACTOR_180P,
SCALE_FACTOR_200P,
SCALE_FACTOR_250P,
SCALE_FACTOR_300P,
} cef_scale_factor_t;
///
// Plugin policies supported by CefRequestContextHandler::OnBeforePluginLoad.
///
typedef enum {
///
// Allow the content.
///
PLUGIN_POLICY_ALLOW,
///
// Allow important content and block unimportant content based on heuristics.
// The user can manually load blocked content.
///
PLUGIN_POLICY_DETECT_IMPORTANT,
///
// Block the content. The user can manually load blocked content.
///
PLUGIN_POLICY_BLOCK,
///
// Disable the content. The user cannot load disabled content.
///
PLUGIN_POLICY_DISABLE,
} cef_plugin_policy_t;
#ifdef __cplusplus
}
#endif

View File

@@ -161,8 +161,8 @@ class CefPoint : public CefStructBase<CefPointTraits> {
}
bool IsEmpty() const { return x <= 0 && y <= 0; }
void Set(int x, int y) {
this->x = x, this->y = y;
void Set(int x_val, int y_val) {
x = x_val, y = y_val;
}
};
@@ -202,8 +202,8 @@ class CefRect : public CefStructBase<CefRectTraits> {
}
bool IsEmpty() const { return width <= 0 || height <= 0; }
void Set(int x, int y, int width, int height) {
this->x = x, this->y = y, this->width = width, this->height = height;
void Set(int x_val, int y_val, int width_val, int height_val) {
x = x_val, y = y_val, width = width_val, height = height_val;
}
};
@@ -243,8 +243,8 @@ class CefSize : public CefStructBase<CefSizeTraits> {
}
bool IsEmpty() const { return width <= 0 || height <= 0; }
void Set(int width, int height) {
this->width = width, this->height = height;
void Set(int width_val, int height_val) {
width = width_val, height = height_val;
}
};
@@ -285,8 +285,8 @@ class CefDraggableRegion : public CefStructBase<CefDraggableRegionTraits> {
Set(bounds, draggable);
}
void Set(const CefRect& bounds, bool draggable) {
this->bounds = bounds, this->draggable = draggable;
void Set(const CefRect& bounds_val, bool draggable_val) {
bounds = bounds_val, draggable = draggable_val;
}
};
@@ -340,18 +340,18 @@ class CefScreenInfo : public CefStructBase<CefScreenInfoTraits> {
is_monochrome, rect, available_rect);
}
void Set(float device_scale_factor,
int depth,
int depth_per_component,
bool is_monochrome,
const CefRect& rect,
const CefRect& available_rect) {
this->device_scale_factor = device_scale_factor;
this->depth = depth;
this->depth_per_component = depth_per_component;
this->is_monochrome = is_monochrome;
this->rect = rect;
this->available_rect = available_rect;
void Set(float device_scale_factor_val,
int depth_val,
int depth_per_component_val,
bool is_monochrome_val,
const CefRect& rect_val,
const CefRect& available_rect_val) {
device_scale_factor = device_scale_factor_val;
depth = depth_val;
depth_per_component = depth_per_component_val;
is_monochrome = is_monochrome_val;
rect = rect_val;
available_rect = available_rect_val;
}
};
@@ -822,13 +822,13 @@ class CefPageRange : public CefStructBase<CefPageRangeTraits> {
CefPageRange(const cef_page_range_t& r) // NOLINT(runtime/explicit)
: parent(r) {}
CefPageRange(const CefPageRange& r) // NOLINT(runtime/explicit)
: parent(r) {}
: parent(r) {}
CefPageRange(int from, int to) : parent() {
Set(from, to);
}
void Set(int from, int to) {
this->from = from, this->to = to;
void Set(int from_val, int to_val) {
from = from_val, to = to_val;
}
};
@@ -862,4 +862,44 @@ struct CefCursorInfoTraits {
///
typedef CefStructBase<CefCursorInfoTraits> CefCursorInfo;
struct CefPdfPrintSettingsTraits {
typedef cef_pdf_print_settings_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->header_footer_title);
cef_string_clear(&s->header_footer_url);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
cef_string_set(src->header_footer_title.str,
src->header_footer_title.length, &target->header_footer_title, copy);
cef_string_set(src->header_footer_url.str, src->header_footer_url.length,
&target->header_footer_url, copy);
target->page_width = src->page_width;
target->page_height = src->page_height;
target->margin_top = src->margin_top;
target->margin_right = src->margin_right;
target->margin_bottom = src->margin_bottom;
target->margin_left = src->margin_left;
target->margin_type = src->margin_type;
target->header_footer_enabled = src->header_footer_enabled;
target->selection_only = src->selection_only;
target->landscape = src->landscape;
target->backgrounds_enabled = src->backgrounds_enabled;
}
};
///
// Class representing PDF print settings
///
typedef CefStructBase<CefPdfPrintSettingsTraits> CefPdfPrintSettings;
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_

View File

@@ -0,0 +1,543 @@
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
// THIS FILE IS FOR TESTING PURPOSES ONLY.
//
// The APIs defined in this file are for testing purposes only. They will not be
// exposed via the binary distribution. All classes in this file must include
// the 'no_debugct_check' attribute to avoid problems when building the binary
// distribution.
//
#ifndef CEF_INCLUDE_TEST_CEF_TEST_H_
#define CEF_INCLUDE_TEST_CEF_TEST_H_
#pragma once
#include <map>
#include <vector>
#include "include/cef_base.h"
class CefTranslatorTestHandler;
class CefTranslatorTestHandlerChild;
class CefTranslatorTestObject;
class CefTranslatorTestObjectChild;
// Test values.
#define TEST_INT_VAL 5
#define TEST_INT_VAL2 60
#define TEST_BOOL_VAL true
#define TEST_DOUBLE_VAL 4.543
#define TEST_LONG_VAL -65
#define TEST_SIZET_VAL 3U
#define TEST_STRING_VAL "My test string"
#define TEST_STRING_VAL2 "My 2nd test string"
#define TEST_STRING_VAL3 "My 3rd test string"
#define TEST_STRING_KEY "key0"
#define TEST_STRING_KEY2 "key1"
#define TEST_STRING_KEY3 "key2"
#define TEST_X_VAL 44
#define TEST_Y_VAL 754
#define TEST_X_VAL2 900
#define TEST_Y_VAL2 300
///
// Class for testing all of the possible data transfer types.
///
/*--cef(source=library,no_debugct_check)--*/
class CefTranslatorTest : public CefBase {
public:
///
// Create the test object.
///
/*--cef()--*/
static CefRefPtr<CefTranslatorTest> Create();
// PRIMITIVE VALUES
///
// Return a void value.
///
/*--cef()--*/
virtual void GetVoid() =0;
///
// Return a bool value.
///
/*--cef()--*/
virtual bool GetBool() =0;
///
// Return an int value.
///
/*--cef()--*/
virtual int GetInt() =0;
///
// Return a double value.
///
/*--cef()--*/
virtual double GetDouble() =0;
///
// Return a long value.
///
/*--cef()--*/
virtual long GetLong() =0;
///
// Return a size_t value.
///
/*--cef()--*/
virtual size_t GetSizet() =0;
///
// Set a void value.
///
/*--cef()--*/
virtual bool SetVoid() =0;
///
// Set a bool value.
///
/*--cef()--*/
virtual bool SetBool(bool val) =0;
///
// Set an int value.
///
/*--cef()--*/
virtual bool SetInt(int val) =0;
///
// Set a double value.
///
/*--cef()--*/
virtual bool SetDouble(double val) =0;
///
// Set a long value.
///
/*--cef()--*/
virtual bool SetLong(long val) =0;
///
// Set a size_t value.
///
/*--cef()--*/
virtual bool SetSizet(size_t val) =0;
// PRIMITIVE LIST VALUES
// Test both with and without a typedef.
typedef std::vector<int> IntList;
///
// Set a int list value.
///
/*--cef()--*/
virtual bool SetIntList(const std::vector<int>& val) =0;
///
// Return an int list value by out-param.
///
/*--cef(count_func=val:GetIntListSize)--*/
virtual bool GetIntListByRef(IntList& val) =0;
///
// Return the number of points that will be output above.
///
/*--cef()--*/
virtual size_t GetIntListSize() = 0;
// STRING VALUES
///
// Return a string value.
///
/*--cef()--*/
virtual CefString GetString() =0;
///
// Set a string value.
///
/*--cef()--*/
virtual bool SetString(const CefString& val) =0;
///
// Return a string value by out-param.
///
/*--cef()--*/
virtual void GetStringByRef(CefString& val) =0;
// STRING LIST VALUES
// Test both with and without a typedef.
typedef std::vector<CefString> StringList;
///
// Set a string list value.
///
/*--cef()--*/
virtual bool SetStringList(const std::vector<CefString>& val) =0;
///
// Return a string list value by out-param.
///
/*--cef()--*/
virtual bool GetStringListByRef(StringList& val) =0;
// STRING MAP VALUES
// Test both with and without a typedef.
typedef std::map<CefString, CefString> StringMap;
///
// Set a string map value.
///
/*--cef()--*/
virtual bool SetStringMap(const StringMap& val) =0;
///
// Return a string map value by out-param.
///
/*--cef()--*/
virtual bool GetStringMapByRef(std::map<CefString, CefString>& val) =0;
// STRING MULTIMAP VALUES
// Test both with and without a typedef.
typedef std::multimap<CefString, CefString> StringMultimap;
///
// Set a string multimap value.
///
/*--cef()--*/
virtual bool SetStringMultimap(
const std::multimap<CefString, CefString>& val) =0;
///
// Return a string multimap value by out-param.
///
/*--cef()--*/
virtual bool GetStringMultimapByRef(StringMultimap& val) =0;
// STRUCT VALUES
///
// Return a point value.
///
/*--cef()--*/
virtual CefPoint GetPoint() =0;
///
// Set a point value.
///
/*--cef()--*/
virtual bool SetPoint(const CefPoint& val) =0;
///
// Return a point value by out-param.
///
/*--cef()--*/
virtual void GetPointByRef(CefPoint& val) =0;
// STRUCT LIST VALUES
// Test both with and without a typedef.
typedef std::vector<CefPoint> PointList;
///
// Set a point list vlaue.
///
/*--cef()--*/
virtual bool SetPointList(const std::vector<CefPoint>& val) =0;
///
// Return a point list value by out-param.
///
/*--cef(count_func=val:GetPointListSize)--*/
virtual bool GetPointListByRef(PointList& val) =0;
///
// Return the number of points that will be output above.
///
/*--cef()--*/
virtual size_t GetPointListSize() = 0;
// LIBRARY-SIDE OBJECT VALUES
///
// Return an new library-side object.
///
/*--cef()--*/
virtual CefRefPtr<CefTranslatorTestObject> GetObject(int val) =0;
///
// Set an object. Returns the value from CefTranslatorTestObject::GetValue().
// This tests input and execution of a library-side object type.
///
/*--cef()--*/
virtual int SetObject(CefRefPtr<CefTranslatorTestObject> val) =0;
///
// Set an object. Returns the object passed in. This tests input and output
// of a library-side object type.
///
/*--cef()--*/
virtual CefRefPtr<CefTranslatorTestObject> SetObjectAndReturn(
CefRefPtr<CefTranslatorTestObject> val) =0;
///
// Set a child object. Returns the value from
// CefTranslatorTestObject::GetValue(). This tests input of a library-side
// child object type and execution as the parent type.
///
/*--cef()--*/
virtual int SetChildObject(CefRefPtr<CefTranslatorTestObjectChild> val) =0;
///
// Set a child object. Returns the object as the parent type. This tests input
// of a library-side child object type and return as the parent type.
///
/*--cef()--*/
virtual CefRefPtr<CefTranslatorTestObject> SetChildObjectAndReturnParent(
CefRefPtr<CefTranslatorTestObjectChild> val) =0;
// LIBRARY-SIDE OBJECT LIST VALUES
// Test both with and without a typedef.
typedef std::vector<CefRefPtr<CefTranslatorTestObject> > ObjectList;
///
// Set an object list vlaue.
///
/*--cef()--*/
virtual bool SetObjectList(
const std::vector<CefRefPtr<CefTranslatorTestObject> >& val,
int val1, int val2) =0;
///
// Return an object list value by out-param.
///
/*--cef(count_func=val:GetObjectListSize)--*/
virtual bool GetObjectListByRef(ObjectList& val, int val1, int val2) =0;
///
// Return the number of object that will be output above.
///
/*--cef()--*/
virtual size_t GetObjectListSize() = 0;
// CLIENT-SIDE OBJECT VALUES
///
// Set an object. Returns the value from CefTranslatorTestHandler::GetValue().
// This tests input and execution of a client-side object type.
///
/*--cef()--*/
virtual int SetHandler(CefRefPtr<CefTranslatorTestHandler> val) =0;
///
// Set an object. Returns the handler passed in. This tests input and output
// of a client-side object type.
///
/*--cef()--*/
virtual CefRefPtr<CefTranslatorTestHandler> SetHandlerAndReturn(
CefRefPtr<CefTranslatorTestHandler> val) =0;
///
// Set a child object. Returns the value from
// CefTranslatorTestHandler::GetValue(). This tests input of a client-side
// child object type and execution as the parent type.
///
/*--cef()--*/
virtual int SetChildHandler(CefRefPtr<CefTranslatorTestHandlerChild> val) =0;
///
// Set a child object. Returns the object as the parent type. This tests
// input of a client-side child object type and return as the parent type.
///
/*--cef()--*/
virtual CefRefPtr<CefTranslatorTestHandler> SetChildHandlerAndReturnParent(
CefRefPtr<CefTranslatorTestHandlerChild> val) =0;
// CLIENT-SIDE OBJECT LIST VALUES
// Test both with and without a typedef.
typedef std::vector<CefRefPtr<CefTranslatorTestHandler> > HandlerList;
///
// Set an object list vlaue.
///
/*--cef()--*/
virtual bool SetHandlerList(
const std::vector<CefRefPtr<CefTranslatorTestHandler> >& val,
int val1, int val2) =0;
///
// Return an object list value by out-param.
///
/*--cef(count_func=val:GetObjectListSize)--*/
virtual bool GetHandlerListByRef(
HandlerList& val,
CefRefPtr<CefTranslatorTestHandler> val1,
CefRefPtr<CefTranslatorTestHandler> val2) =0;
///
// Return the number of object that will be output above.
///
/*--cef()--*/
virtual size_t GetHandlerListSize() = 0;
};
///
// Library-side test object.
///
/*--cef(source=library,no_debugct_check)--*/
class CefTranslatorTestObject : public CefBase {
public:
///
// Create the test object.
///
/*--cef()--*/
static CefRefPtr<CefTranslatorTestObject> Create(int value);
///
// Return a value.
///
/*--cef()--*/
virtual int GetValue() =0;
///
// Set a value.
///
/*--cef()--*/
virtual void SetValue(int value) =0;
};
///
// Library-side child test object.
///
/*--cef(source=library,no_debugct_check)--*/
class CefTranslatorTestObjectChild : public CefTranslatorTestObject {
public:
///
// Create the test object.
///
/*--cef()--*/
static CefRefPtr<CefTranslatorTestObjectChild> Create(int value,
int other_value);
///
// Return a value.
///
/*--cef()--*/
virtual int GetOtherValue() =0;
///
// Set a value.
///
/*--cef()--*/
virtual void SetOtherValue(int value) =0;
};
///
// Another library-side child test object.
///
/*--cef(source=library,no_debugct_check)--*/
class CefTranslatorTestObjectChildChild : public CefTranslatorTestObjectChild {
public:
///
// Create the test object.
///
/*--cef()--*/
static CefRefPtr<CefTranslatorTestObjectChildChild> Create(
int value,
int other_value,
int other_other_value);
///
// Return a value.
///
/*--cef()--*/
virtual int GetOtherOtherValue() =0;
///
// Set a value.
///
/*--cef()--*/
virtual void SetOtherOtherValue(int value) =0;
};
///
// Client-side test object.
///
/*--cef(source=client,no_debugct_check)--*/
class CefTranslatorTestHandler : public virtual CefBase {
public:
///
// Return a value.
///
/*--cef()--*/
virtual int GetValue() =0;
};
///
// Client-side child test object.
///
/*--cef(source=client,no_debugct_check)--*/
class CefTranslatorTestHandlerChild : public CefTranslatorTestHandler {
public:
///
// Return a value.
///
/*--cef()--*/
virtual int GetOtherValue() =0;
};
#endif // CEF_INCLUDE_TEST_CEF_TEST_H_

View File

@@ -4,6 +4,8 @@
#include "libcef/browser/browser_context.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/logging.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
@@ -15,16 +17,7 @@ base::AtomicRefCount CefBrowserContext::DebugObjCt = 0;
#endif
CefBrowserContext::CefBrowserContext()
: resource_context_(new CefResourceContext) {
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
this);
// Spell checking support and possibly other subsystems retrieve the
// PrefService associated with a BrowserContext via UserPrefs::Get().
PrefService* pref_service = CefContentBrowserClient::Get()->pref_service();
DCHECK(pref_service);
user_prefs::UserPrefs::Set(this, pref_service);
: extension_system_(NULL) {
#ifndef NDEBUG
base::AtomicRefCountInc(&DebugObjCt);
#endif
@@ -47,6 +40,34 @@ CefBrowserContext::~CefBrowserContext() {
#endif
}
void CefBrowserContext::Initialize() {
const bool extensions_enabled = extensions::ExtensionsEnabled();
if (extensions_enabled) {
// Create the custom ExtensionSystem first because other KeyedServices
// depend on it.
extension_system_ = static_cast<extensions::CefExtensionSystem*>(
extensions::ExtensionSystem::Get(this));
extension_system_->InitForRegularProfile(true);
}
resource_context_.reset(new CefResourceContext(
IsOffTheRecord(),
extensions_enabled ? extension_system_->info_map() : NULL,
GetHandler()));
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
this);
// Spell checking support and possibly other subsystems retrieve the
// PrefService associated with a BrowserContext via UserPrefs::Get().
PrefService* pref_service = GetPrefs();
DCHECK(pref_service);
user_prefs::UserPrefs::Set(this, pref_service);
if (extensions_enabled)
extension_system_->Init();
}
content::ResourceContext* CefBrowserContext::GetResourceContext() {
return resource_context_.get();
}

View File

@@ -104,6 +104,12 @@
// CefURLRequestContextGetter* destruction.
*/
class PrefService;
namespace extensions {
class CefExtensionSystem;
}
// Main entry point for configuring behavior on a per-browser basis. An instance
// of this class is passed to WebContents::Create in CefBrowserHostImpl::
// CreateInternal. Only accessed on the UI thread unless otherwise indicated.
@@ -114,13 +120,12 @@ class CefBrowserContext
public:
CefBrowserContext();
// Must be called immediately after this object is created.
virtual void Initialize();
// BrowserContext methods.
content::ResourceContext* GetResourceContext() override;
// Returns true if this is a CefBrowserContextProxy object. Safe to call from
// any thread.
virtual bool IsProxy() const = 0;
// Returns the settings associated with this object. Safe to call from any
// thread.
virtual const CefRequestContextSettings& GetSettings() const = 0;
@@ -139,8 +144,14 @@ class CefBrowserContext
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) = 0;
// Preferences.
virtual PrefService* GetPrefs() = 0;
CefResourceContext* resource_context() const {
return resource_context_.get();
return resource_context_.get();
}
extensions::CefExtensionSystem* extension_system() const {
return extension_system_;
}
#ifndef NDEBUG
@@ -159,6 +170,9 @@ class CefBrowserContext
scoped_ptr<CefResourceContext> resource_context_;
// Owned by the KeyedService system.
extensions::CefExtensionSystem* extension_system_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserContext);
};

View File

@@ -6,18 +6,21 @@
#include <map>
#include "libcef/browser/browser_context_proxy.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/browser/download_manager_delegate.h"
#include "libcef/browser/permission_manager.h"
#include "libcef/browser/ssl_host_state_delegate.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/net/proxy_service_factory.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
@@ -27,15 +30,64 @@ using content::BrowserThread;
namespace {
// Manages the global mapping of cache path to Impl instance.
// Manages the global list of Impl instances.
class ImplManager {
public:
typedef std::vector<CefBrowserContextImpl*> Vector;
ImplManager() {}
~ImplManager() {
DCHECK(all_.empty());
DCHECK(map_.empty());
}
CefBrowserContextImpl* GetImpl(const base::FilePath& path) {
void AddImpl(CefBrowserContextImpl* impl) {
CEF_REQUIRE_UIT();
DCHECK(!IsValidImpl(impl));
all_.push_back(impl);
}
void RemoveImpl(CefBrowserContextImpl* impl, const base::FilePath& path) {
CEF_REQUIRE_UIT();
Vector::iterator it = GetImplPos(impl);
DCHECK(it != all_.end());
all_.erase(it);
if (!path.empty()) {
PathMap::iterator it = map_.find(path);
DCHECK(it != map_.end());
if (it != map_.end())
map_.erase(it);
}
}
bool IsValidImpl(const CefBrowserContextImpl* impl) {
CEF_REQUIRE_UIT();
return GetImplPos(impl) != all_.end();
}
CefBrowserContextImpl* GetImplForContext(
const content::BrowserContext* context) {
CEF_REQUIRE_UIT();
Vector::iterator it = all_.begin();
for (; it != all_.end(); ++it) {
if (*it == context || (*it)->HasProxy(context))
return *it;
}
return NULL;
}
void SetImplPath(CefBrowserContextImpl* impl, const base::FilePath& path) {
CEF_REQUIRE_UIT();
DCHECK(!path.empty());
DCHECK(IsValidImpl(impl));
DCHECK(GetImplForPath(path) == NULL);
map_.insert(std::make_pair(path, impl));
}
CefBrowserContextImpl* GetImplForPath(const base::FilePath& path) {
CEF_REQUIRE_UIT();
DCHECK(!path.empty());
PathMap::const_iterator it = map_.find(path);
@@ -44,26 +96,23 @@ class ImplManager {
return NULL;
}
void AddImpl(const base::FilePath& path, CefBrowserContextImpl* impl) {
CEF_REQUIRE_UIT();
DCHECK(!path.empty());
DCHECK(GetImpl(path) == NULL);
map_.insert(std::make_pair(path, impl));
}
void RemoveImpl(const base::FilePath& path) {
CEF_REQUIRE_UIT();
DCHECK(!path.empty());
PathMap::iterator it = map_.find(path);
DCHECK(it != map_.end());
if (it != map_.end())
map_.erase(it);
}
const Vector GetAllImpl() const { return all_; }
private:
Vector::iterator GetImplPos(const CefBrowserContextImpl* impl) {
Vector::iterator it = all_.begin();
for (; it != all_.end(); ++it) {
if (*it == impl)
return it;
}
return all_.end();
}
typedef std::map<base::FilePath, CefBrowserContextImpl*> PathMap;
PathMap map_;
Vector all_;
DISALLOW_COPY_AND_ASSIGN(ImplManager);
};
@@ -74,6 +123,7 @@ base::LazyInstance<ImplManager> g_manager = LAZY_INSTANCE_INITIALIZER;
CefBrowserContextImpl::CefBrowserContextImpl(
const CefRequestContextSettings& settings)
: settings_(settings) {
g_manager.Get().AddImpl(this);
}
CefBrowserContextImpl::~CefBrowserContextImpl() {
@@ -84,8 +134,7 @@ CefBrowserContextImpl::~CefBrowserContextImpl() {
if (download_manager_delegate_.get())
download_manager_delegate_.reset(NULL);
if (!cache_path_.empty())
g_manager.Get().RemoveImpl(cache_path_);
g_manager.Get().RemoveImpl(this, cache_path_);
}
void CefBrowserContextImpl::Initialize() {
@@ -102,7 +151,7 @@ void CefBrowserContextImpl::Initialize() {
}
if (!cache_path_.empty())
g_manager.Get().AddImpl(cache_path_, this);
g_manager.Get().SetImplPath(this, cache_path_);
if (settings_.accept_language_list.length == 0) {
// Use the global language list setting.
@@ -110,10 +159,12 @@ void CefBrowserContextImpl::Initialize() {
CefString(&CefContext::Get()->settings().accept_language_list);
}
CefBrowserContext::Initialize();
// Initialize proxy configuration tracker.
pref_proxy_config_tracker_.reset(
ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState(
CefContentBrowserClient::Get()->pref_service()));
GetPrefs()));
// Create the CefURLRequestContextGetterImpl via an indirect call to
// CreateRequestContext. Triggers a call to CefURLRequestContextGetterImpl::
@@ -123,10 +174,52 @@ void CefBrowserContextImpl::Initialize() {
DCHECK(url_request_getter_.get());
}
void CefBrowserContextImpl::AddProxy(const CefBrowserContextProxy* proxy) {
CEF_REQUIRE_UIT();
DCHECK(!HasProxy(proxy));
proxy_list_.push_back(proxy);
}
void CefBrowserContextImpl::RemoveProxy(const CefBrowserContextProxy* proxy) {
CEF_REQUIRE_UIT();
bool found = false;
ProxyList::iterator it = proxy_list_.begin();
for (; it != proxy_list_.end(); ++it) {
if (*it == proxy) {
proxy_list_.erase(it);
found = true;
break;
}
}
DCHECK(found);
}
bool CefBrowserContextImpl::HasProxy(
const content::BrowserContext* context) const {
CEF_REQUIRE_UIT();
ProxyList::const_iterator it = proxy_list_.begin();
for (; it != proxy_list_.end(); ++it) {
if (*it == context)
return true;
}
return false;
}
// static
scoped_refptr<CefBrowserContextImpl> CefBrowserContextImpl::GetForCachePath(
const base::FilePath& cache_path) {
return g_manager.Get().GetImpl(cache_path);
return g_manager.Get().GetImplForPath(cache_path);
}
// static
CefRefPtr<CefBrowserContextImpl> CefBrowserContextImpl::GetForContext(
content::BrowserContext* context) {
return g_manager.Get().GetImplForContext(context);
}
// static
std::vector<CefBrowserContextImpl*> CefBrowserContextImpl::GetAll() {
return g_manager.Get().GetAllImpl();
}
base::FilePath CefBrowserContextImpl::GetPath() const {
@@ -181,7 +274,8 @@ net::URLRequestContextGetter*
}
content::BrowserPluginGuestManager* CefBrowserContextImpl::GetGuestManager() {
return NULL;
DCHECK(extensions::ExtensionsEnabled());
return guest_view::GuestViewManager::FromBrowserContext(this);
}
storage::SpecialStoragePolicy*
@@ -207,10 +301,6 @@ content::PermissionManager* CefBrowserContextImpl::GetPermissionManager() {
return permission_manager_.get();
}
bool CefBrowserContextImpl::IsProxy() const {
return false;
}
const CefRequestContextSettings& CefBrowserContextImpl::GetSettings() const {
return settings_;
}
@@ -250,3 +340,8 @@ net::URLRequestContextGetter*
content::URLRequestInterceptorScopedVector request_interceptors) {
return NULL;
}
PrefService* CefBrowserContextImpl::GetPrefs() {
// TODO(cef): Perhaps use per-context settings.
return CefContentBrowserClient::Get()->pref_service();
}

View File

@@ -20,6 +20,7 @@ class DownloadManagerDelegate;
class SpeechRecognitionPreferences;
}
class CefBrowserContextProxy;
class CefDownloadManagerDelegate;
class CefSSLHostStateDelegate;
@@ -36,8 +37,20 @@ class CefBrowserContextImpl : public CefBrowserContext {
static scoped_refptr<CefBrowserContextImpl> GetForCachePath(
const base::FilePath& cache_path);
// Returns the underlying CefBrowserContextImpl if any.
static CefRefPtr<CefBrowserContextImpl> GetForContext(
content::BrowserContext* context);
// Returns all existing CefBrowserContextImpl.
static std::vector<CefBrowserContextImpl*> GetAll();
// Must be called immediately after this object is created.
void Initialize();
void Initialize() override;
// Track associated proxy objects.
void AddProxy(const CefBrowserContextProxy* proxy);
void RemoveProxy(const CefBrowserContextProxy* proxy);
bool HasProxy(const content::BrowserContext* context) const;
// BrowserContext methods.
base::FilePath GetPath() const override;
@@ -62,7 +75,6 @@ class CefBrowserContextImpl : public CefBrowserContext {
content::PermissionManager* GetPermissionManager() override;
// CefBrowserContext methods.
bool IsProxy() const override;
const CefRequestContextSettings& GetSettings() const override;
CefRefPtr<CefRequestContextHandler> GetHandler() const override;
net::URLRequestContextGetter* CreateRequestContext(
@@ -75,6 +87,7 @@ class CefBrowserContextImpl : public CefBrowserContext {
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors)
override;
PrefService* GetPrefs() override;
// Guaranteed to exist once this object has been initialized.
scoped_refptr<CefURLRequestContextGetterImpl> request_context() const {
@@ -93,6 +106,10 @@ class CefBrowserContextImpl : public CefBrowserContext {
CefRequestContextSettings settings_;
base::FilePath cache_path_;
// Not owned by this class.
typedef std::vector<const CefBrowserContextProxy*> ProxyList;
ProxyList proxy_list_;
scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
scoped_ptr<CefDownloadManagerDelegate> download_manager_delegate_;

View File

@@ -10,8 +10,28 @@
#include "libcef/browser/url_request_context_getter_proxy.h"
#include "base/logging.h"
#include "components/guest_view/common/guest_view_constants.h"
#include "content/browser/streams/stream_context.h"
#include "content/public/browser/storage_partition.h"
namespace {
bool ShouldProxyUserData(const void* key) {
// If this value is not proxied the blob data fails to load for the PDF
// extension.
if (key == content::StreamContext::GetUserDataKey())
return true;
// If this value is not proxied then CefBrowserContextImpl::GetGuestManager()
// returns NULL.
if (key == guest_view::kGuestViewManagerKeyName)
return true;
return false;
}
} // namespace
CefBrowserContextProxy::CefBrowserContextProxy(
CefRefPtr<CefRequestContextHandler> handler,
scoped_refptr<CefBrowserContextImpl> parent)
@@ -19,9 +39,32 @@ CefBrowserContextProxy::CefBrowserContextProxy(
parent_(parent) {
DCHECK(handler_.get());
DCHECK(parent_.get());
parent_->AddProxy(this);
}
CefBrowserContextProxy::~CefBrowserContextProxy() {
parent_->RemoveProxy(this);
}
base::SupportsUserData::Data*
CefBrowserContextProxy::GetUserData(const void* key) const {
if (ShouldProxyUserData(key))
return parent_->GetUserData(key);
return BrowserContext::GetUserData(key);
}
void CefBrowserContextProxy::SetUserData(const void* key, Data* data) {
if (ShouldProxyUserData(key))
parent_->SetUserData(key, data);
else
BrowserContext::SetUserData(key, data);
}
void CefBrowserContextProxy::RemoveUserData(const void* key) {
if (ShouldProxyUserData(key))
parent_->RemoveUserData(key);
else
BrowserContext::RemoveUserData(key);
}
base::FilePath CefBrowserContextProxy::GetPath() const {
@@ -99,10 +142,6 @@ content::PermissionManager* CefBrowserContextProxy::GetPermissionManager() {
return parent_->GetPermissionManager();
}
bool CefBrowserContextProxy::IsProxy() const {
return true;
}
const CefRequestContextSettings& CefBrowserContextProxy::GetSettings() const {
return parent_->GetSettings();
}
@@ -130,3 +169,7 @@ net::URLRequestContextGetter*
content::URLRequestInterceptorScopedVector request_interceptors) {
return NULL;
}
PrefService* CefBrowserContextProxy::GetPrefs() {
return parent_->GetPrefs();
}

View File

@@ -29,6 +29,11 @@ class CefBrowserContextProxy : public CefBrowserContext {
CefBrowserContextProxy(CefRefPtr<CefRequestContextHandler> handler,
scoped_refptr<CefBrowserContextImpl> parent);
// SupportsUserData methods.
Data* GetUserData(const void* key) const override;
void SetUserData(const void* key, Data* data) override;
void RemoveUserData(const void* key) override;
// BrowserContext methods.
base::FilePath GetPath() const override;
scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
@@ -52,7 +57,6 @@ class CefBrowserContextProxy : public CefBrowserContext {
content::PermissionManager* GetPermissionManager() override;
// CefBrowserContext methods.
bool IsProxy() const override;
const CefRequestContextSettings& GetSettings() const override;
CefRefPtr<CefRequestContextHandler> GetHandler() const override;
net::URLRequestContextGetter* CreateRequestContext(
@@ -65,6 +69,7 @@ class CefBrowserContextProxy : public CefBrowserContext {
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors)
override;
PrefService* GetPrefs() override;
scoped_refptr<CefBrowserContextImpl> parent() const {
return parent_;

View File

@@ -16,6 +16,7 @@
#include "libcef/browser/context.h"
#include "libcef/browser/devtools_delegate.h"
#include "libcef/browser/devtools_frontend.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/navigate_params.h"
#include "libcef/browser/navigation_entry_impl.h"
@@ -28,6 +29,7 @@
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/drag_data_impl.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/http_header_utils.h"
#include "libcef/common/main_delegate.h"
#include "libcef/common/process_message_impl.h"
@@ -73,6 +75,63 @@
namespace {
// Manages the global list of Impl instances.
class ImplManager {
public:
typedef std::vector<CefBrowserHostImpl*> Vector;
ImplManager() {}
~ImplManager() {
DCHECK(all_.empty());
}
void AddImpl(CefBrowserHostImpl* impl) {
CEF_REQUIRE_UIT();
DCHECK(!IsValidImpl(impl));
all_.push_back(impl);
}
void RemoveImpl(CefBrowserHostImpl* impl) {
CEF_REQUIRE_UIT();
Vector::iterator it = GetImplPos(impl);
DCHECK(it != all_.end());
all_.erase(it);
}
bool IsValidImpl(const CefBrowserHostImpl* impl) {
CEF_REQUIRE_UIT();
return GetImplPos(impl) != all_.end();
}
CefBrowserHostImpl* GetImplForWebContents(
const content::WebContents* web_contents) {
CEF_REQUIRE_UIT();
Vector::const_iterator it = all_.begin();
for (; it != all_.end(); ++it) {
if ((*it)->web_contents() == web_contents)
return *it;
}
return NULL;
}
private:
Vector::iterator GetImplPos(const CefBrowserHostImpl* impl) {
Vector::iterator it = all_.begin();
for (; it != all_.end(); ++it) {
if (*it == impl)
return it;
}
return all_.end();
}
Vector all_;
DISALLOW_COPY_AND_ASSIGN(ImplManager);
};
base::LazyInstance<ImplManager> g_manager = LAZY_INSTANCE_INITIALIZER;
class CreateBrowserHelper {
public:
CreateBrowserHelper(const CefWindowInfo& windowInfo,
@@ -312,6 +371,23 @@ class UploadFolderHelper :
DISALLOW_COPY_AND_ASSIGN(UploadFolderHelper);
};
// Returns the primary OSR host view for the specified |web_contents|. If a
// full-screen host view currently exists then it will be returned. Otherwise,
// the main host view will be returned.
CefRenderWidgetHostViewOSR* GetOSRHostView(content::WebContents* web_contents) {
CefRenderWidgetHostViewOSR* fs_view =
static_cast<CefRenderWidgetHostViewOSR*>(
web_contents->GetFullscreenRenderWidgetHostView());
if (fs_view)
return fs_view;
content::RenderViewHost* host = web_contents->GetRenderViewHost();
if (host)
return static_cast<CefRenderWidgetHostViewOSR*>(host->GetView());
return NULL;
}
} // namespace
@@ -479,7 +555,7 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::CreateInternal(
#if defined(OS_LINUX) || defined(OS_ANDROID)
content::RendererPreferences* prefs = web_contents->GetMutableRendererPrefs();
CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params,
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(true), NULL)));
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), NULL)));
prefs->should_antialias_text = params.antialiasing;
prefs->use_subpixel_positioning = params.subpixel_positioning;
prefs->hinting = params.hinting;
@@ -506,7 +582,7 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::GetBrowserForHost(
content::WebContents* web_contents =
content::WebContents::FromRenderViewHost(host);
if (web_contents)
return static_cast<CefBrowserHostImpl*>(web_contents->GetDelegate());
return GetBrowserForContents(web_contents);
return NULL;
}
@@ -519,21 +595,20 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::GetBrowserForHost(
content::WebContents::FromRenderFrameHost(
const_cast<content::RenderFrameHost*>(host));
if (web_contents)
return static_cast<CefBrowserHostImpl*>(web_contents->GetDelegate());
return GetBrowserForContents(web_contents);
return NULL;
}
// static
CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::GetBrowserForContents(
content::WebContents* contents) {
const content::WebContents* contents) {
DCHECK(contents);
CEF_REQUIRE_UIT();
return static_cast<CefBrowserHostImpl*>(contents->GetDelegate());
return g_manager.Get().GetImplForWebContents(contents);
}
// static
CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::GetBrowserForRequest(
net::URLRequest* request) {
const net::URLRequest* request) {
DCHECK(request);
CEF_REQUIRE_IOT();
int render_process_id = -1;
@@ -564,11 +639,11 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::GetBrowserForView(
return GetBrowserForHost(render_view_host);
} else {
// Use the thread-safe approach.
bool is_guest_view = false;
scoped_refptr<CefBrowserInfo> info =
CefContentBrowserClient::Get()->GetBrowserInfoForView(
render_process_id,
render_routing_id);
if (info.get()) {
render_process_id, render_routing_id, &is_guest_view);
if (info.get() && !is_guest_view) {
CefRefPtr<CefBrowserHostImpl> browser = info->browser();
if (!browser.get()) {
LOG(WARNING) << "Found browser id " << info->browser_id() <<
@@ -597,11 +672,11 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::GetBrowserForFrame(
return GetBrowserForHost(render_frame_host);
} else {
// Use the thread-safe approach.
bool is_guest_view = false;
scoped_refptr<CefBrowserInfo> info =
CefContentBrowserClient::Get()->GetBrowserInfoForFrame(
render_process_id,
render_routing_id);
if (info.get()) {
render_process_id, render_routing_id, &is_guest_view);
if (info.get() && !is_guest_view) {
CefRefPtr<CefBrowserHostImpl> browser = info->browser();
if (!browser.get()) {
LOG(WARNING) << "Found browser id " << info->browser_id() <<
@@ -814,24 +889,46 @@ void CefBrowserHostImpl::StartDownload(const CefString& url) {
if (!manager)
return;
scoped_ptr<content::DownloadUrlParameters> params;
params.reset(
scoped_ptr<content::DownloadUrlParameters> params(
content::DownloadUrlParameters::FromWebContents(web_contents(), gurl));
manager->DownloadUrl(params.Pass());
}
void CefBrowserHostImpl::Print() {
if (CEF_CURRENTLY_ON_UIT()) {
if (!web_contents_)
content::WebContents* actionable_contents = GetActionableWebContents();
if (!actionable_contents)
return;
printing::PrintViewManager::FromWebContents(
web_contents_.get())->PrintNow();
actionable_contents)->PrintNow();
} else {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::Print, this));
}
}
void CefBrowserHostImpl::PrintToPDF(const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback) {
if (CEF_CURRENTLY_ON_UIT()) {
content::WebContents* actionable_contents = GetActionableWebContents();
if (!actionable_contents)
return;
printing::PrintViewManager::PdfPrintCallback pdf_callback;
if (callback.get()) {
pdf_callback = base::Bind(&CefPdfPrintCallback::OnPdfPrintFinished,
callback.get(), path);
}
printing::PrintViewManager::FromWebContents(actionable_contents)->
PrintToPDF(base::FilePath(path), settings, pdf_callback);
} else {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::PrintToPDF, this, path, settings,
callback));
}
}
void CefBrowserHostImpl::Find(int identifier, const CefString& searchText,
bool forward, bool matchCase, bool findNext) {
if (CEF_CURRENTLY_ON_UIT()) {
@@ -991,11 +1088,6 @@ void CefBrowserHostImpl::AddWordToDictionary(const CefString& word) {
}
void CefBrowserHostImpl::WasResized() {
if (!IsWindowless()) {
NOTREACHED() << "Window rendering is not disabled";
return;
}
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::WasResized, this));
return;
@@ -1004,11 +1096,15 @@ void CefBrowserHostImpl::WasResized() {
if (!web_contents())
return;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(
web_contents()->GetRenderViewHost()->GetView());
if (view)
view->WasResized();
if (!IsWindowless()) {
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
if (host)
host->WasResized();
} else {
CefRenderWidgetHostViewOSR* view = GetOSRHostView(web_contents());
if (view)
view->WasResized();
}
}
void CefBrowserHostImpl::WasHidden(bool hidden) {
@@ -1026,9 +1122,7 @@ void CefBrowserHostImpl::WasHidden(bool hidden) {
if (!web_contents())
return;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(
web_contents()->GetRenderViewHost()->GetView());
CefRenderWidgetHostViewOSR* view = GetOSRHostView(web_contents());
if (view) {
if (hidden)
view->Hide();
@@ -1052,9 +1146,7 @@ void CefBrowserHostImpl::NotifyScreenInfoChanged() {
if (!web_contents())
return;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(
web_contents()->GetRenderViewHost()->GetView());
CefRenderWidgetHostViewOSR* view = GetOSRHostView(web_contents());
if (view)
view->OnScreenInfoChanged();
}
@@ -1074,9 +1166,7 @@ void CefBrowserHostImpl::Invalidate(PaintElementType type) {
if (!web_contents())
return;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(
web_contents()->GetRenderViewHost()->GetView());
CefRenderWidgetHostViewOSR* view = GetOSRHostView(web_contents());
if (view)
view->Invalidate(type);
}
@@ -1088,20 +1178,18 @@ void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
return;
}
if (!web_contents())
return;
content::NativeWebKeyboardEvent web_event;
PlatformTranslateKeyEvent(web_event, event);
if (!IsWindowless()) {
content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost();
if (widget)
widget->ForwardKeyboardEvent(web_event);
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
if (host)
host->ForwardKeyboardEvent(web_event);
} else {
if (!web_contents())
return;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(
web_contents()->GetRenderViewHost()->GetView());
CefRenderWidgetHostViewOSR* view = GetOSRHostView(web_contents());
if (view)
view->SendKeyEvent(web_event);
}
@@ -1146,20 +1234,18 @@ void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event,
return;
}
if (!web_contents())
return;
blink::WebMouseWheelEvent web_event;
PlatformTranslateWheelEvent(web_event, event, deltaX, deltaY);
if (!IsWindowless()) {
content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost();
if (widget)
widget->ForwardWheelEvent(web_event);
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
if (host)
host->ForwardWheelEvent(web_event);
} else {
if (!web_contents())
return;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(
web_contents()->GetRenderViewHost()->GetView());
CefRenderWidgetHostViewOSR* view = GetOSRHostView(web_contents());
if (view)
view->SendMouseWheelEvent(web_event);
}
@@ -1196,17 +1282,15 @@ int CefBrowserHostImpl::TranslateModifiers(uint32 cef_modifiers) {
}
void CefBrowserHostImpl::SendMouseEvent(const blink::WebMouseEvent& event) {
if (!IsWindowless()) {
content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost();
if (widget)
widget->ForwardMouseEvent(event);
} else {
if (!web_contents())
return;
if (!web_contents())
return;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(
web_contents()->GetRenderViewHost()->GetView());
if (!IsWindowless()) {
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
if (host)
host->ForwardMouseEvent(event);
} else {
CefRenderWidgetHostViewOSR* view = GetOSRHostView(web_contents());
if (view)
view->SendMouseEvent(event);
}
@@ -1225,9 +1309,7 @@ void CefBrowserHostImpl::SendFocusEvent(bool setFocus) {
if (!web_contents())
return;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(
web_contents()->GetRenderViewHost()->GetView());
CefRenderWidgetHostViewOSR* view = GetOSRHostView(web_contents());
if (view)
view->SendFocusEvent(setFocus);
}
@@ -1260,13 +1342,45 @@ void CefBrowserHostImpl::NotifyMoveOrResizeStarted() {
return;
// Dismiss any existing popups.
content::RenderViewHost* rvh = web_contents()->GetRenderViewHost();
if (rvh)
rvh->NotifyMoveOrResizeStarted();
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
if (host)
host->NotifyMoveOrResizeStarted();
PlatformNotifyMoveOrResizeStarted();
}
int CefBrowserHostImpl::GetWindowlessFrameRate() {
// Verify that this method is being called on the UI thread.
if (!CEF_CURRENTLY_ON_UIT()) {
NOTREACHED() << "called on invalid thread";
return 0;
}
return CefRenderWidgetHostViewOSR::ClampFrameRate(
settings_.windowless_frame_rate);
}
void CefBrowserHostImpl::SetWindowlessFrameRate(int frame_rate) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::SetWindowlessFrameRate, this,
frame_rate));
return;
}
if (!IsWindowless())
return;
settings_.windowless_frame_rate = frame_rate;
if (!web_contents())
return;
CefRenderWidgetHostViewOSR* view = GetOSRHostView(web_contents());
if (view)
view->UpdateFrameRate();
}
// CefBrowser methods.
// -----------------------------------------------------------------------------
@@ -1281,6 +1395,13 @@ bool CefBrowserHostImpl::CanGoBack() {
void CefBrowserHostImpl::GoBack() {
if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) {
// Try again after frame destruction has completed.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::GoBack, this));
return;
}
if (web_contents_.get() && web_contents_->GetController().CanGoBack())
web_contents_->GetController().GoBack();
} else {
@@ -1296,6 +1417,13 @@ bool CefBrowserHostImpl::CanGoForward() {
void CefBrowserHostImpl::GoForward() {
if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) {
// Try again after frame destruction has completed.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::GoForward, this));
return;
}
if (web_contents_.get() && web_contents_->GetController().CanGoForward())
web_contents_->GetController().GoForward();
} else {
@@ -1311,6 +1439,13 @@ bool CefBrowserHostImpl::IsLoading() {
void CefBrowserHostImpl::Reload() {
if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) {
// Try again after frame destruction has completed.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::Reload, this));
return;
}
if (web_contents_.get())
web_contents_->GetController().Reload(true);
} else {
@@ -1321,6 +1456,13 @@ void CefBrowserHostImpl::Reload() {
void CefBrowserHostImpl::ReloadIgnoreCache() {
if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) {
// Try again after frame destruction has completed.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::ReloadIgnoreCache, this));
return;
}
if (web_contents_.get())
web_contents_->GetController().ReloadIgnoringCache(true);
} else {
@@ -1331,6 +1473,13 @@ void CefBrowserHostImpl::ReloadIgnoreCache() {
void CefBrowserHostImpl::StopLoad() {
if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) {
// Try again after frame destruction has completed.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::StopLoad, this));
return;
}
if (web_contents_.get())
web_contents_->Stop();
} else {
@@ -1486,6 +1635,8 @@ void CefBrowserHostImpl::DestroyBrowser() {
queued_messages_.pop();
}
g_manager.Get().RemoveImpl(this);
registrar_.reset(NULL);
response_manager_.reset(NULL);
content::WebContentsObserver::Observe(NULL);
@@ -1605,6 +1756,14 @@ void CefBrowserHostImpl::LoadURL(
if (frame_id == CefFrameHostImpl::kMainFrameId) {
// Go through the navigation controller.
if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) {
// Try again after frame destruction has completed.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::LoadURL, this, frame_id, url,
referrer, transition, extra_headers));
return;
}
if (web_contents_.get()) {
GURL gurl = GURL(url);
@@ -1816,6 +1975,34 @@ void CefBrowserHostImpl::RunFileChooser(
callback));
}
bool CefBrowserHostImpl::EmbedsFullscreenWidget() const {
// When using windowless rendering do not allow Flash to create its own full-
// screen widget.
return IsWindowless();
}
void CefBrowserHostImpl::EnterFullscreenModeForTab(
content::WebContents* web_contents,
const GURL& origin) {
OnFullscreenModeChange(true);
}
void CefBrowserHostImpl::ExitFullscreenModeForTab(
content::WebContents* web_contents) {
OnFullscreenModeChange(false);
}
bool CefBrowserHostImpl::IsFullscreenForTabOrPending(
const content::WebContents* web_contents) const {
return is_fullscreen_;
}
blink::WebDisplayMode CefBrowserHostImpl::GetDisplayMode(
const content::WebContents* web_contents) const {
return is_fullscreen_ ? blink::WebDisplayModeFullscreen :
blink::WebDisplayModeBrowser;
}
void CefBrowserHostImpl::FindReply(
content::WebContents* web_contents,
int request_id,
@@ -2043,6 +2230,8 @@ void CefBrowserHostImpl::DragSourceEndedAt(
// content::WebContentsDelegate methods.
// -----------------------------------------------------------------------------
// |source| may be NULL if the navigation originates from a guest view via
// CefContentBrowserClient::CanCreateWindow.
content::WebContents* CefBrowserHostImpl::OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) {
@@ -2183,19 +2372,19 @@ bool CefBrowserHostImpl::TakeFocus(content::WebContents* source,
return false;
}
void CefBrowserHostImpl::WebContentsFocused(content::WebContents* contents) {
if (client_.get()) {
CefRefPtr<CefFocusHandler> handler = client_->GetFocusHandler();
if (handler.get())
handler->OnGotFocus(this);
}
}
bool CefBrowserHostImpl::HandleContextMenu(
const content::ContextMenuParams& params) {
if (!menu_creator_.get())
menu_creator_.reset(new CefMenuCreator(this));
return menu_creator_->CreateContextMenu(params);
return HandleContextMenu(web_contents(), params);
}
content::WebContents* CefBrowserHostImpl::GetActionableWebContents() {
if (web_contents() && extensions::ExtensionsEnabled()) {
content::WebContents* guest_contents =
extensions::GetFullPageGuestForOwnerContents(web_contents());
if (guest_contents)
return guest_contents;
}
return web_contents();
}
bool CefBrowserHostImpl::PreHandleKeyboardEvent(
@@ -2265,7 +2454,7 @@ bool CefBrowserHostImpl::ShouldCreateWebContents(
int route_id,
int main_frame_route_id,
WindowContainerType window_container_type,
const base::string16& frame_name,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace,
@@ -2291,7 +2480,7 @@ bool CefBrowserHostImpl::ShouldCreateWebContents(
void CefBrowserHostImpl::WebContentsCreated(
content::WebContents* source_contents,
int opener_render_frame_id,
const base::string16& frame_name,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
DCHECK(new_contents);
@@ -2307,12 +2496,17 @@ void CefBrowserHostImpl::WebContentsCreated(
content::RenderFrameHost* main_frame_host = new_contents->GetMainFrame();
CefWindowHandle opener = kNullWindowHandle;
bool is_guest_view = false;
scoped_refptr<CefBrowserInfo> info =
CefContentBrowserClient::Get()->GetOrCreateBrowserInfo(
view_host->GetProcess()->GetID(),
view_host->GetRoutingID(),
main_frame_host->GetProcess()->GetID(),
main_frame_host->GetRoutingID());
main_frame_host->GetRoutingID(),
&is_guest_view);
// A CefBrowser should never be created for a guest view WebContents.
CHECK(!is_guest_view);
if (source_contents) {
DCHECK(info->is_popup());
@@ -2379,6 +2573,14 @@ void CefBrowserHostImpl::RunFileChooser(
web_contents, params.mode));
}
bool CefBrowserHostImpl::HandleContextMenu(
content::WebContents* web_contents,
const content::ContextMenuParams& params) {
if (!menu_creator_.get())
menu_creator_.reset(new CefMenuCreator(web_contents, this));
return menu_creator_->CreateContextMenu(params);
}
bool CefBrowserHostImpl::SetPendingPopupInfo(
scoped_ptr<PendingPopupInfo> info) {
base::AutoLock lock_scope(pending_popup_info_lock_);
@@ -2459,21 +2661,23 @@ bool CefBrowserHostImpl::CheckMediaAccessPermission(
void CefBrowserHostImpl::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) {
browser_info_->add_render_frame_id(render_frame_host->GetProcess()->GetID(),
render_frame_host->GetRoutingID());
browser_info_->render_id_manager()->add_render_frame_id(
render_frame_host->GetProcess()->GetID(),
render_frame_host->GetRoutingID());
}
void CefBrowserHostImpl::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
browser_info_->remove_render_frame_id(
browser_info_->render_id_manager()->remove_render_frame_id(
render_frame_host->GetProcess()->GetID(),
render_frame_host->GetRoutingID());
}
void CefBrowserHostImpl::RenderViewCreated(
content::RenderViewHost* render_view_host) {
browser_info_->add_render_view_id(render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
browser_info_->render_id_manager()->add_render_view_id(
render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
// May be already registered if the renderer crashed previously.
if (!registrar_->IsRegistered(
@@ -2486,8 +2690,9 @@ void CefBrowserHostImpl::RenderViewCreated(
void CefBrowserHostImpl::RenderViewDeleted(
content::RenderViewHost* render_view_host) {
browser_info_->remove_render_view_id(render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
browser_info_->render_id_manager()->remove_render_view_id(
render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
if (registrar_->IsRegistered(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
@@ -2525,8 +2730,11 @@ void CefBrowserHostImpl::RenderProcessGone(base::TerminationStatus status) {
if (client_.get()) {
CefRefPtr<CefRequestHandler> handler = client_->GetRequestHandler();
if (handler.get())
if (handler.get()) {
frame_destruction_pending_ = true;
handler->OnRenderProcessTerminated(this, ts);
frame_destruction_pending_ = false;
}
}
}
@@ -2550,7 +2758,8 @@ void CefBrowserHostImpl::DidFailProvisionalLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code,
const base::string16& error_description) {
const base::string16& error_description,
bool was_ignored_by_handler) {
const bool is_main_frame = !render_frame_host->GetParent();
CefRefPtr<CefFrame> frame = GetOrCreateFrame(
render_frame_host->GetRoutingID(),
@@ -2570,7 +2779,8 @@ void CefBrowserHostImpl::DidFailLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code,
const base::string16& error_description) {
const base::string16& error_description,
bool was_ignored_by_handler) {
const bool is_main_frame = !render_frame_host->GetParent();
CefRefPtr<CefFrame> frame = GetOrCreateFrame(
render_frame_host->GetRoutingID(),
@@ -2643,6 +2853,14 @@ bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) {
return handled;
}
void CefBrowserHostImpl::OnWebContentsFocused() {
if (client_.get()) {
CefRefPtr<CefFocusHandler> handler = client_->GetFocusHandler();
if (handler.get())
handler->OnGotFocus(this);
}
}
bool CefBrowserHostImpl::Send(IPC::Message* message) {
if (CEF_CURRENTLY_ON_UIT()) {
if (queue_messages_) {
@@ -2805,10 +3023,12 @@ CefBrowserHostImpl::CefBrowserHostImpl(
can_go_back_(false),
can_go_forward_(false),
has_document_(false),
is_fullscreen_(false),
queue_messages_(true),
main_frame_id_(CefFrameHostImpl::kInvalidFrameId),
focused_frame_id_(CefFrameHostImpl::kInvalidFrameId),
destruction_state_(DESTRUCTION_STATE_NONE),
frame_destruction_pending_(false),
window_destroyed_(false),
is_in_onsetfocus_(false),
focus_on_editable_field_(false),
@@ -2830,6 +3050,8 @@ CefBrowserHostImpl::CefBrowserHostImpl(
web_contents_.reset(web_contents);
web_contents->SetDelegate(this);
g_manager.Get().AddImpl(this);
registrar_.reset(new content::NotificationRegistrar);
registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
content::Source<content::WebContents>(web_contents));
@@ -2856,9 +3078,7 @@ CefBrowserHostImpl::CefBrowserHostImpl(
RenderViewCreated(web_contents->GetRenderViewHost());
if (IsWindowless()) {
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(
web_contents->GetRenderViewHost()->GetView());
CefRenderWidgetHostViewOSR* view = GetOSRHostView(web_contents);
if (view)
view->set_browser_impl(this);
}
@@ -2988,11 +3208,13 @@ void CefBrowserHostImpl::OnLoadError(CefRefPtr<CefFrame> frame,
if (client_.get()) {
CefRefPtr<CefLoadHandler> handler = client_->GetLoadHandler();
if (handler.get()) {
frame_destruction_pending_ = true;
// Notify the handler that loading has failed.
handler->OnLoadError(this, frame,
static_cast<cef_errorcode_t>(error_code),
CefString(error_description),
url.spec());
frame_destruction_pending_ = false;
}
}
}
@@ -3007,6 +3229,20 @@ void CefBrowserHostImpl::OnLoadEnd(CefRefPtr<CefFrame> frame,
}
}
void CefBrowserHostImpl::OnFullscreenModeChange(bool fullscreen) {
if (is_fullscreen_ == fullscreen)
return;
is_fullscreen_ = fullscreen;
WasResized();
if (client_.get()) {
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
if (handler.get())
handler->OnFullscreenModeChange(this, fullscreen);
}
}
void CefBrowserHostImpl::RunFileChooserOnUIThread(
const FileChooserParams& params,
const RunFileChooserCallback& callback) {
@@ -3114,7 +3350,6 @@ void CefBrowserHostImpl::OnRunFileChooserUploadFolderDelegateCallback(
} else {
lister_.reset(new net::DirectoryLister(
file_paths[0],
true,
net::DirectoryLister::NO_SORT,
new UploadFolderHelper(
base::Bind(&CefBrowserHostImpl::OnRunFileChooserDelegateCallback,

View File

@@ -15,6 +15,7 @@
#include "include/cef_browser.h"
#include "include/cef_client.h"
#include "include/cef_frame.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/javascript_dialog_manager.h"
#include "libcef/browser/menu_creator.h"
@@ -131,10 +132,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
const content::RenderFrameHost* host);
// Returns the browser associated with the specified WebContents.
static CefRefPtr<CefBrowserHostImpl> GetBrowserForContents(
content::WebContents* contents);
const content::WebContents* contents);
// Returns the browser associated with the specified URLRequest.
static CefRefPtr<CefBrowserHostImpl> GetBrowserForRequest(
net::URLRequest* request);
const net::URLRequest* request);
// Returns the browser associated with the specified view routing IDs.
static CefRefPtr<CefBrowserHostImpl> GetBrowserForView(
int render_process_id, int render_routing_id);
@@ -162,6 +163,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
CefRefPtr<CefRunFileDialogCallback> callback) override;
void StartDownload(const CefString& url) override;
void Print() override;
void PrintToPDF(const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback) override;
void Find(int identifier, const CefString& searchText,
bool forward, bool matchCase, bool findNext) override;
void StopFinding(bool clearSelection) override;
@@ -193,6 +197,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
void SendFocusEvent(bool setFocus) override;
void SendCaptureLostEvent() override;
void NotifyMoveOrResizeStarted() override;
int GetWindowlessFrameRate() override;
void SetWindowlessFrameRate(int frame_rate) override;
CefTextInputContext GetNSTextInputContext() override;
void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent) override;
void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent) override;
@@ -298,6 +304,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Thread safe accessors.
const CefBrowserSettings& settings() const { return settings_; }
CefRefPtr<CefClient> client() const { return client_; }
scoped_refptr<CefBrowserInfo> browser_info() const { return browser_info_; }
int browser_id() const;
#if defined(USE_AURA)
@@ -328,6 +335,16 @@ class CefBrowserHostImpl : public CefBrowserHost,
void RunFileChooser(const FileChooserParams& params,
const RunFileChooserCallback& callback);
bool HandleContextMenu(
content::WebContents* web_contents,
const content::ContextMenuParams& params);
// Returns the WebContents most likely to handle an action. If extensions are
// enabled and this browser has a full-page guest (for example, a full-page
// PDF viewer extension) then the guest's WebContents will be returned.
// Otherwise, the browser's WebContents will be returned.
content::WebContents* GetActionableWebContents();
// Used when creating a new popup window.
struct PendingPopupInfo {
CefWindowInfo window_info;
@@ -364,7 +381,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool* proceed_to_fire_unload) override;
bool TakeFocus(content::WebContents* source,
bool reverse) override;
void WebContentsFocused(content::WebContents* contents) override;
bool HandleContextMenu(
const content::ContextMenuParams& params) override;
bool PreHandleKeyboardEvent(
@@ -383,7 +399,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
int route_id,
int main_frame_route_id,
WindowContainerType window_container_type,
const base::string16& frame_name,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace,
@@ -391,7 +407,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::RenderViewHostDelegateView** delegate_view) override;
void WebContentsCreated(content::WebContents* source_contents,
int opener_render_frame_id,
const base::string16& frame_name,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) override;
void DidNavigateMainFramePostCommit(
@@ -401,6 +417,14 @@ class CefBrowserHostImpl : public CefBrowserHost,
void RunFileChooser(
content::WebContents* web_contents,
const content::FileChooserParams& params) override;
bool EmbedsFullscreenWidget() const override;
void EnterFullscreenModeForTab(content::WebContents* web_contents,
const GURL& origin) override;
void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
bool IsFullscreenForTabOrPending(
const content::WebContents* web_contents) const override;
blink::WebDisplayMode GetDisplayMode(
const content::WebContents* web_contents) const override;
void FindReply(
content::WebContents* web_contents,
int request_id,
@@ -409,7 +433,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
int active_match_ordinal,
bool final_update) override;
void UpdatePreferredSize(content::WebContents* source,
const gfx::Size& pref_size) override;
const gfx::Size& pref_size) override;
void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
@@ -439,12 +463,14 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code,
const base::string16& error_description) override;
const base::string16& error_description,
bool was_ignored_by_handler) override;
void DocumentAvailableInMainFrame() override;
void DidFailLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code,
const base::string16& error_description) override;
const base::string16& error_description,
bool was_ignored_by_handler) override;
void FrameDeleted(
content::RenderFrameHost* render_frame_host) override;
void PluginCrashed(const base::FilePath& plugin_path,
@@ -452,6 +478,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
void DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& candidates) override;
bool OnMessageReceived(const IPC::Message& message) override;
void OnWebContentsFocused() override;
// Override to provide a thread safe implementation.
bool Send(IPC::Message* message) override;
@@ -570,6 +597,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
void OnLoadEnd(CefRefPtr<CefFrame> frame,
const GURL& url,
int http_status_code);
void OnFullscreenModeChange(bool fullscreen);
// Continuation from RunFileChooser.
void RunFileChooserOnUIThread(const FileChooserParams& params,
@@ -616,6 +644,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool can_go_back_;
bool can_go_forward_;
bool has_document_;
bool is_fullscreen_;
// Messages we queue while waiting for the RenderView to be ready. We queue
// them here instead of in the RenderProcessHost to ensure that they're sent
@@ -637,6 +666,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
// thread.
DestructionState destruction_state_;
// True if frame destruction is currently pending. Navigation should not occur
// while this flag is true.
bool frame_destruction_pending_;
// True if the OS window hosting the browser has been destroyed. Only accessed
// on the UI thread.
bool window_destroyed_;

View File

@@ -438,8 +438,12 @@ void RunOpenFileDialog(const CefBrowserHostImpl::FileChooserParams& params,
[openPanel setShowsHiddenFiles:!params.hidereadonly];
// Show panel.
[openPanel beginSheetModalForWindow:[view window] completionHandler:nil];
if ([openPanel runModal] == NSFileHandlingPanelOKButton) {
[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++) {
@@ -451,8 +455,6 @@ void RunOpenFileDialog(const CefBrowserHostImpl::FileChooserParams& params,
if (filter_delegate != nil)
*filter_index = [filter_delegate filter];
[NSApp endSheet:openPanel];
}
bool RunSaveFileDialog(const CefBrowserHostImpl::FileChooserParams& params,
@@ -501,9 +503,14 @@ bool RunSaveFileDialog(const CefBrowserHostImpl::FileChooserParams& params,
bool success = false;
[savePanel beginSheetModalForWindow:[view window] completionHandler:nil];
if ([savePanel runModal] == NSFileHandlingPanelOKButton) {
NSURL * url = [savePanel URL];
// Show panel.
[savePanel beginSheetModalForWindow:[view window]
completionHandler:^(NSInteger resultCode) {
[NSApp stopModalWithCode:resultCode];
}];
NSInteger result = [NSApp runModalForWindow:[view window]];
if (result == NSFileHandlingPanelOKButton) {
NSURL* url = [savePanel URL];
NSString* path = [url path];
*file = base::FilePath([path UTF8String]);
success = true;
@@ -512,8 +519,6 @@ bool RunSaveFileDialog(const CefBrowserHostImpl::FileChooserParams& params,
if (filter_delegate != nil)
*filter_index = [filter_delegate filter];
[NSApp endSheet:savePanel];
return success;
}

View File

@@ -638,7 +638,7 @@ LPCWSTR ToCursorID(WebCursorInfo::Type type) {
case WebCursorInfo::TypeCell:
return MAKEINTRESOURCE(IDC_CELL);
case WebCursorInfo::TypeContextMenu:
return MAKEINTRESOURCE(IDC_ARROW);
return IDC_ARROW;
case WebCursorInfo::TypeAlias:
return MAKEINTRESOURCE(IDC_ALIAS);
case WebCursorInfo::TypeProgress:

View File

@@ -3,73 +3,59 @@
// be found in the LICENSE file.
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_host_impl.h"
#include "ipc/ipc_message.h"
CefBrowserInfo::CefBrowserInfo(int browser_id, bool is_popup)
: browser_id_(browser_id),
is_popup_(is_popup),
is_windowless_(false) {
DCHECK_GT(browser_id, 0);
// CefBrowserInfo::RenderIDManager
CefBrowserInfo::RenderIDManager::RenderIDManager(base::Lock* lock)
: lock_(lock) {
DCHECK(lock);
}
CefBrowserInfo::~CefBrowserInfo() {
}
void CefBrowserInfo::set_windowless(bool windowless) {
is_windowless_ = windowless;
}
void CefBrowserInfo::add_render_view_id(
void CefBrowserInfo::RenderIDManager::add_render_view_id(
int render_process_id, int render_routing_id) {
add_render_id(&render_view_id_set_, render_process_id, render_routing_id);
}
void CefBrowserInfo::add_render_frame_id(
void CefBrowserInfo::RenderIDManager::add_render_frame_id(
int render_process_id, int render_routing_id) {
add_render_id(&render_frame_id_set_, render_process_id, render_routing_id);
}
void CefBrowserInfo::remove_render_view_id(
void CefBrowserInfo::RenderIDManager::remove_render_view_id(
int render_process_id, int render_routing_id) {
remove_render_id(&render_view_id_set_, render_process_id, render_routing_id);
}
void CefBrowserInfo::remove_render_frame_id(
void CefBrowserInfo::RenderIDManager::remove_render_frame_id(
int render_process_id, int render_routing_id) {
remove_render_id(&render_frame_id_set_, render_process_id, render_routing_id);
}
bool CefBrowserInfo::is_render_view_id_match(
bool CefBrowserInfo::RenderIDManager::is_render_view_id_match(
int render_process_id, int render_routing_id) {
return is_render_id_match(&render_view_id_set_,
render_process_id,
render_routing_id);
}
bool CefBrowserInfo::is_render_frame_id_match(
bool CefBrowserInfo::RenderIDManager::is_render_frame_id_match(
int render_process_id, int render_routing_id) {
return is_render_id_match(&render_frame_id_set_,
render_process_id,
render_routing_id);
}
CefRefPtr<CefBrowserHostImpl> CefBrowserInfo::browser() {
base::AutoLock lock_scope(lock_);
return browser_;
}
void CefBrowserInfo::set_browser(CefRefPtr<CefBrowserHostImpl> browser) {
base::AutoLock lock_scope(lock_);
browser_ = browser;
}
void CefBrowserInfo::add_render_id(RenderIdSet* id_set,
int render_process_id,
int render_routing_id) {
void CefBrowserInfo::RenderIDManager::add_render_id(RenderIdSet* id_set,
int render_process_id,
int render_routing_id) {
DCHECK_GT(render_process_id, 0);
DCHECK_GT(render_routing_id, 0);
base::AutoLock lock_scope(lock_);
base::AutoLock lock_scope(*lock_);
if (!id_set->empty()) {
RenderIdSet::const_iterator it =
@@ -81,13 +67,13 @@ void CefBrowserInfo::add_render_id(RenderIdSet* id_set,
id_set->insert(std::make_pair(render_process_id, render_routing_id));
}
void CefBrowserInfo::remove_render_id(RenderIdSet* id_set,
int render_process_id,
int render_routing_id) {
void CefBrowserInfo::RenderIDManager::remove_render_id(RenderIdSet* id_set,
int render_process_id,
int render_routing_id) {
DCHECK_GT(render_process_id, 0);
DCHECK_GT(render_routing_id, 0);
base::AutoLock lock_scope(lock_);
base::AutoLock lock_scope(*lock_);
DCHECK(!id_set->empty());
if (id_set->empty())
@@ -98,10 +84,11 @@ void CefBrowserInfo::remove_render_id(RenderIdSet* id_set,
DCHECK(erased);
}
bool CefBrowserInfo::is_render_id_match(const RenderIdSet* id_set,
int render_process_id,
int render_routing_id) {
base::AutoLock lock_scope(lock_);
bool CefBrowserInfo::RenderIDManager::is_render_id_match(
const RenderIdSet* id_set,
int render_process_id,
int render_routing_id) {
base::AutoLock lock_scope(*lock_);
if (id_set->empty())
return false;
@@ -110,3 +97,32 @@ bool CefBrowserInfo::is_render_id_match(const RenderIdSet* id_set,
id_set->find(std::make_pair(render_process_id, render_routing_id));
return (it != id_set->end());
}
// CefBrowserInfo
CefBrowserInfo::CefBrowserInfo(int browser_id, bool is_popup)
: browser_id_(browser_id),
is_popup_(is_popup),
is_windowless_(false),
render_id_manager_(&lock_),
guest_render_id_manager_(&lock_) {
DCHECK_GT(browser_id, 0);
}
CefBrowserInfo::~CefBrowserInfo() {
}
void CefBrowserInfo::set_windowless(bool windowless) {
is_windowless_ = windowless;
}
CefRefPtr<CefBrowserHostImpl> CefBrowserInfo::browser() {
base::AutoLock lock_scope(lock_);
return browser_;
}
void CefBrowserInfo::set_browser(CefRefPtr<CefBrowserHostImpl> browser) {
base::AutoLock lock_scope(lock_);
browser_ = browser;
}

View File

@@ -8,8 +8,12 @@
#include <set>
#include "libcef/browser/browser_host_impl.h"
#include "include/internal/cef_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
class CefBrowserHostImpl;
// CefBrowserInfo is used to associate a browser ID and render view/process
// IDs with a particular CefBrowserHostImpl. Render view/process IDs may change
@@ -19,6 +23,53 @@
// be created directly.
class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
public:
class RenderIDManager {
public:
explicit RenderIDManager(base::Lock* lock);
// Adds an ID pair if it doesn't already exist.
void add_render_view_id(int render_process_id, int render_routing_id);
void add_render_frame_id(int render_process_id, int render_routing_id);
// Remove an ID pair if it exists.
void remove_render_view_id(int render_process_id, int render_routing_id);
void remove_render_frame_id(int render_process_id, int render_routing_id);
// Returns true if this browser matches the specified ID pair.
bool is_render_view_id_match(int render_process_id, int render_routing_id);
bool is_render_frame_id_match(int render_process_id, int render_routing_id);
private:
typedef std::set<std::pair<int, int> > RenderIdSet;
void add_render_id(RenderIdSet* id_set,
int render_process_id,
int render_routing_id);
void remove_render_id(RenderIdSet* id_set,
int render_process_id,
int render_routing_id);
bool is_render_id_match(const RenderIdSet* id_set,
int render_process_id,
int render_routing_id);
base::Lock* lock_;
// The below members must be protected by |lock_|.
// Set of mapped (process_id, routing_id) pairs. Keeping this set is
// necessary for the following reasons:
// 1. When navigating cross-origin the new (pending) RenderViewHost will be
// created before the old (current) RenderViewHost is destroyed.
// 2. When canceling and asynchronously continuing navigation of the same
// URL a new RenderViewHost may be created for the first (canceled)
// navigation and then destroyed as a result of the second (allowed)
// navigation.
// 3. Out-of-process iframes have their own render IDs which must also be
// associated with the host browser.
RenderIdSet render_view_id_set_;
RenderIdSet render_frame_id_set_;
};
CefBrowserInfo(int browser_id, bool is_popup);
int browser_id() const { return browser_id_; };
@@ -27,17 +78,15 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
void set_windowless(bool windowless);
// Adds an ID pair if it doesn't already exist.
void add_render_view_id(int render_process_id, int render_routing_id);
void add_render_frame_id(int render_process_id, int render_routing_id);
// Returns the render ID manager for this browser.
RenderIDManager* render_id_manager() {
return &render_id_manager_;
}
// Remove an ID pair if it exists.
void remove_render_view_id(int render_process_id, int render_routing_id);
void remove_render_frame_id(int render_process_id, int render_routing_id);
// Returns true if this browser matches the specified ID pair.
bool is_render_view_id_match(int render_process_id, int render_routing_id);
bool is_render_frame_id_match(int render_process_id, int render_routing_id);
// Returns the render ID manager for guest views owned by this browser.
RenderIDManager* guest_render_id_manager() {
return &guest_render_id_manager_;
}
CefRefPtr<CefBrowserHostImpl> browser();
void set_browser(CefRefPtr<CefBrowserHostImpl> browser);
@@ -47,18 +96,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
~CefBrowserInfo();
typedef std::set<std::pair<int, int> > RenderIdSet;
void add_render_id(RenderIdSet* id_set,
int render_process_id,
int render_routing_id);
void remove_render_id(RenderIdSet* id_set,
int render_process_id,
int render_routing_id);
bool is_render_id_match(const RenderIdSet* id_set,
int render_process_id,
int render_routing_id);
int browser_id_;
bool is_popup_;
bool is_windowless_;
@@ -67,17 +104,8 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// The below members must be protected by |lock_|.
// Set of mapped (process_id, routing_id) pairs. Keeping this set is
// necessary for the following reasons:
// 1. When navigating cross-origin the new (pending) RenderViewHost will be
// created before the old (current) RenderViewHost is destroyed.
// 2. When canceling and asynchronously continuing navigation of the same URL
// a new RenderViewHost may be created for the first (canceled) navigation
// and then destroyed as a result of the second (allowed) navigation.
// 3. Out-of-process iframes have their own render IDs which must also be
// associated with the host browser.
RenderIdSet render_view_id_set_;
RenderIdSet render_frame_id_set_;
RenderIDManager render_id_manager_;
RenderIDManager guest_render_id_manager_;
// May be NULL if the browser has not yet been created or if the browser has
// been destroyed.

View File

@@ -12,17 +12,26 @@
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools_delegate.h"
#include "libcef/browser/extensions/browser_context_keyed_service_factories.h"
#include "libcef/browser/extensions/extensions_browser_client.h"
#include "libcef/browser/extensions/extension_system_factory.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_client.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net_resource_provider.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "content/browser/webui/content_web_ui_controller_factory.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/web_ui_controller_factory.h"
#include "content/public/common/content_switches.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "net/base/net_module.h"
#include "ui/base/resource/resource_bundle.h"
@@ -74,7 +83,6 @@ void CefBrowserMainParts::ToolkitInitialized() {
#if defined(USE_AURA)
CHECK(aura::Env::GetInstance());
DCHECK(!views::ViewsDelegate::views_delegate);
new views::DesktopTestViewsDelegate;
#if defined(OS_WIN)
@@ -93,11 +101,16 @@ void CefBrowserMainParts::PostMainMessageLoopStart() {
#if defined(OS_LINUX)
printing::PrintingContextLinux::SetCreatePrintDialogFunction(
&CefPrintDialogLinux::CreatePrintDialog);
printing::PrintingContextLinux::SetPdfPaperSizeFunction(
&CefPrintDialogLinux::GetPdfPaperSize);
#endif
}
int CefBrowserMainParts::PreCreateThreads() {
#if defined(OS_WIN)
PlatformInitialize();
#endif
net::NetModule::SetResourceProvider(&NetResourceProvider);
// Initialize the GpuDataManager before IO access restrictions are applied and
@@ -118,6 +131,20 @@ int CefBrowserMainParts::PreCreateThreads() {
}
void CefBrowserMainParts::PreMainMessageLoopRun() {
if (extensions::ExtensionsEnabled()) {
// Initialize extension global objects before creating the global
// BrowserContext.
extensions_client_.reset(new extensions::CefExtensionsClient());
extensions::ExtensionsClient::Set(extensions_client_.get());
extensions_browser_client_.reset(new extensions::CefExtensionsBrowserClient);
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
// Register additional KeyedService factories here. See
// ChromeBrowserMainExtraPartsProfiles for details.
extensions::cef::EnsureBrowserContextKeyedServiceFactoriesBuilt();
extensions::CefExtensionSystemFactory::GetInstance();
}
CefRequestContextSettings settings;
CefContext::Get()->PopulateRequestContextSettings(&settings);
@@ -138,9 +165,21 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
LOG(WARNING) << "Invalid http debugger port number " << port;
}
}
// Triggers initialization of the singleton instance on UI thread.
PluginFinder::GetInstance()->Init();
#if defined(OS_WIN)
PlatformPreMainMessageLoopRun();
#endif
}
void CefBrowserMainParts::PostMainMessageLoopRun() {
if (extensions::ExtensionsEnabled()) {
extensions::ExtensionsBrowserClient::Set(NULL);
extensions_browser_client_.reset();
}
if (devtools_delegate_) {
devtools_delegate_->Stop();
devtools_delegate_ = NULL;
@@ -157,13 +196,13 @@ void CefBrowserMainParts::PostMainMessageLoopRun() {
void CefBrowserMainParts::PostDestroyThreads() {
#if defined(USE_AURA)
aura::Env::DeleteInstance();
delete views::ViewsDelegate::views_delegate;
// Delete the DesktopTestViewsDelegate.
delete views::ViewsDelegate::GetInstance();
#endif
#ifndef NDEBUG
// No CefURLRequestContext instances should exist at this point.
DCHECK_EQ(0, CefURLRequestContext::DebugObjCt);
#endif
PlatformCleanup();
}

View File

@@ -27,6 +27,11 @@ namespace content {
struct MainFunctionParams;
}
namespace extensions {
class ExtensionsBrowserClient;
class ExtensionsClient;
}
class CefDevToolsDelegate;
class CefBrowserMainParts : public content::BrowserMainParts {
@@ -52,8 +57,10 @@ class CefBrowserMainParts : public content::BrowserMainParts {
PrefService* pref_service() const { return pref_service_.get(); }
private:
#if defined(OS_WIN)
void PlatformInitialize();
void PlatformCleanup();
void PlatformPreMainMessageLoopRun();
#endif // defined(OS_WIN)
scoped_refptr<CefBrowserContextImpl> global_browser_context_;
CefDevToolsDelegate* devtools_delegate_; // Deletes itself.
@@ -61,6 +68,9 @@ class CefBrowserMainParts : public content::BrowserMainParts {
scoped_refptr<CefBrowserPrefStore> pref_store_;
scoped_ptr<PrefService> pref_service_;
scoped_ptr<extensions::ExtensionsClient> extensions_client_;
scoped_ptr<extensions::ExtensionsBrowserClient> extensions_browser_client_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts);
};

View File

@@ -1,11 +0,0 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/browser_main.h"
void CefBrowserMainParts::PlatformInitialize() {
}
void CefBrowserMainParts::PlatformCleanup() {
}

View File

@@ -1,11 +0,0 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/browser_main.h"
void CefBrowserMainParts::PlatformInitialize() {
}
void CefBrowserMainParts::PlatformCleanup() {
}

View File

@@ -9,6 +9,28 @@
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/browser_main.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 "content/public/common/dwrite_font_platform_win.h"
#include "grit/cef_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/win/direct_write.h"
namespace {
void ExecuteFontCacheBuildTask(const base::FilePath& path) {
base::WeakPtr<content::UtilityProcessHost> utility_process_host(
content::UtilityProcessHost::Create(NULL, NULL)->AsWeakPtr());
utility_process_host->SetName(l10n_util::GetStringUTF16(
IDS_UTILITY_PROCESS_FONT_CACHE_BUILDER_NAME));
utility_process_host->DisableSandbox();
utility_process_host->Send(
new ChromeUtilityHostMsg_BuildDirectWriteFontCache(path));
}
} // namespace
void CefBrowserMainParts::PlatformInitialize() {
HRESULT res;
@@ -28,5 +50,38 @@ void CefBrowserMainParts::PlatformInitialize() {
CefBrowserHostImpl::RegisterWindowClass();
}
void CefBrowserMainParts::PlatformCleanup() {
void CefBrowserMainParts::PlatformPreMainMessageLoopRun() {
// From ChromeBrowserMainPartsWin::PostProfileInit().
// DirectWrite support is mainly available on Windows 7 and up.
if (gfx::win::ShouldUseDirectWrite()) {
const base::FilePath& cache_path = global_browser_context_->GetPath();
if (cache_path.empty())
return;
const base::FilePath& font_cache_path =
cache_path.AppendASCII(content::kFontCacheSharedSectionName);
// This function will create a read only section if cache file exists
// otherwise it will spawn utility process to build cache file, which will
// be used during next browser start/postprofileinit.
if (!content::LoadFontCache(font_cache_path)) {
// We delay building of font cache until first startup page loads.
// During first renderer start there are lot of things happening
// simultaneously some of them are:
// - Renderer is going through all font files on the system to create
// a font collection.
// - Renderer loading up startup URL, accessing HTML/JS File cache,
// net activity etc.
// - Extension initialization.
// We delay building of cache mainly to avoid parallel font file
// loading along with Renderer. Some systems have significant number of
// font files which takes long time to process.
// Related information is at http://crbug.com/436195.
const int kBuildFontCacheDelaySec = 30;
content::BrowserThread::PostDelayedTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(ExecuteFontCacheBuildTask, font_cache_path),
base::TimeDelta::FromSeconds(kBuildFontCacheDelaySec));
}
}
}

View File

@@ -97,7 +97,8 @@ void CefBrowserMessageFilter::OnGetNewBrowserInfo(
host_->GetID(),
render_view_routing_id,
host_->GetID(),
render_frame_routing_id);
render_frame_routing_id,
&params->is_guest_view);
params->browser_id = info->browser_id();
params->is_popup = info->is_popup();
params->is_windowless = info->is_windowless();

View File

@@ -15,9 +15,11 @@
#include "base/values.h"
#include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
#include "chrome/browser/prefs/command_line_pref_store.h"
#include "chrome/browser/prefs/proxy_config_dictionary.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/proxy_config/proxy_config_dictionary.h"
#include "extensions/browser/extension_prefs.h"
#include "grit/cef_strings.h"
#include "ui/base/l10n/l10n_util.h"
@@ -82,17 +84,21 @@ scoped_ptr<PrefService> CefBrowserPrefStore::CreateService() {
new CommandLinePrefStore(command_line));
factory.set_user_prefs(this);
scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple());
scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
new user_prefs::PrefRegistrySyncable());
// Default settings.
CefMediaCaptureDevicesDispatcher::RegisterPrefs(registry.get());
PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get());
extensions::ExtensionPrefs::RegisterProfilePrefs(registry.get());
// Print settings.
registry->RegisterBooleanPref(prefs::kPrintingEnabled, true);
// Spell checking settings.
// Based on SpellcheckServiceFactory::RegisterProfilePrefs.
registry->RegisterListPref(prefs::kSpellCheckDictionaries,
new base::ListValue);
std::string spellcheck_lang =
command_line->GetSwitchValueASCII(switches::kOverrideSpellCheckLang);
if (!spellcheck_lang.empty()) {
@@ -116,6 +122,11 @@ scoped_ptr<PrefService> CefBrowserPrefStore::CreateService() {
registry->RegisterBooleanPref(prefs::kEnableDRM, false);
registry->RegisterStringPref(prefs::kDRMSalt, "");
// Plugin settings.
// Based on chrome::RegisterBrowserUserPrefs.
registry->RegisterBooleanPref(prefs::kPluginsAllowOutdated, false);
registry->RegisterBooleanPref(prefs::kPluginsAlwaysAuthorize, false);
return factory.Create(registry.get());
}

View File

@@ -58,9 +58,9 @@ class NET_EXPORT CefURLFetcherResponseWriter :
public:
CefURLFetcherResponseWriter(
CefRefPtr<CefBrowserURLRequest> url_request,
scoped_refptr<base::MessageLoopProxy> message_loop_proxy)
scoped_refptr<base::SequencedTaskRunner> task_runner)
: url_request_(url_request),
message_loop_proxy_(message_loop_proxy) {
task_runner_(task_runner) {
}
// net::URLFetcherResponseWriter methods.
@@ -72,11 +72,11 @@ class NET_EXPORT CefURLFetcherResponseWriter :
int num_bytes,
const net::CompletionCallback& callback) override {
if (url_request_.get()) {
message_loop_proxy_->PostTask(FROM_HERE,
task_runner_->PostTask(FROM_HERE,
base::Bind(&CefURLFetcherResponseWriter::WriteOnClientThread,
url_request_, scoped_refptr<net::IOBuffer>(buffer),
num_bytes, callback,
base::MessageLoop::current()->message_loop_proxy()));
base::MessageLoop::current()->task_runner()));
return net::ERR_IO_PENDING;
}
return num_bytes;
@@ -94,7 +94,7 @@ class NET_EXPORT CefURLFetcherResponseWriter :
scoped_refptr<net::IOBuffer> buffer,
int num_bytes,
const net::CompletionCallback& callback,
scoped_refptr<base::MessageLoopProxy> source_message_loop_proxy) {
scoped_refptr<base::SequencedTaskRunner> source_message_loop_proxy) {
CefRefPtr<CefURLRequestClient> client = url_request->GetClient();
if (client.get())
client->OnDownloadData(url_request.get(), buffer->data(), num_bytes);
@@ -111,7 +111,7 @@ class NET_EXPORT CefURLFetcherResponseWriter :
}
CefRefPtr<CefBrowserURLRequest> url_request_;
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
scoped_refptr<base::SequencedTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(CefURLFetcherResponseWriter);
};
@@ -137,7 +137,7 @@ class CefBrowserURLRequest::Context
request_(request),
client_(client),
request_context_(request_context),
message_loop_proxy_(base::MessageLoop::current()->message_loop_proxy()),
task_runner_(base::MessageLoop::current()->task_runner()),
status_(UR_IO_PENDING),
error_code_(ERR_NONE),
upload_data_size_(0),
@@ -147,7 +147,7 @@ class CefBrowserURLRequest::Context
}
inline bool CalledOnValidThread() {
return message_loop_proxy_->BelongsToCurrentThread();
return task_runner_->RunsTasksOnCurrentThread();
}
bool Start() {
@@ -160,14 +160,14 @@ class CefBrowserURLRequest::Context
std::string method = request_->GetMethod();
base::StringToLowerASCII(&method);
net::URLFetcher::RequestType request_type = net::URLFetcher::GET;
if (LowerCaseEqualsASCII(method, "get")) {
} else if (LowerCaseEqualsASCII(method, "post")) {
if (base::LowerCaseEqualsASCII(method, "get")) {
} else if (base::LowerCaseEqualsASCII(method, "post")) {
request_type = net::URLFetcher::POST;
} else if (LowerCaseEqualsASCII(method, "head")) {
} else if (base::LowerCaseEqualsASCII(method, "head")) {
request_type = net::URLFetcher::HEAD;
} else if (LowerCaseEqualsASCII(method, "delete")) {
} else if (base::LowerCaseEqualsASCII(method, "delete")) {
request_type = net::URLFetcher::DELETE_REQUEST;
} else if (LowerCaseEqualsASCII(method, "put")) {
} else if (base::LowerCaseEqualsASCII(method, "put")) {
request_type = net::URLFetcher::PUT;
} else {
NOTREACHED() << "invalid request type";
@@ -211,8 +211,8 @@ class CefBrowserURLRequest::Context
fetcher_delegate_.reset(
new CefURLFetcherDelegate(this, request_->GetFlags()));
fetcher_.reset(net::URLFetcher::Create(url, request_type,
fetcher_delegate_.get()));
fetcher_ = net::URLFetcher::Create(url, request_type,
fetcher_delegate_.get());
DCHECK(url_request_getter_.get());
fetcher_->SetRequestContext(url_request_getter_.get());
@@ -324,7 +324,7 @@ class CefBrowserURLRequest::Context
response_writer.reset(new CefURLFetcherResponseWriter(NULL, NULL));
} else {
response_writer.reset(
new CefURLFetcherResponseWriter(url_request_, message_loop_proxy_));
new CefURLFetcherResponseWriter(url_request_, task_runner_));
}
fetcher_->SaveResponseWithWriter(response_writer.Pass());
@@ -429,7 +429,7 @@ class CefBrowserURLRequest::Context
~Context() {
if (fetcher_.get()) {
// Delete the fetcher object on the thread that created it.
message_loop_proxy_->DeleteSoon(FROM_HERE, fetcher_.release());
task_runner_->DeleteSoon(FROM_HERE, fetcher_.release());
}
}
@@ -463,7 +463,7 @@ class CefBrowserURLRequest::Context
CefRefPtr<CefRequest> request_;
CefRefPtr<CefURLRequestClient> client_;
CefRefPtr<CefRequestContext> request_context_;
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
scoped_refptr<base::SequencedTaskRunner> task_runner_;
scoped_ptr<net::URLFetcher> fetcher_;
scoped_ptr<CefURLFetcherDelegate> fetcher_delegate_;
CefURLRequest::Status status_;

View File

@@ -224,8 +224,7 @@ ChromeNetLog* ChromeBrowserProcessStub::net_log() {
component_updater::ComponentUpdateService*
ChromeBrowserProcessStub::component_updater() {
NOTIMPLEMENTED();
return NULL;
return CefContext::Get()->component_updater();
}
CRLSetFetcher* ChromeBrowserProcessStub::crl_set_fetcher() {
@@ -273,3 +272,14 @@ gcm::GCMDriver* ChromeBrowserProcessStub::gcm_driver() {
NOTIMPLEMENTED();
return NULL;
}
memory::OomPriorityManager* ChromeBrowserProcessStub::GetOomPriorityManager() {
NOTIMPLEMENTED();
return NULL;
}
ShellIntegration::DefaultWebClientState
ChromeBrowserProcessStub::CachedDefaultWebClientState() {
NOTIMPLEMENTED();
return ShellIntegration::UNKNOWN_DEFAULT;
}

View File

@@ -96,6 +96,9 @@ class ChromeBrowserProcessStub : public BrowserProcess {
#endif
network_time::NetworkTimeTracker* network_time_tracker() override;
gcm::GCMDriver* gcm_driver() override;
memory::OomPriorityManager* GetOomPriorityManager() override;
ShellIntegration::DefaultWebClientState
CachedDefaultWebClientState() override;
private:
std::string locale_;

View File

@@ -31,6 +31,9 @@
#include "grit/cef_resources.h"
#include "ipc/ipc_channel.h"
#include "net/url_request/url_request.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/resources/grit/webui_resources.h"
#include "ui/resources/grit/webui_resources_map.h"
#include "v8/include/v8.h"
namespace scheme {
@@ -41,12 +44,14 @@ namespace {
const char kChromeCreditsDomain[] = "credits";
const char kChromeLicenseDomain[] = "license";
const char kChromeResourcesDomain[] = "resources";
const char kChromeVersionDomain[] = "version";
enum ChromeDomain {
CHROME_UNKNOWN = 0,
CHROME_CREDITS,
CHROME_LICENSE,
CHROME_RESOURCES,
CHROME_VERSION,
};
@@ -57,6 +62,7 @@ ChromeDomain GetChromeDomain(const std::string& domain_name) {
} domains[] = {
{ kChromeCreditsDomain, CHROME_CREDITS },
{ kChromeLicenseDomain, CHROME_LICENSE },
{ kChromeResourcesDomain, CHROME_RESOURCES },
{ kChromeVersionDomain, CHROME_VERSION },
};
@@ -177,6 +183,48 @@ class TemplateParser {
std::string ident_end_;
};
// From content/browser/webui/shared_resources_data_source.cc.
using ResourcesMap = base::hash_map<std::string, int>;
// TODO(rkc): Once we have a separate source for apps, remove '*/apps/' aliases.
const char* kPathAliases[][2] = {
{"../../../third_party/polymer/v1_0/components-chromium/", "polymer/v1_0/"},
{"../../../third_party/web-animations-js/sources/",
"polymer/v1_0/web-animations-js/"},
{"../../views/resources/default_100_percent/common/", "images/apps/"},
{"../../views/resources/default_200_percent/common/", "images/2x/apps/"},
{"../../webui/resources/cr_elements/", "cr_elements/"}};
void AddResource(const std::string& path,
int resource_id,
ResourcesMap* resources_map) {
if (!resources_map->insert(std::make_pair(path, resource_id)).second)
NOTREACHED() << "Redefinition of '" << path << "'";
}
const ResourcesMap* CreateResourcesMap() {
ResourcesMap* result = new ResourcesMap();
for (size_t i = 0; i < kWebuiResourcesSize; ++i) {
const std::string resource_name = kWebuiResources[i].name;
const int resource_id = kWebuiResources[i].value;
AddResource(resource_name, resource_id, result);
for (const char* (&alias)[2]: kPathAliases) {
if (base::StartsWithASCII(resource_name, alias[0], true)) {
AddResource(alias[1] + resource_name.substr(strlen(alias[0])),
resource_id, result);
}
}
}
return result;
}
const ResourcesMap& GetResourcesMap() {
// This pointer will be intentionally leaked on shutdown.
static const ResourcesMap* resources_map = CreateResourcesMap();
return *resources_map;
}
class Delegate : public InternalHandlerDelegate {
public:
Delegate() {}
@@ -199,6 +247,9 @@ class Delegate : public InternalHandlerDelegate {
case CHROME_LICENSE:
handled = OnLicense(action);
break;
case CHROME_RESOURCES:
handled = OnResources(path, action);
break;
case CHROME_VERSION:
handled = OnVersion(browser, action);
break;
@@ -209,11 +260,15 @@ class Delegate : public InternalHandlerDelegate {
if (!handled && domain != CHROME_VERSION) {
LOG(INFO) << "Reguest for unknown chrome resource: " <<
url.spec().c_str();
action->redirect_url =
GURL(std::string(kChromeURL) + kChromeVersionDomain);
if (domain != CHROME_RESOURCES) {
action->redirect_url =
GURL(std::string(kChromeURL) + kChromeVersionDomain);
return true;
}
}
return true;
return handled;
}
bool OnCredits(const std::string& path, Action* action) {
@@ -245,6 +300,31 @@ class Delegate : public InternalHandlerDelegate {
return true;
}
bool OnResources(const std::string& path, Action* action) {
// Implementation based on SharedResourcesDataSource::StartDataRequest.
const ResourcesMap& resources_map = GetResourcesMap();
auto it = resources_map.find(path);
int resource_id = (it != resources_map.end()) ? it->second : -1;
if (resource_id == -1) {
NOTREACHED() << "Failed to find resource id for " << path;
return false;
}
if (resource_id == IDR_WEBUI_CSS_TEXT_DEFAULTS) {
const std::string& css = webui::GetWebUiCssTextDefaults();
DCHECK(!css.empty());
action->mime_type = "text/css";
action->stream = CefStreamReader::CreateForData(
const_cast<char*>(css.c_str()), css.length());
action->stream_size = css.length();
} else {
action->resource_id = resource_id;
}
return true;
}
bool OnVersion(CefRefPtr<CefBrowser> browser,
Action* action) {
base::StringPiece piece = CefContentClient::Get()->GetDataResource(
@@ -273,8 +353,8 @@ class Delegate : public InternalHandlerDelegate {
parser.Add("USERAGENT", CefContentClient::Get()->GetUserAgent());
parser.Add("COMMANDLINE", GetCommandLine());
parser.Add("MODULEPATH", GetModulePath());
parser.Add("CACHEPATH",
browser->GetHost()->GetRequestContext()->GetCachePath());
parser.Add("CACHEPATH", browser.get() ?
browser->GetHost()->GetRequestContext()->GetCachePath() : "");
std::string tmpl = piece.as_string();
parser.Parse(&tmpl);

View File

@@ -0,0 +1,307 @@
// 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/component_updater/component_updater_url_constants.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/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());
}
// Returns true if falling back on an alternate, unsafe, service URL is
// allowed. In the fallback case, the security of the component update relies
// only on the integrity of the CRX payloads, which is self-validating.
// This is allowed only for some of the pre-Windows Vista versions not including
// Windows XP SP3. As a side note, pings could be sent to the alternate URL too.
bool CanUseAltUrlSource() {
#if defined(OS_WIN)
return !base::win::MaybeHasSHA256Support();
#else
return false;
#endif // OS_WIN
}
// 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);
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 GetLang() const override;
std::string GetOSLongName() const override;
std::string ExtraRequestParams() const override;
net::URLRequestContextGetter* RequestContext() const override;
scoped_refptr<update_client::OutOfProcessPatcher>
CreateOutOfProcessPatcher() const override;
bool DeltasEnabled() const override;
bool UseBackgroundDownloader() const override;
scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
const override;
scoped_refptr<base::SingleThreadTaskRunner> GetSingleThreadTaskRunner()
const override;
private:
friend class base::RefCountedThreadSafe<CefConfigurator>;
~CefConfigurator() override {}
net::URLRequestContextGetter* url_request_getter_;
std::string extra_info_;
GURL url_source_override_;
bool fast_update_;
bool pings_enabled_;
bool deltas_enabled_;
bool background_downloads_enabled_;
bool fallback_to_alt_source_url_enabled_;
};
CefConfigurator::CefConfigurator(
const base::CommandLine* cmdline,
net::URLRequestContextGetter* url_request_getter)
: url_request_getter_(url_request_getter),
fast_update_(false),
pings_enabled_(false),
deltas_enabled_(false),
background_downloads_enabled_(false),
fallback_to_alt_source_url_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\"";
fallback_to_alt_source_url_enabled_ = CanUseAltUrlSource();
}
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));
if (fallback_to_alt_source_url_enabled_) {
urls.push_back(GURL(kUpdaterAltUrl));
}
}
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::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_;
}
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_;
}
scoped_refptr<base::SequencedTaskRunner>
CefConfigurator::GetSequencedTaskRunner() const {
return content::BrowserThread::GetBlockingPool()
->GetSequencedTaskRunnerWithShutdownBehavior(
content::BrowserThread::GetBlockingPool()->GetSequenceToken(),
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
}
scoped_refptr<base::SingleThreadTaskRunner>
CefConfigurator::GetSingleThreadTaskRunner() const {
return content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE);
}
} // namespace
scoped_refptr<update_client::Configurator>
MakeCefComponentUpdaterConfigurator(
const base::CommandLine* cmdline,
net::URLRequestContextGetter* context_getter) {
return new CefConfigurator(cmdline, context_getter);
}
} // namespace component_updater

View File

@@ -0,0 +1,28 @@
// 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;
}
namespace component_updater {
scoped_refptr<update_client::Configurator>
MakeCefComponentUpdaterConfigurator(
const base::CommandLine* cmdline,
net::URLRequestContextGetter* context_getter);
} // namespace component_updater
#endif // LIBCEF_BROWSER_COMPONENT_UPDATER_CEF_COMPONENT_UPDATER_CONFIGURATOR_H_

View File

@@ -0,0 +1,392 @@
// Copyright (c) 2013 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.
// TODO(dberger): This file is nearly identical to
// chrome/browser/component_updater/widevine_cdm_component_installer.cc,
// the only real difference being how we compute the browser version in
// UpdateCDMAdapter.
#include "libcef/browser/component_updater/widevine_cdm_component_installer.h"
#include "include/cef_version.h"
#include <stdint.h>
#include <string.h>
#include <string>
#include <vector>
#include "base/base_paths.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/path_service.h"
#include "base/strings/string16.h"
#include "base/strings/stringprintf.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/widevine_cdm_constants.h"
#include "components/component_updater/component_updater_service.h"
#include "components/component_updater/default_component_installer.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/common/pepper_plugin_info.h"
#include "media/cdm/ppapi/supported_cdm_versions.h"
#include "third_party/widevine/cdm/widevine_cdm_common.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT
using content::BrowserThread;
using content::PluginService;
namespace component_updater {
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
namespace {
// CRX hash. The extension id is: oimompecagnajdejgnnjijobebaeigek.
const uint8_t kSha2Hash[] = {0xe8, 0xce, 0xcf, 0x42, 0x06, 0xd0, 0x93, 0x49,
0x6d, 0xd9, 0x89, 0xe1, 0x41, 0x04, 0x86, 0x4a,
0x8f, 0xbd, 0x86, 0x12, 0xb9, 0x58, 0x9b, 0xfb,
0x4f, 0xbb, 0x1b, 0xa9, 0xd3, 0x85, 0x37, 0xef};
// File name of the Widevine CDM component manifest on different platforms.
const char kWidevineCdmManifestName[] = "WidevineCdm";
// File name of the Widevine CDM adapter version file. The CDM adapter shares
// the same version number with Chromium version.
const char kCdmAdapterVersionName[] = "CdmAdapterVersion";
// Name of the Widevine CDM OS in the component manifest.
const char kWidevineCdmPlatform[] =
#if defined(OS_MACOSX)
"mac";
#elif defined(OS_WIN)
"win";
#else // OS_LINUX, etc. TODO(viettrungluu): Separate out Chrome OS and Android?
"linux";
#endif
// Name of the Widevine CDM architecture in the component manifest.
const char kWidevineCdmArch[] =
#if defined(ARCH_CPU_X86)
"x86";
#elif defined(ARCH_CPU_X86_64)
"x64";
#else // TODO(viettrungluu): Support an ARM check?
"???";
#endif
// The CDM manifest includes several custom values, all beginning with "x-cdm-".
// All values are strings.
// All values that are lists are delimited by commas. No trailing commas.
// For example, "1,2,4".
const char kCdmValueDelimiter = ',';
static_assert(kCdmValueDelimiter == kCdmSupportedCodecsValueDelimiter,
"cdm delimiters must match");
// The following entries are required.
// Interface versions are lists of integers (e.g. "1" or "1,2,4").
// These are checked in this file before registering the CDM.
// All match the interface versions from content_decryption_module.h that the
// CDM supports.
// Matches CDM_MODULE_VERSION.
const char kCdmModuleVersionsName[] = "x-cdm-module-versions";
// Matches supported ContentDecryptionModule_* version(s).
const char kCdmInterfaceVersionsName[] = "x-cdm-interface-versions";
// Matches supported Host_* version(s).
const char kCdmHostVersionsName[] = "x-cdm-host-versions";
// The codecs list is a list of simple codec names (e.g. "vp8,vorbis").
// The list is passed to other parts of Chrome.
const char kCdmCodecsListName[] = "x-cdm-codecs";
// Widevine CDM is packaged as a multi-CRX. Widevine CDM binaries are located in
// _platform_specific/<platform_arch> folder in the package. This function
// returns the platform-specific subdirectory that is part of that multi-CRX.
base::FilePath GetPlatformDirectory(const base::FilePath& base_path) {
std::string platform_arch = kWidevineCdmPlatform;
platform_arch += '_';
platform_arch += kWidevineCdmArch;
return base_path.AppendASCII("_platform_specific").AppendASCII(platform_arch);
}
bool MakeWidevineCdmPluginInfo(
const base::Version& version,
const base::FilePath& path,
const std::vector<base::string16>& additional_param_names,
const std::vector<base::string16>& additional_param_values,
content::PepperPluginInfo* plugin_info) {
if (!version.IsValid() ||
version.components().size() !=
static_cast<size_t>(kWidevineCdmVersionNumComponents)) {
return false;
}
plugin_info->is_internal = false;
// Widevine CDM must run out of process.
plugin_info->is_out_of_process = true;
plugin_info->path = path;
plugin_info->name = kWidevineCdmDisplayName;
plugin_info->description = kWidevineCdmDescription +
std::string(" (version: ") + version.GetString() +
")";
plugin_info->version = version.GetString();
content::WebPluginMimeType widevine_cdm_mime_type(
kWidevineCdmPluginMimeType,
kWidevineCdmPluginExtension,
kWidevineCdmPluginMimeTypeDescription);
widevine_cdm_mime_type.additional_param_names = additional_param_names;
widevine_cdm_mime_type.additional_param_values = additional_param_values;
plugin_info->mime_types.push_back(widevine_cdm_mime_type);
plugin_info->permissions = kWidevineCdmPluginPermissions;
return true;
}
typedef bool (*VersionCheckFunc)(int version);
bool CheckForCompatibleVersion(const base::DictionaryValue& manifest,
const std::string version_name,
VersionCheckFunc version_check_func) {
std::string versions_string;
if (!manifest.GetString(version_name, &versions_string)) {
DLOG(WARNING) << "Widevine CDM component manifest missing " << version_name;
return false;
}
DLOG_IF(WARNING, versions_string.empty())
<< "Widevine CDM component manifest has empty " << version_name;
std::vector<std::string> versions;
base::SplitString(versions_string, kCdmValueDelimiter, &versions);
for (size_t i = 0; i < versions.size(); ++i) {
int version = 0;
if (base::StringToInt(versions[i], &version))
if (version_check_func(version))
return true;
}
DLOG(WARNING) << "Widevine CDM component manifest has no supported "
<< version_name << " in '" << versions_string << "'";
return false;
}
// Returns whether the CDM's API versions, as specified in the manifest, are
// compatible with this Chrome binary.
// Checks the module API, CDM interface API, and Host API.
// This should never fail except in rare cases where the component has not been
// updated recently or the user downgrades Chrome.
bool IsCompatibleWithChrome(const base::DictionaryValue& manifest) {
return CheckForCompatibleVersion(manifest,
kCdmModuleVersionsName,
media::IsSupportedCdmModuleVersion) &&
CheckForCompatibleVersion(manifest,
kCdmInterfaceVersionsName,
media::IsSupportedCdmInterfaceVersion) &&
CheckForCompatibleVersion(manifest,
kCdmHostVersionsName,
media::IsSupportedCdmHostVersion);
}
void GetAdditionalParams(const base::DictionaryValue& manifest,
std::vector<base::string16>* additional_param_names,
std::vector<base::string16>* additional_param_values) {
base::string16 codecs;
if (manifest.GetString(kCdmCodecsListName, &codecs)) {
DLOG_IF(WARNING, codecs.empty())
<< "Widevine CDM component manifest has empty codecs list";
additional_param_names->push_back(
base::ASCIIToUTF16(kCdmSupportedCodecsParamName));
additional_param_values->push_back(codecs);
} else {
DLOG(WARNING) << "Widevine CDM component manifest is missing codecs";
}
}
void RegisterWidevineCdmWithChrome(const base::Version& cdm_version,
const base::FilePath& adapter_install_path,
scoped_ptr<base::DictionaryValue> manifest) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::vector<base::string16> additional_param_names;
std::vector<base::string16> additional_param_values;
GetAdditionalParams(
*manifest, &additional_param_names, &additional_param_values);
content::PepperPluginInfo plugin_info;
if (!MakeWidevineCdmPluginInfo(cdm_version,
adapter_install_path,
additional_param_names,
additional_param_values,
&plugin_info)) {
return;
}
// true = Add to beginning of list to override any existing registrations.
PluginService::GetInstance()->RegisterInternalPlugin(
plugin_info.ToWebPluginInfo(), true);
// Tell the browser to refresh the plugin list. Then tell all renderers to
// update their plugin list caches.
PluginService::GetInstance()->RefreshPlugins();
PluginService::GetInstance()->PurgePluginListCache(NULL, false);
}
} // namespace
class WidevineCdmComponentInstallerTraits : public ComponentInstallerTraits {
public:
WidevineCdmComponentInstallerTraits();
~WidevineCdmComponentInstallerTraits() override {}
private:
// The following methods override ComponentInstallerTraits.
bool CanAutoUpdate() const override;
bool OnCustomInstall(const base::DictionaryValue& manifest,
const base::FilePath& install_dir) override;
bool VerifyInstallation(
const base::DictionaryValue& manifest,
const base::FilePath& install_dir) const override;
void ComponentReady(
const base::Version& version,
const base::FilePath& path,
scoped_ptr<base::DictionaryValue> manifest) override;
base::FilePath GetBaseDirectory() const override;
void GetHash(std::vector<uint8_t>* hash) const override;
std::string GetName() const override;
// Checks and updates CDM adapter if necessary to make sure the latest CDM
// adapter is always used.
// Note: The component is ready when CDM is present, but the CDM won't be
// registered until the adapter is copied by this function (see
// VerifyInstallation).
void UpdateCdmAdapter(const base::Version& cdm_version,
const base::FilePath& cdm_install_dir,
scoped_ptr<base::DictionaryValue> manifest);
DISALLOW_COPY_AND_ASSIGN(WidevineCdmComponentInstallerTraits);
};
WidevineCdmComponentInstallerTraits::WidevineCdmComponentInstallerTraits() {
}
bool WidevineCdmComponentInstallerTraits::CanAutoUpdate() const {
return true;
}
bool WidevineCdmComponentInstallerTraits::OnCustomInstall(
const base::DictionaryValue& manifest,
const base::FilePath& install_dir) {
return true;
}
// Once the CDM is ready, check the CDM adapter.
void WidevineCdmComponentInstallerTraits::ComponentReady(
const base::Version& version,
const base::FilePath& path,
scoped_ptr<base::DictionaryValue> manifest) {
if (!IsCompatibleWithChrome(*manifest)) {
DLOG(WARNING) << "Installed Widevine CDM component is incompatible.";
return;
}
BrowserThread::PostBlockingPoolTask(
FROM_HERE,
base::Bind(&WidevineCdmComponentInstallerTraits::UpdateCdmAdapter,
base::Unretained(this),
version,
path,
base::Passed(&manifest)));
}
bool WidevineCdmComponentInstallerTraits::VerifyInstallation(
const base::DictionaryValue& manifest,
const base::FilePath& install_dir) const {
return IsCompatibleWithChrome(manifest) &&
base::PathExists(GetPlatformDirectory(install_dir)
.AppendASCII(kWidevineCdmFileName));
}
// The base directory on Windows looks like:
// <profile>\AppData\Local\Google\Chrome\User Data\WidevineCdm\.
base::FilePath WidevineCdmComponentInstallerTraits::GetBaseDirectory() const {
base::FilePath result;
PathService::Get(chrome::DIR_COMPONENT_WIDEVINE_CDM, &result);
return result;
}
void WidevineCdmComponentInstallerTraits::GetHash(
std::vector<uint8_t>* hash) const {
hash->assign(kSha2Hash, kSha2Hash + arraysize(kSha2Hash));
}
std::string WidevineCdmComponentInstallerTraits::GetName() const {
return kWidevineCdmManifestName;
}
void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter(
const base::Version& cdm_version,
const base::FilePath& cdm_install_dir,
scoped_ptr<base::DictionaryValue> manifest) {
const base::FilePath adapter_version_path =
GetPlatformDirectory(cdm_install_dir).AppendASCII(kCdmAdapterVersionName);
const base::FilePath adapter_install_path =
GetPlatformDirectory(cdm_install_dir)
.AppendASCII(kWidevineCdmAdapterFileName);
const std::string chrome_version = base::StringPrintf("%d.%d.%d.%d",
CHROME_VERSION_MAJOR,
CHROME_VERSION_MINOR,
CHROME_VERSION_BUILD,
CHROME_VERSION_PATCH);
DCHECK(!chrome_version.empty());
std::string adapter_version;
if (!base::ReadFileToString(adapter_version_path, &adapter_version) ||
adapter_version != chrome_version ||
!base::PathExists(adapter_install_path)) {
int bytes_written = base::WriteFile(
adapter_version_path, chrome_version.data(), chrome_version.size());
if (bytes_written < 0 ||
static_cast<size_t>(bytes_written) != chrome_version.size()) {
DLOG(WARNING) << "Failed to write Widevine CDM adapter version file.";
// Ignore version file writing failure and try to copy the CDM adapter.
}
base::FilePath adapter_source_path;
PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path);
if (!base::CopyFile(adapter_source_path, adapter_install_path)) {
DLOG(WARNING) << "Failed to copy Widevine CDM adapter.";
return;
}
}
BrowserThread::PostTask(content::BrowserThread::UI,
FROM_HERE,
base::Bind(&RegisterWidevineCdmWithChrome,
cdm_version,
adapter_install_path,
base::Passed(&manifest)));
}
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
void RegisterWidevineCdmComponent(ComponentUpdateService* cus) {
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
base::FilePath adapter_source_path;
PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path);
if (!base::PathExists(adapter_source_path))
return;
scoped_ptr<ComponentInstallerTraits> traits(
new WidevineCdmComponentInstallerTraits);
// |cus| will take ownership of |installer| during installer->Register(cus).
DefaultComponentInstaller* installer =
new DefaultComponentInstaller(traits.Pass());
installer->Register(cus, base::Closure());
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
}
} // namespace component_updater

View File

@@ -0,0 +1,23 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_COMPONENT_UPDATER_WIDEVINE_CDM_COMPONENT_INSTALLER_H_
#define CEF_LIBCEF_COMPONENT_UPDATER_WIDEVINE_CDM_COMPONENT_INSTALLER_H_
namespace component_updater {
class ComponentUpdateService;
// Our job is to:
// 1) Find what Widevine CDM is installed (if any).
// 2) Register with the component updater to download the latest version when
// available.
// 3) Copy the Widevine CDM adapter bundled with chrome to the install path.
// 4) Register the Widevine CDM (via the adapter) with Chrome.
// The first part is IO intensive so we do it asynchronously in the file thread.
void RegisterWidevineCdmComponent(ComponentUpdateService* cus);
} // namespace component_updater
#endif // CEF_LIBCEF_COMPONENT_UPDATER_WIDEVINE_CDM_COMPONENT_INSTALLER_H_

View File

@@ -14,17 +14,22 @@
#include "libcef/browser/chrome_scheme_handler.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools_delegate.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/pepper/browser_pepper_host_factory.h"
#include "libcef/browser/plugins/plugin_info_message_filter.h"
#include "libcef/browser/plugins/plugin_service_filter.h"
#include "libcef/browser/printing/printing_message_filter.h"
#include "libcef/browser/resource_dispatcher_host_delegate.h"
#include "libcef/browser/speech_recognition_manager_delegate.h"
#include "libcef/browser/ssl_info_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/web_plugin_impl.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/command_line_impl.h"
#include "libcef/common/content_client.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/scheme_registration.h"
#include "base/base_switches.h"
@@ -35,19 +40,27 @@
#include "chrome/common/chrome_switches.h"
#include "content/browser/plugin_service_impl.h"
#include "content/public/browser/access_token_store.h"
#include "content/public/browser/browser_ppapi_host.h"
#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/plugin_service_filter.h"
#include "content/public/browser/quota_permission_context.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/storage_quota_params.h"
#include "content/public/common/web_preferences.h"
#include "gin/public/isolate_holder.h"
#include "extensions/browser/extension_message_filter.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
#include "extensions/browser/io_thread_extension_message_filter.h"
#include "extensions/common/constants.h"
#include "extensions/common/switches.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "ppapi/host/ppapi_host.h"
#include "third_party/WebKit/public/web/WebWindowFeatures.h"
#include "ui/base/ui_base_switches.h"
#include "url/gurl.h"
@@ -63,6 +76,10 @@
#include "content/public/common/content_descriptors.h"
#endif
#if defined(OS_WIN)
#include "sandbox/win/src/sandbox_policy.h"
#endif
namespace {
// In-memory store for access tokens used by geolocation.
@@ -251,48 +268,6 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext {
DISALLOW_COPY_AND_ASSIGN(CefQuotaPermissionContext);
};
class CefPluginServiceFilter : public content::PluginServiceFilter {
public:
CefPluginServiceFilter() {}
bool IsPluginAvailable(int render_process_id,
int render_frame_id,
const void* context,
const GURL& url,
const GURL& policy_url,
content::WebPluginInfo* plugin) override {
bool allowed = true;
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForFrame(render_process_id,
render_frame_id);
if (browser.get()) {
CefRefPtr<CefClient> client = browser->GetClient();
if (client.get()) {
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
if (handler.get()) {
CefRefPtr<CefWebPluginInfoImpl> pluginInfo(
new CefWebPluginInfoImpl(*plugin));
allowed =
!handler->OnBeforePluginLoad(browser.get(),
url.possibly_invalid_spec(),
policy_url.possibly_invalid_spec(),
pluginInfo.get());
}
}
}
return allowed;
}
bool CanLoadPlugin(int render_process_id,
const base::FilePath& path) override {
return true;
}
DISALLOW_COPY_AND_ASSIGN(CefPluginServiceFilter);
};
void TranslatePopupFeatures(const blink::WebWindowFeatures& webKitFeatures,
CefPopupFeatures& features) {
features.x = static_cast<int>(webKitFeatures.x);
@@ -344,6 +319,14 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
if (!breakpad::IsCrashReporterEnabled())
return -1;
// Extensions have the same process type as renderers.
if (command_line.HasSwitch(extensions::switches::kExtensionProcess)) {
static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
if (!crash_handler)
crash_handler = CreateCrashHandlerHost("extension");
return crash_handler->GetDeathSignalSocket();
}
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
@@ -384,10 +367,6 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
CefContentBrowserClient::CefContentBrowserClient()
: browser_main_parts_(NULL),
#if defined(OS_POSIX) && !defined(OS_MACOSX)
v8_natives_fd_(-1),
v8_snapshot_fd_(-1),
#endif // OS_POSIX && !OS_MACOSX
next_browser_id_(0) {
plugin_service_filter_.reset(new CefPluginServiceFilter);
content::PluginServiceImpl::GetInstance()->SetFilter(
@@ -420,24 +399,37 @@ scoped_refptr<CefBrowserInfo>
int render_view_process_id,
int render_view_routing_id,
int render_frame_process_id,
int render_frame_routing_id) {
int render_frame_routing_id,
bool* is_guest_view) {
base::AutoLock lock_scope(browser_info_lock_);
if (is_guest_view)
*is_guest_view = false;
BrowserInfoList::const_iterator it = browser_info_list_.begin();
for (; it != browser_info_list_.end(); ++it) {
const scoped_refptr<CefBrowserInfo>& browser_info = *it;
if (browser_info->is_render_view_id_match(render_view_process_id,
render_view_routing_id)) {
if (browser_info->render_id_manager()->is_render_view_id_match(
render_view_process_id, render_view_routing_id)) {
// Make sure the frame id is also registered.
browser_info->add_render_frame_id(render_frame_process_id,
render_frame_routing_id);
browser_info->render_id_manager()->add_render_frame_id(
render_frame_process_id, render_frame_routing_id);
return browser_info;
} else if (browser_info->is_render_frame_id_match(
render_frame_process_id,
render_frame_routing_id)) {
}
if (browser_info->render_id_manager()->is_render_frame_id_match(
render_frame_process_id, render_frame_routing_id)) {
// Make sure the view id is also registered.
browser_info->add_render_view_id(render_view_process_id,
render_view_routing_id);
browser_info->render_id_manager()->add_render_view_id(
render_view_process_id, render_view_routing_id);
return browser_info;
}
if (extensions::ExtensionsEnabled() &&
(browser_info->guest_render_id_manager()->is_render_view_id_match(
render_view_process_id, render_view_routing_id) ||
browser_info->guest_render_id_manager()->is_render_frame_id_match(
render_frame_process_id, render_frame_routing_id))) {
if (is_guest_view)
*is_guest_view = true;
return browser_info;
}
}
@@ -445,10 +437,10 @@ scoped_refptr<CefBrowserInfo>
// Must be a popup if it hasn't already been created.
scoped_refptr<CefBrowserInfo> browser_info =
new CefBrowserInfo(++next_browser_id_, true);
browser_info->add_render_view_id(render_view_process_id,
render_view_routing_id);
browser_info->add_render_frame_id(render_frame_process_id,
render_frame_routing_id);
browser_info->render_id_manager()->add_render_view_id(
render_view_process_id, render_view_routing_id);
browser_info->render_id_manager()->add_render_frame_id(
render_frame_process_id, render_frame_routing_id);
browser_info_list_.push_back(browser_info);
return browser_info;
}
@@ -503,16 +495,28 @@ void CefContentBrowserClient::DestroyAllBrowsers() {
}
scoped_refptr<CefBrowserInfo> CefContentBrowserClient::GetBrowserInfoForView(
int render_process_id, int render_routing_id) {
int render_process_id,
int render_routing_id,
bool* is_guest_view) {
base::AutoLock lock_scope(browser_info_lock_);
if (is_guest_view)
*is_guest_view = false;
BrowserInfoList::const_iterator it = browser_info_list_.begin();
for (; it != browser_info_list_.end(); ++it) {
const scoped_refptr<CefBrowserInfo>& browser_info = *it;
if (browser_info->is_render_view_id_match(
if (browser_info->render_id_manager()->is_render_view_id_match(
render_process_id, render_routing_id)) {
return browser_info;
}
if (extensions::ExtensionsEnabled() &&
browser_info->guest_render_id_manager()->is_render_view_id_match(
render_process_id, render_routing_id)) {
if (is_guest_view)
*is_guest_view = true;
return browser_info;
}
}
LOG(WARNING) << "No browser info matching view process id " <<
@@ -522,14 +526,26 @@ scoped_refptr<CefBrowserInfo> CefContentBrowserClient::GetBrowserInfoForView(
}
scoped_refptr<CefBrowserInfo> CefContentBrowserClient::GetBrowserInfoForFrame(
int render_process_id, int render_routing_id) {
int render_process_id,
int render_routing_id,
bool* is_guest_view) {
base::AutoLock lock_scope(browser_info_lock_);
if (is_guest_view)
*is_guest_view = false;
BrowserInfoList::const_iterator it = browser_info_list_.begin();
for (; it != browser_info_list_.end(); ++it) {
const scoped_refptr<CefBrowserInfo>& browser_info = *it;
if (browser_info->is_render_frame_id_match(
render_process_id, render_routing_id)) {
if (browser_info->render_id_manager()->is_render_frame_id_match(
render_process_id, render_routing_id)) {
return browser_info;
}
if (extensions::ExtensionsEnabled() &&
browser_info->guest_render_id_manager()->is_render_frame_id_match(
render_process_id, render_routing_id)) {
if (is_guest_view)
*is_guest_view = true;
return browser_info;
}
}
@@ -561,6 +577,50 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
host->AddFilter(new SpellCheckMessageFilterMac(id));
#endif
}
content::BrowserContext* browser_context = host->GetBrowserContext();
host->AddFilter(new CefPluginInfoMessageFilter(id,
static_cast<CefBrowserContext*>(browser_context)));
if (extensions::ExtensionsEnabled()) {
host->AddFilter(
new extensions::ExtensionMessageFilter(id, browser_context));
host->AddFilter(
new extensions::IOThreadExtensionMessageFilter(id, browser_context));
host->AddFilter(
new extensions::ExtensionsGuestViewMessageFilter(id, browser_context));
}
host->Send(new CefProcessMsg_SetIsIncognitoProcess(
browser_context->IsOffTheRecord()));
}
bool CefContentBrowserClient::ShouldUseProcessPerSite(
content::BrowserContext* browser_context,
const GURL& effective_url) {
if (!extensions::ExtensionsEnabled())
return false;
if (!effective_url.SchemeIs(extensions::kExtensionScheme))
return false;
extensions::ExtensionRegistry* registry =
extensions::ExtensionRegistry::Get(browser_context);
if (!registry)
return false;
const extensions::Extension* extension =
registry->enabled_extensions().GetByID(effective_url.host());
if (!extension)
return false;
// TODO(extensions): Extra checks required if type is TYPE_HOSTED_APP.
// Hosted apps that have script access to their background page must use
// process per site, since all instances can make synchronous calls to the
// background window. Other extensions should use process per site as well.
return true;
}
net::URLRequestContextGetter* CefContentBrowserClient::CreateRequestContext(
@@ -569,6 +629,19 @@ net::URLRequestContextGetter* CefContentBrowserClient::CreateRequestContext(
content::URLRequestInterceptorScopedVector request_interceptors) {
scoped_refptr<CefBrowserContext> context =
static_cast<CefBrowserContext*>(content_browser_context);
if (extensions::ExtensionsEnabled()) {
// Handle only chrome-extension:// requests. CEF does not support
// chrome-extension-resource:// requests (it does not store shared extension
// data in its installation directory).
extensions::InfoMap* extension_info_map =
context->extension_system()->info_map();
(*protocol_handlers)[extensions::kExtensionScheme] =
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
extensions::CreateExtensionProtocolHandler(
context->IsOffTheRecord(), extension_info_map));
}
return context->CreateRequestContext(
protocol_handlers,
request_interceptors.Pass());
@@ -635,6 +708,8 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
// any associated values) if present in the browser command line.
static const char* const kSwitchNames[] = {
switches::kContextSafetyImplementation,
switches::kDisableExtensions,
switches::kDisablePdfExtension,
switches::kDisableScrollBounce,
switches::kDisableSpellChecking,
switches::kEnableSpeechInput,
@@ -644,9 +719,25 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kPpapiFlashPath,
switches::kPpapiFlashVersion,
switches::kUncaughtExceptionStackSize,
switches::kWidevineCdmPath,
switches::kWidevineCdmVersion,
};
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
arraysize(kSwitchNames));
if (extensions::ExtensionsEnabled()) {
// Based on ChromeContentBrowserClientExtensionsPart::
// AppendExtraRendererCommandLineSwitches
content::RenderProcessHost* process =
content::RenderProcessHost::FromID(child_process_id);
content::BrowserContext* browser_context =
process ? process->GetBrowserContext() : NULL;
if (browser_context &&
extensions::ProcessMap::Get(browser_context)->Contains(
process->GetID())) {
command_line->AppendSwitch(extensions::switches::kExtensionProcess);
}
}
}
#if defined(OS_LINUX)
@@ -656,6 +747,8 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
static const char* const kSwitchNames[] = {
switches::kPpapiFlashPath,
switches::kPpapiFlashVersion,
switches::kWidevineCdmPath,
switches::kWidevineCdmVersion,
};
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
arraysize(kSwitchNames));
@@ -780,7 +873,8 @@ bool CefContentBrowserClient::CanCreateWindow(
bool opener_suppressed,
content::ResourceContext* context,
int render_process_id,
int opener_id,
int opener_render_view_id,
int opener_render_frame_id,
bool* no_javascript_access) {
CEF_REQUIRE_IOT();
*no_javascript_access = false;
@@ -789,13 +883,34 @@ bool CefContentBrowserClient::CanCreateWindow(
if (last_create_window_params_.opener_process_id == MSG_ROUTING_NONE)
return false;
bool is_guest_view = false;
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForView(
extensions::GetOwnerBrowserForView(
last_create_window_params_.opener_process_id,
last_create_window_params_.opener_view_id);
last_create_window_params_.opener_view_id,
&is_guest_view);
DCHECK(browser.get());
if (!browser.get()) {
LOG(WARNING) << "CanCreateWindow called before browser was created";
// Cancel the popup.
last_create_window_params_.opener_process_id = MSG_ROUTING_NONE;
return false;
}
if (is_guest_view) {
content::OpenURLParams params(target_url,
referrer,
disposition,
ui::PAGE_TRANSITION_LINK,
true);
params.user_gesture = user_gesture;
// Pass navigation to the owner browser.
CEF_POST_TASK(CEF_UIT,
base::Bind(base::IgnoreResult(&CefBrowserHostImpl::OpenURLFromTab),
browser.get(), nullptr, params));
// Cancel the popup.
last_create_window_params_.opener_process_id = MSG_ROUTING_NONE;
return false;
}
@@ -876,13 +991,13 @@ void CefContentBrowserClient::OverrideWebkitPrefs(
base::CommandLine::ForCurrentProcess();
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForHost(rvh);
DCHECK(browser.get());
extensions::GetOwnerBrowserForHost(rvh, NULL);
if (browser.get()) {
// Populate WebPreferences based on CefBrowserSettings.
BrowserToWebSettings(browser->settings(), *prefs);
}
// Populate WebPreferences based on CefBrowserSettings.
BrowserToWebSettings(browser->settings(), *prefs);
prefs->base_background_color = GetBaseBackgroundColor(rvh);
prefs->base_background_color = GetBaseBackgroundColor(browser);
if (rvh->GetView())
rvh->GetView()->SetBackgroundColor(prefs->base_background_color);
@@ -920,28 +1035,6 @@ void CefContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
const base::CommandLine& command_line,
int child_process_id,
content::FileDescriptorInfo* mappings) {
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
if (v8_snapshot_fd_.get() == -1 && v8_natives_fd_.get() == -1) {
base::FilePath v8_data_path;
PathService::Get(gin::IsolateHolder::kV8SnapshotBasePathKey, &v8_data_path);
DCHECK(!v8_data_path.empty());
int file_flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
base::FilePath v8_natives_data_path =
v8_data_path.AppendASCII(gin::IsolateHolder::kNativesFileName);
base::FilePath v8_snapshot_data_path =
v8_data_path.AppendASCII(gin::IsolateHolder::kSnapshotFileName);
base::File v8_natives_data_file(v8_natives_data_path, file_flags);
base::File v8_snapshot_data_file(v8_snapshot_data_path, file_flags);
DCHECK(v8_natives_data_file.IsValid());
DCHECK(v8_snapshot_data_file.IsValid());
v8_natives_fd_.reset(v8_natives_data_file.TakePlatformFile());
v8_snapshot_fd_.reset(v8_snapshot_data_file.TakePlatformFile());
}
mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
#endif // V8_USE_EXTERNAL_STARTUP_DATA
int crash_signal_fd = GetCrashSignalFD(command_line);
if (crash_signal_fd >= 0) {
mappings->Share(kCrashDumpSignal, crash_signal_fd);
@@ -966,6 +1059,20 @@ const wchar_t* CefContentBrowserClient::GetResourceDllName() {
return file_path;
}
void CefContentBrowserClient::PreSpawnRenderer(
sandbox::TargetPolicy* policy,
bool* success) {
// Flash requires this permission to play video files.
sandbox::ResultCode result = policy->AddRule(
sandbox::TargetPolicy::SUBSYS_HANDLES,
sandbox::TargetPolicy::HANDLES_DUP_ANY,
L"File");
if (result != sandbox::SBOX_ALL_OK) {
*success = false;
return;
}
}
#endif // defined(OS_WIN)
void CefContentBrowserClient::RegisterCustomScheme(const std::string& scheme) {
@@ -997,27 +1104,26 @@ PrefService* CefContentBrowserClient::pref_service() const {
return browser_main_parts_->pref_service();
}
// static
SkColor CefContentBrowserClient::GetBaseBackgroundColor(
content::RenderViewHost* rvh) {
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForHost(rvh);
DCHECK(browser.get());
const CefBrowserSettings& browser_settings = browser->settings();
if (CefColorGetA(browser_settings.background_color) > 0) {
return SkColorSetRGB(
CefColorGetR(browser_settings.background_color),
CefColorGetG(browser_settings.background_color),
CefColorGetB(browser_settings.background_color));
} else {
const CefSettings& settings = CefContext::Get()->settings();
if (CefColorGetA(settings.background_color) > 0) {
CefRefPtr<CefBrowserHostImpl> browser) {
if (browser.get()) {
const CefBrowserSettings& browser_settings = browser->settings();
if (CefColorGetA(browser_settings.background_color) > 0) {
return SkColorSetRGB(
CefColorGetR(settings.background_color),
CefColorGetG(settings.background_color),
CefColorGetB(settings.background_color));
CefColorGetR(browser_settings.background_color),
CefColorGetG(browser_settings.background_color),
CefColorGetB(browser_settings.background_color));
}
}
const CefSettings& settings = CefContext::Get()->settings();
if (CefColorGetA(settings.background_color) > 0) {
return SkColorSetRGB(
CefColorGetR(settings.background_color),
CefColorGetG(settings.background_color),
CefColorGetB(settings.background_color));
}
return SK_ColorWHITE;
}

View File

@@ -24,6 +24,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "url/gurl.h"
class CefBrowserHostImpl;
class CefBrowserInfo;
class CefBrowserMainParts;
class CefDevToolsDelegate;
@@ -50,29 +51,38 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
// to CefBrowserHostImpl::ShouldCreateWebContents on the UI thread. To resolve
// this race CefBrowserInfo may be created when requested for the first time
// and before the associated CefBrowserHostImpl is created.
// |is_guest_view| will be set to true if the IDs match a guest view
// associated with the returned browser info instead of the browser itself.
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(bool is_popup);
scoped_refptr<CefBrowserInfo> GetOrCreateBrowserInfo(
int render_view_process_id,
int render_view_routing_id,
int render_frame_process_id,
int render_frame_routing_id);
int render_frame_routing_id,
bool* is_guest_view);
void RemoveBrowserInfo(scoped_refptr<CefBrowserInfo> browser_info);
void DestroyAllBrowsers();
// Retrieves the CefBrowserInfo matching the specified IDs or an empty
// pointer if no match is found. It is allowed to add new callers of this
// method but consider using CefBrowserHostImpl::GetBrowserFor[View|Frame]()
// instead.
// or extensions::GetOwnerBrowserForView() instead.
// |is_guest_view| will be set to true if the IDs match a guest view
// associated with the returned browser info instead of the browser itself.
scoped_refptr<CefBrowserInfo> GetBrowserInfoForView(int render_process_id,
int render_routing_id);
int render_routing_id,
bool* is_guest_view);
scoped_refptr<CefBrowserInfo> GetBrowserInfoForFrame(int render_process_id,
int render_routing_id);
int render_routing_id,
bool* is_guest_view);
// ContentBrowserClient implementation.
content::BrowserMainParts* CreateBrowserMainParts(
const content::MainFunctionParams& parameters) override;
void RenderProcessWillLaunch(
content::RenderProcessHost* host) override;
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
const GURL& effective_url) override;
net::URLRequestContextGetter* CreateRequestContext(
content::BrowserContext* browser_context,
content::ProtocolHandlerMap* protocol_handlers,
@@ -122,7 +132,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
bool opener_suppressed,
content::ResourceContext* context,
int render_process_id,
int opener_id,
int opener_render_view_id,
int opener_render_frame_id,
bool* no_javascript_access) override;
void ResourceDispatcherHostCreated() override;
void OverrideWebkitPrefs(content::RenderViewHost* rvh,
@@ -143,6 +154,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
#if defined(OS_WIN)
const wchar_t* GetResourceDllName() override;
void PreSpawnRenderer(sandbox::TargetPolicy* policy, bool* success) override;
#endif
// Perform browser process registration for the custom scheme.
@@ -155,7 +167,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
int opener_view_id;
int64 opener_frame_id;
GURL target_url;
base::string16 target_frame_name;
std::string target_frame_name;
};
void set_last_create_window_params(const LastCreateWindowParams& params);
@@ -164,7 +176,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
PrefService* pref_service() const;
private:
SkColor GetBaseBackgroundColor(content::RenderViewHost* rvh);
static SkColor GetBaseBackgroundColor(CefRefPtr<CefBrowserHostImpl> browser);
CefBrowserMainParts* browser_main_parts_;
@@ -172,11 +184,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
scoped_ptr<CefResourceDispatcherHostDelegate>
resource_dispatcher_host_delegate_;
#if defined(OS_POSIX) && !defined(OS_MACOSX)
base::ScopedFD v8_natives_fd_;
base::ScopedFD v8_snapshot_fd_;
#endif
base::Lock browser_info_lock_;
// Access must be protected by |browser_info_lock_|.

View File

@@ -9,6 +9,8 @@
#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/component_updater/widevine_cdm_component_installer.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/trace_subscriber.h"
@@ -22,7 +24,10 @@
#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/printing/print_job_manager.h"
#include "components/component_updater/component_updater_service.h"
#include "components/update_client/configurator.h"
#include "content/public/app/content_main.h"
#include "content/public/app/content_main_runner.h"
#include "content/public/browser/notification_service.h"
@@ -330,6 +335,23 @@ CefTraceSubscriber* CefContext::GetTraceSubscriber() {
return trace_subscriber_.get();
}
component_updater::ComponentUpdateService*
CefContext::component_updater() {
if (!component_updater_.get()) {
CEF_REQUIRE_UIT_RETURN(NULL);
scoped_refptr<update_client::Configurator> configurator =
component_updater::MakeCefComponentUpdaterConfigurator(
base::CommandLine::ForCurrentProcess(),
CefContentBrowserClient::Get()->browser_context()->
request_context().get());
// 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 =
@@ -345,12 +367,31 @@ void CefContext::PopulateRequestContextSettings(
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);
// Notify the handler.
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
if (app.get()) {

View File

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

View File

@@ -133,3 +133,13 @@ CefContextMenuParamsImpl::EditStateFlags
CEF_VALUE_VERIFY_RETURN(false, CM_EDITFLAG_NONE);
return static_cast<EditStateFlags>(const_value().edit_flags);
}
bool CefContextMenuParamsImpl::IsCustomMenu() {
CEF_VALUE_VERIFY_RETURN(false, false);
return !const_value().custom_items.empty();
}
bool CefContextMenuParamsImpl::IsPepperMenu() {
CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().custom_context.is_pepper_menu;
}

View File

@@ -37,6 +37,8 @@ class CefContextMenuParamsImpl
bool IsEditable() override;
bool IsSpellCheckEnabled() override;
EditStateFlags GetEditStateFlags() override;
bool IsCustomMenu() override;
bool IsPepperMenu() override;
DISALLOW_COPY_AND_ASSIGN(CefContextMenuParamsImpl);
};

View File

@@ -18,9 +18,9 @@
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/threading/thread_restrictions.h"
#include "content/browser/net/sqlite_persistent_cookie_store.h"
#include "net/cookies/cookie_util.h"
#include "net/cookies/parsed_cookie.h"
#include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
#include "net/url_request/url_request_context.h"
#include "url/gurl.h"
@@ -174,8 +174,7 @@ CefCookieManagerImpl::GetExistingCookieMonster() {
return cookie_monster_;
} else if (request_context_impl_.get()) {
scoped_refptr<net::CookieMonster> cookie_monster =
request_context_impl_->GetURLRequestContext()->cookie_store()->
GetCookieMonster();
request_context_impl_->GetCookieMonster();
DCHECK(cookie_monster.get());
return cookie_monster;
}
@@ -194,39 +193,12 @@ void CefCookieManagerImpl::SetSupportedSchemes(
return;
}
if (HasContext()) {
RunMethodWithContext(
base::Bind(&CefCookieManagerImpl::SetSupportedSchemesWithContext, this,
schemes, callback));
return;
}
DCHECK(cookie_monster_.get());
if (!cookie_monster_.get())
return;
supported_schemes_ = schemes;
if (supported_schemes_.empty()) {
supported_schemes_.push_back("http");
supported_schemes_.push_back("https");
}
std::set<std::string> scheme_set;
std::vector<CefString>::const_iterator it = supported_schemes_.begin();
for (; it != supported_schemes_.end(); ++it)
std::vector<CefString>::const_iterator it = schemes.begin();
for (; it != schemes.end(); ++it)
scheme_set.insert(*it);
const char** arr = new const char*[scheme_set.size()];
std::set<std::string>::const_iterator it2 = scheme_set.begin();
for (int i = 0; it2 != scheme_set.end(); ++it2, ++i)
arr[i] = it2->c_str();
cookie_monster_->SetCookieableSchemes(arr, scheme_set.size());
delete [] arr;
RunAsyncCompletionOnIOThread(callback);
SetSupportedSchemesInternal(scheme_set, callback);
}
bool CefCookieManagerImpl::VisitAllCookies(
@@ -309,7 +281,7 @@ bool CefCookieManagerImpl::SetStoragePath(
return true;
}
scoped_refptr<content::SQLitePersistentCookieStore> persistent_store;
scoped_refptr<net::SQLitePersistentCookieStore> persistent_store;
if (!new_path.empty()) {
// TODO(cef): Move directory creation to the blocking pool instead of
// allowing file IO on this thread.
@@ -318,12 +290,11 @@ bool CefCookieManagerImpl::SetStoragePath(
base::CreateDirectory(new_path)) {
const base::FilePath& cookie_path = new_path.AppendASCII("Cookies");
persistent_store =
new content::SQLitePersistentCookieStore(
new net::SQLitePersistentCookieStore(
cookie_path,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
persist_session_cookies,
NULL,
NULL);
} else {
NOTREACHED() << "The cookie storage directory could not be created";
@@ -340,7 +311,7 @@ bool CefCookieManagerImpl::SetStoragePath(
storage_path_ = new_path;
// Restore the previously supported schemes.
SetSupportedSchemes(supported_schemes_, callback);
SetSupportedSchemesInternal(supported_schemes_, callback);
return true;
}
@@ -404,6 +375,30 @@ bool CefCookieManagerImpl::GetCefCookie(const GURL& url,
return true;
}
// static
void CefCookieManagerImpl::SetCookieMonsterSchemes(
net::CookieMonster* cookie_monster,
const std::set<std::string>& schemes) {
CEF_REQUIRE_IOT();
std::set<std::string> all_schemes = schemes;
// Add default schemes that should always support cookies.
all_schemes.insert("http");
all_schemes.insert("https");
all_schemes.insert("ws");
all_schemes.insert("wss");
const char** arr = new const char*[all_schemes.size()];
std::set<std::string>::const_iterator it2 = all_schemes.begin();
for (int i = 0; it2 != all_schemes.end(); ++it2, ++i)
arr[i] = it2->c_str();
cookie_monster->SetCookieableSchemes(arr, all_schemes.size());
delete [] arr;
}
bool CefCookieManagerImpl::HasContext() {
CEF_REQUIRE_IOT();
return (request_context_impl_.get() || request_context_.get());
@@ -458,17 +453,12 @@ void CefCookieManagerImpl::SetStoragePathWithContext(
}
void CefCookieManagerImpl::SetSupportedSchemesWithContext(
const std::vector<CefString>& schemes,
const std::set<std::string>& schemes,
CefRefPtr<CefCompletionCallback> callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context) {
CEF_REQUIRE_IOT();
std::vector<std::string> scheme_vec;
std::vector<CefString>::const_iterator it = schemes.begin();
for (; it != schemes.end(); ++it)
scheme_vec.push_back(it->ToString());
request_context->SetCookieSupportedSchemes(scheme_vec);
request_context->SetCookieSupportedSchemes(schemes);
RunAsyncCompletionOnIOThread(callback);
}
@@ -480,8 +470,7 @@ void CefCookieManagerImpl::GetCookieMonsterWithContext(
CEF_REQUIRE_IOT();
scoped_refptr<net::CookieMonster> cookie_monster =
request_context->GetURLRequestContext()->cookie_store()->
GetCookieMonster();
request_context->GetCookieMonster();
if (task_runner->BelongsToCurrentThread()) {
// Execute the callback immediately.
@@ -492,6 +481,28 @@ void CefCookieManagerImpl::GetCookieMonsterWithContext(
}
}
void CefCookieManagerImpl::SetSupportedSchemesInternal(
const std::set<std::string>& schemes,
CefRefPtr<CefCompletionCallback> callback){
CEF_REQUIRE_IOT();
if (HasContext()) {
RunMethodWithContext(
base::Bind(&CefCookieManagerImpl::SetSupportedSchemesWithContext, this,
schemes, callback));
return;
}
DCHECK(cookie_monster_.get());
if (!cookie_monster_.get())
return;
supported_schemes_ = schemes;
SetCookieMonsterSchemes(cookie_monster_.get(), supported_schemes_);
RunAsyncCompletionOnIOThread(callback);
}
void CefCookieManagerImpl::VisitAllCookiesInternal(
CefRefPtr<CefCookieVisitor> visitor,
scoped_refptr<net::CookieMonster> cookie_monster) {

View File

@@ -5,6 +5,8 @@
#ifndef CEF_LIBCEF_BROWSER_COOKIE_MANAGER_IMPL_H_
#define CEF_LIBCEF_BROWSER_COOKIE_MANAGER_IMPL_H_
#include <set>
#include "include/cef_cookie.h"
#include "libcef/browser/request_context_impl.h"
@@ -58,6 +60,11 @@ class CefCookieManagerImpl : public CefCookieManager {
static bool GetCefCookie(const GURL& url, const std::string& cookie_line,
CefCookie& cookie);
// Set the schemes supported by |cookie_monster|. Default schemes will always
// be supported.
static void SetCookieMonsterSchemes(net::CookieMonster* cookie_monster,
const std::set<std::string>& schemes);
private:
// Returns true if a context is or will be available.
bool HasContext();
@@ -75,7 +82,7 @@ class CefCookieManagerImpl : public CefCookieManager {
CefRefPtr<CefCompletionCallback> callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void SetSupportedSchemesWithContext(
const std::vector<CefString>& schemes,
const std::set<std::string>& schemes,
CefRefPtr<CefCompletionCallback> callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void GetCookieMonsterWithContext(
@@ -83,6 +90,9 @@ class CefCookieManagerImpl : public CefCookieManager {
const CookieMonsterCallback& callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void SetSupportedSchemesInternal(
const std::set<std::string>& schemes,
CefRefPtr<CefCompletionCallback> callback);
void VisitAllCookiesInternal(
CefRefPtr<CefCookieVisitor> visitor,
scoped_refptr<net::CookieMonster> cookie_monster);
@@ -111,7 +121,7 @@ class CefCookieManagerImpl : public CefCookieManager {
// Used for cookie monsters owned by this object.
base::FilePath storage_path_;
std::vector<CefString> supported_schemes_;
std::set<std::string> supported_schemes_;
scoped_refptr<net::CookieMonster> cookie_monster_;
IMPLEMENT_REFCOUNTING(CefCookieManagerImpl);

View File

@@ -17,8 +17,9 @@
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/devtools_agent_host.h"
#include "base/time/time.h"
#include "content/public/browser/devtools_http_handler.h"
#include "content/public/browser/devtools_target.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"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
@@ -35,14 +36,10 @@
namespace {
const char kTargetTypePage[] = "page";
const char kTargetTypeServiceWorker[] = "service_worker";
const char kTargetTypeOther[] = "other";
const int kBackLog = 10;
class TCPServerSocketFactory
: public content::DevToolsHttpHandler::ServerSocketFactory {
: public devtools_http_handler::DevToolsHttpHandler::ServerSocketFactory {
public:
TCPServerSocketFactory(const std::string& address, uint16 port)
: address_(address), port_(port) {
@@ -65,71 +62,11 @@ class TCPServerSocketFactory
DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
};
scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>
scoped_ptr<devtools_http_handler::DevToolsHttpHandler::ServerSocketFactory>
CreateSocketFactory(uint16 port) {
return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>(
new TCPServerSocketFactory("127.0.0.1", port));
}
class Target : public content::DevToolsTarget {
public:
explicit Target(scoped_refptr<content::DevToolsAgentHost> agent_host);
std::string GetId() const override { return agent_host_->GetId(); }
std::string GetParentId() const override { return std::string(); }
std::string GetType() const override {
switch (agent_host_->GetType()) {
case content::DevToolsAgentHost::TYPE_WEB_CONTENTS:
return kTargetTypePage;
case content::DevToolsAgentHost::TYPE_SERVICE_WORKER:
return kTargetTypeServiceWorker;
default:
break;
}
return kTargetTypeOther;
}
std::string GetTitle() const override {
return agent_host_->GetTitle();
}
std::string GetDescription() const override { return std::string(); }
GURL GetURL() const override { return agent_host_->GetURL(); }
GURL GetFaviconURL() const override { return favicon_url_; }
base::TimeTicks GetLastActivityTime() const override {
return last_activity_time_;
}
bool IsAttached() const override {
return agent_host_->IsAttached();
}
scoped_refptr<content::DevToolsAgentHost> GetAgentHost() const
override {
return agent_host_;
}
bool Activate() const override;
bool Close() const override;
private:
scoped_refptr<content::DevToolsAgentHost> agent_host_;
GURL favicon_url_;
base::TimeTicks last_activity_time_;
};
Target::Target(scoped_refptr<content::DevToolsAgentHost> agent_host)
: agent_host_(agent_host) {
if (content::WebContents* web_contents = agent_host_->GetWebContents()) {
content::NavigationController& controller = web_contents->GetController();
content::NavigationEntry* entry = controller.GetActiveEntry();
if (entry != NULL && entry->GetURL().is_valid())
favicon_url_ = entry->GetFavicon().url;
last_activity_time_ = web_contents->GetLastActiveTime();
}
}
bool Target::Activate() const {
return agent_host_->Activate();
}
bool Target::Close() const {
return agent_host_->Close();
return scoped_ptr<
devtools_http_handler::DevToolsHttpHandler::ServerSocketFactory>(
new TCPServerSocketFactory("127.0.0.1", port));
}
} // namespace
@@ -137,11 +74,14 @@ bool Target::Close() const {
// CefDevToolsDelegate
CefDevToolsDelegate::CefDevToolsDelegate(uint16 port) {
devtools_http_handler_.reset(content::DevToolsHttpHandler::Start(
devtools_http_handler_.reset(new devtools_http_handler::DevToolsHttpHandler(
CreateSocketFactory(port),
std::string(),
this,
base::FilePath()));
base::FilePath(),
base::FilePath(),
std::string(),
CefContentClient::Get()->GetUserAgent()));
}
CefDevToolsDelegate::~CefDevToolsDelegate() {
@@ -152,7 +92,8 @@ void CefDevToolsDelegate::Stop() {
// Release the reference before deleting the handler. Deleting the handler
// will delete |this| and no members of |this| should be accessed after that
// call.
content::DevToolsHttpHandler* handler = devtools_http_handler_.release();
devtools_http_handler::DevToolsHttpHandler* handler =
devtools_http_handler_.release();
delete handler;
}
@@ -161,16 +102,17 @@ std::string CefDevToolsDelegate::GetDiscoveryPageHTML() {
IDR_CEF_DEVTOOLS_DISCOVERY_PAGE, ui::SCALE_FACTOR_NONE).as_string();
}
bool CefDevToolsDelegate::BundlesFrontendResources() {
return true;
std::string CefDevToolsDelegate::GetPageThumbnailData(const GURL& url) {
return std::string();
}
base::FilePath CefDevToolsDelegate::GetDebugFrontendDir() {
return base::FilePath();
std::string CefDevToolsDelegate::GetFrontendResource(
const std::string& path) {
return content::DevToolsFrontendHost::GetFrontendResource(path).as_string();
}
std::string CefDevToolsDelegate::GetChromeDevToolsURL() {
return base::StringPrintf("%s://%s/devtools.html",
return base::StringPrintf("%s://%s/inspector.html",
content::kChromeDevToolsScheme, scheme::kChromeDevToolsHost);
}
@@ -187,24 +129,3 @@ base::DictionaryValue* CefDevToolsManagerDelegate::HandleCommand(
base::DictionaryValue* command) {
return NULL;
}
std::string CefDevToolsManagerDelegate::GetPageThumbnailData(
const GURL& url) {
return std::string();
}
scoped_ptr<content::DevToolsTarget>
CefDevToolsManagerDelegate::CreateNewTarget(const GURL& url) {
return scoped_ptr<content::DevToolsTarget>();
}
void CefDevToolsManagerDelegate::EnumerateTargets(TargetCallback callback) {
TargetList targets;
content::DevToolsAgentHost::List agents =
content::DevToolsAgentHost::GetOrCreateAll();
for (content::DevToolsAgentHost::List::iterator it = agents.begin();
it != agents.end(); ++it) {
targets.push_back(new Target(*it));
}
callback.Run(targets);
}

View File

@@ -12,16 +12,17 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "components/devtools_http_handler/devtools_http_handler.h"
#include "components/devtools_http_handler/devtools_http_handler_delegate.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_http_handler.h"
#include "content/public/browser/devtools_http_handler_delegate.h"
#include "content/public/browser/devtools_manager_delegate.h"
namespace content {
class RenderViewHost;
}
class CefDevToolsDelegate : public content::DevToolsHttpHandlerDelegate {
class CefDevToolsDelegate :
public devtools_http_handler::DevToolsHttpHandlerDelegate {
public:
explicit CefDevToolsDelegate(uint16 port);
~CefDevToolsDelegate() override;
@@ -31,14 +32,14 @@ class CefDevToolsDelegate : public content::DevToolsHttpHandlerDelegate {
// DevToolsHttpHandlerDelegate overrides.
std::string GetDiscoveryPageHTML() override;
bool BundlesFrontendResources() override;
base::FilePath GetDebugFrontendDir() override;
std::string GetFrontendResource(const std::string& path) override;
std::string GetPageThumbnailData(const GURL& url) override;
// Returns the chrome-devtools URL.
std::string GetChromeDevToolsURL();
private:
scoped_ptr<content::DevToolsHttpHandler> devtools_http_handler_;
scoped_ptr<devtools_http_handler::DevToolsHttpHandler> devtools_http_handler_;
DISALLOW_COPY_AND_ASSIGN(CefDevToolsDelegate);
};
@@ -56,10 +57,6 @@ class CefDevToolsManagerDelegate : public content::DevToolsManagerDelegate {
base::DictionaryValue* HandleCommand(
content::DevToolsAgentHost* agent_host,
base::DictionaryValue* command) override;
scoped_ptr<content::DevToolsTarget> CreateNewTarget(
const GURL& url) override;
void EnumerateTargets(TargetCallback callback) override;
std::string GetPageThumbnailData(const GURL& url) override;
private:
DISALLOW_COPY_AND_ASSIGN(CefDevToolsManagerDelegate);

View File

@@ -17,7 +17,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/devtools_http_handler.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
@@ -187,9 +186,15 @@ void CefDevToolsFrontend::RenderViewCreated(
}
void CefDevToolsFrontend::DocumentAvailableInMainFrame() {
agent_host_ =
// Don't call AttachClient multiple times for the same DevToolsAgentHost.
// Otherwise it will call AgentHostClosed which closes the DevTools window.
// This may happen in cases where the DevTools content fails to load.
scoped_refptr<content::DevToolsAgentHost> agent_host =
content::DevToolsAgentHost::GetOrCreateFor(inspected_contents_);
agent_host_->AttachClient(this);
if (agent_host != agent_host_) {
agent_host_ = agent_host;
agent_host_->AttachClient(this);
}
}
void CefDevToolsFrontend::WebContentsDestroyed() {
@@ -205,7 +210,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
std::string method;
base::ListValue* params = NULL;
base::DictionaryValue* dict = NULL;
scoped_ptr<base::Value> parsed_message(base::JSONReader::Read(message));
scoped_ptr<base::Value> parsed_message = base::JSONReader::Read(message);
if (!parsed_message ||
!parsed_message->GetAsDictionary(&dict) ||
!dict->GetString("method", &method)) {
@@ -242,7 +247,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
}
net::URLFetcher* fetcher =
net::URLFetcher::Create(gurl, net::URLFetcher::GET, this);
net::URLFetcher::Create(gurl, net::URLFetcher::GET, this).release();
pending_requests_[fetcher] = request_id;
fetcher->SetRequestContext(web_contents()->GetBrowserContext()->
GetRequestContext());
@@ -251,6 +256,22 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
new ResponseWriter(weak_factory_.GetWeakPtr(), stream_id)));
fetcher->Start();
return;
} else if (method == "getPreferences") {
SendMessageAck(request_id, &preferences_);
return;
} else if (method == "setPreference") {
std::string name;
std::string value;
if (!params->GetString(0, &name) ||
!params->GetString(1, &value)) {
return;
}
preferences_.SetStringWithoutPathExpansion(name, value);
} else if (method == "removePreference") {
std::string name;
if (!params->GetString(0, &name))
return;
preferences_.RemoveWithoutPathExpansion(name, nullptr);
} else {
return;
}
@@ -277,9 +298,9 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
base::FundamentalValue total_size(static_cast<int>(message.length()));
for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize));
std::string param;
base::JSONWriter::Write(&message_value, &param);
base::JSONWriter::Write(
base::StringValue(message.substr(pos, kMaxMessageChunkSize)), &param);
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");";
base::string16 javascript = base::UTF8ToUTF16(code);
web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
@@ -318,13 +339,13 @@ void CefDevToolsFrontend::CallClientFunction(
std::string javascript = function_name + "(";
if (arg1) {
std::string json;
base::JSONWriter::Write(arg1, &json);
base::JSONWriter::Write(*arg1, &json);
javascript.append(json);
if (arg2) {
base::JSONWriter::Write(arg2, &json);
base::JSONWriter::Write(*arg2, &json);
javascript.append(", ").append(json);
if (arg3) {
base::JSONWriter::Write(arg3, &json);
base::JSONWriter::Write(*arg3, &json);
javascript.append(", ").append(json);
}
}

View File

@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_frontend_host.h"
#include "content/public/browser/web_contents_observer.h"
@@ -64,6 +65,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_; }
// WebContentsObserver overrides
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
@@ -87,6 +89,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
scoped_ptr<content::DevToolsFrontendHost> frontend_host_;
using PendingRequestsMap = std::map<const net::URLFetcher*, int>;
PendingRequestsMap pending_requests_;
base::DictionaryValue preferences_;
base::WeakPtrFactory<CefDevToolsFrontend> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CefDevToolsFrontend);

View File

@@ -0,0 +1,21 @@
# 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.
{
'targets': [
{
'target_name': 'cef_api_registration',
'type': 'static_library',
# TODO(jschuh): http://crbug.com/167187 size_t -> int
'msvs_disabled_warnings': [ 4267 ],
'includes': [
'../../../../../build/json_schema_bundle_registration_compile.gypi',
'../../../common/extensions/api/schemas.gypi',
],
'dependencies': [
'../../../common/extensions/api/api.gyp:cef_api',
],
},
],
}

View File

@@ -0,0 +1,175 @@
// Copyright (c) 2012 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/extensions/api/streams_private/streams_private_api.h"
#include "base/lazy_instance.h"
#include "base/values.h"
#include "cef/libcef/common/extensions/api/streams_private.h"
#include "content/public/browser/stream_handle.h"
#include "content/public/browser/stream_info.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
#include "extensions/common/manifest_handlers/mime_types_handler.h"
#include "net/http/http_response_headers.h"
namespace extensions {
namespace {
void CreateResponseHeadersDictionary(const net::HttpResponseHeaders* headers,
base::DictionaryValue* result) {
if (!headers)
return;
void* iter = NULL;
std::string header_name;
std::string header_value;
while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) {
base::Value* existing_value = NULL;
if (result->Get(header_name, &existing_value)) {
base::StringValue* existing_string_value =
static_cast<base::StringValue*>(existing_value);
existing_string_value->GetString()->append(", ").append(header_value);
} else {
result->SetString(header_name, header_value);
}
}
}
} // namespace
namespace streams_private = api::streams_private;
// static
StreamsPrivateAPI* StreamsPrivateAPI::Get(content::BrowserContext* context) {
return GetFactoryInstance()->Get(context);
}
StreamsPrivateAPI::StreamsPrivateAPI(content::BrowserContext* context)
: browser_context_(context),
extension_registry_observer_(this),
weak_ptr_factory_(this) {
extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_));
}
StreamsPrivateAPI::~StreamsPrivateAPI() {
}
void StreamsPrivateAPI::ExecuteMimeTypeHandler(
const std::string& extension_id,
int tab_id,
scoped_ptr<content::StreamInfo> stream,
const std::string& view_id,
int64 expected_content_size,
bool embedded,
int render_process_id,
int render_frame_id) {
const Extension* extension = ExtensionRegistry::Get(browser_context_)
->enabled_extensions()
.GetByID(extension_id);
if (!extension)
return;
MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
// If the mime handler uses MimeHandlerViewGuest, the MimeHandlerViewGuest
// will take ownership of the stream. Otherwise, store the stream handle in
// |streams_| and fire an event notifying the extension.
if (!handler->handler_url().empty()) {
GURL handler_url(Extension::GetBaseURLFromExtensionId(extension_id).spec() +
handler->handler_url());
scoped_ptr<StreamContainer> stream_container(new StreamContainer(
stream.Pass(), tab_id, embedded, handler_url, extension_id));
MimeHandlerStreamManager::Get(browser_context_)
->AddStream(view_id, stream_container.Pass(), render_process_id,
render_frame_id);
return;
}
// Create the event's arguments value.
streams_private::StreamInfo info;
info.mime_type = stream->mime_type;
info.original_url = stream->original_url.spec();
info.stream_url = stream->handle->GetURL().spec();
info.tab_id = tab_id;
info.embedded = embedded;
if (!view_id.empty()) {
info.view_id.reset(new std::string(view_id));
}
int size = -1;
if (expected_content_size <= INT_MAX)
size = expected_content_size;
info.expected_content_size = size;
CreateResponseHeadersDictionary(stream->response_headers.get(),
&info.response_headers.additional_properties);
scoped_ptr<Event> event(new Event(
events::UNKNOWN, streams_private::OnExecuteMimeTypeHandler::kEventName,
streams_private::OnExecuteMimeTypeHandler::Create(info)));
EventRouter::Get(browser_context_)
->DispatchEventToExtension(extension_id, event.Pass());
GURL url = stream->handle->GetURL();
streams_[extension_id][url] = make_linked_ptr(stream->handle.release());
}
void StreamsPrivateAPI::AbortStream(const std::string& extension_id,
const GURL& stream_url,
const base::Closure& callback) {
StreamMap::iterator extension_it = streams_.find(extension_id);
if (extension_it == streams_.end()) {
callback.Run();
return;
}
StreamMap::mapped_type* url_map = &extension_it->second;
StreamMap::mapped_type::iterator url_it = url_map->find(stream_url);
if (url_it == url_map->end()) {
callback.Run();
return;
}
url_it->second->AddCloseListener(callback);
url_map->erase(url_it);
}
void StreamsPrivateAPI::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionInfo::Reason reason) {
streams_.erase(extension->id());
}
StreamsPrivateAbortFunction::StreamsPrivateAbortFunction() {
}
ExtensionFunction::ResponseAction StreamsPrivateAbortFunction::Run() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &stream_url_));
StreamsPrivateAPI::Get(browser_context())->AbortStream(
extension_id(), GURL(stream_url_), base::Bind(
&StreamsPrivateAbortFunction::OnClose, this));
return RespondLater();
}
void StreamsPrivateAbortFunction::OnClose() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
Respond(NoArguments());
}
static base::LazyInstance<BrowserContextKeyedAPIFactory<StreamsPrivateAPI> >
g_factory = LAZY_INSTANCE_INITIALIZER;
// static
BrowserContextKeyedAPIFactory<StreamsPrivateAPI>*
StreamsPrivateAPI::GetFactoryInstance() {
return g_factory.Pointer();
}
} // namespace extensions

View File

@@ -0,0 +1,104 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_
#include <map>
#include <string>
#include "base/scoped_observer.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_registry_observer.h"
namespace content {
class BrowserContext;
class StreamHandle;
struct StreamInfo;
}
namespace extensions {
class ExtensionRegistry;
class StreamsPrivateAPI : public BrowserContextKeyedAPI,
public ExtensionRegistryObserver {
public:
// Convenience method to get the StreamsPrivateAPI for a BrowserContext.
static StreamsPrivateAPI* Get(content::BrowserContext* context);
explicit StreamsPrivateAPI(content::BrowserContext* context);
~StreamsPrivateAPI() override;
// Send the onExecuteMimeTypeHandler event to |extension_id|.
// |tab_id| is used to determine the tabId where the document is being
// opened. The data for the document will be readable from |stream|, and
// should be |expected_content_size| bytes long. If the viewer is being opened
// in a BrowserPlugin, specify a non-empty |view_id| of the plugin. |embedded|
// should be set to whether the document is embedded within another document.
void ExecuteMimeTypeHandler(const std::string& extension_id,
int tab_id,
scoped_ptr<content::StreamInfo> stream,
const std::string& view_id,
int64 expected_content_size,
bool embedded,
int render_process_id,
int render_frame_id);
void AbortStream(const std::string& extension_id,
const GURL& stream_url,
const base::Closure& callback);
// BrowserContextKeyedAPI implementation.
static BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance();
private:
friend class BrowserContextKeyedAPIFactory<StreamsPrivateAPI>;
typedef std::map<std::string,
std::map<GURL,
linked_ptr<content::StreamHandle> > > StreamMap;
// ExtensionRegistryObserver implementation.
void OnExtensionUnloaded(content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionInfo::Reason reason) override;
// BrowserContextKeyedAPI implementation.
static const char* service_name() {
return "StreamsPrivateAPI";
}
static const bool kServiceIsNULLWhileTesting = true;
static const bool kServiceRedirectedInIncognito = true;
content::BrowserContext* const browser_context_;
StreamMap streams_;
// Listen to extension unloaded notifications.
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
extension_registry_observer_;
base::WeakPtrFactory<StreamsPrivateAPI> weak_ptr_factory_;
};
class StreamsPrivateAbortFunction : public UIThreadExtensionFunction {
public:
StreamsPrivateAbortFunction();
DECLARE_EXTENSION_FUNCTION("streamsPrivate.abort", STREAMSPRIVATE_ABORT)
protected:
~StreamsPrivateAbortFunction() override {}
// ExtensionFunction:
ExtensionFunction::ResponseAction Run() override;
private:
void OnClose();
std::string stream_url_;
};
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_

View File

@@ -0,0 +1,20 @@
// Copyright 2015 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
#include "libcef/browser/extensions/browser_context_keyed_service_factories.h"
#include "libcef/browser/extensions/api/streams_private/streams_private_api.h"
#include "extensions/browser/renderer_startup_helper.h"
namespace extensions {
namespace cef {
void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
RendererStartupHelperFactory::GetInstance();
StreamsPrivateAPI::GetFactoryInstance();
}
} // namespace cef
} // namespace extensions

View File

@@ -0,0 +1,19 @@
// Copyright 2015 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
namespace extensions {
namespace cef {
// Ensures the existence of any BrowserContextKeyedServiceFactory provided by
// the CEF extensions code or otherwise required by CEF. See
// libcef/common/extensions/api/README.txt for additional details.
void EnsureBrowserContextKeyedServiceFactoriesBuilt();
} // namespace cef
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_

View File

@@ -0,0 +1,112 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_util.h"
#include "content/browser/browser_plugin/browser_plugin_embedder.h"
#include "content/browser/browser_plugin/browser_plugin_guest.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_plugin_guest_manager.h"
namespace extensions {
namespace {
bool InsertWebContents(std::vector<content::WebContents*>* vector,
content::WebContents* web_contents) {
vector->push_back(web_contents);
return false; // Continue iterating.
}
} // namespace
content::WebContents* GetFullPageGuestForOwnerContents(
content::WebContents* owner) {
content::WebContentsImpl* owner_impl =
static_cast<content::WebContentsImpl*>(owner);
content::BrowserPluginEmbedder* plugin_embedder =
owner_impl->GetBrowserPluginEmbedder();
if (plugin_embedder) {
content::BrowserPluginGuest* plugin_guest =
plugin_embedder->GetFullPageGuest();
if (plugin_guest)
return plugin_guest->web_contents();
}
return NULL;
}
void GetAllGuestsForOwnerContents(content::WebContents* owner,
std::vector<content::WebContents*>* guests) {
content::BrowserPluginGuestManager* plugin_guest_manager =
owner->GetBrowserContext()->GetGuestManager();
plugin_guest_manager->ForEachGuest(owner,
base::Bind(InsertWebContents, guests));
}
content::WebContents* GetOwnerForGuestContents(content::WebContents* guest) {
content::WebContentsImpl* guest_impl =
static_cast<content::WebContentsImpl*>(guest);
content::BrowserPluginGuest* plugin_guest =
guest_impl->GetBrowserPluginGuest();
if (plugin_guest)
return plugin_guest->embedder_web_contents();
return NULL;
}
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForView(int render_process_id,
int render_routing_id,
bool* is_guest_view) {
if (CEF_CURRENTLY_ON_UIT()) {
// Use the non-thread-safe but potentially faster approach.
content::RenderViewHost* host =
content::RenderViewHost::FromID(render_process_id, render_routing_id);
if (host)
return GetOwnerBrowserForHost(host, is_guest_view);
return NULL;
} else {
// Use the thread-safe approach.
scoped_refptr<CefBrowserInfo> info =
CefContentBrowserClient::Get()->GetBrowserInfoForView(
render_process_id, render_routing_id, is_guest_view);
if (info.get()) {
CefRefPtr<CefBrowserHostImpl> browser = info->browser();
if (!browser.get()) {
LOG(WARNING) << "Found browser id " << info->browser_id() <<
" but no browser object matching view process id " <<
render_process_id << " and routing id " <<
render_routing_id;
}
return browser;
}
return NULL;
}
}
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
content::RenderViewHost* host,
bool* is_guest_view) {
if (is_guest_view)
*is_guest_view = false;
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForHost(host);
if (!browser.get() && ExtensionsEnabled()) {
// Retrieve the owner browser, if any.
content::WebContents* owner = GetOwnerForGuestContents(
content::WebContents::FromRenderViewHost(host));
if (owner) {
browser = CefBrowserHostImpl::GetBrowserForContents(owner);
if (browser.get() && is_guest_view)
*is_guest_view = true;
}
}
return browser;
}
} // namespace extensions

View File

@@ -0,0 +1,47 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_
#include <vector>
#include "libcef/browser/browser_host_impl.h"
namespace content {
class RenderViewHost;
class WebContents;
}
namespace extensions {
// Returns the full-page guest WebContents for the specified |owner|, if any.
content::WebContents* GetFullPageGuestForOwnerContents(
content::WebContents* owner);
// Populates |guests| with all guest WebContents with the specified |owner|.
void GetAllGuestsForOwnerContents(content::WebContents* owner,
std::vector<content::WebContents*>* guests);
// Returns the WebContents that owns the specified |guest|, if any.
content::WebContents* GetOwnerForGuestContents(content::WebContents* guest);
// Returns the CefBrowserHostImpl that owns the host identified by the specified
// view routing IDs, if any. |is_guest_view| will be set to true if the IDs
// match a guest view associated with the returned browser instead of the
// browser itself.
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForView(int render_process_id,
int render_routing_id,
bool* is_guest_view);
// Returns the CefBrowserHostImpl that owns the specified |host|, if any.
// |is_guest_view| will be set to true if the host matches a guest view
// associated with the returned browser instead of the browser itself.
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
content::RenderViewHost* host,
bool* is_guest_view);
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_

View File

@@ -0,0 +1,58 @@
// 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/extensions/component_extension_resource_manager.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/common/chrome_paths.h"
#include "grit/component_extension_resources_map.h"
namespace extensions {
CefComponentExtensionResourceManager::CefComponentExtensionResourceManager() {
AddComponentResourceEntries(
kComponentExtensionResources,
kComponentExtensionResourcesSize);
}
CefComponentExtensionResourceManager::~CefComponentExtensionResourceManager() {}
bool CefComponentExtensionResourceManager::IsComponentExtensionResource(
const base::FilePath& extension_path,
const base::FilePath& resource_path,
int* resource_id) const {
base::FilePath directory_path = extension_path;
base::FilePath resources_dir;
base::FilePath relative_path;
if (!PathService::Get(chrome::DIR_RESOURCES, &resources_dir) ||
!resources_dir.AppendRelativePath(directory_path, &relative_path)) {
return false;
}
relative_path = relative_path.Append(resource_path);
relative_path = relative_path.NormalizePathSeparators();
std::map<base::FilePath, int>::const_iterator entry =
path_to_resource_id_.find(relative_path);
if (entry != path_to_resource_id_.end())
*resource_id = entry->second;
return entry != path_to_resource_id_.end();
}
void CefComponentExtensionResourceManager::AddComponentResourceEntries(
const GritResourceMap* entries,
size_t size) {
for (size_t i = 0; i < size; ++i) {
base::FilePath resource_path = base::FilePath().AppendASCII(
entries[i].name);
resource_path = resource_path.NormalizePathSeparators();
DCHECK(path_to_resource_id_.find(resource_path) ==
path_to_resource_id_.end());
path_to_resource_id_[resource_path] = entries[i].value;
}
}
} // namespace extensions

View File

@@ -0,0 +1,41 @@
// 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 CEF_LIBCEF_BROWSER_EXTENSIONS_COMPONENT_EXTENSION_RESOURCE_MANAGER_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_COMPONENT_EXTENSION_RESOURCE_MANAGER_H_
#include <map>
#include "base/basictypes.h"
#include "base/files/file_path.h"
#include "extensions/browser/component_extension_resource_manager.h"
struct GritResourceMap;
namespace extensions {
class CefComponentExtensionResourceManager
: public ComponentExtensionResourceManager {
public:
CefComponentExtensionResourceManager();
~CefComponentExtensionResourceManager() override;
// Overridden from ComponentExtensionResourceManager:
bool IsComponentExtensionResource(const base::FilePath& extension_path,
const base::FilePath& resource_path,
int* resource_id) const override;
private:
void AddComponentResourceEntries(const GritResourceMap* entries, size_t size);
// A map from a resource path to the resource ID. Used by
// IsComponentExtensionResource.
std::map<base::FilePath, int> path_to_resource_id_;
DISALLOW_COPY_AND_ASSIGN(CefComponentExtensionResourceManager);
};
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_COMPONENT_EXTENSION_RESOURCE_MANAGER_H_

View File

@@ -0,0 +1,125 @@
// Copyright (c) 2012 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/extensions/event_router_forwarder.h"
#include "libcef/browser/browser_context_impl.h"
#include "base/bind.h"
#include "base/values.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/event_router.h"
#include "url/gurl.h"
using content::BrowserThread;
namespace extensions {
EventRouterForwarder::EventRouterForwarder() {
}
EventRouterForwarder::~EventRouterForwarder() {
}
void EventRouterForwarder::BroadcastEventToRenderers(
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
const GURL& event_url) {
HandleEvent(std::string(), event_name, event_args.Pass(), 0, true, event_url);
}
void EventRouterForwarder::DispatchEventToRenderers(
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url) {
if (!profile)
return;
HandleEvent(std::string(),
event_name,
event_args.Pass(),
profile,
use_profile_to_restrict_events,
event_url);
}
void EventRouterForwarder::BroadcastEventToExtension(
const std::string& extension_id,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
const GURL& event_url) {
HandleEvent(extension_id, event_name, event_args.Pass(), 0, true, event_url);
}
void EventRouterForwarder::DispatchEventToExtension(
const std::string& extension_id,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url) {
if (!profile)
return;
HandleEvent(extension_id, event_name, event_args.Pass(), profile,
use_profile_to_restrict_events, event_url);
}
void EventRouterForwarder::HandleEvent(const std::string& extension_id,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile_ptr,
bool use_profile_to_restrict_events,
const GURL& event_url) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&EventRouterForwarder::HandleEvent, this,
extension_id, event_name, base::Passed(&event_args),
profile_ptr, use_profile_to_restrict_events, event_url));
return;
}
content::BrowserContext* profile = NULL;
if (profile_ptr) {
profile = reinterpret_cast<content::BrowserContext*>(profile_ptr);
if (CefBrowserContextImpl::GetForContext(profile) == NULL)
return;
}
if (profile) {
CallEventRouter(profile, extension_id, event_name, event_args.Pass(),
use_profile_to_restrict_events ? profile : NULL, event_url);
} else {
std::vector<CefBrowserContextImpl*> profiles(
CefBrowserContextImpl::GetAll());
for (size_t i = 0; i < profiles.size(); ++i) {
scoped_ptr<base::ListValue> per_profile_event_args(
event_args->DeepCopy());
CallEventRouter(
profiles[i], extension_id, event_name, per_profile_event_args.Pass(),
use_profile_to_restrict_events ? profiles[i] : NULL, event_url);
}
}
}
void EventRouterForwarder::CallEventRouter(
content::BrowserContext* profile,
const std::string& extension_id,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
content::BrowserContext* restrict_to_profile,
const GURL& event_url) {
scoped_ptr<Event> event(
new Event(events::UNKNOWN, event_name, event_args.Pass()));
event->restrict_to_browser_context = restrict_to_profile;
event->event_url = event_url;
if (extension_id.empty()) {
extensions::EventRouter::Get(profile)->BroadcastEvent(event.Pass());
} else {
extensions::EventRouter::Get(profile)
->DispatchEventToExtension(extension_id, event.Pass());
}
}
} // namespace extensions

View File

@@ -0,0 +1,107 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_
#include <string>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/values.h"
class GURL;
namespace content {
class BrowserContext;
}
namespace extensions {
// This class forwards events to EventRouters.
// The advantages of this class over direct usage of EventRouters are:
// - this class is thread-safe, you can call the functions from UI and IO
// thread.
// - the class can handle if a profile is deleted between the time of sending
// the event from the IO thread to the UI thread.
// - this class can be used in contexts that are not governed by a profile, e.g.
// by system URLRequestContexts. In these cases the |restrict_to_profile|
// parameter remains NULL and events are broadcasted to all profiles.
class EventRouterForwarder
: public base::RefCountedThreadSafe<EventRouterForwarder> {
public:
EventRouterForwarder();
// Calls
// DispatchEventToRenderers(event_name, event_args, profile, event_url)
// on all (original) profiles' EventRouters.
// May be called on any thread.
void BroadcastEventToRenderers(const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
const GURL& event_url);
// Calls
// DispatchEventToExtension(extension_id, event_name, event_args,
// profile, event_url)
// on all (original) profiles' EventRouters.
// May be called on any thread.
void BroadcastEventToExtension(const std::string& extension_id,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
const GURL& event_url);
// Calls
// DispatchEventToRenderers(event_name, event_args,
// use_profile_to_restrict_events ? profile : NULL, event_url)
// on |profile|'s EventRouter. May be called on any thread.
void DispatchEventToRenderers(const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url);
// Calls
// DispatchEventToExtension(extension_id, event_name, event_args,
// use_profile_to_restrict_events ? profile : NULL, event_url)
// on |profile|'s EventRouter. May be called on any thread.
void DispatchEventToExtension(const std::string& extension_id,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url);
protected:
// Protected for testing.
virtual ~EventRouterForwarder();
// Helper function for {Broadcast,Dispatch}EventTo{Extension,Renderers}.
// Virtual for testing.
virtual void HandleEvent(const std::string& extension_id,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url);
// Calls DispatchEventToRenderers or DispatchEventToExtension (depending on
// whether extension_id == "" or not) of |profile|'s EventRouter.
// |profile| may never be NULL.
// Virtual for testing.
virtual void CallEventRouter(content::BrowserContext* profile,
const std::string& extension_id,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
content::BrowserContext* restrict_to_profile,
const GURL& event_url);
private:
friend class base::RefCountedThreadSafe<EventRouterForwarder>;
DISALLOW_COPY_AND_ASSIGN(EventRouterForwarder);
};
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_

View File

@@ -0,0 +1,440 @@
// Copyright 2015 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.
#include "libcef/browser/extensions/extension_system.h"
#include <string>
#include "libcef/browser/extensions/pdf_extension_util.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/json/json_string_value_serializer.h"
#include "base/path_service.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/common/chrome_paths.h"
#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_process_host.h"
#include "extensions/browser/api/app_runtime/app_runtime_api.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/info_map.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/quota_service.h"
#include "extensions/browser/runtime_data.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_messages.h"
#include "extensions/common/file_util.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/mime_types_handler.h"
#include "extensions/common/switches.h"
#include "net/base/mime_util.h"
using content::BrowserContext;
using content::BrowserThread;
namespace extensions {
namespace {
std::string GenerateId(const base::DictionaryValue* manifest,
const base::FilePath& path) {
std::string raw_key;
std::string id_input;
CHECK(manifest->GetString(manifest_keys::kPublicKey, &raw_key));
CHECK(Extension::ParsePEMKeyBytes(raw_key, &id_input));
std::string id = crx_file::id_util::GenerateId(id_input);
return id;
}
// Implementation based on ComponentLoader::ParseManifest.
base::DictionaryValue* ParseManifest(
const std::string& manifest_contents) {
JSONStringValueDeserializer deserializer(manifest_contents);
scoped_ptr<base::Value> manifest(deserializer.Deserialize(NULL, NULL));
if (!manifest.get() || !manifest->IsType(base::Value::TYPE_DICTIONARY)) {
LOG(ERROR) << "Failed to parse extension manifest.";
return NULL;
}
// Transfer ownership to the caller.
return static_cast<base::DictionaryValue*>(manifest.release());
}
} // namespace
CefExtensionSystem::CefExtensionSystem(BrowserContext* browser_context)
: browser_context_(browser_context),
registry_(ExtensionRegistry::Get(browser_context)) {
}
CefExtensionSystem::~CefExtensionSystem() {
}
void CefExtensionSystem::Init() {
// There's complexity here related to the ordering of message delivery. For
// an extension to load correctly both the ExtensionMsg_Loaded and
// ExtensionMsg_ActivateExtension messages must be sent. These messages are
// currently sent by RendererStartupHelper, ExtensionWebContentsObserver, and
// this class. ExtensionMsg_Loaded is handled by Dispatcher::OnLoaded and adds
// the extension to |extensions_|. ExtensionMsg_ActivateExtension is handled
// by Dispatcher::OnActivateExtension and adds the extension to
// |active_extension_ids_|. If these messages are not sent correctly then
// ScriptContextSet::Register called from Dispatcher::DidCreateScriptContext
// will classify the extension incorrectly and API bindings will not be added.
// Inform the rest of the extensions system to start.
ready_.Signal();
content::NotificationService::current()->Notify(
NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
content::Source<BrowserContext>(browser_context_),
content::NotificationService::NoDetails());
// Add the built-in PDF extension. PDF loading works as follows:
// 1. PDF PPAPI plugin is registered to handle kPDFPluginOutOfProcessMimeType
// in libcef/common/content_client.cc ComputeBuiltInPlugins.
// 2. PDF extension is registered with the below call to AddExtension.
// 3. A page requests a plugin to handle "application/pdf" mime type. This
// results in a call to CefContentRendererClient::OverrideCreatePlugin
// in the renderer process which calls CefContentRendererClient::
// CreateBrowserPluginDelegate indirectly to create a
// MimeHandlerViewContainer.
// 4. CefResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream
// intercepts the PDF load in the browser process, associates the load with
// the PDF extension and makes the PDF file contents available to the
// extension via the Stream API.
// 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
// CefExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob and
// CefComponentExtensionResourceManager.
// 8. 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
// kPDFPluginOutOfProcessMimeType which loads the PDF PPAPI plugin.
// 10.Routing of print-related commands are handled by ChromePDFPrintClient
// and CefPrintWebViewHelperDelegate in the renderer process.
if (PdfExtensionEnabled()) {
AddExtension(pdf_extension_util::GetManifest(),
base::FilePath(FILE_PATH_LITERAL("pdf")));
}
}
// Implementation based on ComponentLoader::Add.
const Extension* CefExtensionSystem::AddExtension(
const std::string& manifest_contents,
const base::FilePath& root_directory) {
base::DictionaryValue* manifest = ParseManifest(manifest_contents);
if (!manifest)
return NULL;
ComponentExtensionInfo info(manifest, root_directory);
const Extension* extension = LoadExtension(info);
delete manifest;
return extension;
}
// Implementation based on ExtensionService::RemoveComponentExtension.
void CefExtensionSystem::RemoveExtension(const std::string& extension_id) {
scoped_refptr<const Extension> extension(
registry_->enabled_extensions().GetByID(extension_id));
UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL);
if (extension.get()) {
registry_->TriggerOnUninstalled(
extension.get(), extensions::UNINSTALL_REASON_COMPONENT_REMOVED);
}
}
void CefExtensionSystem::Shutdown() {
}
void CefExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
runtime_data_.reset(new RuntimeData(registry_));
quota_service_.reset(new QuotaService);
}
ExtensionService* CefExtensionSystem::extension_service() {
return nullptr;
}
RuntimeData* CefExtensionSystem::runtime_data() {
return runtime_data_.get();
}
ManagementPolicy* CefExtensionSystem::management_policy() {
return nullptr;
}
SharedUserScriptMaster* CefExtensionSystem::shared_user_script_master() {
return nullptr;
}
StateStore* CefExtensionSystem::state_store() {
return nullptr;
}
StateStore* CefExtensionSystem::rules_store() {
return nullptr;
}
InfoMap* CefExtensionSystem::info_map() {
if (!info_map_.get())
info_map_ = new InfoMap;
return info_map_.get();
}
QuotaService* CefExtensionSystem::quota_service() {
return quota_service_.get();
}
// Implementation based on
// ExtensionSystemImpl::RegisterExtensionWithRequestContexts.
void CefExtensionSystem::RegisterExtensionWithRequestContexts(
const Extension* extension) {
// TODO(extensions): The |incognito_enabled| value should be set based on
// manifest settings.
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(&InfoMap::AddExtension,
info_map(),
make_scoped_refptr(extension),
base::Time::Now(),
true, // incognito_enabled
false)); // notifications_disabled
}
// Implementation based on
// ExtensionSystemImpl::UnregisterExtensionWithRequestContexts.
void CefExtensionSystem::UnregisterExtensionWithRequestContexts(
const std::string& extension_id,
const UnloadedExtensionInfo::Reason reason) {
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
}
const OneShotEvent& CefExtensionSystem::ready() const {
return ready_;
}
ContentVerifier* CefExtensionSystem::content_verifier() {
return nullptr;
}
scoped_ptr<ExtensionSet> CefExtensionSystem::GetDependentExtensions(
const Extension* extension) {
return make_scoped_ptr(new ExtensionSet());
}
CefExtensionSystem::ComponentExtensionInfo::ComponentExtensionInfo(
const base::DictionaryValue* manifest, const base::FilePath& directory)
: manifest(manifest),
root_directory(directory) {
if (!root_directory.IsAbsolute()) {
// This path structure is required by
// url_request_util::MaybeCreateURLRequestResourceBundleJob.
CHECK(PathService::Get(chrome::DIR_RESOURCES, &root_directory));
root_directory = root_directory.Append(directory);
}
extension_id = GenerateId(manifest, root_directory);
}
// Implementation based on ComponentLoader::CreateExtension.
scoped_refptr<const Extension> CefExtensionSystem::CreateExtension(
const ComponentExtensionInfo& info, std::string* utf8_error) {
// TODO(abarth): We should REQUIRE_MODERN_MANIFEST_VERSION once we've updated
// our component extensions to the new manifest version.
int flags = Extension::REQUIRE_KEY;
return Extension::Create(
info.root_directory,
Manifest::COMPONENT,
*info.manifest,
flags,
utf8_error);
}
// Implementation based on ComponentLoader::Load and
// ExtensionService::AddExtension.
const Extension* CefExtensionSystem::LoadExtension(
const ComponentExtensionInfo& info) {
std::string error;
scoped_refptr<const Extension> extension(CreateExtension(info, &error));
if (!extension.get()) {
LOG(ERROR) << error;
return NULL;
}
CHECK_EQ(info.extension_id, extension->id()) << extension->name();
registry_->AddEnabled(extension.get());
NotifyExtensionLoaded(extension.get());
return extension.get();
}
// Implementation based on ExtensionService::UnloadExtension.
void CefExtensionSystem::UnloadExtension(
const std::string& extension_id,
UnloadedExtensionInfo::Reason reason) {
// Make sure the extension gets deleted after we return from this function.
int include_mask =
ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::TERMINATED;
scoped_refptr<const Extension> extension(
registry_->GetExtensionById(extension_id, include_mask));
// This method can be called via PostTask, so the extension may have been
// unloaded by the time this runs.
if (!extension.get()) {
// In case the extension may have crashed/uninstalled. Allow the profile to
// clean up its RequestContexts.
UnregisterExtensionWithRequestContexts(extension_id, reason);
return;
}
if (registry_->disabled_extensions().Contains(extension->id())) {
registry_->RemoveDisabled(extension->id());
// Make sure the profile cleans up its RequestContexts when an already
// disabled extension is unloaded (since they are also tracking the disabled
// extensions).
UnregisterExtensionWithRequestContexts(extension_id, reason);
// Don't send the unloaded notification. It was sent when the extension
// was disabled.
} else {
// Remove the extension from the enabled list.
registry_->RemoveEnabled(extension->id());
NotifyExtensionUnloaded(extension.get(), reason);
}
content::NotificationService::current()->Notify(
extensions::NOTIFICATION_EXTENSION_REMOVED,
content::Source<content::BrowserContext>(browser_context_),
content::Details<const Extension>(extension.get()));
}
// Implementation based on ExtensionService::NotifyExtensionLoaded.
void CefExtensionSystem::NotifyExtensionLoaded(const Extension* extension) {
// The URLRequestContexts need to be first to know that the extension
// was loaded, otherwise a race can arise where a renderer that is created
// for the extension may try to load an extension URL with an extension id
// that the request context doesn't yet know about. The profile is responsible
// for ensuring its URLRequestContexts appropriately discover the loaded
// extension.
RegisterExtensionWithRequestContexts(extension);
// Tell renderers about the new extension, unless it's a theme (renderers
// don't need to know about themes).
if (!extension->is_theme()) {
for (content::RenderProcessHost::iterator i(
content::RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance()) {
content::RenderProcessHost* host = i.GetCurrentValue();
if (host->GetBrowserContext() == browser_context_) {
// We don't need to include tab permisisons here, since the extension
// was just loaded.
std::vector<ExtensionMsg_Loaded_Params> loaded_extensions(
1, ExtensionMsg_Loaded_Params(extension,
false /* no tab permissions */));
host->Send(
new ExtensionMsg_Loaded(loaded_extensions));
}
}
}
// Tell subsystems that use the EXTENSION_LOADED notification about the new
// extension.
//
// NOTE: It is important that this happen after notifying the renderers about
// the new extensions so that if we navigate to an extension URL in
// ExtensionRegistryObserver::OnLoaded or
// NOTIFICATION_EXTENSION_LOADED_DEPRECATED, the
// renderer is guaranteed to know about it.
registry_->TriggerOnLoaded(extension);
// Register plugins included with the extension.
// Implementation based on PluginManager::OnExtensionLoaded.
const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
if (handler && !handler->handler_url().empty()) {
content::WebPluginInfo info;
info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN;
info.name = base::UTF8ToUTF16(extension->name());
info.path = base::FilePath::FromUTF8Unsafe(extension->url().spec());
for (std::set<std::string>::const_iterator mime_type =
handler->mime_type_set().begin();
mime_type != handler->mime_type_set().end(); ++mime_type) {
content::WebPluginMimeType mime_type_info;
mime_type_info.mime_type = *mime_type;
base::FilePath::StringType file_extension;
if (net::GetPreferredExtensionForMimeType(*mime_type, &file_extension)) {
mime_type_info.file_extensions.push_back(
base::FilePath(file_extension).AsUTF8Unsafe());
}
info.mime_types.push_back(mime_type_info);
}
content::PluginService* plugin_service =
content::PluginService::GetInstance();
plugin_service->RefreshPlugins();
plugin_service->RegisterInternalPlugin(info, true);
}
content::NotificationService::current()->Notify(
extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
content::Source<content::BrowserContext>(browser_context_),
content::Details<const Extension>(extension));
}
// Implementation based on ExtensionService::NotifyExtensionUnloaded.
void CefExtensionSystem::NotifyExtensionUnloaded(
const Extension* extension,
UnloadedExtensionInfo::Reason reason) {
UnloadedExtensionInfo details(extension, reason);
// Unregister plugins included with the extension.
// Implementation based on PluginManager::OnExtensionUnloaded.
const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
if (handler && !handler->handler_url().empty()) {
base::FilePath path =
base::FilePath::FromUTF8Unsafe(extension->url().spec());
content::PluginService* plugin_service =
content::PluginService::GetInstance();
plugin_service->UnregisterInternalPlugin(path);
plugin_service->ForcePluginShutdown(path);
plugin_service->RefreshPlugins();
}
registry_->TriggerOnUnloaded(extension, reason);
content::NotificationService::current()->Notify(
extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
content::Source<content::BrowserContext>(browser_context_),
content::Details<UnloadedExtensionInfo>(&details));
for (content::RenderProcessHost::iterator i(
content::RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance()) {
content::RenderProcessHost* host = i.GetCurrentValue();
if (host->GetBrowserContext() == browser_context_)
host->Send(new ExtensionMsg_Unloaded(extension->id()));
}
UnregisterExtensionWithRequestContexts(extension->id(), reason);
}
} // namespace extensions

View File

@@ -0,0 +1,127 @@
// Copyright 2015 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.
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_
#include <vector>
#include "base/compiler_specific.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/one_shot_event.h"
class BrowserContextKeyedServiceFactory;
namespace base {
class FilePath;
}
namespace content {
class BrowserContext;
}
namespace extensions {
class ExtensionRegistry;
class InfoMap;
class ProcessManager;
class RendererStartupHelper;
class SharedUserScriptMaster;
// Used to manage extensions.
class CefExtensionSystem : public ExtensionSystem {
public:
explicit CefExtensionSystem(content::BrowserContext* browser_context);
~CefExtensionSystem() override;
// Initializes the extension system.
void Init();
// Add an extension. Returns the new Extension object on success or NULL on
// failure.
const Extension* AddExtension(const std::string& manifest_contents,
const base::FilePath& root_directory);
// Remove an extension.
void RemoveExtension(const std::string& extension_id);
// KeyedService implementation:
void Shutdown() override;
// ExtensionSystem implementation:
void InitForRegularProfile(bool extensions_enabled) override;
ExtensionService* extension_service() override;
RuntimeData* runtime_data() override;
ManagementPolicy* management_policy() override;
SharedUserScriptMaster* shared_user_script_master() override;
StateStore* state_store() override;
StateStore* rules_store() override;
InfoMap* info_map() override;
QuotaService* quota_service() override;
void RegisterExtensionWithRequestContexts(
const Extension* extension) override;
void UnregisterExtensionWithRequestContexts(
const std::string& extension_id,
const UnloadedExtensionInfo::Reason reason) override;
const OneShotEvent& ready() const override;
ContentVerifier* content_verifier() override;
scoped_ptr<ExtensionSet> GetDependentExtensions(
const Extension* extension) override;
private:
// Information about a registered component extension.
struct ComponentExtensionInfo {
ComponentExtensionInfo(const base::DictionaryValue* manifest,
const base::FilePath& root_directory);
// The parsed contents of the extensions's manifest file.
const base::DictionaryValue* manifest;
// Directory where the extension is stored.
base::FilePath root_directory;
// The component extension's ID.
std::string extension_id;
};
scoped_refptr<const Extension> CreateExtension(
const ComponentExtensionInfo& info, std::string* utf8_error);
// Loads a registered component extension.
const Extension* LoadExtension(const ComponentExtensionInfo& info);
// Unload the specified extension.
void UnloadExtension(
const std::string& extension_id,
extensions::UnloadedExtensionInfo::Reason reason);
// Handles sending notification that |extension| was loaded.
void NotifyExtensionLoaded(const Extension* extension);
// Handles sending notification that |extension| was unloaded.
void NotifyExtensionUnloaded(
const Extension* extension,
UnloadedExtensionInfo::Reason reason);
content::BrowserContext* browser_context_; // Not owned.
// Data to be accessed on the IO thread. Must outlive process_manager_.
scoped_refptr<InfoMap> info_map_;
scoped_ptr<RuntimeData> runtime_data_;
scoped_ptr<QuotaService> quota_service_;
// Signaled when the extension system has completed its startup tasks.
OneShotEvent ready_;
// Sets of enabled/disabled/terminated/blacklisted extensions. Not owned.
ExtensionRegistry* registry_;
DISALLOW_COPY_AND_ASSIGN(CefExtensionSystem);
};
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_

View File

@@ -0,0 +1,55 @@
// 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/extensions/extension_system_factory.h"
#include "libcef/browser/extensions/extension_system.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/extension_prefs_factory.h"
#include "extensions/browser/extension_registry_factory.h"
using content::BrowserContext;
namespace extensions {
ExtensionSystem* CefExtensionSystemFactory::GetForBrowserContext(
BrowserContext* context) {
return static_cast<CefExtensionSystem*>(
GetInstance()->GetServiceForBrowserContext(context, true));
}
// static
CefExtensionSystemFactory* CefExtensionSystemFactory::GetInstance() {
return Singleton<CefExtensionSystemFactory>::get();
}
CefExtensionSystemFactory::CefExtensionSystemFactory()
: ExtensionSystemProvider("CefExtensionSystem",
BrowserContextDependencyManager::GetInstance()) {
// Other factories that this factory depends on. See
// libcef/common/extensions/api/README.txt for additional details.
DependsOn(ExtensionPrefsFactory::GetInstance());
DependsOn(ExtensionRegistryFactory::GetInstance());
}
CefExtensionSystemFactory::~CefExtensionSystemFactory() {
}
KeyedService* CefExtensionSystemFactory::BuildServiceInstanceFor(
BrowserContext* context) const {
return new CefExtensionSystem(context);
}
BrowserContext* CefExtensionSystemFactory::GetBrowserContextToUse(
BrowserContext* context) const {
// Use a separate instance for incognito.
return context;
}
bool CefExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const {
return true;
}
} // namespace extensions

View File

@@ -0,0 +1,40 @@
// 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 CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_FACTORY_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_FACTORY_H_
#include "base/memory/singleton.h"
#include "extensions/browser/extension_system_provider.h"
namespace extensions {
// Factory that provides CefExtensionSystem.
class CefExtensionSystemFactory : public ExtensionSystemProvider {
public:
// ExtensionSystemProvider implementation:
ExtensionSystem* GetForBrowserContext(
content::BrowserContext* context) override;
static CefExtensionSystemFactory* GetInstance();
private:
friend struct DefaultSingletonTraits<CefExtensionSystemFactory>;
CefExtensionSystemFactory();
~CefExtensionSystemFactory() override;
// BrowserContextKeyedServiceFactory implementation:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
bool ServiceIsCreatedWithBrowserContext() const override;
DISALLOW_COPY_AND_ASSIGN(CefExtensionSystemFactory);
};
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_FACTORY_H_

View File

@@ -0,0 +1,19 @@
// 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/extensions/extension_web_contents_observer.h"
DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::CefExtensionWebContentsObserver);
namespace extensions {
CefExtensionWebContentsObserver::CefExtensionWebContentsObserver(
content::WebContents* web_contents)
: ExtensionWebContentsObserver(web_contents) {
}
CefExtensionWebContentsObserver::~CefExtensionWebContentsObserver() {
}
} // namespace extensions

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