Compare commits

...

54 Commits
4951 ... 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
249 changed files with 7901 additions and 1305 deletions

View File

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

64
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',
@@ -457,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',
@@ -595,6 +600,8 @@
'destination': '<(PRODUCT_DIR)/files',
'files': [
'tests/cefclient/resources/osr_test.html',
'tests/cefclient/resources/pdf.html',
'tests/cefclient/resources/pdf.pdf',
],
},
],
@@ -799,6 +806,7 @@
'<(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',
@@ -830,6 +838,7 @@
'<(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',
},
@@ -844,6 +853,7 @@
'<(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',
},
@@ -862,6 +872,7 @@
'<(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',
],
@@ -921,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',
@@ -936,6 +948,10 @@
# 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',
@@ -986,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',
@@ -1045,6 +1063,10 @@
'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',
@@ -1071,8 +1093,6 @@
'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/plugin_info_message_filter.cc',
'libcef/browser/extensions/plugin_info_message_filter.h',
'libcef/browser/extensions/url_request_util.cc',
'libcef/browser/extensions/url_request_util.h',
'libcef/browser/frame_host_impl.cc',
@@ -1100,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',
@@ -1199,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',
@@ -1242,11 +1270,17 @@
'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',
@@ -1376,12 +1410,33 @@
'<(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"', {
@@ -1488,6 +1543,7 @@
'<(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!': [
@@ -1727,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',
@@ -1742,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',
@@ -110,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',
@@ -248,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',
@@ -442,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',

View File

@@ -158,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',

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

@@ -132,22 +132,6 @@
#error Please add support for your compiler in cef_build.h
#endif
// Annotate a virtual method indicating it must be overriding a virtual
// method in the parent class.
// Use like:
// virtual void foo() OVERRIDE;
#ifndef OVERRIDE
#if defined(__clang__) || defined(COMPILER_MSVC)
#define OVERRIDE override
#elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
#define OVERRIDE override
#else
#define OVERRIDE
#endif
#endif // OVERRIDE
// Annotate a function indicating the caller must examine the return value.
// Use like:
// int foo() WARN_UNUSED_RESULT;
@@ -183,4 +167,23 @@
#endif // !BUILDING_CEF_SHARED
// Annotate a virtual method indicating it must be overriding a virtual method
// in the parent class.
// Use like:
// void foo() OVERRIDE;
// NOTE: This define should only be used in classes exposed to the client since
// C++11 support may not be enabled in client applications. CEF internal classes
// should use the `override` keyword directly.
#ifndef OVERRIDE
#if defined(__clang__) || defined(COMPILER_MSVC)
#define OVERRIDE override
#elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
#define OVERRIDE override
#else
#define OVERRIDE
#endif
#endif // OVERRIDE
#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_

View File

@@ -2554,7 +2554,7 @@ template <typename Runnable, typename RunType, typename BoundArgsType>
struct BindState;
template <typename Runnable, typename RunType>
struct BindState<Runnable, RunType, void()> final : public BindStateBase {
struct BindState<Runnable, RunType, void()> : public BindStateBase {
typedef Runnable RunnableType;
typedef false_type IsWeakCall;
typedef Invoker<0, BindState, RunType> InvokerType;
@@ -2574,7 +2574,7 @@ struct BindState<Runnable, RunType, void()> final : public BindStateBase {
};
template <typename Runnable, typename RunType, typename P1>
struct BindState<Runnable, RunType, void(P1)> final : public BindStateBase {
struct BindState<Runnable, RunType, void(P1)> : public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
typedef Invoker<1, BindState, RunType> InvokerType;
@@ -2602,7 +2602,7 @@ struct BindState<Runnable, RunType, void(P1)> final : public BindStateBase {
};
template <typename Runnable, typename RunType, typename P1, typename P2>
struct BindState<Runnable, RunType, void(P1, P2)> final : public BindStateBase {
struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
typedef Invoker<2, BindState, RunType> InvokerType;
@@ -2634,7 +2634,7 @@ struct BindState<Runnable, RunType, void(P1, P2)> final : public BindStateBase {
template <typename Runnable, typename RunType, typename P1, typename P2,
typename P3>
struct BindState<Runnable, RunType, void(P1, P2, P3)> final
struct BindState<Runnable, RunType, void(P1, P2, P3)>
: public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
@@ -2670,7 +2670,7 @@ struct BindState<Runnable, RunType, void(P1, P2, P3)> final
template <typename Runnable, typename RunType, typename P1, typename P2,
typename P3, typename P4>
struct BindState<Runnable, RunType, void(P1, P2, P3, P4)> final
struct BindState<Runnable, RunType, void(P1, P2, P3, P4)>
: public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
@@ -2710,7 +2710,7 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4)> final
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)> final
struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5)>
: public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
@@ -2753,7 +2753,7 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5)> final
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)> final
struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6)>
: public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
@@ -2799,7 +2799,7 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6)> final
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)> final
struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6, P7)>
: public BindStateBase {
typedef Runnable RunnableType;
typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;

View File

@@ -60,7 +60,7 @@ class BindStateBase {
protected:
explicit BindStateBase(void (*destructor)(BindStateBase*))
: ref_count_(0), destructor_(destructor) {}
~BindStateBase() = default;
~BindStateBase() {}
private:
friend class scoped_refptr<BindStateBase>;

View File

@@ -175,6 +175,13 @@ CEF_EXPORT void cef_quit_message_loop();
///
CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop);
///
// Call during process startup to enable High-DPI support on Windows 7 or newer.
// Older versions of Windows should be left DPI-unaware because they do not
// support DirectWrite and GDI fonts are kerned very badly.
///
CEF_EXPORT void cef_enable_highdpi_support();
#ifdef __cplusplus
}
#endif

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

@@ -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

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

@@ -124,6 +124,14 @@ void CefQuitMessageLoop();
/*--cef()--*/
void CefSetOSModalLoop(bool osModalLoop);
///
// Call during process startup to enable High-DPI support on Windows 7 or newer.
// Older versions of Windows should be left DPI-unaware because they do not
// support DirectWrite and GDI fonts are kerned very badly.
///
/*--cef(capi_name=cef_enable_highdpi_support)--*/
void CefEnableHighDPISupport();
///
// Implement this interface to provide handler implementations. Methods will be
// called by the process and/or thread indicated.

View File

@@ -113,17 +113,17 @@ class CefRefCount {
///
#define IMPLEMENT_REFCOUNTING(ClassName) \
public: \
void AddRef() const { \
void AddRef() const OVERRIDE { \
ref_count_.AddRef(); \
} \
bool Release() const { \
bool Release() const OVERRIDE { \
if (ref_count_.Release()) { \
delete static_cast<const ClassName*>(this); \
return true; \
} \
return false; \
} \
bool HasOneRef() const { \
bool HasOneRef() const OVERRIDE { \
return ref_count_.HasOneRef(); \
} \
private: \

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

@@ -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

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

@@ -148,7 +148,7 @@ class CefRunnableMethod : public CefTask {
traits_.ReleaseCallee(obj);
}
virtual void Execute() {
void Execute() OVERRIDE {
if (obj_)
DispatchToMethod(obj_, meth_, params_);
}
@@ -240,7 +240,7 @@ class CefRunnableFunction : public CefTask {
~CefRunnableFunction() {
}
virtual void Execute() {
void Execute() OVERRIDE {
if (function_)
DispatchToFunction(function_, params_);
}

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

@@ -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

@@ -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;
@@ -1462,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.
@@ -2280,6 +2246,50 @@ typedef struct _cef_pdf_print_settings_t {
} 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;
}
};
@@ -827,8 +827,8 @@ class CefPageRange : public CefStructBase<CefPageRangeTraits> {
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;
}
};

View File

@@ -52,14 +52,15 @@ void CefBrowserContext::Initialize() {
resource_context_.reset(new CefResourceContext(
IsOffTheRecord(),
extensions_enabled ? extension_system_->info_map() : NULL));
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 = CefContentBrowserClient::Get()->pref_service();
PrefService* pref_service = GetPrefs();
DCHECK(pref_service);
user_prefs::UserPrefs::Set(this, pref_service);

View File

@@ -104,6 +104,8 @@
// CefURLRequestContextGetter* destruction.
*/
class PrefService;
namespace extensions {
class CefExtensionSystem;
}
@@ -142,6 +144,9 @@ class CefBrowserContext
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) = 0;
// Preferences.
virtual PrefService* GetPrefs() = 0;
CefResourceContext* resource_context() const {
return resource_context_.get();
}

View File

@@ -164,7 +164,7 @@ void CefBrowserContextImpl::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::
@@ -340,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

@@ -87,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 {

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)
@@ -26,6 +46,27 @@ 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 {
return parent_->GetPath();
}
@@ -128,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(
@@ -64,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

@@ -371,6 +371,9 @@ 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*>(
@@ -636,13 +639,13 @@ 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() && !info->is_mime_handler_view()) {
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 " <<
@@ -669,13 +672,13 @@ 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() && !info->is_mime_handler_view()) {
if (!browser.get()) {
LOG(WARNING) << "Found browser id " << info->browser_id() <<
" but no browser object matching frame process id " <<
render_process_id << " and routing id " <<
@@ -2227,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) {
@@ -2375,7 +2380,7 @@ bool CefBrowserHostImpl::HandleContextMenu(
content::WebContents* CefBrowserHostImpl::GetActionableWebContents() {
if (web_contents() && extensions::ExtensionsEnabled()) {
content::WebContents* guest_contents =
extensions::GetGuestForOwnerContents(web_contents());
extensions::GetFullPageGuestForOwnerContents(web_contents());
if (guest_contents)
return guest_contents;
}
@@ -2491,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());
@@ -2651,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(
@@ -2678,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,

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"
@@ -303,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)

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

@@ -37,6 +37,7 @@
#include "ui/aura/window_tree_host.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/win/shell.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/win/hwnd_util.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
#include "ui/views/widget/widget.h"
@@ -637,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:
@@ -809,11 +810,17 @@ bool CefBrowserHostImpl::PlatformCreateWindow() {
CefColorGetB(settings.background_color));
}
// Adjust for potential display scaling.
gfx::Point point = gfx::Point(cr.right, cr.bottom);
float scale = gfx::Screen::GetNativeScreen()->
GetDisplayNearestPoint(point).device_scale_factor();
point = gfx::ToFlooredPoint(gfx::ScalePoint(point, 1.0f / scale));
CefWindowDelegateView* delegate_view =
new CefWindowDelegateView(background_color);
delegate_view->Init(window_info_.window,
web_contents(),
gfx::Rect(0, 0, cr.right, cr.bottom));
gfx::Rect(0, 0, point.x(), point.y()));
window_widget_ = delegate_view->GetWidget();
window_widget_->Show();

View File

@@ -3,78 +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),
is_mime_handler_view_(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::set_mime_handler_view(bool mime_handler_view) {
is_mime_handler_view_ = mime_handler_view;
}
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 =
@@ -86,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())
@@ -103,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;
@@ -115,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,27 +23,70 @@
// 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_; };
bool is_popup() const { return is_popup_; }
bool is_windowless() const { return is_windowless_; }
bool is_mime_handler_view() const { return is_mime_handler_view_; }
void set_windowless(bool windowless);
void set_mime_handler_view(bool mime_handler_view);
// 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);
@@ -49,38 +96,16 @@ 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_;
bool is_mime_handler_view_;
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_;
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

@@ -24,6 +24,7 @@
#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"
@@ -165,6 +166,9 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
}
}
// Triggers initialization of the singleton instance on UI thread.
PluginFinder::GetInstance()->Init();
#if defined(OS_WIN)
PlatformPreMainMessageLoopRun();
#endif

View File

@@ -97,11 +97,11 @@ 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();
params->is_mime_handler_view = info->is_mime_handler_view();
}
void CefBrowserMessageFilter::OnCreateWindow(

View File

@@ -84,7 +84,7 @@ scoped_ptr<PrefService> CefBrowserPrefStore::CreateService() {
new CommandLinePrefStore(command_line));
factory.set_user_prefs(this);
scoped_refptr< user_prefs::PrefRegistrySyncable> registry(
scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
new user_prefs::PrefRegistrySyncable());
// Default settings.
@@ -97,6 +97,8 @@ scoped_ptr<PrefService> CefBrowserPrefStore::CreateService() {
// 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()) {
@@ -120,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

@@ -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() {
@@ -278,3 +277,9 @@ memory::OomPriorityManager* ChromeBrowserProcessStub::GetOomPriorityManager() {
NOTIMPLEMENTED();
return NULL;
}
ShellIntegration::DefaultWebClientState
ChromeBrowserProcessStub::CachedDefaultWebClientState() {
NOTIMPLEMENTED();
return ShellIntegration::UNKNOWN_DEFAULT;
}

View File

@@ -97,6 +97,8 @@ class ChromeBrowserProcessStub : public BrowserProcess {
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

@@ -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

@@ -16,15 +16,15 @@
#include "libcef/browser/devtools_delegate.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/extensions/plugin_info_message_filter.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"
@@ -40,12 +40,13 @@
#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"
@@ -57,7 +58,9 @@
#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"
@@ -265,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);
@@ -358,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);
@@ -430,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;
}
}
@@ -455,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;
}
@@ -513,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 " <<
@@ -532,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;
}
}
@@ -574,9 +580,10 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
content::BrowserContext* browser_context = host->GetBrowserContext();
host->AddFilter(new CefPluginInfoMessageFilter(id,
static_cast<CefBrowserContext*>(browser_context)));
if (extensions::ExtensionsEnabled()) {
host->AddFilter(
new extensions::CefPluginInfoMessageFilter(id, browser_context));
host->AddFilter(
new extensions::ExtensionMessageFilter(id, browser_context));
host->AddFilter(
@@ -712,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)
@@ -724,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));
@@ -858,12 +883,36 @@ 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);
if (!browser.get())
last_create_window_params_.opener_view_id,
&is_guest_view);
DCHECK(browser.get());
if (!browser.get()) {
// 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;
}
CefRefPtr<CefClient> client = browser->GetClient();
bool allow = true;
@@ -942,15 +991,7 @@ void CefContentBrowserClient::OverrideWebkitPrefs(
base::CommandLine::ForCurrentProcess();
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForHost(rvh);
if (!browser.get() && extensions::ExtensionsEnabled()) {
// Retrieve the owner browser, if any.
content::WebContents* owner = extensions::GetOwnerForGuestContents(
content::WebContents::FromRenderViewHost(rvh));
if (owner)
browser = CefBrowserHostImpl::GetBrowserForContents(owner);
}
extensions::GetOwnerBrowserForHost(rvh, NULL);
if (browser.get()) {
// Populate WebPreferences based on CefBrowserSettings.
BrowserToWebSettings(browser->settings(), *prefs);

View File

@@ -51,23 +51,30 @@ 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(

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

@@ -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(
@@ -339,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;
}
@@ -403,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());
@@ -457,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);
}
@@ -479,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.
@@ -491,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

