mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Compare commits
119 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ffd843c47c | ||
|
d7afec5dbd | ||
|
48e5f3d239 | ||
|
1b7ab74bcf | ||
|
49678210ec | ||
|
f7effc7aab | ||
|
3f66e81a78 | ||
|
b34508375a | ||
|
e8462d6b01 | ||
|
ab288d40f1 | ||
|
d0e0aaa382 | ||
|
71c8a797f3 | ||
|
7fd1fdae9e | ||
|
2d6e4cf9c6 | ||
|
a9b41ef611 | ||
|
4366a9b7b2 | ||
|
21e54ba6cc | ||
|
b53a2b0fcb | ||
|
7190ce8f68 | ||
|
709fd2b485 | ||
|
175be9a74b | ||
|
6881f83630 | ||
|
c956572b48 | ||
|
01ce16f127 | ||
|
7fe3d037c4 | ||
|
4e029f4dc2 | ||
|
bf6e3f5e98 | ||
|
2be7dee3fa | ||
|
bd987e54f0 | ||
|
356a488133 | ||
|
c31696628a | ||
|
b2968a0a5e | ||
|
be607a0ec9 | ||
|
4e7013cbfe | ||
|
d3b835eb2b | ||
|
4bb6c87876 | ||
|
adda1d223c | ||
|
7e034c9d6b | ||
|
02029b3689 | ||
|
c83b6a1bff | ||
|
743d0419f0 | ||
|
b52741d236 | ||
|
5068b50b48 | ||
|
ad1619dbd7 | ||
|
1e84e0cfff | ||
|
9064e30296 | ||
|
c48cac8dc4 | ||
|
9ee4db6dbb | ||
|
ae452e5348 | ||
|
d4663b2b4c | ||
|
c006dc7f0f | ||
|
5288dc5414 | ||
|
041ec09525 | ||
|
0cba9481fb | ||
|
da314f12fb | ||
|
b89329b0fa | ||
|
3b5fb0d526 | ||
|
69334e22c2 | ||
|
1c06d8e3f5 | ||
|
73c669d67e | ||
|
2e1d960f3f | ||
|
4f0ba755c6 | ||
|
aa950f8bdb | ||
|
ea33255c09 | ||
|
8a68967937 | ||
|
968fbacac3 | ||
|
2070a1bc41 | ||
|
5444c389fd | ||
|
98f59f47fd | ||
|
d92bc1d200 | ||
|
f2f76a0a20 | ||
|
88a8dad9c9 | ||
|
0e940c4128 | ||
|
5732a8da52 | ||
|
f4425a9a0c | ||
|
3cc539b506 | ||
|
62d177455b | ||
|
cf4a50b116 | ||
|
1ee311fa45 | ||
|
188326bbc4 | ||
|
c8681ea3e8 | ||
|
a22b11d764 | ||
|
8a5e7a1270 | ||
|
a60bb077a3 | ||
|
d0a2e217a0 | ||
|
05ee60b7b4 | ||
|
66425def4a | ||
|
262e327c74 | ||
|
f5b910326d | ||
|
eb199b2547 | ||
|
80f5a35668 | ||
|
18d882b5d2 | ||
|
b23c0f1097 | ||
|
acdb4bb564 | ||
|
e41a763307 | ||
|
a356ee9ca1 | ||
|
fe9c24e307 | ||
|
76a40cafe3 | ||
|
754638846e | ||
|
733ff6ffff | ||
|
f1fec0933e | ||
|
e0fd09ed20 | ||
|
99bf1b8458 | ||
|
769150e178 | ||
|
ab2636b012 | ||
|
582ce074aa | ||
|
0b3d93cc8f | ||
|
ca928bd3f7 | ||
|
80c7c1bd77 | ||
|
575c968a55 | ||
|
958618359c | ||
|
543178ce67 | ||
|
839e78a519 | ||
|
bff6dd684c | ||
|
157f526d07 | ||
|
da3c6a3b61 | ||
|
1ff26aa02a | ||
|
52f9aacdf5 | ||
|
e690fa444c |
@@ -29,3 +29,4 @@ Felix Bruns <felixbruns@spotify.com>
|
||||
YuTeh Shen <shenyute@gmail.com>
|
||||
Andrei Kurushin <ajax16384@gmail.com>
|
||||
Gonzo Berman <gberman@factset.com>
|
||||
Jakub Trzebiatowski <kuba.trzebiatowski@gmail.com>
|
||||
|
@@ -7,5 +7,5 @@
|
||||
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
||||
|
||||
{
|
||||
'chromium_checkout': 'refs/tags/51.0.2704.103',
|
||||
'chromium_checkout': 'refs/tags/54.0.2840.99',
|
||||
}
|
||||
|
12
README.md
12
README.md
@@ -10,7 +10,7 @@ The Chromium Embedded Framework (CEF) is a simple framework for embedding Chromi
|
||||
* Support Forum - http://www.magpcss.org/ceforum/
|
||||
* CEF1 C++ API Docs - http://magpcss.org/ceforum/apidocs/
|
||||
* CEF3 C++ API Docs - http://magpcss.org/ceforum/apidocs3/
|
||||
* Downloads - http://www.magpcss.net/cef_downloads/ and http://cefbuilds.com (automated nightly builds)
|
||||
* Downloads - http://www.magpcss.net/cef_downloads/ and http://cefbuilds.com
|
||||
* Donations - http://www.magpcss.org/ceforum/donate.php
|
||||
|
||||
# Introduction
|
||||
@@ -24,15 +24,15 @@ CEF is a BSD-licensed open source project founded by Marshall Greenblatt in 2008
|
||||
|
||||
CEF supports a wide range of programming languages and operating systems and can be easily integrated into both new and existing applications. It was designed from the ground up with both performance and ease of use in mind. The base framework includes C and C++ programming interfaces exposed via native libraries that insulate the host application from Chromium and Blink implementation details. It provides close integration between the browser and the host application including support for custom plugins, protocols, JavaScript objects and JavaScript extensions. The host application can optionally control resource loading, navigation, context menus, printing and more, while taking advantage of the same performance and HTML5 technologies available in the Google Chrome Web browser.
|
||||
|
||||
Users new to CEF development should start by reading the [Tutorial](https://bitbucket.org/chromiumembedded/cef/wiki/Tutorial) Wiki page for an overview of CEF usage and then proceed to the [GeneralUsage](https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage) Wiki page for a more in-depth discussion or architectural and usage issues. Complete API documentation is available [here](http://magpcss.org/ceforum/apidocs3/). CEF support and related discussion is available on the [CEF Forum](http://www.magpcss.org/ceforum/).
|
||||
|
||||
Numerous individuals and organizations contribute time and resources to support CEF development, but more involvement from the community is always welcome. This includes support for both the core CEF project and external projects that integrate CEF with additional programming languages and frameworks (see the "External Projects" section below). If you are interested in donating time to help with CEF development please see the "Helping Out" section below. If you are interested in donating money to support general CEF development and infrastructure efforts please visit the [CEF Donations](http://www.magpcss.org/ceforum/donate.php) page.
|
||||
|
||||
# Getting Started
|
||||
|
||||
Users new to CEF development should start by reading the [Tutorial](https://bitbucket.org/chromiumembedded/cef/wiki/Tutorial) Wiki page for an overview of CEF usage and then proceed to the [GeneralUsage](https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage) Wiki page for a more in-depth discussion or architectural and usage issues. Complete API documentation is available [here](http://magpcss.org/ceforum/apidocs3/). CEF support and related discussion is available on the [CEF Forum](http://www.magpcss.org/ceforum/).
|
||||
|
||||
# Binary Distributions
|
||||
|
||||
Binary distributions, which include all files necessary to build a CEF-based application, are available on the [Downloads](http://www.magpcss.net/cef_downloads/) page. Automated nightly builds, available from http://cefbuilds.com, include the newest changes but may not be fully tested. Binary distributions are stand-alone and do not require the download of CEF or Chromium source code. Symbol files for debugging binary distributions of libcef can also be downloaded from the above links.
|
||||
|
||||
Release notes for past and current CEF binary distributions are available [here](https://bitbucket.org/chromiumembedded/cef/wiki/ReleaseNotes).
|
||||
Binary distributions, which include all files necessary to build a CEF-based application, are available on the [Downloads](http://www.magpcss.net/cef_downloads/) page and http://cefbuilds.com. Binary distributions are stand-alone and do not require the download of CEF or Chromium source code. Symbol files for debugging binary distributions of libcef can also be downloaded from the above links.
|
||||
|
||||
# Source Distributions
|
||||
|
||||
|
34
cef.gypi
34
cef.gypi
@@ -1,34 +0,0 @@
|
||||
# Copyright (c) 2013 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.
|
||||
|
||||
{
|
||||
'variables': {
|
||||
# Don't use the chrome style plugin with CEF.
|
||||
'clang_use_chrome_plugins': 0,
|
||||
# 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"', {
|
||||
'cef_directory' : '<!(echo %CEF_DIRECTORY%)',
|
||||
}, { # OS!="win"
|
||||
'cef_directory' : '<!(echo $CEF_DIRECTORY)',
|
||||
}],
|
||||
[ 'OS=="mac"', {
|
||||
# Strip symbols and create dSYM files for the Release target.
|
||||
'mac_strip_release': 1,
|
||||
}],
|
||||
['os_posix==1 and OS!="mac" and OS!="android"', {
|
||||
# Disable theme support on Linux so we don't need to implement
|
||||
# ThemeService[Factory] classes.
|
||||
'enable_themes': 0,
|
||||
}]
|
||||
]
|
||||
}
|
||||
}
|
@@ -61,6 +61,7 @@
|
||||
'include/cef_response_filter.h',
|
||||
'include/cef_scheme.h',
|
||||
'include/cef_ssl_info.h',
|
||||
'include/cef_ssl_status.h',
|
||||
'include/cef_stream.h',
|
||||
'include/cef_string_visitor.h',
|
||||
'include/cef_task.h',
|
||||
@@ -69,6 +70,7 @@
|
||||
'include/cef_v8.h',
|
||||
'include/cef_values.h',
|
||||
'include/cef_web_plugin.h',
|
||||
'include/cef_x509_certificate.h',
|
||||
'include/cef_xml_reader.h',
|
||||
'include/cef_zip_reader.h',
|
||||
'include/test/cef_translator_test.h',
|
||||
@@ -143,6 +145,7 @@
|
||||
'include/capi/cef_response_filter_capi.h',
|
||||
'include/capi/cef_scheme_capi.h',
|
||||
'include/capi/cef_ssl_info_capi.h',
|
||||
'include/capi/cef_ssl_status_capi.h',
|
||||
'include/capi/cef_stream_capi.h',
|
||||
'include/capi/cef_string_visitor_capi.h',
|
||||
'include/capi/cef_task_capi.h',
|
||||
@@ -151,6 +154,7 @@
|
||||
'include/capi/cef_v8_capi.h',
|
||||
'include/capi/cef_values_capi.h',
|
||||
'include/capi/cef_web_plugin_capi.h',
|
||||
'include/capi/cef_x509_certificate_capi.h',
|
||||
'include/capi/cef_xml_reader_capi.h',
|
||||
'include/capi/cef_zip_reader_capi.h',
|
||||
'include/capi/test/cef_translator_test_capi.h',
|
||||
@@ -314,6 +318,8 @@
|
||||
'libcef_dll/cpptoc/process_message_cpptoc.h',
|
||||
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/read_handler_ctocpp.h',
|
||||
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.h',
|
||||
'libcef_dll/ctocpp/render_handler_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/render_handler_ctocpp.h',
|
||||
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
|
||||
@@ -344,16 +350,18 @@
|
||||
'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',
|
||||
'libcef_dll/cpptoc/sslcert_principal_cpptoc.h',
|
||||
'libcef_dll/cpptoc/sslinfo_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/sslinfo_cpptoc.h',
|
||||
'libcef_dll/cpptoc/sslstatus_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/sslstatus_cpptoc.h',
|
||||
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h',
|
||||
'libcef_dll/cpptoc/scheme_registrar_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/scheme_registrar_cpptoc.h',
|
||||
'libcef_dll/cpptoc/views/scroll_view_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/views/scroll_view_cpptoc.h',
|
||||
'libcef_dll/cpptoc/select_client_certificate_callback_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/select_client_certificate_callback_cpptoc.h',
|
||||
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.h',
|
||||
'libcef_dll/cpptoc/stream_reader_cpptoc.cc',
|
||||
@@ -394,6 +402,8 @@
|
||||
'libcef_dll/cpptoc/v8exception_cpptoc.h',
|
||||
'libcef_dll/ctocpp/v8handler_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/v8handler_ctocpp.h',
|
||||
'libcef_dll/ctocpp/v8interceptor_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/v8interceptor_ctocpp.h',
|
||||
'libcef_dll/cpptoc/v8stack_frame_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/v8stack_frame_cpptoc.h',
|
||||
'libcef_dll/cpptoc/v8stack_trace_cpptoc.cc',
|
||||
@@ -418,6 +428,10 @@
|
||||
'libcef_dll/ctocpp/views/window_delegate_ctocpp.h',
|
||||
'libcef_dll/ctocpp/write_handler_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/write_handler_ctocpp.h',
|
||||
'libcef_dll/cpptoc/x509cert_principal_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/x509cert_principal_cpptoc.h',
|
||||
'libcef_dll/cpptoc/x509certificate_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/x509certificate_cpptoc.h',
|
||||
'libcef_dll/cpptoc/xml_reader_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/xml_reader_cpptoc.h',
|
||||
'libcef_dll/cpptoc/zip_reader_cpptoc.cc',
|
||||
@@ -562,6 +576,8 @@
|
||||
'libcef_dll/ctocpp/process_message_ctocpp.h',
|
||||
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/read_handler_cpptoc.h',
|
||||
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.h',
|
||||
'libcef_dll/cpptoc/render_handler_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/render_handler_cpptoc.h',
|
||||
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',
|
||||
@@ -592,16 +608,18 @@
|
||||
'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',
|
||||
'libcef_dll/ctocpp/sslcert_principal_ctocpp.h',
|
||||
'libcef_dll/ctocpp/sslinfo_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/sslinfo_ctocpp.h',
|
||||
'libcef_dll/ctocpp/sslstatus_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/sslstatus_ctocpp.h',
|
||||
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h',
|
||||
'libcef_dll/ctocpp/scheme_registrar_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/scheme_registrar_ctocpp.h',
|
||||
'libcef_dll/ctocpp/views/scroll_view_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/views/scroll_view_ctocpp.h',
|
||||
'libcef_dll/ctocpp/select_client_certificate_callback_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/select_client_certificate_callback_ctocpp.h',
|
||||
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.h',
|
||||
'libcef_dll/ctocpp/stream_reader_ctocpp.cc',
|
||||
@@ -642,6 +660,8 @@
|
||||
'libcef_dll/ctocpp/v8exception_ctocpp.h',
|
||||
'libcef_dll/cpptoc/v8handler_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/v8handler_cpptoc.h',
|
||||
'libcef_dll/cpptoc/v8interceptor_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/v8interceptor_cpptoc.h',
|
||||
'libcef_dll/ctocpp/v8stack_frame_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/v8stack_frame_ctocpp.h',
|
||||
'libcef_dll/ctocpp/v8stack_trace_ctocpp.cc',
|
||||
@@ -666,6 +686,10 @@
|
||||
'libcef_dll/cpptoc/views/window_delegate_cpptoc.h',
|
||||
'libcef_dll/cpptoc/write_handler_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/write_handler_cpptoc.h',
|
||||
'libcef_dll/ctocpp/x509cert_principal_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/x509cert_principal_ctocpp.h',
|
||||
'libcef_dll/ctocpp/x509certificate_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/x509certificate_ctocpp.h',
|
||||
'libcef_dll/ctocpp/xml_reader_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/xml_reader_ctocpp.h',
|
||||
'libcef_dll/ctocpp/zip_reader_ctocpp.cc',
|
||||
|
@@ -3,10 +3,6 @@
|
||||
# can be found in the LICENSE file.
|
||||
|
||||
{
|
||||
'includes': [
|
||||
# Bring in the autogenerated source file lists.
|
||||
'cef_paths.gypi',
|
||||
],
|
||||
'variables': {
|
||||
'includes_common': [
|
||||
'include/base/cef_atomic_ref_count.h',
|
||||
@@ -40,8 +36,6 @@
|
||||
'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h',
|
||||
'include/base/internal/cef_thread_checker_impl.h',
|
||||
'include/cef_base.h',
|
||||
'include/cef_pack_resources.h',
|
||||
'include/cef_pack_strings.h',
|
||||
'include/cef_version.h',
|
||||
'include/internal/cef_export.h',
|
||||
'include/internal/cef_logging_internal.h',
|
||||
@@ -57,11 +51,9 @@
|
||||
'include/internal/cef_trace_event_internal.h',
|
||||
'include/internal/cef_types.h',
|
||||
'include/internal/cef_types_wrappers.h',
|
||||
'<@(autogen_cpp_includes)',
|
||||
],
|
||||
'includes_capi': [
|
||||
'include/capi/cef_base_capi.h',
|
||||
'<@(autogen_capi_includes)',
|
||||
],
|
||||
'includes_wrapper': [
|
||||
'include/wrapper/cef_byte_read_handler.h',
|
||||
@@ -89,6 +81,7 @@
|
||||
],
|
||||
'includes_linux': [
|
||||
'include/base/internal/cef_atomicops_atomicword_compat.h',
|
||||
'include/base/internal/cef_atomicops_arm_gcc.h',
|
||||
'include/base/internal/cef_atomicops_x86_gcc.h',
|
||||
'include/internal/cef_linux.h',
|
||||
'include/internal/cef_types_linux.h',
|
||||
@@ -104,7 +97,6 @@
|
||||
'libcef_dll/transfer_util.cc',
|
||||
'libcef_dll/transfer_util.h',
|
||||
'libcef_dll/wrapper_types.h',
|
||||
'<@(autogen_library_side)',
|
||||
],
|
||||
'libcef_dll_wrapper_sources_base': [
|
||||
'libcef_dll/base/cef_atomicops_x86_gcc.cc',
|
||||
@@ -138,7 +130,6 @@
|
||||
'libcef_dll/wrapper/cef_zip_archive.cc',
|
||||
'libcef_dll/wrapper/libcef_dll_wrapper.cc',
|
||||
'libcef_dll/wrapper/libcef_dll_wrapper2.cc',
|
||||
'<@(autogen_client_side)',
|
||||
],
|
||||
'cefclient_sources_browser': [
|
||||
'tests/cefclient/browser/binding_test.cc',
|
||||
@@ -159,6 +150,8 @@
|
||||
'tests/cefclient/browser/client_types.h',
|
||||
'tests/cefclient/browser/dialog_test.cc',
|
||||
'tests/cefclient/browser/dialog_test.h',
|
||||
'tests/cefclient/browser/drm_test.cc',
|
||||
'tests/cefclient/browser/drm_test.h',
|
||||
'tests/cefclient/browser/geometry_util.cc',
|
||||
'tests/cefclient/browser/geometry_util.h',
|
||||
'tests/cefclient/browser/main_context.cc',
|
||||
@@ -167,6 +160,8 @@
|
||||
'tests/cefclient/browser/main_context_impl.h',
|
||||
'tests/cefclient/browser/main_message_loop.h',
|
||||
'tests/cefclient/browser/main_message_loop.cc',
|
||||
'tests/cefclient/browser/main_message_loop_external_pump.cc',
|
||||
'tests/cefclient/browser/main_message_loop_external_pump.h',
|
||||
'tests/cefclient/browser/main_message_loop_std.h',
|
||||
'tests/cefclient/browser/main_message_loop_std.cc',
|
||||
'tests/cefclient/browser/osr_dragdrop_events.h',
|
||||
@@ -222,6 +217,7 @@
|
||||
'tests/cefclient/resources/binding.html',
|
||||
'tests/cefclient/resources/dialogs.html',
|
||||
'tests/cefclient/resources/draggable.html',
|
||||
'tests/cefclient/resources/drm.html',
|
||||
'tests/cefclient/resources/localstorage.html',
|
||||
'tests/cefclient/resources/logo.png',
|
||||
'tests/cefclient/resources/menu_icon.1x.png',
|
||||
@@ -247,6 +243,7 @@
|
||||
'tests/cefclient/browser/browser_window_std_win.cc',
|
||||
'tests/cefclient/browser/browser_window_std_win.h',
|
||||
'tests/cefclient/browser/main_context_impl_win.cc',
|
||||
'tests/cefclient/browser/main_message_loop_external_pump_win.cc',
|
||||
'tests/cefclient/browser/main_message_loop_multithreaded_win.cc',
|
||||
'tests/cefclient/browser/main_message_loop_multithreaded_win.h',
|
||||
'tests/cefclient/browser/osr_dragdrop_win.cc',
|
||||
@@ -273,10 +270,6 @@
|
||||
'tests/cefclient/resources/win/cefclient.ico',
|
||||
'tests/cefclient/resources/win/cefclient.rc',
|
||||
'tests/cefclient/resources/win/small.ico',
|
||||
'<@(cefclient_sources_browser)',
|
||||
'<@(cefclient_sources_common)',
|
||||
'<@(cefclient_sources_renderer)',
|
||||
'<@(cefclient_sources_resources)',
|
||||
],
|
||||
'cefclient_sources_mac': [
|
||||
'tests/cefclient/browser/browser_window_osr_mac.h',
|
||||
@@ -284,6 +277,7 @@
|
||||
'tests/cefclient/browser/browser_window_std_mac.h',
|
||||
'tests/cefclient/browser/browser_window_std_mac.mm',
|
||||
'tests/cefclient/browser/main_context_impl_posix.cc',
|
||||
'tests/cefclient/browser/main_message_loop_external_pump_mac.mm',
|
||||
'tests/cefclient/browser/resource_util_mac.mm',
|
||||
'tests/cefclient/browser/resource_util_posix.cc',
|
||||
'tests/cefclient/browser/root_window_mac.h',
|
||||
@@ -293,20 +287,15 @@
|
||||
'tests/cefclient/browser/window_test_runner_mac.h',
|
||||
'tests/cefclient/browser/window_test_runner_mac.mm',
|
||||
'tests/cefclient/cefclient_mac.mm',
|
||||
'<@(cefclient_sources_browser)',
|
||||
'<@(cefclient_sources_common)',
|
||||
],
|
||||
'cefclient_sources_mac_helper': [
|
||||
'tests/cefclient/process_helper_mac.cc',
|
||||
'<@(cefclient_sources_common)',
|
||||
'<@(cefclient_sources_renderer)',
|
||||
],
|
||||
'cefclient_bundle_resources_mac': [
|
||||
'tests/cefclient/resources/mac/cefclient.icns',
|
||||
'tests/cefclient/resources/mac/English.lproj/InfoPlist.strings',
|
||||
'tests/cefclient/resources/mac/English.lproj/MainMenu.xib',
|
||||
'tests/cefclient/resources/mac/Info.plist',
|
||||
'<@(cefclient_sources_resources)',
|
||||
],
|
||||
'cefclient_sources_linux': [
|
||||
'tests/cefclient/browser/browser_window_osr_gtk.cc',
|
||||
@@ -316,6 +305,7 @@
|
||||
'tests/cefclient/browser/dialog_handler_gtk.cc',
|
||||
'tests/cefclient/browser/dialog_handler_gtk.h',
|
||||
'tests/cefclient/browser/main_context_impl_posix.cc',
|
||||
'tests/cefclient/browser/main_message_loop_external_pump_linux.cc',
|
||||
'tests/cefclient/browser/print_handler_gtk.cc',
|
||||
'tests/cefclient/browser/print_handler_gtk.h',
|
||||
'tests/cefclient/browser/resource_util_linux.cc',
|
||||
@@ -333,12 +323,6 @@
|
||||
'tests/cefclient/browser/window_test_runner_views.cc',
|
||||
'tests/cefclient/browser/window_test_runner_views.h',
|
||||
'tests/cefclient/cefclient_gtk.cc',
|
||||
'<@(cefclient_sources_browser)',
|
||||
'<@(cefclient_sources_common)',
|
||||
'<@(cefclient_sources_renderer)',
|
||||
],
|
||||
'cefclient_bundle_resources_linux': [
|
||||
'<@(cefclient_sources_resources)',
|
||||
],
|
||||
'cefsimple_sources_common': [
|
||||
'tests/cefsimple/simple_app.cc',
|
||||
|
127
cef_repack_locales.gni
Normal file
127
cef_repack_locales.gni
Normal file
@@ -0,0 +1,127 @@
|
||||
# Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
|
||||
# 2014 the Chromium Authors. All rights reserved. Use of this source code is
|
||||
# governed by a BSD-style license that can be found in the LICENSE file.
|
||||
#
|
||||
# This is a copy of src/chrome/chrome_repack_locales.gni with the necessary
|
||||
# modifications to meet CEF's requirements.
|
||||
|
||||
import("//build/config/chrome_build.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/config/ui.gni")
|
||||
import("//tools/grit/repack.gni")
|
||||
|
||||
# Arguments:
|
||||
#
|
||||
# locale
|
||||
# Internal name of locale. e.g. "pt-BR"
|
||||
#
|
||||
# output
|
||||
# Output file name.
|
||||
#
|
||||
# visibility
|
||||
# Normal meaning.
|
||||
template("_repack_one_locale") {
|
||||
locale = invoker.locale
|
||||
|
||||
repack(target_name) {
|
||||
visibility = invoker.visibility
|
||||
|
||||
# Each input pak file should also have a deps line for completeness.
|
||||
sources = [
|
||||
"${root_gen_dir}/cef/cef_strings_${locale}.pak",
|
||||
"${root_gen_dir}/chrome/generated_resources_${locale}.pak",
|
||||
"${root_gen_dir}/chrome/locale_settings_${locale}.pak",
|
||||
"${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak",
|
||||
"${root_gen_dir}/components/strings/components_locale_settings_${locale}.pak",
|
||||
"${root_gen_dir}/components/strings/components_strings_${locale}.pak",
|
||||
"${root_gen_dir}/content/app/strings/content_strings_${locale}.pak",
|
||||
"${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak",
|
||||
"${root_gen_dir}/ui/strings/app_locale_settings_${locale}.pak",
|
||||
"${root_gen_dir}/ui/strings/ui_strings_${locale}.pak",
|
||||
]
|
||||
|
||||
# Use public_deps so that generated grit headers are discoverable from
|
||||
# the libcef_static target. Grit deps that generate .cc files must be
|
||||
# listed both here and in the libcef_static target.
|
||||
public_deps = [
|
||||
":cef_strings",
|
||||
"//chrome/app:generated_resources",
|
||||
"//chrome/app/resources:locale_settings",
|
||||
"//chrome/app/resources:platform_locale_settings",
|
||||
"//components/strings:components_locale_settings",
|
||||
"//components/strings:components_strings",
|
||||
"//content/app/strings",
|
||||
"//extensions/strings",
|
||||
"//ui/strings:app_locale_settings",
|
||||
"//ui/strings:ui_strings",
|
||||
]
|
||||
|
||||
output = invoker.output
|
||||
}
|
||||
}
|
||||
|
||||
# Creates an action to call the repack_locales script.
|
||||
#
|
||||
# The GYP version generates the locales in the "gen" directory and then copies
|
||||
# it to the root build directory. This isn't easy to express in a GN copy
|
||||
# rule since the files on Mac have a complex structure. So we generate the
|
||||
# files into the final place and skip the "gen" directory.
|
||||
#
|
||||
# This template uses GN's looping constructs to avoid the complex call to
|
||||
# chrome/tools/build/repack_locales.py which wraps the repack commands in the
|
||||
# GYP build.
|
||||
#
|
||||
# Arguments
|
||||
#
|
||||
# input_locales
|
||||
# List of locale names to use as inputs.
|
||||
#
|
||||
# output_locales
|
||||
# A list containing the corresponding output names for each of the
|
||||
# input names. Mac uses different names in some cases.
|
||||
#
|
||||
# visibility
|
||||
template("cef_repack_locales") {
|
||||
# This is the name of the group below that will collect all the invidual
|
||||
# locale targets. External targets will depend on this.
|
||||
group_target_name = target_name
|
||||
|
||||
# GN's subscript is too stupid to do invoker.output_locales[foo] so we need
|
||||
# to make a copy and do output_locales[foo].
|
||||
output_locales = invoker.output_locales
|
||||
|
||||
# Collects all targets the loop generates.
|
||||
locale_targets = []
|
||||
|
||||
# This loop iterates over the input locales and also keeps a counter so it
|
||||
# can simultaneously iterate over the output locales (using GN's very
|
||||
# limited looping capabilities).
|
||||
current_index = 0
|
||||
foreach(input_locale, invoker.input_locales) {
|
||||
output_locale = output_locales[current_index]
|
||||
|
||||
# Compute the name of the target for the current file. Save it for the deps.
|
||||
current_name = "${target_name}_${input_locale}"
|
||||
locale_targets += [ ":$current_name" ]
|
||||
|
||||
_repack_one_locale(current_name) {
|
||||
visibility = [ ":$group_target_name" ]
|
||||
locale = input_locale
|
||||
|
||||
# Compute the output name. Mac uses a different location.
|
||||
if (is_mac || is_ios) {
|
||||
output = "${root_gen_dir}/repack/locales/${output_locale}.pak"
|
||||
} else {
|
||||
output = "${root_out_dir}/locales/${output_locale}.pak"
|
||||
}
|
||||
}
|
||||
|
||||
current_index = current_index + 1
|
||||
}
|
||||
|
||||
# The group that external targets depend on which collects all deps.
|
||||
group(group_target_name) {
|
||||
forward_variables_from(invoker, [ "visibility" ])
|
||||
public_deps = locale_targets
|
||||
}
|
||||
}
|
@@ -185,26 +185,20 @@ endif(OS_LINUX)
|
||||
|
||||
if(OS_MACOSX)
|
||||
|
||||
# Fix the framework link in the helper executable.
|
||||
macro(FIX_MACOSX_HELPER_FRAMEWORK_LINK target app_path)
|
||||
add_custom_command(TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND install_name_tool -change "@executable_path/Chromium Embedded Framework"
|
||||
"@executable_path/../../../../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework"
|
||||
"${app_path}/Contents/MacOS/${target}"
|
||||
VERBATIM
|
||||
)
|
||||
# Fix the framework rpath in the helper executable.
|
||||
macro(FIX_MACOSX_HELPER_FRAMEWORK_RPATH target)
|
||||
# The helper is in $app_name.app/Contents/Frameworks/$app_name Helper.app/Contents/MacOS/
|
||||
# so set rpath up to Contents/ so that the loader can find Frameworks/.
|
||||
set_target_properties(${target} PROPERTIES INSTALL_RPATH "@executable_path/../../../..")
|
||||
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
endmacro()
|
||||
|
||||
# Fix the framework link in the main executable.
|
||||
macro(FIX_MACOSX_MAIN_FRAMEWORK_LINK target app_path)
|
||||
add_custom_command(TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND install_name_tool -change "@executable_path/Chromium Embedded Framework"
|
||||
"@executable_path/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework"
|
||||
"${app_path}/Contents/MacOS/${target}"
|
||||
VERBATIM
|
||||
)
|
||||
# Fix the framework rpath in the main executable.
|
||||
macro(FIX_MACOSX_MAIN_FRAMEWORK_RPATH target)
|
||||
# The main app is at $app_name.app/Contents/MacOS/$app_name
|
||||
# so set rpath up to Contents/ so that the loader can find Frameworks/.
|
||||
set_target_properties(${target} PROPERTIES INSTALL_RPATH "@executable_path/..")
|
||||
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
endmacro()
|
||||
|
||||
# Manually process and copy over resource files.
|
||||
|
@@ -305,6 +305,24 @@ endif()
|
||||
#
|
||||
|
||||
if(OS_WINDOWS)
|
||||
# Configure use of the sandbox.
|
||||
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
|
||||
if(USE_SANDBOX AND NOT MSVC_VERSION EQUAL 1900)
|
||||
# The cef_sandbox.lib static library is currently built with VS2015. It will
|
||||
# not link successfully with other VS versions.
|
||||
set(USE_SANDBOX OFF)
|
||||
endif()
|
||||
|
||||
# Configure use of official build compiler settings.
|
||||
# When using an official build the "Debug" build is actually a Release build
|
||||
# with DCHECKs enabled. In order to link the sandbox the Debug build must
|
||||
# be configured with some Release-related compiler settings.
|
||||
option(USE_OFFICIAL_BUILD_SANDBOX "Enable or disable use of an official build sandbox." ON)
|
||||
if(NOT USE_SANDBOX)
|
||||
# Don't need official build settings when the sandbox is off.
|
||||
set(USE_OFFICIAL_BUILD_SANDBOX OFF)
|
||||
endif()
|
||||
|
||||
# Consumers who run into LNK4099 warnings can pass /Z7 instead (see issue #385).
|
||||
set(CEF_DEBUG_INFO_FLAG "/Zi" CACHE STRING "Optional flag specifying specific /Z flag to use")
|
||||
|
||||
@@ -326,11 +344,22 @@ if(OS_WINDOWS)
|
||||
/wd4996 # Ignore "function or variable may be unsafe" warning
|
||||
${CEF_DEBUG_INFO_FLAG}
|
||||
)
|
||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||
/MTd # Multithreaded debug runtime
|
||||
/RTC1 # Disable optimizations
|
||||
/Od # Enable basic run-time checks
|
||||
)
|
||||
if(USE_OFFICIAL_BUILD_SANDBOX)
|
||||
# CMake adds /RTC1, /D"_DEBUG" and a few other values by default for Debug
|
||||
# builds. We can't link the sandbox with those values so clear the CMake
|
||||
# defaults here.
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "")
|
||||
|
||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||
/MT # Multithreaded release runtime
|
||||
)
|
||||
else()
|
||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||
/MTd # Multithreaded debug runtime
|
||||
/RTC1 # Disable optimizations
|
||||
/Od # Enable basic run-time checks
|
||||
)
|
||||
endif()
|
||||
list(APPEND CEF_COMPILER_FLAGS_RELEASE
|
||||
/MT # Multithreaded release runtime
|
||||
/O2 # Optimize for maximum speed
|
||||
@@ -341,7 +370,8 @@ if(OS_WINDOWS)
|
||||
/DEBUG # Generate debug information
|
||||
)
|
||||
list(APPEND CEF_EXE_LINKER_FLAGS
|
||||
/MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage)
|
||||
/MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage)
|
||||
/LARGEADDRESSAWARE # Allow 32-bit processes to access 3GB of RAM
|
||||
)
|
||||
list(APPEND CEF_COMPILER_DEFINES
|
||||
WIN32 _WIN32 _WINDOWS # Windows platform
|
||||
@@ -351,6 +381,12 @@ if(OS_WINDOWS)
|
||||
WIN32_LEAN_AND_MEAN # Exclude less common API declarations
|
||||
_HAS_EXCEPTIONS=0 # Disable exceptions
|
||||
)
|
||||
if(USE_OFFICIAL_BUILD_SANDBOX)
|
||||
list(APPEND CEF_COMPILER_DEFINES_DEBUG
|
||||
NDEBUG _NDEBUG # Not a debug build
|
||||
DCHECK_ALWAYS_ON=1 # DCHECKs are enabled
|
||||
)
|
||||
endif()
|
||||
list(APPEND CEF_COMPILER_DEFINES_RELEASE
|
||||
NDEBUG _NDEBUG # Not a debug build
|
||||
)
|
||||
@@ -395,14 +431,6 @@ if(OS_WINDOWS)
|
||||
locales
|
||||
)
|
||||
|
||||
# Configure use of the sandbox.
|
||||
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
|
||||
if(USE_SANDBOX AND NOT MSVC_VERSION EQUAL 1900)
|
||||
# The cef_sandbox.lib static library is currently built with VS2015. It will
|
||||
# not link successfully with other VS versions.
|
||||
set(USE_SANDBOX OFF)
|
||||
endif()
|
||||
|
||||
if(USE_SANDBOX)
|
||||
list(APPEND CEF_COMPILER_DEFINES
|
||||
PSAPI_VERSION=1 # Required by cef_sandbox.lib
|
||||
|
@@ -183,6 +183,8 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
|
||||
#include "include/base/internal/cef_atomicops_mac.h"
|
||||
#elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)
|
||||
#include "include/base/internal/cef_atomicops_x86_gcc.h"
|
||||
#elif defined(COMPILER_GCC) && defined(__ARM_ARCH)
|
||||
#include "include/base/internal/cef_atomicops_arm_gcc.h"
|
||||
#else
|
||||
#error "Atomic operations are not supported on your platform"
|
||||
#endif
|
||||
|
@@ -45,18 +45,20 @@
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_macros.h"
|
||||
#include "include/base/cef_platform_thread.h"
|
||||
#include "include/base/internal/cef_lock_impl.h"
|
||||
|
||||
namespace base {
|
||||
namespace cef_internal {
|
||||
|
||||
// A convenient wrapper for an OS specific critical section. The only real
|
||||
// intelligence in this class is in debug mode for the support for the
|
||||
// AssertAcquired() method.
|
||||
class Lock {
|
||||
public:
|
||||
#if defined(NDEBUG) // Optimized wrapper implementation
|
||||
#if !DCHECK_IS_ON() // Optimized wrapper implementation
|
||||
Lock() : lock_() {}
|
||||
~Lock() {}
|
||||
void Acquire() { lock_.Lock(); }
|
||||
@@ -95,10 +97,10 @@ class Lock {
|
||||
}
|
||||
|
||||
void AssertAcquired() const;
|
||||
#endif // NDEBUG
|
||||
#endif // !DCHECK_IS_ON()
|
||||
|
||||
private:
|
||||
#if !defined(NDEBUG)
|
||||
#if DCHECK_IS_ON()
|
||||
// Members and routines taking care of locks assertions.
|
||||
// Note that this checks for recursive locks and allows them
|
||||
// if the variable is set. This is allowed by the underlying implementation
|
||||
@@ -110,10 +112,10 @@ class Lock {
|
||||
// All private data is implicitly protected by lock_.
|
||||
// Be VERY careful to only access members under that lock.
|
||||
base::PlatformThreadRef owning_thread_ref_;
|
||||
#endif // NDEBUG
|
||||
#endif // DCHECK_IS_ON()
|
||||
|
||||
// Platform specific underlying lock implementation.
|
||||
cef_internal::LockImpl lock_;
|
||||
LockImpl lock_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Lock);
|
||||
};
|
||||
@@ -160,6 +162,15 @@ class AutoUnlock {
|
||||
DISALLOW_COPY_AND_ASSIGN(AutoUnlock);
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
|
||||
// Implement classes in the cef_internal namespace and then expose them to the
|
||||
// base namespace. This avoids conflicts with the base.lib implementation when
|
||||
// linking sandbox support on Windows.
|
||||
using cef_internal::Lock;
|
||||
using cef_internal::AutoLock;
|
||||
using cef_internal::AutoUnlock;
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
@@ -39,6 +39,10 @@
|
||||
// Chromium uses movable types.
|
||||
#define MOVE_SCOPED_PTR(var) std::move(var)
|
||||
|
||||
// Chromium uses std types.
|
||||
#define SCOPED_PTR(type) std::unique_ptr<type>
|
||||
#define DEFAULT_DELETER(type) std::default_delete<type>
|
||||
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
@@ -50,6 +54,10 @@
|
||||
// CEF does not use movable types.
|
||||
#define MOVE_SCOPED_PTR(var) var.Pass()
|
||||
|
||||
// CEF uses base types.
|
||||
#define SCOPED_PTR(type) scoped_ptr<type>
|
||||
#define DEFAULT_DELETER(type) struct base::DefaultDeleter<type>
|
||||
|
||||
#if !defined(arraysize)
|
||||
|
||||
// The arraysize(arr) macro returns the # of elements in an array arr.
|
||||
|
@@ -50,9 +50,7 @@
|
||||
|
||||
#include "include/base/cef_atomic_ref_count.h"
|
||||
#include "include/base/cef_build.h"
|
||||
#ifndef NDEBUG
|
||||
#include "include/base/cef_logging.h"
|
||||
#endif
|
||||
#include "include/base/cef_thread_collision_warner.h"
|
||||
|
||||
namespace base {
|
||||
@@ -66,14 +64,14 @@ class RefCountedBase {
|
||||
protected:
|
||||
RefCountedBase()
|
||||
: ref_count_(0)
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
, in_dtor_(false)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
~RefCountedBase() {
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
|
||||
#endif
|
||||
}
|
||||
@@ -84,7 +82,7 @@ class RefCountedBase {
|
||||
// Current thread books the critical section "AddRelease"
|
||||
// without release it.
|
||||
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
#endif
|
||||
++ref_count_;
|
||||
@@ -96,11 +94,11 @@ class RefCountedBase {
|
||||
// Current thread books the critical section "AddRelease"
|
||||
// without release it.
|
||||
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
#endif
|
||||
if (--ref_count_ == 0) {
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
in_dtor_ = true;
|
||||
#endif
|
||||
return true;
|
||||
@@ -110,7 +108,7 @@ class RefCountedBase {
|
||||
|
||||
private:
|
||||
mutable int ref_count_;
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
mutable bool in_dtor_;
|
||||
#endif
|
||||
|
||||
@@ -134,7 +132,7 @@ class RefCountedThreadSafeBase {
|
||||
|
||||
private:
|
||||
mutable AtomicRefCount ref_count_;
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
mutable bool in_dtor_;
|
||||
#endif
|
||||
|
||||
|
@@ -120,8 +120,7 @@
|
||||
// client application. When using Chromium code directly always include
|
||||
// the Chromium header first to avoid type conflicts.
|
||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
// Do nothing when building CEF.
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include "include/base/cef_atomicops.h"
|
||||
#include "include/base/cef_basictypes.h"
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_macros.h"
|
||||
|
||||
// A helper class alongside macros to be used to verify assumptions about thread
|
||||
@@ -139,7 +140,7 @@
|
||||
// };
|
||||
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
#if DCHECK_IS_ON()
|
||||
|
||||
// Defines a class member that acts like a mutex. It is used only as a
|
||||
// verification tool.
|
||||
|
320
include/base/internal/cef_atomicops_arm_gcc.h
Normal file
320
include/base/internal/cef_atomicops_arm_gcc.h
Normal file
@@ -0,0 +1,320 @@
|
||||
// Copyright (c) 2013 Google Inc. 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.
|
||||
//
|
||||
// Do not include this header file directly. Use base/cef_atomicops.h
|
||||
// instead.
|
||||
//
|
||||
// LinuxKernelCmpxchg and Barrier_AtomicIncrement are from Google Gears.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM_GCC_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM_GCC_H_
|
||||
|
||||
#if defined(OS_QNX)
|
||||
#include <sys/cpuinline.h>
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
namespace subtle {
|
||||
|
||||
// Memory barriers on ARM are funky, but the kernel is here to help:
|
||||
//
|
||||
// * ARMv5 didn't support SMP, there is no memory barrier instruction at
|
||||
// all on this architecture, or when targeting its machine code.
|
||||
//
|
||||
// * Some ARMv6 CPUs support SMP. A full memory barrier can be produced by
|
||||
// writing a random value to a very specific coprocessor register.
|
||||
//
|
||||
// * On ARMv7, the "dmb" instruction is used to perform a full memory
|
||||
// barrier (though writing to the co-processor will still work).
|
||||
// However, on single core devices (e.g. Nexus One, or Nexus S),
|
||||
// this instruction will take up to 200 ns, which is huge, even though
|
||||
// it's completely un-needed on these devices.
|
||||
//
|
||||
// * There is no easy way to determine at runtime if the device is
|
||||
// single or multi-core. However, the kernel provides a useful helper
|
||||
// function at a fixed memory address (0xffff0fa0), which will always
|
||||
// perform a memory barrier in the most efficient way. I.e. on single
|
||||
// core devices, this is an empty function that exits immediately.
|
||||
// On multi-core devices, it implements a full memory barrier.
|
||||
//
|
||||
// * This source could be compiled to ARMv5 machine code that runs on a
|
||||
// multi-core ARMv6 or ARMv7 device. In this case, memory barriers
|
||||
// are needed for correct execution. Always call the kernel helper, even
|
||||
// when targeting ARMv5TE.
|
||||
//
|
||||
|
||||
inline void MemoryBarrier() {
|
||||
#if defined(OS_LINUX) || defined(OS_ANDROID)
|
||||
// Note: This is a function call, which is also an implicit compiler barrier.
|
||||
typedef void (*KernelMemoryBarrierFunc)();
|
||||
((KernelMemoryBarrierFunc)0xffff0fa0)();
|
||||
#elif defined(OS_QNX)
|
||||
__cpu_membarrier();
|
||||
#else
|
||||
#error MemoryBarrier() is not implemented on this platform.
|
||||
#endif
|
||||
}
|
||||
|
||||
// An ARM toolchain would only define one of these depending on which
|
||||
// variant of the target architecture is being used. This tests against
|
||||
// any known ARMv6 or ARMv7 variant, where it is possible to directly
|
||||
// use ldrex/strex instructions to implement fast atomic operations.
|
||||
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
|
||||
defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || \
|
||||
defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
|
||||
defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \
|
||||
defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__)
|
||||
|
||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 prev_value;
|
||||
int reloop;
|
||||
do {
|
||||
// The following is equivalent to:
|
||||
//
|
||||
// prev_value = LDREX(ptr)
|
||||
// reloop = 0
|
||||
// if (prev_value != old_value)
|
||||
// reloop = STREX(ptr, new_value)
|
||||
__asm__ __volatile__(" ldrex %0, [%3]\n"
|
||||
" mov %1, #0\n"
|
||||
" cmp %0, %4\n"
|
||||
#ifdef __thumb2__
|
||||
" it eq\n"
|
||||
#endif
|
||||
" strexeq %1, %5, [%3]\n"
|
||||
: "=&r"(prev_value), "=&r"(reloop), "+m"(*ptr)
|
||||
: "r"(ptr), "r"(old_value), "r"(new_value)
|
||||
: "cc", "memory");
|
||||
} while (reloop != 0);
|
||||
return prev_value;
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 result = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
MemoryBarrier();
|
||||
return result;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
MemoryBarrier();
|
||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
Atomic32 value;
|
||||
int reloop;
|
||||
do {
|
||||
// Equivalent to:
|
||||
//
|
||||
// value = LDREX(ptr)
|
||||
// value += increment
|
||||
// reloop = STREX(ptr, value)
|
||||
//
|
||||
__asm__ __volatile__(" ldrex %0, [%3]\n"
|
||||
" add %0, %0, %4\n"
|
||||
" strex %1, %0, [%3]\n"
|
||||
: "=&r"(value), "=&r"(reloop), "+m"(*ptr)
|
||||
: "r"(ptr), "r"(increment)
|
||||
: "cc", "memory");
|
||||
} while (reloop);
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
// TODO(digit): Investigate if it's possible to implement this with
|
||||
// a single MemoryBarrier() operation between the LDREX and STREX.
|
||||
// See http://crbug.com/246514
|
||||
MemoryBarrier();
|
||||
Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment);
|
||||
MemoryBarrier();
|
||||
return result;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 old_value;
|
||||
int reloop;
|
||||
do {
|
||||
// old_value = LDREX(ptr)
|
||||
// reloop = STREX(ptr, new_value)
|
||||
__asm__ __volatile__(" ldrex %0, [%3]\n"
|
||||
" strex %1, %4, [%3]\n"
|
||||
: "=&r"(old_value), "=&r"(reloop), "+m"(*ptr)
|
||||
: "r"(ptr), "r"(new_value)
|
||||
: "cc", "memory");
|
||||
} while (reloop != 0);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
// This tests against any known ARMv5 variant.
|
||||
#elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
|
||||
defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
|
||||
|
||||
// The kernel also provides a helper function to perform an atomic
|
||||
// compare-and-swap operation at the hard-wired address 0xffff0fc0.
|
||||
// On ARMv5, this is implemented by a special code path that the kernel
|
||||
// detects and treats specially when thread pre-emption happens.
|
||||
// On ARMv6 and higher, it uses LDREX/STREX instructions instead.
|
||||
//
|
||||
// Note that this always perform a full memory barrier, there is no
|
||||
// need to add calls MemoryBarrier() before or after it. It also
|
||||
// returns 0 on success, and 1 on exit.
|
||||
//
|
||||
// Available and reliable since Linux 2.6.24. Both Android and ChromeOS
|
||||
// use newer kernel revisions, so this should not be a concern.
|
||||
namespace {
|
||||
|
||||
inline int LinuxKernelCmpxchg(Atomic32 old_value,
|
||||
Atomic32 new_value,
|
||||
volatile Atomic32* ptr) {
|
||||
typedef int (*KernelCmpxchgFunc)(Atomic32, Atomic32, volatile Atomic32*);
|
||||
return ((KernelCmpxchgFunc)0xffff0fc0)(old_value, new_value, ptr);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 prev_value;
|
||||
for (;;) {
|
||||
prev_value = *ptr;
|
||||
if (prev_value != old_value)
|
||||
return prev_value;
|
||||
if (!LinuxKernelCmpxchg(old_value, new_value, ptr))
|
||||
return old_value;
|
||||
}
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 old_value;
|
||||
do {
|
||||
old_value = *ptr;
|
||||
} while (LinuxKernelCmpxchg(old_value, new_value, ptr));
|
||||
return old_value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
return Barrier_AtomicIncrement(ptr, increment);
|
||||
}
|
||||
|
||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||
Atomic32 increment) {
|
||||
for (;;) {
|
||||
// Atomic exchange the old value with an incremented one.
|
||||
Atomic32 old_value = *ptr;
|
||||
Atomic32 new_value = old_value + increment;
|
||||
if (!LinuxKernelCmpxchg(old_value, new_value, ptr)) {
|
||||
// The exchange took place as expected.
|
||||
return new_value;
|
||||
}
|
||||
// Otherwise, *ptr changed mid-loop and we need to retry.
|
||||
}
|
||||
}
|
||||
|
||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
Atomic32 prev_value;
|
||||
for (;;) {
|
||||
prev_value = *ptr;
|
||||
if (prev_value != old_value) {
|
||||
// Always ensure acquire semantics.
|
||||
MemoryBarrier();
|
||||
return prev_value;
|
||||
}
|
||||
if (!LinuxKernelCmpxchg(old_value, new_value, ptr))
|
||||
return old_value;
|
||||
}
|
||||
}
|
||||
|
||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||
Atomic32 old_value,
|
||||
Atomic32 new_value) {
|
||||
// This could be implemented as:
|
||||
// MemoryBarrier();
|
||||
// return NoBarrier_CompareAndSwap();
|
||||
//
|
||||
// But would use 3 barriers per succesful CAS. To save performance,
|
||||
// use Acquire_CompareAndSwap(). Its implementation guarantees that:
|
||||
// - A succesful swap uses only 2 barriers (in the kernel helper).
|
||||
// - An early return due to (prev_value != old_value) performs
|
||||
// a memory barrier with no store, which is equivalent to the
|
||||
// generic implementation above.
|
||||
return Acquire_CompareAndSwap(ptr, old_value, new_value);
|
||||
}
|
||||
|
||||
#else
|
||||
# error "Your CPU's ARM architecture is not supported yet"
|
||||
#endif
|
||||
|
||||
// NOTE: Atomicity of the following load and store operations is only
|
||||
// guaranteed in case of 32-bit alignement of |ptr| values.
|
||||
|
||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
*ptr = value;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||
MemoryBarrier();
|
||||
*ptr = value;
|
||||
}
|
||||
|
||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { return *ptr; }
|
||||
|
||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||
Atomic32 value = *ptr;
|
||||
MemoryBarrier();
|
||||
return value;
|
||||
}
|
||||
|
||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||
MemoryBarrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
} // namespace base::subtle
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM_GCC_H_
|
@@ -144,11 +144,18 @@ CEF_EXPORT void cef_shutdown();
|
||||
|
||||
///
|
||||
// Perform a single iteration of CEF message loop processing. This function is
|
||||
// used to integrate the CEF message loop into an existing application message
|
||||
// loop. Care must be taken to balance performance against excessive CPU usage.
|
||||
// This function should only be called on the main application thread and only
|
||||
// if cef_initialize() is called with a CefSettings.multi_threaded_message_loop
|
||||
// value of false (0). This function will not block.
|
||||
// provided for cases where the CEF message loop must be integrated into an
|
||||
// existing application message loop. Use of this function is not recommended
|
||||
// for most users; use either the cef_run_message_loop() function or
|
||||
// CefSettings.multi_threaded_message_loop if possible. When using this function
|
||||
// care must be taken to balance performance against excessive CPU usage. It is
|
||||
// recommended to enable the CefSettings.external_message_pump option when using
|
||||
// this function so that
|
||||
// cef_browser_process_handler_t::on_schedule_message_pump_work() callbacks can
|
||||
// facilitate the scheduling process. This function should only be called on the
|
||||
// main application thread and only if cef_initialize() is called with a
|
||||
// CefSettings.multi_threaded_message_loop value of false (0). This function
|
||||
// will not block.
|
||||
///
|
||||
CEF_EXPORT void cef_do_message_loop_work();
|
||||
|
||||
|
@@ -700,6 +700,13 @@ typedef struct _cef_browser_host_t {
|
||||
///
|
||||
void (CEF_CALLBACK *drag_source_system_drag_ended)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Returns the current visible navigation entry for this browser. This
|
||||
// function can only be called on the UI thread.
|
||||
///
|
||||
struct _cef_navigation_entry_t* (CEF_CALLBACK *get_visible_navigation_entry)(
|
||||
struct _cef_browser_host_t* self);
|
||||
} cef_browser_host_t;
|
||||
|
||||
|
||||
|
@@ -94,6 +94,22 @@ typedef struct _cef_browser_process_handler_t {
|
||||
///
|
||||
struct _cef_print_handler_t* (CEF_CALLBACK *get_print_handler)(
|
||||
struct _cef_browser_process_handler_t* self);
|
||||
|
||||
///
|
||||
// Called from any thread when work has been scheduled for the browser process
|
||||
// main (UI) thread. This callback is used in combination with CefSettings.
|
||||
// external_message_pump and cef_do_message_loop_work() in cases where the CEF
|
||||
// message loop must be integrated into an existing application message loop
|
||||
// (see additional comments and warnings on CefDoMessageLoopWork). This
|
||||
// callback should schedule a cef_do_message_loop_work() call to happen on the
|
||||
// main (UI) thread. |delay_ms| is the requested delay in milliseconds. If
|
||||
// |delay_ms| is <= 0 then the call should happen reasonably soon. If
|
||||
// |delay_ms| is > 0 then the call should be scheduled to happen after the
|
||||
// specified delay and any currently pending scheduled call should be
|
||||
// cancelled.
|
||||
///
|
||||
void (CEF_CALLBACK *on_schedule_message_pump_work)(
|
||||
struct _cef_browser_process_handler_t* self, int64 delay_ms);
|
||||
} cef_browser_process_handler_t;
|
||||
|
||||
|
||||
|
@@ -331,6 +331,11 @@ typedef struct _cef_domnode_t {
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_element_inner_text)(
|
||||
struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
// Returns the bounds of the element.
|
||||
///
|
||||
cef_rect_t (CEF_CALLBACK *get_element_bounds)(struct _cef_domnode_t* self);
|
||||
} cef_domnode_t;
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ typedef struct _cef_life_span_handler_t {
|
||||
// has been fired.
|
||||
//
|
||||
// An application should handle top-level owner window close notifications by
|
||||
// calling cef_browser_host_t::Tryclose_browser() or
|
||||
// calling cef_browser_host_t::try_close_browser() or
|
||||
// cef_browser_host_t::CloseBrowser(false (0)) instead of allowing the window
|
||||
// to close immediately (see the examples below). This gives CEF an
|
||||
// opportunity to process the 'onbeforeunload' event and optionally cancel the
|
||||
@@ -132,7 +132,7 @@ typedef struct _cef_life_span_handler_t {
|
||||
// The below examples describe what should happen during window close when the
|
||||
// browser is parented to an application-provided top-level window.
|
||||
//
|
||||
// Example 1: Using cef_browser_host_t::Tryclose_browser(). This is
|
||||
// Example 1: Using cef_browser_host_t::try_close_browser(). This is
|
||||
// recommended for clients using standard close handling and windows created
|
||||
// on the browser process UI thread. 1. User clicks the window close button
|
||||
// which sends a close notification to
|
||||
|
@@ -72,14 +72,17 @@ typedef struct _cef_load_handler_t {
|
||||
///
|
||||
// Called when the browser begins loading a frame. The |frame| value will
|
||||
// never be NULL -- call the is_main() function to check if this frame is the
|
||||
// main frame. Multiple frames may be loading at the same time. Sub-frames may
|
||||
// start or continue loading after the main frame load has ended. This
|
||||
// function will always be called for all frames irrespective of whether the
|
||||
// request completes successfully. For notification of overall browser load
|
||||
// status use OnLoadingStateChange instead.
|
||||
// main frame. |transition_type| provides information about the source of the
|
||||
// navigation and an accurate value is only available in the browser process.
|
||||
// Multiple frames may be loading at the same time. Sub-frames may start or
|
||||
// continue loading after the main frame load has ended. This function will
|
||||
// always be called for all frames irrespective of whether the request
|
||||
// completes successfully. For notification of overall browser load status use
|
||||
// OnLoadingStateChange instead.
|
||||
///
|
||||
void (CEF_CALLBACK *on_load_start)(struct _cef_load_handler_t* self,
|
||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame);
|
||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||
cef_transition_type_t transition_type);
|
||||
|
||||
///
|
||||
// Called when the browser is done loading a frame. The |frame| value will
|
||||
|
@@ -70,6 +70,19 @@ typedef struct _cef_menu_model_delegate_t {
|
||||
///
|
||||
void (CEF_CALLBACK *menu_will_show)(struct _cef_menu_model_delegate_t* self,
|
||||
struct _cef_menu_model_t* menu_model);
|
||||
|
||||
///
|
||||
// The menu has closed.
|
||||
///
|
||||
void (CEF_CALLBACK *menu_closed)(struct _cef_menu_model_delegate_t* self,
|
||||
struct _cef_menu_model_t* menu_model);
|
||||
|
||||
///
|
||||
// Optionally modify a menu item label. Return true (1) if |label| was
|
||||
// modified.
|
||||
///
|
||||
int (CEF_CALLBACK *format_label)(struct _cef_menu_model_delegate_t* self,
|
||||
struct _cef_menu_model_t* menu_model, cef_string_t* label);
|
||||
} cef_menu_model_delegate_t;
|
||||
|
||||
|
||||
|
@@ -44,6 +44,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_sslstatus_t;
|
||||
|
||||
///
|
||||
// Structure used to represent an entry in navigation history.
|
||||
@@ -116,6 +117,12 @@ typedef struct _cef_navigation_entry_t {
|
||||
///
|
||||
int (CEF_CALLBACK *get_http_status_code)(
|
||||
struct _cef_navigation_entry_t* self);
|
||||
|
||||
///
|
||||
// Returns the SSL information for this navigation entry.
|
||||
///
|
||||
struct _cef_sslstatus_t* (CEF_CALLBACK *get_sslstatus)(
|
||||
struct _cef_navigation_entry_t* self);
|
||||
} cef_navigation_entry_t;
|
||||
|
||||
|
||||
|
@@ -47,6 +47,7 @@
|
||||
#include "include/capi/cef_response_capi.h"
|
||||
#include "include/capi/cef_response_filter_capi.h"
|
||||
#include "include/capi/cef_ssl_info_capi.h"
|
||||
#include "include/capi/cef_x509_certificate_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -75,6 +76,25 @@ typedef struct _cef_request_callback_t {
|
||||
} cef_request_callback_t;
|
||||
|
||||
|
||||
///
|
||||
// Callback structure used to select a client certificate for authentication.
|
||||
///
|
||||
typedef struct _cef_select_client_certificate_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Chooses the specified certificate for client certificate authentication.
|
||||
// NULL value means that no client certificate should be used.
|
||||
///
|
||||
void (CEF_CALLBACK *select)(
|
||||
struct _cef_select_client_certificate_callback_t* self,
|
||||
struct _cef_x509certificate_t* cert);
|
||||
} cef_select_client_certificate_callback_t;
|
||||
|
||||
|
||||
///
|
||||
// Implement this structure to handle events related to browser requests. The
|
||||
// functions of this structure will be called on the thread indicated.
|
||||
@@ -146,12 +166,15 @@ typedef struct _cef_request_handler_t {
|
||||
///
|
||||
// Called on the IO thread when a resource load is redirected. The |request|
|
||||
// parameter will contain the old URL and other request-related information.
|
||||
// The |new_url| parameter will contain the new URL and can be changed if
|
||||
// desired. The |request| object cannot be modified in this callback.
|
||||
// The |response| parameter will contain the response that resulted in the
|
||||
// redirect. The |new_url| parameter will contain the new URL and can be
|
||||
// changed if desired. The |request| object cannot be modified in this
|
||||
// callback.
|
||||
///
|
||||
void (CEF_CALLBACK *on_resource_redirect)(struct _cef_request_handler_t* self,
|
||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||
struct _cef_request_t* request, cef_string_t* new_url);
|
||||
struct _cef_request_t* request, struct _cef_response_t* response,
|
||||
cef_string_t* new_url);
|
||||
|
||||
///
|
||||
// Called on the IO thread when a resource response is received. To allow the
|
||||
@@ -238,6 +261,26 @@ 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 UI thread when a client certificate is being requested for
|
||||
// authentication. Return false (0) to use the default behavior and
|
||||
// automatically select the first certificate available. Return true (1) and
|
||||
// call cef_select_client_certificate_callback_t::Select either in this
|
||||
// function or at a later time to select a certificate. Do not call Select or
|
||||
// call it with NULL to continue without using any certificate. |isProxy|
|
||||
// indicates whether the host is an HTTPS proxy or the origin server. |host|
|
||||
// and |port| contains the hostname and port of the SSL server. |certificates|
|
||||
// is the list of certificates to choose from; this list has already been
|
||||
// pruned by Chromium so that it only contains certificates from issuers that
|
||||
// the server trusts.
|
||||
///
|
||||
int (CEF_CALLBACK *on_select_client_certificate)(
|
||||
struct _cef_request_handler_t* self, struct _cef_browser_t* browser,
|
||||
int isProxy, const cef_string_t* host, int port,
|
||||
size_t certificatesCount,
|
||||
struct _cef_x509certificate_t* const* certificates,
|
||||
struct _cef_select_client_certificate_callback_t* callback);
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread when a plugin has crashed.
|
||||
// |plugin_path| is the path of the plugin that crashed.
|
||||
|
@@ -40,83 +40,13 @@
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
#include "include/capi/cef_x509_certificate_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
///
|
||||
// Structure representing the issuer or subject field of an X.509 certificate.
|
||||
///
|
||||
typedef struct _cef_sslcert_principal_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns a name that can be used to represent the issuer. It tries in this
|
||||
// order: CN, O and OU and returns the first non-NULL one found.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_display_name)(
|
||||
struct _cef_sslcert_principal_t* self);
|
||||
|
||||
///
|
||||
// Returns the common name.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_common_name)(
|
||||
struct _cef_sslcert_principal_t* self);
|
||||
|
||||
///
|
||||
// Returns the locality name.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_locality_name)(
|
||||
struct _cef_sslcert_principal_t* self);
|
||||
|
||||
///
|
||||
// Returns the state or province name.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_state_or_province_name)(
|
||||
struct _cef_sslcert_principal_t* self);
|
||||
|
||||
///
|
||||
// Returns the country name.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_country_name)(
|
||||
struct _cef_sslcert_principal_t* self);
|
||||
|
||||
///
|
||||
// Retrieve the list of street addresses.
|
||||
///
|
||||
void (CEF_CALLBACK *get_street_addresses)(
|
||||
struct _cef_sslcert_principal_t* self, cef_string_list_t addresses);
|
||||
|
||||
///
|
||||
// Retrieve the list of organization names.
|
||||
///
|
||||
void (CEF_CALLBACK *get_organization_names)(
|
||||
struct _cef_sslcert_principal_t* self, cef_string_list_t names);
|
||||
|
||||
///
|
||||
// Retrieve the list of organization unit names.
|
||||
///
|
||||
void (CEF_CALLBACK *get_organization_unit_names)(
|
||||
struct _cef_sslcert_principal_t* self, cef_string_list_t names);
|
||||
|
||||
///
|
||||
// Retrieve the list of domain components.
|
||||
///
|
||||
void (CEF_CALLBACK *get_domain_components)(
|
||||
struct _cef_sslcert_principal_t* self, cef_string_list_t components);
|
||||
} cef_sslcert_principal_t;
|
||||
|
||||
|
||||
///
|
||||
// Structure representing SSL information.
|
||||
///
|
||||
@@ -134,85 +64,24 @@ typedef struct _cef_sslinfo_t {
|
||||
struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the certificate status has any error, major or minor.
|
||||
// Returns the X.509 certificate.
|
||||
///
|
||||
int (CEF_CALLBACK *is_cert_status_error)(struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the certificate status represents only minor errors
|
||||
// (e.g. failure to verify certificate revocation).
|
||||
///
|
||||
int (CEF_CALLBACK *is_cert_status_minor_error)(struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns the subject of the X.509 certificate. For HTTPS server certificates
|
||||
// this represents the web server. The common name of the subject should
|
||||
// match the host name of the web server.
|
||||
///
|
||||
struct _cef_sslcert_principal_t* (CEF_CALLBACK *get_subject)(
|
||||
struct _cef_x509certificate_t* (CEF_CALLBACK *get_x509certificate)(
|
||||
struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns the issuer of the X.509 certificate.
|
||||
///
|
||||
struct _cef_sslcert_principal_t* (CEF_CALLBACK *get_issuer)(
|
||||
struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns the DER encoded serial number for the X.509 certificate. The value
|
||||
// possibly includes a leading 00 byte.
|
||||
///
|
||||
struct _cef_binary_value_t* (CEF_CALLBACK *get_serial_number)(
|
||||
struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns the date before which the X.509 certificate is invalid.
|
||||
// CefTime.GetTimeT() will return 0 if no date was specified.
|
||||
///
|
||||
cef_time_t (CEF_CALLBACK *get_valid_start)(struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns the date after which the X.509 certificate is invalid.
|
||||
// CefTime.GetTimeT() will return 0 if no date was specified.
|
||||
///
|
||||
cef_time_t (CEF_CALLBACK *get_valid_expiry)(struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns the DER encoded data for the X.509 certificate.
|
||||
///
|
||||
struct _cef_binary_value_t* (CEF_CALLBACK *get_derencoded)(
|
||||
struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns the PEM encoded data for the X.509 certificate.
|
||||
///
|
||||
struct _cef_binary_value_t* (CEF_CALLBACK *get_pemencoded)(
|
||||
struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns the number of certificates in the issuer chain. If 0, the
|
||||
// certificate is self-signed.
|
||||
///
|
||||
size_t (CEF_CALLBACK *get_issuer_chain_size)(struct _cef_sslinfo_t* self);
|
||||
|
||||
///
|
||||
// Returns the DER encoded data for the certificate issuer chain. If we failed
|
||||
// to encode a certificate in the chain it is still present in the array but
|
||||
// is an NULL string.
|
||||
///
|
||||
void (CEF_CALLBACK *get_derencoded_issuer_chain)(struct _cef_sslinfo_t* self,
|
||||
size_t* chainCount, struct _cef_binary_value_t** chain);
|
||||
|
||||
///
|
||||
// Returns the PEM encoded data for the certificate issuer chain. If we failed
|
||||
// to encode a certificate in the chain it is still present in the array but
|
||||
// is an NULL string.
|
||||
///
|
||||
void (CEF_CALLBACK *get_pemencoded_issuer_chain)(struct _cef_sslinfo_t* self,
|
||||
size_t* chainCount, struct _cef_binary_value_t** chain);
|
||||
} cef_sslinfo_t;
|
||||
|
||||
|
||||
///
|
||||
// Returns true (1) if the certificate status has any error, major or minor.
|
||||
///
|
||||
CEF_EXPORT int cef_is_cert_status_error(cef_cert_status_t status);
|
||||
|
||||
///
|
||||
// Returns true (1) if the certificate status represents only minor errors (e.g.
|
||||
// failure to verify certificate revocation).
|
||||
///
|
||||
CEF_EXPORT int cef_is_cert_status_minor_error(cef_cert_status_t status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
95
include/capi/cef_ssl_status_capi.h
Normal file
95
include/capi/cef_ssl_status_capi.h
Normal file
@@ -0,0 +1,95 @@
|
||||
// Copyright (c) 2016 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_SSL_STATUS_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_x509certificate_t;
|
||||
|
||||
///
|
||||
// Structure representing the SSL information for a navigation entry.
|
||||
///
|
||||
typedef struct _cef_sslstatus_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns true (1) if the status is related to a secure SSL/TLS connection.
|
||||
///
|
||||
int (CEF_CALLBACK *is_secure_connection)(struct _cef_sslstatus_t* self);
|
||||
|
||||
///
|
||||
// Returns a bitmask containing any and all problems verifying the server
|
||||
// certificate.
|
||||
///
|
||||
cef_cert_status_t (CEF_CALLBACK *get_cert_status)(
|
||||
struct _cef_sslstatus_t* self);
|
||||
|
||||
///
|
||||
// Returns the SSL version used for the SSL connection.
|
||||
///
|
||||
cef_ssl_version_t (CEF_CALLBACK *get_sslversion)(
|
||||
struct _cef_sslstatus_t* self);
|
||||
|
||||
///
|
||||
// Returns a bitmask containing the page security content status.
|
||||
///
|
||||
cef_ssl_content_status_t (CEF_CALLBACK *get_content_status)(
|
||||
struct _cef_sslstatus_t* self);
|
||||
|
||||
///
|
||||
// Returns the X.509 certificate.
|
||||
///
|
||||
struct _cef_x509certificate_t* (CEF_CALLBACK *get_x509certificate)(
|
||||
struct _cef_sslstatus_t* self);
|
||||
} cef_sslstatus_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_
|
@@ -123,14 +123,16 @@ typedef struct _cef_v8context_t {
|
||||
struct _cef_v8context_t* that);
|
||||
|
||||
///
|
||||
// Evaluates the specified JavaScript code using this context's global object.
|
||||
// Execute a string of JavaScript code in this V8 context. The |script_url|
|
||||
// parameter is the URL where the script in question can be found, if any. The
|
||||
// |start_line| parameter is the base line number to use for error reporting.
|
||||
// On success |retval| will be set to the return value, if any, and the
|
||||
// function will return true (1). On failure |exception| will be set to the
|
||||
// exception, if any, and the function will return false (0).
|
||||
///
|
||||
int (CEF_CALLBACK *eval)(struct _cef_v8context_t* self,
|
||||
const cef_string_t* code, struct _cef_v8value_t** retval,
|
||||
struct _cef_v8exception_t** exception);
|
||||
const cef_string_t* code, const cef_string_t* script_url, int start_line,
|
||||
struct _cef_v8value_t** retval, struct _cef_v8exception_t** exception);
|
||||
} cef_v8context_t;
|
||||
|
||||
|
||||
@@ -211,6 +213,70 @@ typedef struct _cef_v8accessor_t {
|
||||
} cef_v8accessor_t;
|
||||
|
||||
|
||||
///
|
||||
// Structure that should be implemented to handle V8 interceptor calls. The
|
||||
// functions of this structure will be called on the thread associated with the
|
||||
// V8 interceptor. Interceptor's named property handlers (with first argument of
|
||||
// type CefString) are called when object is indexed by string. Indexed property
|
||||
// handlers (with first argument of type int) are called when object is indexed
|
||||
// by integer.
|
||||
///
|
||||
typedef struct _cef_v8interceptor_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Handle retrieval of the interceptor value identified by |name|. |object| is
|
||||
// the receiver ('this' object) of the interceptor. If retrieval succeeds, set
|
||||
// |retval| to the return value. If the requested value does not exist, don't
|
||||
// set either |retval| or |exception|. If retrieval fails, set |exception| to
|
||||
// the exception that will be thrown. If the property has an associated
|
||||
// accessor, it will be called only if you don't set |retval|. Return true (1)
|
||||
// if interceptor retrieval was handled, false (0) otherwise.
|
||||
///
|
||||
int (CEF_CALLBACK *get_byname)(struct _cef_v8interceptor_t* self,
|
||||
const cef_string_t* name, struct _cef_v8value_t* object,
|
||||
struct _cef_v8value_t** retval, cef_string_t* exception);
|
||||
|
||||
///
|
||||
// Handle retrieval of the interceptor value identified by |index|. |object|
|
||||
// is the receiver ('this' object) of the interceptor. If retrieval succeeds,
|
||||
// set |retval| to the return value. If the requested value does not exist,
|
||||
// don't set either |retval| or |exception|. If retrieval fails, set
|
||||
// |exception| to the exception that will be thrown. Return true (1) if
|
||||
// interceptor retrieval was handled, false (0) otherwise.
|
||||
///
|
||||
int (CEF_CALLBACK *get_byindex)(struct _cef_v8interceptor_t* self, int index,
|
||||
struct _cef_v8value_t* object, struct _cef_v8value_t** retval,
|
||||
cef_string_t* exception);
|
||||
|
||||
///
|
||||
// Handle assignment of the interceptor value identified by |name|. |object|
|
||||
// is the receiver ('this' object) of the interceptor. |value| is the new
|
||||
// value being assigned to the interceptor. If assignment fails, set
|
||||
// |exception| to the exception that will be thrown. This setter will always
|
||||
// be called, even when the property has an associated accessor. Return true
|
||||
// (1) if interceptor assignment was handled, false (0) otherwise.
|
||||
///
|
||||
int (CEF_CALLBACK *set_byname)(struct _cef_v8interceptor_t* self,
|
||||
const cef_string_t* name, struct _cef_v8value_t* object,
|
||||
struct _cef_v8value_t* value, cef_string_t* exception);
|
||||
|
||||
///
|
||||
// Handle assignment of the interceptor value identified by |index|. |object|
|
||||
// is the receiver ('this' object) of the interceptor. |value| is the new
|
||||
// value being assigned to the interceptor. If assignment fails, set
|
||||
// |exception| to the exception that will be thrown. Return true (1) if
|
||||
// interceptor assignment was handled, false (0) otherwise.
|
||||
///
|
||||
int (CEF_CALLBACK *set_byindex)(struct _cef_v8interceptor_t* self, int index,
|
||||
struct _cef_v8value_t* object, struct _cef_v8value_t* value,
|
||||
cef_string_t* exception);
|
||||
} cef_v8interceptor_t;
|
||||
|
||||
|
||||
///
|
||||
// Structure representing a V8 exception. The functions of this structure may be
|
||||
// called on any render process thread.
|
||||
@@ -358,38 +424,32 @@ typedef struct _cef_v8value_t {
|
||||
struct _cef_v8value_t* that);
|
||||
|
||||
///
|
||||
// Return a bool value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return a bool value.
|
||||
///
|
||||
int (CEF_CALLBACK *get_bool_value)(struct _cef_v8value_t* self);
|
||||
|
||||
///
|
||||
// Return an int value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return an int value.
|
||||
///
|
||||
int32 (CEF_CALLBACK *get_int_value)(struct _cef_v8value_t* self);
|
||||
|
||||
///
|
||||
// Return an unisgned int value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return an unsigned int value.
|
||||
///
|
||||
uint32 (CEF_CALLBACK *get_uint_value)(struct _cef_v8value_t* self);
|
||||
|
||||
///
|
||||
// Return a double value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return a double value.
|
||||
///
|
||||
double (CEF_CALLBACK *get_double_value)(struct _cef_v8value_t* self);
|
||||
|
||||
///
|
||||
// Return a Date value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return a Date value.
|
||||
///
|
||||
cef_time_t (CEF_CALLBACK *get_date_value)(struct _cef_v8value_t* self);
|
||||
|
||||
///
|
||||
// Return a string value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return a string value.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_string_value)(
|
||||
@@ -652,13 +712,14 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date);
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value);
|
||||
|
||||
///
|
||||
// Create a new cef_v8value_t object of type object with optional accessor. This
|
||||
// function should only be called from within the scope of a
|
||||
// cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t callback,
|
||||
// or in combination with calling enter() and exit() on a stored cef_v8context_t
|
||||
// reference.
|
||||
// Create a new cef_v8value_t object of type object with optional accessor
|
||||
// and/or interceptor. This function should only be called from within the scope
|
||||
// of a cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t
|
||||
// callback, or in combination with calling enter() and exit() on a stored
|
||||
// cef_v8context_t reference.
|
||||
///
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_v8accessor_t* accessor);
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_v8accessor_t* accessor,
|
||||
cef_v8interceptor_t* interceptor);
|
||||
|
||||
///
|
||||
// Create a new cef_v8value_t object of type array with the specified |length|.
|
||||
|
@@ -127,6 +127,29 @@ typedef struct _cef_web_plugin_unstable_callback_t {
|
||||
} cef_web_plugin_unstable_callback_t;
|
||||
|
||||
|
||||
///
|
||||
// Implement this structure to receive notification when CDM registration is
|
||||
// complete. The functions of this structure will be called on the browser
|
||||
// process UI thread.
|
||||
///
|
||||
typedef struct _cef_register_cdm_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Method that will be called when CDM registration is complete. |result| will
|
||||
// be CEF_CDM_REGISTRATION_ERROR_NONE if registration completed successfully.
|
||||
// Otherwise, |result| and |error_message| will contain additional information
|
||||
// about why registration failed.
|
||||
///
|
||||
void (CEF_CALLBACK *on_cdm_registration_complete)(
|
||||
struct _cef_register_cdm_callback_t* self,
|
||||
cef_cdm_registration_error_t result, const cef_string_t* error_message);
|
||||
} cef_register_cdm_callback_t;
|
||||
|
||||
|
||||
///
|
||||
// Visit web plugin information. Can be called on any thread in the browser
|
||||
// process.
|
||||
@@ -161,6 +184,54 @@ CEF_EXPORT void cef_register_web_plugin_crash(const cef_string_t* path);
|
||||
CEF_EXPORT void cef_is_web_plugin_unstable(const cef_string_t* path,
|
||||
cef_web_plugin_unstable_callback_t* callback);
|
||||
|
||||
///
|
||||
// Register the Widevine CDM plugin.
|
||||
//
|
||||
// The client application is responsible for downloading an appropriate
|
||||
// platform-specific CDM binary distribution from Google, extracting the
|
||||
// contents, and building the required directory structure on the local machine.
|
||||
// The cef_browser_host_t::StartDownload function and CefZipArchive structure
|
||||
// can be used to implement this functionality in CEF. Contact Google via
|
||||
// https://www.widevine.com/contact.html for details on CDM download.
|
||||
//
|
||||
// |path| is a directory that must contain the following files:
|
||||
// 1. manifest.json file from the CDM binary distribution (see below).
|
||||
// 2. widevinecdm file from the CDM binary distribution (e.g.
|
||||
// widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X,
|
||||
// libwidevinecdm.so on Linux).
|
||||
// 3. widevidecdmadapter file from the CEF binary distribution (e.g.
|
||||
// widevinecdmadapter.dll on Windows, widevinecdmadapter.plugin on OS X,
|
||||
// libwidevinecdmadapter.so on Linux).
|
||||
//
|
||||
// If any of these files are missing or if the manifest file has incorrect
|
||||
// contents the registration will fail and |callback| will receive a |result|
|
||||
// value of CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS.
|
||||
//
|
||||
// The manifest.json file must contain the following keys:
|
||||
// A. "os": Supported OS (e.g. "mac", "win" or "linux").
|
||||
// B. "arch": Supported architecture (e.g. "ia32" or "x64").
|
||||
// C. "x-cdm-module-versions": Module API version (e.g. "4").
|
||||
// D. "x-cdm-interface-versions": Interface API version (e.g. "8").
|
||||
// E. "x-cdm-host-versions": Host API version (e.g. "8").
|
||||
// F. "version": CDM version (e.g. "1.4.8.903").
|
||||
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1").
|
||||
//
|
||||
// A through E are used to verify compatibility with the current Chromium
|
||||
// version. If the CDM is not compatible the registration will fail and
|
||||
// |callback| will receive a |result| value of
|
||||
// CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE.
|
||||
//
|
||||
// |callback| will be executed asynchronously once registration is complete.
|
||||
//
|
||||
// On Linux this function must be called before cef_initialize() and the
|
||||
// registration cannot be changed during runtime. If registration is not
|
||||
// supported at the time that cef_register_widevine_cdm() is called then
|
||||
// |callback| will receive a |result| value of
|
||||
// CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED.
|
||||
///
|
||||
CEF_EXPORT void cef_register_widevine_cdm(const cef_string_t* path,
|
||||
cef_register_cdm_callback_t* callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
208
include/capi/cef_x509_certificate_capi.h
Normal file
208
include/capi/cef_x509_certificate_capi.h
Normal file
@@ -0,0 +1,208 @@
|
||||
// Copyright (c) 2016 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_X509_CERTIFICATE_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_X509_CERTIFICATE_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
///
|
||||
// Structure representing the issuer or subject field of an X.509 certificate.
|
||||
///
|
||||
typedef struct _cef_x509cert_principal_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns a name that can be used to represent the issuer. It tries in this
|
||||
// order: Common Name (CN), Organization Name (O) and Organizational Unit Name
|
||||
// (OU) and returns the first non-NULL one found.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_display_name)(
|
||||
struct _cef_x509cert_principal_t* self);
|
||||
|
||||
///
|
||||
// Returns the common name.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_common_name)(
|
||||
struct _cef_x509cert_principal_t* self);
|
||||
|
||||
///
|
||||
// Returns the locality name.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_locality_name)(
|
||||
struct _cef_x509cert_principal_t* self);
|
||||
|
||||
///
|
||||
// Returns the state or province name.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_state_or_province_name)(
|
||||
struct _cef_x509cert_principal_t* self);
|
||||
|
||||
///
|
||||
// Returns the country name.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_country_name)(
|
||||
struct _cef_x509cert_principal_t* self);
|
||||
|
||||
///
|
||||
// Retrieve the list of street addresses.
|
||||
///
|
||||
void (CEF_CALLBACK *get_street_addresses)(
|
||||
struct _cef_x509cert_principal_t* self, cef_string_list_t addresses);
|
||||
|
||||
///
|
||||
// Retrieve the list of organization names.
|
||||
///
|
||||
void (CEF_CALLBACK *get_organization_names)(
|
||||
struct _cef_x509cert_principal_t* self, cef_string_list_t names);
|
||||
|
||||
///
|
||||
// Retrieve the list of organization unit names.
|
||||
///
|
||||
void (CEF_CALLBACK *get_organization_unit_names)(
|
||||
struct _cef_x509cert_principal_t* self, cef_string_list_t names);
|
||||
|
||||
///
|
||||
// Retrieve the list of domain components.
|
||||
///
|
||||
void (CEF_CALLBACK *get_domain_components)(
|
||||
struct _cef_x509cert_principal_t* self, cef_string_list_t components);
|
||||
} cef_x509cert_principal_t;
|
||||
|
||||
|
||||
///
|
||||
// Structure representing a X.509 certificate.
|
||||
///
|
||||
typedef struct _cef_x509certificate_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns the subject of the X.509 certificate. For HTTPS server certificates
|
||||
// this represents the web server. The common name of the subject should
|
||||
// match the host name of the web server.
|
||||
///
|
||||
struct _cef_x509cert_principal_t* (CEF_CALLBACK *get_subject)(
|
||||
struct _cef_x509certificate_t* self);
|
||||
|
||||
///
|
||||
// Returns the issuer of the X.509 certificate.
|
||||
///
|
||||
struct _cef_x509cert_principal_t* (CEF_CALLBACK *get_issuer)(
|
||||
struct _cef_x509certificate_t* self);
|
||||
|
||||
///
|
||||
// Returns the DER encoded serial number for the X.509 certificate. The value
|
||||
// possibly includes a leading 00 byte.
|
||||
///
|
||||
struct _cef_binary_value_t* (CEF_CALLBACK *get_serial_number)(
|
||||
struct _cef_x509certificate_t* self);
|
||||
|
||||
///
|
||||
// Returns the date before which the X.509 certificate is invalid.
|
||||
// CefTime.GetTimeT() will return 0 if no date was specified.
|
||||
///
|
||||
cef_time_t (CEF_CALLBACK *get_valid_start)(
|
||||
struct _cef_x509certificate_t* self);
|
||||
|
||||
///
|
||||
// Returns the date after which the X.509 certificate is invalid.
|
||||
// CefTime.GetTimeT() will return 0 if no date was specified.
|
||||
///
|
||||
cef_time_t (CEF_CALLBACK *get_valid_expiry)(
|
||||
struct _cef_x509certificate_t* self);
|
||||
|
||||
///
|
||||
// Returns the DER encoded data for the X.509 certificate.
|
||||
///
|
||||
struct _cef_binary_value_t* (CEF_CALLBACK *get_derencoded)(
|
||||
struct _cef_x509certificate_t* self);
|
||||
|
||||
///
|
||||
// Returns the PEM encoded data for the X.509 certificate.
|
||||
///
|
||||
struct _cef_binary_value_t* (CEF_CALLBACK *get_pemencoded)(
|
||||
struct _cef_x509certificate_t* self);
|
||||
|
||||
///
|
||||
// Returns the number of certificates in the issuer chain. If 0, the
|
||||
// certificate is self-signed.
|
||||
///
|
||||
size_t (CEF_CALLBACK *get_issuer_chain_size)(
|
||||
struct _cef_x509certificate_t* self);
|
||||
|
||||
///
|
||||
// Returns the DER encoded data for the certificate issuer chain. If we failed
|
||||
// to encode a certificate in the chain it is still present in the array but
|
||||
// is an NULL string.
|
||||
///
|
||||
void (CEF_CALLBACK *get_derencoded_issuer_chain)(
|
||||
struct _cef_x509certificate_t* self, size_t* chainCount,
|
||||
struct _cef_binary_value_t** chain);
|
||||
|
||||
///
|
||||
// Returns the PEM encoded data for the certificate issuer chain. If we failed
|
||||
// to encode a certificate in the chain it is still present in the array but
|
||||
// is an NULL string.
|
||||
///
|
||||
void (CEF_CALLBACK *get_pemencoded_issuer_chain)(
|
||||
struct _cef_x509certificate_t* self, size_t* chainCount,
|
||||
struct _cef_binary_value_t** chain);
|
||||
} cef_x509certificate_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_X509_CERTIFICATE_CAPI_H_
|
@@ -89,11 +89,17 @@ void CefShutdown();
|
||||
|
||||
///
|
||||
// Perform a single iteration of CEF message loop processing. This function is
|
||||
// used to integrate the CEF message loop into an existing application message
|
||||
// loop. Care must be taken to balance performance against excessive CPU usage.
|
||||
// This function should only be called on the main application thread and only
|
||||
// if CefInitialize() is called with a CefSettings.multi_threaded_message_loop
|
||||
// value of false. This function will not block.
|
||||
// provided for cases where the CEF message loop must be integrated into an
|
||||
// existing application message loop. Use of this function is not recommended
|
||||
// for most users; use either the CefRunMessageLoop() function or
|
||||
// CefSettings.multi_threaded_message_loop if possible. When using this function
|
||||
// care must be taken to balance performance against excessive CPU usage. It is
|
||||
// recommended to enable the CefSettings.external_message_pump option when using
|
||||
// this function so that CefBrowserProcessHandler::OnScheduleMessagePumpWork()
|
||||
// callbacks can facilitate the scheduling process. This function should only be
|
||||
// called on the main application thread and only if CefInitialize() is called
|
||||
// with a CefSettings.multi_threaded_message_loop value of false. This function
|
||||
// will not block.
|
||||
///
|
||||
/*--cef()--*/
|
||||
void CefDoMessageLoopWork();
|
||||
|
@@ -753,6 +753,13 @@ class CefBrowserHost : public virtual CefBase {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void DragSourceSystemDragEnded() =0;
|
||||
|
||||
///
|
||||
// Returns the current visible navigation entry for this browser. This method
|
||||
// can only be called on the UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_BROWSER_H_
|
||||
|
@@ -87,6 +87,22 @@ class CefBrowserProcessHandler : public virtual CefBase {
|
||||
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
///
|
||||
// Called from any thread when work has been scheduled for the browser process
|
||||
// main (UI) thread. This callback is used in combination with CefSettings.
|
||||
// external_message_pump and CefDoMessageLoopWork() in cases where the CEF
|
||||
// message loop must be integrated into an existing application message loop
|
||||
// (see additional comments and warnings on CefDoMessageLoopWork). This
|
||||
// callback should schedule a CefDoMessageLoopWork() call to happen on the
|
||||
// main (UI) thread. |delay_ms| is the requested delay in milliseconds. If
|
||||
// |delay_ms| is <= 0 then the call should happen reasonably soon. If
|
||||
// |delay_ms| is > 0 then the call should be scheduled to happen after the
|
||||
// specified delay and any currently pending scheduled call should be
|
||||
// cancelled.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnScheduleMessagePumpWork(int64 delay_ms) {}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_
|
||||
|
@@ -323,6 +323,12 @@ class CefDOMNode : public virtual CefBase {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetElementInnerText() =0;
|
||||
|
||||
///
|
||||
// Returns the bounds of the element.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRect GetElementBounds() =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_DOM_H_
|
||||
|
@@ -51,6 +51,7 @@
|
||||
class CefLoadHandler : public virtual CefBase {
|
||||
public:
|
||||
typedef cef_errorcode_t ErrorCode;
|
||||
typedef cef_transition_type_t TransitionType;
|
||||
|
||||
///
|
||||
// Called when the loading state has changed. This callback will be executed
|
||||
@@ -68,15 +69,18 @@ class CefLoadHandler : public virtual CefBase {
|
||||
///
|
||||
// Called when the browser begins loading a frame. The |frame| value will
|
||||
// never be empty -- call the IsMain() method to check if this frame is the
|
||||
// main frame. Multiple frames may be loading at the same time. Sub-frames may
|
||||
// start or continue loading after the main frame load has ended. This method
|
||||
// will always be called for all frames irrespective of whether the request
|
||||
// main frame. |transition_type| provides information about the source of the
|
||||
// navigation and an accurate value is only available in the browser process.
|
||||
// Multiple frames may be loading at the same time. Sub-frames may start or
|
||||
// continue loading after the main frame load has ended. This method will
|
||||
// always be called for all frames irrespective of whether the request
|
||||
// completes successfully. For notification of overall browser load status use
|
||||
// OnLoadingStateChange instead.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame) {}
|
||||
CefRefPtr<CefFrame> frame,
|
||||
TransitionType transition_type) {}
|
||||
|
||||
///
|
||||
// Called when the browser is done loading a frame. The |frame| value will
|
||||
|
@@ -63,20 +63,20 @@ class CefMenuModelDelegate : public virtual CefBase {
|
||||
// The menu is about to show.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void MenuWillShow(CefRefPtr<CefMenuModel> menu_model) {};
|
||||
virtual void MenuWillShow(CefRefPtr<CefMenuModel> menu_model) {}
|
||||
|
||||
///
|
||||
// The menu has closed.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void MenuClosed(CefRefPtr<CefMenuModel> menu_model) {};
|
||||
virtual void MenuClosed(CefRefPtr<CefMenuModel> menu_model) {}
|
||||
|
||||
///
|
||||
// Optionally modify a menu item label. Return true if |label| was modified.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool FormatLabel(CefRefPtr<CefMenuModel> menu_model,
|
||||
CefString& label) { return false; };
|
||||
CefString& label) { return false; }
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_VIEWS_CEF_MENU_MODEL_DELEGATE_H_
|
||||
|
@@ -40,6 +40,8 @@
|
||||
|
||||
#include "include/cef_base.h"
|
||||
|
||||
class CefSSLStatus;
|
||||
|
||||
///
|
||||
// Class used to represent an entry in navigation history.
|
||||
///
|
||||
@@ -108,6 +110,12 @@ class CefNavigationEntry : public virtual CefBase {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual int GetHttpStatusCode() =0;
|
||||
|
||||
///
|
||||
// Returns the SSL information for this navigation entry.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefSSLStatus> GetSSLStatus() =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_NAVIGATION_ENTRY_H_
|
||||
|
@@ -38,10 +38,11 @@
|
||||
#define CEF_INCLUDE_CEF_RENDER_HANDLER_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_drag_data.h"
|
||||
#include <vector>
|
||||
|
||||
///
|
||||
// Implement this interface to handle events when window rendering is disabled.
|
||||
|
@@ -38,6 +38,8 @@
|
||||
#define CEF_INCLUDE_CEF_REQUEST_HANDLER_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_auth_callback.h"
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_browser.h"
|
||||
@@ -47,7 +49,7 @@
|
||||
#include "include/cef_response_filter.h"
|
||||
#include "include/cef_request.h"
|
||||
#include "include/cef_ssl_info.h"
|
||||
|
||||
#include "include/cef_x509_certificate.h"
|
||||
|
||||
///
|
||||
// Callback interface used for asynchronous continuation of url requests.
|
||||
@@ -70,6 +72,21 @@ class CefRequestCallback : public virtual CefBase {
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
// Callback interface used to select a client certificate for authentication.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefSelectClientCertificateCallback : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Chooses the specified certificate for client certificate authentication.
|
||||
// NULL value means that no client certificate should be used.
|
||||
///
|
||||
/*--cef(optional_param=cert)--*/
|
||||
virtual void Select(CefRefPtr<CefX509Certificate> cert) =0;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
// Implement this interface to handle events related to browser requests. The
|
||||
// methods of this class will be called on the thread indicated.
|
||||
@@ -81,6 +98,7 @@ class CefRequestHandler : public virtual CefBase {
|
||||
typedef cef_termination_status_t TerminationStatus;
|
||||
typedef cef_urlrequest_status_t URLRequestStatus;
|
||||
typedef cef_window_open_disposition_t WindowOpenDisposition;
|
||||
typedef std::vector<CefRefPtr<CefX509Certificate> > X509CertificateList;
|
||||
|
||||
///
|
||||
// Called on the UI thread before browser navigation. Return true to cancel
|
||||
@@ -159,13 +177,16 @@ class CefRequestHandler : public virtual CefBase {
|
||||
///
|
||||
// Called on the IO thread when a resource load is redirected. The |request|
|
||||
// parameter will contain the old URL and other request-related information.
|
||||
// The |new_url| parameter will contain the new URL and can be changed if
|
||||
// desired. The |request| object cannot be modified in this callback.
|
||||
// The |response| parameter will contain the response that resulted in the
|
||||
// redirect. The |new_url| parameter will contain the new URL and can be
|
||||
// changed if desired. The |request| object cannot be modified in this
|
||||
// callback.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnResourceRedirect(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefResponse> response,
|
||||
CefString& new_url) {}
|
||||
|
||||
///
|
||||
@@ -279,6 +300,29 @@ class CefRequestHandler : public virtual CefBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
// Called on the UI thread when a client certificate is being requested for
|
||||
// authentication. Return false to use the default behavior and automatically
|
||||
// select the first certificate available. Return true and call
|
||||
// CefSelectClientCertificateCallback::Select either in this method or at a
|
||||
// later time to select a certificate. Do not call Select or call it with NULL
|
||||
// to continue without using any certificate. |isProxy| indicates whether the
|
||||
// host is an HTTPS proxy or the origin server. |host| and |port| contains the
|
||||
// hostname and port of the SSL server. |certificates| is the list of
|
||||
// certificates to choose from; this list has already been pruned by Chromium
|
||||
// so that it only contains certificates from issuers that the server trusts.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool OnSelectClientCertificate(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
bool isProxy,
|
||||
const CefString& host,
|
||||
int port,
|
||||
const X509CertificateList& certificates,
|
||||
CefRefPtr<CefSelectClientCertificateCallback> callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread when a plugin has crashed.
|
||||
// |plugin_path| is the path of the plugin that crashed.
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#define CEF_INCLUDE_CEF_SANDBOX_WIN_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
||||
|
@@ -38,72 +38,10 @@
|
||||
#define CEF_INCLUDE_CEF_SSL_INFO_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
///
|
||||
// Class representing the issuer or subject field of an X.509 certificate.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefSSLCertPrincipal : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Returns a name that can be used to represent the issuer. It tries in this
|
||||
// order: CN, O and OU and returns the first non-empty one found.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetDisplayName() =0;
|
||||
|
||||
///
|
||||
// Returns the common name.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetCommonName() =0;
|
||||
|
||||
///
|
||||
// Returns the locality name.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetLocalityName() =0;
|
||||
|
||||
///
|
||||
// Returns the state or province name.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetStateOrProvinceName() =0;
|
||||
|
||||
///
|
||||
// Returns the country name.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetCountryName() =0;
|
||||
|
||||
///
|
||||
// Retrieve the list of street addresses.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetStreetAddresses(std::vector<CefString>& addresses) =0;
|
||||
|
||||
///
|
||||
// Retrieve the list of organization names.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetOrganizationNames(std::vector<CefString>& names) =0;
|
||||
|
||||
///
|
||||
// Retrieve the list of organization unit names.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetOrganizationUnitNames(std::vector<CefString>& names) =0;
|
||||
|
||||
///
|
||||
// Retrieve the list of domain components.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetDomainComponents(std::vector<CefString>& components) =0;
|
||||
};
|
||||
#include "include/cef_x509_certificate.h"
|
||||
|
||||
///
|
||||
// Class representing SSL information.
|
||||
@@ -111,8 +49,6 @@ class CefSSLCertPrincipal : public virtual CefBase {
|
||||
/*--cef(source=library)--*/
|
||||
class CefSSLInfo : public virtual CefBase {
|
||||
public:
|
||||
typedef std::vector<CefRefPtr<CefBinaryValue> > IssuerChainBinaryList;
|
||||
|
||||
///
|
||||
// Returns a bitmask containing any and all problems verifying the server
|
||||
// certificate.
|
||||
@@ -121,87 +57,24 @@ class CefSSLInfo : public virtual CefBase {
|
||||
virtual cef_cert_status_t GetCertStatus() =0;
|
||||
|
||||
///
|
||||
// Returns true if the certificate status has any error, major or minor.
|
||||
// Returns the X.509 certificate.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsCertStatusError() =0;
|
||||
|
||||
///
|
||||
// Returns true if the certificate status represents only minor errors
|
||||
// (e.g. failure to verify certificate revocation).
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsCertStatusMinorError() =0;
|
||||
|
||||
///
|
||||
// Returns the subject of the X.509 certificate. For HTTPS server
|
||||
// certificates this represents the web server. The common name of the
|
||||
// subject should match the host name of the web server.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefSSLCertPrincipal> GetSubject() =0;
|
||||
|
||||
///
|
||||
// Returns the issuer of the X.509 certificate.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefSSLCertPrincipal> GetIssuer() =0;
|
||||
|
||||
///
|
||||
// Returns the DER encoded serial number for the X.509 certificate. The value
|
||||
// possibly includes a leading 00 byte.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefBinaryValue> GetSerialNumber() =0;
|
||||
|
||||
///
|
||||
// Returns the date before which the X.509 certificate is invalid.
|
||||
// CefTime.GetTimeT() will return 0 if no date was specified.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefTime GetValidStart() =0;
|
||||
|
||||
///
|
||||
// Returns the date after which the X.509 certificate is invalid.
|
||||
// CefTime.GetTimeT() will return 0 if no date was specified.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefTime GetValidExpiry() =0;
|
||||
|
||||
///
|
||||
// Returns the DER encoded data for the X.509 certificate.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefBinaryValue> GetDEREncoded() =0;
|
||||
|
||||
///
|
||||
// Returns the PEM encoded data for the X.509 certificate.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefBinaryValue> GetPEMEncoded() =0;
|
||||
|
||||
///
|
||||
// Returns the number of certificates in the issuer chain.
|
||||
// If 0, the certificate is self-signed.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual size_t GetIssuerChainSize() =0;
|
||||
|
||||
///
|
||||
// Returns the DER encoded data for the certificate issuer chain.
|
||||
// If we failed to encode a certificate in the chain it is still
|
||||
// present in the array but is an empty string.
|
||||
///
|
||||
/*--cef(count_func=chain:GetIssuerChainSize)--*/
|
||||
virtual void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) =0;
|
||||
|
||||
///
|
||||
// Returns the PEM encoded data for the certificate issuer chain.
|
||||
// If we failed to encode a certificate in the chain it is still
|
||||
// present in the array but is an empty string.
|
||||
///
|
||||
/*--cef(count_func=chain:GetIssuerChainSize)--*/
|
||||
virtual void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) =0;
|
||||
virtual CefRefPtr<CefX509Certificate> GetX509Certificate() =0;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
// Returns true if the certificate status has any error, major or minor.
|
||||
///
|
||||
/*--cef()--*/
|
||||
bool CefIsCertStatusError(cef_cert_status_t status);
|
||||
|
||||
///
|
||||
// Returns true if the certificate status represents only minor errors
|
||||
// (e.g. failure to verify certificate revocation).
|
||||
///
|
||||
/*--cef()--*/
|
||||
bool CefIsCertStatusMinorError(cef_cert_status_t status);
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_SSL_INFO_H_
|
||||
|
84
include/cef_ssl_status.h
Normal file
84
include/cef_ssl_status.h
Normal file
@@ -0,0 +1,84 @@
|
||||
// Copyright (c) 2016 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_SSL_STATUS_H_
|
||||
#define CEF_INCLUDE_CEF_SSL_STATUS_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
class CefX509Certificate;
|
||||
|
||||
///
|
||||
// Class representing the SSL information for a navigation entry.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefSSLStatus : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Returns true if the status is related to a secure SSL/TLS connection.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsSecureConnection() =0;
|
||||
|
||||
///
|
||||
// Returns a bitmask containing any and all problems verifying the server
|
||||
// certificate.
|
||||
///
|
||||
/*--cef(default_retval=CERT_STATUS_NONE)--*/
|
||||
virtual cef_cert_status_t GetCertStatus() =0;
|
||||
|
||||
///
|
||||
// Returns the SSL version used for the SSL connection.
|
||||
///
|
||||
/*--cef(default_retval=SSL_CONNECTION_VERSION_UNKNOWN)--*/
|
||||
virtual cef_ssl_version_t GetSSLVersion() =0;
|
||||
|
||||
///
|
||||
// Returns a bitmask containing the page security content status.
|
||||
///
|
||||
/*--cef(default_retval=SSL_CONTENT_NORMAL_CONTENT)--*/
|
||||
virtual cef_ssl_content_status_t GetContentStatus() =0;
|
||||
|
||||
///
|
||||
// Returns the X.509 certificate.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefX509Certificate> GetX509Certificate() =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_SSL_STATUS_H_
|
108
include/cef_v8.h
108
include/cef_v8.h
@@ -206,13 +206,17 @@ class CefV8Context : public virtual CefBase {
|
||||
virtual bool IsSame(CefRefPtr<CefV8Context> that) =0;
|
||||
|
||||
///
|
||||
// Evaluates the specified JavaScript code using this context's global object.
|
||||
// On success |retval| will be set to the return value, if any, and the
|
||||
// function will return true. On failure |exception| will be set to the
|
||||
// Execute a string of JavaScript code in this V8 context. The |script_url|
|
||||
// parameter is the URL where the script in question can be found, if any.
|
||||
// The |start_line| parameter is the base line number to use for error
|
||||
// reporting. On success |retval| will be set to the return value, if any, and
|
||||
// the function will return true. On failure |exception| will be set to the
|
||||
// exception, if any, and the function will return false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
/*--cef(optional_param=script_url)--*/
|
||||
virtual bool Eval(const CefString& code,
|
||||
const CefString& script_url,
|
||||
int start_line,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefRefPtr<CefV8Exception>& exception) =0;
|
||||
};
|
||||
@@ -277,6 +281,74 @@ class CefV8Accessor : public virtual CefBase {
|
||||
CefString& exception) =0;
|
||||
};
|
||||
|
||||
///
|
||||
// Interface that should be implemented to handle V8 interceptor calls. The
|
||||
// methods of this class will be called on the thread associated with the V8
|
||||
// interceptor. Interceptor's named property handlers (with first argument of
|
||||
// type CefString) are called when object is indexed by string. Indexed property
|
||||
// handlers (with first argument of type int) are called when object is indexed
|
||||
// by integer.
|
||||
///
|
||||
/*--cef(source=client)--*/
|
||||
class CefV8Interceptor : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Handle retrieval of the interceptor value identified by |name|. |object| is
|
||||
// the receiver ('this' object) of the interceptor. If retrieval succeeds, set
|
||||
// |retval| to the return value. If the requested value does not exist, don't
|
||||
// set either |retval| or |exception|. If retrieval fails, set |exception| to
|
||||
// the exception that will be thrown. If the property has an associated
|
||||
// accessor, it will be called only if you don't set |retval|.
|
||||
// Return true if interceptor retrieval was handled, false otherwise.
|
||||
///
|
||||
/*--cef(capi_name=get_byname)--*/
|
||||
virtual bool Get(const CefString& name,
|
||||
const CefRefPtr<CefV8Value> object,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) =0;
|
||||
|
||||
///
|
||||
// Handle retrieval of the interceptor value identified by |index|. |object|
|
||||
// is the receiver ('this' object) of the interceptor. If retrieval succeeds,
|
||||
// set |retval| to the return value. If the requested value does not exist,
|
||||
// don't set either |retval| or |exception|. If retrieval fails, set
|
||||
// |exception| to the exception that will be thrown.
|
||||
// Return true if interceptor retrieval was handled, false otherwise.
|
||||
///
|
||||
/*--cef(capi_name=get_byindex,index_param=index)--*/
|
||||
virtual bool Get(int index,
|
||||
const CefRefPtr<CefV8Value> object,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) =0;
|
||||
|
||||
///
|
||||
// Handle assignment of the interceptor value identified by |name|. |object|
|
||||
// is the receiver ('this' object) of the interceptor. |value| is the new
|
||||
// value being assigned to the interceptor. If assignment fails, set
|
||||
// |exception| to the exception that will be thrown. This setter will always
|
||||
// be called, even when the property has an associated accessor.
|
||||
// Return true if interceptor assignment was handled, false otherwise.
|
||||
///
|
||||
/*--cef(capi_name=set_byname)--*/
|
||||
virtual bool Set(const CefString& name,
|
||||
const CefRefPtr<CefV8Value> object,
|
||||
const CefRefPtr<CefV8Value> value,
|
||||
CefString& exception) =0;
|
||||
|
||||
///
|
||||
// Handle assignment of the interceptor value identified by |index|. |object|
|
||||
// is the receiver ('this' object) of the interceptor. |value| is the new
|
||||
// value being assigned to the interceptor. If assignment fails, set
|
||||
// |exception| to the exception that will be thrown.
|
||||
// Return true if interceptor assignment was handled, false otherwise.
|
||||
///
|
||||
/*--cef(capi_name=set_byindex,index_param=index)--*/
|
||||
virtual bool Set(int index,
|
||||
const CefRefPtr<CefV8Value> object,
|
||||
const CefRefPtr<CefV8Value> value,
|
||||
CefString& exception) =0;
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing a V8 exception. The methods of this class may be called on
|
||||
// any render process thread.
|
||||
@@ -404,14 +476,16 @@ class CefV8Value : public virtual CefBase {
|
||||
static CefRefPtr<CefV8Value> CreateString(const CefString& value);
|
||||
|
||||
///
|
||||
// Create a new CefV8Value object of type object with optional accessor. This
|
||||
// method should only be called from within the scope of a
|
||||
// Create a new CefV8Value object of type object with optional accessor and/or
|
||||
// interceptor. This method should only be called from within the scope of a
|
||||
// CefRenderProcessHandler, CefV8Handler or CefV8Accessor callback, or in
|
||||
// combination with calling Enter() and Exit() on a stored CefV8Context
|
||||
// reference.
|
||||
///
|
||||
/*--cef(optional_param=accessor)--*/
|
||||
static CefRefPtr<CefV8Value> CreateObject(CefRefPtr<CefV8Accessor> accessor);
|
||||
/*--cef(optional_param=accessor, optional_param=interceptor)--*/
|
||||
static CefRefPtr<CefV8Value> CreateObject(
|
||||
CefRefPtr<CefV8Accessor> accessor,
|
||||
CefRefPtr<CefV8Interceptor> interceptor);
|
||||
|
||||
///
|
||||
// Create a new CefV8Value object of type array with the specified |length|.
|
||||
@@ -515,43 +589,37 @@ class CefV8Value : public virtual CefBase {
|
||||
virtual bool IsSame(CefRefPtr<CefV8Value> that) =0;
|
||||
|
||||
///
|
||||
// Return a bool value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return a bool value.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetBoolValue() =0;
|
||||
|
||||
///
|
||||
// Return an int value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return an int value.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual int32 GetIntValue() =0;
|
||||
|
||||
///
|
||||
// Return an unisgned int value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return an unsigned int value.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual uint32 GetUIntValue() =0;
|
||||
|
||||
///
|
||||
// Return a double value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return a double value.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual double GetDoubleValue() =0;
|
||||
|
||||
///
|
||||
// Return a Date value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return a Date value.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefTime GetDateValue() =0;
|
||||
|
||||
///
|
||||
// Return a string value. The underlying data will be converted to if
|
||||
// necessary.
|
||||
// Return a string value.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetStringValue() =0;
|
||||
|
@@ -144,5 +144,71 @@ class CefWebPluginUnstableCallback : public virtual CefBase {
|
||||
void CefIsWebPluginUnstable(const CefString& path,
|
||||
CefRefPtr<CefWebPluginUnstableCallback> callback);
|
||||
|
||||
///
|
||||
// Implement this interface to receive notification when CDM registration is
|
||||
// complete. The methods of this class will be called on the browser process
|
||||
// UI thread.
|
||||
///
|
||||
/*--cef(source=client)--*/
|
||||
class CefRegisterCdmCallback : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Method that will be called when CDM registration is complete. |result|
|
||||
// will be CEF_CDM_REGISTRATION_ERROR_NONE if registration completed
|
||||
// successfully. Otherwise, |result| and |error_message| will contain
|
||||
// additional information about why registration failed.
|
||||
///
|
||||
/*--cef(optional_param=error_message)--*/
|
||||
virtual void OnCdmRegistrationComplete(cef_cdm_registration_error_t result,
|
||||
const CefString& error_message) =0;
|
||||
};
|
||||
|
||||
///
|
||||
// Register the Widevine CDM plugin.
|
||||
//
|
||||
// The client application is responsible for downloading an appropriate
|
||||
// platform-specific CDM binary distribution from Google, extracting the
|
||||
// contents, and building the required directory structure on the local machine.
|
||||
// The CefBrowserHost::StartDownload method and CefZipArchive class can be used
|
||||
// to implement this functionality in CEF. Contact Google via
|
||||
// https://www.widevine.com/contact.html for details on CDM download.
|
||||
//
|
||||
// |path| is a directory that must contain the following files:
|
||||
// 1. manifest.json file from the CDM binary distribution (see below).
|
||||
// 2. widevinecdm file from the CDM binary distribution (e.g.
|
||||
// widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X,
|
||||
// libwidevinecdm.so on Linux).
|
||||
// 3. widevidecdmadapter file from the CEF binary distribution (e.g.
|
||||
// widevinecdmadapter.dll on Windows, widevinecdmadapter.plugin on OS X,
|
||||
// libwidevinecdmadapter.so on Linux).
|
||||
//
|
||||
// If any of these files are missing or if the manifest file has incorrect
|
||||
// contents the registration will fail and |callback| will receive a |result|
|
||||
// value of CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS.
|
||||
//
|
||||
// The manifest.json file must contain the following keys:
|
||||
// A. "os": Supported OS (e.g. "mac", "win" or "linux").
|
||||
// B. "arch": Supported architecture (e.g. "ia32" or "x64").
|
||||
// C. "x-cdm-module-versions": Module API version (e.g. "4").
|
||||
// D. "x-cdm-interface-versions": Interface API version (e.g. "8").
|
||||
// E. "x-cdm-host-versions": Host API version (e.g. "8").
|
||||
// F. "version": CDM version (e.g. "1.4.8.903").
|
||||
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1").
|
||||
//
|
||||
// A through E are used to verify compatibility with the current Chromium
|
||||
// version. If the CDM is not compatible the registration will fail and
|
||||
// |callback| will receive a |result| value of
|
||||
// CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE.
|
||||
//
|
||||
// |callback| will be executed asynchronously once registration is complete.
|
||||
//
|
||||
// On Linux this function must be called before CefInitialize() and the
|
||||
// registration cannot be changed during runtime. If registration is not
|
||||
// supported at the time that CefRegisterWidevineCdm() is called then |callback|
|
||||
// will receive a |result| value of CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED.
|
||||
///
|
||||
/*--cef(optional_param=callback)--*/
|
||||
void CefRegisterWidevineCdm(const CefString& path,
|
||||
CefRefPtr<CefRegisterCdmCallback> callback);
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_WEB_PLUGIN_H_
|
||||
|
188
include/cef_x509_certificate.h
Normal file
188
include/cef_x509_certificate.h
Normal file
@@ -0,0 +1,188 @@
|
||||
// Copyright (c) 2016 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_X509_CERTIFICATE_H_
|
||||
#define CEF_INCLUDE_CEF_X509_CERTIFICATE_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
///
|
||||
// Class representing the issuer or subject field of an X.509 certificate.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefX509CertPrincipal : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Returns a name that can be used to represent the issuer. It tries in this
|
||||
// order: Common Name (CN), Organization Name (O) and Organizational Unit
|
||||
// Name (OU) and returns the first non-empty one found.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetDisplayName() =0;
|
||||
|
||||
///
|
||||
// Returns the common name.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetCommonName() =0;
|
||||
|
||||
///
|
||||
// Returns the locality name.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetLocalityName() =0;
|
||||
|
||||
///
|
||||
// Returns the state or province name.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetStateOrProvinceName() =0;
|
||||
|
||||
///
|
||||
// Returns the country name.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetCountryName() =0;
|
||||
|
||||
///
|
||||
// Retrieve the list of street addresses.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetStreetAddresses(std::vector<CefString>& addresses) =0;
|
||||
|
||||
///
|
||||
// Retrieve the list of organization names.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetOrganizationNames(std::vector<CefString>& names) =0;
|
||||
|
||||
///
|
||||
// Retrieve the list of organization unit names.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetOrganizationUnitNames(std::vector<CefString>& names) =0;
|
||||
|
||||
///
|
||||
// Retrieve the list of domain components.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetDomainComponents(std::vector<CefString>& components) =0;
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing a X.509 certificate.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefX509Certificate : public virtual CefBase {
|
||||
public:
|
||||
typedef std::vector<CefRefPtr<CefBinaryValue> > IssuerChainBinaryList;
|
||||
|
||||
///
|
||||
// Returns the subject of the X.509 certificate. For HTTPS server
|
||||
// certificates this represents the web server. The common name of the
|
||||
// subject should match the host name of the web server.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefX509CertPrincipal> GetSubject() =0;
|
||||
|
||||
///
|
||||
// Returns the issuer of the X.509 certificate.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefX509CertPrincipal> GetIssuer() =0;
|
||||
|
||||
///
|
||||
// Returns the DER encoded serial number for the X.509 certificate. The value
|
||||
// possibly includes a leading 00 byte.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefBinaryValue> GetSerialNumber() =0;
|
||||
|
||||
///
|
||||
// Returns the date before which the X.509 certificate is invalid.
|
||||
// CefTime.GetTimeT() will return 0 if no date was specified.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefTime GetValidStart() =0;
|
||||
|
||||
///
|
||||
// Returns the date after which the X.509 certificate is invalid.
|
||||
// CefTime.GetTimeT() will return 0 if no date was specified.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefTime GetValidExpiry() =0;
|
||||
|
||||
///
|
||||
// Returns the DER encoded data for the X.509 certificate.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefBinaryValue> GetDEREncoded() =0;
|
||||
|
||||
///
|
||||
// Returns the PEM encoded data for the X.509 certificate.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefBinaryValue> GetPEMEncoded() =0;
|
||||
|
||||
///
|
||||
// Returns the number of certificates in the issuer chain.
|
||||
// If 0, the certificate is self-signed.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual size_t GetIssuerChainSize() =0;
|
||||
|
||||
///
|
||||
// Returns the DER encoded data for the certificate issuer chain.
|
||||
// If we failed to encode a certificate in the chain it is still
|
||||
// present in the array but is an empty string.
|
||||
///
|
||||
/*--cef(count_func=chain:GetIssuerChainSize)--*/
|
||||
virtual void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) =0;
|
||||
|
||||
///
|
||||
// Returns the PEM encoded data for the certificate issuer chain.
|
||||
// If we failed to encode a certificate in the chain it is still
|
||||
// present in the array but is an empty string.
|
||||
///
|
||||
/*--cef(count_func=chain:GetIssuerChainSize)--*/
|
||||
virtual void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_X509_CERTIFICATE_H_
|
@@ -180,6 +180,18 @@ typedef struct _cef_settings_t {
|
||||
///
|
||||
int multi_threaded_message_loop;
|
||||
|
||||
///
|
||||
// Set to true (1) to control browser process main (UI) thread message pump
|
||||
// scheduling via the CefBrowserProcessHandler::OnScheduleMessagePumpWork()
|
||||
// callback. This option is recommended for use in combination with the
|
||||
// CefDoMessageLoopWork() function in cases where the CEF message loop must be
|
||||
// integrated into an existing application message loop (see additional
|
||||
// comments and warnings on CefDoMessageLoopWork). Enabling this option is not
|
||||
// recommended for most users; leave this option disabled and use either the
|
||||
// CefRunMessageLoop() function or multi_threaded_message_loop if possible.
|
||||
///
|
||||
int external_message_pump;
|
||||
|
||||
///
|
||||
// Set to true (1) to enable windowless (off-screen) rendering support. Do not
|
||||
// enable this value if the application does not use windowless rendering as
|
||||
@@ -364,6 +376,19 @@ typedef struct _cef_settings_t {
|
||||
///
|
||||
int ignore_certificate_errors;
|
||||
|
||||
///
|
||||
// Set to true (1) to enable date-based expiration of built in network
|
||||
// security information (i.e. certificate transparency logs, HSTS preloading
|
||||
// and pinning information). Enabling this option improves network security
|
||||
// but may cause HTTPS load failures when using CEF binaries built more than
|
||||
// 10 weeks in the past. See https://www.certificate-transparency.org/ and
|
||||
// https://www.chromium.org/hsts for details. Also configurable using the
|
||||
// "enable-net-security-expiration" command-line switch. Can be overridden for
|
||||
// individual CefRequestContext instances via the
|
||||
// CefRequestContextSettings.enable_net_security_expiration value.
|
||||
///
|
||||
int enable_net_security_expiration;
|
||||
|
||||
///
|
||||
// Opaque background color used for accelerated content. By default the
|
||||
// background color will be white. Only the RGB compontents of the specified
|
||||
@@ -431,6 +456,17 @@ typedef struct _cef_request_context_settings_t {
|
||||
///
|
||||
int ignore_certificate_errors;
|
||||
|
||||
///
|
||||
// Set to true (1) to enable date-based expiration of built in network
|
||||
// security information (i.e. certificate transparency logs, HSTS preloading
|
||||
// and pinning information). Enabling this option improves network security
|
||||
// but may cause HTTPS load failures when using CEF binaries built more than
|
||||
// 10 weeks in the past. See https://www.certificate-transparency.org/ and
|
||||
// https://www.chromium.org/hsts for details. Can be set globally using the
|
||||
// CefSettings.enable_net_security_expiration value.
|
||||
///
|
||||
int enable_net_security_expiration;
|
||||
|
||||
///
|
||||
// Comma delimited ordered list of language codes without any whitespace that
|
||||
// will be used in the "Accept-Language" HTTP header. Can be set globally
|
||||
@@ -930,11 +966,12 @@ typedef enum {
|
||||
} cef_cert_status_t;
|
||||
|
||||
///
|
||||
// The manner in which a link click should be opened.
|
||||
// The manner in which a link click should be opened. These constants match
|
||||
// their equivalents in Chromium's window_open_disposition.h and should not be
|
||||
// renumbered.
|
||||
///
|
||||
typedef enum {
|
||||
WOD_UNKNOWN,
|
||||
WOD_SUPPRESS_OPEN,
|
||||
WOD_CURRENT_TAB,
|
||||
WOD_SINGLETON_TAB,
|
||||
WOD_NEW_FOREGROUND_TAB,
|
||||
@@ -2623,6 +2660,52 @@ typedef enum {
|
||||
CEF_MENU_ANCHOR_BOTTOMCENTER,
|
||||
} cef_menu_anchor_position_t;
|
||||
|
||||
// Supported SSL version values. See net/ssl/ssl_connection_status_flags.h
|
||||
// for more information.
|
||||
typedef enum {
|
||||
SSL_CONNECTION_VERSION_UNKNOWN = 0, // Unknown SSL version.
|
||||
SSL_CONNECTION_VERSION_SSL2 = 1,
|
||||
SSL_CONNECTION_VERSION_SSL3 = 2,
|
||||
SSL_CONNECTION_VERSION_TLS1 = 3,
|
||||
SSL_CONNECTION_VERSION_TLS1_1 = 4,
|
||||
SSL_CONNECTION_VERSION_TLS1_2 = 5,
|
||||
// Reserve 6 for TLS 1.3.
|
||||
SSL_CONNECTION_VERSION_QUIC = 7,
|
||||
} cef_ssl_version_t;
|
||||
|
||||
// Supported SSL content status flags. See content/public/common/ssl_status.h
|
||||
// for more information.
|
||||
typedef enum {
|
||||
SSL_CONTENT_NORMAL_CONTENT = 0,
|
||||
SSL_CONTENT_DISPLAYED_INSECURE_CONTENT = 1 << 0,
|
||||
SSL_CONTENT_RAN_INSECURE_CONTENT = 1 << 1,
|
||||
} cef_ssl_content_status_t;
|
||||
|
||||
///
|
||||
// Error codes for CDM registration. See cef_web_plugin.h for details.
|
||||
///
|
||||
typedef enum {
|
||||
///
|
||||
// No error. Registration completed successfully.
|
||||
///
|
||||
CEF_CDM_REGISTRATION_ERROR_NONE,
|
||||
|
||||
///
|
||||
// Required files or manifest contents are missing.
|
||||
///
|
||||
CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS,
|
||||
|
||||
///
|
||||
// The CDM is incompatible with the current Chromium version.
|
||||
///
|
||||
CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE,
|
||||
|
||||
///
|
||||
// CDM registration is not supported at this time.
|
||||
///
|
||||
CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED,
|
||||
} cef_cdm_registration_error_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -575,6 +575,7 @@ struct CefSettingsTraits {
|
||||
src->browser_subprocess_path.length,
|
||||
&target->browser_subprocess_path, copy);
|
||||
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
|
||||
target->external_message_pump = src->external_message_pump;
|
||||
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
|
||||
target->command_line_args_disabled = src->command_line_args_disabled;
|
||||
|
||||
@@ -606,6 +607,8 @@ struct CefSettingsTraits {
|
||||
target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
|
||||
target->context_safety_implementation = src->context_safety_implementation;
|
||||
target->ignore_certificate_errors = src->ignore_certificate_errors;
|
||||
target->enable_net_security_expiration =
|
||||
src->enable_net_security_expiration;
|
||||
target->background_color = src->background_color;
|
||||
|
||||
cef_string_set(src->accept_language_list.str,
|
||||
@@ -638,6 +641,8 @@ struct CefRequestContextSettingsTraits {
|
||||
target->persist_session_cookies = src->persist_session_cookies;
|
||||
target->persist_user_preferences = src->persist_user_preferences;
|
||||
target->ignore_certificate_errors = src->ignore_certificate_errors;
|
||||
target->enable_net_security_expiration =
|
||||
src->enable_net_security_expiration;
|
||||
cef_string_set(src->accept_language_list.str,
|
||||
src->accept_language_list.length, &target->accept_language_list, copy);
|
||||
}
|
||||
|
@@ -159,18 +159,18 @@ class CefResourceManager :
|
||||
|
||||
// The below methods are called on the browser process IO thread.
|
||||
|
||||
explicit Request(scoped_ptr<RequestState> state);
|
||||
explicit Request(SCOPED_PTR(RequestState) state);
|
||||
|
||||
scoped_ptr<RequestState> SendRequest();
|
||||
SCOPED_PTR(RequestState) SendRequest();
|
||||
bool HasState();
|
||||
|
||||
static void ContinueOnIOThread(scoped_ptr<RequestState> state,
|
||||
static void ContinueOnIOThread(SCOPED_PTR(RequestState) state,
|
||||
CefRefPtr<CefResourceHandler> handler);
|
||||
static void StopOnIOThread(scoped_ptr<RequestState> state);
|
||||
static void StopOnIOThread(SCOPED_PTR(RequestState) state);
|
||||
|
||||
// Will be non-NULL while the request is pending. Only accessed on the
|
||||
// browser process IO thread.
|
||||
scoped_ptr<RequestState> state_;
|
||||
SCOPED_PTR(RequestState) state_;
|
||||
|
||||
// Params that stay with this request object. Safe to access on any thread.
|
||||
RequestParams params_;
|
||||
@@ -343,10 +343,10 @@ class CefResourceManager :
|
||||
|
||||
// Methods that manage request state between requests. Called on the browser
|
||||
// process IO thread.
|
||||
bool SendRequest(scoped_ptr<RequestState> state);
|
||||
void ContinueRequest(scoped_ptr<RequestState> state,
|
||||
bool SendRequest(SCOPED_PTR(RequestState) state);
|
||||
void ContinueRequest(SCOPED_PTR(RequestState) state,
|
||||
CefRefPtr<CefResourceHandler> handler);
|
||||
void StopRequest(scoped_ptr<RequestState> state);
|
||||
void StopRequest(SCOPED_PTR(RequestState) state);
|
||||
bool IncrementProvider(RequestState* state);
|
||||
void DetachRequestFromProvider(RequestState* state);
|
||||
void GetNextValidProvider(ProviderEntryList::iterator& iterator);
|
||||
@@ -365,7 +365,7 @@ class CefResourceManager :
|
||||
MimeTypeResolver mime_type_resolver_;
|
||||
|
||||
// Must be the last member. Created and accessed on the IO thread.
|
||||
scoped_ptr<base::WeakPtrFactory<CefResourceManager> > weak_ptr_factory_;
|
||||
SCOPED_PTR(base::WeakPtrFactory<CefResourceManager>) weak_ptr_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefResourceManager);
|
||||
};
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#define CEF_INCLUDE_WRAPPER_CEF_STREAM_RESOURCE_HANDLER_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_macros.h"
|
||||
#include "include/base/cef_scoped_ptr.h"
|
||||
#include "include/cef_base.h"
|
||||
@@ -90,8 +91,8 @@ class CefStreamResourceHandler : public CefResourceHandler {
|
||||
bool read_on_file_thread_;
|
||||
|
||||
class Buffer;
|
||||
scoped_ptr<Buffer> buffer_;
|
||||
#ifndef NDEBUG
|
||||
SCOPED_PTR(Buffer) buffer_;
|
||||
#if DCHECK_IS_ON()
|
||||
// Used in debug builds to verify that |buffer_| isn't being accessed on
|
||||
// multiple threads at the same time.
|
||||
bool buffer_owned_by_file_thread_;
|
||||
|
@@ -14,16 +14,15 @@
|
||||
#include "components/user_prefs/user_prefs.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "extensions/browser/extension_protocols.h"
|
||||
#include "extensions/common/constants.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
base::AtomicRefCount CefBrowserContext::DebugObjCt = 0;
|
||||
#endif
|
||||
|
||||
CefBrowserContext::CefBrowserContext()
|
||||
: extension_system_(NULL) {
|
||||
#ifndef NDEBUG
|
||||
CefBrowserContext::CefBrowserContext(bool is_proxy)
|
||||
: is_proxy_(is_proxy),
|
||||
extension_system_(NULL) {
|
||||
#if DCHECK_IS_ON()
|
||||
base::AtomicRefCountInc(&DebugObjCt);
|
||||
#endif
|
||||
}
|
||||
@@ -32,7 +31,7 @@ CefBrowserContext::~CefBrowserContext() {
|
||||
// Should be cleared in Shutdown().
|
||||
DCHECK(!resource_context_.get());
|
||||
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
base::AtomicRefCountDec(&DebugObjCt);
|
||||
#endif
|
||||
}
|
||||
@@ -44,9 +43,15 @@ void CefBrowserContext::Initialize() {
|
||||
if (extensions_enabled) {
|
||||
// Create the custom ExtensionSystem first because other KeyedServices
|
||||
// depend on it.
|
||||
// The same CefExtensionSystem instance is shared by CefBrowserContextImpl
|
||||
// and CefBrowserContextProxy objects.
|
||||
extension_system_ = static_cast<extensions::CefExtensionSystem*>(
|
||||
extensions::ExtensionSystem::Get(this));
|
||||
extension_system_->InitForRegularProfile(true);
|
||||
if (is_proxy_) {
|
||||
DCHECK(extension_system_->initialized());
|
||||
} else {
|
||||
extension_system_->InitForRegularProfile(true);
|
||||
}
|
||||
}
|
||||
|
||||
resource_context_.reset(new CefResourceContext(
|
||||
@@ -63,45 +68,58 @@ void CefBrowserContext::Initialize() {
|
||||
DCHECK(pref_service);
|
||||
user_prefs::UserPrefs::Set(this, pref_service);
|
||||
|
||||
if (extensions_enabled)
|
||||
if (extensions_enabled && !is_proxy_)
|
||||
extension_system_->Init();
|
||||
}
|
||||
|
||||
void CefBrowserContext::CreateProtocolHandlers(
|
||||
content::ProtocolHandlerMap* protocol_handlers) {
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
// Handle only chrome-extension:// requests. CEF does not support
|
||||
// chrome-extension-resource:// requests (it does not store shared extension
|
||||
// data in its installation directory).
|
||||
extensions::InfoMap* extension_info_map =
|
||||
extension_system()->info_map();
|
||||
(*protocol_handlers)[extensions::kExtensionScheme] =
|
||||
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
|
||||
extensions::CreateExtensionProtocolHandler(
|
||||
IsOffTheRecord(), extension_info_map).release());
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContext::Shutdown() {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// Send notifications to clean up objects associated with this Profile.
|
||||
MaybeSendDestroyedNotification();
|
||||
|
||||
// Remove any BrowserContextKeyedServiceFactory associations. This must be
|
||||
// called before the ProxyService owned by CefBrowserContextImpl is destroyed.
|
||||
BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
|
||||
this);
|
||||
|
||||
if (!is_proxy_) {
|
||||
// Shuts down the storage partitions associated with this browser context.
|
||||
// This must be called before the browser context is actually destroyed
|
||||
// and before a clean-up task for its corresponding IO thread residents
|
||||
// (e.g. ResourceContext) is posted, so that the classes that hung on
|
||||
// StoragePartition can have time to do necessary cleanups on IO thread.
|
||||
ShutdownStoragePartitions();
|
||||
}
|
||||
|
||||
if (resource_context_.get()) {
|
||||
// Destruction of the ResourceContext will trigger destruction of all
|
||||
// associated URLRequests.
|
||||
content::BrowserThread::DeleteSoon(
|
||||
content::BrowserThread::IO, FROM_HERE, resource_context_.release());
|
||||
}
|
||||
|
||||
// Remove any BrowserContextKeyedServiceFactory associations. This must be
|
||||
// called before the ProxyService owned by CefBrowserContextImpl is destroyed.
|
||||
BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
|
||||
this);
|
||||
}
|
||||
|
||||
content::ResourceContext* CefBrowserContext::GetResourceContext() {
|
||||
return resource_context_.get();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* CefBrowserContext::GetRequestContext() {
|
||||
CEF_REQUIRE_UIT();
|
||||
return GetDefaultStoragePartition(this)->GetURLRequestContext();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* CefBrowserContext::CreateMediaRequestContext() {
|
||||
return GetRequestContext();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContext::CreateMediaRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ChromeZoomLevelPrefs* CefBrowserContext::GetZoomLevelPrefs() {
|
||||
return static_cast<ChromeZoomLevelPrefs*>(
|
||||
GetStoragePartition(this, NULL)->GetZoomLevelDelegate());
|
||||
|
@@ -33,12 +33,22 @@
|
||||
//
|
||||
// BCI = CefBrowserContextImpl
|
||||
// Entry point from WC when using an isolated RCI. Owns the RC and creates the
|
||||
// URCGI. Life span controlled by RCI and (for the global context)
|
||||
// SPI indirectly. Life span controlled by RCI and (for the global context)
|
||||
// CefBrowserMainParts.
|
||||
//
|
||||
// BCP = CefBrowserContextProxy
|
||||
// Entry point from WC when using a custom RCI. Owns the RC and creates the
|
||||
// URCGP. Life span controlled by RCI.
|
||||
// URCGP and SPP. Life span controlled by RCI.
|
||||
//
|
||||
// SPI = content::StoragePartitionImpl
|
||||
// Owns storage-related objects like Quota, IndexedDB, Cache, etc. Created by
|
||||
// StoragePartitionImplMap::Get(). Provides access to the URCGI. Life span is
|
||||
// controlled indirectly by BCI.
|
||||
//
|
||||
// SPP = CefStoragePartitionProxy
|
||||
// Forwards requests for storage-related objects to SPI. Created by
|
||||
// GetStoragePartitionFromConfig() calling BCI::GetStoragePartitionProxy().
|
||||
// Provides access to the URCGP. Life span is controlled by BCP.
|
||||
//
|
||||
// RC = CefResourceContext
|
||||
// Acts as a bridge for resource loading. URLRequest life span is tied to this
|
||||
@@ -46,11 +56,14 @@
|
||||
// controlled by BCI/BCP.
|
||||
//
|
||||
// URCGI = CefURLRequestContextGetterImpl
|
||||
// Creates and owns the URCI. Life span is controlled by RC and (for the
|
||||
// global context) CefBrowserMainParts.
|
||||
// Creates and owns the URCI. Created by StoragePartitionImplMap::Get()
|
||||
// calling BCI::CreateRequestContext(). Life span is controlled by RC and (for
|
||||
// the global context) CefBrowserMainParts, and SPI.
|
||||
//
|
||||
// URCGP = CefURLRequestContextGetterProxy
|
||||
// Creates and owns the URCP. Life span is controlled by RC.
|
||||
// Creates and owns the URCP. Created by GetStoragePartitionFromConfig()
|
||||
// calling BCI::GetStoragePartitionProxy(). Life span is controlled by RC and
|
||||
// SPP.
|
||||
//
|
||||
// URCI = CefURLRequestContextImpl
|
||||
// Owns various network-related objects including the isolated cookie manager.
|
||||
@@ -73,15 +86,15 @@
|
||||
// own = ownership (scoped_ptr)
|
||||
// ptr = raw pointer
|
||||
//
|
||||
// CefBrowserMainParts isolated cookie manager, etc...
|
||||
// | | ^
|
||||
// ref ref ref/own
|
||||
// v v |
|
||||
// /---> BCI -ref-> URCGI --own-> URCI <-ptr-- CSP
|
||||
// / ^ ^ ^
|
||||
// ptr ref ref /
|
||||
// / | | /
|
||||
// BHI -own-> WC -ptr-> BCP -ref-> URCGP -own-> URCP --ref-/
|
||||
// CefBrowserMainParts----\ isolated cookie manager, etc.
|
||||
// | \ ^
|
||||
// ref ref ref/own
|
||||
// v v |
|
||||
// /---> BCI -own-> SPI -ref-> URCGI --own-> URCI <-ptr-- CSP
|
||||
// / ^ ^ ^ ^
|
||||
// ptr ref ptr ref /
|
||||
// / | | | /
|
||||
// BHI -own-> WC -ptr-> BCP -own-> SPP -ref-> URCGP -own-> URCP --ref-/
|
||||
//
|
||||
// BHI -ref-> RCI -ref-> BCI/BCP -own-> RC -ref-> URCGI/URCGP
|
||||
//
|
||||
@@ -120,13 +133,18 @@ class CefBrowserContext
|
||||
public base::RefCountedThreadSafe<
|
||||
CefBrowserContext, content::BrowserThread::DeleteOnUIThread> {
|
||||
public:
|
||||
CefBrowserContext();
|
||||
explicit CefBrowserContext(bool is_proxy);
|
||||
|
||||
// Must be called immediately after this object is created.
|
||||
virtual void Initialize();
|
||||
|
||||
// BrowserContext methods.
|
||||
content::ResourceContext* GetResourceContext() override;
|
||||
net::URLRequestContextGetter* GetRequestContext() override;
|
||||
net::URLRequestContextGetter* CreateMediaRequestContext() override;
|
||||
net::URLRequestContextGetter* CreateMediaRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory) override;
|
||||
|
||||
// Profile methods.
|
||||
ChromeZoomLevelPrefs* GetZoomLevelPrefs() override;
|
||||
@@ -153,7 +171,7 @@ class CefBrowserContext
|
||||
return extension_system_;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
// Simple tracking of allocated objects.
|
||||
static base::AtomicRefCount DebugObjCt; // NOLINT(runtime/int)
|
||||
#endif
|
||||
@@ -161,8 +179,6 @@ class CefBrowserContext
|
||||
protected:
|
||||
~CefBrowserContext() override;
|
||||
|
||||
void CreateProtocolHandlers(content::ProtocolHandlerMap* protocol_handlers);
|
||||
|
||||
// Must be called before the child object destructor has completed.
|
||||
void Shutdown();
|
||||
|
||||
@@ -172,6 +188,9 @@ class CefBrowserContext
|
||||
content::BrowserThread::UI>;
|
||||
friend class base::DeleteHelper<CefBrowserContext>;
|
||||
|
||||
// True if this CefBrowserContext is a CefBrowserContextProxy.
|
||||
const bool is_proxy_;
|
||||
|
||||
std::unique_ptr<CefResourceContext> resource_context_;
|
||||
|
||||
// Owned by the KeyedService system.
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include "libcef/browser/browser_context_proxy.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/download_manager_delegate.h"
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
#include "libcef/browser/permissions/permission_manager.h"
|
||||
#include "libcef/browser/prefs/browser_prefs.h"
|
||||
#include "libcef/browser/ssl_host_state_delegate.h"
|
||||
@@ -29,12 +30,14 @@
|
||||
#include "components/content_settings/core/browser/host_content_settings_map.h"
|
||||
#include "components/guest_view/browser/guest_view_manager.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/ui/zoom/zoom_event_manager.h"
|
||||
#include "components/visitedlink/browser/visitedlink_event_listener.h"
|
||||
#include "components/visitedlink/browser/visitedlink_master.h"
|
||||
#include "components/zoom/zoom_event_manager.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "extensions/browser/extension_protocols.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "net/proxy/proxy_config_service.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
@@ -196,11 +199,15 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::Listener {
|
||||
|
||||
CefBrowserContextImpl::CefBrowserContextImpl(
|
||||
const CefRequestContextSettings& settings)
|
||||
: settings_(settings) {
|
||||
: CefBrowserContext(false),
|
||||
settings_(settings) {
|
||||
g_manager.Get().AddImpl(this);
|
||||
}
|
||||
|
||||
CefBrowserContextImpl::~CefBrowserContextImpl() {
|
||||
// Unregister the context first to avoid re-entrancy during shutdown.
|
||||
g_manager.Get().RemoveImpl(this, cache_path_);
|
||||
|
||||
Shutdown();
|
||||
|
||||
// The FontFamilyCache references the ProxyService so delete it before the
|
||||
@@ -218,8 +225,6 @@ CefBrowserContextImpl::~CefBrowserContextImpl() {
|
||||
// when it's accessed from the content::BrowserContext destructor.
|
||||
if (download_manager_delegate_)
|
||||
download_manager_delegate_.reset(NULL);
|
||||
|
||||
g_manager.Get().RemoveImpl(this, cache_path_);
|
||||
}
|
||||
|
||||
void CefBrowserContextImpl::Initialize() {
|
||||
@@ -245,10 +250,8 @@ void CefBrowserContextImpl::Initialize() {
|
||||
}
|
||||
|
||||
// Initialize preferences.
|
||||
base::FilePath pref_path;
|
||||
if (!cache_path_.empty() && settings_.persist_user_preferences)
|
||||
pref_path = cache_path_.AppendASCII(browser_prefs::kUserPrefsFileName);
|
||||
pref_service_ = browser_prefs::CreatePrefService(pref_path);
|
||||
pref_service_ = browser_prefs::CreatePrefService(
|
||||
this, cache_path_, !!settings_.persist_user_preferences);
|
||||
|
||||
// Initialize visited links management.
|
||||
base::FilePath visited_link_path;
|
||||
@@ -276,6 +279,14 @@ void CefBrowserContextImpl::Initialize() {
|
||||
// CefURLRequestContextImpl.
|
||||
GetRequestContext();
|
||||
DCHECK(url_request_getter_.get());
|
||||
|
||||
// Create the StoragePartitionImplMap and StoragePartitionImpl for this
|
||||
// object. This must be done before the first WebContents is created using a
|
||||
// CefBrowserContextProxy of this object, otherwise the StoragePartitionProxy
|
||||
// will not be created (in that case
|
||||
// CefBrowserContextProxy::CreateRequestContext will be called, which is
|
||||
// incorrect).
|
||||
GetDefaultStoragePartition(this);
|
||||
}
|
||||
|
||||
void CefBrowserContextImpl::AddProxy(const CefBrowserContextProxy* proxy) {
|
||||
@@ -341,9 +352,9 @@ std::unique_ptr<content::ZoomLevelDelegate>
|
||||
if (cache_path_.empty())
|
||||
return std::unique_ptr<content::ZoomLevelDelegate>();
|
||||
|
||||
return make_scoped_ptr(new ChromeZoomLevelPrefs(
|
||||
return base::WrapUnique(new ChromeZoomLevelPrefs(
|
||||
GetPrefs(), cache_path_, partition_path,
|
||||
ui_zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
|
||||
zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
|
||||
}
|
||||
|
||||
bool CefBrowserContextImpl::IsOffTheRecord() const {
|
||||
@@ -359,29 +370,6 @@ content::DownloadManagerDelegate*
|
||||
return download_manager_delegate_.get();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* CefBrowserContextImpl::GetRequestContext() {
|
||||
CEF_REQUIRE_UIT();
|
||||
return GetDefaultStoragePartition(this)->GetURLRequestContext();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextImpl::GetMediaRequestContext() {
|
||||
return GetRequestContext();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextImpl::GetMediaRequestContextForRenderProcess(
|
||||
int renderer_child_id) {
|
||||
return GetRequestContext();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextImpl::GetMediaRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory) {
|
||||
return GetRequestContext();
|
||||
}
|
||||
|
||||
content::BrowserPluginGuestManager* CefBrowserContextImpl::GetGuestManager() {
|
||||
DCHECK(extensions::ExtensionsEnabled());
|
||||
return guest_view::GuestViewManager::FromBrowserContext(this);
|
||||
@@ -415,22 +403,6 @@ content::BackgroundSyncController*
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PrefService* CefBrowserContextImpl::GetPrefs() {
|
||||
return pref_service_.get();
|
||||
}
|
||||
|
||||
const PrefService* CefBrowserContextImpl::GetPrefs() const {
|
||||
return pref_service_.get();
|
||||
}
|
||||
|
||||
const CefRequestContextSettings& CefBrowserContextImpl::GetSettings() const {
|
||||
return settings_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContextHandler> CefBrowserContextImpl::GetHandler() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* CefBrowserContextImpl::CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
@@ -442,13 +414,23 @@ net::URLRequestContextGetter* CefBrowserContextImpl::CreateRequestContext(
|
||||
ProxyServiceFactory::CreateProxyConfigService(
|
||||
pref_proxy_config_tracker_.get()));
|
||||
|
||||
CreateProtocolHandlers(protocol_handlers);
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
// Handle only chrome-extension:// requests. CEF does not support
|
||||
// chrome-extension-resource:// requests (it does not store shared extension
|
||||
// data in its installation directory).
|
||||
extensions::InfoMap* extension_info_map =
|
||||
extension_system()->info_map();
|
||||
(*protocol_handlers)[extensions::kExtensionScheme] =
|
||||
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
|
||||
extensions::CreateExtensionProtocolHandler(
|
||||
IsOffTheRecord(), extension_info_map).release());
|
||||
}
|
||||
|
||||
url_request_getter_ = new CefURLRequestContextGetterImpl(
|
||||
settings_,
|
||||
GetPrefs(),
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
|
||||
protocol_handlers,
|
||||
std::move(proxy_config_service),
|
||||
std::move(request_interceptors));
|
||||
@@ -462,6 +444,30 @@ net::URLRequestContextGetter*
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
content::StoragePartition* CefBrowserContextImpl::GetStoragePartitionProxy(
|
||||
content::BrowserContext* browser_context,
|
||||
content::StoragePartition* partition_impl) {
|
||||
CefBrowserContextProxy* proxy =
|
||||
static_cast<CefBrowserContextProxy*>(browser_context);
|
||||
return proxy->GetOrCreateStoragePartitionProxy(partition_impl);
|
||||
}
|
||||
|
||||
PrefService* CefBrowserContextImpl::GetPrefs() {
|
||||
return pref_service_.get();
|
||||
}
|
||||
|
||||
const PrefService* CefBrowserContextImpl::GetPrefs() const {
|
||||
return pref_service_.get();
|
||||
}
|
||||
|
||||
const CefRequestContextSettings& CefBrowserContextImpl::GetSettings() const {
|
||||
return settings_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContextHandler> CefBrowserContextImpl::GetHandler() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -59,28 +59,12 @@ class CefBrowserContextImpl : public CefBrowserContext,
|
||||
const base::FilePath& partition_path) override;
|
||||
bool IsOffTheRecord() const override;
|
||||
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
|
||||
net::URLRequestContextGetter* GetRequestContext() override;
|
||||
net::URLRequestContextGetter* GetMediaRequestContext() override;
|
||||
net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
|
||||
int renderer_child_id) override;
|
||||
net::URLRequestContextGetter*
|
||||
GetMediaRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory) override;
|
||||
content::BrowserPluginGuestManager* GetGuestManager() override;
|
||||
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
|
||||
content::PushMessagingService* GetPushMessagingService() override;
|
||||
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
|
||||
content::PermissionManager* GetPermissionManager() override;
|
||||
content::BackgroundSyncController* GetBackgroundSyncController() override;
|
||||
|
||||
// Profile methods.
|
||||
PrefService* GetPrefs() override;
|
||||
const PrefService* GetPrefs() const override;
|
||||
|
||||
// CefBrowserContext methods.
|
||||
const CefRequestContextSettings& GetSettings() const override;
|
||||
CefRefPtr<CefRequestContextHandler> GetHandler() const override;
|
||||
net::URLRequestContextGetter* CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors)
|
||||
@@ -91,6 +75,17 @@ class CefBrowserContextImpl : public CefBrowserContext,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors)
|
||||
override;
|
||||
content::StoragePartition* GetStoragePartitionProxy(
|
||||
content::BrowserContext* browser_context,
|
||||
content::StoragePartition* partition_impl) override;
|
||||
|
||||
// Profile methods.
|
||||
PrefService* GetPrefs() override;
|
||||
const PrefService* GetPrefs() const override;
|
||||
|
||||
// CefBrowserContext methods.
|
||||
const CefRequestContextSettings& GetSettings() const override;
|
||||
CefRefPtr<CefRequestContextHandler> GetHandler() const override;
|
||||
HostContentSettingsMap* GetHostContentSettingsMap() override;
|
||||
void AddVisitedURLs(const std::vector<GURL>& urls) override;
|
||||
|
||||
|
@@ -7,23 +7,34 @@
|
||||
#include "libcef/browser/content_browser_client.h"
|
||||
#include "libcef/browser/download_manager_delegate.h"
|
||||
#include "libcef/browser/net/url_request_context_getter_proxy.h"
|
||||
#include "libcef/browser/storage_partition_proxy.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "chrome/browser/font_family_cache.h"
|
||||
#include "components/guest_view/common/guest_view_constants.h"
|
||||
#include "components/visitedlink/browser/visitedlink_master.h"
|
||||
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
|
||||
#include "content/browser/resource_context_impl.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())
|
||||
// If this value is not proxied then multiple StoragePartitionImpl objects
|
||||
// will be created and filesystem API access will fail, among other things.
|
||||
if (key == content::BrowserContext::GetStoragePartitionMapUserDataKey())
|
||||
return true;
|
||||
|
||||
// If these values are not proxied then blob data fails to load for the PDF
|
||||
// extension.
|
||||
// See also the call to InitializeResourceContext().
|
||||
if (key == content::ChromeBlobStorageContext::GetUserDataKey() ||
|
||||
key == content::StreamContext::GetUserDataKey()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If this value is not proxied then CefBrowserContextImpl::GetGuestManager()
|
||||
// returns NULL.
|
||||
// See also CefExtensionsAPIClient::CreateGuestViewManagerDelegate.
|
||||
@@ -44,7 +55,8 @@ bool ShouldProxyUserData(const void* key) {
|
||||
CefBrowserContextProxy::CefBrowserContextProxy(
|
||||
CefRefPtr<CefRequestContextHandler> handler,
|
||||
scoped_refptr<CefBrowserContextImpl> parent)
|
||||
: handler_(handler),
|
||||
: CefBrowserContext(true),
|
||||
handler_(handler),
|
||||
parent_(parent) {
|
||||
DCHECK(handler_.get());
|
||||
DCHECK(parent_.get());
|
||||
@@ -101,29 +113,6 @@ content::DownloadManagerDelegate*
|
||||
return download_manager_delegate_.get();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* CefBrowserContextProxy::GetRequestContext() {
|
||||
CEF_REQUIRE_UIT();
|
||||
return GetDefaultStoragePartition(this)->GetURLRequestContext();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextProxy::GetMediaRequestContext() {
|
||||
return GetRequestContext();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextProxy::GetMediaRequestContextForRenderProcess(
|
||||
int renderer_child_id) {
|
||||
return GetRequestContext();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextProxy::GetMediaRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory) {
|
||||
return GetRequestContext();
|
||||
}
|
||||
|
||||
content::BrowserPluginGuestManager* CefBrowserContextProxy::GetGuestManager() {
|
||||
return parent_->GetGuestManager();
|
||||
}
|
||||
@@ -152,6 +141,24 @@ content::BackgroundSyncController*
|
||||
return parent_->GetBackgroundSyncController();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* CefBrowserContextProxy::CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
// CefBrowserContextImpl::GetOrCreateStoragePartitionProxy is called instead
|
||||
// of this method.
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextProxy::CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PrefService* CefBrowserContextProxy::GetPrefs() {
|
||||
return parent_->GetPrefs();
|
||||
}
|
||||
@@ -168,29 +175,6 @@ CefRefPtr<CefRequestContextHandler> CefBrowserContextProxy::GetHandler() const {
|
||||
return handler_;
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* CefBrowserContextProxy::CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(!url_request_getter_.get());
|
||||
|
||||
CreateProtocolHandlers(protocol_handlers);
|
||||
|
||||
url_request_getter_ =
|
||||
new CefURLRequestContextGetterProxy(handler_, parent_->request_context());
|
||||
resource_context()->set_url_request_context_getter(url_request_getter_.get());
|
||||
return url_request_getter_.get();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextProxy::CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HostContentSettingsMap* CefBrowserContextProxy::GetHostContentSettingsMap() {
|
||||
return parent_->GetHostContentSettingsMap();
|
||||
}
|
||||
@@ -198,3 +182,29 @@ HostContentSettingsMap* CefBrowserContextProxy::GetHostContentSettingsMap() {
|
||||
void CefBrowserContextProxy::AddVisitedURLs(const std::vector<GURL>& urls) {
|
||||
parent_->AddVisitedURLs(urls);
|
||||
}
|
||||
|
||||
content::StoragePartition*
|
||||
CefBrowserContextProxy::GetOrCreateStoragePartitionProxy(
|
||||
content::StoragePartition* partition_impl) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
if (!storage_partition_proxy_) {
|
||||
scoped_refptr<CefURLRequestContextGetterProxy> url_request_getter =
|
||||
new CefURLRequestContextGetterProxy(handler_,
|
||||
parent_->request_context());
|
||||
resource_context()->set_url_request_context_getter(
|
||||
url_request_getter.get());
|
||||
storage_partition_proxy_.reset(
|
||||
new CefStoragePartitionProxy(partition_impl,
|
||||
url_request_getter.get()));
|
||||
|
||||
// Associates UserData keys with the ResourceContext.
|
||||
// Called from StoragePartitionImplMap::Get() for CefBrowserContextImpl.
|
||||
content::InitializeResourceContext(this);
|
||||
}
|
||||
|
||||
// There should only be one CefStoragePartitionProxy for this
|
||||
// CefBrowserContextProxy.
|
||||
DCHECK_EQ(storage_partition_proxy_->parent(), partition_impl);
|
||||
return storage_partition_proxy_.get();
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#include "base/memory/ref_counted.h"
|
||||
|
||||
class CefDownloadManagerDelegate;
|
||||
class CefURLRequestContextGetterProxy;
|
||||
class CefStoragePartitionProxy;
|
||||
|
||||
// BrowserContext implementation for a particular CefRequestContext. Life span
|
||||
// is controlled by CefRequestContextImpl. Only accessed on the UI thread. See
|
||||
@@ -34,28 +34,12 @@ class CefBrowserContextProxy : public CefBrowserContext {
|
||||
const base::FilePath& partition_path) override;
|
||||
bool IsOffTheRecord() const override;
|
||||
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
|
||||
net::URLRequestContextGetter* GetRequestContext() override;
|
||||
net::URLRequestContextGetter* GetMediaRequestContext() override;
|
||||
net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
|
||||
int renderer_child_id) override;
|
||||
net::URLRequestContextGetter*
|
||||
GetMediaRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory) override;
|
||||
content::BrowserPluginGuestManager* GetGuestManager() override;
|
||||
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
|
||||
content::PushMessagingService* GetPushMessagingService() override;
|
||||
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
|
||||
content::PermissionManager* GetPermissionManager() override;
|
||||
content::BackgroundSyncController* GetBackgroundSyncController() override;
|
||||
|
||||
// Profile methods.
|
||||
PrefService* GetPrefs() override;
|
||||
const PrefService* GetPrefs() const override;
|
||||
|
||||
// CefBrowserContext methods.
|
||||
const CefRequestContextSettings& GetSettings() const override;
|
||||
CefRefPtr<CefRequestContextHandler> GetHandler() const override;
|
||||
net::URLRequestContextGetter* CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors)
|
||||
@@ -66,9 +50,20 @@ class CefBrowserContextProxy : public CefBrowserContext {
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors)
|
||||
override;
|
||||
|
||||
// Profile methods.
|
||||
PrefService* GetPrefs() override;
|
||||
const PrefService* GetPrefs() const override;
|
||||
|
||||
// CefBrowserContext methods.
|
||||
const CefRequestContextSettings& GetSettings() const override;
|
||||
CefRefPtr<CefRequestContextHandler> GetHandler() const override;
|
||||
HostContentSettingsMap* GetHostContentSettingsMap() override;
|
||||
void AddVisitedURLs(const std::vector<GURL>& urls) override;
|
||||
|
||||
content::StoragePartition* GetOrCreateStoragePartitionProxy(
|
||||
content::StoragePartition* partition_impl);
|
||||
|
||||
scoped_refptr<CefBrowserContextImpl> parent() const {
|
||||
return parent_;
|
||||
}
|
||||
@@ -86,7 +81,7 @@ class CefBrowserContextProxy : public CefBrowserContext {
|
||||
scoped_refptr<CefBrowserContextImpl> parent_;
|
||||
|
||||
std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_;
|
||||
scoped_refptr<CefURLRequestContextGetterProxy> url_request_getter_;
|
||||
std::unique_ptr<CefStoragePartitionProxy> storage_partition_proxy_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserContextProxy);
|
||||
};
|
||||
|
@@ -39,9 +39,11 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/bind_helpers.h"
|
||||
#include "base/command_line.h"
|
||||
#include "chrome/browser/sessions/session_tab_helper.h"
|
||||
#include "chrome/browser/spellchecker/spellcheck_factory.h"
|
||||
#include "chrome/browser/spellchecker/spellcheck_service.h"
|
||||
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
||||
#include "components/zoom/zoom_controller.h"
|
||||
#include "content/browser/renderer_host/render_view_host_impl.h"
|
||||
#include "content/browser/gpu/compositor_util.h"
|
||||
#include "content/common/view_messages.h"
|
||||
@@ -62,7 +64,7 @@
|
||||
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include "chrome/browser/spellchecker/spellcheck_platform.h"
|
||||
#include "components/spellcheck/browser/spellcheck_platform.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@@ -285,6 +287,11 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::Create(
|
||||
request_context_impl->GetBrowserContext();
|
||||
DCHECK(browser_context);
|
||||
|
||||
// A StoragePartitionImplMap must already exist for the BrowserContext. See
|
||||
// additional comments in CefBrowserContextImpl::Initialize().
|
||||
DCHECK(browser_context->GetUserData(
|
||||
content::BrowserContext::GetStoragePartitionMapUserDataKey()));
|
||||
|
||||
if (!create_params.request_context) {
|
||||
// Using the global request context.
|
||||
create_params.request_context = request_context_impl.get();
|
||||
@@ -556,7 +563,7 @@ void CefBrowserHostImpl::CloseBrowser(bool force_close) {
|
||||
if (contents && contents->NeedToFireBeforeUnload()) {
|
||||
// Will result in a call to BeforeUnloadFired() and, if the close isn't
|
||||
// canceled, CloseContents().
|
||||
contents->DispatchBeforeUnload(false);
|
||||
contents->DispatchBeforeUnload();
|
||||
} else {
|
||||
CloseContents(contents);
|
||||
}
|
||||
@@ -596,7 +603,7 @@ void CefBrowserHostImpl::SetFocus(bool focus) {
|
||||
|
||||
if (focus)
|
||||
OnSetFocus(FOCUS_SOURCE_SYSTEM);
|
||||
else
|
||||
else if (platform_delegate_)
|
||||
platform_delegate_->SendFocusEvent(false);
|
||||
}
|
||||
|
||||
@@ -695,7 +702,8 @@ void CefBrowserHostImpl::StartDownload(const CefString& url) {
|
||||
return;
|
||||
|
||||
std::unique_ptr<content::DownloadUrlParameters> params(
|
||||
content::DownloadUrlParameters::FromWebContents(web_contents(), gurl));
|
||||
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
|
||||
web_contents(), gurl));
|
||||
manager->DownloadUrl(std::move(params));
|
||||
}
|
||||
|
||||
@@ -732,7 +740,7 @@ void CefBrowserHostImpl::Print() {
|
||||
content::WebContents* actionable_contents = GetActionableWebContents();
|
||||
if (!actionable_contents)
|
||||
return;
|
||||
printing::PrintViewManager::FromWebContents(
|
||||
printing::CefPrintViewManager::FromWebContents(
|
||||
actionable_contents)->PrintNow();
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
@@ -748,12 +756,12 @@ void CefBrowserHostImpl::PrintToPDF(const CefString& path,
|
||||
if (!actionable_contents)
|
||||
return;
|
||||
|
||||
printing::PrintViewManager::PdfPrintCallback pdf_callback;
|
||||
printing::CefPrintViewManager::PdfPrintCallback pdf_callback;
|
||||
if (callback.get()) {
|
||||
pdf_callback = base::Bind(&CefPdfPrintCallback::OnPdfPrintFinished,
|
||||
callback.get(), path);
|
||||
}
|
||||
printing::PrintViewManager::FromWebContents(actionable_contents)->
|
||||
printing::CefPrintViewManager::FromWebContents(actionable_contents)->
|
||||
PrintToPDF(base::FilePath(path), settings, pdf_callback);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
@@ -885,6 +893,22 @@ void CefBrowserHostImpl::GetNavigationEntries(
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefNavigationEntry> CefBrowserHostImpl::GetVisibleNavigationEntry() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
content::NavigationEntry* entry = nullptr;
|
||||
if (web_contents())
|
||||
entry = web_contents()->GetController().GetVisibleEntry();
|
||||
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
|
||||
return new CefNavigationEntryImpl(entry);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
mouse_cursor_change_disabled_ = disabled;
|
||||
@@ -939,7 +963,7 @@ void CefBrowserHostImpl::WasResized() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->WasResized();
|
||||
@@ -957,7 +981,7 @@ void CefBrowserHostImpl::WasHidden(bool hidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->WasHidden(hidden);
|
||||
@@ -975,7 +999,7 @@ void CefBrowserHostImpl::NotifyScreenInfoChanged() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->NotifyScreenInfoChanged();
|
||||
@@ -993,7 +1017,7 @@ void CefBrowserHostImpl::Invalidate(PaintElementType type) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->Invalidate(type);
|
||||
@@ -1006,7 +1030,7 @@ void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
content::NativeWebKeyboardEvent web_event;
|
||||
@@ -1023,7 +1047,7 @@ void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
blink::WebMouseEvent web_event;
|
||||
@@ -1041,7 +1065,7 @@ void CefBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
blink::WebMouseEvent web_event;
|
||||
@@ -1058,7 +1082,7 @@ void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
blink::WebMouseWheelEvent web_event;
|
||||
@@ -1077,7 +1101,7 @@ void CefBrowserHostImpl::SendCaptureLostEvent() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->SendCaptureLostEvent();
|
||||
@@ -1091,7 +1115,7 @@ void CefBrowserHostImpl::NotifyMoveOrResizeStarted() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->NotifyMoveOrResizeStarted();
|
||||
@@ -1117,7 +1141,9 @@ void CefBrowserHostImpl::SetWindowlessFrameRate(int frame_rate) {
|
||||
}
|
||||
|
||||
settings_.windowless_frame_rate = frame_rate;
|
||||
platform_delegate_->SetWindowlessFrameRate(frame_rate);
|
||||
|
||||
if (platform_delegate_)
|
||||
platform_delegate_->SetWindowlessFrameRate(frame_rate);
|
||||
}
|
||||
|
||||
// CefBrowser methods.
|
||||
@@ -1420,12 +1446,14 @@ void CefBrowserHostImpl::DestroyBrowser() {
|
||||
#if defined(USE_AURA)
|
||||
views::Widget* CefBrowserHostImpl::GetWindowWidget() const {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!platform_delegate_)
|
||||
return nullptr;
|
||||
return platform_delegate_->GetWindowWidget();
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserView> CefBrowserHostImpl::GetBrowserView() const {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (IsViewsHosted())
|
||||
if (IsViewsHosted() && platform_delegate_)
|
||||
return platform_delegate_->GetBrowserView();
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1664,7 +1692,8 @@ void CefBrowserHostImpl::ViewText(const std::string& text) {
|
||||
return;
|
||||
}
|
||||
|
||||
platform_delegate_->ViewText(text);
|
||||
if (platform_delegate_)
|
||||
platform_delegate_->ViewText(text);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::HandleExternalProtocol(const GURL& url) {
|
||||
@@ -1677,7 +1706,7 @@ void CefBrowserHostImpl::HandleExternalProtocol(const GURL& url) {
|
||||
handler->OnProtocolExecution(this, url.spec(), allow_os_execution);
|
||||
}
|
||||
|
||||
if (allow_os_execution)
|
||||
if (allow_os_execution && platform_delegate_)
|
||||
platform_delegate_->HandleExternalProtocol(url);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
@@ -1707,7 +1736,8 @@ void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
||||
}
|
||||
}
|
||||
|
||||
platform_delegate_->SendFocusEvent(true);
|
||||
if (platform_delegate_)
|
||||
platform_delegate_->SendFocusEvent(true);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBrowserHostImpl::OnSetFocus, this, source));
|
||||
@@ -1779,7 +1809,7 @@ CefTextInputContext CefBrowserHostImpl::GetNSTextInputContext() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return nullptr;
|
||||
|
||||
return platform_delegate_->GetNSTextInputContext();
|
||||
@@ -1801,7 +1831,7 @@ void CefBrowserHostImpl::HandleKeyEventBeforeTextInputClient(
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->HandleKeyEventBeforeTextInputClient(keyEvent);
|
||||
@@ -1821,7 +1851,7 @@ void CefBrowserHostImpl::HandleKeyEventAfterTextInputClient(
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
return platform_delegate_->HandleKeyEventAfterTextInputClient(keyEvent);
|
||||
@@ -1848,7 +1878,7 @@ void CefBrowserHostImpl::DragTargetDragEnter(CefRefPtr<CefDragData> drag_data,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->DragTargetDragEnter(drag_data, event, allowed_ops);
|
||||
@@ -1868,7 +1898,7 @@ void CefBrowserHostImpl::DragTargetDragOver(const CefMouseEvent& event,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->DragTargetDragOver(event, allowed_ops);
|
||||
@@ -1886,7 +1916,7 @@ void CefBrowserHostImpl::DragTargetDragLeave() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->DragTargetDragLeave();
|
||||
@@ -1904,7 +1934,7 @@ void CefBrowserHostImpl::DragTargetDrop(const CefMouseEvent& event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->DragTargetDrop(event);
|
||||
@@ -1922,6 +1952,9 @@ void CefBrowserHostImpl::DragSourceSystemDragEnded() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->DragSourceSystemDragEnded();
|
||||
}
|
||||
|
||||
@@ -1938,7 +1971,7 @@ void CefBrowserHostImpl::DragSourceEndedAt(
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->DragSourceEndedAt(x, y, op);
|
||||
@@ -2108,6 +2141,9 @@ bool CefBrowserHostImpl::PreHandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event,
|
||||
bool* is_keyboard_shortcut) {
|
||||
if (!platform_delegate_)
|
||||
return false;
|
||||
|
||||
if (client_.get()) {
|
||||
CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler();
|
||||
if (handler.get()) {
|
||||
@@ -2133,6 +2169,9 @@ void CefBrowserHostImpl::HandleKeyboardEvent(
|
||||
if (event.skip_in_browser)
|
||||
return;
|
||||
|
||||
if (!platform_delegate_)
|
||||
return;
|
||||
|
||||
if (client_.get()) {
|
||||
CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler();
|
||||
if (handler.get()) {
|
||||
@@ -2234,7 +2273,7 @@ void CefBrowserHostImpl::DidNavigateMainFramePostCommit(
|
||||
content::JavaScriptDialogManager*
|
||||
CefBrowserHostImpl::GetJavaScriptDialogManager(
|
||||
content::WebContents* source) {
|
||||
if (!javascript_dialog_manager_.get()) {
|
||||
if (!javascript_dialog_manager_.get() && platform_delegate_) {
|
||||
javascript_dialog_manager_.reset(
|
||||
new CefJavaScriptDialogManager(this,
|
||||
platform_delegate_->CreateJavaScriptDialogRunner()));
|
||||
@@ -2243,17 +2282,17 @@ content::JavaScriptDialogManager*
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::RunFileChooser(
|
||||
content::WebContents* web_contents,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params) {
|
||||
EnsureFileDialogManager();
|
||||
file_dialog_manager_->RunFileChooser(web_contents, params);
|
||||
file_dialog_manager_->RunFileChooser(render_frame_host, params);
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::HandleContextMenu(
|
||||
content::WebContents* web_contents,
|
||||
const content::ContextMenuParams& params) {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!menu_manager_.get()) {
|
||||
if (!menu_manager_.get() && platform_delegate_) {
|
||||
menu_manager_.reset(
|
||||
new CefMenuManager(this,
|
||||
platform_delegate_->CreateMenuRunner()));
|
||||
@@ -2265,7 +2304,8 @@ void CefBrowserHostImpl::UpdatePreferredSize(content::WebContents* source,
|
||||
const gfx::Size& pref_size) {
|
||||
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX))
|
||||
CEF_REQUIRE_UIT();
|
||||
platform_delegate_->SizeTo(pref_size.width(), pref_size.height());
|
||||
if (platform_delegate_)
|
||||
platform_delegate_->SizeTo(pref_size.width(), pref_size.height());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2797,7 +2837,13 @@ CefBrowserHostImpl::CefBrowserHostImpl(
|
||||
CefFrameHostImpl::kInvalidFrameId);
|
||||
|
||||
PrefsTabHelper::CreateForWebContents(web_contents_.get());
|
||||
printing::PrintViewManager::CreateForWebContents(web_contents_.get());
|
||||
printing::CefPrintViewManager::CreateForWebContents(web_contents_.get());
|
||||
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
// Used by the tabs extension API.
|
||||
SessionTabHelper::CreateForWebContents(web_contents_.get());
|
||||
zoom::ZoomController::CreateForWebContents(web_contents_.get());
|
||||
}
|
||||
|
||||
// Make sure RenderViewCreated is called at least one time.
|
||||
RenderViewCreated(web_contents->GetRenderViewHost());
|
||||
@@ -2931,7 +2977,7 @@ void CefBrowserHostImpl::SetFocusedFrame(int64 frame_id) {
|
||||
|
||||
gfx::Point CefBrowserHostImpl::GetScreenPoint(const gfx::Point& view) const {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (platform_delegate_.get())
|
||||
if (platform_delegate_)
|
||||
return platform_delegate_->GetScreenPoint(view);
|
||||
return gfx::Point();
|
||||
}
|
||||
@@ -2954,7 +3000,8 @@ void CefBrowserHostImpl::OnLoadStart(CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefLoadHandler> handler = client_->GetLoadHandler();
|
||||
if (handler.get()) {
|
||||
// Notify the handler that loading has started.
|
||||
handler->OnLoadStart(this, frame);
|
||||
handler->OnLoadStart(this, frame,
|
||||
static_cast<cef_transition_type_t>(transition_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3016,7 +3063,7 @@ void CefBrowserHostImpl::OnDevToolsWebContentsDestroyed() {
|
||||
|
||||
void CefBrowserHostImpl::EnsureFileDialogManager() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!file_dialog_manager_.get()) {
|
||||
if (!file_dialog_manager_.get() && platform_delegate_) {
|
||||
file_dialog_manager_.reset(
|
||||
new CefFileDialogManager(this,
|
||||
platform_delegate_->CreateFileDialogRunner()));
|
||||
|
@@ -218,6 +218,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
void DragTargetDrop(const CefMouseEvent& event) override;
|
||||
void DragSourceSystemDragEnded() override;
|
||||
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
|
||||
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
|
||||
|
||||
// CefBrowser methods.
|
||||
CefRefPtr<CefBrowserHost> GetHost() override;
|
||||
@@ -404,7 +405,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
||||
content::WebContents* source) override;
|
||||
void RunFileChooser(
|
||||
content::WebContents* web_contents,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params) override;
|
||||
bool EmbedsFullscreenWidget() const override;
|
||||
void EnterFullscreenModeForTab(content::WebContents* web_contents,
|
||||
|
@@ -347,7 +347,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
// Verify that no request for the same route is currently queued.
|
||||
{
|
||||
PendingNewBrowserInfoList::const_iterator it =
|
||||
@@ -408,7 +408,7 @@ void CefBrowserInfoManager::DestroyAllBrowsers() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
{
|
||||
// Verify that all browser windows have been destroyed.
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
@@ -435,6 +435,11 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoForFrame(
|
||||
is_guest_view);
|
||||
}
|
||||
|
||||
void CefBrowserInfoManager::GetBrowserInfoList(BrowserInfoList& list) {
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
list = browser_info_list_;
|
||||
}
|
||||
|
||||
void CefBrowserInfoManager::RenderProcessHostDestroyed(
|
||||
content::RenderProcessHost* host) {
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
@@ -488,7 +493,7 @@ std::unique_ptr<CefBrowserInfoManager::PendingPopup>
|
||||
popup->opener_view_id == opener_view_id &&
|
||||
popup->target_url == target_url) {
|
||||
pending_popup_list_.weak_erase(it);
|
||||
return make_scoped_ptr(popup);
|
||||
return base::WrapUnique(popup);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -128,6 +128,10 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
int render_routing_id,
|
||||
bool* is_guest_view);
|
||||
|
||||
// Retrieves all existing CefBrowserInfo objects.
|
||||
typedef std::list<scoped_refptr<CefBrowserInfo> > BrowserInfoList;
|
||||
void GetBrowserInfoList(BrowserInfoList& list);
|
||||
|
||||
private:
|
||||
// RenderProcessHostObserver methods:
|
||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
@@ -220,7 +224,6 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
|
||||
// Access to the below members must be protected by |browser_info_lock_|.
|
||||
|
||||
typedef std::list<scoped_refptr<CefBrowserInfo> > BrowserInfoList;
|
||||
BrowserInfoList browser_info_list_;
|
||||
int next_browser_id_;
|
||||
|
||||
|
@@ -32,6 +32,9 @@
|
||||
#include "content/public/browser/gpu_data_manager.h"
|
||||
#include "content/public/browser/web_ui_controller_factory.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "device/geolocation/access_token_store.h"
|
||||
#include "device/geolocation/geolocation_delegate.h"
|
||||
#include "device/geolocation/geolocation_provider.h"
|
||||
#include "extensions/browser/extension_system.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "net/base/net_module.h"
|
||||
@@ -39,7 +42,7 @@
|
||||
|
||||
#if defined(USE_AURA)
|
||||
#include "ui/aura/env.h"
|
||||
#include "ui/gfx/screen.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/views/test/desktop_test_views_delegate.h"
|
||||
#include "ui/views/widget/desktop_aura/desktop_screen.h"
|
||||
|
||||
@@ -56,6 +59,50 @@
|
||||
#include "libcef/browser/printing/print_dialog_linux.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// In-memory store for access tokens used by geolocation.
|
||||
class CefAccessTokenStore : public device::AccessTokenStore {
|
||||
public:
|
||||
// |system_context| is used by NetworkLocationProvider to communicate with a
|
||||
// remote geolocation service.
|
||||
explicit CefAccessTokenStore(net::URLRequestContextGetter* system_context)
|
||||
: system_context_(system_context) {}
|
||||
|
||||
void LoadAccessTokens(const LoadAccessTokensCallback& callback) override {
|
||||
callback.Run(access_token_map_, system_context_);
|
||||
}
|
||||
|
||||
void SaveAccessToken(
|
||||
const GURL& server_url, const base::string16& access_token) override {
|
||||
access_token_map_[server_url] = access_token;
|
||||
}
|
||||
|
||||
private:
|
||||
net::URLRequestContextGetter* system_context_;
|
||||
AccessTokenMap access_token_map_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefAccessTokenStore);
|
||||
};
|
||||
|
||||
// A provider of services for geolocation.
|
||||
class CefGeolocationDelegate : public device::GeolocationDelegate {
|
||||
public:
|
||||
explicit CefGeolocationDelegate(net::URLRequestContextGetter* system_context)
|
||||
: system_context_(system_context) {}
|
||||
|
||||
scoped_refptr<device::AccessTokenStore> CreateAccessTokenStore() override {
|
||||
return new CefAccessTokenStore(system_context_);
|
||||
}
|
||||
|
||||
private:
|
||||
net::URLRequestContextGetter* system_context_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefGeolocationDelegate);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
CefBrowserMainParts::CefBrowserMainParts(
|
||||
const content::MainFunctionParams& parameters)
|
||||
: BrowserMainParts(),
|
||||
@@ -69,7 +116,6 @@ void CefBrowserMainParts::PreMainMessageLoopStart() {
|
||||
if (!base::MessageLoop::current()) {
|
||||
// Create the browser message loop.
|
||||
message_loop_.reset(new CefBrowserMessageLoop());
|
||||
message_loop_->set_thread_name("CrBrowserMain");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +166,7 @@ int CefBrowserMainParts::PreCreateThreads() {
|
||||
content::GpuDataManager::GetInstance();
|
||||
|
||||
#if defined(USE_AURA)
|
||||
gfx::Screen::SetScreenInstance(views::CreateDesktopScreen());
|
||||
display::Screen::SetScreenInstance(views::CreateDesktopScreen());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@@ -164,6 +210,10 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
|
||||
|
||||
// Triggers initialization of the singleton instance on UI thread.
|
||||
PluginFinder::GetInstance()->Init();
|
||||
|
||||
device::GeolocationProvider::SetGeolocationDelegate(
|
||||
new CefGeolocationDelegate(
|
||||
global_browser_context_->request_context().get()));
|
||||
}
|
||||
|
||||
void CefBrowserMainParts::PostMainMessageLoopRun() {
|
||||
@@ -178,23 +228,11 @@ void CefBrowserMainParts::PostMainMessageLoopRun() {
|
||||
}
|
||||
|
||||
global_browser_context_ = NULL;
|
||||
|
||||
#ifndef NDEBUG
|
||||
// No CefBrowserContext instances should exist at this point.
|
||||
DCHECK_EQ(0, CefBrowserContext::DebugObjCt);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CefBrowserMainParts::PostDestroyThreads() {
|
||||
#if defined(USE_AURA)
|
||||
aura::Env::DeleteInstance();
|
||||
|
||||
// Delete the DesktopTestViewsDelegate.
|
||||
delete views::ViewsDelegate::GetInstance();
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
// No CefURLRequestContext instances should exist at this point.
|
||||
DCHECK_EQ(0, CefURLRequestContext::DebugObjCt);
|
||||
#endif
|
||||
}
|
||||
|
@@ -8,10 +8,10 @@
|
||||
|
||||
#include "libcef/browser/browser_main.h"
|
||||
|
||||
#include "cef/grit/cef_strings.h"
|
||||
#include "chrome/common/chrome_utility_messages.h"
|
||||
#include "content/public/browser/utility_process_host.h"
|
||||
#include "content/public/browser/utility_process_host_client.h"
|
||||
#include "grit/cef_strings.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/gfx/win/direct_write.h"
|
||||
|
||||
|
@@ -3,9 +3,108 @@
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/browser_message_loop.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/common/content_client.h"
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/run_loop.h"
|
||||
|
||||
CefBrowserMessageLoop::CefBrowserMessageLoop() {
|
||||
#if defined(OS_MACOSX)
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// MessagePump implementation that delegates to OnScheduleMessagePumpWork() for
|
||||
// scheduling.
|
||||
class MessagePumpExternal : public base::MessagePump {
|
||||
public:
|
||||
MessagePumpExternal(float max_time_slice,
|
||||
CefRefPtr<CefBrowserProcessHandler> handler)
|
||||
: max_time_slice_(max_time_slice),
|
||||
handler_(handler) {
|
||||
}
|
||||
|
||||
void Run(Delegate* delegate) override {
|
||||
base::TimeTicks start = base::TimeTicks::Now();
|
||||
while (true) {
|
||||
#if defined(OS_MACOSX)
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
||||
#endif
|
||||
|
||||
const bool has_more_work = DirectRunWork(delegate);
|
||||
if (!has_more_work)
|
||||
break;
|
||||
|
||||
const base::TimeDelta& delta = base::TimeTicks::Now() - start;
|
||||
if (delta.InSecondsF() > max_time_slice_)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Quit() override {
|
||||
}
|
||||
|
||||
void ScheduleWork() override {
|
||||
handler_->OnScheduleMessagePumpWork(0);
|
||||
}
|
||||
|
||||
void ScheduleDelayedWork(const base::TimeTicks& delayed_work_time) override {
|
||||
const base::TimeDelta& delta = delayed_work_time - base::TimeTicks::Now();
|
||||
handler_->OnScheduleMessagePumpWork(delta.InMilliseconds());
|
||||
}
|
||||
|
||||
private:
|
||||
bool DirectRunWork(Delegate* delegate) {
|
||||
bool did_work = false;
|
||||
bool did_delayed_work = false;
|
||||
bool did_idle_work = false;
|
||||
|
||||
// Perform work & delayed work.
|
||||
// If no work was found, then perform idle work.
|
||||
|
||||
did_work = delegate->DoWork();
|
||||
|
||||
// We are using an external timer, so we don't have any action based on the
|
||||
// returned next delayed work time.
|
||||
base::TimeTicks next_time;
|
||||
did_delayed_work = delegate->DoDelayedWork(&next_time);
|
||||
|
||||
if (!did_work && !did_delayed_work) {
|
||||
did_idle_work = delegate->DoIdleWork();
|
||||
}
|
||||
|
||||
return did_work || did_delayed_work || did_idle_work;
|
||||
}
|
||||
|
||||
const float max_time_slice_;
|
||||
CefRefPtr<CefBrowserProcessHandler> handler_;
|
||||
};
|
||||
|
||||
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
|
||||
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
|
||||
if (app)
|
||||
return app->GetBrowserProcessHandler();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<base::MessagePump> CreatePump() {
|
||||
const CefSettings& settings = CefContext::Get()->settings();
|
||||
if (settings.external_message_pump) {
|
||||
CefRefPtr<CefBrowserProcessHandler> handler = GetBrowserProcessHandler();
|
||||
if (handler)
|
||||
return base::WrapUnique(new MessagePumpExternal(0.01f, handler));
|
||||
}
|
||||
|
||||
return base::MessageLoop::CreateMessagePumpForType(
|
||||
base::MessageLoop::TYPE_UI);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CefBrowserMessageLoop::CefBrowserMessageLoop()
|
||||
: base::MessageLoopForUI(CreatePump()) {
|
||||
BindToCurrentThread();
|
||||
}
|
||||
|
||||
CefBrowserMessageLoop::~CefBrowserMessageLoop() {
|
||||
@@ -14,7 +113,7 @@ CefBrowserMessageLoop::~CefBrowserMessageLoop() {
|
||||
// static
|
||||
CefBrowserMessageLoop* CefBrowserMessageLoop::current() {
|
||||
base::MessageLoop* loop = base::MessageLoop::current();
|
||||
DCHECK_EQ(base::MessageLoop::TYPE_UI, loop->type());
|
||||
DCHECK(loop->IsType(base::MessageLoop::TYPE_UI));
|
||||
return static_cast<CefBrowserMessageLoop*>(loop);
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class CefBrowserMessageLoop : public base::MessageLoopForUI {
|
||||
CefBrowserMessageLoop();
|
||||
~CefBrowserMessageLoop() override;
|
||||
|
||||
// Returns the MessageLoopForUI of the current thread.
|
||||
// Returns the CefBrowserMessageLoop of the current thread.
|
||||
static CefBrowserMessageLoop* current();
|
||||
|
||||
// Do a single interation of the UI message loop.
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -30,11 +31,11 @@ namespace {
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
|
||||
const CefWindowInfo& window_info) {
|
||||
#if defined(OS_WIN)
|
||||
return make_scoped_ptr(new CefBrowserPlatformDelegateNativeWin(window_info));
|
||||
return base::WrapUnique(new CefBrowserPlatformDelegateNativeWin(window_info));
|
||||
#elif defined(OS_MACOSX)
|
||||
return make_scoped_ptr(new CefBrowserPlatformDelegateNativeMac(window_info));
|
||||
return base::WrapUnique(new CefBrowserPlatformDelegateNativeMac(window_info));
|
||||
#elif defined(OS_LINUX)
|
||||
return make_scoped_ptr(
|
||||
return base::WrapUnique(
|
||||
new CefBrowserPlatformDelegateNativeLinux(window_info));
|
||||
#endif
|
||||
}
|
||||
@@ -42,14 +43,14 @@ std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
|
||||
std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate) {
|
||||
#if defined(OS_WIN)
|
||||
return make_scoped_ptr(
|
||||
new CefBrowserPlatformDelegateOsrWin(std::move(native_delegate)));
|
||||
return base::WrapUnique(
|
||||
new CefBrowserPlatformDelegateOsrWin(std::move(native_delegate)));
|
||||
#elif defined(OS_MACOSX)
|
||||
return make_scoped_ptr(
|
||||
new CefBrowserPlatformDelegateOsrMac(std::move(native_delegate)));
|
||||
return base::WrapUnique(
|
||||
new CefBrowserPlatformDelegateOsrMac(std::move(native_delegate)));
|
||||
#elif defined(OS_LINUX)
|
||||
return make_scoped_ptr(
|
||||
new CefBrowserPlatformDelegateOsrLinux(std::move(native_delegate)));
|
||||
return base::WrapUnique(
|
||||
new CefBrowserPlatformDelegateOsrLinux(std::move(native_delegate)));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
||||
// CefWindowInfo is not used in this case.
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
||||
CreateNativeDelegate(CefWindowInfo());
|
||||
return make_scoped_ptr(new CefBrowserPlatformDelegateViews(
|
||||
return base::WrapUnique(new CefBrowserPlatformDelegateViews(
|
||||
std::move(native_delegate),
|
||||
static_cast<CefBrowserViewImpl*>(create_params.browser_view.get())));
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ class CefURLFetcherDelegate : public net::URLFetcherDelegate {
|
||||
// net::URLFetcherDelegate methods.
|
||||
void OnURLFetchComplete(const net::URLFetcher* source) override;
|
||||
void OnURLFetchDownloadProgress(const net::URLFetcher* source,
|
||||
int64 current, int64 total) override;
|
||||
int64_t current,
|
||||
int64_t total,
|
||||
int64_t current_network_bytes) override;
|
||||
void OnURLFetchUploadProgress(const net::URLFetcher* source,
|
||||
int64 current, int64 total) override;
|
||||
|
||||
@@ -396,13 +398,15 @@ void CefURLFetcherDelegate::OnURLFetchComplete(
|
||||
const net::URLFetcher* source) {
|
||||
// Complete asynchronously so as not to delete the URLFetcher while it's still
|
||||
// in the call stack.
|
||||
base::MessageLoop::current()->PostTask(FROM_HERE,
|
||||
base::MessageLoop::current()->task_runner()->PostTask(FROM_HERE,
|
||||
base::Bind(&CefBrowserURLRequest::Context::OnComplete, context_));
|
||||
}
|
||||
|
||||
void CefURLFetcherDelegate::OnURLFetchDownloadProgress(
|
||||
const net::URLFetcher* source,
|
||||
int64 current, int64 total) {
|
||||
int64_t current,
|
||||
int64_t total,
|
||||
int64_t current_network_bytes) {
|
||||
context_->OnDownloadProgress(current, total);
|
||||
}
|
||||
|
||||
|
@@ -4,16 +4,57 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/chrome_browser_process_stub.h"
|
||||
#include "libcef/browser/context.h"
|
||||
|
||||
#include "libcef/browser/browser_context_impl.h"
|
||||
#include "libcef/browser/chrome_profile_manager_stub.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "chrome/browser/printing/print_job_manager.h"
|
||||
#include "ui/message_center/message_center.h"
|
||||
|
||||
ChromeBrowserProcessStub::ChromeBrowserProcessStub()
|
||||
: locale_("en-US") {
|
||||
: initialized_(false),
|
||||
shutdown_(false),
|
||||
locale_("en-US") {
|
||||
chrome::SetBrowserContextIncognitoHelper(this);
|
||||
}
|
||||
|
||||
ChromeBrowserProcessStub::~ChromeBrowserProcessStub() {
|
||||
DCHECK(!initialized_ || shutdown_);
|
||||
g_browser_process = NULL;
|
||||
chrome::SetBrowserContextIncognitoHelper(nullptr);
|
||||
}
|
||||
|
||||
void ChromeBrowserProcessStub::Initialize() {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(!initialized_);
|
||||
DCHECK(!shutdown_);
|
||||
|
||||
// Must be created after the NotificationService.
|
||||
print_job_manager_.reset(new printing::PrintJobManager());
|
||||
profile_manager_.reset(new ChromeProfileManagerStub());
|
||||
event_router_forwarder_ = new extensions::EventRouterForwarder();
|
||||
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
void ChromeBrowserProcessStub::Shutdown() {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(initialized_);
|
||||
DCHECK(!shutdown_);
|
||||
|
||||
// Wait for the pending print jobs to finish. Don't do this later, since
|
||||
// this might cause a nested message loop to run, and we don't want pending
|
||||
// tasks to run once teardown has started.
|
||||
print_job_manager_->Shutdown();
|
||||
print_job_manager_.reset(NULL);
|
||||
|
||||
profile_manager_.reset();
|
||||
event_router_forwarder_ = nullptr;
|
||||
|
||||
shutdown_ = true;
|
||||
}
|
||||
|
||||
void ChromeBrowserProcessStub::ResourceDispatcherHostCreated() {
|
||||
@@ -51,8 +92,7 @@ WatchDogThread* ChromeBrowserProcessStub::watchdog_thread() {
|
||||
}
|
||||
|
||||
ProfileManager* ChromeBrowserProcessStub::profile_manager() {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
return profile_manager_.get();
|
||||
}
|
||||
|
||||
PrefService* ChromeBrowserProcessStub::local_state() {
|
||||
@@ -72,12 +112,6 @@ variations::VariationsService*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
web_resource::PromoResourceService*
|
||||
ChromeBrowserProcessStub::promo_resource_service() {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BrowserProcessPlatformPart* ChromeBrowserProcessStub::platform_part() {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
@@ -85,11 +119,16 @@ BrowserProcessPlatformPart* ChromeBrowserProcessStub::platform_part() {
|
||||
|
||||
extensions::EventRouterForwarder*
|
||||
ChromeBrowserProcessStub::extension_event_router_forwarder() {
|
||||
return event_router_forwarder_.get();
|
||||
}
|
||||
|
||||
NotificationUIManager* ChromeBrowserProcessStub::notification_ui_manager() {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NotificationUIManager* ChromeBrowserProcessStub::notification_ui_manager() {
|
||||
NotificationPlatformBridge*
|
||||
ChromeBrowserProcessStub::notification_platform_bridge() {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
@@ -115,12 +154,12 @@ IconManager* ChromeBrowserProcessStub::icon_manager() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GLStringManager* ChromeBrowserProcessStub::gl_string_manager() {
|
||||
GpuModeManager* ChromeBrowserProcessStub::gpu_mode_manager() {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GpuModeManager* ChromeBrowserProcessStub::gpu_mode_manager() {
|
||||
GpuProfileCache* ChromeBrowserProcessStub::gpu_profile_cache() {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
@@ -141,7 +180,7 @@ bool ChromeBrowserProcessStub::IsShuttingDown() {
|
||||
}
|
||||
|
||||
printing::PrintJobManager* ChromeBrowserProcessStub::print_job_manager() {
|
||||
return CefContext::Get()->print_job_manager();
|
||||
return print_job_manager_.get();
|
||||
}
|
||||
|
||||
printing::PrintPreviewDialogController*
|
||||
@@ -208,6 +247,12 @@ safe_browsing::ClientSideDetectionService*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
subresource_filter::RulesetService*
|
||||
ChromeBrowserProcessStub::subresource_filter_ruleset_service() {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
|
||||
void ChromeBrowserProcessStub::StartAutoupdateTimer() {
|
||||
}
|
||||
@@ -220,7 +265,8 @@ net_log::ChromeNetLog* ChromeBrowserProcessStub::net_log() {
|
||||
|
||||
component_updater::ComponentUpdateService*
|
||||
ChromeBrowserProcessStub::component_updater() {
|
||||
return CefContext::Get()->component_updater();
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CRLSetFetcher* ChromeBrowserProcessStub::crl_set_fetcher() {
|
||||
@@ -279,3 +325,15 @@ memory::TabManager* ChromeBrowserProcessStub::GetTabManager() {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
content::BrowserContext*
|
||||
ChromeBrowserProcessStub::GetBrowserContextRedirectedInIncognito(
|
||||
content::BrowserContext* context) {
|
||||
return CefBrowserContextImpl::GetForContext(context).get();
|
||||
}
|
||||
|
||||
content::BrowserContext*
|
||||
ChromeBrowserProcessStub::GetBrowserContextOwnInstanceInIncognito(
|
||||
content::BrowserContext* context) {
|
||||
return GetBrowserContextRedirectedInIncognito(context);
|
||||
}
|
||||
|
@@ -3,16 +3,21 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// This file provides a stub implementation of Chrome's BrowserProcess object
|
||||
// for use as an interop layer between CEF and files that live in chrome/.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_
|
||||
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/extensions/event_router_forwarder.h"
|
||||
#include "chrome/browser/profiles/incognito_helpers.h"
|
||||
#include "base/compiler_specific.h"
|
||||
|
||||
// This file provides a stub implementation of Chrome's BrowserProcess object
|
||||
// for use as an interop layer between CEF and files that live in chrome/.
|
||||
class ChromeProfileManagerStub;
|
||||
|
||||
class BackgroundModeManager {
|
||||
public:
|
||||
@@ -22,11 +27,15 @@ class BackgroundModeManager {
|
||||
DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager);
|
||||
};
|
||||
|
||||
class ChromeBrowserProcessStub : public BrowserProcess {
|
||||
class ChromeBrowserProcessStub : public BrowserProcess,
|
||||
public chrome::BrowserContextIncognitoHelper {
|
||||
public:
|
||||
ChromeBrowserProcessStub();
|
||||
~ChromeBrowserProcessStub() override;
|
||||
|
||||
void Initialize();
|
||||
void Shutdown();
|
||||
|
||||
// BrowserProcess implementation.
|
||||
void ResourceDispatcherHostCreated() override;
|
||||
void EndSession() override;
|
||||
@@ -40,17 +49,17 @@ class ChromeBrowserProcessStub : public BrowserProcess {
|
||||
PrefService* local_state() override;
|
||||
net::URLRequestContextGetter* system_request_context() override;
|
||||
variations::VariationsService* variations_service() override;
|
||||
web_resource::PromoResourceService* promo_resource_service() override;
|
||||
BrowserProcessPlatformPart* platform_part() override;
|
||||
extensions::EventRouterForwarder*
|
||||
extension_event_router_forwarder() override;
|
||||
NotificationUIManager* notification_ui_manager() override;
|
||||
NotificationPlatformBridge* notification_platform_bridge() override;
|
||||
message_center::MessageCenter* message_center() override;
|
||||
policy::BrowserPolicyConnector* browser_policy_connector() override;
|
||||
policy::PolicyService* policy_service() override;
|
||||
IconManager* icon_manager() override;
|
||||
GLStringManager* gl_string_manager() override;
|
||||
GpuModeManager* gpu_mode_manager() override;
|
||||
GpuProfileCache* gpu_profile_cache() override;
|
||||
void CreateDevToolsHttpProtocolHandler(const std::string& ip,
|
||||
uint16_t port) override;
|
||||
void CreateDevToolsAutoOpener() override;
|
||||
@@ -72,6 +81,8 @@ class ChromeBrowserProcessStub : public BrowserProcess {
|
||||
safe_browsing::SafeBrowsingService* safe_browsing_service() override;
|
||||
safe_browsing::ClientSideDetectionService*
|
||||
safe_browsing_detection_service() override;
|
||||
subresource_filter::RulesetService*
|
||||
subresource_filter_ruleset_service() override;
|
||||
|
||||
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
|
||||
void StartAutoupdateTimer() override;
|
||||
@@ -97,8 +108,20 @@ class ChromeBrowserProcessStub : public BrowserProcess {
|
||||
CachedDefaultWebClientState() override;
|
||||
memory::TabManager* GetTabManager() override;
|
||||
|
||||
// BrowserContextIncognitoHelper implementation.
|
||||
content::BrowserContext* GetBrowserContextRedirectedInIncognito(
|
||||
content::BrowserContext* context) override;
|
||||
content::BrowserContext* GetBrowserContextOwnInstanceInIncognito(
|
||||
content::BrowserContext* context) override;
|
||||
|
||||
private:
|
||||
bool initialized_;
|
||||
bool shutdown_;
|
||||
|
||||
std::string locale_;
|
||||
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
|
||||
std::unique_ptr<ChromeProfileManagerStub> profile_manager_;
|
||||
scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProcessStub);
|
||||
};
|
||||
|
31
libcef/browser/chrome_profile_manager_stub.cc
Normal file
31
libcef/browser/chrome_profile_manager_stub.cc
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2016 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/chrome_profile_manager_stub.h"
|
||||
|
||||
#include "libcef/browser/browser_context_impl.h"
|
||||
|
||||
ChromeProfileManagerStub::ChromeProfileManagerStub()
|
||||
: ProfileManager(base::FilePath()) {
|
||||
}
|
||||
|
||||
ChromeProfileManagerStub::~ChromeProfileManagerStub() {
|
||||
}
|
||||
|
||||
Profile* ChromeProfileManagerStub::GetProfile(
|
||||
const base::FilePath& profile_dir) {
|
||||
scoped_refptr<CefBrowserContextImpl> browser_context =
|
||||
CefBrowserContextImpl::GetForCachePath(profile_dir);
|
||||
DCHECK(browser_context);
|
||||
return browser_context.get();
|
||||
}
|
||||
|
||||
bool ChromeProfileManagerStub::IsValidProfile(const void* profile) {
|
||||
if (!profile)
|
||||
return false;
|
||||
return !!CefBrowserContextImpl::GetForContext(
|
||||
reinterpret_cast<content::BrowserContext*>(
|
||||
const_cast<void*>(profile))).get();
|
||||
}
|
26
libcef/browser/chrome_profile_manager_stub.h
Normal file
26
libcef/browser/chrome_profile_manager_stub.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2016 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// This file provides a stub implementation of Chrome's ProfileManager object
|
||||
// for use as an interop layer between CEF and files that live in chrome/.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_
|
||||
#define CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_
|
||||
|
||||
#include "chrome/browser/profiles/profile_manager.h"
|
||||
|
||||
class ChromeProfileManagerStub : public ProfileManager {
|
||||
public:
|
||||
ChromeProfileManagerStub();
|
||||
~ChromeProfileManagerStub() override;
|
||||
|
||||
Profile* GetProfile(const base::FilePath& profile_dir) override;
|
||||
bool IsValidProfile(const void* profile) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ChromeProfileManagerStub);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_
|
@@ -5,84 +5,6 @@
|
||||
|
||||
#include "libcef/browser/chrome_profile_stub.h"
|
||||
|
||||
// Profile implementation.
|
||||
// Based on chrome/browser/profiles/profile.cc.
|
||||
|
||||
Profile::Profile() {
|
||||
}
|
||||
|
||||
Profile::~Profile() {
|
||||
}
|
||||
|
||||
// static
|
||||
Profile* Profile::FromBrowserContext(content::BrowserContext* browser_context) {
|
||||
// This is safe; this is the only implementation of the browser context.
|
||||
return static_cast<Profile*>(browser_context);
|
||||
}
|
||||
|
||||
// static
|
||||
Profile* Profile::FromWebUI(content::WebUI* web_ui) {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TestingProfile* Profile::AsTestingProfile() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ChromeZoomLevelPrefs* Profile::GetZoomLevelPrefs() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// static
|
||||
void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
std::string Profile::GetDebugName() {
|
||||
NOTIMPLEMENTED();
|
||||
return std::string();
|
||||
}
|
||||
|
||||
bool Profile::IsGuestSession() const {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Profile::IsSystemProfile() const {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Profile::IsNewProfile() {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Profile::IsSyncAllowed() {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
void Profile::MaybeSendDestroyedNotification() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
bool ProfileCompare::operator()(Profile* a, Profile* b) const {
|
||||
DCHECK(a && b);
|
||||
if (a->IsSameProfile(b))
|
||||
return false;
|
||||
return a->GetOriginalProfile() < b->GetOriginalProfile();
|
||||
}
|
||||
|
||||
double Profile::GetDefaultZoomLevelForProfile() {
|
||||
NOTIMPLEMENTED();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
// ChromeProfileStub implementation.
|
||||
|
||||
ChromeProfileStub::ChromeProfileStub(){
|
||||
}
|
||||
|
||||
@@ -123,7 +45,6 @@ Profile* ChromeProfileStub::GetOriginalProfile() {
|
||||
}
|
||||
|
||||
bool ChromeProfileStub::IsSupervised() const {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -1,304 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/component_updater/cef_component_updater_configurator.h"
|
||||
#include "include/cef_version.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/version.h"
|
||||
#include "build/build_config.h"
|
||||
#include "chrome/browser/update_client/chrome_update_query_params_delegate.h"
|
||||
#include "components/update_client/component_patcher_operation.h"
|
||||
#include "components/component_updater/component_updater_switches.h"
|
||||
#include "components/component_updater/component_updater_url_constants.h"
|
||||
#include "components/update_client/configurator.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "base/win/win_util.h"
|
||||
#endif // OS_WIN
|
||||
|
||||
using update_client::Configurator;
|
||||
|
||||
namespace component_updater {
|
||||
|
||||
namespace {
|
||||
|
||||
// Default time constants.
|
||||
const int kDelayOneMinute = 60;
|
||||
const int kDelayOneHour = kDelayOneMinute * 60;
|
||||
|
||||
// Debug values you can pass to --component-updater=value1,value2.
|
||||
// Speed up component checking.
|
||||
const char kSwitchFastUpdate[] = "fast-update";
|
||||
|
||||
// Add "testrequest=1" attribute to the update check request.
|
||||
const char kSwitchRequestParam[] = "test-request";
|
||||
|
||||
// Disables pings. Pings are the requests sent to the update server that report
|
||||
// the success or the failure of component install or update attempts.
|
||||
extern const char kSwitchDisablePings[] = "disable-pings";
|
||||
|
||||
// Sets the URL for updates.
|
||||
const char kSwitchUrlSource[] = "url-source";
|
||||
|
||||
// Disables differential updates.
|
||||
const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates";
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Disables background downloads.
|
||||
const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads";
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
// Returns true if and only if |test| is contained in |vec|.
|
||||
bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) {
|
||||
if (vec.empty())
|
||||
return 0;
|
||||
return (std::find(vec.begin(), vec.end(), test) != vec.end());
|
||||
}
|
||||
|
||||
// If there is an element of |vec| of the form |test|=.*, returns the right-
|
||||
// hand side of that assignment. Otherwise, returns an empty string.
|
||||
// The right-hand side may contain additional '=' characters, allowing for
|
||||
// further nesting of switch arguments.
|
||||
std::string GetSwitchArgument(const std::vector<std::string>& vec,
|
||||
const char* test) {
|
||||
if (vec.empty())
|
||||
return std::string();
|
||||
for (std::vector<std::string>::const_iterator it = vec.begin();
|
||||
it != vec.end();
|
||||
++it) {
|
||||
const std::size_t found = it->find("=");
|
||||
if (found != std::string::npos) {
|
||||
if (it->substr(0, found) == test) {
|
||||
return it->substr(found + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
class CefConfigurator : public Configurator {
|
||||
public:
|
||||
CefConfigurator(const base::CommandLine* cmdline,
|
||||
net::URLRequestContextGetter* url_request_getter,
|
||||
PrefService* pref_service);
|
||||
|
||||
int InitialDelay() const override;
|
||||
int NextCheckDelay() const override;
|
||||
int StepDelay() const override;
|
||||
int OnDemandDelay() const override;
|
||||
int UpdateDelay() const override;
|
||||
std::vector<GURL> UpdateUrl() const override;
|
||||
std::vector<GURL> PingUrl() const override;
|
||||
base::Version GetBrowserVersion() const override;
|
||||
std::string GetChannel() const override;
|
||||
std::string GetBrand() const override;
|
||||
std::string GetLang() const override;
|
||||
std::string GetOSLongName() const override;
|
||||
std::string ExtraRequestParams() const override;
|
||||
std::string GetDownloadPreference() const override;
|
||||
net::URLRequestContextGetter* RequestContext() const override;
|
||||
scoped_refptr<update_client::OutOfProcessPatcher>
|
||||
CreateOutOfProcessPatcher() const override;
|
||||
bool DeltasEnabled() const override;
|
||||
bool UseBackgroundDownloader() const override;
|
||||
bool UseCupSigning() const override;
|
||||
scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
|
||||
const override;
|
||||
PrefService* GetPrefService() const override;
|
||||
|
||||
private:
|
||||
friend class base::RefCountedThreadSafe<CefConfigurator>;
|
||||
|
||||
~CefConfigurator() override {}
|
||||
|
||||
net::URLRequestContextGetter* url_request_getter_;
|
||||
PrefService* pref_service_;
|
||||
std::string extra_info_;
|
||||
GURL url_source_override_;
|
||||
bool fast_update_;
|
||||
bool pings_enabled_;
|
||||
bool deltas_enabled_;
|
||||
bool background_downloads_enabled_;
|
||||
};
|
||||
|
||||
CefConfigurator::CefConfigurator(
|
||||
const base::CommandLine* cmdline,
|
||||
net::URLRequestContextGetter* url_request_getter,
|
||||
PrefService* pref_service)
|
||||
: url_request_getter_(url_request_getter),
|
||||
pref_service_(pref_service),
|
||||
fast_update_(false),
|
||||
pings_enabled_(false),
|
||||
deltas_enabled_(false),
|
||||
background_downloads_enabled_(false) {
|
||||
// Parse comma-delimited debug flags.
|
||||
std::vector<std::string> switch_values = base::SplitString(
|
||||
cmdline->GetSwitchValueASCII(switches::kComponentUpdater),
|
||||
",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate);
|
||||
pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings);
|
||||
deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates);
|
||||
|
||||
// TODO(dberger): Pull this (and possibly the various hard-coded
|
||||
// delay params in this file) from cef settings.
|
||||
fast_update_ = true;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
background_downloads_enabled_ =
|
||||
!HasSwitchValue(switch_values, kSwitchDisableBackgroundDownloads);
|
||||
#else
|
||||
background_downloads_enabled_ = false;
|
||||
#endif
|
||||
|
||||
const std::string switch_url_source =
|
||||
GetSwitchArgument(switch_values, kSwitchUrlSource);
|
||||
if (!switch_url_source.empty()) {
|
||||
url_source_override_ = GURL(switch_url_source);
|
||||
DCHECK(url_source_override_.is_valid());
|
||||
}
|
||||
|
||||
if (HasSwitchValue(switch_values, kSwitchRequestParam))
|
||||
extra_info_ += "testrequest=\"1\"";
|
||||
}
|
||||
|
||||
int CefConfigurator::InitialDelay() const {
|
||||
return fast_update_ ? 10 : (6 * kDelayOneMinute);
|
||||
}
|
||||
|
||||
int CefConfigurator::NextCheckDelay() const {
|
||||
return fast_update_ ? 60 : (6 * kDelayOneHour);
|
||||
}
|
||||
|
||||
int CefConfigurator::StepDelay() const {
|
||||
return fast_update_ ? 1 : 1;
|
||||
}
|
||||
|
||||
int CefConfigurator::OnDemandDelay() const {
|
||||
return fast_update_ ? 2 : (30 * kDelayOneMinute);
|
||||
}
|
||||
|
||||
int CefConfigurator::UpdateDelay() const {
|
||||
return fast_update_ ? 10 : (15 * kDelayOneMinute);
|
||||
}
|
||||
|
||||
std::vector<GURL> CefConfigurator::UpdateUrl() const {
|
||||
std::vector<GURL> urls;
|
||||
if (url_source_override_.is_valid()) {
|
||||
urls.push_back(GURL(url_source_override_));
|
||||
} else {
|
||||
urls.push_back(GURL(kUpdaterDefaultUrl));
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
std::vector<GURL> CefConfigurator::PingUrl() const {
|
||||
return pings_enabled_ ? UpdateUrl() : std::vector<GURL>();
|
||||
}
|
||||
|
||||
base::Version CefConfigurator::GetBrowserVersion() const {
|
||||
return base::Version(base::StringPrintf("%d.%d.%d.%d",
|
||||
CHROME_VERSION_MAJOR,
|
||||
CHROME_VERSION_MINOR,
|
||||
CHROME_VERSION_BUILD,
|
||||
CHROME_VERSION_PATCH));
|
||||
}
|
||||
|
||||
std::string CefConfigurator::GetChannel() const {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string CefConfigurator::GetBrand() const {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string CefConfigurator::GetLang() const {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string CefConfigurator::GetOSLongName() const {
|
||||
#if defined(OS_WIN)
|
||||
return "Windows";
|
||||
#elif defined(OS_MACOSX)
|
||||
return "Mac OS X";
|
||||
#elif defined(OS_CHROMEOS)
|
||||
return "Chromium OS";
|
||||
#elif defined(OS_ANDROID)
|
||||
return "Android";
|
||||
#elif defined(OS_LINUX)
|
||||
return "Linux";
|
||||
#elif defined(OS_FREEBSD)
|
||||
return "FreeBSD";
|
||||
#elif defined(OS_OPENBSD)
|
||||
return "OpenBSD";
|
||||
#elif defined(OS_SOLARIS)
|
||||
return "Solaris";
|
||||
#else
|
||||
return "Unknown";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string CefConfigurator::ExtraRequestParams() const {
|
||||
return extra_info_;
|
||||
}
|
||||
|
||||
std::string CefConfigurator::GetDownloadPreference() const {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* CefConfigurator::RequestContext() const {
|
||||
return url_request_getter_;
|
||||
}
|
||||
|
||||
scoped_refptr<update_client::OutOfProcessPatcher>
|
||||
CefConfigurator::CreateOutOfProcessPatcher() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CefConfigurator::DeltasEnabled() const {
|
||||
return deltas_enabled_;
|
||||
}
|
||||
|
||||
bool CefConfigurator::UseBackgroundDownloader() const {
|
||||
return background_downloads_enabled_;
|
||||
}
|
||||
|
||||
bool CefConfigurator::UseCupSigning() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
scoped_refptr<base::SequencedTaskRunner>
|
||||
CefConfigurator::GetSequencedTaskRunner() const {
|
||||
return content::BrowserThread::GetBlockingPool()
|
||||
->GetSequencedTaskRunnerWithShutdownBehavior(
|
||||
base::SequencedWorkerPool::GetSequenceToken(),
|
||||
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
|
||||
}
|
||||
|
||||
PrefService* CefConfigurator::GetPrefService() const {
|
||||
return pref_service_;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
scoped_refptr<update_client::Configurator>
|
||||
MakeCefComponentUpdaterConfigurator(
|
||||
const base::CommandLine* cmdline,
|
||||
net::URLRequestContextGetter* context_getter,
|
||||
PrefService* pref_service) {
|
||||
return new CefConfigurator(cmdline, context_getter, pref_service);
|
||||
}
|
||||
|
||||
} // namespace component_updater
|
@@ -1,31 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef LIBCEF_BROWSER_COMPONENT_UPDATER_CEF_COMPONENT_UPDATER_CONFIGURATOR_H_
|
||||
#define LIBCEF_BROWSER_COMPONENT_UPDATER_CEF_COMPONENT_UPDATER_CONFIGURATOR_H_
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "components/update_client/configurator.h"
|
||||
|
||||
namespace base {
|
||||
class CommandLine;
|
||||
}
|
||||
|
||||
namespace net {
|
||||
class URLRequestContextGetter;
|
||||
}
|
||||
|
||||
class PrefService;
|
||||
|
||||
namespace component_updater {
|
||||
|
||||
scoped_refptr<update_client::Configurator>
|
||||
MakeCefComponentUpdaterConfigurator(
|
||||
const base::CommandLine* cmdline,
|
||||
net::URLRequestContextGetter* context_getter,
|
||||
PrefService* pref_service);
|
||||
|
||||
} // namespace component_updater
|
||||
|
||||
#endif // LIBCEF_BROWSER_COMPONENT_UPDATER_CEF_COMPONENT_UPDATER_CONFIGURATOR_H_
|
@@ -27,6 +27,7 @@
|
||||
#include "libcef/browser/speech_recognition_manager_delegate.h"
|
||||
#include "libcef/browser/ssl_info_impl.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/browser/x509_certificate_impl.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/command_line_impl.h"
|
||||
@@ -46,7 +47,6 @@
|
||||
#include "content/browser/frame_host/navigation_handle_impl.h"
|
||||
#include "content/browser/frame_host/render_frame_host_impl.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"
|
||||
@@ -63,6 +63,7 @@
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/storage_quota_params.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "extensions/browser/extensions_browser_client.h"
|
||||
#include "extensions/browser/extension_message_filter.h"
|
||||
#include "extensions/browser/extension_registry.h"
|
||||
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
|
||||
@@ -75,8 +76,12 @@
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
#include "libcef/common/widevine_loader.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include "chrome/browser/spellchecker/spellcheck_message_filter_platform.h"
|
||||
#include "components/spellcheck/browser/spellcheck_message_filter_platform.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||
@@ -92,30 +97,6 @@
|
||||
|
||||
namespace {
|
||||
|
||||
// In-memory store for access tokens used by geolocation.
|
||||
class CefAccessTokenStore : public content::AccessTokenStore {
|
||||
public:
|
||||
// |system_context| is used by NetworkLocationProvider to communicate with a
|
||||
// remote geolocation service.
|
||||
explicit CefAccessTokenStore(net::URLRequestContextGetter* system_context)
|
||||
: system_context_(system_context) {}
|
||||
|
||||
void LoadAccessTokens(const LoadAccessTokensCallback& callback) override {
|
||||
callback.Run(access_token_map_, system_context_);
|
||||
}
|
||||
|
||||
void SaveAccessToken(
|
||||
const GURL& server_url, const base::string16& access_token) override {
|
||||
access_token_map_[server_url] = access_token;
|
||||
}
|
||||
|
||||
private:
|
||||
net::URLRequestContextGetter* system_context_;
|
||||
AccessTokenMap access_token_map_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefAccessTokenStore);
|
||||
};
|
||||
|
||||
class CefQuotaCallbackImpl : public CefRequestCallback {
|
||||
public:
|
||||
explicit CefQuotaCallbackImpl(
|
||||
@@ -173,7 +154,7 @@ class CefQuotaCallbackImpl : public CefRequestCallback {
|
||||
|
||||
class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
|
||||
public:
|
||||
typedef base::Callback<void(bool)> // NOLINT(readability/function)
|
||||
typedef base::Callback<void(content::CertificateRequestResultType)>
|
||||
CallbackType;
|
||||
|
||||
explicit CefAllowCertificateErrorCallbackImpl(const CallbackType& callback)
|
||||
@@ -217,7 +198,8 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
|
||||
private:
|
||||
static void RunNow(const CallbackType& callback, bool allow) {
|
||||
CEF_REQUIRE_UIT();
|
||||
callback.Run(allow);
|
||||
callback.Run(allow ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE :
|
||||
content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
|
||||
}
|
||||
|
||||
CallbackType callback_;
|
||||
@@ -226,6 +208,58 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
|
||||
DISALLOW_COPY_AND_ASSIGN(CefAllowCertificateErrorCallbackImpl);
|
||||
};
|
||||
|
||||
class CefSelectClientCertificateCallbackImpl :
|
||||
public CefSelectClientCertificateCallback {
|
||||
public:
|
||||
explicit CefSelectClientCertificateCallbackImpl(
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate)
|
||||
: delegate_(std::move(delegate)) {
|
||||
}
|
||||
|
||||
~CefSelectClientCertificateCallbackImpl() {
|
||||
// If Select has not been called, call it with NULL to continue without any
|
||||
// client certificate.
|
||||
if (delegate_)
|
||||
DoSelect(NULL);
|
||||
}
|
||||
|
||||
void Select(CefRefPtr<CefX509Certificate> cert) override {
|
||||
if (delegate_)
|
||||
DoSelect(cert);
|
||||
}
|
||||
|
||||
private:
|
||||
void DoSelect(CefRefPtr<CefX509Certificate> cert) {
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
RunNow(std::move(delegate_), cert);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefSelectClientCertificateCallbackImpl::RunNow,
|
||||
base::Passed(std::move(delegate_)), cert));
|
||||
}
|
||||
}
|
||||
|
||||
static void RunNow(
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate,
|
||||
CefRefPtr<CefX509Certificate> cert) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
scoped_refptr<net::X509Certificate> x509cert = NULL;
|
||||
if (cert) {
|
||||
CefX509CertificateImpl* certImpl =
|
||||
static_cast<CefX509CertificateImpl*>(cert.get());
|
||||
x509cert = certImpl->GetInternalCertObject();
|
||||
}
|
||||
|
||||
delegate->ContinueWithCertificate(x509cert.get());
|
||||
}
|
||||
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefSelectClientCertificateCallbackImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefSelectClientCertificateCallbackImpl);
|
||||
};
|
||||
|
||||
class CefQuotaPermissionContext : public content::QuotaPermissionContext {
|
||||
public:
|
||||
CefQuotaPermissionContext() {
|
||||
@@ -426,7 +460,7 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
|
||||
const int id = host->GetID();
|
||||
|
||||
host->GetChannel()->AddFilter(new CefBrowserMessageFilter(id));
|
||||
host->AddFilter(new printing::PrintingMessageFilter(id));
|
||||
host->AddFilter(new printing::CefPrintingMessageFilter(id));
|
||||
|
||||
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
|
||||
host->AddFilter(new SpellCheckMessageFilter(id));
|
||||
@@ -498,6 +532,62 @@ bool CefContentBrowserClient::IsHandledURL(const GURL& url) {
|
||||
return CefContentClient::Get()->HasCustomScheme(scheme);
|
||||
}
|
||||
|
||||
void CefContentBrowserClient::SiteInstanceGotProcess(
|
||||
content::SiteInstance* site_instance) {
|
||||
if (!extensions::ExtensionsEnabled())
|
||||
return;
|
||||
|
||||
// If this isn't an extension renderer there's nothing to do.
|
||||
const extensions::Extension* extension = GetExtension(site_instance);
|
||||
if (!extension)
|
||||
return;
|
||||
|
||||
CefBrowserContext* browser_context =
|
||||
static_cast<CefBrowserContext*>(site_instance->GetBrowserContext());
|
||||
|
||||
extensions::ProcessMap::Get(browser_context)
|
||||
->Insert(extension->id(),
|
||||
site_instance->GetProcess()->GetID(),
|
||||
site_instance->GetId());
|
||||
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&extensions::InfoMap::RegisterExtensionProcess,
|
||||
browser_context->extension_system()->info_map(),
|
||||
extension->id(),
|
||||
site_instance->GetProcess()->GetID(),
|
||||
site_instance->GetId()));
|
||||
}
|
||||
|
||||
void CefContentBrowserClient::SiteInstanceDeleting(
|
||||
content::SiteInstance* site_instance) {
|
||||
if (!extensions::ExtensionsEnabled())
|
||||
return;
|
||||
|
||||
// May be NULL during shutdown.
|
||||
if (!extensions::ExtensionsBrowserClient::Get())
|
||||
return;
|
||||
|
||||
// If this isn't an extension renderer there's nothing to do.
|
||||
const extensions::Extension* extension = GetExtension(site_instance);
|
||||
if (!extension)
|
||||
return;
|
||||
|
||||
CefBrowserContext* browser_context =
|
||||
static_cast<CefBrowserContext*>(site_instance->GetBrowserContext());
|
||||
|
||||
extensions::ProcessMap::Get(browser_context)
|
||||
->Remove(extension->id(),
|
||||
site_instance->GetProcess()->GetID(),
|
||||
site_instance->GetId());
|
||||
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&extensions::InfoMap::UnregisterExtensionProcess,
|
||||
browser_context->extension_system()->info_map(),
|
||||
extension->id(),
|
||||
site_instance->GetProcess()->GetID(),
|
||||
site_instance->GetId()));
|
||||
}
|
||||
|
||||
void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
base::CommandLine* command_line, int child_process_id) {
|
||||
const base::CommandLine* browser_cmd =
|
||||
@@ -541,8 +631,6 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
switches::kPpapiFlashPath,
|
||||
switches::kPpapiFlashVersion,
|
||||
switches::kUncaughtExceptionStackSize,
|
||||
switches::kWidevineCdmPath,
|
||||
switches::kWidevineCdmVersion,
|
||||
};
|
||||
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
||||
arraysize(kSwitchNames));
|
||||
@@ -564,17 +652,25 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
if (process_type == switches::kZygoteProcess) {
|
||||
// Propagate the following switches to the zygone command line (along with
|
||||
// Propagate the following switches to the zygote command line (along with
|
||||
// any associated values) if present in the browser command line.
|
||||
static const char* const kSwitchNames[] = {
|
||||
switches::kPpapiFlashPath,
|
||||
switches::kPpapiFlashVersion,
|
||||
switches::kWidevineCdmPath,
|
||||
switches::kWidevineCdmVersion,
|
||||
};
|
||||
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
||||
arraysize(kSwitchNames));
|
||||
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
|
||||
if (!browser_cmd->HasSwitch(switches::kNoSandbox)) {
|
||||
// Pass the Widevine CDM path to the Zygote process. See comments in
|
||||
// CefWidevineLoader::AddPepperPlugins.
|
||||
const base::FilePath& cdm_path = CefWidevineLoader::GetInstance()->path();
|
||||
if (!cdm_path.empty())
|
||||
command_line->AppendSwitchPath(switches::kWidevineCdmPath, cdm_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (browser_cmd->HasSwitch(switches::kBrowserSubprocessPath)) {
|
||||
// Force use of the sub-process executable path for the zygote process.
|
||||
const base::FilePath& subprocess_path =
|
||||
@@ -626,15 +722,15 @@ void CefContentBrowserClient::AllowCertificateError(
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* result) {
|
||||
const base::Callback<
|
||||
void(content::CertificateRequestResultType)>& callback) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
if (resource_type != content::ResourceType::RESOURCE_TYPE_MAIN_FRAME) {
|
||||
// A sub-resource has a certificate error. The user doesn't really
|
||||
// have a context for making the right decision, so block the request
|
||||
// hard.
|
||||
*result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
|
||||
callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -660,23 +756,49 @@ void CefContentBrowserClient::AllowCertificateError(
|
||||
if (!proceed)
|
||||
callbackImpl->Disconnect();
|
||||
|
||||
*result = proceed ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE :
|
||||
content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
|
||||
callback.Run(proceed ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE :
|
||||
content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
|
||||
}
|
||||
|
||||
void CefContentBrowserClient::SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
|
||||
if (!cert_request_info->client_certs.empty()) {
|
||||
// Use the first certificate.
|
||||
delegate->ContinueWithCertificate(cert_request_info->client_certs[0].get());
|
||||
}
|
||||
}
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
content::AccessTokenStore* CefContentBrowserClient::CreateAccessTokenStore() {
|
||||
return new CefAccessTokenStore(
|
||||
browser_main_parts_->browser_context()->request_context().get());
|
||||
CefRefPtr<CefRequestHandler> handler;
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
if (browser.get()) {
|
||||
CefRefPtr<CefClient> client = browser->GetClient();
|
||||
if (client.get())
|
||||
handler = client->GetRequestHandler();
|
||||
}
|
||||
|
||||
if (!handler.get()) {
|
||||
delegate->ContinueWithCertificate(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
CefRequestHandler::X509CertificateList certs;
|
||||
for (std::vector<scoped_refptr<net::X509Certificate> >::iterator iter =
|
||||
cert_request_info->client_certs.begin();
|
||||
iter != cert_request_info->client_certs.end(); iter++) {
|
||||
certs.push_back(new CefX509CertificateImpl(*iter));
|
||||
}
|
||||
|
||||
CefRefPtr<CefSelectClientCertificateCallbackImpl> callbackImpl(
|
||||
new CefSelectClientCertificateCallbackImpl(std::move(delegate)));
|
||||
|
||||
bool proceed = handler->OnSelectClientCertificate(
|
||||
browser.get(), cert_request_info->is_proxy,
|
||||
cert_request_info->host_and_port.host(),
|
||||
cert_request_info->host_and_port.port(),
|
||||
certs, callbackImpl.get());
|
||||
|
||||
if (!proceed && !certs.empty()) {
|
||||
callbackImpl->Select(certs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
bool CefContentBrowserClient::CanCreateWindow(
|
||||
@@ -686,6 +808,7 @@ bool CefContentBrowserClient::CanCreateWindow(
|
||||
WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
bool user_gesture,
|
||||
@@ -716,7 +839,8 @@ void CefContentBrowserClient::OverrideWebkitPrefs(
|
||||
content::WebPreferences* prefs) {
|
||||
renderer_prefs::PopulateWebPreferences(rvh, *prefs);
|
||||
|
||||
if (rvh->GetWidget()->GetView()) {
|
||||
if (rvh->GetWidget()->GetView() &&
|
||||
rvh->GetWidget()->GetView()->GetNativeView()) {
|
||||
rvh->GetWidget()->GetView()->SetBackgroundColor(
|
||||
prefs->base_background_color);
|
||||
}
|
||||
@@ -823,12 +947,7 @@ const wchar_t* CefContentBrowserClient::GetResourceDllName() {
|
||||
|
||||
bool CefContentBrowserClient::PreSpawnRenderer(
|
||||
sandbox::TargetPolicy* policy) {
|
||||
// Flash requires this permission to play video files.
|
||||
sandbox::ResultCode result = policy->AddRule(
|
||||
sandbox::TargetPolicy::SUBSYS_HANDLES,
|
||||
sandbox::TargetPolicy::HANDLES_DUP_ANY,
|
||||
L"File");
|
||||
return result == sandbox::SBOX_ALL_OK;
|
||||
return true;
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
@@ -850,3 +969,11 @@ CefContentBrowserClient::browser_context() const {
|
||||
CefDevToolsDelegate* CefContentBrowserClient::devtools_delegate() const {
|
||||
return browser_main_parts_->devtools_delegate();
|
||||
}
|
||||
|
||||
const extensions::Extension* CefContentBrowserClient::GetExtension(
|
||||
content::SiteInstance* site_instance) {
|
||||
extensions::ExtensionRegistry* registry =
|
||||
extensions::ExtensionRegistry::Get(site_instance->GetBrowserContext());
|
||||
return registry->enabled_extensions().GetExtensionOrAppByURL(
|
||||
site_instance->GetSiteURL());
|
||||
}
|
||||
|
@@ -44,6 +44,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
|
||||
const GURL& effective_url) override;
|
||||
bool IsHandledURL(const GURL& url) override;
|
||||
void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
|
||||
void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
|
||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
||||
int child_process_id) override;
|
||||
content::QuotaPermissionContext*
|
||||
@@ -60,19 +62,19 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* result) override;
|
||||
const base::Callback<
|
||||
void(content::CertificateRequestResultType)>& callback) override;
|
||||
void SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
content::AccessTokenStore* CreateAccessTokenStore() override;
|
||||
bool CanCreateWindow(const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
bool user_gesture,
|
||||
@@ -113,6 +115,10 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
CefDevToolsDelegate* devtools_delegate() const;
|
||||
|
||||
private:
|
||||
// Returns the extension or app associated with |site_instance| or NULL.
|
||||
const extensions::Extension* GetExtension(
|
||||
content::SiteInstance* site_instance);
|
||||
|
||||
CefBrowserMainParts* browser_main_parts_;
|
||||
|
||||
std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_;
|
||||
|
@@ -3,19 +3,17 @@
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_main.h"
|
||||
#include "libcef/browser/browser_message_loop.h"
|
||||
#include "libcef/browser/chrome_browser_process_stub.h"
|
||||
#include "libcef/browser/component_updater/cef_component_updater_configurator.h"
|
||||
#include "libcef/browser/content_browser_client.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/browser/trace_subscriber.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/main_delegate.h"
|
||||
#include "libcef/common/widevine_loader.h"
|
||||
#include "libcef/renderer/content_renderer_client.h"
|
||||
|
||||
#include "base/base_switches.h"
|
||||
@@ -24,11 +22,6 @@
|
||||
#include "base/debug/debugger.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
|
||||
#include "chrome/browser/printing/print_job_manager.h"
|
||||
#include "components/component_updater/component_updater_service.h"
|
||||
#include "components/update_client/configurator.h"
|
||||
#include "content/public/app/content_main.h"
|
||||
#include "content/public/app/content_main_runner.h"
|
||||
#include "content/public/browser/notification_service.h"
|
||||
@@ -326,7 +319,9 @@ void CefContext::Shutdown() {
|
||||
if (settings_.multi_threaded_message_loop) {
|
||||
// Events that will be used to signal when shutdown is complete. Start in
|
||||
// non-signaled mode so that the event will block.
|
||||
base::WaitableEvent uithread_shutdown_event(false, false);
|
||||
base::WaitableEvent uithread_shutdown_event(
|
||||
base::WaitableEvent::ResetPolicy::AUTOMATIC,
|
||||
base::WaitableEvent::InitialState::NOT_SIGNALED);
|
||||
|
||||
// Finish shutdown on the UI thread.
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
@@ -359,25 +354,6 @@ CefTraceSubscriber* CefContext::GetTraceSubscriber() {
|
||||
return trace_subscriber_.get();
|
||||
}
|
||||
|
||||
component_updater::ComponentUpdateService*
|
||||
CefContext::component_updater() {
|
||||
if (!component_updater_.get()) {
|
||||
CEF_REQUIRE_UIT_RETURN(NULL);
|
||||
scoped_refptr<CefBrowserContextImpl> browser_context =
|
||||
CefContentBrowserClient::Get()->browser_context();
|
||||
scoped_refptr<update_client::Configurator> configurator =
|
||||
component_updater::MakeCefComponentUpdaterConfigurator(
|
||||
base::CommandLine::ForCurrentProcess(),
|
||||
browser_context->request_context().get(),
|
||||
browser_context->GetPrefs());
|
||||
// Creating the component updater does not do anything, components
|
||||
// need to be registered and Start() needs to be called.
|
||||
component_updater_.reset(component_updater::ComponentUpdateServiceFactory(
|
||||
configurator).release());
|
||||
}
|
||||
return component_updater_.get();
|
||||
}
|
||||
|
||||
void CefContext::PopulateRequestContextSettings(
|
||||
CefRequestContextSettings* settings) {
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
@@ -392,34 +368,21 @@ void CefContext::PopulateRequestContextSettings(
|
||||
settings->ignore_certificate_errors =
|
||||
settings_.ignore_certificate_errors ||
|
||||
command_line->HasSwitch(switches::kIgnoreCertificateErrors);
|
||||
settings->enable_net_security_expiration =
|
||||
settings_.enable_net_security_expiration ||
|
||||
command_line->HasSwitch(switches::kEnableNetSecurityExpiration);
|
||||
CefString(&settings->accept_language_list) =
|
||||
CefString(&settings_.accept_language_list);
|
||||
}
|
||||
|
||||
void RegisterComponentsForUpdate() {
|
||||
component_updater::ComponentUpdateService* cus =
|
||||
CefContext::Get()->component_updater();
|
||||
|
||||
// Registration can be before or after cus->Start() so it is ok to post
|
||||
// a task to the UI thread to do registration once you done the necessary
|
||||
// file IO to know you existing component version.
|
||||
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kEnableWidevineCdm)) {
|
||||
RegisterWidevineCdmComponent(cus);
|
||||
}
|
||||
#endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
|
||||
}
|
||||
|
||||
void CefContext::OnContextInitialized() {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// Must be created after the NotificationService.
|
||||
print_job_manager_.reset(new printing::PrintJobManager());
|
||||
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Initialize();
|
||||
|
||||
bool io_was_allowed = base::ThreadRestrictions::SetIOAllowed(true);
|
||||
RegisterComponentsForUpdate();
|
||||
base::ThreadRestrictions::SetIOAllowed(io_was_allowed);
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
|
||||
CefWidevineLoader::GetInstance()->OnContextInitialized();
|
||||
#endif
|
||||
|
||||
// Notify the handler.
|
||||
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
|
||||
@@ -435,19 +398,12 @@ void CefContext::FinishShutdownOnUIThread(
|
||||
base::WaitableEvent* uithread_shutdown_event) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// Wait for the pending print jobs to finish. Don't do this later, since
|
||||
// this might cause a nested message loop to run, and we don't want pending
|
||||
// tasks to run once teardown has started.
|
||||
print_job_manager_->Shutdown();
|
||||
print_job_manager_.reset(NULL);
|
||||
|
||||
browser_info_manager_->DestroyAllBrowsers();
|
||||
|
||||
if (trace_subscriber_.get())
|
||||
trace_subscriber_.reset(NULL);
|
||||
|
||||
if (component_updater_.get())
|
||||
component_updater_.reset(NULL);
|
||||
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Shutdown();
|
||||
|
||||
if (uithread_shutdown_event)
|
||||
uithread_shutdown_event->Signal();
|
||||
|
@@ -18,18 +18,10 @@ namespace base {
|
||||
class WaitableEvent;
|
||||
}
|
||||
|
||||
namespace component_updater {
|
||||
class ComponentUpdateService;
|
||||
}
|
||||
|
||||
namespace content {
|
||||
class ContentMainRunner;
|
||||
}
|
||||
|
||||
namespace printing {
|
||||
class PrintJobManager;
|
||||
}
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class CefBrowserInfoManager;
|
||||
class CefMainDelegate;
|
||||
@@ -63,12 +55,6 @@ class CefContext {
|
||||
|
||||
const CefSettings& settings() const { return settings_; }
|
||||
|
||||
printing::PrintJobManager* print_job_manager() const {
|
||||
return print_job_manager_.get();
|
||||
}
|
||||
|
||||
component_updater::ComponentUpdateService* component_updater();
|
||||
|
||||
CefTraceSubscriber* GetTraceSubscriber();
|
||||
|
||||
// Populate the request context settings based on CefSettings and command-
|
||||
@@ -98,12 +84,6 @@ class CefContext {
|
||||
std::unique_ptr<content::ContentMainRunner> main_runner_;
|
||||
std::unique_ptr<CefTraceSubscriber> trace_subscriber_;
|
||||
std::unique_ptr<CefBrowserInfoManager> browser_info_manager_;
|
||||
|
||||
// Only accessed on the UI Thread.
|
||||
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
|
||||
|
||||
// Initially only for Widevine components.
|
||||
std::unique_ptr<component_updater::ComponentUpdateService> component_updater_;
|
||||
};
|
||||
|
||||
// Helper macro that returns true if the global context is in a valid state.
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "base/format_macros.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "content/browser/storage_partition_impl.h"
|
||||
#include "net/cookies/cookie_util.h"
|
||||
#include "net/cookies/parsed_cookie.h"
|
||||
#include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
|
||||
@@ -139,7 +140,7 @@ void CefCookieManagerImpl::Initialize(
|
||||
if (request_context.get()) {
|
||||
request_context_ = request_context;
|
||||
request_context_->GetRequestContextImpl(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::InitWithContext, this, callback));
|
||||
} else {
|
||||
SetStoragePath(path, persist_session_cookies, callback);
|
||||
@@ -225,7 +226,7 @@ void CefCookieManagerImpl::SetSupportedSchemes(
|
||||
bool CefCookieManagerImpl::VisitAllCookies(
|
||||
CefRefPtr<CefCookieVisitor> visitor) {
|
||||
GetCookieStore(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::VisitAllCookiesInternal, this,
|
||||
visitor));
|
||||
return true;
|
||||
@@ -236,7 +237,7 @@ bool CefCookieManagerImpl::VisitUrlCookies(
|
||||
bool includeHttpOnly,
|
||||
CefRefPtr<CefCookieVisitor> visitor) {
|
||||
GetCookieStore(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::VisitUrlCookiesInternal, this, url,
|
||||
includeHttpOnly, visitor));
|
||||
return true;
|
||||
@@ -251,7 +252,7 @@ bool CefCookieManagerImpl::SetCookie(
|
||||
return false;
|
||||
|
||||
GetCookieStore(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::SetCookieInternal, this, gurl, cookie,
|
||||
callback));
|
||||
return true;
|
||||
@@ -267,7 +268,7 @@ bool CefCookieManagerImpl::DeleteCookies(
|
||||
return false;
|
||||
|
||||
GetCookieStore(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::DeleteCookiesInternal, this, gurl,
|
||||
cookie_name, callback));
|
||||
return true;
|
||||
@@ -313,8 +314,8 @@ bool CefCookieManagerImpl::SetStoragePath(
|
||||
persistent_store =
|
||||
new net::SQLitePersistentCookieStore(
|
||||
cookie_path,
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::DB),
|
||||
persist_session_cookies,
|
||||
NULL);
|
||||
} else {
|
||||
@@ -340,7 +341,7 @@ bool CefCookieManagerImpl::SetStoragePath(
|
||||
bool CefCookieManagerImpl::FlushStore(
|
||||
CefRefPtr<CefCompletionCallback> callback) {
|
||||
GetCookieStore(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::FlushStoreInternal, this, callback));
|
||||
return true;
|
||||
}
|
||||
@@ -426,7 +427,7 @@ void CefCookieManagerImpl::RunMethodWithContext(
|
||||
} else if (request_context_.get()) {
|
||||
// Try again after the request context is initialized.
|
||||
request_context_->GetRequestContextImpl(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
method);
|
||||
} else {
|
||||
NOTREACHED();
|
||||
@@ -608,8 +609,9 @@ void CefCookieManagerImpl::DeleteCookiesInternal(
|
||||
base::Bind(DeleteCookiesCallbackImpl, callback));
|
||||
} else if (cookie_name.empty()) {
|
||||
// Delete all matching host cookies.
|
||||
cookie_store->DeleteAllCreatedBetweenForHostAsync(
|
||||
base::Time(), base::Time::Max(), url,
|
||||
cookie_store->DeleteAllCreatedBetweenWithPredicateAsync(
|
||||
base::Time(), base::Time::Max(),
|
||||
content::StoragePartitionImpl::CreatePredicateForHostCookies(url),
|
||||
base::Bind(DeleteCookiesCallbackImpl, callback));
|
||||
} else {
|
||||
// Delete all matching host and domain cookies.
|
||||
|
@@ -16,10 +16,11 @@
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
#include "base/time/time.h"
|
||||
#include "cef/grit/cef_resources.h"
|
||||
#include "components/devtools_discovery/basic_target_descriptor.h"
|
||||
#include "components/devtools_discovery/devtools_discovery_manager.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
#include "content/public/browser/devtools_frontend_host.h"
|
||||
#include "content/public/browser/favicon_status.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
@@ -29,7 +30,6 @@
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "grit/cef_resources.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/socket/tcp_server_socket.h"
|
||||
#include "ui/base/layout.h"
|
||||
@@ -132,6 +132,9 @@ CefDevToolsManagerDelegate::~CefDevToolsManagerDelegate() {
|
||||
|
||||
base::DictionaryValue* CefDevToolsManagerDelegate::HandleCommand(
|
||||
content::DevToolsAgentHost* agent_host,
|
||||
base::DictionaryValue* command) {
|
||||
return NULL;
|
||||
base::DictionaryValue* command_dict) {
|
||||
std::unique_ptr<base::DictionaryValue> result =
|
||||
devtools_discovery::DevToolsDiscoveryManager::GetInstance()
|
||||
->HandleCreateTargetCommand(command_dict);
|
||||
return result.release(); // Caller takes ownership.
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/json/json_reader.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/json/string_escape.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@@ -19,6 +21,7 @@
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
#include "ipc/ipc_channel.h"
|
||||
@@ -144,7 +147,7 @@ void CefDevToolsFrontend::InspectElementAt(int x, int y) {
|
||||
if (inspect_element_at_.x != x || inspect_element_at_.y != y)
|
||||
inspect_element_at_.Set(x, y);
|
||||
if (agent_host_)
|
||||
agent_host_->InspectElement(x, y);
|
||||
agent_host_->InspectElement(this, x, y);
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::Close() {
|
||||
@@ -156,7 +159,7 @@ void CefDevToolsFrontend::Close() {
|
||||
void CefDevToolsFrontend::DisconnectFromTarget() {
|
||||
if (!agent_host_)
|
||||
return;
|
||||
agent_host_->DetachClient();
|
||||
agent_host_->DetachClient(this);
|
||||
agent_host_ = NULL;
|
||||
}
|
||||
|
||||
@@ -204,7 +207,7 @@ void CefDevToolsFrontend::DocumentAvailableInMainFrame() {
|
||||
|
||||
void CefDevToolsFrontend::WebContentsDestroyed() {
|
||||
if (agent_host_)
|
||||
agent_host_->DetachClient();
|
||||
agent_host_->DetachClient(this);
|
||||
delete this;
|
||||
}
|
||||
|
||||
@@ -226,11 +229,12 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
dict->GetList("params", ¶ms);
|
||||
|
||||
if (method == "dispatchProtocolMessage" && params && params->GetSize() == 1) {
|
||||
if (!agent_host_ || !agent_host_->IsAttached())
|
||||
return;
|
||||
std::string protocol_message;
|
||||
if (!params->GetString(0, &protocol_message))
|
||||
return;
|
||||
if (agent_host_)
|
||||
agent_host_->DispatchProtocolMessage(protocol_message);
|
||||
agent_host_->DispatchProtocolMessage(this, protocol_message);
|
||||
} else if (method == "loadCompleted") {
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
|
||||
base::ASCIIToUTF16("DevToolsAPI.setUseSoftMenu(true);"));
|
||||
@@ -256,10 +260,12 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
net::URLFetcher* fetcher =
|
||||
net::URLFetcher::Create(gurl, net::URLFetcher::GET, this).release();
|
||||
pending_requests_[fetcher] = request_id;
|
||||
fetcher->SetRequestContext(web_contents()->GetBrowserContext()->
|
||||
GetRequestContext());
|
||||
fetcher->SetRequestContext(
|
||||
content::BrowserContext::GetDefaultStoragePartition(
|
||||
web_contents()->GetBrowserContext())->
|
||||
GetURLRequestContext());
|
||||
fetcher->SetExtraRequestHeaders(headers);
|
||||
fetcher->SaveResponseWithWriter(std::unique_ptr<net::URLFetcherResponseWriter>(
|
||||
fetcher->SaveResponseWithWriter(base::WrapUnique(
|
||||
new ResponseWriter(weak_factory_.GetWeakPtr(), stream_id)));
|
||||
fetcher->Start();
|
||||
return;
|
||||
@@ -294,23 +300,41 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
|
||||
content::DevToolsAgentHost* agent_host,
|
||||
const std::string& message) {
|
||||
if (message.length() < kMaxMessageChunkSize) {
|
||||
base::string16 javascript = base::UTF8ToUTF16(
|
||||
"DevToolsAPI.dispatchMessage(" + message + ");");
|
||||
std::string param;
|
||||
base::EscapeJSONString(message, true, ¶m);
|
||||
std::string code = "DevToolsAPI.dispatchMessage(" + param + ");";
|
||||
base::string16 javascript = base::UTF8ToUTF16(code);
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
|
||||
return;
|
||||
}
|
||||
|
||||
base::FundamentalValue total_size(static_cast<int>(message.length()));
|
||||
size_t total_size = message.length();
|
||||
for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
|
||||
std::string param;
|
||||
base::JSONWriter::Write(
|
||||
base::StringValue(message.substr(pos, kMaxMessageChunkSize)), ¶m);
|
||||
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");";
|
||||
base::EscapeJSONString(message.substr(pos, kMaxMessageChunkSize), true,
|
||||
¶m);
|
||||
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," +
|
||||
std::to_string(pos ? 0 : total_size) + ");";
|
||||
base::string16 javascript = base::UTF8ToUTF16(code);
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
|
||||
}
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::SetPreferences(const std::string& json) {
|
||||
preferences_.Clear();
|
||||
if (json.empty())
|
||||
return;
|
||||
base::DictionaryValue* dict = nullptr;
|
||||
std::unique_ptr<base::Value> parsed = base::JSONReader::Read(json);
|
||||
if (!parsed || !parsed->GetAsDictionary(&dict))
|
||||
return;
|
||||
for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
|
||||
if (!it.value().IsType(base::Value::TYPE_STRING))
|
||||
continue;
|
||||
preferences_.SetWithoutPathExpansion(it.key(), it.value().CreateDeepCopy());
|
||||
}
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
// TODO(pfeldman): this is a copy of chrome's devtools_ui_bindings.cc.
|
||||
// We should handle some of the commands including this one in content.
|
||||
|
@@ -62,7 +62,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
|
||||
bool replaced) override;
|
||||
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
|
||||
const std::string& message) override;
|
||||
base::DictionaryValue* preferences() { return &preferences_; }
|
||||
void SetPreferences(const std::string& json);
|
||||
|
||||
// WebContentsObserver overrides
|
||||
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||
|
@@ -1,21 +0,0 @@
|
||||
# Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'cef_api_registration',
|
||||
'type': 'static_library',
|
||||
# TODO(jschuh): http://crbug.com/167187 size_t -> int
|
||||
'msvs_disabled_warnings': [ 4267 ],
|
||||
'includes': [
|
||||
'../../../../../build/json_schema_bundle_registration_compile.gypi',
|
||||
'../../../common/extensions/api/schemas.gypi',
|
||||
],
|
||||
'dependencies': [
|
||||
'../../../common/extensions/api/api.gyp:cef_api',
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
@@ -1,179 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/extensions/api/streams_private/streams_private_api.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <utility>
|
||||
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/values.h"
|
||||
#include "cef/libcef/common/extensions/api/streams_private.h"
|
||||
#include "content/public/browser/stream_handle.h"
|
||||
#include "content/public/browser/stream_info.h"
|
||||
#include "extensions/browser/event_router.h"
|
||||
#include "extensions/browser/extension_function_registry.h"
|
||||
#include "extensions/browser/extension_registry.h"
|
||||
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.h"
|
||||
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
|
||||
#include "extensions/common/manifest_handlers/mime_types_handler.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
|
||||
namespace extensions {
|
||||
namespace {
|
||||
|
||||
void CreateResponseHeadersDictionary(const net::HttpResponseHeaders* headers,
|
||||
base::DictionaryValue* result) {
|
||||
if (!headers)
|
||||
return;
|
||||
|
||||
size_t iter = 0;
|
||||
std::string header_name;
|
||||
std::string header_value;
|
||||
while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) {
|
||||
base::Value* existing_value = NULL;
|
||||
if (result->Get(header_name, &existing_value)) {
|
||||
base::StringValue* existing_string_value =
|
||||
static_cast<base::StringValue*>(existing_value);
|
||||
existing_string_value->GetString()->append(", ").append(header_value);
|
||||
} else {
|
||||
result->SetString(header_name, header_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace streams_private = api::streams_private;
|
||||
|
||||
// static
|
||||
StreamsPrivateAPI* StreamsPrivateAPI::Get(content::BrowserContext* context) {
|
||||
return GetFactoryInstance()->Get(context);
|
||||
}
|
||||
|
||||
StreamsPrivateAPI::StreamsPrivateAPI(content::BrowserContext* context)
|
||||
: browser_context_(context),
|
||||
extension_registry_observer_(this),
|
||||
weak_ptr_factory_(this) {
|
||||
extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_));
|
||||
}
|
||||
|
||||
StreamsPrivateAPI::~StreamsPrivateAPI() {
|
||||
}
|
||||
|
||||
void StreamsPrivateAPI::ExecuteMimeTypeHandler(
|
||||
const std::string& extension_id,
|
||||
int tab_id,
|
||||
std::unique_ptr<content::StreamInfo> stream,
|
||||
const std::string& view_id,
|
||||
int64_t expected_content_size,
|
||||
bool embedded,
|
||||
int render_process_id,
|
||||
int render_frame_id) {
|
||||
const Extension* extension = ExtensionRegistry::Get(browser_context_)
|
||||
->enabled_extensions()
|
||||
.GetByID(extension_id);
|
||||
if (!extension)
|
||||
return;
|
||||
|
||||
MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
|
||||
// If the mime handler uses MimeHandlerViewGuest, the MimeHandlerViewGuest
|
||||
// will take ownership of the stream. Otherwise, store the stream handle in
|
||||
// |streams_| and fire an event notifying the extension.
|
||||
if (handler->HasPlugin()) {
|
||||
GURL handler_url(Extension::GetBaseURLFromExtensionId(extension_id).spec() +
|
||||
handler->handler_url());
|
||||
std::unique_ptr<StreamContainer> stream_container(new StreamContainer(
|
||||
std::move(stream), tab_id, embedded, handler_url, extension_id));
|
||||
MimeHandlerStreamManager::Get(browser_context_)
|
||||
->AddStream(view_id, std::move(stream_container), render_process_id,
|
||||
render_frame_id);
|
||||
return;
|
||||
}
|
||||
// Create the event's arguments value.
|
||||
streams_private::StreamInfo info;
|
||||
info.mime_type = stream->mime_type;
|
||||
info.original_url = stream->original_url.spec();
|
||||
info.stream_url = stream->handle->GetURL().spec();
|
||||
info.tab_id = tab_id;
|
||||
info.embedded = embedded;
|
||||
|
||||
if (!view_id.empty()) {
|
||||
info.view_id.reset(new std::string(view_id));
|
||||
}
|
||||
|
||||
int size = -1;
|
||||
if (expected_content_size <= INT_MAX)
|
||||
size = expected_content_size;
|
||||
info.expected_content_size = size;
|
||||
|
||||
CreateResponseHeadersDictionary(stream->response_headers.get(),
|
||||
&info.response_headers.additional_properties);
|
||||
|
||||
std::unique_ptr<Event> event(
|
||||
new Event(events::STREAMS_PRIVATE_ON_EXECUTE_MIME_TYPE_HANDLER,
|
||||
streams_private::OnExecuteMimeTypeHandler::kEventName,
|
||||
streams_private::OnExecuteMimeTypeHandler::Create(info)));
|
||||
|
||||
EventRouter::Get(browser_context_)
|
||||
->DispatchEventToExtension(extension_id, std::move(event));
|
||||
|
||||
GURL url = stream->handle->GetURL();
|
||||
streams_[extension_id][url] = make_linked_ptr(stream->handle.release());
|
||||
}
|
||||
|
||||
void StreamsPrivateAPI::AbortStream(const std::string& extension_id,
|
||||
const GURL& stream_url,
|
||||
const base::Closure& callback) {
|
||||
StreamMap::iterator extension_it = streams_.find(extension_id);
|
||||
if (extension_it == streams_.end()) {
|
||||
callback.Run();
|
||||
return;
|
||||
}
|
||||
|
||||
StreamMap::mapped_type* url_map = &extension_it->second;
|
||||
StreamMap::mapped_type::iterator url_it = url_map->find(stream_url);
|
||||
if (url_it == url_map->end()) {
|
||||
callback.Run();
|
||||
return;
|
||||
}
|
||||
|
||||
url_it->second->AddCloseListener(callback);
|
||||
url_map->erase(url_it);
|
||||
}
|
||||
|
||||
void StreamsPrivateAPI::OnExtensionUnloaded(
|
||||
content::BrowserContext* browser_context,
|
||||
const Extension* extension,
|
||||
UnloadedExtensionInfo::Reason reason) {
|
||||
streams_.erase(extension->id());
|
||||
}
|
||||
|
||||
StreamsPrivateAbortFunction::StreamsPrivateAbortFunction() {
|
||||
}
|
||||
|
||||
ExtensionFunction::ResponseAction StreamsPrivateAbortFunction::Run() {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &stream_url_));
|
||||
StreamsPrivateAPI::Get(browser_context())->AbortStream(
|
||||
extension_id(), GURL(stream_url_), base::Bind(
|
||||
&StreamsPrivateAbortFunction::OnClose, this));
|
||||
return RespondLater();
|
||||
}
|
||||
|
||||
void StreamsPrivateAbortFunction::OnClose() {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
Respond(NoArguments());
|
||||
}
|
||||
|
||||
static base::LazyInstance<BrowserContextKeyedAPIFactory<StreamsPrivateAPI> >
|
||||
g_factory = LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
// static
|
||||
BrowserContextKeyedAPIFactory<StreamsPrivateAPI>*
|
||||
StreamsPrivateAPI::GetFactoryInstance() {
|
||||
return g_factory.Pointer();
|
||||
}
|
||||
|
||||
} // namespace extensions
|
@@ -1,106 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_
|
||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "base/scoped_observer.h"
|
||||
#include "extensions/browser/browser_context_keyed_api_factory.h"
|
||||
#include "extensions/browser/extension_function.h"
|
||||
#include "extensions/browser/extension_registry_observer.h"
|
||||
|
||||
namespace content {
|
||||
class BrowserContext;
|
||||
class StreamHandle;
|
||||
struct StreamInfo;
|
||||
}
|
||||
|
||||
namespace extensions {
|
||||
class ExtensionRegistry;
|
||||
|
||||
class StreamsPrivateAPI : public BrowserContextKeyedAPI,
|
||||
public ExtensionRegistryObserver {
|
||||
public:
|
||||
// Convenience method to get the StreamsPrivateAPI for a BrowserContext.
|
||||
static StreamsPrivateAPI* Get(content::BrowserContext* context);
|
||||
|
||||
explicit StreamsPrivateAPI(content::BrowserContext* context);
|
||||
~StreamsPrivateAPI() override;
|
||||
|
||||
// Send the onExecuteMimeTypeHandler event to |extension_id|.
|
||||
// |tab_id| is used to determine the tabId where the document is being
|
||||
// opened. The data for the document will be readable from |stream|, and
|
||||
// should be |expected_content_size| bytes long. If the viewer is being opened
|
||||
// in a BrowserPlugin, specify a non-empty |view_id| of the plugin. |embedded|
|
||||
// should be set to whether the document is embedded within another document.
|
||||
void ExecuteMimeTypeHandler(const std::string& extension_id,
|
||||
int tab_id,
|
||||
std::unique_ptr<content::StreamInfo> stream,
|
||||
const std::string& view_id,
|
||||
int64_t expected_content_size,
|
||||
bool embedded,
|
||||
int render_process_id,
|
||||
int render_frame_id);
|
||||
|
||||
void AbortStream(const std::string& extension_id,
|
||||
const GURL& stream_url,
|
||||
const base::Closure& callback);
|
||||
|
||||
// BrowserContextKeyedAPI implementation.
|
||||
static BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance();
|
||||
|
||||
private:
|
||||
friend class BrowserContextKeyedAPIFactory<StreamsPrivateAPI>;
|
||||
typedef std::map<std::string,
|
||||
std::map<GURL,
|
||||
linked_ptr<content::StreamHandle> > > StreamMap;
|
||||
|
||||
// ExtensionRegistryObserver implementation.
|
||||
void OnExtensionUnloaded(content::BrowserContext* browser_context,
|
||||
const Extension* extension,
|
||||
UnloadedExtensionInfo::Reason reason) override;
|
||||
|
||||
// BrowserContextKeyedAPI implementation.
|
||||
static const char* service_name() {
|
||||
return "StreamsPrivateAPI";
|
||||
}
|
||||
static const bool kServiceIsNULLWhileTesting = true;
|
||||
static const bool kServiceRedirectedInIncognito = true;
|
||||
|
||||
content::BrowserContext* const browser_context_;
|
||||
StreamMap streams_;
|
||||
|
||||
// Listen to extension unloaded notifications.
|
||||
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
|
||||
extension_registry_observer_;
|
||||
|
||||
base::WeakPtrFactory<StreamsPrivateAPI> weak_ptr_factory_;
|
||||
|
||||
};
|
||||
|
||||
class StreamsPrivateAbortFunction : public UIThreadExtensionFunction {
|
||||
public:
|
||||
StreamsPrivateAbortFunction();
|
||||
DECLARE_EXTENSION_FUNCTION("streamsPrivate.abort", STREAMSPRIVATE_ABORT)
|
||||
|
||||
protected:
|
||||
~StreamsPrivateAbortFunction() override {}
|
||||
|
||||
// ExtensionFunction:
|
||||
ExtensionFunction::ResponseAction Run() override;
|
||||
|
||||
private:
|
||||
void OnClose();
|
||||
|
||||
std::string stream_url_;
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_
|
271
libcef/browser/extensions/api/tabs/tabs_api.cc
Normal file
271
libcef/browser/extensions/api/tabs/tabs_api.cc
Normal file
@@ -0,0 +1,271 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/extensions/api/tabs/tabs_api.h"
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/sessions/session_tab_helper.h"
|
||||
#include "components/zoom/zoom_controller.h"
|
||||
#include "content/public/common/page_zoom.h"
|
||||
#include "extensions/browser/extension_zoom_request_client.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "extensions/common/permissions/permissions_data.h"
|
||||
|
||||
namespace extensions {
|
||||
namespace cef {
|
||||
|
||||
namespace keys = extensions::tabs_constants;
|
||||
namespace tabs = api::tabs;
|
||||
|
||||
namespace {
|
||||
|
||||
// Any out parameter (|browser|, |contents|, & |tab_index|) may be NULL and will
|
||||
// not be set within the function.
|
||||
// Based on ExtensionTabUtil::GetTabById().
|
||||
bool GetTabById(int tab_id,
|
||||
content::BrowserContext* browser_context,
|
||||
bool include_incognito,
|
||||
CefRefPtr<CefBrowserHostImpl>* browser,
|
||||
content::WebContents** contents) {
|
||||
if (tab_id == api::tabs::TAB_ID_NONE)
|
||||
return false;
|
||||
|
||||
// As an extra security check make sure we're operating in the same
|
||||
// BrowserContext.
|
||||
Profile* profile = Profile::FromBrowserContext(browser_context);
|
||||
Profile* incognito_profile =
|
||||
include_incognito && profile->HasOffTheRecordProfile() ?
|
||||
profile->GetOffTheRecordProfile() : NULL;
|
||||
|
||||
CefBrowserInfoManager::BrowserInfoList list;
|
||||
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList(list);
|
||||
for (auto browser_info : list) {
|
||||
CefRefPtr<CefBrowserHostImpl> cef_browser = browser_info->browser();
|
||||
if (!cef_browser)
|
||||
continue;
|
||||
CefRefPtr<CefRequestContext> request_context =
|
||||
cef_browser->GetRequestContext();
|
||||
if (!request_context)
|
||||
continue;
|
||||
CefRefPtr<CefRequestContextImpl> request_context_impl =
|
||||
CefRequestContextImpl::GetForRequestContext(request_context);
|
||||
if (!request_context_impl)
|
||||
continue;
|
||||
scoped_refptr<CefBrowserContext> browser_context =
|
||||
request_context_impl->GetBrowserContext();
|
||||
if (!browser_context)
|
||||
continue;
|
||||
|
||||
if (browser_context == profile ||
|
||||
browser_context == incognito_profile) {
|
||||
content::WebContents* web_contents = cef_browser->web_contents();
|
||||
if (SessionTabHelper::IdForTab(web_contents) == tab_id) {
|
||||
if (browser)
|
||||
*browser = cef_browser;
|
||||
if (contents)
|
||||
*contents = web_contents;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// |error_message| can optionally be passed in and will be set with an
|
||||
// appropriate message if the tab cannot be found by id.
|
||||
bool GetTabById(int tab_id,
|
||||
content::BrowserContext* browser_context,
|
||||
bool include_incognito,
|
||||
CefRefPtr<CefBrowserHostImpl>* browser,
|
||||
content::WebContents** contents,
|
||||
std::string* error_message) {
|
||||
if (GetTabById(tab_id, browser_context, include_incognito, browser,
|
||||
contents)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (error_message) {
|
||||
*error_message = ErrorUtils::FormatErrorMessage(
|
||||
keys::kTabNotFoundError, base::IntToString(tab_id));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ZoomModeToZoomSettings(zoom::ZoomController::ZoomMode zoom_mode,
|
||||
api::tabs::ZoomSettings* zoom_settings) {
|
||||
DCHECK(zoom_settings);
|
||||
switch (zoom_mode) {
|
||||
case zoom::ZoomController::ZOOM_MODE_DEFAULT:
|
||||
zoom_settings->mode = api::tabs::ZOOM_SETTINGS_MODE_AUTOMATIC;
|
||||
zoom_settings->scope = api::tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN;
|
||||
break;
|
||||
case zoom::ZoomController::ZOOM_MODE_ISOLATED:
|
||||
zoom_settings->mode = api::tabs::ZOOM_SETTINGS_MODE_AUTOMATIC;
|
||||
zoom_settings->scope = api::tabs::ZOOM_SETTINGS_SCOPE_PER_TAB;
|
||||
break;
|
||||
case zoom::ZoomController::ZOOM_MODE_MANUAL:
|
||||
zoom_settings->mode = api::tabs::ZOOM_SETTINGS_MODE_MANUAL;
|
||||
zoom_settings->scope = api::tabs::ZOOM_SETTINGS_SCOPE_PER_TAB;
|
||||
break;
|
||||
case zoom::ZoomController::ZOOM_MODE_DISABLED:
|
||||
zoom_settings->mode = api::tabs::ZOOM_SETTINGS_MODE_DISABLED;
|
||||
zoom_settings->scope = api::tabs::ZOOM_SETTINGS_SCOPE_PER_TAB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
content::WebContents* ZoomAPIFunction::GetWebContents(int tab_id) {
|
||||
content::WebContents* web_contents = NULL;
|
||||
if (tab_id != -1) {
|
||||
// We assume this call leaves web_contents unchanged if it is unsuccessful.
|
||||
GetTabById(tab_id,
|
||||
context_,
|
||||
include_incognito(),
|
||||
NULL /* ignore CefBrowserHostImpl* output */,
|
||||
&web_contents,
|
||||
&error_);
|
||||
} else {
|
||||
// Use the sender as the default.
|
||||
web_contents = GetSenderWebContents();
|
||||
}
|
||||
return web_contents;
|
||||
}
|
||||
|
||||
bool TabsSetZoomFunction::RunAsync() {
|
||||
std::unique_ptr<tabs::SetZoom::Params> params(
|
||||
tabs::SetZoom::Params::Create(*args_));
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
if (!web_contents)
|
||||
return false;
|
||||
|
||||
GURL url(web_contents->GetVisibleURL());
|
||||
if (extensions::PermissionsData::IsRestrictedUrl(url, extension(), &error_))
|
||||
return false;
|
||||
|
||||
zoom::ZoomController* zoom_controller =
|
||||
zoom::ZoomController::FromWebContents(web_contents);
|
||||
double zoom_level = params->zoom_factor > 0
|
||||
? content::ZoomFactorToZoomLevel(params->zoom_factor)
|
||||
: zoom_controller->GetDefaultZoomLevel();
|
||||
|
||||
scoped_refptr<extensions::ExtensionZoomRequestClient> client(
|
||||
new extensions::ExtensionZoomRequestClient(extension()));
|
||||
if (!zoom_controller->SetZoomLevelByClient(zoom_level, client)) {
|
||||
// Tried to zoom a tab in disabled mode.
|
||||
error_ = keys::kCannotZoomDisabledTabError;
|
||||
return false;
|
||||
}
|
||||
|
||||
SendResponse(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TabsGetZoomFunction::RunAsync() {
|
||||
std::unique_ptr<tabs::GetZoom::Params> params(
|
||||
tabs::GetZoom::Params::Create(*args_));
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
if (!web_contents)
|
||||
return false;
|
||||
|
||||
double zoom_level =
|
||||
zoom::ZoomController::FromWebContents(web_contents)->GetZoomLevel();
|
||||
double zoom_factor = content::ZoomLevelToZoomFactor(zoom_level);
|
||||
results_ = tabs::GetZoom::Results::Create(zoom_factor);
|
||||
SendResponse(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TabsSetZoomSettingsFunction::RunAsync() {
|
||||
using api::tabs::ZoomSettings;
|
||||
|
||||
std::unique_ptr<tabs::SetZoomSettings::Params> params(
|
||||
tabs::SetZoomSettings::Params::Create(*args_));
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
if (!web_contents)
|
||||
return false;
|
||||
|
||||
GURL url(web_contents->GetVisibleURL());
|
||||
if (PermissionsData::IsRestrictedUrl(url, extension(), &error_))
|
||||
return false;
|
||||
|
||||
// "per-origin" scope is only available in "automatic" mode.
|
||||
if (params->zoom_settings.scope == tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN &&
|
||||
params->zoom_settings.mode != tabs::ZOOM_SETTINGS_MODE_AUTOMATIC &&
|
||||
params->zoom_settings.mode != tabs::ZOOM_SETTINGS_MODE_NONE) {
|
||||
error_ = keys::kPerOriginOnlyInAutomaticError;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine the correct internal zoom mode to set |web_contents| to from the
|
||||
// user-specified |zoom_settings|.
|
||||
zoom::ZoomController::ZoomMode zoom_mode =
|
||||
zoom::ZoomController::ZOOM_MODE_DEFAULT;
|
||||
switch (params->zoom_settings.mode) {
|
||||
case tabs::ZOOM_SETTINGS_MODE_NONE:
|
||||
case tabs::ZOOM_SETTINGS_MODE_AUTOMATIC:
|
||||
switch (params->zoom_settings.scope) {
|
||||
case tabs::ZOOM_SETTINGS_SCOPE_NONE:
|
||||
case tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN:
|
||||
zoom_mode = zoom::ZoomController::ZOOM_MODE_DEFAULT;
|
||||
break;
|
||||
case tabs::ZOOM_SETTINGS_SCOPE_PER_TAB:
|
||||
zoom_mode = zoom::ZoomController::ZOOM_MODE_ISOLATED;
|
||||
}
|
||||
break;
|
||||
case tabs::ZOOM_SETTINGS_MODE_MANUAL:
|
||||
zoom_mode = zoom::ZoomController::ZOOM_MODE_MANUAL;
|
||||
break;
|
||||
case tabs::ZOOM_SETTINGS_MODE_DISABLED:
|
||||
zoom_mode = zoom::ZoomController::ZOOM_MODE_DISABLED;
|
||||
}
|
||||
|
||||
zoom::ZoomController::FromWebContents(web_contents)->SetZoomMode(zoom_mode);
|
||||
|
||||
SendResponse(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TabsGetZoomSettingsFunction::RunAsync() {
|
||||
std::unique_ptr<tabs::GetZoomSettings::Params> params(
|
||||
tabs::GetZoomSettings::Params::Create(*args_));
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
if (!web_contents)
|
||||
return false;
|
||||
zoom::ZoomController* zoom_controller =
|
||||
zoom::ZoomController::FromWebContents(web_contents);
|
||||
|
||||
zoom::ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode();
|
||||
api::tabs::ZoomSettings zoom_settings;
|
||||
ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
|
||||
zoom_settings.default_zoom_factor.reset(new double(
|
||||
content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel())));
|
||||
|
||||
results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
|
||||
SendResponse(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace cef
|
||||
} // namespace extensions
|
73
libcef/browser/extensions/api/tabs/tabs_api.h
Normal file
73
libcef/browser/extensions/api/tabs/tabs_api.h
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
||||
|
||||
#include "chrome/common/extensions/api/tabs.h"
|
||||
#include "extensions/browser/extension_function.h"
|
||||
|
||||
// The contents of this file are extracted from
|
||||
// chrome/browser/extensions/api/tabs/tabs_api.h.
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
namespace extensions {
|
||||
namespace cef {
|
||||
|
||||
class ZoomAPIFunction : public AsyncExtensionFunction {
|
||||
protected:
|
||||
~ZoomAPIFunction() override {}
|
||||
|
||||
// Gets the WebContents for |tab_id| if it is specified. Otherwise get the
|
||||
// WebContents for the active tab in the current window. Calling this function
|
||||
// may set error_.
|
||||
//
|
||||
// TODO(...) many other tabs API functions use similar behavior. There should
|
||||
// be a way to share this implementation somehow.
|
||||
content::WebContents* GetWebContents(int tab_id);
|
||||
};
|
||||
|
||||
class TabsSetZoomFunction : public ZoomAPIFunction {
|
||||
private:
|
||||
~TabsSetZoomFunction() override {}
|
||||
|
||||
bool RunAsync() override;
|
||||
|
||||
DECLARE_EXTENSION_FUNCTION("tabs.setZoom", TABS_SETZOOM)
|
||||
};
|
||||
|
||||
class TabsGetZoomFunction : public ZoomAPIFunction {
|
||||
private:
|
||||
~TabsGetZoomFunction() override {}
|
||||
|
||||
bool RunAsync() override;
|
||||
|
||||
DECLARE_EXTENSION_FUNCTION("tabs.getZoom", TABS_GETZOOM)
|
||||
};
|
||||
|
||||
class TabsSetZoomSettingsFunction : public ZoomAPIFunction {
|
||||
private:
|
||||
~TabsSetZoomSettingsFunction() override {}
|
||||
|
||||
bool RunAsync() override;
|
||||
|
||||
DECLARE_EXTENSION_FUNCTION("tabs.setZoomSettings", TABS_SETZOOMSETTINGS)
|
||||
};
|
||||
|
||||
class TabsGetZoomSettingsFunction : public ZoomAPIFunction {
|
||||
private:
|
||||
~TabsGetZoomSettingsFunction() override {}
|
||||
|
||||
bool RunAsync() override;
|
||||
|
||||
DECLARE_EXTENSION_FUNCTION("tabs.getZoomSettings", TABS_GETZOOMSETTINGS)
|
||||
};
|
||||
|
||||
} // namespace cef
|
||||
} // namespace extensions
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "libcef/browser/extensions/browser_context_keyed_service_factories.h"
|
||||
|
||||
#include "libcef/browser/extensions/api/streams_private/streams_private_api.h"
|
||||
|
||||
#include "chrome/browser/content_settings/cookie_settings_factory.h"
|
||||
#include "chrome/browser/extensions/api/streams_private/streams_private_api.h"
|
||||
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
||||
#include "extensions/browser/renderer_startup_helper.h"
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace extensions {
|
||||
namespace cef {
|
||||
|
||||
void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
|
||||
CookieSettingsFactory::GetInstance();
|
||||
PrefsTabHelper::GetServiceInstance();
|
||||
RendererStartupHelperFactory::GetInstance();
|
||||
StreamsPrivateAPI::GetFactoryInstance();
|
||||
|
59
libcef/browser/extensions/chrome_api_registration.cc
Normal file
59
libcef/browser/extensions/chrome_api_registration.cc
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright (c) 2016 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.
|
||||
|
||||
// APIs must also be registered in
|
||||
// libcef/common/extensions/api/_*_features.json files. See
|
||||
// libcef/common/extensions/api/README.txt for additional details.
|
||||
|
||||
#include "libcef/browser/extensions/chrome_api_registration.h"
|
||||
|
||||
#include "libcef/browser/extensions/api/tabs/tabs_api.h"
|
||||
|
||||
#include "chrome/browser/extensions/api/resources_private/resources_private_api.h"
|
||||
#include "chrome/browser/extensions/api/streams_private/streams_private_api.h"
|
||||
#include "extensions/browser/extension_function_registry.h"
|
||||
|
||||
namespace extensions {
|
||||
namespace api {
|
||||
namespace cef {
|
||||
|
||||
namespace cefimpl = extensions::cef;
|
||||
|
||||
#define EXTENSION_FUNCTION_NAME(classname) classname::function_name()
|
||||
|
||||
// Only add APIs to this list that have been tested in CEF.
|
||||
// static
|
||||
bool ChromeFunctionRegistry::IsSupported(const std::string& name) {
|
||||
static const char* const supported_apis[] = {
|
||||
"resourcesPrivate",
|
||||
EXTENSION_FUNCTION_NAME(ResourcesPrivateGetStringsFunction),
|
||||
"streamsPrivate",
|
||||
EXTENSION_FUNCTION_NAME(StreamsPrivateAbortFunction),
|
||||
"tabs",
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomSettingsFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomSettingsFunction),
|
||||
};
|
||||
for (size_t i = 0; i < arraysize(supported_apis); ++i) {
|
||||
if (name == supported_apis[i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only add APIs to this list that have been tested in CEF.
|
||||
// static
|
||||
void ChromeFunctionRegistry::RegisterAll(ExtensionFunctionRegistry* registry) {
|
||||
registry->RegisterFunction<ResourcesPrivateGetStringsFunction>();
|
||||
registry->RegisterFunction<StreamsPrivateAbortFunction>();
|
||||
registry->RegisterFunction<cefimpl::TabsSetZoomFunction>();
|
||||
registry->RegisterFunction<cefimpl::TabsGetZoomFunction>();
|
||||
registry->RegisterFunction<cefimpl::TabsSetZoomSettingsFunction>();
|
||||
registry->RegisterFunction<cefimpl::TabsGetZoomSettingsFunction>();
|
||||
}
|
||||
|
||||
} // namespace cef
|
||||
} // namespace api
|
||||
} // namespace extensions
|
26
libcef/browser/extensions/chrome_api_registration.h
Normal file
26
libcef/browser/extensions/chrome_api_registration.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_CHROME_API_REGISTRATION_H_
|
||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_CHROME_API_REGISTRATION_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
class ExtensionFunctionRegistry;
|
||||
|
||||
namespace extensions {
|
||||
namespace api {
|
||||
namespace cef {
|
||||
|
||||
class ChromeFunctionRegistry {
|
||||
public:
|
||||
static bool IsSupported(const std::string& name);
|
||||
static void RegisterAll(ExtensionFunctionRegistry* registry);
|
||||
};
|
||||
|
||||
} // namespace cef
|
||||
} // namespace api
|
||||
} // namespace extensions
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_CHROME_API_REGISTRATION_H_
|
@@ -7,7 +7,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/path_service.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "grit/component_extension_resources_map.h"
|
||||
#include "chrome/grit/component_extension_resources_map.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
|
@@ -1,136 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/extensions/event_router_forwarder.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/browser_context_impl.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/values.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "extensions/browser/event_router.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace extensions {
|
||||
|
||||
EventRouterForwarder::EventRouterForwarder() {
|
||||
}
|
||||
|
||||
EventRouterForwarder::~EventRouterForwarder() {
|
||||
}
|
||||
|
||||
void EventRouterForwarder::BroadcastEventToRenderers(
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
const GURL& event_url) {
|
||||
HandleEvent(std::string(), histogram_value, event_name, std::move(event_args),
|
||||
0, true, event_url);
|
||||
}
|
||||
|
||||
void EventRouterForwarder::DispatchEventToRenderers(
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
void* profile,
|
||||
bool use_profile_to_restrict_events,
|
||||
const GURL& event_url) {
|
||||
if (!profile)
|
||||
return;
|
||||
HandleEvent(std::string(), histogram_value, event_name, std::move(event_args),
|
||||
profile, use_profile_to_restrict_events, event_url);
|
||||
}
|
||||
|
||||
void EventRouterForwarder::BroadcastEventToExtension(
|
||||
const std::string& extension_id,
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
const GURL& event_url) {
|
||||
HandleEvent(extension_id, histogram_value, event_name, std::move(event_args),
|
||||
0, true, event_url);
|
||||
}
|
||||
|
||||
void EventRouterForwarder::DispatchEventToExtension(
|
||||
const std::string& extension_id,
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
void* profile,
|
||||
bool use_profile_to_restrict_events,
|
||||
const GURL& event_url) {
|
||||
if (!profile)
|
||||
return;
|
||||
HandleEvent(extension_id, histogram_value, event_name, std::move(event_args),
|
||||
profile, use_profile_to_restrict_events, event_url);
|
||||
}
|
||||
|
||||
void EventRouterForwarder::HandleEvent(
|
||||
const std::string& extension_id,
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
void* profile_ptr,
|
||||
bool use_profile_to_restrict_events,
|
||||
const GURL& event_url) {
|
||||
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&EventRouterForwarder::HandleEvent, this, extension_id,
|
||||
histogram_value, event_name, base::Passed(&event_args),
|
||||
profile_ptr, use_profile_to_restrict_events, event_url));
|
||||
return;
|
||||
}
|
||||
|
||||
content::BrowserContext* profile = NULL;
|
||||
if (profile_ptr) {
|
||||
profile = reinterpret_cast<content::BrowserContext*>(profile_ptr);
|
||||
if (CefBrowserContextImpl::GetForContext(profile) == NULL)
|
||||
return;
|
||||
}
|
||||
if (profile) {
|
||||
CallEventRouter(profile, extension_id, histogram_value, event_name,
|
||||
std::move(event_args),
|
||||
use_profile_to_restrict_events ? profile : NULL, event_url);
|
||||
} else {
|
||||
std::vector<CefBrowserContextImpl*> profiles(
|
||||
CefBrowserContextImpl::GetAll());
|
||||
for (size_t i = 0; i < profiles.size(); ++i) {
|
||||
std::unique_ptr<base::ListValue> per_profile_event_args(
|
||||
event_args->DeepCopy());
|
||||
CallEventRouter(profiles[i], extension_id, histogram_value, event_name,
|
||||
std::move(per_profile_event_args),
|
||||
use_profile_to_restrict_events ? profiles[i] : NULL,
|
||||
event_url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EventRouterForwarder::CallEventRouter(
|
||||
content::BrowserContext* profile,
|
||||
const std::string& extension_id,
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
content::BrowserContext* restrict_to_profile,
|
||||
const GURL& event_url) {
|
||||
std::unique_ptr<Event> event(
|
||||
new Event(histogram_value, event_name, std::move(event_args)));
|
||||
event->restrict_to_browser_context = restrict_to_profile;
|
||||
event->event_url = event_url;
|
||||
if (extension_id.empty()) {
|
||||
extensions::EventRouter::Get(profile)->BroadcastEvent(std::move(event));
|
||||
} else {
|
||||
extensions::EventRouter::Get(profile)
|
||||
->DispatchEventToExtension(extension_id, std::move(event));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace extensions
|
@@ -1,114 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_
|
||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/values.h"
|
||||
#include "extensions/browser/extension_event_histogram_value.h"
|
||||
|
||||
class GURL;
|
||||
|
||||
namespace content {
|
||||
class BrowserContext;
|
||||
}
|
||||
|
||||
namespace extensions {
|
||||
|
||||
// This class forwards events to EventRouters.
|
||||
// The advantages of this class over direct usage of EventRouters are:
|
||||
// - this class is thread-safe, you can call the functions from UI and IO
|
||||
// thread.
|
||||
// - the class can handle if a profile is deleted between the time of sending
|
||||
// the event from the IO thread to the UI thread.
|
||||
// - this class can be used in contexts that are not governed by a profile, e.g.
|
||||
// by system URLRequestContexts. In these cases the |restrict_to_profile|
|
||||
// parameter remains NULL and events are broadcasted to all profiles.
|
||||
class EventRouterForwarder
|
||||
: public base::RefCountedThreadSafe<EventRouterForwarder> {
|
||||
public:
|
||||
EventRouterForwarder();
|
||||
|
||||
// Calls
|
||||
// DispatchEventToRenderers(event_name, event_args, profile, event_url)
|
||||
// on all (original) profiles' EventRouters.
|
||||
// May be called on any thread.
|
||||
void BroadcastEventToRenderers(events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
const GURL& event_url);
|
||||
|
||||
// Calls
|
||||
// DispatchEventToExtension(extension_id, event_name, event_args,
|
||||
// profile, event_url)
|
||||
// on all (original) profiles' EventRouters.
|
||||
// May be called on any thread.
|
||||
void BroadcastEventToExtension(const std::string& extension_id,
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
const GURL& event_url);
|
||||
|
||||
// Calls
|
||||
// DispatchEventToRenderers(event_name, event_args,
|
||||
// use_profile_to_restrict_events ? profile : NULL, event_url)
|
||||
// on |profile|'s EventRouter. May be called on any thread.
|
||||
void DispatchEventToRenderers(events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
void* profile,
|
||||
bool use_profile_to_restrict_events,
|
||||
const GURL& event_url);
|
||||
|
||||
// Calls
|
||||
// DispatchEventToExtension(extension_id, event_name, event_args,
|
||||
// use_profile_to_restrict_events ? profile : NULL, event_url)
|
||||
// on |profile|'s EventRouter. May be called on any thread.
|
||||
void DispatchEventToExtension(const std::string& extension_id,
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
void* profile,
|
||||
bool use_profile_to_restrict_events,
|
||||
const GURL& event_url);
|
||||
|
||||
protected:
|
||||
// Protected for testing.
|
||||
virtual ~EventRouterForwarder();
|
||||
|
||||
// Helper function for {Broadcast,Dispatch}EventTo{Extension,Renderers}.
|
||||
// Virtual for testing.
|
||||
virtual void HandleEvent(const std::string& extension_id,
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
void* profile,
|
||||
bool use_profile_to_restrict_events,
|
||||
const GURL& event_url);
|
||||
|
||||
// Calls DispatchEventToRenderers or DispatchEventToExtension (depending on
|
||||
// whether extension_id == "" or not) of |profile|'s EventRouter.
|
||||
// |profile| may never be NULL.
|
||||
// Virtual for testing.
|
||||
virtual void CallEventRouter(content::BrowserContext* profile,
|
||||
const std::string& extension_id,
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> event_args,
|
||||
content::BrowserContext* restrict_to_profile,
|
||||
const GURL& event_url);
|
||||
|
||||
private:
|
||||
friend class base::RefCountedThreadSafe<EventRouterForwarder>;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(EventRouterForwarder);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EVENT_ROUTER_FORWARDER_H_
|
@@ -80,6 +80,7 @@ base::DictionaryValue* ParseManifest(
|
||||
|
||||
CefExtensionSystem::CefExtensionSystem(BrowserContext* browser_context)
|
||||
: browser_context_(browser_context),
|
||||
initialized_(false),
|
||||
registry_(ExtensionRegistry::Get(browser_context)),
|
||||
weak_ptr_factory_(this) {
|
||||
}
|
||||
@@ -88,6 +89,8 @@ CefExtensionSystem::~CefExtensionSystem() {
|
||||
}
|
||||
|
||||
void CefExtensionSystem::Init() {
|
||||
DCHECK(!initialized_);
|
||||
|
||||
// There's complexity here related to the ordering of message delivery. For
|
||||
// an extension to load correctly both the ExtensionMsg_Loaded and
|
||||
// ExtensionMsg_ActivateExtension messages must be sent. These messages are
|
||||
@@ -122,23 +125,27 @@ void CefExtensionSystem::Init() {
|
||||
// 5. A MimeHandlerViewGuest and CefMimeHandlerViewGuestDelegate is created in
|
||||
// the browser process.
|
||||
// 6. MimeHandlerViewGuest navigates to the PDF extension URL.
|
||||
// 7. PDF extension resources are provided from bundle via
|
||||
// 7. Access to PDF extension resources is checked by
|
||||
// CefExtensionsBrowserClient::AllowCrossRendererResourceLoad.
|
||||
// 8. PDF extension resources are provided from bundle via
|
||||
// CefExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob and
|
||||
// CefComponentExtensionResourceManager.
|
||||
// 8. The PDF extension communicates via the chrome.mimeHandlerPrivate Mojo
|
||||
// 9. The PDF extension communicates via the chrome.mimeHandlerPrivate Mojo
|
||||
// API which is implemented as described in
|
||||
// libcef/common/extensions/api/README.txt.
|
||||
// 9. The PDF extension requests a plugin to handle
|
||||
// 10.The PDF extension requests a plugin to handle
|
||||
// kPDFPluginOutOfProcessMimeType which loads the PDF PPAPI plugin.
|
||||
// 10.Routing of print-related commands are handled by ChromePDFPrintClient
|
||||
// 11.Routing of print-related commands are handled by ChromePDFPrintClient
|
||||
// and CefPrintWebViewHelperDelegate in the renderer process.
|
||||
// 11.The PDF extension is granted access to chrome://resources via
|
||||
// 12.The PDF extension is granted access to chrome://resources via
|
||||
// CefExtensionWebContentsObserver::RenderViewCreated in the browser
|
||||
// process.
|
||||
if (PdfExtensionEnabled()) {
|
||||
AddExtension(pdf_extension_util::GetManifest(),
|
||||
base::FilePath(FILE_PATH_LITERAL("pdf")));
|
||||
}
|
||||
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
// Implementation based on ComponentLoader::Add.
|
||||
@@ -171,6 +178,7 @@ void CefExtensionSystem::Shutdown() {
|
||||
}
|
||||
|
||||
void CefExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
|
||||
DCHECK(!initialized_);
|
||||
service_worker_manager_.reset(new ServiceWorkerManager(browser_context_));
|
||||
runtime_data_.reset(new RuntimeData(registry_));
|
||||
quota_service_.reset(new QuotaService);
|
||||
@@ -263,7 +271,7 @@ ContentVerifier* CefExtensionSystem::content_verifier() {
|
||||
|
||||
std::unique_ptr<ExtensionSet> CefExtensionSystem::GetDependentExtensions(
|
||||
const Extension* extension) {
|
||||
return make_scoped_ptr(new ExtensionSet());
|
||||
return base::MakeUnique<ExtensionSet>();
|
||||
}
|
||||
|
||||
void CefExtensionSystem::InstallUpdate(const std::string& extension_id,
|
||||
|
@@ -78,6 +78,8 @@ class CefExtensionSystem : public ExtensionSystem {
|
||||
void InstallUpdate(const std::string& extension_id,
|
||||
const base::FilePath& temp_dir) override;
|
||||
|
||||
bool initialized() const { return initialized_; }
|
||||
|
||||
private:
|
||||
// Information about a registered component extension.
|
||||
struct ComponentExtensionInfo {
|
||||
@@ -120,6 +122,8 @@ class CefExtensionSystem : public ExtensionSystem {
|
||||
|
||||
content::BrowserContext* browser_context_; // Not owned.
|
||||
|
||||
bool initialized_;
|
||||
|
||||
// Data to be accessed on the IO thread. Must outlive process_manager_.
|
||||
scoped_refptr<InfoMap> info_map_;
|
||||
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
|
||||
#include "chrome/browser/profiles/incognito_helpers.h"
|
||||
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
||||
#include "extensions/browser/extension_prefs_factory.h"
|
||||
#include "extensions/browser/extension_registry_factory.h"
|
||||
@@ -45,7 +46,7 @@ KeyedService* CefExtensionSystemFactory::BuildServiceInstanceFor(
|
||||
BrowserContext* CefExtensionSystemFactory::GetBrowserContextToUse(
|
||||
BrowserContext* context) const {
|
||||
// Use a separate instance for incognito.
|
||||
return context;
|
||||
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
|
||||
}
|
||||
|
||||
bool CefExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const {
|
||||
|
@@ -12,8 +12,11 @@
|
||||
#include "libcef/browser/extensions/pdf_web_contents_helper_client.h"
|
||||
#include "libcef/browser/printing/print_view_manager.h"
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "chrome/browser/sessions/session_tab_helper.h"
|
||||
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
||||
#include "components/pdf/browser/pdf_web_contents_helper.h"
|
||||
#include "components/zoom/zoom_controller.h"
|
||||
#include "extensions/browser/guest_view/extensions_guest_view_manager_delegate.h"
|
||||
|
||||
namespace extensions {
|
||||
@@ -39,7 +42,7 @@ CefExtensionsAPIClient::CreateGuestViewManagerDelegate(
|
||||
// to provide the *Impl object instead of |context| which may be a *Proxy
|
||||
// object. If we don't do this then the Delegate may attempt to access a
|
||||
// *Proxy object that has already been deleted.
|
||||
return make_scoped_ptr(
|
||||
return base::WrapUnique(
|
||||
new extensions::ExtensionsGuestViewManagerDelegate(
|
||||
CefBrowserContextImpl::GetForContext(context).get()));
|
||||
}
|
||||
@@ -47,18 +50,25 @@ CefExtensionsAPIClient::CreateGuestViewManagerDelegate(
|
||||
std::unique_ptr<MimeHandlerViewGuestDelegate>
|
||||
CefExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate(
|
||||
MimeHandlerViewGuest* guest) const {
|
||||
return make_scoped_ptr(new CefMimeHandlerViewGuestDelegate(guest));
|
||||
return base::WrapUnique(new CefMimeHandlerViewGuestDelegate(guest));
|
||||
}
|
||||
|
||||
void CefExtensionsAPIClient::AttachWebContentsHelpers(
|
||||
content::WebContents* web_contents) const {
|
||||
PrefsTabHelper::CreateForWebContents(web_contents);
|
||||
printing::PrintViewManager::CreateForWebContents(web_contents);
|
||||
printing::CefPrintViewManager::CreateForWebContents(web_contents);
|
||||
|
||||
CefExtensionWebContentsObserver::CreateForWebContents(web_contents);
|
||||
|
||||
// Used by the PDF extension.
|
||||
pdf::PDFWebContentsHelper::CreateForWebContentsWithClient(
|
||||
web_contents,
|
||||
std::unique_ptr<pdf::PDFWebContentsHelperClient>(
|
||||
new CefPDFWebContentsHelperClient()));
|
||||
CefExtensionWebContentsObserver::CreateForWebContents(web_contents);
|
||||
|
||||
// Used by the tabs extension API.
|
||||
SessionTabHelper::CreateForWebContents(web_contents);
|
||||
zoom::ZoomController::CreateForWebContents(web_contents);
|
||||
}
|
||||
|
||||
} // namespace extensions
|
||||
|
@@ -8,13 +8,17 @@
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/browser_context_impl.h"
|
||||
#include "libcef/browser/extensions/chrome_api_registration.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"
|
||||
#include "libcef/browser/extensions/extensions_api_client.h"
|
||||
#include "libcef/browser/extensions/url_request_util.h"
|
||||
|
||||
#include "cef/libcef/browser/extensions/api/generated_api_registration.h"
|
||||
//#include "cef/libcef/browser/extensions/api/generated_api_registration.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/extensions/chrome_url_request_util.h"
|
||||
#include "chrome/browser/extensions/event_router_forwarder.h"
|
||||
#include "chrome/browser/profiles/incognito_helpers.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
@@ -27,6 +31,7 @@
|
||||
#include "extensions/browser/extension_host_delegate.h"
|
||||
#include "extensions/browser/mojo/service_registration.h"
|
||||
#include "extensions/browser/url_request_util.h"
|
||||
#include "extensions/common/constants.h"
|
||||
|
||||
using content::BrowserContext;
|
||||
using content::BrowserThread;
|
||||
@@ -35,8 +40,7 @@ namespace extensions {
|
||||
|
||||
CefExtensionsBrowserClient::CefExtensionsBrowserClient()
|
||||
: api_client_(new CefExtensionsAPIClient),
|
||||
resource_manager_(new CefComponentExtensionResourceManager),
|
||||
event_router_forwarder_(new EventRouterForwarder) {
|
||||
resource_manager_(new CefComponentExtensionResourceManager) {
|
||||
}
|
||||
|
||||
CefExtensionsBrowserClient::~CefExtensionsBrowserClient() {
|
||||
@@ -58,7 +62,10 @@ bool CefExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
|
||||
|
||||
bool CefExtensionsBrowserClient::IsSameContext(BrowserContext* first,
|
||||
BrowserContext* second) {
|
||||
return first == second;
|
||||
// Returns true if |first| and |second| share the same underlying
|
||||
// CefBrowserContextImpl.
|
||||
return CefBrowserContextImpl::GetForContext(first).get() ==
|
||||
CefBrowserContextImpl::GetForContext(second).get();
|
||||
}
|
||||
|
||||
bool CefExtensionsBrowserClient::HasOffTheRecordContext(
|
||||
@@ -74,7 +81,7 @@ BrowserContext* CefExtensionsBrowserClient::GetOffTheRecordContext(
|
||||
|
||||
BrowserContext* CefExtensionsBrowserClient::GetOriginalContext(
|
||||
BrowserContext* context) {
|
||||
return context;
|
||||
return chrome::GetBrowserContextRedirectedInIncognito(context);
|
||||
}
|
||||
|
||||
bool CefExtensionsBrowserClient::IsGuestSession(
|
||||
@@ -101,7 +108,7 @@ CefExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob(
|
||||
const base::FilePath& directory_path,
|
||||
const std::string& content_security_policy,
|
||||
bool send_cors_header) {
|
||||
return url_request_util::MaybeCreateURLRequestResourceBundleJob(
|
||||
return chrome_url_request_util::MaybeCreateURLRequestResourceBundleJob(
|
||||
request,
|
||||
network_delegate,
|
||||
directory_path,
|
||||
@@ -114,6 +121,13 @@ bool CefExtensionsBrowserClient::AllowCrossRendererResourceLoad(
|
||||
bool is_incognito,
|
||||
const Extension* extension,
|
||||
InfoMap* extension_info_map) {
|
||||
// TODO(cef): This bypasses additional checks added to
|
||||
// AllowCrossRendererResourceLoad() in https://crrev.com/5cf9d45c. Figure out
|
||||
// why permission is not being granted based on "web_accessible_resources"
|
||||
// specified in the PDF extension manifest.json file.
|
||||
if (extension && extension->id() == extension_misc::kPdfExtensionId)
|
||||
return true;
|
||||
|
||||
bool allowed = false;
|
||||
if (url_request_util::AllowCrossRendererResourceLoad(
|
||||
request, is_incognito, extension, extension_info_map, &allowed)) {
|
||||
@@ -162,12 +176,6 @@ bool CefExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
|
||||
return false;
|
||||
}
|
||||
|
||||
ApiActivityMonitor* CefExtensionsBrowserClient::GetApiActivityMonitor(
|
||||
BrowserContext* context) {
|
||||
// CEF doesn't monitor API function calls or events.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ExtensionSystemProvider*
|
||||
CefExtensionsBrowserClient::GetExtensionSystemFactory() {
|
||||
return CefExtensionSystemFactory::GetInstance();
|
||||
@@ -179,7 +187,12 @@ void CefExtensionsBrowserClient::RegisterExtensionFunctions(
|
||||
api::GeneratedFunctionRegistry::RegisterAll(registry);
|
||||
|
||||
// CEF-only APIs.
|
||||
api::ChromeGeneratedFunctionRegistry::RegisterAll(registry);
|
||||
// TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See
|
||||
// libcef/common/extensions/api/README.txt for details.
|
||||
//api::cef::CefGeneratedFunctionRegistry::RegisterAll(registry);
|
||||
|
||||
// Chrome APIs whitelisted by CEF.
|
||||
api::cef::ChromeFunctionRegistry::RegisterAll(registry);
|
||||
}
|
||||
|
||||
void CefExtensionsBrowserClient::RegisterMojoServices(
|
||||
@@ -193,7 +206,7 @@ CefExtensionsBrowserClient::CreateRuntimeAPIDelegate(
|
||||
content::BrowserContext* context) const {
|
||||
// TODO(extensions): Implement to support Apps.
|
||||
NOTREACHED();
|
||||
return std::unique_ptr<RuntimeAPIDelegate>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const ComponentExtensionResourceManager*
|
||||
@@ -205,8 +218,9 @@ void CefExtensionsBrowserClient::BroadcastEventToRenderers(
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> args) {
|
||||
event_router_forwarder_->BroadcastEventToRenderers(
|
||||
histogram_value, event_name, std::move(args), GURL());
|
||||
g_browser_process->extension_event_router_forwarder()->
|
||||
BroadcastEventToRenderers(histogram_value, event_name, std::move(args),
|
||||
GURL());
|
||||
}
|
||||
|
||||
net::NetLog* CefExtensionsBrowserClient::GetNetLog() {
|
||||
|
@@ -6,8 +6,6 @@
|
||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSIONS_BROWSER_CLIENT_H_
|
||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSIONS_BROWSER_CLIENT_H_
|
||||
|
||||
#include "libcef/browser/extensions/event_router_forwarder.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "extensions/browser/extensions_browser_client.h"
|
||||
|
||||
@@ -64,8 +62,6 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
|
||||
void PermitExternalProtocolHandler() override;
|
||||
bool IsRunningInForcedAppMode() override;
|
||||
bool IsLoggedInAsPublicAccount() override;
|
||||
ApiActivityMonitor* GetApiActivityMonitor(
|
||||
content::BrowserContext* context) override;
|
||||
ExtensionSystemProvider* GetExtensionSystemFactory() override;
|
||||
void RegisterExtensionFunctions(
|
||||
ExtensionFunctionRegistry* registry) const override;
|
||||
@@ -95,8 +91,6 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
|
||||
// Resource manager used to supply resources from pak files.
|
||||
std::unique_ptr<ComponentExtensionResourceManager> resource_manager_;
|
||||
|
||||
scoped_refptr<EventRouterForwarder> event_router_forwarder_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefExtensionsBrowserClient);
|
||||
};
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include "libcef/browser/extensions/pdf_extension_util.h"
|
||||
|
||||
#include "base/strings/string_util.h"
|
||||
#include "grit/cef_resources.h"
|
||||
#include "chrome/grit/browser_resources.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
|
||||
namespace extensions {
|
||||
@@ -26,7 +26,10 @@ const char kPdfResourceIdentifier[] = "google-chrome-pdf";
|
||||
const char kPdfResourceIdentifier[] = "chromium-pdf";
|
||||
#endif
|
||||
|
||||
const char kPdfPluginName[] = "Chromium PDF Viewer";
|
||||
// Match the GOOGLE_CHROME_BUILD value from ChromeContentClient::kPDFPluginName
|
||||
// to avoid breaking Websites that specifically look for this string in the
|
||||
// plugin list.
|
||||
const char kPdfPluginName[] = "Chrome PDF Viewer";
|
||||
|
||||
std::string GetManifest() {
|
||||
std::string manifest_contents =
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user