@@ -112,7 +112,7 @@ std::string CefDevToolsDelegate::GetFrontendResource(
}
std::string CefDevToolsDelegate::GetChromeDevToolsURL() {
return base::StringPrintf("%s://%s/devtools.html",
return base::StringPrintf("%s://%s/inspector.html",
content::kChromeDevToolsScheme, scheme::kChromeDevToolsHost);
}

View File

@@ -186,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() {

View File

@@ -4,32 +4,109 @@
#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 {
content::WebContents* GetGuestForOwnerContents(content::WebContents* guest) {
content::WebContentsImpl* guest_impl =
static_cast<content::WebContentsImpl*>(guest);
content::BrowserPluginEmbedder* embedder =
guest_impl->GetBrowserPluginEmbedder();
if (embedder) {
content::BrowserPluginGuest* guest = embedder->GetFullPageGuest();
if (guest)
return guest->web_contents();
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;
}
content::WebContents* GetOwnerForGuestContents(content::WebContents* owner) {
content::WebContentsImpl* owner_impl =
static_cast<content::WebContentsImpl*>(owner);
content::BrowserPluginGuest* guest = owner_impl->GetBrowserPluginGuest();
if (guest)
return guest->embedder_web_contents();
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

@@ -5,17 +5,42 @@
#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 WebContents that owns the specified |guest|, if any.
content::WebContents* GetGuestForOwnerContents(content::WebContents* guest);
// Returns the full-page guest WebContents for the specified |owner|, if any.
content::WebContents* GetFullPageGuestForOwnerContents(
content::WebContents* owner);
// Returns the guest WebContents for the specified |owner|, if any.
content::WebContents* GetOwnerForGuestContents(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

View File

@@ -5,7 +5,7 @@
#include "libcef/browser/extensions/extensions_browser_client.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/extensions/component_extension_resource_manager.h"
#include "libcef/browser/extensions/extension_system_factory.h"
#include "libcef/browser/extensions/extension_web_contents_observer.h"
@@ -125,8 +125,7 @@ bool CefExtensionsBrowserClient::AllowCrossRendererResourceLoad(
PrefService* CefExtensionsBrowserClient::GetPrefServiceForContext(
BrowserContext* context) {
// TODO(extensions): Do we need a per-context PrefService?
return CefContentBrowserClient::Get()->pref_service();
return CefBrowserContextImpl::GetForContext(context)->GetPrefs();
}
void CefExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(

View File

@@ -55,18 +55,20 @@ bool CefMimeHandlerViewGuestDelegate::OnGuestAttached(
content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents);
// Associate state information with the new WebContents.
content::RenderViewHost* view_host = web_contents->GetRenderViewHost();
content::RenderFrameHost* main_frame_host = web_contents->GetMainFrame();
scoped_refptr<CefBrowserInfo> info =
CefContentBrowserClient::Get()->GetOrCreateBrowserInfo(
view_host->GetProcess()->GetID(),
view_host->GetRoutingID(),
main_frame_host->GetProcess()->GetID(),
main_frame_host->GetRoutingID());
info->set_mime_handler_view(true);
CefRefPtr<CefBrowserHostImpl> owner_browser = GetOwnerBrowser(guest_);
// Associate guest state information with the owner browser.
scoped_refptr<CefBrowserInfo> info = owner_browser->browser_info();
info->guest_render_id_manager()->add_render_view_id(
view_host->GetProcess()->GetID(),
view_host->GetRoutingID());
info->guest_render_id_manager()->add_render_frame_id(
main_frame_host->GetProcess()->GetID(),
main_frame_host->GetRoutingID());
if (owner_browser->IsWindowless()) {
// Use the OSR view instead of the default WebContentsViewGuest.
content::WebContentsImpl* web_contents_impl =
@@ -85,8 +87,25 @@ bool CefMimeHandlerViewGuestDelegate::OnGuestAttached(
bool CefMimeHandlerViewGuestDelegate::OnGuestDetached(
content::WebContentsView* guest_view,
content::WebContentsView* parent_view) {
content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents);
content::RenderViewHost* view_host = web_contents->GetRenderViewHost();
content::RenderFrameHost* main_frame_host = web_contents->GetMainFrame();
CefRefPtr<CefBrowserHostImpl> owner_browser = GetOwnerBrowser(guest_);
// Disassociate guest state information with the owner browser.
scoped_refptr<CefBrowserInfo> info = owner_browser->browser_info();
info->guest_render_id_manager()->remove_render_view_id(
view_host->GetProcess()->GetID(),
view_host->GetRoutingID());
info->guest_render_id_manager()->remove_render_frame_id(
main_frame_host->GetProcess()->GetID(),
main_frame_host->GetRoutingID());
// Do nothing when the browser is windowless.
return GetOwnerBrowser(guest_)->IsWindowless();
return owner_browser->IsWindowless();
}
bool CefMimeHandlerViewGuestDelegate::CreateViewForWidget(

View File

@@ -1,217 +0,0 @@
// Copyright 2015 The Chromium Embedded Framework Authors.
// Portions copyright 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/plugin_info_message_filter.h"
#include "libcef/common/cef_messages.h"
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/plugin_service_filter.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/webplugininfo.h"
#include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "url/gurl.h"
using content::PluginService;
using content::WebPluginInfo;
namespace extensions {
namespace {
#if defined(OS_WIN) || defined(OS_MACOSX)
// These are the mime-types of plugins which are known to have PPAPI versions.
const char* kPepperPluginMimeTypes[] = {
"application/pdf",
"application/x-google-chrome-pdf",
"application/x-nacl",
"application/x-pnacl",
"application/vnd.chromium.remoting-viewer",
"application/x-shockwave-flash",
"application/futuresplash",
};
#endif
} // namespace
CefPluginInfoMessageFilter::Context::Context(
int render_process_id,
content::BrowserContext* browser_context)
: render_process_id_(render_process_id),
resource_context_(browser_context->GetResourceContext()) {
}
CefPluginInfoMessageFilter::Context::~Context() {
}
CefPluginInfoMessageFilter::CefPluginInfoMessageFilter(
int render_process_id,
content::BrowserContext* browser_context)
: BrowserMessageFilter(ExtensionMsgStart),
context_(render_process_id, browser_context),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_ptr_factory_(this) {
}
bool CefPluginInfoMessageFilter::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(CefPluginInfoMessageFilter, message)
IPC_MESSAGE_HANDLER_DELAY_REPLY(CefViewHostMsg_GetPluginInfo,
OnGetPluginInfo)
IPC_MESSAGE_UNHANDLED(return false)
IPC_END_MESSAGE_MAP()
return true;
}
void CefPluginInfoMessageFilter::OnDestruct() const {
const_cast<CefPluginInfoMessageFilter*>(this)->
weak_ptr_factory_.InvalidateWeakPtrs();
// Destroy on the UI thread because we contain a |PrefMember|.
content::BrowserThread::DeleteOnUIThread::Destruct(this);
}
CefPluginInfoMessageFilter::~CefPluginInfoMessageFilter() {}
struct CefPluginInfoMessageFilter::GetPluginInfo_Params {
int render_frame_id;
GURL url;
GURL top_origin_url;
std::string mime_type;
};
void CefPluginInfoMessageFilter::OnGetPluginInfo(
int render_frame_id,
const GURL& url,
const GURL& top_origin_url,
const std::string& mime_type,
IPC::Message* reply_msg) {
GetPluginInfo_Params params = {
render_frame_id,
url,
top_origin_url,
mime_type
};
PluginService::GetInstance()->GetPlugins(
base::Bind(&CefPluginInfoMessageFilter::PluginsLoaded,
weak_ptr_factory_.GetWeakPtr(),
params, reply_msg));
}
void CefPluginInfoMessageFilter::PluginsLoaded(
const GetPluginInfo_Params& params,
IPC::Message* reply_msg,
const std::vector<WebPluginInfo>& plugins) {
CefViewHostMsg_GetPluginInfo_Output output;
// This also fills in |actual_mime_type|.
if (context_.FindEnabledPlugin(params.render_frame_id, params.url,
params.top_origin_url, params.mime_type,
&output.status, &output.plugin,
&output.actual_mime_type)) {
context_.DecidePluginStatus(params, output.plugin, &output.status);
}
CefViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, output);
Send(reply_msg);
}
void CefPluginInfoMessageFilter::Context::DecidePluginStatus(
const GetPluginInfo_Params& params,
const WebPluginInfo& plugin,
CefViewHostMsg_GetPluginInfo_Status* status) const {
if (plugin.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) {
CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
// NPAPI plugins are not supported inside <webview> guests.
if (extensions::WebViewRendererState::GetInstance()->IsGuest(
render_process_id_)) {
*status = CefViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported;
return;
}
}
// Check if the plugin is crashing too much.
if (PluginService::GetInstance()->IsPluginUnstable(plugin.path)) {
*status = CefViewHostMsg_GetPluginInfo_Status::kUnauthorized;
return;
}
if (*status == CefViewHostMsg_GetPluginInfo_Status::kAllowed) {
// Allow an embedder of <webview> to block a plugin from being loaded inside
// the guest. In order to do this, set the status to 'Unauthorized' here,
// and update the status as appropriate depending on the response from the
// embedder.
if (extensions::WebViewRendererState::GetInstance()->IsGuest(
render_process_id_)) {
*status = CefViewHostMsg_GetPluginInfo_Status::kUnauthorized;
}
}
}
bool CefPluginInfoMessageFilter::Context::FindEnabledPlugin(
int render_frame_id,
const GURL& url,
const GURL& top_origin_url,
const std::string& mime_type,
CefViewHostMsg_GetPluginInfo_Status* status,
WebPluginInfo* plugin,
std::string* actual_mime_type) const {
*status = CefViewHostMsg_GetPluginInfo_Status::kAllowed;
bool allow_wildcard = true;
std::vector<WebPluginInfo> matching_plugins;
std::vector<std::string> mime_types;
PluginService::GetInstance()->GetPluginInfoArray(
url, mime_type, allow_wildcard, &matching_plugins, &mime_types);
if (matching_plugins.empty()) {
*status = CefViewHostMsg_GetPluginInfo_Status::kNotFound;
#if defined(OS_WIN) || defined(OS_MACOSX)
if (!PluginService::GetInstance()->NPAPIPluginsSupported()) {
// At this point it is not known for sure this is an NPAPI plugin as it
// could be a not-yet-installed Pepper plugin. To avoid notifying on
// these types, bail early based on a blacklist of pepper mime types.
for (auto pepper_mime_type : kPepperPluginMimeTypes)
if (pepper_mime_type == mime_type)
return false;
}
#endif
return false;
}
content::PluginServiceFilter* filter =
PluginService::GetInstance()->GetFilter();
size_t i = 0;
for (; i < matching_plugins.size(); ++i) {
if (!filter || filter->IsPluginAvailable(render_process_id_,
render_frame_id,
resource_context_,
url,
top_origin_url,
&matching_plugins[i])) {
break;
}
}
// If we broke out of the loop, we have found an enabled plugin.
bool enabled = i < matching_plugins.size();
if (!enabled) {
// Otherwise, we only found disabled plugins, so we take the first one.
i = 0;
*status = CefViewHostMsg_GetPluginInfo_Status::kDisabled;
}
*plugin = matching_plugins[i];
*actual_mime_type = mime_types[i];
return enabled;
}
} // namespace extensions

View File

@@ -11,6 +11,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "net/base/mime_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -27,6 +28,10 @@ base::FilePath FilePathFromASCII(const std::string& str) {
}
static std::string GetMimeType(const std::string& filename) {
// Requests should not block on the disk! On POSIX this goes to disk.
// http://code.google.com/p/chromium/issues/detail?id=59849
base::ThreadRestrictions::ScopedAllowIO allow_io;
std::string mime_type;
if (net::GetMimeTypeFromFile(FilePathFromASCII(filename), &mime_type))
return mime_type;

View File

@@ -5,6 +5,7 @@
#include "libcef/browser/menu_creator.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/context_menu_params_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/content_client.h"
#include "base/compiler_specific.h"
@@ -31,12 +32,73 @@ CefString GetLabel(int message_id) {
return label;
}
const int kInvalidCommandId = -1;
const cef_event_flags_t kEmptyEventFlags = static_cast<cef_event_flags_t>(0);
class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback {
public:
typedef base::Callback<void(int,cef_event_flags_t)> Callback;
explicit CefRunContextMenuCallbackImpl(const Callback& callback)
: callback_(callback) {
}
~CefRunContextMenuCallbackImpl() {
if (!callback_.is_null()) {
// The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_UIT()) {
RunNow(callback_, kInvalidCommandId, kEmptyEventFlags);
} else {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefRunContextMenuCallbackImpl::RunNow, callback_,
kInvalidCommandId, kEmptyEventFlags));
}
}
}
void Continue(int command_id, cef_event_flags_t event_flags) override {
if (CEF_CURRENTLY_ON_UIT()) {
if (!callback_.is_null()) {
RunNow(callback_, command_id, event_flags);
callback_.Reset();
}
} else {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefRunContextMenuCallbackImpl::Continue, this,
command_id, event_flags));
}
}
void Cancel() override {
Continue(kInvalidCommandId, kEmptyEventFlags);
}
void Disconnect() {
callback_.Reset();
}
private:
static void RunNow(const Callback& callback,
int command_id,
cef_event_flags_t event_flags) {
CEF_REQUIRE_UIT();
callback.Run(command_id, event_flags);
}
Callback callback_;
IMPLEMENT_REFCOUNTING(CefRunContextMenuCallbackImpl);
DISALLOW_COPY_AND_ASSIGN(CefRunContextMenuCallbackImpl);
};
} // namespace
CefMenuCreator::CefMenuCreator(content::WebContents* web_contents,
CefBrowserHostImpl* browser)
: content::WebContentsObserver(web_contents),
browser_(browser) {
browser_(browser),
custom_menu_callback_(NULL),
weak_ptr_factory_(this) {
DCHECK(web_contents);
DCHECK(browser_);
model_ = new CefMenuModelImpl(this);
@@ -77,39 +139,75 @@ bool CefMenuCreator::CreateContextMenu(
// Create the default menu model.
CreateDefaultModel();
bool custom_menu = false;
DCHECK(!custom_menu_callback_);
// Give the client a chance to modify the model.
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefContextMenuHandler> handler =
client->GetContextMenuHandler();
if (handler.get()) {
CefRefPtr<CefContextMenuParamsImpl> paramsPtr(
new CefContextMenuParamsImpl(&params_));
CefRefPtr<CefContextMenuHandler> handler =
client->GetContextMenuHandler();
if (handler.get()) {
CefRefPtr<CefContextMenuParamsImpl> paramsPtr(
new CefContextMenuParamsImpl(&params_));
CefRefPtr<CefFrame> frame = browser_->GetFocusedFrame();
handler->OnBeforeContextMenu(browser_,
browser_->GetFocusedFrame(),
paramsPtr.get(),
model_.get());
handler->OnBeforeContextMenu(browser_,
frame,
paramsPtr.get(),
model_.get());
// Do not keep references to the parameters in the callback.
paramsPtr->Detach(NULL);
DCHECK(paramsPtr->HasOneRef());
DCHECK(model_->VerifyRefCount());
MenuWillShow(model_);
// Menu is empty so notify the client and return.
if (model_->GetCount() == 0) {
MenuClosed(model_);
return true;
if (model_->GetCount() > 0) {
CefRefPtr<CefRunContextMenuCallbackImpl> callbackImpl(
new CefRunContextMenuCallbackImpl(
base::Bind(&CefMenuCreator::ExecuteCommandCallback,
weak_ptr_factory_.GetWeakPtr())));
// This reference will be cleared when the callback is executed or
// the callback object is deleted.
custom_menu_callback_ = callbackImpl.get();
if (handler->RunContextMenu(browser_,
frame,
paramsPtr.get(),
model_.get(),
callbackImpl.get())) {
custom_menu = true;
} else {
// Callback should not be executed if the handler returns false.
DCHECK(custom_menu_callback_);
custom_menu_callback_ = NULL;
callbackImpl->Disconnect();
}
}
// Do not keep references to the parameters in the callback.
paramsPtr->Detach(NULL);
DCHECK(paramsPtr->HasOneRef());
DCHECK(model_->VerifyRefCount());
// Menu is empty so notify the client and return.
if (model_->GetCount() == 0 && !custom_menu) {
MenuClosed(model_);
return true;
}
}
}
if (custom_menu)
return true;
return runner_->RunContextMenu(this);
}
void CefMenuCreator::CancelContextMenu() {
if (IsShowingContextMenu())
runner_->CancelContextMenu();
if (IsShowingContextMenu()) {
if (custom_menu_callback_)
custom_menu_callback_->Cancel();
else
runner_->CancelContextMenu();
}
}
bool CefMenuCreator::CreateRunner() {
@@ -135,26 +233,26 @@ void CefMenuCreator::ExecuteCommand(CefRefPtr<CefMenuModelImpl> source,
// Give the client a chance to handle the command.
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefContextMenuHandler> handler =
client->GetContextMenuHandler();
if (handler.get()) {
CefRefPtr<CefContextMenuParamsImpl> paramsPtr(
new CefContextMenuParamsImpl(&params_));
CefRefPtr<CefContextMenuHandler> handler =
client->GetContextMenuHandler();
if (handler.get()) {
CefRefPtr<CefContextMenuParamsImpl> paramsPtr(
new CefContextMenuParamsImpl(&params_));
bool handled = handler->OnContextMenuCommand(
browser_,
browser_->GetFocusedFrame(),
paramsPtr.get(),
command_id,
event_flags);
bool handled = handler->OnContextMenuCommand(
browser_,
browser_->GetFocusedFrame(),
paramsPtr.get(),
command_id,
event_flags);
// Do not keep references to the parameters in the callback.
paramsPtr->Detach(NULL);
DCHECK(paramsPtr->HasOneRef());
// Do not keep references to the parameters in the callback.
paramsPtr->Detach(NULL);
DCHECK(paramsPtr->HasOneRef());
if (handled)
return;
}
if (handled)
return;
}
}
// Execute the default command handling.
@@ -169,6 +267,10 @@ void CefMenuCreator::MenuWillShow(CefRefPtr<CefMenuModelImpl> source) {
if (!web_contents())
return;
// May be called multiple times.
if (IsShowingContextMenu())
return;
// Notify the host before showing the context menu.
content::RenderWidgetHostView* view =
web_contents()->GetRenderWidgetHostView();
@@ -181,31 +283,56 @@ void CefMenuCreator::MenuClosed(CefRefPtr<CefMenuModelImpl> source) {
if (source.get() != model_.get())
return;
if (!web_contents())
return;
DCHECK(IsShowingContextMenu());
// Notify the client.
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefContextMenuHandler> handler =
client->GetContextMenuHandler();
if (handler.get()) {
handler->OnContextMenuDismissed(browser_, browser_->GetFocusedFrame());
}
CefRefPtr<CefContextMenuHandler> handler =
client->GetContextMenuHandler();
if (handler.get()) {
handler->OnContextMenuDismissed(browser_, browser_->GetFocusedFrame());
}
}
if (IsShowingContextMenu() && web_contents()) {
// Notify the host after closing the context menu.
content::RenderWidgetHostView* view =
web_contents()->GetRenderWidgetHostView();
if (view)
view->SetShowingContextMenu(false);
web_contents()->NotifyContextMenuClosed(params_.custom_context);
}
// Notify the host after closing the context menu.
content::RenderWidgetHostView* view =
web_contents()->GetRenderWidgetHostView();
if (view)
view->SetShowingContextMenu(false);
web_contents()->NotifyContextMenuClosed(params_.custom_context);
}
bool CefMenuCreator::FormatLabel(base::string16& label) {
return runner_->FormatLabel(label);
}
void CefMenuCreator::ExecuteCommandCallback(int command_id,
cef_event_flags_t event_flags) {
DCHECK(IsShowingContextMenu());
DCHECK(custom_menu_callback_);
if (command_id != kInvalidCommandId)
ExecuteCommand(model_, command_id, event_flags);
MenuClosed(model_);
custom_menu_callback_ = NULL;
}
void CefMenuCreator::CreateDefaultModel() {
if (!params_.custom_items.empty()) {
// Custom menu items originating from the renderer process. For example,
// plugin placeholder menu items or Flash menu items.
for (size_t i = 0; i < params_.custom_items.size(); ++i) {
content::MenuItem menu_item = params_.custom_items[i];
menu_item.action += MENU_ID_CUSTOM_FIRST;
DCHECK_LE(static_cast<int>(menu_item.action), MENU_ID_CUSTOM_LAST);
model_->AddMenuItem(menu_item);
}
return;
}
if (params_.is_editable) {
// Editable node.
model_->AddItem(MENU_ID_UNDO, GetLabel(IDS_MENU_UNDO));
@@ -284,6 +411,14 @@ void CefMenuCreator::CreateDefaultModel() {
}
void CefMenuCreator::ExecuteDefaultCommand(int command_id) {
if (IsCustomContextMenuCommand(command_id)) {
if (web_contents()) {
web_contents()->ExecuteCustomContextMenuCommand(
command_id - MENU_ID_CUSTOM_FIRST, params_.custom_context);
}
return;
}
// If the user chose a replacement word for a misspelling, replace it here.
if (command_id >= MENU_ID_SPELLCHECK_SUGGESTION_0 &&
command_id <= MENU_ID_SPELLCHECK_SUGGESTION_LAST) {
@@ -358,3 +493,20 @@ void CefMenuCreator::ExecuteDefaultCommand(int command_id) {
break;
}
}
bool CefMenuCreator::IsCustomContextMenuCommand(int command_id) {
// Verify that the command ID is in the correct range.
if (command_id < MENU_ID_CUSTOM_FIRST || command_id > MENU_ID_CUSTOM_LAST)
return false;
command_id -= MENU_ID_CUSTOM_FIRST;
// Verify that the specific command ID was passed from the renderer process.
if (!params_.custom_items.empty()) {
for (size_t i = 0; i < params_.custom_items.size(); ++i) {
if (static_cast<int>(params_.custom_items[i].action) == command_id)
return true;
}
}
return false;
}

View File

@@ -9,6 +9,7 @@
#include "libcef/browser/menu_model_impl.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/context_menu_params.h"
@@ -17,6 +18,7 @@ class RenderFrameHost;
class WebContents;
};
class CefRunContextMenuCallback;
class CefBrowserHostImpl;
class CefMenuCreator : public CefMenuModelImpl::Delegate,
@@ -58,11 +60,17 @@ class CefMenuCreator : public CefMenuModelImpl::Delegate,
void MenuClosed(CefRefPtr<CefMenuModelImpl> source) override;
bool FormatLabel(base::string16& label) override;
void ExecuteCommandCallback(int command_id,
cef_event_flags_t event_flags);
// Create the default menu model.
void CreateDefaultModel();
// Execute the default command handling.
void ExecuteDefaultCommand(int command_id);
// Returns true if the specified id is a custom context menu command.
bool IsCustomContextMenuCommand(int command_id);
// CefBrowserHostImpl pointer is guaranteed to outlive this object.
CefBrowserHostImpl* browser_;
@@ -70,6 +78,12 @@ class CefMenuCreator : public CefMenuModelImpl::Delegate,
content::ContextMenuParams params_;
scoped_ptr<Runner> runner_;
// Not owned by this class.
CefRunContextMenuCallback* custom_menu_callback_;
// Must be the last member.
base::WeakPtrFactory<CefMenuCreator> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefMenuCreator);
};

View File

@@ -8,6 +8,8 @@
#include "base/message_loop/message_loop.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/screen.h"
#include "ui/views/controls/menu/menu_2.h"
CefMenuCreatorRunnerWin::CefMenuCreatorRunnerWin() {
@@ -46,6 +48,11 @@ bool CefMenuCreatorRunnerWin::RunContextMenu(CefMenuCreator* manager) {
const gfx::Rect& bounds_in_screen = window->GetBoundsInScreen();
screen_point = gfx::Point(bounds_in_screen.x() + manager->params().x,
bounds_in_screen.y() + manager->params().y);
// Adjust for potential display scaling.
float scale = gfx::Screen::GetScreenFor(window)->
GetDisplayNearestWindow(window).device_scale_factor();
screen_point = gfx::ToFlooredPoint(gfx::ScalePoint(screen_point, scale));
}
// Show the menu. Blocks until the menu is dismissed.

View File

@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "content/public/common/menu_item.h"
#include "ui/base/accelerators/accelerator.h"
namespace {
@@ -661,6 +662,41 @@ bool CefMenuModelImpl::VerifyRefCount() {
return true;
}
void CefMenuModelImpl::AddMenuItem(const content::MenuItem& menu_item) {
const int command_id = static_cast<int>(menu_item.action);
switch (menu_item.type) {
case content::MenuItem::OPTION:
AddItem(command_id, menu_item.label);
break;
case content::MenuItem::CHECKABLE_OPTION:
AddCheckItem(command_id, menu_item.label);
break;
case content::MenuItem::GROUP:
AddRadioItem(command_id, menu_item.label, 0);
break;
case content::MenuItem::SEPARATOR:
AddSeparator();
break;
case content::MenuItem::SUBMENU: {
CefRefPtr<CefMenuModelImpl> sub_menu = static_cast<CefMenuModelImpl*>(
AddSubMenu(command_id, menu_item.label).get());
for (size_t i = 0; i < menu_item.submenu.size(); ++i)
sub_menu->AddMenuItem(menu_item.submenu[i]);
break;
}
}
if (!menu_item.enabled && menu_item.type != content::MenuItem::SEPARATOR)
SetEnabled(command_id, false);
if (menu_item.checked &&
(menu_item.type == content::MenuItem::CHECKABLE_OPTION ||
menu_item.type == content::MenuItem::GROUP)) {
SetChecked(command_id, true);
}
}
void CefMenuModelImpl::AppendItem(const Item& item) {
ValidateItem(item);
items_.push_back(item);

View File

@@ -15,6 +15,10 @@
#include "base/threading/platform_thread.h"
#include "ui/base/models/menu_model.h"
namespace content {
struct MenuItem;
}
class CefMenuModelImpl : public CefMenuModel {
public:
class Delegate {
@@ -112,6 +116,9 @@ class CefMenuModelImpl : public CefMenuModel {
// Verify that only a single reference exists to all CefMenuModelImpl objects.
bool VerifyRefCount();
// Helper for adding custom menu items originating from the renderer process.
void AddMenuItem(const content::MenuItem& menu_item);
ui::MenuModel* model() { return model_.get(); }
Delegate* delegate() { return delegate_; }
void set_delegate(Delegate* delegate) { delegate_ = NULL; }

View File

@@ -5,6 +5,7 @@
#include "libcef/browser/pepper/browser_pepper_host_factory.h"
#include "libcef/browser/pepper/pepper_flash_browser_host.h"
#include "libcef/browser/pepper/pepper_isolated_file_system_message_filter.h"
#include "build/build_config.h"
#include "chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h"
@@ -56,6 +57,21 @@ scoped_ptr<ResourceHost> CefBrowserPepperHostFactory::CreateResourceHost(
}
}
// Permissions for the following interfaces will be checked at the
// time of the corresponding instance's methods calls (because
// permission check can be performed only on the UI
// thread). Currently these interfaces are available only for
// whitelisted apps which may not have access to the other private
// interfaces.
if (message.type() == PpapiHostMsg_IsolatedFileSystem_Create::ID) {
PepperIsolatedFileSystemMessageFilter* isolated_fs_filter =
PepperIsolatedFileSystemMessageFilter::Create(instance, host_);
if (!isolated_fs_filter)
return scoped_ptr<ResourceHost>();
return scoped_ptr<ResourceHost>(
new MessageFilterHost(host, instance, resource, isolated_fs_filter));
}
NOTREACHED() << "Unhandled message type: " << message.type();
return scoped_ptr<ResourceHost>();
}

View File

@@ -0,0 +1,192 @@
// Copyright 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.
#include "libcef/browser/pepper/pepper_isolated_file_system_message_filter.h"
#include "libcef/browser/browser_context_impl.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pepper_permission_util.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_view_host.h"
#if defined(ENABLE_EXTENSIONS)
#include "extensions/browser/extension_registry.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
#endif
#include "ppapi/c/pp_errors.h"
#include "ppapi/host/dispatch_host_message.h"
#include "ppapi/host/host_message_context.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/file_system_util.h"
#include "storage/browser/fileapi/isolated_context.h"
namespace {
const char* kPredefinedAllowedCrxFsOrigins[] = {
"6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/234789
"4EB74897CB187C7633357C2FE832E0AD6A44883A" // see crbug.com/234789
};
} // namespace
// static
PepperIsolatedFileSystemMessageFilter*
PepperIsolatedFileSystemMessageFilter::Create(PP_Instance instance,
content::BrowserPpapiHost* host) {
int render_process_id;
int unused_render_frame_id;
if (!host->GetRenderFrameIDsForInstance(
instance, &render_process_id, &unused_render_frame_id)) {
return NULL;
}
return new PepperIsolatedFileSystemMessageFilter(
render_process_id,
host->GetProfileDataDirectory(),
host->GetDocumentURLForInstance(instance),
host->GetPpapiHost());
}
PepperIsolatedFileSystemMessageFilter::PepperIsolatedFileSystemMessageFilter(
int render_process_id,
const base::FilePath& profile_directory,
const GURL& document_url,
ppapi::host::PpapiHost* ppapi_host)
: render_process_id_(render_process_id),
profile_directory_(profile_directory),
document_url_(document_url),
ppapi_host_(ppapi_host) {
for (size_t i = 0; i < arraysize(kPredefinedAllowedCrxFsOrigins); ++i)
allowed_crxfs_origins_.insert(kPredefinedAllowedCrxFsOrigins[i]);
}
PepperIsolatedFileSystemMessageFilter::
~PepperIsolatedFileSystemMessageFilter() {}
scoped_refptr<base::TaskRunner>
PepperIsolatedFileSystemMessageFilter::OverrideTaskRunnerForMessage(
const IPC::Message& msg) {
// In order to reach ExtensionSystem, we need to get ProfileManager first.
// ProfileManager lives in UI thread, so we need to do this in UI thread.
return content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI);
}
int32_t PepperIsolatedFileSystemMessageFilter::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
PPAPI_BEGIN_MESSAGE_MAP(PepperIsolatedFileSystemMessageFilter, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_IsolatedFileSystem_BrowserOpen,
OnOpenFileSystem)
PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
std::string PepperIsolatedFileSystemMessageFilter::CreateCrxFileSystem(
content::BrowserContext* profile) {
#if defined(ENABLE_EXTENSIONS)
const extensions::Extension* extension =
extensions::ExtensionRegistry::Get(profile)->enabled_extensions().GetByID(
document_url_.host());
if (!extension)
return std::string();
// First level directory for isolated filesystem to lookup.
std::string kFirstLevelDirectory("crxfs");
return storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath(
storage::kFileSystemTypeNativeLocal,
std::string(),
extension->path(),
&kFirstLevelDirectory);
#else
return std::string();
#endif
}
int32_t PepperIsolatedFileSystemMessageFilter::OnOpenFileSystem(
ppapi::host::HostMessageContext* context,
PP_IsolatedFileSystemType_Private type) {
switch (type) {
case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_INVALID:
break;
case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_CRX:
return OpenCrxFileSystem(context);
case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_PLUGINPRIVATE:
return OpenPluginPrivateFileSystem(context);
}
NOTREACHED();
context->reply_msg =
PpapiPluginMsg_IsolatedFileSystem_BrowserOpenReply(std::string());
return PP_ERROR_FAILED;
}
int32_t PepperIsolatedFileSystemMessageFilter::OpenCrxFileSystem(
ppapi::host::HostMessageContext* context) {
#if defined(ENABLE_EXTENSIONS)
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
scoped_refptr<CefBrowserContextImpl> browser_context =
CefBrowserContextImpl::GetForCachePath(profile_directory_);
DCHECK(browser_context);
const extensions::ExtensionSet* extension_set = NULL;
if (browser_context) {
extension_set = &extensions::ExtensionRegistry::Get(browser_context.get())->
enabled_extensions();
}
if (!chrome::IsExtensionOrSharedModuleWhitelisted(
document_url_, extension_set, allowed_crxfs_origins_) &&
!chrome::IsHostAllowedByCommandLine(
document_url_, extension_set, switches::kAllowNaClCrxFsAPI)) {
LOG(ERROR) << "Host " << document_url_.host() << " cannot use CrxFs API.";
return PP_ERROR_NOACCESS;
}
// TODO(raymes): When we remove FileSystem from the renderer, we should create
// a pending PepperFileSystemBrowserHost here with the fsid and send the
// pending host ID back to the plugin.
const std::string fsid = CreateCrxFileSystem(browser_context.get());
if (fsid.empty()) {
context->reply_msg =
PpapiPluginMsg_IsolatedFileSystem_BrowserOpenReply(std::string());
return PP_ERROR_NOTSUPPORTED;
}
// Grant readonly access of isolated filesystem to renderer process.
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
policy->GrantReadFileSystem(render_process_id_, fsid);
context->reply_msg = PpapiPluginMsg_IsolatedFileSystem_BrowserOpenReply(fsid);
return PP_OK;
#else
return PP_ERROR_NOTSUPPORTED;
#endif
}
int32_t PepperIsolatedFileSystemMessageFilter::OpenPluginPrivateFileSystem(
ppapi::host::HostMessageContext* context) {
DCHECK(ppapi_host_);
// Only plugins with private permission can open the filesystem.
if (!ppapi_host_->permissions().HasPermission(ppapi::PERMISSION_PRIVATE))
return PP_ERROR_NOACCESS;
const std::string& root_name = ppapi::IsolatedFileSystemTypeToRootName(
PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_PLUGINPRIVATE);
const std::string& fsid =
storage::IsolatedContext::GetInstance()->RegisterFileSystemForVirtualPath(
storage::kFileSystemTypePluginPrivate, root_name, base::FilePath());
// Grant full access of isolated filesystem to renderer process.
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
policy->GrantCreateReadWriteFileSystem(render_process_id_, fsid);
context->reply_msg = PpapiPluginMsg_IsolatedFileSystem_BrowserOpenReply(fsid);
return PP_OK;
}

View File

@@ -0,0 +1,76 @@
// Copyright 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_BROWSER_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_
#define CEF_LIBCEF_BROWSER_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_
#include <set>
#include <string>
#include "base/files/file_path.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/private/ppb_isolated_file_system_private.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/host/resource_message_filter.h"
#include "url/gurl.h"
namespace content {
class BrowserContext;
class BrowserPpapiHost;
}
namespace ppapi {
namespace host {
struct HostMessageContext;
} // namespace host
} // namespace ppapi
class PepperIsolatedFileSystemMessageFilter
: public ppapi::host::ResourceMessageFilter {
public:
static PepperIsolatedFileSystemMessageFilter* Create(
PP_Instance instance,
content::BrowserPpapiHost* host);
// ppapi::host::ResourceMessageFilter implementation.
scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
const IPC::Message& msg) override;
int32_t OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) override;
private:
PepperIsolatedFileSystemMessageFilter(int render_process_id,
const base::FilePath& profile_directory,
const GURL& document_url,
ppapi::host::PpapiHost* ppapi_host_);
~PepperIsolatedFileSystemMessageFilter() override;
// Returns filesystem id of isolated filesystem if valid, or empty string
// otherwise. This must run on the UI thread because ProfileManager only
// allows access on that thread.
std::string CreateCrxFileSystem(content::BrowserContext* profile);
int32_t OnOpenFileSystem(ppapi::host::HostMessageContext* context,
PP_IsolatedFileSystemType_Private type);
int32_t OpenCrxFileSystem(ppapi::host::HostMessageContext* context);
int32_t OpenPluginPrivateFileSystem(ppapi::host::HostMessageContext* context);
const int render_process_id_;
// Keep a copy from original thread.
const base::FilePath profile_directory_;
const GURL document_url_;
// Not owned by this object.
ppapi::host::PpapiHost* ppapi_host_;
// Set of origins that can use CrxFs private APIs from NaCl.
std::set<std::string> allowed_crxfs_origins_;
DISALLOW_COPY_AND_ASSIGN(PepperIsolatedFileSystemMessageFilter);
};
#endif // CEF_LIBCEF_BROWSER_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_

View File

@@ -0,0 +1,504 @@
// Copyright 2015 The Chromium Embedded Framework Authors.
// Portions copyright 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/plugins/plugin_info_message_filter.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/plugins/plugin_service_filter.h"
#include "libcef/browser/web_plugin_impl.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/common/pref_names.h"
#include "components/content_settings/core/browser/content_settings_utils.h"
#include "components/content_settings/core/browser/plugins_field_trial.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/plugin_service_filter.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/webplugininfo.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/webview_info.h"
#include "url/gurl.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
#if defined(OS_WIN)
#include "base/win/metro.h"
#endif
#if !defined(DISABLE_NACL)
#include "components/nacl/common/nacl_constants.h"
#endif
using content::PluginService;
using content::WebPluginInfo;
namespace {
#if defined(OS_WIN) || defined(OS_MACOSX)
// These are the mime-types of plugins which are known to have PPAPI versions.
const char* kPepperPluginMimeTypes[] = {
"application/pdf",
"application/x-google-chrome-pdf",
"application/x-nacl",
"application/x-pnacl",
"application/vnd.chromium.remoting-viewer",
"application/x-shockwave-flash",
"application/futuresplash",
};
#endif
#if defined(ENABLE_PEPPER_CDMS)
enum PluginAvailabilityStatusForUMA {
PLUGIN_NOT_REGISTERED,
PLUGIN_AVAILABLE,
PLUGIN_DISABLED,
PLUGIN_AVAILABILITY_STATUS_MAX
};
static void SendPluginAvailabilityUMA(const std::string& mime_type,
PluginAvailabilityStatusForUMA status) {
#if defined(WIDEVINE_CDM_AVAILABLE)
// Only report results for Widevine CDM.
if (mime_type != kWidevineCdmPluginMimeType)
return;
UMA_HISTOGRAM_ENUMERATION("Plugin.AvailabilityStatus.WidevineCdm",
status, PLUGIN_AVAILABILITY_STATUS_MAX);
#endif // defined(WIDEVINE_CDM_AVAILABLE)
}
#endif // defined(ENABLE_PEPPER_CDMS)
void ReportMetrics(const std::string& mime_type,
const GURL& url,
const GURL& origin_url) {
}
#if defined(ENABLE_EXTENSIONS)
// Returns whether a request from a plugin to load |resource| from a renderer
// with process id |process_id| is a request for an internal resource by an app
// listed in |accessible_resources| in its manifest.
bool IsPluginLoadingAccessibleResourceInWebView(
extensions::ExtensionRegistry* extension_registry,
int process_id,
const GURL& resource) {
extensions::WebViewRendererState* renderer_state =
extensions::WebViewRendererState::GetInstance();
std::string partition_id;
if (!renderer_state->IsGuest(process_id) ||
!renderer_state->GetPartitionID(process_id, &partition_id)) {
return false;
}
const std::string extension_id = resource.host();
const extensions::Extension* extension =
extension_registry->GetExtensionById(extension_id,
extensions::ExtensionRegistry::ENABLED);
if (!extension)
return false;
const extensions::WebviewInfo* webview_info =
static_cast<const extensions::WebviewInfo*>(extension->GetManifestData(
extensions::manifest_keys::kWebviewAccessibleResources));
if (!webview_info ||
!webview_info->IsResourceWebviewAccessible(extension, partition_id,
resource.path())) {
return false;
}
// Make sure the renderer making the request actually belongs to the
// same extension.
std::string owner_extension;
return renderer_state->GetOwnerInfo(process_id, nullptr, &owner_extension) &&
owner_extension == extension_id;
}
#endif // defined(ENABLE_EXTENSIONS)
} // namespace
CefPluginInfoMessageFilter::Context::Context(
int render_process_id,
CefBrowserContext* profile)
: render_process_id_(render_process_id),
resource_context_(profile->GetResourceContext()) {
#if defined(ENABLE_EXTENSIONS)
if (extensions::ExtensionsEnabled())
extension_registry_ = extensions::ExtensionRegistry::Get(profile);
#endif
allow_outdated_plugins_.Init(prefs::kPluginsAllowOutdated,
profile->GetPrefs());
allow_outdated_plugins_.MoveToThread(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::IO));
always_authorize_plugins_.Init(prefs::kPluginsAlwaysAuthorize,
profile->GetPrefs());
always_authorize_plugins_.MoveToThread(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::IO));
}
CefPluginInfoMessageFilter::Context::~Context() {
}
CefPluginInfoMessageFilter::CefPluginInfoMessageFilter(
int render_process_id,
CefBrowserContext* profile)
: BrowserMessageFilter(ExtensionMsgStart),
context_(render_process_id, profile),
browser_context_(profile),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_ptr_factory_(this) {
}
bool CefPluginInfoMessageFilter::OnMessageReceived(
const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(CefPluginInfoMessageFilter, message)
IPC_MESSAGE_HANDLER_DELAY_REPLY(CefViewHostMsg_GetPluginInfo,
OnGetPluginInfo)
#if defined(ENABLE_PEPPER_CDMS)
IPC_MESSAGE_HANDLER(
CefViewHostMsg_IsInternalPluginAvailableForMimeType,
OnIsInternalPluginAvailableForMimeType)
#endif
IPC_MESSAGE_UNHANDLED(return false)
IPC_END_MESSAGE_MAP()
return true;
}
void CefPluginInfoMessageFilter::OnDestruct() const {
const_cast<CefPluginInfoMessageFilter*>(this)->
weak_ptr_factory_.InvalidateWeakPtrs();
// Destroy on the UI thread because we contain a |PrefMember|.
content::BrowserThread::DeleteOnUIThread::Destruct(this);
}
CefPluginInfoMessageFilter::~CefPluginInfoMessageFilter() {}
struct CefPluginInfoMessageFilter::GetPluginInfo_Params {
int render_frame_id;
GURL url;
GURL top_origin_url;
std::string mime_type;
};
void CefPluginInfoMessageFilter::OnGetPluginInfo(
int render_frame_id,
const GURL& url,
const GURL& top_origin_url,
const std::string& mime_type,
IPC::Message* reply_msg) {
GetPluginInfo_Params params = {
render_frame_id,
url,
top_origin_url,
mime_type
};
PluginService::GetInstance()->GetPlugins(
base::Bind(&CefPluginInfoMessageFilter::PluginsLoaded,
weak_ptr_factory_.GetWeakPtr(),
params, reply_msg));
}
void CefPluginInfoMessageFilter::PluginsLoaded(
const GetPluginInfo_Params& params,
IPC::Message* reply_msg,
const std::vector<WebPluginInfo>& plugins) {
CefViewHostMsg_GetPluginInfo_Output output;
CefRefPtr<CefRequestContextHandler> handler =
browser_context_->GetHandler();
// This also fills in |actual_mime_type|.
scoped_ptr<PluginMetadata> plugin_metadata;
context_.FindEnabledPlugin(params, handler.get(),
&output.status, &output.plugin,
&output.actual_mime_type,
&plugin_metadata);
if (plugin_metadata) {
output.group_identifier = plugin_metadata->identifier();
output.group_name = plugin_metadata->name();
}
CefViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, output);
Send(reply_msg);
if (output.status !=
CefViewHostMsg_GetPluginInfo_Status::kNotFound) {
main_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&ReportMetrics, output.actual_mime_type,
params.url, params.top_origin_url));
}
}
#if defined(ENABLE_PEPPER_CDMS)
void CefPluginInfoMessageFilter::OnIsInternalPluginAvailableForMimeType(
const std::string& mime_type,
bool* is_available,
std::vector<base::string16>* additional_param_names,
std::vector<base::string16>* additional_param_values) {
std::vector<WebPluginInfo> plugins;
PluginService::GetInstance()->GetInternalPlugins(&plugins);
bool is_plugin_disabled = false;
for (size_t i = 0; i < plugins.size(); ++i) {
const WebPluginInfo& plugin = plugins[i];
const std::vector<content::WebPluginMimeType>& mime_types =
plugin.mime_types;
for (size_t j = 0; j < mime_types.size(); ++j) {
if (mime_types[j].mime_type == mime_type) {
if (!context_.IsPluginEnabled(plugin)) {
is_plugin_disabled = true;
break;
}
*is_available = true;
*additional_param_names = mime_types[j].additional_param_names;
*additional_param_values = mime_types[j].additional_param_values;
SendPluginAvailabilityUMA(mime_type, PLUGIN_AVAILABLE);
return;
}
}
}
*is_available = false;
SendPluginAvailabilityUMA(
mime_type, is_plugin_disabled ? PLUGIN_DISABLED : PLUGIN_NOT_REGISTERED);
}
#endif // defined(ENABLE_PEPPER_CDMS)
void CefPluginInfoMessageFilter::Context::DecidePluginStatus(
const GetPluginInfo_Params& params,
const WebPluginInfo& plugin,
const PluginMetadata* plugin_metadata,
CefViewHostMsg_GetPluginInfo_Status* status) const {
#if defined(OS_WIN)
if (plugin.type == WebPluginInfo::PLUGIN_TYPE_NPAPI &&
base::win::IsMetroProcess()) {
*status = CefViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported;
return;
}
#endif
if (plugin.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) {
CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
// NPAPI plugins are not supported inside <webview> guests.
#if defined(ENABLE_EXTENSIONS)
if (extensions::WebViewRendererState::GetInstance()->IsGuest(
render_process_id_)) {
*status = CefViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported;
return;
}
#endif
}
ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT;
bool uses_default_content_setting = true;
bool is_managed = false;
// Check plugin content settings. The primary URL is the top origin URL and
// the secondary URL is the plugin URL.
GetPluginContentSetting(plugin, params.top_origin_url, params.url,
plugin_metadata->identifier(), &plugin_setting,
&uses_default_content_setting, &is_managed);
// TODO(tommycli): Remove once we deprecate the plugin ASK policy.
bool legacy_ask_user = plugin_setting == CONTENT_SETTING_ASK;
plugin_setting = content_settings::PluginsFieldTrial::EffectiveContentSetting(
CONTENT_SETTINGS_TYPE_PLUGINS, plugin_setting);
DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT);
DCHECK(plugin_setting != CONTENT_SETTING_ASK);
PluginMetadata::SecurityStatus plugin_status =
plugin_metadata->GetSecurityStatus(plugin);
#if defined(ENABLE_PLUGIN_INSTALLATION)
// Check if the plugin is outdated.
if (plugin_status == PluginMetadata::SECURITY_STATUS_OUT_OF_DATE &&
!allow_outdated_plugins_.GetValue()) {
if (allow_outdated_plugins_.IsManaged()) {
*status = CefViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed;
} else {
*status = CefViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked;
}
return;
}
#endif
// Check if the plugin requires authorization.
if (plugin_status ==
PluginMetadata::SECURITY_STATUS_REQUIRES_AUTHORIZATION &&
plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS &&
plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS &&
plugin.type != WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN &&
!always_authorize_plugins_.GetValue() &&
plugin_setting != CONTENT_SETTING_BLOCK &&
uses_default_content_setting) {
*status = CefViewHostMsg_GetPluginInfo_Status::kUnauthorized;
return;
}
// Check if the plugin is crashing too much.
if (PluginService::GetInstance()->IsPluginUnstable(plugin.path) &&
!always_authorize_plugins_.GetValue() &&
plugin_setting != CONTENT_SETTING_BLOCK &&
uses_default_content_setting) {
*status = CefViewHostMsg_GetPluginInfo_Status::kUnauthorized;
return;
}
#if defined(ENABLE_EXTENSIONS)
// If an app has explicitly made internal resources available by listing them
// in |accessible_resources| in the manifest, then allow them to be loaded by
// plugins inside a guest-view.
if (extensions::ExtensionsEnabled() &&
params.url.SchemeIs(extensions::kExtensionScheme) && !is_managed &&
plugin_setting == CONTENT_SETTING_BLOCK &&
IsPluginLoadingAccessibleResourceInWebView(
extension_registry_, render_process_id_, params.url)) {
plugin_setting = CONTENT_SETTING_ALLOW;
}
#endif // defined(ENABLE_EXTENSIONS)
if (plugin_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) {
*status = CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
} else if (plugin_setting == CONTENT_SETTING_BLOCK) {
// For managed users with the ASK policy, we allow manually running plugins
// via context menu. This is the closest to admin intent.
*status = is_managed && !legacy_ask_user
? CefViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy
: CefViewHostMsg_GetPluginInfo_Status::kBlocked;
}
if (*status == CefViewHostMsg_GetPluginInfo_Status::kAllowed) {
// Allow an embedder of <webview> to block a plugin from being loaded inside
// the guest. In order to do this, set the status to 'Unauthorized' here,
// and update the status as appropriate depending on the response from the
// embedder.
#if defined(ENABLE_EXTENSIONS)
if (extensions::WebViewRendererState::GetInstance()->IsGuest(
render_process_id_)) {
*status = CefViewHostMsg_GetPluginInfo_Status::kUnauthorized;
}
#endif
}
}
bool CefPluginInfoMessageFilter::Context::FindEnabledPlugin(
const GetPluginInfo_Params& params,
CefRequestContextHandler* handler,
CefViewHostMsg_GetPluginInfo_Status* status,
WebPluginInfo* plugin,
std::string* actual_mime_type,
scoped_ptr<PluginMetadata>* plugin_metadata) const {
*status = CefViewHostMsg_GetPluginInfo_Status::kAllowed;
bool allow_wildcard = true;
std::vector<WebPluginInfo> matching_plugins;
std::vector<std::string> mime_types;
PluginService::GetInstance()->GetPluginInfoArray(
params.url, params.mime_type, allow_wildcard, &matching_plugins,
&mime_types);
if (matching_plugins.empty()) {
*status = CefViewHostMsg_GetPluginInfo_Status::kNotFound;
#if defined(OS_WIN) || defined(OS_MACOSX)
if (!PluginService::GetInstance()->NPAPIPluginsSupported()) {
// At this point it is not known for sure this is an NPAPI plugin as it
// could be a not-yet-installed Pepper plugin. To avoid notifying on
// these types, bail early based on a blacklist of pepper mime types.
for (auto pepper_mime_type : kPepperPluginMimeTypes)
if (pepper_mime_type == params.mime_type)
return false;
}
#endif
return false;
}
CefPluginServiceFilter* filter = static_cast<CefPluginServiceFilter*>(
PluginService::GetInstance()->GetFilter());
DCHECK(filter);
CefViewHostMsg_GetPluginInfo_Status first_status = *status;
size_t i = 0;
for (; i < matching_plugins.size(); ++i) {
*plugin = matching_plugins[i];
*actual_mime_type = mime_types[i];
*plugin_metadata = PluginFinder::GetInstance()->GetPluginMetadata(*plugin);
DecidePluginStatus(params, *plugin, (*plugin_metadata).get(), status);
if (filter->IsPluginAvailable(handler,
params.url,
params.top_origin_url,
plugin,
status)) {
break;
}
if (i == 0)
first_status = *status;
}
// If we broke out of the loop, we have found an enabled plugin.
bool enabled = i < matching_plugins.size();
if (!enabled) {
// Otherwise, we only found disabled/not-found plugins, so we take the first
// one.
*plugin = matching_plugins[0];
*actual_mime_type = mime_types[0];
*plugin_metadata = PluginFinder::GetInstance()->GetPluginMetadata(*plugin);
*status = first_status;
}
return enabled;
}
void CefPluginInfoMessageFilter::Context::GetPluginContentSetting(
const WebPluginInfo& plugin,
const GURL& policy_url,
const GURL& plugin_url,
const std::string& resource,
ContentSetting* setting,
bool* uses_default_content_setting,
bool* is_managed) const {
*setting = CONTENT_SETTING_ALLOW;
*uses_default_content_setting = true;
*is_managed = false;
// Change the default plugin policy.
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
const std::string& plugin_policy_str =
command_line->GetSwitchValueASCII(switches::kPluginPolicy);
if (!plugin_policy_str.empty()) {
if (base::LowerCaseEqualsASCII(plugin_policy_str,
switches::kPluginPolicy_Detect)) {
*setting = CONTENT_SETTING_DETECT_IMPORTANT_CONTENT;
} else if (base::LowerCaseEqualsASCII(plugin_policy_str,
switches::kPluginPolicy_Block)) {
*setting = CONTENT_SETTING_BLOCK;
}
}
}
bool CefPluginInfoMessageFilter::Context::IsPluginEnabled(
const content::WebPluginInfo& plugin) const {
return true;
}

View File

@@ -3,8 +3,8 @@
// 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_PLUGIN_INFO_MESSAGE_FILTER_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_PLUGIN_INFO_MESSAGE_FILTER_H_
#ifndef CEF_LIBCEF_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_
#define CEF_LIBCEF_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_
#include <string>
#include <vector>
@@ -14,19 +14,24 @@
#include "base/memory/weak_ptr.h"
#include "base/prefs/pref_member.h"
#include "base/sequenced_task_runner_helpers.h"
#include "chrome/browser/plugins/plugin_metadata.h"
#include "components/content_settings/core/common/content_settings.h"
#include "content/public/browser/browser_message_filter.h"
class CefBrowserContext;
class CefRequestContextHandler;
struct CefViewHostMsg_GetPluginInfo_Output;
enum class CefViewHostMsg_GetPluginInfo_Status;
class GURL;
namespace content {
class BrowserContext;
class ResourceContext;
struct WebPluginInfo;
}
namespace extensions {
class ExtensionRegistry;
}
// This class filters out incoming IPC messages requesting plugin information.
class CefPluginInfoMessageFilter : public content::BrowserMessageFilter {
@@ -36,29 +41,45 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter {
// Contains all the information needed by the CefPluginInfoMessageFilter.
class Context {
public:
Context(int render_process_id, content::BrowserContext* browser_context);
Context(int render_process_id, CefBrowserContext* profile);
~Context();
void DecidePluginStatus(
const GetPluginInfo_Params& params,
const content::WebPluginInfo& plugin,
const PluginMetadata* plugin_metadata,
CefViewHostMsg_GetPluginInfo_Status* status) const;
bool FindEnabledPlugin(int render_frame_id,
const GURL& url,
const GURL& top_origin_url,
const std::string& mime_type,
bool FindEnabledPlugin(const GetPluginInfo_Params& params,
CefRequestContextHandler* handler,
CefViewHostMsg_GetPluginInfo_Status* status,
content::WebPluginInfo* plugin,
std::string* actual_mime_type) const;
std::string* actual_mime_type,
scoped_ptr<PluginMetadata>* plugin_metadata) const;
void GetPluginContentSetting(const content::WebPluginInfo& plugin,
const GURL& policy_url,
const GURL& plugin_url,
const std::string& resource,
ContentSetting* setting,
bool* is_default,
bool* is_managed) const;
void MaybeGrantAccess(CefViewHostMsg_GetPluginInfo_Status status,
const base::FilePath& path) const;
bool IsPluginEnabled(const content::WebPluginInfo& plugin) const;
private:
int render_process_id_;
content::ResourceContext* resource_context_;
#if defined(ENABLE_EXTENSIONS)
extensions::ExtensionRegistry* extension_registry_;
#endif
BooleanPrefMember allow_outdated_plugins_;
BooleanPrefMember always_authorize_plugins_;
};
CefPluginInfoMessageFilter(int render_process_id,
content::BrowserContext* browser_context);
CefBrowserContext* profile);
// content::BrowserMessageFilter methods:
bool OnMessageReceived(const IPC::Message& message) override;
@@ -83,7 +104,23 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter {
IPC::Message* reply_msg,
const std::vector<content::WebPluginInfo>& plugins);
#if defined(ENABLE_PEPPER_CDMS)
// Returns whether any internal plugin supporting |mime_type| is registered
// and enabled. Does not determine whether the plugin can actually be
// instantiated (e.g. whether it has all its dependencies).
// When the returned *|is_available| is true, |additional_param_names| and
// |additional_param_values| contain the name-value pairs, if any, specified
// for the *first* non-disabled plugin found that is registered for
// |mime_type|.
void OnIsInternalPluginAvailableForMimeType(
const std::string& mime_type,
bool* is_available,
std::vector<base::string16>* additional_param_names,
std::vector<base::string16>* additional_param_values);
#endif
Context context_;
CefBrowserContext* browser_context_;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
base::WeakPtrFactory<CefPluginInfoMessageFilter> weak_ptr_factory_;
@@ -91,6 +128,4 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter {
DISALLOW_COPY_AND_ASSIGN(CefPluginInfoMessageFilter);
};
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_PLUGIN_INFO_MESSAGE_FILTER_H_
#endif // CEF_LIBCEF_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_

View File

@@ -0,0 +1,106 @@
// 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/plugins/plugin_service_filter.h"
#include "include/cef_request_context_handler.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/resource_context.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/web_plugin_impl.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/content_client.h"
CefPluginServiceFilter::CefPluginServiceFilter() {
}
bool CefPluginServiceFilter::IsPluginAvailable(
int render_process_id,
int render_frame_id,
const void* context,
const GURL& url,
const GURL& policy_url,
content::WebPluginInfo* plugin) {
CefRefPtr<CefRequestContextHandler> handler =
reinterpret_cast<const CefResourceContext*>(context)->GetHandler();
CefViewHostMsg_GetPluginInfo_Status status =
CefViewHostMsg_GetPluginInfo_Status::kAllowed;
return IsPluginAvailable(handler.get(), url, policy_url, plugin, &status);
}
bool CefPluginServiceFilter::CanLoadPlugin(int render_process_id,
const base::FilePath& path) {
return true;
}
bool CefPluginServiceFilter::IsPluginAvailable(
CefRequestContextHandler* handler,
const GURL& url,
const GURL& policy_url,
content::WebPluginInfo* plugin,
CefViewHostMsg_GetPluginInfo_Status* status) {
if (*status == CefViewHostMsg_GetPluginInfo_Status::kNotFound ||
*status == CefViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported) {
// The plugin does not exist so no need to query the handler.
return false;
}
if (plugin->path == CefString(CefContentClient::kPDFPluginPath)) {
// Always allow the internal PDF plugin to load.
*status = CefViewHostMsg_GetPluginInfo_Status::kAllowed;
return true;
}
if (handler) {
CefRefPtr<CefWebPluginInfoImpl> pluginInfo(
new CefWebPluginInfoImpl(*plugin));
cef_plugin_policy_t plugin_policy = PLUGIN_POLICY_ALLOW;
switch (*status) {
case CefViewHostMsg_GetPluginInfo_Status::kAllowed:
plugin_policy = PLUGIN_POLICY_ALLOW;
break;
case CefViewHostMsg_GetPluginInfo_Status::kBlocked:
case CefViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy:
case CefViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked:
case CefViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed:
case CefViewHostMsg_GetPluginInfo_Status::kUnauthorized:
plugin_policy = PLUGIN_POLICY_BLOCK;
break;
case CefViewHostMsg_GetPluginInfo_Status::kDisabled:
plugin_policy = PLUGIN_POLICY_DISABLE;
break;
case CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent:
plugin_policy = PLUGIN_POLICY_DETECT_IMPORTANT;
break;
default:
NOTREACHED();
break;
}
if (handler->OnBeforePluginLoad(plugin->mime_types[0].mime_type,
url.possibly_invalid_spec(),
policy_url.possibly_invalid_spec(),
pluginInfo.get(),
&plugin_policy)) {
switch (plugin_policy) {
case PLUGIN_POLICY_ALLOW:
*status = CefViewHostMsg_GetPluginInfo_Status::kAllowed;
break;
case PLUGIN_POLICY_DETECT_IMPORTANT:
*status = CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
break;
case PLUGIN_POLICY_BLOCK:
*status = CefViewHostMsg_GetPluginInfo_Status::kBlocked;
break;
case PLUGIN_POLICY_DISABLE:
*status = CefViewHostMsg_GetPluginInfo_Status::kDisabled;
break;
}
}
}
return (*status != CefViewHostMsg_GetPluginInfo_Status::kDisabled);
}

View File

@@ -0,0 +1,46 @@
// 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_PLUGINS_PLUGIN_SERVICE_FILTER_H_
#define CEF_LIBCEF_BROWSER_PLUGINS_PLUGIN_SERVICE_FILTER_H_
#include "content/public/browser/plugin_service_filter.h"
#include "include/internal/cef_types.h"
#include "base/macros.h"
class CefRequestContextHandler;
enum class CefViewHostMsg_GetPluginInfo_Status;
class CefPluginServiceFilter : public content::PluginServiceFilter {
public:
CefPluginServiceFilter();
// Called whenever the plugin list is queried. For example, when choosing the
// plugin to handle a mime type or when determining the plugins that will be
// exposed to JavaScript via 'navigator.plugins'.
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 CanLoadPlugin(int render_process_id,
const base::FilePath& path) override;
// Returns false if the plugin is not found or disabled. May call
// CefRequestContextHandler::OnBeforePluginLoad if possible/necessary.
bool IsPluginAvailable(CefRequestContextHandler* handler,
const GURL& url,
const GURL& policy_url,
content::WebPluginInfo* plugin,
CefViewHostMsg_GetPluginInfo_Status* status);
private:
DISALLOW_COPY_AND_ASSIGN(CefPluginServiceFilter);
};
#endif // CEF_LIBCEF_BROWSER_PLUGINS_PLUGIN_SERVICE_FILTER_H_

View File

@@ -8,6 +8,8 @@
#include <string>
#include <vector>
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/print_settings_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/content_client.h"
@@ -134,6 +136,37 @@ gfx::Size CefPrintDialogLinux::GetPdfPaperSize(
return size;
}
// static
void CefPrintDialogLinux::OnPrintStart(int render_process_id,
int render_routing_id) {
if (!CEF_CURRENTLY_ON(CEF_UIT)) {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefPrintDialogLinux::OnPrintStart,
render_process_id, render_routing_id));
return;
}
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
if (!app.get())
return;
CefRefPtr<CefBrowserProcessHandler> browser_handler =
app->GetBrowserProcessHandler();
if (!browser_handler.get())
return;
CefRefPtr<CefPrintHandler> handler = browser_handler->GetPrintHandler();
if (!handler.get())
return;
CefRefPtr<CefBrowserHostImpl> browser =
extensions::GetOwnerBrowserForView(render_process_id,
render_routing_id,
NULL);
if (browser.get())
handler->OnPrintStart(browser.get());
}
CefPrintDialogLinux::CefPrintDialogLinux(PrintingContextLinux* context)
: context_(context) {
}

View File

@@ -37,6 +37,10 @@ class CefPrintDialogLinux
static gfx::Size GetPdfPaperSize(
printing::PrintingContextLinux* context);
// Notify the client when printing has started.
static void OnPrintStart(int render_process_id,
int render_routing_id);
// printing::CefPrintDialogLinuxInterface implementation.
void UseDefaultSettings() override;
bool UpdateSettings(printing::PrintSettings* settings) override;

View File

@@ -32,6 +32,10 @@
#include "printing/printing_context_android.h"
#endif
#if defined(OS_LINUX)
#include "libcef/browser/printing/print_dialog_linux.h"
#endif
using content::BrowserThread;
namespace printing {
@@ -254,6 +258,12 @@ void PrintingMessageFilter::OnIsPrintingEnabled(bool* is_enabled) {
void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
#if defined(OS_LINUX)
// Send notification to the client.
CefPrintDialogLinux::OnPrintStart(render_process_id_,
reply_msg->routing_id());
#endif
scoped_refptr<PrinterQuery> printer_query;
printer_query = queue_->PopPrinterQuery(0);
if (!printer_query.get()) {
@@ -424,7 +434,7 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply(
void PrintingMessageFilter::OnCheckForCancel(int32 preview_ui_id,
int preview_request_id,
bool* cancel) {
*cancel = false;
*cancel = false;
}
} // namespace printing

View File

@@ -498,6 +498,11 @@ CefRenderWidgetHostViewOSR::~CefRenderWidgetHostViewOSR() {
delegated_frame_host_.reset(NULL);
compositor_.reset(NULL);
root_layer_.reset(NULL);
DCHECK(parent_host_view_ == NULL);
DCHECK(popup_host_view_ == NULL);
DCHECK(child_host_view_ == NULL);
DCHECK(guest_host_views_.empty());
}
// Called for full-screen widgets.
@@ -508,11 +513,14 @@ void CefRenderWidgetHostViewOSR::InitAsChild(gfx::NativeView parent_view) {
if (parent_host_view_->child_host_view_) {
// Cancel the previous popup widget.
parent_host_view_->child_host_view_->CancelChildWidget();
parent_host_view_->child_host_view_->CancelWidget();
}
parent_host_view_->set_child_host_view(this);
// The parent view should not render while the full-screen view exists.
parent_host_view_->Hide();
ResizeRootLayer();
Show();
}
@@ -649,7 +657,8 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
output_surface_id,
frame->delegated_frame_data.Pass(),
frame->metadata.device_scale_factor,
frame->metadata.latency_info);
frame->metadata.latency_info,
&frame->metadata.satisfies_sequences);
} else {
if (!copy_frame_generator_.get()) {
copy_frame_generator_.reset(
@@ -668,7 +677,8 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
output_surface_id,
frame->delegated_frame_data.Pass(),
frame->metadata.device_scale_factor,
frame->metadata.latency_info);
frame->metadata.latency_info,
&frame->metadata.satisfies_sequences);
// Request a copy of the last compositor frame which will eventually call
// OnPaint asynchronously.
@@ -698,7 +708,7 @@ void CefRenderWidgetHostViewOSR::InitAsPopup(
if (parent_host_view_->popup_host_view_) {
// Cancel the previous popup widget.
parent_host_view_->popup_host_view_->CancelPopupWidget();
parent_host_view_->popup_host_view_->CancelWidget();
}
parent_host_view_->set_popup_host_view(this);
@@ -796,12 +806,7 @@ void CefRenderWidgetHostViewOSR::ImeCancelComposition() {
void CefRenderWidgetHostViewOSR::RenderProcessGone(
base::TerminationStatus status,
int error_code) {
// TODO(OSR): Need to also clear WebContentsViewOSR::view_?
Destroy();
render_widget_host_ = NULL;
parent_host_view_ = NULL;
popup_host_view_ = NULL;
child_host_view_ = NULL;
}
void CefRenderWidgetHostViewOSR::Destroy() {
@@ -809,15 +814,14 @@ void CefRenderWidgetHostViewOSR::Destroy() {
is_destroyed_ = true;
if (has_parent_) {
if (IsPopupWidget())
CancelPopupWidget();
else
CancelChildWidget();
CancelWidget();
} else {
if (popup_host_view_)
popup_host_view_->CancelPopupWidget();
popup_host_view_->CancelWidget();
if (child_host_view_)
child_host_view_->CancelChildWidget();
child_host_view_->CancelWidget();
for (auto guest_host_view : guest_host_views_)
guest_host_view->CancelWidget();
Hide();
}
}
@@ -988,6 +992,8 @@ bool CefRenderWidgetHostViewOSR::OnMessageReceived(const IPC::Message& msg) {
}
void CefRenderWidgetHostViewOSR::OnSetNeedsBeginFrames(bool enabled) {
SetFrameRate();
// Start/stop the timer that sends BeginFrame requests.
begin_frame_timer_->SetActive(enabled);
if (software_output_device_) {
@@ -1104,6 +1110,10 @@ void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() {
// We might want to change the cursor scale factor here as well - see the
// cache for the current_cursor_, as passed by UpdateCursor from the renderer
// in the rwhv_aura (current_cursor_.SetScaleFactor)
// Notify the guest hosts if any.
for (auto guest_host_view : guest_host_views_)
guest_host_view->OnScreenInfoChanged();
}
void CefRenderWidgetHostViewOSR::Invalidate(
@@ -1184,7 +1194,7 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
// Execute asynchronously to avoid deleting the widget from inside some
// other callback.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefRenderWidgetHostViewOSR::CancelPopupWidget,
base::Bind(&CefRenderWidgetHostViewOSR::CancelWidget,
popup_host_view_->weak_ptr_factory_.GetWeakPtr()));
}
}
@@ -1215,6 +1225,10 @@ void CefRenderWidgetHostViewOSR::SendFocusEvent(bool focus) {
void CefRenderWidgetHostViewOSR::UpdateFrameRate() {
frame_rate_threshold_ms_ = 0;
SetFrameRate();
// Notify the guest hosts if any.
for (auto guest_host_view : guest_host_views_)
guest_host_view->UpdateFrameRate();
}
void CefRenderWidgetHostViewOSR::HoldResize() {
@@ -1268,6 +1282,16 @@ void CefRenderWidgetHostViewOSR::OnPaint(
ReleaseResize();
}
void CefRenderWidgetHostViewOSR::AddGuestHostView(
CefRenderWidgetHostViewOSR* guest_host) {
guest_host_views_.insert(guest_host);
}
void CefRenderWidgetHostViewOSR::RemoveGuestHostView(
CefRenderWidgetHostViewOSR* guest_host) {
guest_host_views_.erase(guest_host);
}
// static
int CefRenderWidgetHostViewOSR::ClampFrameRate(int frame_rate) {
if (frame_rate < 1)
@@ -1278,16 +1302,21 @@ int CefRenderWidgetHostViewOSR::ClampFrameRate(int frame_rate) {
}
void CefRenderWidgetHostViewOSR::SetFrameRate() {
DCHECK(browser_impl_.get());
if (!browser_impl_.get())
return;
CefRefPtr<CefBrowserHostImpl> browser;
if (parent_host_view_) {
// Use the same frame rate as the embedding browser.
browser = parent_host_view_->browser_impl_;
} else {
browser = browser_impl_;
}
CHECK(browser);
// Only set the frame rate one time.
if (frame_rate_threshold_ms_ != 0)
return;
const int frame_rate =
ClampFrameRate(browser_impl_->settings().windowless_frame_rate);
ClampFrameRate(browser->settings().windowless_frame_rate);
frame_rate_threshold_ms_ = 1000 / frame_rate;
// Configure the VSync interval for the browser process.
@@ -1387,15 +1416,13 @@ void CefRenderWidgetHostViewOSR::SendBeginFrame(base::TimeTicks frame_time,
vsync_period, cc::BeginFrameArgs::NORMAL)));
}
void CefRenderWidgetHostViewOSR::CancelPopupWidget() {
DCHECK(IsPopupWidget());
void CefRenderWidgetHostViewOSR::CancelWidget() {
if (render_widget_host_)
render_widget_host_->LostCapture();
Hide();
if (browser_impl_.get()) {
if (IsPopupWidget() && browser_impl_.get()) {
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
if (handler.get())
@@ -1404,25 +1431,16 @@ void CefRenderWidgetHostViewOSR::CancelPopupWidget() {
}
if (parent_host_view_) {
parent_host_view_->set_popup_host_view(NULL);
parent_host_view_ = NULL;
}
if (parent_host_view_->popup_host_view_ == this) {
parent_host_view_->set_popup_host_view(NULL);
} else if (parent_host_view_->child_host_view_ == this) {
parent_host_view_->set_child_host_view(NULL);
if (render_widget_host_ && !is_destroyed_) {
is_destroyed_ = true;
// Results in a call to Destroy().
render_widget_host_->Shutdown();
}
}
void CefRenderWidgetHostViewOSR::CancelChildWidget() {
if (render_widget_host_)
render_widget_host_->LostCapture();
Hide();
if (parent_host_view_) {
parent_host_view_->set_child_host_view(NULL);
// Start rendering the parent view again.
parent_host_view_->Show();
} else {
parent_host_view_->RemoveGuestHostView(this);
}
parent_host_view_ = NULL;
}

View File

@@ -7,6 +7,7 @@
#define CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_
#pragma once
#include <set>
#include <vector>
#include "include/cef_base.h"
@@ -257,6 +258,9 @@ class CefRenderWidgetHostViewOSR
gfx::Range* actual_range) const;
#endif // defined(OS_MACOSX)
void AddGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
void RemoveGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
CefRefPtr<CefBrowserHostImpl> browser_impl() const { return browser_impl_; }
void set_browser_impl(CefRefPtr<CefBrowserHostImpl> browser) {
browser_impl_ = browser;
@@ -288,8 +292,7 @@ class CefRenderWidgetHostViewOSR
void SendBeginFrame(base::TimeTicks frame_time,
base::TimeDelta vsync_period);
void CancelPopupWidget();
void CancelChildWidget();
void CancelWidget();
void OnScrollOffsetChanged();
@@ -359,6 +362,7 @@ class CefRenderWidgetHostViewOSR
CefRenderWidgetHostViewOSR* parent_host_view_;
CefRenderWidgetHostViewOSR* popup_host_view_;
CefRenderWidgetHostViewOSR* child_host_view_;
std::set<CefRenderWidgetHostViewOSR*> guest_host_views_;
CefRefPtr<CefBrowserHostImpl> browser_impl_;

View File

@@ -9,8 +9,10 @@
#include "libcef/browser/context.h"
#include "libcef/browser/cookie_manager_impl.h"
#include "libcef/browser/thread_util.h"
#include "base/atomic_sequence_num.h"
#include "base/logging.h"
#include "content/public/browser/plugin_service.h"
using content::BrowserThread;
@@ -283,6 +285,13 @@ bool CefRequestContextImpl::ClearSchemeHandlerFactories() {
return true;
}
void CefRequestContextImpl::PurgePluginListCache(bool reload_pages) {
GetBrowserContext(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&CefRequestContextImpl::PurgePluginListCacheInternal,
this, reload_pages));
}
CefRequestContextImpl::CefRequestContextImpl(
scoped_refptr<CefBrowserContext> browser_context)
: browser_context_(browser_context),
@@ -375,3 +384,11 @@ void CefRequestContextImpl::ClearSchemeHandlerFactoriesInternal(
CEF_REQUIRE_IOT();
request_context->request_manager()->ClearFactories();
}
void CefRequestContextImpl::PurgePluginListCacheInternal(
bool reload_pages,
scoped_refptr<CefBrowserContext> browser_context) {
CEF_REQUIRE_UIT();
content::PluginService::GetInstance()->PurgePluginListCache(
browser_context.get(), false);
}

View File

@@ -60,6 +60,7 @@ class CefRequestContextImpl : public CefRequestContext {
const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory) override;
bool ClearSchemeHandlerFactories() override;
void PurgePluginListCache(bool reload_pages) override;
const CefRequestContextSettings& settings() const { return settings_; }
@@ -85,9 +86,12 @@ class CefRequestContextImpl : public CefRequestContext {
const CefString& scheme_name,
const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory,
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void ClearSchemeHandlerFactoriesInternal(
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void PurgePluginListCacheInternal(
bool reload_pages,
scoped_refptr<CefBrowserContext> browser_context);
scoped_refptr<CefBrowserContext> browser_context_;
CefRequestContextSettings settings_;

View File

@@ -22,9 +22,11 @@
CefResourceContext::CefResourceContext(
bool is_off_the_record,
extensions::InfoMap* extension_info_map)
extensions::InfoMap* extension_info_map,
CefRefPtr<CefRequestContextHandler> handler)
: is_off_the_record_(is_off_the_record),
extension_info_map_(extension_info_map) {
extension_info_map_(extension_info_map),
handler_(handler) {
}
CefResourceContext::~CefResourceContext() {

View File

@@ -6,6 +6,8 @@
#define CEF_LIBCEF_BROWSER_RESOURCE_CONTEXT_H_
#pragma once
#include "include/cef_request_context_handler.h"
#include "content/public/browser/resource_context.h"
#include "extensions/browser/info_map.h"
@@ -22,7 +24,8 @@ class CefURLRequestContextGetter;
class CefResourceContext : public content::ResourceContext {
public:
CefResourceContext(bool is_off_the_record,
extensions::InfoMap* extension_info_map);
extensions::InfoMap* extension_info_map,
CefRefPtr<CefRequestContextHandler> handler);
~CefResourceContext() override;
// ResourceContext implementation.
@@ -38,12 +41,14 @@ class CefResourceContext : public content::ResourceContext {
const extensions::InfoMap* GetExtensionInfoMap() const {
return extension_info_map_.get();
}
CefRefPtr<CefRequestContextHandler> GetHandler() const { return handler_; }
private:
scoped_refptr<CefURLRequestContextGetter> getter_;
bool is_off_the_record_;
scoped_refptr<extensions::InfoMap> extension_info_map_;
CefRefPtr<CefRequestContextHandler> handler_;
DISALLOW_COPY_AND_ASSIGN(CefResourceContext);
};

View File

@@ -348,8 +348,13 @@ extern "C" {
// doesn't call any NSTextInput functions, such as setMarkedText or
// insertText. So, we need to send an IPC message to a renderer so it can
// delete the composition node.
// TODO(erikchen): NSInputManager is deprecated since OSX 10.6. Switch to
// NSTextInputContext. http://www.crbug.com/479010.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSInputManager *currentInputManager = [NSInputManager currentInputManager];
[currentInputManager markedTextAbandoned:self];
#pragma clang diagnostic pop
hasMarkedText_ = NO;
// Should not call [self unmarkText] here, because it'll send unnecessary

View File

@@ -122,7 +122,9 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
disconnector->Disconnect();
request->RemoveUserData(UserDataKey());
callback.Run(allow ? net::OK : net::ERR_ABORTED);
// Only execute the callback if the request has not been canceled.
if (request->status().status() != net::URLRequestStatus::CANCELED)
callback.Run(allow ? net::OK : net::ERR_ABORTED);
}
static inline void* UserDataKey() {

View File

@@ -10,6 +10,7 @@
#include <string>
#include <vector>
#include "libcef/browser/cookie_manager_impl.h"
#include "libcef/browser/scheme_handler.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/url_network_delegate.h"
@@ -52,8 +53,8 @@
#include "net/url_request/url_request_job_factory_impl.h"
#include "net/url_request/url_request_job_manager.h"
#if defined(USE_NSS)
#include "net/ocsp/nss_ocsp.h"
#if defined(USE_NSS_CERTS)
#include "net/cert_net/nss_ocsp.h"
#endif
using content::BrowserThread;
@@ -261,7 +262,7 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
storage_->set_job_factory(top_job_factory.release());
#if defined(USE_NSS)
#if defined(USE_NSS_CERTS)
// Only do this for the first (global) request context.
static bool request_context_for_nss_set = false;
if (!request_context_for_nss_set) {
@@ -326,35 +327,17 @@ void CefURLRequestContextGetterImpl::SetCookieStoragePath(
cookie_store_path_ = path;
// Restore the previously supported schemes.
SetCookieSupportedSchemes(cookie_supported_schemes_);
CefCookieManagerImpl::SetCookieMonsterSchemes(cookie_monster.get(),
cookie_supported_schemes_);
}
void CefURLRequestContextGetterImpl::SetCookieSupportedSchemes(
const std::vector<std::string>& schemes) {
const std::set<std::string>& schemes) {
CEF_REQUIRE_IOT();
cookie_supported_schemes_ = schemes;
if (cookie_supported_schemes_.empty()) {
cookie_supported_schemes_.push_back("http");
cookie_supported_schemes_.push_back("https");
}
std::set<std::string> scheme_set;
std::vector<std::string>::const_iterator it =
cookie_supported_schemes_.begin();
for (; it != cookie_supported_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();
url_request_context_->cookie_store()->GetCookieMonster()->
SetCookieableSchemes(arr, scheme_set.size());
delete [] arr;
CefCookieManagerImpl::SetCookieMonsterSchemes(GetCookieMonster(),
cookie_supported_schemes_);
}
void CefURLRequestContextGetterImpl::AddHandler(
@@ -367,6 +350,11 @@ void CefURLRequestContextGetterImpl::AddHandler(
handler_list_.push_back(handler);
}
net::CookieMonster* CefURLRequestContextGetterImpl::GetCookieMonster() const {
CEF_REQUIRE_IOT();
return url_request_context_->cookie_store()->GetCookieMonster();
}
void CefURLRequestContextGetterImpl::CreateProxyConfigService() {
if (proxy_config_service_.get())
return;

View File

@@ -6,8 +6,8 @@
#define CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_IMPL_H_
#pragma once
#include <set>
#include <string>
#include <vector>
#include "include/internal/cef_types_wrappers.h"
#include "libcef/browser/url_request_context_getter.h"
@@ -26,6 +26,7 @@ class MessageLoop;
}
namespace net {
class CookieMonster;
class FtpTransactionFactory;
class ProxyConfigService;
class URLRequestContextStorage;
@@ -59,12 +60,14 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
void SetCookieStoragePath(const base::FilePath& path,
bool persist_session_cookies);
void SetCookieSupportedSchemes(const std::vector<std::string>& schemes);
void SetCookieSupportedSchemes(const std::set<std::string>& schemes);
// Keep a reference to all handlers sharing this context so that they'll be
// kept alive until the context is destroyed.
void AddHandler(CefRefPtr<CefRequestContextHandler> handler);
net::CookieMonster* GetCookieMonster() const;
CefURLRequestManager* request_manager() const {
return url_request_manager_.get();
}
@@ -87,7 +90,7 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
content::URLRequestInterceptorScopedVector request_interceptors_;
base::FilePath cookie_store_path_;
std::vector<std::string> cookie_supported_schemes_;
std::set<std::string> cookie_supported_schemes_;
std::vector<CefRefPtr<CefRequestContextHandler> > handler_list_;

View File

@@ -119,8 +119,16 @@ content::RenderWidgetHostViewBase* CefWebContentsViewOSR::CreateViewForWidget(
if (guest_) {
// Based on WebContentsViewGuest::CreateViewForWidget.
content::WebContents* embedder_web_contents =
guest_->embedder_web_contents();
CefRenderWidgetHostViewOSR* embedder_host_view =
static_cast<CefRenderWidgetHostViewOSR*>(
embedder_web_contents->GetRenderViewHost()->GetView());
CefRenderWidgetHostViewOSR* platform_widget =
new CefRenderWidgetHostViewOSR(render_widget_host, NULL);
new CefRenderWidgetHostViewOSR(render_widget_host, embedder_host_view);
embedder_host_view->AddGuestHostView(platform_widget);
return new content::RenderWidgetHostViewGuest(
render_widget_host,
guest_,

View File

@@ -1,6 +1,13 @@
// Copyright (c) 2014 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.
// Copyright 2014 The Chromium Embedded Framework Authors. Portions copyright
// 2011 the Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "include/base/cef_build.h"
#if defined(OS_WIN)
#include <windows.h>
#include <shellscalingapi.h>
#endif
#include "include/internal/cef_trace_event_internal.h"
#include "include/internal/cef_logging_internal.h"
@@ -10,6 +17,55 @@
#include "base/threading/platform_thread.h"
#include "base/trace_event/trace_event.h"
#if defined(OS_WIN)
#include "base/win/windows_version.h"
namespace {
// Implementation from chrome/app/chrome_exe_main_win.cc.
// Win8.1 supports monitor-specific DPI scaling.
bool SetProcessDpiAwarenessWrapper(PROCESS_DPI_AWARENESS value) {
typedef HRESULT(WINAPI *SetProcessDpiAwarenessPtr)(PROCESS_DPI_AWARENESS);
SetProcessDpiAwarenessPtr set_process_dpi_awareness_func =
reinterpret_cast<SetProcessDpiAwarenessPtr>(
GetProcAddress(GetModuleHandleA("user32.dll"),
"SetProcessDpiAwarenessInternal"));
if (set_process_dpi_awareness_func) {
HRESULT hr = set_process_dpi_awareness_func(value);
if (SUCCEEDED(hr)) {
VLOG(1) << "SetProcessDpiAwareness succeeded.";
return true;
} else if (hr == E_ACCESSDENIED) {
LOG(ERROR) << "Access denied error from SetProcessDpiAwareness. "
"Function called twice, or manifest was used.";
}
}
return false;
}
// This function works for Windows Vista through Win8. Win8.1 must use
// SetProcessDpiAwareness[Wrapper].
BOOL SetProcessDPIAwareWrapper() {
typedef BOOL(WINAPI *SetProcessDPIAwarePtr)(VOID);
SetProcessDPIAwarePtr set_process_dpi_aware_func =
reinterpret_cast<SetProcessDPIAwarePtr>(
GetProcAddress(GetModuleHandleA("user32.dll"),
"SetProcessDPIAware"));
return set_process_dpi_aware_func &&
set_process_dpi_aware_func();
}
void EnableHighDPISupport() {
if (!SetProcessDpiAwarenessWrapper(PROCESS_SYSTEM_DPI_AWARE)) {
SetProcessDPIAwareWrapper();
}
}
} // namespace
#endif // defined(OS_WIN)
// The contents of this file are a compilation unit that is not called by other
// functions in the the library. Consiquently MSVS will exclude it during the
// linker stage if we don't call a stub function.
@@ -343,3 +399,13 @@ CEF_EXPORT cef_platform_thread_handle_t
return base::PlatformThread::CurrentHandle().platform_handle();
#endif
}
void CefEnableHighDPISupport() {
#if defined(OS_WIN)
// We don't want to set DPI awareness on pre-Win7 because we don't support
// DirectWrite there. GDI fonts are kerned very badly, so better to leave
// DPI-unaware and at effective 1.0. See also ShouldUseDirectWrite().
if (base::win::GetVersion() >= base::win::VERSION_WIN7)
EnableHighDPISupport();
#endif
}

View File

@@ -163,6 +163,11 @@ IPC_MESSAGE_ROUTED1(CefMsg_Response,
IPC_MESSAGE_ROUTED1(CefMsg_ResponseAck,
int /* request_id */)
// Tells the render frame to load all blocked plugins with the given identifier.
// Based on ChromeViewMsg_LoadBlockedPlugins.
IPC_MESSAGE_ROUTED1(CefViewMsg_LoadBlockedPlugins,
std::string /* identifier */)
// Sent on process startup to indicate whether this process is running in
// incognito mode. Based on ChromeViewMsg_SetIsIncognitoProcess.
IPC_MESSAGE_CONTROL1(CefProcessMsg_SetIsIncognitoProcess,
@@ -197,7 +202,7 @@ IPC_STRUCT_BEGIN(CefProcessHostMsg_GetNewBrowserInfo_Params)
IPC_STRUCT_MEMBER(int, browser_id)
IPC_STRUCT_MEMBER(bool, is_popup)
IPC_STRUCT_MEMBER(bool, is_windowless)
IPC_STRUCT_MEMBER(bool, is_mime_handler_view)
IPC_STRUCT_MEMBER(bool, is_guest_view)
IPC_STRUCT_END()
// Retrieve information about a newly created browser.
@@ -230,6 +235,20 @@ IPC_SYNC_MESSAGE_CONTROL4_1(CefViewHostMsg_GetPluginInfo,
std::string /* mime_type */,
CefViewHostMsg_GetPluginInfo_Output /* output */)
// Returns whether any internal plugin supporting |mime_type| is registered and
// enabled. Does not determine whether the plugin can actually be instantiated
// (e.g. whether it has all its dependencies).
// When the returned *|is_available| is true, |additional_param_names| and
// |additional_param_values| contain the name-value pairs, if any, specified
// for the *first* non-disabled plugin found that is registered for |mime_type|.
// Based on ChromeViewHostMsg_IsInternalPluginAvailableForMimeType.
IPC_SYNC_MESSAGE_CONTROL1_3(
CefViewHostMsg_IsInternalPluginAvailableForMimeType,
std::string /* mime_type */,
bool /* is_available */,
std::vector<base::string16> /* additional_param_names */,
std::vector<base::string16> /* additional_param_values */)
// Sent when a frame is identified for the first time.
IPC_MESSAGE_ROUTED3(CefHostMsg_FrameIdentified,
int64 /* frame_id */,

View File

@@ -103,4 +103,23 @@ const char kDisableScrollBounce[] = "disable-scroll-bounce";
// Disable the PDF extension.
const char kDisablePdfExtension[] = "disable-pdf-extension";
// Enable Widevine CDM.
const char kEnableWidevineCdm[] = "enable-widevine-cdm";
// Path to Widevine CDM binaries.
const char kWidevineCdmPath[] = "widevine-cdm-path";
// Widevine CDM version.
const char kWidevineCdmVersion[] = "widevine-cdm-version";
// Default plugin policy action.
const char kPluginPolicy[] = "plugin-policy";
// Allow the content. This is the default value.
const char kPluginPolicy_Allow[] = "allow";
// Allow important content and block unimportant content based on heuristics.
// The user can manually load blocked content.
const char kPluginPolicy_Detect[] = "detect";
// Block the content. The user can manually load blocked content.
const char kPluginPolicy_Block[] = "block";
} // namespace switches

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