Compare commits

...

61 Commits
4044 ... 4103

Author SHA1 Message Date
Marshall Greenblatt
bf03589c4d Expose MediaSink device ip/port and model name (see issue #2900) 2020-07-14 16:59:41 -04:00
Marshall Greenblatt
a4a78d1254 Windows: Explicitly specify the SDK version in setup_toolchain.py
Avoid building with a new and untested SDK version. See
https://crbug.com/1089996 for background.
2020-07-13 16:28:33 -04:00
Marshall Greenblatt
babcf94317 Make chrome://chrome-urls an alias for chrome://webui-hosts (fixes issue #2977) 2020-07-02 15:46:26 -04:00
Marshall Greenblatt
1a5bcf17bd Fix decoding of resources (fixes issue #2966)
Use LoadDataResourceString instead of GetDataResource. It will perform
decoding if necessary.
2020-07-02 15:08:43 -04:00
Cristian Amarie
c8d4f85687 Fix crash when reading malformed Flash manifest file (fixes issue #2948) 2020-06-30 14:49:00 -04:00
Marshall Greenblatt
7d5d193cf7 Windows: Fix CefCookieVisitor crash on invalid date (fixes issue #2927) 2020-06-30 14:36:44 -04:00
Marshall Greenblatt
fd6631bd18 Add support for direct DevTools protocol messaging (fixes issue #2961).
This change allows the client to directly send and receive DevTools
protocol messages (send method calls, and receive method results and
events) without requiring a DevTools front-end or remote-debugging
session.

This change includes additional supporting changes:
- Add a new CefRequestHandler::OnDocumentAvailableInMainFrame
  callback (see issue #1454).
- Add a CefParseJSON variant that accepts a UTF8-encoded buffer.
- Add a `--devtools-protocol-log-file=<path>` command-line flag for
  logging protocol messages sent to/from the DevTools front-end
  while it is displayed. This is useful for understanding existing
  DevTools protocol usage.
- Add a new "libcef_static_unittests" executable target to support
  light-weight unit tests of libcef_static internals (e.g. without
  requiring exposure via the CEF API). Files to be unittested are
  placed in the new "libcef_static_unittested" source_set which is
  then included by both the existing libcef_static library and the
  new unittests executable target.
- Linux: Remove use_bundled_fontconfig=false, which is no longer
  required and causes unittest build errors (see issue #2424).

This change also adds a cefclient demo for configuring offline mode
using the DevTools protocol (fixes issue #245). This is controlled
by the "Offline mode" context menu option and the `--offline`
command-line switch which will launch cefclient in offline mode. When
cefclient is offline all network requests will fail with
ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when
called from JavaScript in any frame. This mode is per-browser so
newly created browser windows will have the default mode. Note that
configuring offline mode in this way will not update the Network tab
UI ("Throtting" option) in a displayed DevTools front-end instance.
2020-06-20 18:48:29 -04:00
Marshall Greenblatt
eb9a2ffa3d Update to Chromium version 83.0.4103.106 2020-06-20 18:45:14 -04:00
Marshall Greenblatt
0889ff05e8 Update to Chromium version 83.0.4103.97 2020-06-04 18:56:42 -04:00
Marshall Greenblatt
1fac1e551d Remove duplicate local_discovery file entries (see issue #2900)
This fixes duplicate symbol errors when linking libcef on Linux. These files
are now included by default with enable_service_discovery=true.
2020-05-26 13:33:09 -04:00
Marshall Greenblatt
124ce018e7 Enable DNS-SD discovery for cast devices (see issue #2900) 2020-05-25 16:58:56 -04:00
Marshall Greenblatt
ed43e55867 Linux: Fix undefined symbol: ui::GtkUiDelegate::SetInstance
See https://crbug.com/1085806 for details.
2020-05-22 15:32:37 -04:00
Marshall Greenblatt
38d22c402d Update to Chromium version 83.0.4103.61 2020-05-22 15:32:14 -04:00
Marshall Greenblatt
42fc10a6cd Windows: Add VS2019 path discovery to msvs_env.bat (fixes issue #2925) 2020-05-13 13:24:34 -04:00
Marshall Greenblatt
52b62306e0 Remember the user-selected printer by default (fixes issue #2875) 2020-05-13 13:11:23 -04:00
Marshall Greenblatt
8758255ef7 Fix window.print() of PDF file (fixes issue #2987) 2020-05-12 16:27:44 -04:00
Marshall Greenblatt
b1d19f3c9e Windows: cefclient: Fix return value check for AcquireSync (fixes issue #2933) 2020-05-12 15:42:58 -04:00
Marshall Greenblatt
d91b677975 Fix load of non-standard custom scheme URI as iframe src (see issue #2929) 2020-05-11 18:18:28 -04:00
Marshall Greenblatt
658928d5ad Fix registration of WebSafe schemes (fixes issue #2929) 2020-05-11 18:18:22 -04:00
Marshall Greenblatt
62f6ca21a1 Update AUTHORS.txt documentation 2020-05-08 12:41:12 -04:00
Mike Wiedenbauer
04d461e032 Re-implement audio capturing based on the AudioService API (fixes issue #2755) 2020-05-01 14:21:43 -04:00
Marshall Greenblatt
6b8a2df316 Update cef_api_hash.h at build time if necessary (fixes issue #2922)
The cef_api_hash.h file was previously only updated when the translator tool
was run manually. Forgetting to run the translator tool after changing
include/internal/cef_types*.h files would result in cef_parser.py
incorrectly computing the CEF minor version number for future builds. By
updating this file automatically at build time the number of errors should be
reduced.
2020-04-30 18:26:57 -04:00
Marshall Greenblatt
07830a15a4 Save LocalPrefs.json in CefSettings.root_cache_path (see issue #2890) 2020-04-29 15:38:39 -04:00
Marshall Greenblatt
1f55c0d762 Add CefMediaSink::GetIconType (see issue #2900)
This attribute is useful for identifying different classes of cast devices
without first requiring a connection (CAST, CAST_AUDIO, CAST_AUDIO_GROUP, etc).
2020-04-29 15:08:31 -04:00
Vladislav
f5f5127a37 Fix OSR resize issue with DPI scaling (fixes issue #2733) 2020-04-27 12:49:49 -04:00
Dmitry Azaraev
e22543f8d5 Add SameSite (same_site) and Priority attributes to CefCookie (fixes issue #2524)
This change also restores the Chromium default values for the
SameSiteByDefaultCookies and CookiesWithoutSameSiteMustBeSecure features. See
https://www.chromium.org/updates/same-site for feature details and rollout
timeline.
2020-04-24 18:07:46 -04:00
Marshall Greenblatt
e840f2394d Revert "Fix background color assignment for popups (fixes issue #2482)"
This reverts commit 1a0593dd6c.
2020-04-24 18:07:07 -04:00
Marshall Greenblatt
dede95c586 Normalize path values and add additional error logging (fixes issue #2405)
This change also improves the settings documentation and enforces the
requirement that path values be absolute (see issue #2916).
2020-04-23 18:48:10 -04:00
Marshall Greenblatt
1bc50299fb Fix transposed variables in GetRequestInfo (fixes issue #2530) 2020-04-23 14:39:36 -04:00
Marshall Greenblatt
1a0593dd6c Fix background color assignment for popups (fixes issue #2482) 2020-04-23 14:04:48 -04:00
Marshall Greenblatt
9e69e29c9d Fix PDF extension loading of large files (fixes issue #2905)
The PDF extension will send Range requests when loading large PDF files. For
these cross-origin requests to be allowed (from extension origin to PDF origin)
the CORB checks in URLLoader must be disabled.
2020-04-22 16:28:58 -04:00
Alex Maitland
bcc0a67cd6 Change cef_pdf_print_settings_t custom margins from double to int (fixes issue #2694) 2020-04-21 14:45:59 -04:00
Mike Wiedenbauer
1b5211033c Fix OSR keyboard input for editable PDF (fixes issue #2907) 2020-04-21 14:32:14 -04:00
Jengerer
1a852a1bc2 Fix handling of partial range request (fixes issue #2873) 2020-04-20 13:22:37 -04:00
Marshall Greenblatt
2cab6f1f6a Remove DCHECK in InterceptedRequest::OnReceiveRedirect (fixes issue #2917) 2020-04-20 12:42:58 -04:00
Marshall Greenblatt
56a01f713c Update to Chromium version 83.0.4103.14 2020-04-15 21:51:09 -04:00
Marshall Greenblatt
245bc9bfab Windows: Early init parental controls to avoid blocking assertions 2020-04-15 21:46:31 -04:00
Marshall Greenblatt
fa519f5108 Update to Chromium version 83.0.4103.0 (#756066) 2020-04-15 16:47:50 -04:00
Mike Wiedenbauer
30d83cb94a Fix AltGr handling for OSR keyboard events (fixes issue #2892) 2020-04-08 15:43:39 +00:00
Mike Wiedenbauer
f5c79bf50c Linux: Fix CefPrintHandler callbacks from PDF viewer (fixes issue #2906) 2020-04-02 21:26:14 +00:00
Andrei Kurushin
ea1324a9f1 Windows: cefclient: Fix accessibility where TreeId type has changed from int to string 2020-04-02 21:19:25 +00:00
Andy Tzeng
261a8899fc Fix UU_REPLACE_PLUS_WITH_SPACE value to match Chromium (fixes issue #2904) 2020-04-02 21:16:52 +00:00
Vladislav
a5de549456 Fix OSR popup position when the view origin is offset in screen coords (fixes issue #2902) 2020-04-02 21:14:28 +00:00
rcdrone
bdaa857c49 Windows: Disable the sandbox if windows_sandbox_info is null
This restores the behavior prior to revision 438382c. Calling
InitializeSandboxInfo from inside libcef won’t work unless libcef is
statically linked with the executable, so there's no point in doing so.
See the Chromium sandbox docs for background.
2020-04-02 21:11:16 +00:00
Cristian Amarie
1c14900093 Remove unexpected content headers when converting from POST to GET request on 302 redirect response (fixes issue #2883) 2020-04-02 21:05:07 +00:00
Andrei Kurushin
01f385a6f7 Fix CefFrame::GetSource crash on detached frame (fixes issue #2898) 2020-04-02 21:01:33 +00:00
Mike Wiedenbauer
cf6b57d659 Enable smooth scrolling with OSR (fixes issue #2895) 2020-04-02 20:59:26 +00:00
Marshall Greenblatt
f742ab4994 Mac: Remove unicode character in README.redistrib.txt (fixes issue #2910) 2020-04-02 13:44:27 -04:00
Marshall Greenblatt
cfac1c347c Fix no newline at end of file error with Xcode 11.3.1 2020-04-02 13:36:45 -04:00
Marshall Greenblatt
047e8f9349 Update to Chromium version 82.0.4085.0 (#749737)
- Building on macOS now requires the 10.15 SDK. Xcode 11.3 is recommended as
  Xcode 11.4 is not currently supported (see https://crbug.com/1065146).
- Jumbo build configuration is no longer supported.

Chromium is skipping the M82 release and consequently no CEF 4085 branch will
be created. For details on the Chromium decision see
https://groups.google.com/a/chromium.org/d/msg/chromium-dev/Vn7uzglqLz0/JItlSrZxBAAJ
2020-04-02 13:20:25 -04:00
Marshall Greenblatt
3d87a68561 Always persist local_state by default (fixes issue #2890)
If a cache_path is specified local_state will now be persisted to a
LocalPrefs.json file. This is necessary because local_state is used to store
the cookie encryption key on Windows.
2020-04-01 17:06:19 -04:00
Marshall Greenblatt
66433c1869 Windows: Fix warning C4457: declaration of 'result' hides function parameter in VS2019 2020-04-01 17:06:19 -04:00
Marshall Greenblatt
869ae21c9f Convert CefCookieManagerImpl to use CefBrowserContext::Getter.
With this change CefCookieManagerImpl no longer keeps a reference to the
originating CefRequestContextImpl. This means that the CefRequestContextImpl
can be destroyed if all other references are released while the
CefCookieManagerImpl exists. If CefRequestContextImpl destruction results in
the underlying CefBrowserContext being destroyed then the CefCookieManagerImpl's
reference to that CefBrowserContext will be invalidated.

This is the same ownership model introduced with CefMediaRouterImpl in the
previous commit.
2020-03-27 16:22:34 -04:00
Marshall Greenblatt
03fd5b15da Add support for media device discovery and messaging (fixes issue #2900)
Chromium supports communication with media devices on the local network via
the Cast and DIAL protocols. This takes two primary forms:

1. Messaging, where strings representing state information are passed between
   the client and a dedicated receiver app on the media device. The receiver
   app communicates directly with an app-specific backend service to retrieve
   and possibly control media playback.
2. Tab/desktop mirroring, where the media contents are streamed directly from
   the browser to a generic streaming app on the media device and playback is
   controlled by the browser.

This change adds support for device discovery and messaging (but not
mirroring) with functionality exposed via the new CefMediaRouter interface.

To test: Navigate to http://tests/media_router in cefclient and follow the
on-screen instructions.
2020-03-27 15:54:39 -04:00
Vladislav
fecd582035 Fix OSR crash on window.open with new client (fixes issue #2894) 2020-03-06 19:51:58 +00:00
Andy Tzeng
180e9bd362 Support fragment (hash) component in CefParseURL (fixes issue #2896) 2020-03-06 17:40:28 +00:00
Marshall Greenblatt
2fbb6ba1e9 automate-git: Add support for depot_tools version pinning (fixes issue #2893) 2020-03-06 11:42:08 -05:00
Marshall Greenblatt
51e12b3866 automate-git: Remove support for branches older than 3071.
3071 and newer branches use Git and GN exclusively.
2020-03-05 13:56:17 -05:00
rcdrone
a6f9d78c1c Windows: Skip InitializeSandboxInfo if no_sandbox is true
The InitializeSandboxInfo method applies mitigations to the main process
that are inappropriate when the sandbox is disabled.
2020-03-05 17:53:13 +00:00
rcdrone
8cf82c24dc Windows: Skip InitializeSandboxInfo if no_sandbox is true
The InitializeSandboxInfo method applies mitigations to the main process
that are inappropriate when the sandbox is disabled.
2020-03-05 17:52:51 +00:00
rcdrone
438382c5df Windows: Skip InitializeSandboxInfo if no_sandbox is true
The InitializeSandboxInfo method applies mitigations to the main process
that are inappropriate when the sandbox is disabled.
2020-03-05 17:52:41 +00:00
284 changed files with 13547 additions and 4193 deletions

View File

@@ -1,6 +1,8 @@
# This file is an addendum to the Chromium AUTHORS file.
# Names should be added to this file like so:
# Name or Organization <email address>
# This file is an addendum to the Chromium AUTHORS file. It lists authors
# through March 16, 2015 when Git was introduced for source code management.
# A list of additional authors added after that date can be found by executing
# this command on a local Git checkout:
# git log --all --format="%aN <%aE>" | sort -u
Marshall Greenblatt <magreenblatt@gmail.com>
Jamie Kirkpatrick <jkp@spotify.com>

164
BUILD.gn
View File

@@ -106,6 +106,7 @@ import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni")
import("//testing/test.gni")
import("//third_party/icu/config.gni")
import("//third_party/widevine/cdm/widevine.gni")
import("//tools/grit/repack.gni")
@@ -253,7 +254,6 @@ if (is_linux) {
# Set ENABLE_PRINTING=1 ENABLE_BASIC_PRINTING=1.
assert(enable_basic_printing)
assert(enable_print_preview)
assert(!enable_service_discovery)
# Enable support for Widevine CDM.
assert(enable_widevine)
@@ -263,12 +263,6 @@ if (is_clang) {
assert(!clang_use_chrome_plugins)
}
if (is_linux) {
# Use system fontconfig. This avoids a startup hang on Ubuntu 16.04.4 (see
# issue #2424).
assert(!use_bundled_fontconfig)
}
if (is_mac) {
# Always generate dSYM files. The make_distrib script will fail if
# enable_dsyms=true is not explicitly set when is_official_build=false.
@@ -303,6 +297,10 @@ gypi_paths2 = exec_script("//cef/tools/gypi_to_gn.py",
"scope",
[ "cef_paths2.gypi" ])
includes_common = gypi_paths2.includes_common + gypi_paths2.includes_common_capi
includes_mac = gypi_paths2.includes_mac + gypi_paths2.includes_mac_capi
includes_linux = gypi_paths2.includes_linux + gypi_paths2.includes_linux_capi
includes_win = gypi_paths2.includes_win + gypi_paths2.includes_win_capi
#
# Targets that will be built when depending on "//cef".
@@ -313,6 +311,7 @@ group("cef") {
deps = [
":cefsimple",
":ceftests",
":libcef_static_unittests",
]
if (!is_linux || use_x11) {
@@ -370,9 +369,46 @@ if (is_win) {
}
}
# libcef_static source files that have unit tests.
source_set("libcef_static_unittested") {
sources = [
"libcef/browser/devtools/devtools_util.cc",
"libcef/browser/devtools/devtools_util.h",
]
deps = [
"//base",
]
configs += [
"libcef/features:config",
"//build/config:precompiled_headers",
]
}
# Executable target for libcef_static unit tests.
test("libcef_static_unittests") {
sources = [
"libcef/browser/devtools/devtools_util_unittest.cc",
]
deps = [
":libcef_static_unittested",
"//base/test:run_all_unittests",
"//testing/gtest",
]
configs += [
"libcef/features:config",
"//build/config:precompiled_headers",
]
}
static_library("libcef_static") {
sources = gypi_paths2.includes_common +
sources = includes_common +
gypi_paths.autogen_cpp_includes + [
"libcef/browser/audio_capturer.cc",
"libcef/browser/audio_capturer.h",
"libcef/browser/browser_context.cc",
"libcef/browser/browser_context.h",
"libcef/browser/browser_context_keyed_service_factories.cc",
@@ -407,10 +443,14 @@ static_library("libcef_static") {
"libcef/browser/context.h",
"libcef/browser/context_menu_params_impl.cc",
"libcef/browser/context_menu_params_impl.h",
"libcef/browser/devtools/devtools_controller.cc",
"libcef/browser/devtools/devtools_controller.h",
"libcef/browser/devtools/devtools_file_manager.cc",
"libcef/browser/devtools/devtools_file_manager.h",
"libcef/browser/devtools/devtools_frontend.cc",
"libcef/browser/devtools/devtools_frontend.h",
"libcef/browser/devtools/devtools_manager.cc",
"libcef/browser/devtools/devtools_manager.h",
"libcef/browser/devtools/devtools_manager_delegate.cc",
"libcef/browser/devtools/devtools_manager_delegate.h",
"libcef/browser/download_item_impl.cc",
@@ -473,6 +513,16 @@ static_library("libcef_static") {
"libcef/browser/javascript_dialog_manager.h",
"libcef/browser/media_capture_devices_dispatcher.cc",
"libcef/browser/media_capture_devices_dispatcher.h",
"libcef/browser/media_router/media_route_impl.cc",
"libcef/browser/media_router/media_route_impl.h",
"libcef/browser/media_router/media_router_impl.cc",
"libcef/browser/media_router/media_router_impl.h",
"libcef/browser/media_router/media_router_manager.cc",
"libcef/browser/media_router/media_router_manager.h",
"libcef/browser/media_router/media_sink_impl.cc",
"libcef/browser/media_router/media_sink_impl.h",
"libcef/browser/media_router/media_source_impl.cc",
"libcef/browser/media_router/media_source_impl.h",
"libcef/browser/menu_manager.cc",
"libcef/browser/menu_manager.h",
"libcef/browser/menu_model_impl.cc",
@@ -696,17 +746,6 @@ static_library("libcef_static") {
"libcef/renderer/url_loader_throttle_provider_impl.h",
"libcef/renderer/v8_impl.cc",
"libcef/renderer/v8_impl.h",
"//chrome/browser/local_discovery/service_discovery_device_lister.cc",
"//chrome/browser/local_discovery/service_discovery_device_lister.h",
"//chrome/browser/local_discovery/service_discovery_client_impl.cc",
"//chrome/browser/local_discovery/service_discovery_client_impl.h",
"//chrome/browser/local_discovery/service_discovery_client.cc",
"//chrome/browser/local_discovery/service_discovery_client.h",
"//chrome/browser/local_discovery/service_discovery_client_mdns.cc",
"//chrome/browser/local_discovery/service_discovery_client_mdns.h",
"//chrome/browser/local_discovery/service_discovery_shared_client.cc",
"//chrome/browser/local_discovery/service_discovery_shared_client.h",
]
configs += [
@@ -735,6 +774,8 @@ static_library("libcef_static") {
":cef_make_headers",
":cef_service_manifests",
":libcef_static_unittested",
# Generate API bindings for extensions.
# TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See
# libcef/common/extensions/api/README.txt for details.
@@ -775,7 +816,6 @@ static_library("libcef_static") {
"//components/safe_browsing/core/db:test_database_manager",
"//components/services/print_compositor/public/cpp",
"//components/services/print_compositor/public/mojom",
"//components/tracing",
"//components/update_client",
"//components/url_formatter",
"//components/user_prefs",
@@ -838,7 +878,7 @@ static_library("libcef_static") {
]
if (is_win) {
sources += gypi_paths2.includes_win + [
sources += includes_win + [
"libcef/browser/browser_main_win.cc",
"libcef/browser/native/browser_platform_delegate_native_win.cc",
"libcef/browser/native/browser_platform_delegate_native_win.h",
@@ -883,7 +923,7 @@ static_library("libcef_static") {
}
if (is_linux) {
sources += gypi_paths2.includes_linux + [
sources += includes_linux + [
"libcef/browser/native/browser_platform_delegate_native_linux.cc",
"libcef/browser/native/browser_platform_delegate_native_linux.h",
"libcef/browser/native/menu_runner_linux.cc",
@@ -915,7 +955,7 @@ static_library("libcef_static") {
}
if (is_mac) {
sources += gypi_paths2.includes_mac + [
sources += includes_mac + [
"libcef/browser/native/browser_platform_delegate_native_mac.h",
"libcef/browser/native/browser_platform_delegate_native_mac.mm",
"libcef/browser/native/file_dialog_runner_mac.h",
@@ -946,7 +986,7 @@ static_library("libcef_static") {
]
deps += [
"//components/crash/content/app",
"//components/crash/core/app",
"//components/crash/content/browser",
]
}
@@ -1078,8 +1118,8 @@ static_library("libcef_static") {
"//ui/aura/test/aura_test_utils.cc",
"//ui/aura/test/aura_test_utils.h",
# Part of //ui/events:test_support which is testingonly.
"//ui/events/test/platform_event_waiter.cc",
"//ui/events/test/platform_event_waiter.h",
"//ui/events/test/x11_event_waiter.cc",
"//ui/events/test/x11_event_waiter.h",
]
if (use_x11) {
@@ -1129,7 +1169,7 @@ config("libcef_dll_wrapper_config") {
# libcef_dll_wrapper target.
static_library("libcef_dll_wrapper") {
sources = gypi_paths2.includes_common +
sources = includes_common +
gypi_paths.autogen_cpp_includes +
gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes +
@@ -1485,11 +1525,29 @@ make_pack_header("strings") {
]
}
# Generate cef_api_hash.h.
action("make_api_hash_header") {
script = "tools/make_api_hash_header.py"
# List of all C API files that will be checked for changes by cef_api_hash.py.
inputs = gypi_paths2.includes_common_capi +
gypi_paths2.includes_linux_capi +
gypi_paths2.includes_mac_capi +
gypi_paths2.includes_win_capi +
gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes
include_dir = [ "include" ]
outputs = [ "$root_out_dir/includes/include/cef_api_hash.h" ]
args = rebase_path(outputs + include_dir, root_build_dir)
}
# Generate pack files and associated CEF header files.
group("cef_make_headers") {
deps = [
":make_pack_header_resources",
":make_pack_header_strings",
":make_api_hash_header",
]
}
@@ -1587,12 +1645,15 @@ if (is_mac) {
sources = [
"$root_out_dir/egl_intermediates/libswiftshader_libEGL.dylib",
"$root_out_dir/egl_intermediates/libswiftshader_libGLESv2.dylib",
"$root_out_dir/vk_intermediates/libvk_swiftshader.dylib",
"$root_out_dir/vk_intermediates/vk_swiftshader_icd.json",
]
outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
]
public_deps = [
"//ui/gl:swiftshader_library_copy",
"//ui/gl:swiftshader_egl_library_copy",
"//ui/gl:swiftshader_vk_library_copy",
]
}
}
@@ -1622,8 +1683,8 @@ if (is_mac) {
"Resources",
]
sources = gypi_paths2.includes_common +
gypi_paths2.includes_mac +
sources = includes_common +
includes_mac +
gypi_paths.autogen_cpp_includes +
gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes +
@@ -1666,7 +1727,7 @@ if (is_mac) {
}
} else {
shared_library("libcef") {
sources = gypi_paths2.includes_common +
sources = includes_common +
gypi_paths.autogen_cpp_includes +
gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes +
@@ -1678,15 +1739,10 @@ if (is_mac) {
]
if (is_win) {
sources += gypi_paths2.includes_win + [
sources += includes_win + [
"libcef_dll/libcef_dll.rc",
]
# This is a large module that can't do incremental linking in some cases.
configs -= [ "//build/config/win:default_incremental_linking" ]
configs +=
[ "//build/config/win:default_large_module_incremental_linking" ]
deps += [
# Bring in ui_unscaled_resources.rc which contains custom cursors.
# TODO(cef): Remove this once custom cursors can be loaded via
@@ -1894,8 +1950,8 @@ if (is_mac) {
cef_app("cefclient") {
helper_info_plist = "tests/cefclient/resources/mac/helper-Info.plist"
helper_sources = gypi_paths2.includes_mac +
gypi_paths2.includes_common +
helper_sources = includes_common +
includes_mac +
gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_mac +
gypi_paths2.shared_sources_common +
@@ -1908,8 +1964,8 @@ if (is_mac) {
]
info_plist = "tests/cefclient/resources/mac/Info.plist"
sources = gypi_paths2.includes_mac +
gypi_paths2.includes_common +
sources = includes_common +
includes_mac +
gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_mac +
gypi_paths2.shared_sources_browser +
@@ -1967,8 +2023,8 @@ if (is_mac) {
cef_app("cefsimple") {
helper_info_plist = "tests/cefsimple/mac/helper-Info.plist"
helper_sources = gypi_paths2.includes_mac +
gypi_paths2.includes_common +
helper_sources = includes_common +
includes_mac +
gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_mac +
gypi_paths2.cefsimple_sources_mac_helper
@@ -1977,8 +2033,8 @@ if (is_mac) {
]
info_plist = "tests/cefsimple/mac/Info.plist"
sources = gypi_paths2.includes_mac +
gypi_paths2.includes_common +
sources = includes_common +
includes_mac +
gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_mac +
gypi_paths2.cefsimple_sources_common +
@@ -2044,8 +2100,8 @@ if (is_mac) {
]
info_plist = "tests/ceftests/resources/mac/Info.plist"
sources = gypi_paths2.includes_mac +
gypi_paths2.includes_common +
sources = includes_common +
includes_mac +
gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_mac +
gypi_paths2.shared_sources_browser +
@@ -2113,7 +2169,7 @@ if (is_mac) {
}
executable("cefclient") {
sources = gypi_paths2.includes_common +
sources = includes_common +
gypi_paths2.includes_wrapper +
gypi_paths2.shared_sources_browser +
gypi_paths2.shared_sources_common +
@@ -2132,7 +2188,7 @@ if (is_mac) {
]
if (is_win) {
sources += gypi_paths2.includes_win +
sources += includes_win +
gypi_paths2.shared_sources_win +
gypi_paths2.cefclient_sources_win
@@ -2167,7 +2223,7 @@ if (is_mac) {
}
if (is_linux) {
sources += gypi_paths2.includes_linux +
sources += includes_linux +
gypi_paths2.shared_sources_linux +
gypi_paths2.cefclient_sources_linux
@@ -2206,7 +2262,7 @@ if (is_mac) {
#
executable("cefsimple") {
sources = gypi_paths2.includes_common +
sources = includes_common +
gypi_paths2.includes_wrapper +
gypi_paths2.cefsimple_sources_common
@@ -2220,7 +2276,7 @@ if (is_mac) {
]
if (is_win) {
sources += gypi_paths2.includes_win +
sources += includes_win +
gypi_paths2.cefsimple_sources_win
# Set /SUBSYSTEM:WINDOWS.
@@ -2240,7 +2296,7 @@ if (is_mac) {
}
if (is_linux) {
sources += gypi_paths2.includes_linux +
sources += includes_linux +
gypi_paths2.cefsimple_sources_linux
if (use_x11) {
@@ -2271,7 +2327,7 @@ if (is_mac) {
executable("ceftests") {
testonly = true
sources = gypi_paths2.includes_common +
sources = includes_common +
gypi_paths2.includes_wrapper +
gypi_paths2.shared_sources_browser +
gypi_paths2.shared_sources_common +

View File

@@ -7,5 +7,6 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/81.0.4044.0'
'chromium_checkout': 'refs/tags/83.0.4103.106',
'depot_tools_checkout': 'fc5e103221'
}

View File

@@ -57,7 +57,9 @@
'content/shell/renderer/shell_*',
'content/shell/utility/shell_*',
'extensions/shell/*',
'net/base/features.cc',
'net/cookies/cookie_store.h',
'services/network/public/cpp/features.cc',
'ui/base/ui_base_features.cc',
],
# Patterns that should not be found in the chromium/src directory after

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=98198bc4243deb46c848735f0d5499aa4891e535$
# $hash=72268a78a76d7d91b8ad47f6b6e9f6d9cb04d9cf$
#
{
@@ -16,6 +16,7 @@
'autogen_cpp_includes': [
'include/cef_accessibility_handler.h',
'include/cef_app.h',
'include/cef_audio_handler.h',
'include/cef_auth_callback.h',
'include/cef_browser.h',
'include/cef_browser_process_handler.h',
@@ -25,6 +26,7 @@
'include/cef_context_menu_handler.h',
'include/cef_cookie.h',
'include/cef_crash_util.h',
'include/cef_devtools_message_observer.h',
'include/cef_dialog_handler.h',
'include/cef_display_handler.h',
'include/cef_dom.h',
@@ -43,6 +45,7 @@
'include/cef_keyboard_handler.h',
'include/cef_life_span_handler.h',
'include/cef_load_handler.h',
'include/cef_media_router.h',
'include/cef_menu_model.h',
'include/cef_menu_model_delegate.h',
'include/cef_navigation_entry.h',
@@ -53,6 +56,7 @@
'include/cef_print_settings.h',
'include/cef_process_message.h',
'include/cef_process_util.h',
'include/cef_registration.h',
'include/cef_render_handler.h',
'include/cef_render_process_handler.h',
'include/cef_request.h',
@@ -109,6 +113,7 @@
'autogen_capi_includes': [
'include/capi/cef_accessibility_handler_capi.h',
'include/capi/cef_app_capi.h',
'include/capi/cef_audio_handler_capi.h',
'include/capi/cef_auth_callback_capi.h',
'include/capi/cef_browser_capi.h',
'include/capi/cef_browser_process_handler_capi.h',
@@ -118,6 +123,7 @@
'include/capi/cef_context_menu_handler_capi.h',
'include/capi/cef_cookie_capi.h',
'include/capi/cef_crash_util_capi.h',
'include/capi/cef_devtools_message_observer_capi.h',
'include/capi/cef_dialog_handler_capi.h',
'include/capi/cef_display_handler_capi.h',
'include/capi/cef_dom_capi.h',
@@ -136,6 +142,7 @@
'include/capi/cef_keyboard_handler_capi.h',
'include/capi/cef_life_span_handler_capi.h',
'include/capi/cef_load_handler_capi.h',
'include/capi/cef_media_router_capi.h',
'include/capi/cef_menu_model_capi.h',
'include/capi/cef_menu_model_delegate_capi.h',
'include/capi/cef_navigation_entry_capi.h',
@@ -146,6 +153,7 @@
'include/capi/cef_print_settings_capi.h',
'include/capi/cef_process_message_capi.h',
'include/capi/cef_process_util_capi.h',
'include/capi/cef_registration_capi.h',
'include/capi/cef_render_handler_capi.h',
'include/capi/cef_render_process_handler_capi.h',
'include/capi/cef_request_capi.h',
@@ -204,6 +212,8 @@
'libcef_dll/ctocpp/accessibility_handler_ctocpp.h',
'libcef_dll/ctocpp/app_ctocpp.cc',
'libcef_dll/ctocpp/app_ctocpp.h',
'libcef_dll/ctocpp/audio_handler_ctocpp.cc',
'libcef_dll/ctocpp/audio_handler_ctocpp.h',
'libcef_dll/cpptoc/auth_callback_cpptoc.cc',
'libcef_dll/cpptoc/auth_callback_cpptoc.h',
'libcef_dll/cpptoc/before_download_callback_cpptoc.cc',
@@ -252,6 +262,8 @@
'libcef_dll/ctocpp/domvisitor_ctocpp.h',
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.cc',
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.h',
'libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.cc',
'libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.h',
'libcef_dll/ctocpp/dialog_handler_ctocpp.cc',
'libcef_dll/ctocpp/dialog_handler_ctocpp.h',
'libcef_dll/cpptoc/dictionary_value_cpptoc.cc',
@@ -308,6 +320,20 @@
'libcef_dll/cpptoc/list_value_cpptoc.h',
'libcef_dll/ctocpp/load_handler_ctocpp.cc',
'libcef_dll/ctocpp/load_handler_ctocpp.h',
'libcef_dll/ctocpp/media_observer_ctocpp.cc',
'libcef_dll/ctocpp/media_observer_ctocpp.h',
'libcef_dll/cpptoc/media_route_cpptoc.cc',
'libcef_dll/cpptoc/media_route_cpptoc.h',
'libcef_dll/ctocpp/media_route_create_callback_ctocpp.cc',
'libcef_dll/ctocpp/media_route_create_callback_ctocpp.h',
'libcef_dll/cpptoc/media_router_cpptoc.cc',
'libcef_dll/cpptoc/media_router_cpptoc.h',
'libcef_dll/cpptoc/media_sink_cpptoc.cc',
'libcef_dll/cpptoc/media_sink_cpptoc.h',
'libcef_dll/ctocpp/media_sink_device_info_callback_ctocpp.cc',
'libcef_dll/ctocpp/media_sink_device_info_callback_ctocpp.h',
'libcef_dll/cpptoc/media_source_cpptoc.cc',
'libcef_dll/cpptoc/media_source_cpptoc.h',
'libcef_dll/cpptoc/views/menu_button_cpptoc.cc',
'libcef_dll/cpptoc/views/menu_button_cpptoc.h',
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc',
@@ -346,6 +372,8 @@
'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/cpptoc/registration_cpptoc.cc',
'libcef_dll/cpptoc/registration_cpptoc.h',
'libcef_dll/ctocpp/render_handler_ctocpp.cc',
'libcef_dll/ctocpp/render_handler_ctocpp.h',
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
@@ -494,6 +522,8 @@
'libcef_dll/cpptoc/accessibility_handler_cpptoc.h',
'libcef_dll/cpptoc/app_cpptoc.cc',
'libcef_dll/cpptoc/app_cpptoc.h',
'libcef_dll/cpptoc/audio_handler_cpptoc.cc',
'libcef_dll/cpptoc/audio_handler_cpptoc.h',
'libcef_dll/ctocpp/auth_callback_ctocpp.cc',
'libcef_dll/ctocpp/auth_callback_ctocpp.h',
'libcef_dll/ctocpp/before_download_callback_ctocpp.cc',
@@ -542,6 +572,8 @@
'libcef_dll/cpptoc/domvisitor_cpptoc.h',
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.cc',
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.h',
'libcef_dll/cpptoc/dev_tools_message_observer_cpptoc.cc',
'libcef_dll/cpptoc/dev_tools_message_observer_cpptoc.h',
'libcef_dll/cpptoc/dialog_handler_cpptoc.cc',
'libcef_dll/cpptoc/dialog_handler_cpptoc.h',
'libcef_dll/ctocpp/dictionary_value_ctocpp.cc',
@@ -598,6 +630,20 @@
'libcef_dll/ctocpp/list_value_ctocpp.h',
'libcef_dll/cpptoc/load_handler_cpptoc.cc',
'libcef_dll/cpptoc/load_handler_cpptoc.h',
'libcef_dll/cpptoc/media_observer_cpptoc.cc',
'libcef_dll/cpptoc/media_observer_cpptoc.h',
'libcef_dll/ctocpp/media_route_ctocpp.cc',
'libcef_dll/ctocpp/media_route_ctocpp.h',
'libcef_dll/cpptoc/media_route_create_callback_cpptoc.cc',
'libcef_dll/cpptoc/media_route_create_callback_cpptoc.h',
'libcef_dll/ctocpp/media_router_ctocpp.cc',
'libcef_dll/ctocpp/media_router_ctocpp.h',
'libcef_dll/ctocpp/media_sink_ctocpp.cc',
'libcef_dll/ctocpp/media_sink_ctocpp.h',
'libcef_dll/cpptoc/media_sink_device_info_callback_cpptoc.cc',
'libcef_dll/cpptoc/media_sink_device_info_callback_cpptoc.h',
'libcef_dll/ctocpp/media_source_ctocpp.cc',
'libcef_dll/ctocpp/media_source_ctocpp.h',
'libcef_dll/ctocpp/views/menu_button_ctocpp.cc',
'libcef_dll/ctocpp/views/menu_button_ctocpp.h',
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc',
@@ -636,6 +682,8 @@
'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/ctocpp/registration_ctocpp.cc',
'libcef_dll/ctocpp/registration_ctocpp.h',
'libcef_dll/cpptoc/render_handler_cpptoc.cc',
'libcef_dll/cpptoc/render_handler_cpptoc.h',
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',

View File

@@ -39,19 +39,21 @@
'include/cef_config.h',
'include/cef_version.h',
'include/internal/cef_export.h',
'include/internal/cef_logging_internal.h',
'include/internal/cef_ptr.h',
'include/internal/cef_string_wrappers.h',
'include/internal/cef_types_wrappers.h',
],
'includes_common_capi': [
'include/internal/cef_logging_internal.h',
'include/internal/cef_string.h',
'include/internal/cef_string_list.h',
'include/internal/cef_string_map.h',
'include/internal/cef_string_multimap.h',
'include/internal/cef_string_types.h',
'include/internal/cef_string_wrappers.h',
'include/internal/cef_thread_internal.h',
'include/internal/cef_time.h',
'include/internal/cef_trace_event_internal.h',
'include/internal/cef_types.h',
'include/internal/cef_types_wrappers.h',
],
'includes_capi': [
'include/capi/cef_base_capi.h',
@@ -75,15 +77,19 @@
'include/base/internal/cef_atomicops_x86_msvc.h',
'include/base/internal/cef_bind_internal_win.h',
'include/cef_sandbox_win.h',
'include/internal/cef_types_win.h',
'include/internal/cef_win.h',
],
'includes_win_capi': [
'include/internal/cef_types_win.h',
],
'includes_mac': [
'include/base/internal/cef_atomicops_atomicword_compat.h',
'include/base/internal/cef_atomicops_mac.h',
'include/cef_application_mac.h',
'include/cef_sandbox_mac.h',
'include/internal/cef_mac.h',
],
'includes_mac_capi': [
'include/internal/cef_types_mac.h',
],
'includes_linux': [
@@ -92,6 +98,8 @@
'include/base/internal/cef_atomicops_arm64_gcc.h',
'include/base/internal/cef_atomicops_x86_gcc.h',
'include/internal/cef_linux.h',
],
'includes_linux_capi': [
'include/internal/cef_types_linux.h',
],
'libcef_sources_common': [
@@ -238,6 +246,8 @@
'tests/cefclient/browser/main_context.h',
'tests/cefclient/browser/main_context_impl.cc',
'tests/cefclient/browser/main_context_impl.h',
'tests/cefclient/browser/media_router_test.cc',
'tests/cefclient/browser/media_router_test.h',
'tests/cefclient/browser/osr_dragdrop_events.h',
'tests/cefclient/browser/osr_renderer.h',
'tests/cefclient/browser/osr_renderer.cc',
@@ -287,6 +297,7 @@
'tests/cefclient/resources/drm.html',
'tests/cefclient/resources/localstorage.html',
'tests/cefclient/resources/logo.png',
'tests/cefclient/resources/media_router.html',
'tests/cefclient/resources/menu_icon.1x.png',
'tests/cefclient/resources/menu_icon.2x.png',
'tests/cefclient/resources/other_tests.html',
@@ -455,9 +466,11 @@
'tests/cefsimple/simple_handler_linux.cc',
],
'ceftests_sources_common': [
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/browser_info_map_unittest.cc',
'tests/ceftests/command_line_unittest.cc',
'tests/ceftests/cookie_unittest.cc',
'tests/ceftests/devtools_message_unittest.cc',
'tests/ceftests/dialog_unittest.cc',
'tests/ceftests/display_unittest.cc',
'tests/ceftests/dom_unittest.cc',
@@ -554,6 +567,7 @@
'tests/shared/browser/resource_util.h',
'tests/shared/browser/resource_util_mac.mm',
'tests/shared/browser/resource_util_posix.cc',
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/client_app_delegates.cc',
'tests/ceftests/cookie_unittest.cc',
'tests/ceftests/dom_unittest.cc',

View File

@@ -0,0 +1,121 @@
// Copyright (c) 2020 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.
//
// $hash=430877d950508a545d0baa18c8c8c0d2d183fec4$
//
#ifndef CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Implement this structure to handle audio events.
///
typedef struct _cef_audio_handler_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called on the UI thread to allow configuration of audio stream parameters.
// Return true (1) to proceed with audio stream capture, or false (0) to
// cancel it. All members of |params| can optionally be configured here, but
// they are also pre-filled with some sensible defaults.
///
int(CEF_CALLBACK* get_audio_parameters)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
cef_audio_parameters_t* params);
///
// Called on a browser audio capture thread when the browser starts streaming
// audio. OnAudioSteamStopped will always be called after
// OnAudioStreamStarted; both functions may be called multiple times for the
// same browser. |params| contains the audio parameters like sample rate and
// channel layout. |channels| is the number of channels.
///
void(CEF_CALLBACK* on_audio_stream_started)(
struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const cef_audio_parameters_t* params,
int channels);
///
// Called on the audio stream thread when a PCM packet is received for the
// stream. |data| is an array representing the raw PCM data as a floating
// point type, i.e. 4-byte value(s). |frames| is the number of frames in the
// PCM packet. |pts| is the presentation timestamp (in milliseconds since the
// Unix Epoch) and represents the time at which the decompressed packet should
// be presented to the user. Based on |frames| and the |channel_layout| value
// passed to OnAudioStreamStarted you can calculate the size of the |data|
// array in bytes.
///
void(CEF_CALLBACK* on_audio_stream_packet)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const float** data,
int frames,
int64 pts);
///
// Called on the UI thread when the stream has stopped. OnAudioSteamStopped
// will always be called after OnAudioStreamStarted; both functions may be
// called multiple times for the same stream.
///
void(CEF_CALLBACK* on_audio_stream_stopped)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser);
///
// Called on the UI or audio stream thread when an error occurred. During the
// stream creation phase this callback will be called on the UI thread while
// in the capturing phase it will be called on the audio stream thread. The
// stream will be stopped immediately.
///
void(CEF_CALLBACK* on_audio_stream_error)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const cef_string_t* message);
} cef_audio_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=ba4033eaf40a8ee24408b89b78496bf1381e7e6b$
// $hash=6cb00a0fa3631a46903abb3a783f315895511db2$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
@@ -41,10 +41,12 @@
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_devtools_message_observer_capi.h"
#include "include/capi/cef_drag_data_capi.h"
#include "include/capi/cef_frame_capi.h"
#include "include/capi/cef_image_capi.h"
#include "include/capi/cef_navigation_entry_capi.h"
#include "include/capi/cef_registration_capi.h"
#include "include/capi/cef_request_context_capi.h"
#ifdef __cplusplus
@@ -484,6 +486,71 @@ typedef struct _cef_browser_host_t {
///
int(CEF_CALLBACK* has_dev_tools)(struct _cef_browser_host_t* self);
///
// Send a function call message over the DevTools protocol. |message| must be
// a UTF8-encoded JSON dictionary that contains "id" (int), "function"
// (string) and "params" (dictionary, optional) values. See the DevTools
// protocol documentation at https://chromedevtools.github.io/devtools-
// protocol/ for details of supported functions and the expected "params"
// dictionary contents. |message| will be copied if necessary. This function
// will return true (1) if called on the UI thread and the message was
// successfully submitted for validation, otherwise false (0). Validation will
// be applied asynchronously and any messages that fail due to formatting
// errors or missing parameters may be discarded without notification. Prefer
// ExecuteDevToolsMethod if a more structured approach to message formatting
// is desired.
//
// Every valid function call will result in an asynchronous function result or
// error message that references the sent message "id". Event messages are
// received while notifications are enabled (for example, between function
// calls for "Page.enable" and "Page.disable"). All received messages will be
// delivered to the observer(s) registered with AddDevToolsMessageObserver.
// See cef_dev_tools_message_observer_t::OnDevToolsMessage documentation for
// details of received message contents.
//
// Usage of the SendDevToolsMessage, ExecuteDevToolsMethod and
// AddDevToolsMessageObserver functions does not require an active DevTools
// front-end or remote-debugging session. Other active DevTools sessions will
// continue to function independently. However, any modification of global
// browser state by one session may not be reflected in the UI of other
// sessions.
//
// Communication with the DevTools front-end (when displayed) can be logged
// for development purposes by passing the `--devtools-protocol-log-
// file=<path>` command-line flag.
///
int(CEF_CALLBACK* send_dev_tools_message)(struct _cef_browser_host_t* self,
const void* message,
size_t message_size);
///
// Execute a function call over the DevTools protocol. This is a more
// structured version of SendDevToolsMessage. |message_id| is an incremental
// number that uniquely identifies the message (pass 0 to have the next number
// assigned automatically based on previous values). |function| is the
// function name. |params| are the function parameters, which may be NULL. See
// the DevTools protocol documentation (linked above) for details of supported
// functions and the expected |params| dictionary contents. This function will
// return the assigned message ID if called on the UI thread and the message
// was successfully submitted for validation, otherwise 0. See the
// SendDevToolsMessage documentation for additional usage information.
///
int(CEF_CALLBACK* execute_dev_tools_method)(
struct _cef_browser_host_t* self,
int message_id,
const cef_string_t* method,
struct _cef_dictionary_value_t* params);
///
// Add an observer for DevTools protocol messages (function results and
// events). The observer will remain registered until the returned
// Registration object is destroyed. See the SendDevToolsMessage documentation
// for additional usage information.
///
struct _cef_registration_t*(CEF_CALLBACK* add_dev_tools_message_observer)(
struct _cef_browser_host_t* self,
struct _cef_dev_tools_message_observer_t* observer);
///
// Retrieve a snapshot of current navigation entries as values sent to the
// specified visitor. If |current_only| is true (1) only the current

View File

@@ -33,13 +33,14 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=6a0312765614a697d56e87c8503afba8404bb08b$
// $hash=8d4cb3e0bbf230804c93898daa4a8b2866a2c1ce$
//
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
#pragma once
#include "include/capi/cef_audio_handler_capi.h"
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_context_menu_handler_capi.h"
#include "include/capi/cef_dialog_handler_capi.h"
@@ -69,6 +70,12 @@ typedef struct _cef_client_t {
///
cef_base_ref_counted_t base;
///
// Return the handler for audio rendering events.
///
struct _cef_audio_handler_t*(CEF_CALLBACK* get_audio_handler)(
struct _cef_client_t* self);
///
// Return the handler for context menus. If no handler is provided the default
// implementation will be used.

View File

@@ -0,0 +1,147 @@
// Copyright (c) 2020 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.
//
// $hash=86906c2e971fea7e479738f59bbf85d71ce31953$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_browser_t;
///
// Callback structure for cef_browser_host_t::AddDevToolsMessageObserver. The
// functions of this structure will be called on the browser process UI thread.
///
typedef struct _cef_dev_tools_message_observer_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Method that will be called on receipt of a DevTools protocol message.
// |browser| is the originating browser instance. |message| is a UTF8-encoded
// JSON dictionary representing either a function result or an event.
// |message| is only valid for the scope of this callback and should be copied
// if necessary. Return true (1) if the message was handled or false (0) if
// the message should be further processed and passed to the
// OnDevToolsMethodResult or OnDevToolsEvent functions as appropriate.
//
// Method result dictionaries include an "id" (int) value that identifies the
// orginating function call sent from cef_browser_host_t::SendDevToolsMessage,
// and optionally either a "result" (dictionary) or "error" (dictionary)
// value. The "error" dictionary will contain "code" (int) and "message"
// (string) values. Event dictionaries include a "function" (string) value and
// optionally a "params" (dictionary) value. See the DevTools protocol
// documentation at https://chromedevtools.github.io/devtools-protocol/ for
// details of supported function calls and the expected "result" or "params"
// dictionary contents. JSON dictionaries can be parsed using the CefParseJSON
// function if desired, however be aware of performance considerations when
// parsing large messages (some of which may exceed 1MB in size).
///
int(CEF_CALLBACK* on_dev_tools_message)(
struct _cef_dev_tools_message_observer_t* self,
struct _cef_browser_t* browser,
const void* message,
size_t message_size);
///
// Method that will be called after attempted execution of a DevTools protocol
// function. |browser| is the originating browser instance. |message_id| is
// the "id" value that identifies the originating function call message. If
// the function succeeded |success| will be true (1) and |result| will be the
// UTF8-encoded JSON "result" dictionary value (which may be NULL). If the
// function failed |success| will be false (0) and |result| will be the
// UTF8-encoded JSON "error" dictionary value. |result| is only valid for the
// scope of this callback and should be copied if necessary. See the
// OnDevToolsMessage documentation for additional details on |result|
// contents.
///
void(CEF_CALLBACK* on_dev_tools_method_result)(
struct _cef_dev_tools_message_observer_t* self,
struct _cef_browser_t* browser,
int message_id,
int success,
const void* result,
size_t result_size);
///
// Method that will be called on receipt of a DevTools protocol event.
// |browser| is the originating browser instance. |function| is the "function"
// value. |params| is the UTF8-encoded JSON "params" dictionary value (which
// may be NULL). |params| is only valid for the scope of this callback and
// should be copied if necessary. See the OnDevToolsMessage documentation for
// additional details on |params| contents.
///
void(CEF_CALLBACK* on_dev_tools_event)(
struct _cef_dev_tools_message_observer_t* self,
struct _cef_browser_t* browser,
const cef_string_t* method,
const void* params,
size_t params_size);
///
// Method that will be called when the DevTools agent has attached. |browser|
// is the originating browser instance. This will generally occur in response
// to the first message sent while the agent is detached.
///
void(CEF_CALLBACK* on_dev_tools_agent_attached)(
struct _cef_dev_tools_message_observer_t* self,
struct _cef_browser_t* browser);
///
// Method that will be called when the DevTools agent has detached. |browser|
// is the originating browser instance. Any function results that were pending
// before the agent became detached will not be delivered, and any active
// event subscriptions will be canceled.
///
void(CEF_CALLBACK* on_dev_tools_agent_detached)(
struct _cef_dev_tools_message_observer_t* self,
struct _cef_browser_t* browser);
} cef_dev_tools_message_observer_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_

View File

@@ -0,0 +1,355 @@
// Copyright (c) 2020 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.
//
// $hash=9d5077fdb3fe7fa0ff1141f839988ac821eba4bf$
//
#ifndef CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_registration_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_media_observer_t;
struct _cef_media_route_create_callback_t;
struct _cef_media_route_t;
struct _cef_media_sink_device_info_callback_t;
struct _cef_media_sink_t;
struct _cef_media_source_t;
///
// Supports discovery of and communication with media devices on the local
// network via the Cast and DIAL protocols. The functions of this structure may
// be called on any browser process thread unless otherwise indicated.
///
typedef struct _cef_media_router_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Add an observer for MediaRouter events. The observer will remain registered
// until the returned Registration object is destroyed.
///
struct _cef_registration_t*(CEF_CALLBACK* add_observer)(
struct _cef_media_router_t* self,
struct _cef_media_observer_t* observer);
///
// Returns a MediaSource object for the specified media source URN. Supported
// URN schemes include "cast:" and "dial:", and will be already known by the
// client application (e.g. "cast:<appId>?clientId=<clientId>").
///
struct _cef_media_source_t*(CEF_CALLBACK* get_source)(
struct _cef_media_router_t* self,
const cef_string_t* urn);
///
// Trigger an asynchronous call to cef_media_observer_t::OnSinks on all
// registered observers.
///
void(CEF_CALLBACK* notify_current_sinks)(struct _cef_media_router_t* self);
///
// Create a new route between |source| and |sink|. Source and sink must be
// valid, compatible (as reported by cef_media_sink_t::IsCompatibleWith), and
// a route between them must not already exist. |callback| will be executed on
// success or failure. If route creation succeeds it will also trigger an
// asynchronous call to cef_media_observer_t::OnRoutes on all registered
// observers.
///
void(CEF_CALLBACK* create_route)(
struct _cef_media_router_t* self,
struct _cef_media_source_t* source,
struct _cef_media_sink_t* sink,
struct _cef_media_route_create_callback_t* callback);
///
// Trigger an asynchronous call to cef_media_observer_t::OnRoutes on all
// registered observers.
///
void(CEF_CALLBACK* notify_current_routes)(struct _cef_media_router_t* self);
} cef_media_router_t;
///
// Returns the MediaRouter object associated with the global request context.
// Equivalent to calling cef_request_context_t::cef_request_context_get_global_c
// ontext()->get_media_router().
///
CEF_EXPORT cef_media_router_t* cef_media_router_get_global();
///
// Implemented by the client to observe MediaRouter events and registered via
// cef_media_router_t::AddObserver. The functions of this structure will be
// called on the browser process UI thread.
///
typedef struct _cef_media_observer_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// The list of available media sinks has changed or
// cef_media_router_t::NotifyCurrentSinks was called.
///
void(CEF_CALLBACK* on_sinks)(struct _cef_media_observer_t* self,
size_t sinksCount,
struct _cef_media_sink_t* const* sinks);
///
// The list of available media routes has changed or
// cef_media_router_t::NotifyCurrentRoutes was called.
///
void(CEF_CALLBACK* on_routes)(struct _cef_media_observer_t* self,
size_t routesCount,
struct _cef_media_route_t* const* routes);
///
// The connection state of |route| has changed.
///
void(CEF_CALLBACK* on_route_state_changed)(
struct _cef_media_observer_t* self,
struct _cef_media_route_t* route,
cef_media_route_connection_state_t state);
///
// A message was recieved over |route|. |message| is only valid for the scope
// of this callback and should be copied if necessary.
///
void(CEF_CALLBACK* on_route_message_received)(
struct _cef_media_observer_t* self,
struct _cef_media_route_t* route,
const void* message,
size_t message_size);
} cef_media_observer_t;
///
// Represents the route between a media source and sink. Instances of this
// object are created via cef_media_router_t::CreateRoute and retrieved via
// cef_media_observer_t::OnRoutes. Contains the status and metadata of a routing
// operation. The functions of this structure may be called on any browser
// process thread unless otherwise indicated.
///
typedef struct _cef_media_route_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns the ID for this route.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_route_t* self);
///
// Returns the source associated with this route.
///
struct _cef_media_source_t*(CEF_CALLBACK* get_source)(
struct _cef_media_route_t* self);
///
// Returns the sink associated with this route.
///
struct _cef_media_sink_t*(CEF_CALLBACK* get_sink)(
struct _cef_media_route_t* self);
///
// Send a message over this route. |message| will be copied if necessary.
///
void(CEF_CALLBACK* send_route_message)(struct _cef_media_route_t* self,
const void* message,
size_t message_size);
///
// Terminate this route. Will result in an asynchronous call to
// cef_media_observer_t::OnRoutes on all registered observers.
///
void(CEF_CALLBACK* terminate)(struct _cef_media_route_t* self);
} cef_media_route_t;
///
// Callback structure for cef_media_router_t::CreateRoute. The functions of this
// structure will be called on the browser process UI thread.
///
typedef struct _cef_media_route_create_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Method that will be executed when the route creation has finished. |result|
// will be CEF_MRCR_OK if the route creation succeeded. |error| will be a
// description of the error if the route creation failed. |route| is the
// resulting route, or NULL if the route creation failed.
///
void(CEF_CALLBACK* on_media_route_create_finished)(
struct _cef_media_route_create_callback_t* self,
cef_media_route_create_result_t result,
const cef_string_t* error,
struct _cef_media_route_t* route);
} cef_media_route_create_callback_t;
///
// Represents a sink to which media can be routed. Instances of this object are
// retrieved via cef_media_observer_t::OnSinks. The functions of this structure
// may be called on any browser process thread unless otherwise indicated.
///
typedef struct _cef_media_sink_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns the ID for this sink.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_sink_t* self);
///
// Returns true (1) if this sink is valid.
///
int(CEF_CALLBACK* is_valid)(struct _cef_media_sink_t* self);
///
// Returns the name of this sink.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_media_sink_t* self);
///
// Returns the description of this sink.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_description)(
struct _cef_media_sink_t* self);
///
// Returns the icon type for this sink.
///
cef_media_sink_icon_type_t(CEF_CALLBACK* get_icon_type)(
struct _cef_media_sink_t* self);
///
// Asynchronously retrieves device info.
///
void(CEF_CALLBACK* get_device_info)(
struct _cef_media_sink_t* self,
struct _cef_media_sink_device_info_callback_t* callback);
///
// Returns true (1) if this sink accepts content via Cast.
///
int(CEF_CALLBACK* is_cast_sink)(struct _cef_media_sink_t* self);
///
// Returns true (1) if this sink accepts content via DIAL.
///
int(CEF_CALLBACK* is_dial_sink)(struct _cef_media_sink_t* self);
///
// Returns true (1) if this sink is compatible with |source|.
///
int(CEF_CALLBACK* is_compatible_with)(struct _cef_media_sink_t* self,
struct _cef_media_source_t* source);
} cef_media_sink_t;
///
// Callback structure for cef_media_sink_t::GetDeviceInfo. The functions of this
// structure will be called on the browser process UI thread.
///
typedef struct _cef_media_sink_device_info_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Method that will be executed asyncronously once device information has been
// retrieved.
///
void(CEF_CALLBACK* on_media_sink_device_info)(
struct _cef_media_sink_device_info_callback_t* self,
const struct _cef_media_sink_device_info_t* device_info);
} cef_media_sink_device_info_callback_t;
///
// Represents a source from which media can be routed. Instances of this object
// are retrieved via cef_media_router_t::GetSource. The functions of this
// structure may be called on any browser process thread unless otherwise
// indicated.
///
typedef struct _cef_media_source_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns the ID (media source URN or URL) for this source.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_source_t* self);
///
// Returns true (1) if this source is valid.
///
int(CEF_CALLBACK* is_valid)(struct _cef_media_source_t* self);
///
// Returns true (1) if this source outputs its content via Cast.
///
int(CEF_CALLBACK* is_cast_source)(struct _cef_media_source_t* self);
///
// Returns true (1) if this source outputs its content via DIAL.
///
int(CEF_CALLBACK* is_dial_source)(struct _cef_media_source_t* self);
} cef_media_source_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=3bc4225f43428d8a3a24dcac1830dafac18b0caf$
// $hash=14cf03e02d8ca3416e65f756470afd8185c7bc78$
//
#ifndef CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_
@@ -140,6 +140,16 @@ CEF_EXPORT struct _cef_value_t* cef_parse_json(
const cef_string_t* json_string,
cef_json_parser_options_t options);
///
// Parses the specified UTF8-encoded |json| buffer of size |json_size| and
// returns a dictionary or list representation. If JSON parsing fails this
// function returns NULL.
///
CEF_EXPORT struct _cef_value_t* cef_parse_json_buffer(
const void* json,
size_t json_size,
cef_json_parser_options_t options);
///
// Parses the specified |json_string| and returns a dictionary or list
// representation. If JSON parsing fails this function returns NULL and

View File

@@ -0,0 +1,63 @@
// Copyright (c) 2020 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.
//
// $hash=029e237cf80f94a25453bac5a9b1e0765bb56f37$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Generic callback structure used for managing the lifespan of a registration.
///
typedef struct _cef_registration_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
} cef_registration_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=2b01472d9b9a8cc9d1b2e669c91c2849bdb162e9$
// $hash=7ce0953f069204a4dd2037c4a05ac9454c5e66a6$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@@ -44,6 +44,7 @@
#include "include/capi/cef_cookie_capi.h"
#include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/capi/cef_media_router_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
@@ -353,6 +354,12 @@ typedef struct _cef_request_context_t {
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
struct _cef_request_context_t* self,
const cef_string_t* extension_id);
///
// Returns the MediaRouter object associated with this context.
///
struct _cef_media_router_t*(CEF_CALLBACK* get_media_router)(
struct _cef_request_context_t* self);
} cef_request_context_t;
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=a28219cc8c1cb53faacaf236374c3cf2c0c45bef$
// $hash=0167eb1abe614bd6391d273a8085fa3e53e7c217$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_
@@ -253,6 +253,14 @@ typedef struct _cef_request_handler_t {
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
cef_termination_status_t status);
///
// Called on the browser process UI thread when the window.document object of
// the main frame has been created.
///
void(CEF_CALLBACK* on_document_available_in_main_frame)(
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser);
} cef_request_handler_t;
#ifdef __cplusplus

View File

@@ -29,12 +29,7 @@
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=06d0c1ccfa43926a01cbeb3ec95ff2a001fd0b45$
// This file was generated by the make_api_hash_header.py tool.
//
#ifndef CEF_INCLUDE_API_HASH_H_
@@ -47,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "3ad9591f7024619a1e2fd796c7ad51ae3a34abbb"
#define CEF_API_HASH_UNIVERSAL "385d8af3c6da76f123f3aa292d3a3308ef456297"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "3b8e38ae40c1a930227c6277c39dbc24081ccec1"
#define CEF_API_HASH_PLATFORM "4bb528b0bb076ed5177d6581cfca12dd7b2fee04"
#elif defined(OS_MACOSX)
#define CEF_API_HASH_PLATFORM "4a77f1908fabccdb01a2d3bdbede5ca09fbaa394"
#define CEF_API_HASH_PLATFORM "f6580fc0858f3580b7d25e1d094dd0a336132522"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "434da6be7db70fd90c4265118ac47ace4073c6ae"
#define CEF_API_HASH_PLATFORM "83f3053840abba3b83e43ade58230f10b48591dd"
#endif
#ifdef __cplusplus

111
include/cef_audio_handler.h Normal file
View File

@@ -0,0 +1,111 @@
// Copyright (c) 2019 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_AUDIO_HANDLER_H_
#define CEF_INCLUDE_CEF_AUDIO_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
///
// Implement this interface to handle audio events.
///
/*--cef(source=client)--*/
class CefAudioHandler : public virtual CefBaseRefCounted {
public:
typedef cef_channel_layout_t ChannelLayout;
///
// Called on the UI thread to allow configuration of audio stream parameters.
// Return true to proceed with audio stream capture, or false to cancel it.
// All members of |params| can optionally be configured here, but they are
// also pre-filled with some sensible defaults.
///
/*--cef()--*/
virtual bool GetAudioParameters(CefRefPtr<CefBrowser> browser,
CefAudioParameters& params) {
return true;
}
///
// Called on a browser audio capture thread when the browser starts
// streaming audio. OnAudioSteamStopped will always be called after
// OnAudioStreamStarted; both methods may be called multiple times
// for the same browser. |params| contains the audio parameters like
// sample rate and channel layout. |channels| is the number of channels.
///
/*--cef()--*/
virtual void OnAudioStreamStarted(CefRefPtr<CefBrowser> browser,
const CefAudioParameters& params,
int channels) = 0;
///
// Called on the audio stream thread when a PCM packet is received for the
// stream. |data| is an array representing the raw PCM data as a floating
// point type, i.e. 4-byte value(s). |frames| is the number of frames in the
// PCM packet. |pts| is the presentation timestamp (in milliseconds since the
// Unix Epoch) and represents the time at which the decompressed packet should
// be presented to the user. Based on |frames| and the |channel_layout| value
// passed to OnAudioStreamStarted you can calculate the size of the |data|
// array in bytes.
///
/*--cef()--*/
virtual void OnAudioStreamPacket(CefRefPtr<CefBrowser> browser,
const float** data,
int frames,
int64 pts) = 0;
///
// Called on the UI thread when the stream has stopped. OnAudioSteamStopped
// will always be called after OnAudioStreamStarted; both methods may be
// called multiple times for the same stream.
///
/*--cef()--*/
virtual void OnAudioStreamStopped(CefRefPtr<CefBrowser> browser) = 0;
///
// Called on the UI or audio stream thread when an error occurred. During the
// stream creation phase this callback will be called on the UI thread while
// in the capturing phase it will be called on the audio stream thread. The
// stream will be stopped immediately.
///
/*--cef()--*/
virtual void OnAudioStreamError(CefRefPtr<CefBrowser> browser,
const CefString& message) = 0;
};
#endif // CEF_INCLUDE_CEF_AUDIO_HANDLER_H_

View File

@@ -40,10 +40,12 @@
#include <vector>
#include "include/cef_base.h"
#include "include/cef_devtools_message_observer.h"
#include "include/cef_drag_data.h"
#include "include/cef_frame.h"
#include "include/cef_image.h"
#include "include/cef_navigation_entry.h"
#include "include/cef_registration.h"
#include "include/cef_request_context.h"
class CefBrowserHost;
@@ -517,6 +519,69 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual bool HasDevTools() = 0;
///
// Send a method call message over the DevTools protocol. |message| must be a
// UTF8-encoded JSON dictionary that contains "id" (int), "method" (string)
// and "params" (dictionary, optional) values. See the DevTools protocol
// documentation at https://chromedevtools.github.io/devtools-protocol/ for
// details of supported methods and the expected "params" dictionary contents.
// |message| will be copied if necessary. This method will return true if
// called on the UI thread and the message was successfully submitted for
// validation, otherwise false. Validation will be applied asynchronously and
// any messages that fail due to formatting errors or missing parameters may
// be discarded without notification. Prefer ExecuteDevToolsMethod if a more
// structured approach to message formatting is desired.
//
// Every valid method call will result in an asynchronous method result or
// error message that references the sent message "id". Event messages are
// received while notifications are enabled (for example, between method calls
// for "Page.enable" and "Page.disable"). All received messages will be
// delivered to the observer(s) registered with AddDevToolsMessageObserver.
// See CefDevToolsMessageObserver::OnDevToolsMessage documentation for details
// of received message contents.
//
// Usage of the SendDevToolsMessage, ExecuteDevToolsMethod and
// AddDevToolsMessageObserver methods does not require an active DevTools
// front-end or remote-debugging session. Other active DevTools sessions will
// continue to function independently. However, any modification of global
// browser state by one session may not be reflected in the UI of other
// sessions.
//
// Communication with the DevTools front-end (when displayed) can be logged
// for development purposes by passing the
// `--devtools-protocol-log-file=<path>` command-line flag.
///
/*--cef()--*/
virtual bool SendDevToolsMessage(const void* message,
size_t message_size) = 0;
///
// Execute a method call over the DevTools protocol. This is a more structured
// version of SendDevToolsMessage. |message_id| is an incremental number that
// uniquely identifies the message (pass 0 to have the next number assigned
// automatically based on previous values). |method| is the method name.
// |params| are the method parameters, which may be empty. See the DevTools
// protocol documentation (linked above) for details of supported methods and
// the expected |params| dictionary contents. This method will return the
// assigned message ID if called on the UI thread and the message was
// successfully submitted for validation, otherwise 0. See the
// SendDevToolsMessage documentation for additional usage information.
///
/*--cef(optional_param=params)--*/
virtual int ExecuteDevToolsMethod(int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) = 0;
///
// Add an observer for DevTools protocol messages (method results and events).
// The observer will remain registered until the returned Registration object
// is destroyed. See the SendDevToolsMessage documentation for additional
// usage information.
///
/*--cef()--*/
virtual CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) = 0;
///
// Retrieve a snapshot of current navigation entries as values sent to the
// specified visitor. If |current_only| is true only the current navigation

View File

@@ -38,6 +38,7 @@
#define CEF_INCLUDE_CEF_CLIENT_H_
#pragma once
#include "include/cef_audio_handler.h"
#include "include/cef_base.h"
#include "include/cef_context_menu_handler.h"
#include "include/cef_dialog_handler.h"
@@ -60,6 +61,12 @@
/*--cef(source=client,no_debugct_check)--*/
class CefClient : public virtual CefBaseRefCounted {
public:
///
// Return the handler for audio rendering events.
///
/*--cef()--*/
virtual CefRefPtr<CefAudioHandler> GetAudioHandler() { return nullptr; }
///
// Return the handler for context menus. If no handler is provided the default
// implementation will be used.

View File

@@ -0,0 +1,130 @@
// Copyright (c) 2020 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_DEVTOOLS_MESSAGE_OBSERVER_H_
#define CEF_INCLUDE_CEF_DEVTOOLS_MESSAGE_OBSERVER_H_
#pragma once
#include "include/cef_base.h"
class CefBrowser;
///
// Callback interface for CefBrowserHost::AddDevToolsMessageObserver. The
// methods of this class will be called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefDevToolsMessageObserver : public virtual CefBaseRefCounted {
public:
///
// Method that will be called on receipt of a DevTools protocol message.
// |browser| is the originating browser instance. |message| is a UTF8-encoded
// JSON dictionary representing either a method result or an event. |message|
// is only valid for the scope of this callback and should be copied if
// necessary. Return true if the message was handled or false if the message
// should be further processed and passed to the OnDevToolsMethodResult or
// OnDevToolsEvent methods as appropriate.
//
// Method result dictionaries include an "id" (int) value that identifies the
// orginating method call sent from CefBrowserHost::SendDevToolsMessage, and
// optionally either a "result" (dictionary) or "error" (dictionary) value.
// The "error" dictionary will contain "code" (int) and "message" (string)
// values. Event dictionaries include a "method" (string) value and optionally
// a "params" (dictionary) value. See the DevTools protocol documentation at
// https://chromedevtools.github.io/devtools-protocol/ for details of
// supported method calls and the expected "result" or "params" dictionary
// contents. JSON dictionaries can be parsed using the CefParseJSON function
// if desired, however be aware of performance considerations when parsing
// large messages (some of which may exceed 1MB in size).
///
/*--cef()--*/
virtual bool OnDevToolsMessage(CefRefPtr<CefBrowser> browser,
const void* message,
size_t message_size) {
return false;
}
///
// Method that will be called after attempted execution of a DevTools protocol
// method. |browser| is the originating browser instance. |message_id| is the
// "id" value that identifies the originating method call message. If the
// method succeeded |success| will be true and |result| will be the
// UTF8-encoded JSON "result" dictionary value (which may be empty). If the
// method failed |success| will be false and |result| will be the UTF8-encoded
// JSON "error" dictionary value. |result| is only valid for the scope of this
// callback and should be copied if necessary. See the OnDevToolsMessage
// documentation for additional details on |result| contents.
///
/*--cef(optional_param=result)--*/
virtual void OnDevToolsMethodResult(CefRefPtr<CefBrowser> browser,
int message_id,
bool success,
const void* result,
size_t result_size) {}
///
// Method that will be called on receipt of a DevTools protocol event.
// |browser| is the originating browser instance. |method| is the "method"
// value. |params| is the UTF8-encoded JSON "params" dictionary value (which
// may be empty). |params| is only valid for the scope of this callback and
// should be copied if necessary. See the OnDevToolsMessage documentation for
// additional details on |params| contents.
///
/*--cef(optional_param=params)--*/
virtual void OnDevToolsEvent(CefRefPtr<CefBrowser> browser,
const CefString& method,
const void* params,
size_t params_size) {}
///
// Method that will be called when the DevTools agent has attached. |browser|
// is the originating browser instance. This will generally occur in response
// to the first message sent while the agent is detached.
///
/*--cef()--*/
virtual void OnDevToolsAgentAttached(CefRefPtr<CefBrowser> browser) {}
///
// Method that will be called when the DevTools agent has detached. |browser|
// is the originating browser instance. Any method results that were pending
// before the agent became detached will not be delivered, and any active
// event subscriptions will be canceled.
///
/*--cef()--*/
virtual void OnDevToolsAgentDetached(CefRefPtr<CefBrowser> browser) {}
};
#endif // CEF_INCLUDE_CEF_DEVTOOLS_MESSAGE_OBSERVER_H_

332
include/cef_media_router.h Normal file
View File

@@ -0,0 +1,332 @@
// Copyright (c) 2020 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_MEDIA_ROUTER_H_
#define CEF_INCLUDE_CEF_MEDIA_ROUTER_H_
#pragma once
#include <vector>
#include "include/cef_base.h"
#include "include/cef_registration.h"
class CefMediaObserver;
class CefMediaRoute;
class CefMediaRouteCreateCallback;
class CefMediaSink;
class CefMediaSinkDeviceInfoCallback;
class CefMediaSource;
///
// Supports discovery of and communication with media devices on the local
// network via the Cast and DIAL protocols. The methods of this class may be
// called on any browser process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaRouter : public virtual CefBaseRefCounted {
public:
///
// Returns the MediaRouter object associated with the global request context.
// Equivalent to calling
// CefRequestContext::GetGlobalContext()->GetMediaRouter().
///
/*--cef()--*/
static CefRefPtr<CefMediaRouter> GetGlobalMediaRouter();
///
// Add an observer for MediaRouter events. The observer will remain registered
// until the returned Registration object is destroyed.
///
/*--cef()--*/
virtual CefRefPtr<CefRegistration> AddObserver(
CefRefPtr<CefMediaObserver> observer) = 0;
///
// Returns a MediaSource object for the specified media source URN. Supported
// URN schemes include "cast:" and "dial:", and will be already known by the
// client application (e.g. "cast:<appId>?clientId=<clientId>").
///
/*--cef()--*/
virtual CefRefPtr<CefMediaSource> GetSource(const CefString& urn) = 0;
///
// Trigger an asynchronous call to CefMediaObserver::OnSinks on all
// registered observers.
///
/*--cef()--*/
virtual void NotifyCurrentSinks() = 0;
///
// Create a new route between |source| and |sink|. Source and sink must be
// valid, compatible (as reported by CefMediaSink::IsCompatibleWith), and a
// route between them must not already exist. |callback| will be executed
// on success or failure. If route creation succeeds it will also trigger an
// asynchronous call to CefMediaObserver::OnRoutes on all registered
// observers.
///
/*--cef()--*/
virtual void CreateRoute(CefRefPtr<CefMediaSource> source,
CefRefPtr<CefMediaSink> sink,
CefRefPtr<CefMediaRouteCreateCallback> callback) = 0;
///
// Trigger an asynchronous call to CefMediaObserver::OnRoutes on all
// registered observers.
///
/*--cef()--*/
virtual void NotifyCurrentRoutes() = 0;
};
///
// Implemented by the client to observe MediaRouter events and registered via
// CefMediaRouter::AddObserver. The methods of this class will be called on the
// browser process UI thread.
///
/*--cef(source=client)--*/
class CefMediaObserver : public virtual CefBaseRefCounted {
public:
typedef cef_media_route_connection_state_t ConnectionState;
///
// The list of available media sinks has changed or
// CefMediaRouter::NotifyCurrentSinks was called.
///
/*--cef()--*/
virtual void OnSinks(const std::vector<CefRefPtr<CefMediaSink>>& sinks) = 0;
///
// The list of available media routes has changed or
// CefMediaRouter::NotifyCurrentRoutes was called.
///
/*--cef()--*/
virtual void OnRoutes(
const std::vector<CefRefPtr<CefMediaRoute>>& routes) = 0;
///
// The connection state of |route| has changed.
///
/*--cef()--*/
virtual void OnRouteStateChanged(CefRefPtr<CefMediaRoute> route,
ConnectionState state) = 0;
///
// A message was recieved over |route|. |message| is only valid for
// the scope of this callback and should be copied if necessary.
///
/*--cef()--*/
virtual void OnRouteMessageReceived(CefRefPtr<CefMediaRoute> route,
const void* message,
size_t message_size) = 0;
};
///
// Represents the route between a media source and sink. Instances of this
// object are created via CefMediaRouter::CreateRoute and retrieved via
// CefMediaObserver::OnRoutes. Contains the status and metadata of a
// routing operation. The methods of this class may be called on any browser
// process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaRoute : public virtual CefBaseRefCounted {
public:
///
// Returns the ID for this route.
///
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns the source associated with this route.
///
/*--cef()--*/
virtual CefRefPtr<CefMediaSource> GetSource() = 0;
///
// Returns the sink associated with this route.
///
/*--cef()--*/
virtual CefRefPtr<CefMediaSink> GetSink() = 0;
///
// Send a message over this route. |message| will be copied if necessary.
///
/*--cef()--*/
virtual void SendRouteMessage(const void* message, size_t message_size) = 0;
///
// Terminate this route. Will result in an asynchronous call to
// CefMediaObserver::OnRoutes on all registered observers.
///
/*--cef()--*/
virtual void Terminate() = 0;
};
///
// Callback interface for CefMediaRouter::CreateRoute. The methods of this
// class will be called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefMediaRouteCreateCallback : public virtual CefBaseRefCounted {
public:
typedef cef_media_route_create_result_t RouteCreateResult;
///
// Method that will be executed when the route creation has finished. |result|
// will be CEF_MRCR_OK if the route creation succeeded. |error| will be a
// description of the error if the route creation failed. |route| is the
// resulting route, or empty if the route creation failed.
///
/*--cef(optional_param=error,optional_param=route)--*/
virtual void OnMediaRouteCreateFinished(RouteCreateResult result,
const CefString& error,
CefRefPtr<CefMediaRoute> route) = 0;
};
///
// Represents a sink to which media can be routed. Instances of this object are
// retrieved via CefMediaObserver::OnSinks. The methods of this class may
// be called on any browser process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaSink : public virtual CefBaseRefCounted {
public:
typedef cef_media_sink_icon_type_t IconType;
///
// Returns the ID for this sink.
///
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns true if this sink is valid.
///
/*--cef()--*/
virtual bool IsValid() = 0;
///
// Returns the name of this sink.
///
/*--cef()--*/
virtual CefString GetName() = 0;
///
// Returns the description of this sink.
///
/*--cef()--*/
virtual CefString GetDescription() = 0;
///
// Returns the icon type for this sink.
///
/*--cef(default_retval=CEF_MSIT_GENERIC)--*/
virtual IconType GetIconType() = 0;
///
// Asynchronously retrieves device info.
///
/*--cef()--*/
virtual void GetDeviceInfo(
CefRefPtr<CefMediaSinkDeviceInfoCallback> callback) = 0;
///
// Returns true if this sink accepts content via Cast.
///
/*--cef()--*/
virtual bool IsCastSink() = 0;
///
// Returns true if this sink accepts content via DIAL.
///
/*--cef()--*/
virtual bool IsDialSink() = 0;
///
// Returns true if this sink is compatible with |source|.
///
/*--cef()--*/
virtual bool IsCompatibleWith(CefRefPtr<CefMediaSource> source) = 0;
};
///
// Callback interface for CefMediaSink::GetDeviceInfo. The methods of this
// class will be called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefMediaSinkDeviceInfoCallback : public virtual CefBaseRefCounted {
public:
///
// Method that will be executed asyncronously once device information has been
// retrieved.
///
/*--cef()--*/
virtual void OnMediaSinkDeviceInfo(
const CefMediaSinkDeviceInfo& device_info) = 0;
};
///
// Represents a source from which media can be routed. Instances of this object
// are retrieved via CefMediaRouter::GetSource. The methods of this class may be
// called on any browser process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaSource : public virtual CefBaseRefCounted {
public:
///
// Returns the ID (media source URN or URL) for this source.
///
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns true if this source is valid.
///
/*--cef()--*/
virtual bool IsValid() = 0;
///
// Returns true if this source outputs its content via Cast.
///
/*--cef()--*/
virtual bool IsCastSource() = 0;
///
// Returns true if this source outputs its content via DIAL.
///
/*--cef()--*/
virtual bool IsDialSource() = 0;
};
#endif // CEF_INCLUDE_CEF_MEDIA_ROUTER_H_

View File

@@ -133,6 +133,16 @@ CefString CefURIDecode(const CefString& text,
CefRefPtr<CefValue> CefParseJSON(const CefString& json_string,
cef_json_parser_options_t options);
///
// Parses the specified UTF8-encoded |json| buffer of size |json_size| and
// returns a dictionary or list representation. If JSON parsing fails this
// method returns NULL.
///
/*--cef(capi_name=cef_parse_json_buffer)--*/
CefRefPtr<CefValue> CefParseJSON(const void* json,
size_t json_size,
cef_json_parser_options_t options);
///
// Parses the specified |json_string| and returns a dictionary or list
// representation. If JSON parsing fails this method returns NULL and populates

View File

@@ -0,0 +1,49 @@
// Copyright (c) 2020 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_REGISTRATION_H_
#define CEF_INCLUDE_CEF_REGISTRATION_H_
#pragma once
#include "include/cef_base.h"
///
// Generic callback interface used for managing the lifespan of a registration.
///
/*--cef(source=library)--*/
class CefRegistration : public virtual CefBaseRefCounted {};
#endif // CEF_INCLUDE_CEF_REGISTRATION_H_

View File

@@ -44,6 +44,7 @@
#include "include/cef_cookie.h"
#include "include/cef_extension.h"
#include "include/cef_extension_handler.h"
#include "include/cef_media_router.h"
#include "include/cef_values.h"
class CefRequestContextHandler;
@@ -361,6 +362,12 @@ class CefRequestContext : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual CefRefPtr<CefExtension> GetExtension(
const CefString& extension_id) = 0;
///
// Returns the MediaRouter object associated with this context.
///
/*--cef()--*/
virtual CefRefPtr<CefMediaRouter> GetMediaRouter() = 0;
};
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_

View File

@@ -252,6 +252,13 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
TerminationStatus status) {}
///
// Called on the browser process UI thread when the window.document object of
// the main frame has been created.
///
/*--cef()--*/
virtual void OnDocumentAvailableInMainFrame(CefRefPtr<CefBrowser> browser) {}
};
#endif // CEF_INCLUDE_CEF_REQUEST_HANDLER_H_

View File

@@ -170,23 +170,25 @@ typedef struct _cef_settings_t {
// will be used. If this value is empty on macOS then a helper executable must
// exist at "Contents/Frameworks/<app> Helper.app/Contents/MacOS/<app> Helper"
// in the top-level app bundle. See the comments on CefExecuteProcess() for
// details. Also configurable using the "browser-subprocess-path" command-line
// switch.
// details. If this value is non-empty then it must be an absolute path. Also
// configurable using the "browser-subprocess-path" command-line switch.
///
cef_string_t browser_subprocess_path;
///
// The path to the CEF framework directory on macOS. If this value is empty
// then the framework must exist at "Contents/Frameworks/Chromium Embedded
// Framework.framework" in the top-level app bundle. Also configurable using
// the "framework-dir-path" command-line switch.
// Framework.framework" in the top-level app bundle. If this value is
// non-empty then it must be an absolute path. Also configurable using the
// "framework-dir-path" command-line switch.
///
cef_string_t framework_dir_path;
///
// The path to the main bundle on macOS. If this value is empty then it
// defaults to the top-level app bundle. Also configurable using
// the "main-bundle-path" command-line switch.
// defaults to the top-level app bundle. If this value is non-empty then it
// must be an absolute path. Also configurable using the "main-bundle-path"
// command-line switch.
///
cef_string_t main_bundle_path;
@@ -227,33 +229,35 @@ typedef struct _cef_settings_t {
///
// The location where data for the global browser cache will be stored on
// disk. If non-empty this must be either equal to or a child directory of
// CefSettings.root_cache_path. If empty then browsers will be created in
// "incognito mode" where in-memory caches are used for storage and no data is
// persisted to disk. HTML5 databases such as localStorage will only persist
// across sessions if a cache path is specified. Can be overridden for
// individual CefRequestContext instances via the
// CefRequestContextSettings.cache_path value.
// disk. If this value is non-empty then it must be an absolute path that is
// either equal to or a child directory of CefSettings.root_cache_path. If
// this value is empty then browsers will be created in "incognito mode" where
// in-memory caches are used for storage and no data is persisted to disk.
// HTML5 databases such as localStorage will only persist across sessions if a
// cache path is specified. Can be overridden for individual CefRequestContext
// instances via the CefRequestContextSettings.cache_path value.
///
cef_string_t cache_path;
///
// The root directory that all CefSettings.cache_path and
// CefRequestContextSettings.cache_path values must have in common. If this
// value is empty and CefSettings.cache_path is non-empty then this value will
// default to the CefSettings.cache_path value. Failure to set this value
// correctly may result in the sandbox blocking read/write access to the
// cache_path directory.
// value is empty and CefSettings.cache_path is non-empty then it will
// default to the CefSettings.cache_path value. If this value is non-empty
// then it must be an absolute path. Failure to set this value correctly may
// result in the sandbox blocking read/write access to the cache_path
// directory.
///
cef_string_t root_cache_path;
///
// The location where user data such as spell checking dictionary files will
// be stored on disk. If empty then the default platform-specific user data
// directory will be used ("~/.cef_user_data" directory on Linux,
// "~/Library/Application Support/CEF/User Data" directory on Mac OS X,
// "Local Settings\Application Data\CEF\User Data" directory under the user
// profile directory on Windows).
// be stored on disk. If this value is empty then the default
// platform-specific user data directory will be used ("~/.cef_user_data"
// directory on Linux, "~/Library/Application Support/CEF/User Data" directory
// on Mac OS X, "Local Settings\Application Data\CEF\User Data" directory
// under the user profile directory on Windows). If this value is non-empty
// then it must be an absolute path.
///
cef_string_t user_data_path;
@@ -333,16 +337,17 @@ typedef struct _cef_settings_t {
// The fully qualified path for the resources directory. If this value is
// empty the cef.pak and/or devtools_resources.pak files must be located in
// the module directory on Windows/Linux or the app bundle Resources directory
// on Mac OS X. Also configurable using the "resources-dir-path" command-line
// switch.
// on Mac OS X. If this value is non-empty then it must be an absolute path.
// Also configurable using the "resources-dir-path" command-line switch.
///
cef_string_t resources_dir_path;
///
// The fully qualified path for the locales directory. If this value is empty
// the locales directory must be located in the module directory. This value
// is ignored on Mac OS X where pack files are always loaded from the app
// bundle Resources directory. Also configurable using the "locales-dir-path"
// the locales directory must be located in the module directory. If this
// value is non-empty then it must be an absolute path. This value is ignored
// on Mac OS X where pack files are always loaded from the app bundle
// Resources directory. Also configurable using the "locales-dir-path"
// command-line switch.
///
cef_string_t locales_dir_path;
@@ -428,13 +433,13 @@ typedef struct _cef_request_context_settings_t {
///
// The location where cache data for this request context will be stored on
// disk. If non-empty this must be either equal to or a child directory of
// CefSettings.root_cache_path. If empty then browsers will be created in
// "incognito mode" where in-memory caches are used for storage and no data is
// persisted to disk. HTML5 databases such as localStorage will only persist
// across sessions if a cache path is specified. To share the global browser
// cache and related configuration set this value to match the
// CefSettings.cache_path value.
// disk. If this value is non-empty then it must be an absolute path that is
// either equal to or a child directory of CefSettings.root_cache_path. If
// this value is empty then browsers will be created in "incognito mode" where
// in-memory caches are used for storage and no data is persisted to disk.
// HTML5 databases such as localStorage will only persist across sessions if a
// cache path is specified. To share the global browser cache and related
// configuration set this value to match the CefSettings.cache_path value.
///
cef_string_t cache_path;
@@ -725,8 +730,32 @@ typedef struct _cef_urlparts_t {
// Query string component (i.e., everything following the '?').
///
cef_string_t query;
///
// Fragment (hash) identifier component (i.e., the string following the '#').
///
cef_string_t fragment;
} cef_urlparts_t;
///
// Cookie priority values.
///
typedef enum {
CEF_COOKIE_PRIORITY_LOW = -1,
CEF_COOKIE_PRIORITY_MEDIUM = 0,
CEF_COOKIE_PRIORITY_HIGH = 1,
} cef_cookie_priority_t;
///
// Cookie same site values.
///
typedef enum {
CEF_COOKIE_SAME_SITE_UNSPECIFIED,
CEF_COOKIE_SAME_SITE_NO_RESTRICTION,
CEF_COOKIE_SAME_SITE_LAX_MODE,
CEF_COOKIE_SAME_SITE_STRICT_MODE,
} cef_cookie_same_site_t;
///
// Cookie information.
///
@@ -781,6 +810,16 @@ typedef struct _cef_cookie_t {
///
int has_expires;
cef_time_t expires;
///
// Same site.
///
cef_cookie_same_site_t same_site;
///
// Priority.
///
cef_cookie_priority_t priority;
} cef_cookie_t;
///
@@ -1775,6 +1814,7 @@ typedef enum {
EVENTFLAG_IS_KEY_PAD = 1 << 9,
EVENTFLAG_IS_LEFT = 1 << 10,
EVENTFLAG_IS_RIGHT = 1 << 11,
EVENTFLAG_ALTGR_DOWN = 1 << 12,
} cef_event_flags_t;
///
@@ -2232,7 +2272,13 @@ typedef enum {
CT_ZOOMOUT,
CT_GRAB,
CT_GRABBING,
CT_MIDDLE_PANNING_VERTICAL,
CT_MIDDLE_PANNING_HORIZONTAL,
CT_CUSTOM,
CT_DND_NONE,
CT_DND_MOVE,
CT_DND_COPY,
CT_DND_LINK,
} cef_cursor_type_t;
///
@@ -2292,21 +2338,10 @@ typedef enum {
///
UU_URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS = 1 << 3,
///
// Unescapes characters that can be used in spoofing attempts (such as LOCK)
// and control characters (such as BiDi control characters and %01). This
// INCLUDES NULLs. This is used for rare cases such as data: URL decoding
// where the result is binary data.
//
// DO NOT use UU_SPOOFING_AND_CONTROL_CHARS if the URL is going to be
// displayed in the UI for security reasons.
///
UU_SPOOFING_AND_CONTROL_CHARS = 1 << 4,
///
// URL queries use "+" for space. This flag controls that replacement.
///
UU_REPLACE_PLUS_WITH_SPACE = 1 << 5,
UU_REPLACE_PLUS_WITH_SPACE = 1 << 4,
} cef_uri_unescape_rule_t;
///
@@ -2429,13 +2464,13 @@ typedef struct _cef_pdf_print_settings_t {
int scale_factor;
///
// Margins in millimeters. Only used if |margin_type| is set to
// Margins in points. Only used if |margin_type| is set to
// PDF_PRINT_MARGIN_CUSTOM.
///
double margin_top;
double margin_right;
double margin_bottom;
double margin_left;
int margin_top;
int margin_right;
int margin_bottom;
int margin_left;
///
// Margin type.
@@ -2968,6 +3003,192 @@ typedef struct _cef_composition_underline_t {
cef_composition_underline_style_t style;
} cef_composition_underline_t;
///
// Enumerates the various representations of the ordering of audio channels.
// Must be kept synchronized with media::ChannelLayout from Chromium.
// See media\base\channel_layout.h
///
typedef enum {
CEF_CHANNEL_LAYOUT_NONE = 0,
CEF_CHANNEL_LAYOUT_UNSUPPORTED = 1,
// Front C
CEF_CHANNEL_LAYOUT_MONO = 2,
// Front L, Front R
CEF_CHANNEL_LAYOUT_STEREO = 3,
// Front L, Front R, Back C
CEF_CHANNEL_LAYOUT_2_1 = 4,
// Front L, Front R, Front C
CEF_CHANNEL_LAYOUT_SURROUND = 5,
// Front L, Front R, Front C, Back C
CEF_CHANNEL_LAYOUT_4_0 = 6,
// Front L, Front R, Side L, Side R
CEF_CHANNEL_LAYOUT_2_2 = 7,
// Front L, Front R, Back L, Back R
CEF_CHANNEL_LAYOUT_QUAD = 8,
// Front L, Front R, Front C, Side L, Side R
CEF_CHANNEL_LAYOUT_5_0 = 9,
// Front L, Front R, Front C, LFE, Side L, Side R
CEF_CHANNEL_LAYOUT_5_1 = 10,
// Front L, Front R, Front C, Back L, Back R
CEF_CHANNEL_LAYOUT_5_0_BACK = 11,
// Front L, Front R, Front C, LFE, Back L, Back R
CEF_CHANNEL_LAYOUT_5_1_BACK = 12,
// Front L, Front R, Front C, Side L, Side R, Back L, Back R
CEF_CHANNEL_LAYOUT_7_0 = 13,
// Front L, Front R, Front C, LFE, Side L, Side R, Back L, Back R
CEF_CHANNEL_LAYOUT_7_1 = 14,
// Front L, Front R, Front C, LFE, Side L, Side R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_7_1_WIDE = 15,
// Stereo L, Stereo R
CEF_CHANNEL_LAYOUT_STEREO_DOWNMIX = 16,
// Stereo L, Stereo R, LFE
CEF_CHANNEL_LAYOUT_2POINT1 = 17,
// Stereo L, Stereo R, Front C, LFE
CEF_CHANNEL_LAYOUT_3_1 = 18,
// Stereo L, Stereo R, Front C, Rear C, LFE
CEF_CHANNEL_LAYOUT_4_1 = 19,
// Stereo L, Stereo R, Front C, Side L, Side R, Back C
CEF_CHANNEL_LAYOUT_6_0 = 20,
// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_6_0_FRONT = 21,
// Stereo L, Stereo R, Front C, Rear L, Rear R, Rear C
CEF_CHANNEL_LAYOUT_HEXAGONAL = 22,
// Stereo L, Stereo R, Front C, LFE, Side L, Side R, Rear Center
CEF_CHANNEL_LAYOUT_6_1 = 23,
// Stereo L, Stereo R, Front C, LFE, Back L, Back R, Rear Center
CEF_CHANNEL_LAYOUT_6_1_BACK = 24,
// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE
CEF_CHANNEL_LAYOUT_6_1_FRONT = 25,
// Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_7_0_FRONT = 26,
// Front L, Front R, Front C, LFE, Back L, Back R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_7_1_WIDE_BACK = 27,
// Front L, Front R, Front C, Side L, Side R, Rear L, Back R, Back C.
CEF_CHANNEL_LAYOUT_OCTAGONAL = 28,
// Channels are not explicitly mapped to speakers.
CEF_CHANNEL_LAYOUT_DISCRETE = 29,
// Front L, Front R, Front C. Front C contains the keyboard mic audio. This
// layout is only intended for input for WebRTC. The Front C channel
// is stripped away in the WebRTC audio input pipeline and never seen outside
// of that.
CEF_CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC = 30,
// Front L, Front R, Side L, Side R, LFE
CEF_CHANNEL_LAYOUT_4_1_QUAD_SIDE = 31,
// Actual channel layout is specified in the bitstream and the actual channel
// count is unknown at Chromium media pipeline level (useful for audio
// pass-through mode).
CEF_CHANNEL_LAYOUT_BITSTREAM = 32,
// Max value, must always equal the largest entry ever logged.
CEF_CHANNEL_LAYOUT_MAX = CEF_CHANNEL_LAYOUT_BITSTREAM
} cef_channel_layout_t;
///
// Structure representing the audio parameters for setting up the audio handler.
///
typedef struct _cef_audio_parameters_t {
///
// Layout of the audio channels
///
cef_channel_layout_t channel_layout;
///
// Sample rate
//
int sample_rate;
///
// Number of frames per buffer
///
int frames_per_buffer;
} cef_audio_parameters_t;
///
// Result codes for CefMediaRouter::CreateRoute. Should be kept in sync with
// Chromium's media_router::RouteRequestResult::ResultCode type.
///
typedef enum {
CEF_MRCR_UNKNOWN_ERROR = 0,
CEF_MRCR_OK = 1,
CEF_MRCR_TIMED_OUT = 2,
CEF_MRCR_ROUTE_NOT_FOUND = 3,
CEF_MRCR_SINK_NOT_FOUND = 4,
CEF_MRCR_INVALID_ORIGIN = 5,
CEF_MRCR_NO_SUPPORTED_PROVIDER = 7,
CEF_MRCR_CANCELLED = 8,
CEF_MRCR_ROUTE_ALREADY_EXISTS = 9,
CEF_MRCR_TOTAL_COUNT = 11 // The total number of values.
} cef_media_route_create_result_t;
///
// Connection state for a MediaRoute object.
///
typedef enum {
CEF_MRCS_UNKNOWN,
CEF_MRCS_CONNECTING,
CEF_MRCS_CONNECTED,
CEF_MRCS_CLOSED,
CEF_MRCS_TERMINATED,
} cef_media_route_connection_state_t;
///
// Icon types for a MediaSink object. Should be kept in sync with Chromium's
// media_router::SinkIconType type.
///
typedef enum {
CEF_MSIT_CAST,
CEF_MSIT_CAST_AUDIO_GROUP,
CEF_MSIT_CAST_AUDIO,
CEF_MSIT_MEETING,
CEF_MSIT_HANGOUT,
CEF_MSIT_EDUCATION,
CEF_MSIT_WIRED_DISPLAY,
CEF_MSIT_GENERIC,
CEF_MSIT_TOTAL_COUNT, // The total number of values.
} cef_media_sink_icon_type_t;
///
// Device information for a MediaSink object.
///
typedef struct _cef_media_sink_device_info_t {
cef_string_t ip_address;
int port;
cef_string_t model_name;
} cef_media_sink_device_info_t;
#ifdef __cplusplus
}
#endif

View File

@@ -743,6 +743,7 @@ struct CefURLPartsTraits {
cef_string_clear(&s->origin);
cef_string_clear(&s->path);
cef_string_clear(&s->query);
cef_string_clear(&s->fragment);
}
static inline void set(const struct_type* src,
@@ -759,6 +760,8 @@ struct CefURLPartsTraits {
cef_string_set(src->origin.str, src->origin.length, &target->origin, copy);
cef_string_set(src->path.str, src->path.length, &target->path, copy);
cef_string_set(src->query.str, src->query.length, &target->query, copy);
cef_string_set(src->fragment.str, src->fragment.length, &target->fragment,
copy);
}
};
@@ -848,6 +851,8 @@ struct CefCookieTraits {
target->last_access = src->last_access;
target->has_expires = src->has_expires;
target->expires = src->expires;
target->same_site = src->same_site;
target->priority = src->priority;
}
};
@@ -955,4 +960,49 @@ struct CefCompositionUnderlineTraits {
///
typedef CefStructBase<CefCompositionUnderlineTraits> CefCompositionUnderline;
struct CefAudioParametersTraits {
typedef cef_audio_parameters_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src,
struct_type* target,
bool copy) {
*target = *src;
}
};
///
// Class representing CefAudioParameters settings
///
typedef CefStructBase<CefAudioParametersTraits> CefAudioParameters;
struct CefMediaSinkDeviceInfoTraits {
typedef cef_media_sink_device_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->ip_address);
cef_string_clear(&s->model_name);
}
static inline void set(const struct_type* src,
struct_type* target,
bool copy) {
cef_string_set(src->ip_address.str, src->ip_address.length,
&target->ip_address, copy);
target->port = src->port;
cef_string_set(src->model_name.str, src->model_name.length,
&target->model_name, copy);
}
};
///
// Class representing MediaSink device info.
///
typedef CefStructBase<CefMediaSinkDeviceInfoTraits> CefMediaSinkDeviceInfo;
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_

View File

@@ -0,0 +1,125 @@
// Copyright (c) 2019 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/audio_capturer.h"
#include "libcef/browser/browser_host_impl.h"
#include "components/mirroring/service/captured_audio_input.h"
#include "content/public/browser/audio_loopback_stream_creator.h"
#include "media/audio/audio_input_device.h"
namespace {
media::ChannelLayout TranslateChannelLayout(
cef_channel_layout_t channel_layout) {
// Verify that our enum matches Chromium's values. The enum values match
// between those enums and existing values don't ever change, so it's enough
// to check that there are no new ones added.
static_assert(
static_cast<int>(CEF_CHANNEL_LAYOUT_MAX) ==
static_cast<int>(media::CHANNEL_LAYOUT_MAX),
"cef_channel_layout_t must match the ChannelLayout enum in Chromium");
return static_cast<media::ChannelLayout>(channel_layout);
}
void StreamCreatorHelper(
content::WebContents* source_web_contents,
content::AudioLoopbackStreamCreator* audio_stream_creator,
mojo::PendingRemote<mirroring::mojom::AudioStreamCreatorClient> client,
const media::AudioParameters& params,
uint32_t total_segments) {
audio_stream_creator->CreateLoopbackStream(
source_web_contents, params, total_segments,
base::BindRepeating(
[](mojo::PendingRemote<mirroring::mojom::AudioStreamCreatorClient>
client,
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe) {
mojo::Remote<mirroring::mojom::AudioStreamCreatorClient>
audio_client(std::move(client));
audio_client->StreamCreated(
std::move(stream), std::move(client_receiver),
std::move(data_pipe), false /* initially_muted */);
},
base::Passed(&client)));
}
} // namespace
CefAudioCapturer::CefAudioCapturer(const CefAudioParameters& params,
CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefAudioHandler> audio_handler)
: params_(params),
browser_(browser),
audio_handler_(audio_handler),
audio_stream_creator_(content::AudioLoopbackStreamCreator::
CreateInProcessAudioLoopbackStreamCreator()) {
media::AudioParameters audio_params(
media::AudioParameters::AUDIO_PCM_LINEAR,
TranslateChannelLayout(params.channel_layout), params.sample_rate,
params.frames_per_buffer);
if (!audio_params.IsValid()) {
LOG(ERROR) << "Invalid audio parameters";
return;
}
DCHECK(browser_);
DCHECK(audio_handler_);
DCHECK(browser_->web_contents());
channels_ = audio_params.channels();
audio_input_device_ = new media::AudioInputDevice(
std::make_unique<mirroring::CapturedAudioInput>(base::BindRepeating(
&StreamCreatorHelper, base::Unretained(browser_->web_contents()),
base::Unretained(audio_stream_creator_.get()))),
media::AudioInputDevice::kLoopback);
audio_input_device_->Initialize(audio_params, this);
audio_input_device_->Start();
}
CefAudioCapturer::~CefAudioCapturer() {
StopStream();
}
void CefAudioCapturer::OnCaptureStarted() {
audio_handler_->OnAudioStreamStarted(browser_, params_, channels_);
DCHECK(!capturing_);
capturing_ = true;
}
void CefAudioCapturer::Capture(const media::AudioBus* source,
base::TimeTicks audio_capture_time,
double /*volume*/,
bool /*key_pressed*/) {
const int channels = source->channels();
std::array<const float*, media::CHANNELS_MAX> data;
DCHECK(channels == channels_);
DCHECK(channels <= static_cast<int>(data.size()));
for (int c = 0; c < channels; ++c) {
data[c] = source->channel(c);
}
base::TimeDelta pts = audio_capture_time - base::TimeTicks::UnixEpoch();
audio_handler_->OnAudioStreamPacket(browser_, data.data(), source->frames(),
pts.InMilliseconds());
}
void CefAudioCapturer::OnCaptureError(const std::string& message) {
audio_handler_->OnAudioStreamError(browser_, message);
StopStream();
}
void CefAudioCapturer::StopStream() {
if (audio_input_device_)
audio_input_device_->Stop();
if (capturing_)
audio_handler_->OnAudioStreamStopped(browser_);
audio_input_device_ = nullptr;
capturing_ = false;
}

View File

@@ -0,0 +1,53 @@
// Copyright (c) 2019 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_
#define CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_
#pragma once
#include "include/internal/cef_ptr.h"
#include "include/internal/cef_types_wrappers.h"
#include "media/base/audio_capturer_source.h"
namespace content {
class AudioLoopbackStreamCreator;
} // namespace content
namespace media {
class AudioInputDevice;
} // namespace media
class CefAudioHandler;
class CefBrowserHostImpl;
class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback {
public:
CefAudioCapturer(const CefAudioParameters& params,
CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefAudioHandler> audio_handler);
~CefAudioCapturer() override;
private:
void OnCaptureStarted() override;
void Capture(const media::AudioBus* audio_source,
base::TimeTicks audio_capture_time,
double volume,
bool key_pressed) override;
void OnCaptureError(const std::string& message) override;
void OnCaptureMuted(bool is_muted) override {}
void StopStream();
CefAudioParameters params_;
CefRefPtr<CefBrowserHostImpl> browser_;
CefRefPtr<CefAudioHandler> audio_handler_;
std::unique_ptr<content::AudioLoopbackStreamCreator> audio_stream_creator_;
scoped_refptr<media::AudioInputDevice> audio_input_device_;
bool capturing_ = false;
int channels_ = 0;
};
#endif // CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_

View File

@@ -8,9 +8,9 @@
#include <utility>
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/browser/download_manager_delegate.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/ssl_host_state_delegate.h"
@@ -47,7 +47,6 @@
#include "extensions/browser/process_manager.h"
#include "extensions/common/constants.h"
#include "net/proxy_resolution/proxy_config_service.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
#include "services/network/public/mojom/cors_origin_pattern.mojom.h"
using content::BrowserThread;
@@ -164,6 +163,11 @@ base::LazyInstance<ImplManager>::DestructorAtExit g_manager =
base::LazyInstance<ImplManager>::Leaky g_manager = LAZY_INSTANCE_INITIALIZER;
#endif
CefBrowserContext* GetSelf(base::WeakPtr<CefBrowserContext> self) {
CEF_REQUIRE_UIT();
return self.get();
}
} // namespace
// Creates and manages VisitedLinkEventListener objects for each
@@ -220,8 +224,9 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkWriter::Listener {
};
CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings)
: settings_(settings) {
: settings_(settings), weak_ptr_factory_(this) {
g_manager.Get().AddImpl(this);
getter_ = base::BindRepeating(GetSelf, weak_ptr_factory_.GetWeakPtr());
}
CefBrowserContext::~CefBrowserContext() {
@@ -233,6 +238,9 @@ CefBrowserContext::~CefBrowserContext() {
// Unregister the context first to avoid re-entrancy during shutdown.
g_manager.Get().RemoveImpl(this, cache_path_);
// Destroy objects that may hold references to the MediaRouter.
media_router_manager_.reset();
// Send notifications to clean up objects associated with this Profile.
MaybeSendDestroyedNotification();
@@ -283,36 +291,23 @@ CefBrowserContext::~CefBrowserContext() {
}
void CefBrowserContext::Initialize() {
CefContext* context = CefContext::Get();
cache_path_ = base::FilePath(CefString(&settings_.cache_path));
if (!context->ValidateCachePath(cache_path_)) {
// Reset to in-memory storage.
CefString(&settings_.cache_path).clear();
cache_path_ = base::FilePath();
}
if (!cache_path_.empty())
g_manager.Get().SetImplPath(this, cache_path_);
if (settings_.accept_language_list.length == 0) {
// Use the global language list setting.
CefString(&settings_.accept_language_list) =
CefString(&context->settings().accept_language_list);
}
if (!!settings_.persist_session_cookies) {
set_should_persist_session_cookies(true);
}
key_ = std::make_unique<ProfileKey>(GetPath());
key_ = std::make_unique<ProfileKey>(cache_path_);
SimpleKeyMap::GetInstance()->Associate(this, key_.get());
// Initialize the PrefService object.
pref_service_ = browser_prefs::CreatePrefService(
this, cache_path_, !!settings_.persist_user_preferences);
content::BrowserContext::Initialize(this, GetPath());
content::BrowserContext::Initialize(this, cache_path_);
resource_context_.reset(new CefResourceContext(IsOffTheRecord()));
@@ -812,3 +807,11 @@ bool CefBrowserContext::IsPrintPreviewSupported() const {
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
}
CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
CEF_REQUIRE_UIT();
if (!media_router_manager_) {
media_router_manager_.reset(new CefMediaRouterManager(this));
}
return media_router_manager_.get();
}

View File

@@ -13,8 +13,10 @@
#include "libcef/browser/request_context_handler_map.h"
#include "libcef/browser/resource_context.h"
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/common/plugin.mojom.h"
#include "components/proxy_config/pref_proxy_config_tracker.h"
@@ -84,6 +86,7 @@
*/
class CefDownloadManagerDelegate;
class CefMediaRouterManager;
class CefRequestContextImpl;
class CefSSLHostStateDelegate;
class CefVisitedLinkListener;
@@ -279,6 +282,13 @@ class CefBrowserContext : public ChromeProfileStub,
// Returns true if this context supports print preview.
bool IsPrintPreviewSupported() const;
CefMediaRouterManager* GetMediaRouterManager();
// Returns the BrowserContext, or nullptr if the BrowserContext has already
// been destroyed.
using Getter = base::RepeatingCallback<CefBrowserContext*()>;
Getter getter() const { return getter_; }
private:
// Allow deletion via std::unique_ptr().
friend std::default_delete<CefBrowserContext>;
@@ -286,7 +296,7 @@ class CefBrowserContext : public ChromeProfileStub,
~CefBrowserContext() override;
// Members initialized during construction are safe to access from any thread.
CefRequestContextSettings settings_;
const CefRequestContextSettings settings_;
base::FilePath cache_path_;
// CefRequestContextImpl objects referencing this object.
@@ -315,6 +325,8 @@ class CefBrowserContext : public ChromeProfileStub,
std::unique_ptr<DownloadPrefs> download_prefs_;
std::unique_ptr<CefMediaRouterManager> media_router_manager_;
// Map IDs to CefRequestContextHandler objects.
CefRequestContextHandlerMap handler_map_;
@@ -338,6 +350,9 @@ class CefBrowserContext : public ChromeProfileStub,
typedef std::set<int> NodeIdSet;
NodeIdSet node_id_set_;
Getter getter_;
base::WeakPtrFactory<CefBrowserContext> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserContext);
};

View File

@@ -8,6 +8,7 @@
#include <string>
#include <utility>
#include "libcef/browser/audio_capturer.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h"
@@ -15,8 +16,7 @@
#include "libcef/browser/browser_util.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools/devtools_frontend.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/devtools/devtools_manager.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/extensions/extension_background_host.h"
#include "libcef/browser/extensions/extension_system.h"
@@ -47,6 +47,8 @@
#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/favicon/core/favicon_url.h"
#include "components/spellcheck/common/spellcheck_features.h"
#include "components/zoom/zoom_controller.h"
#include "content/browser/gpu/compositor_util.h"
#include "content/browser/web_contents/web_contents_impl.h"
@@ -69,7 +71,6 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/favicon_url.h"
#include "extensions/browser/process_manager.h"
#include "net/base/net_errors.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
@@ -193,6 +194,9 @@ void OnDownloadImage(uint32 max_image_size,
image_impl.get());
}
static constexpr base::TimeDelta kRecentlyAudibleTimeout =
base::TimeDelta::FromSeconds(2);
} // namespace
// CefBrowserHost static methods.
@@ -547,26 +551,6 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::GetBrowserForFrameRoute(
// CefBrowserHostImpl methods.
// -----------------------------------------------------------------------------
// WebContentsObserver that will be notified when the frontend WebContents is
// destroyed so that the inspected browser can clear its DevTools references.
class CefBrowserHostImpl::DevToolsWebContentsObserver
: public content::WebContentsObserver {
public:
DevToolsWebContentsObserver(CefBrowserHostImpl* browser,
content::WebContents* frontend_web_contents)
: WebContentsObserver(frontend_web_contents), browser_(browser) {}
// WebContentsObserver methods:
void WebContentsDestroyed() override {
browser_->OnDevToolsWebContentsDestroyed();
}
private:
CefBrowserHostImpl* browser_;
DISALLOW_COPY_AND_ASSIGN(DevToolsWebContentsObserver);
};
CefBrowserHostImpl::~CefBrowserHostImpl() {}
CefRefPtr<CefBrowser> CefBrowserHostImpl::GetBrowser() {
@@ -859,39 +843,29 @@ void CefBrowserHostImpl::ShowDevTools(const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at) {
if (CEF_CURRENTLY_ON_UIT()) {
if (!web_contents())
return;
if (devtools_frontend_) {
if (!inspect_element_at.IsEmpty()) {
devtools_frontend_->InspectElementAt(inspect_element_at.x,
inspect_element_at.y);
}
devtools_frontend_->Focus();
return;
}
devtools_frontend_ = CefDevToolsFrontend::Show(
this, windowInfo, client, settings, inspect_element_at);
devtools_observer_.reset(new DevToolsWebContentsObserver(
this, devtools_frontend_->frontend_browser()->web_contents()));
} else {
if (!CEF_CURRENTLY_ON_UIT()) {
ShowDevToolsHelper* helper = new ShowDevToolsHelper(
this, windowInfo, client, settings, inspect_element_at);
CEF_POST_TASK(CEF_UIT, base::BindOnce(ShowDevToolsWithHelper, helper));
return;
}
if (!EnsureDevToolsManager())
return;
devtools_manager_->ShowDevTools(windowInfo, client, settings,
inspect_element_at);
}
void CefBrowserHostImpl::CloseDevTools() {
if (CEF_CURRENTLY_ON_UIT()) {
if (!devtools_frontend_)
return;
devtools_frontend_->Close();
} else {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefBrowserHostImpl::CloseDevTools, this));
return;
}
if (!devtools_manager_)
return;
devtools_manager_->CloseDevTools();
}
bool CefBrowserHostImpl::HasDevTools() {
@@ -900,7 +874,84 @@ bool CefBrowserHostImpl::HasDevTools() {
return false;
}
return (devtools_frontend_ != nullptr);
if (!devtools_manager_)
return false;
return devtools_manager_->HasDevTools();
}
bool CefBrowserHostImpl::SendDevToolsMessage(const void* message,
size_t message_size) {
if (!message || message_size == 0)
return false;
if (!CEF_CURRENTLY_ON_UIT()) {
std::string message_str(static_cast<const char*>(message), message_size);
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
[](CefRefPtr<CefBrowserHostImpl> self, std::string message_str) {
self->SendDevToolsMessage(message_str.data(), message_str.size());
},
CefRefPtr<CefBrowserHostImpl>(this), std::move(message_str)));
return false;
}
if (!EnsureDevToolsManager())
return false;
return devtools_manager_->SendDevToolsMessage(message, message_size);
}
int CefBrowserHostImpl::ExecuteDevToolsMethod(
int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT, base::BindOnce(base::IgnoreResult(
&CefBrowserHostImpl::ExecuteDevToolsMethod),
this, message_id, method, params));
return 0;
}
if (!EnsureDevToolsManager())
return 0;
return devtools_manager_->ExecuteDevToolsMethod(message_id, method, params);
}
CefRefPtr<CefRegistration> CefBrowserHostImpl::AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) {
if (!observer)
return nullptr;
auto registration = CefDevToolsManager::CreateRegistration(observer);
InitializeDevToolsRegistrationOnUIThread(registration);
return registration.get();
}
bool CefBrowserHostImpl::EnsureDevToolsManager() {
CEF_REQUIRE_UIT();
if (!web_contents())
return false;
if (!devtools_manager_) {
devtools_manager_.reset(new CefDevToolsManager(this));
}
return true;
}
void CefBrowserHostImpl::InitializeDevToolsRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
&CefBrowserHostImpl::InitializeDevToolsRegistrationOnUIThread, this,
registration));
return;
}
if (!EnsureDevToolsManager())
return;
devtools_manager_->InitializeRegistrationOnUIThread(registration);
}
void CefBrowserHostImpl::GetNavigationEntries(
@@ -1056,16 +1107,18 @@ void CefBrowserHostImpl::AddWordToDictionary(const CefString& word) {
if (!web_contents())
return;
SpellcheckService* spellcheck = nullptr;
content::BrowserContext* browser_context =
web_contents()->GetBrowserContext();
if (browser_context) {
SpellcheckService* spellcheck =
SpellcheckServiceFactory::GetForContext(browser_context);
spellcheck = SpellcheckServiceFactory::GetForContext(browser_context);
if (spellcheck)
spellcheck->GetCustomDictionary()->AddWord(word);
}
#if defined(OS_MACOSX)
spellcheck_platform::AddWord(word);
if (spellcheck && spellcheck::UseBrowserSpellChecker()) {
spellcheck_platform::AddWord(spellcheck->platform_spell_checker(), word);
}
#endif
}
@@ -1556,6 +1609,12 @@ void CefBrowserHostImpl::DestroyBrowser() {
javascript_dialog_manager_.reset(nullptr);
menu_manager_.reset(nullptr);
// Delete the audio capturer
recently_audible_timer_.Stop();
audio_capturer_.reset(nullptr);
devtools_manager_.reset(nullptr);
// Delete the platform delegate.
platform_delegate_.reset(nullptr);
@@ -2644,16 +2703,24 @@ void CefBrowserHostImpl::DidStopLoading() {
}
void CefBrowserHostImpl::DocumentAvailableInMainFrame() {
base::AutoLock lock_scope(state_lock_);
has_document_ = true;
{
base::AutoLock lock_scope(state_lock_);
has_document_ = true;
}
if (client_) {
CefRefPtr<CefRequestHandler> handler = client_->GetRequestHandler();
if (handler)
handler->OnDocumentAvailableInMainFrame(this);
}
}
void CefBrowserHostImpl::DidFailLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code) {
// The navigation failed after commit. OnLoadStart was called so we also call
// OnLoadEnd.
// The navigation failed after commit. OnLoadStart was called so we also
// call OnLoadEnd.
auto frame = browser_info_->GetFrameForHost(render_frame_host);
frame->RefreshAttributes();
OnLoadError(frame, validated_url, error_code);
@@ -2679,15 +2746,14 @@ void CefBrowserHostImpl::PluginCrashed(const base::FilePath& plugin_path,
}
void CefBrowserHostImpl::DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& candidates) {
const std::vector<blink::mojom::FaviconURLPtr>& candidates) {
if (client_.get()) {
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
if (handler.get()) {
std::vector<CefString> icon_urls;
std::vector<content::FaviconURL>::const_iterator it = candidates.begin();
for (; it != candidates.end(); ++it) {
if (it->icon_type == content::FaviconURL::IconType::kFavicon)
icon_urls.push_back(it->icon_url.spec());
for (const auto& icon : candidates) {
if (icon->icon_type == blink::mojom::FaviconIconType::kFavicon)
icon_urls.push_back(icon->icon_url.spec());
}
if (!icon_urls.empty())
handler->OnFaviconURLChange(this, icon_urls);
@@ -2695,6 +2761,25 @@ void CefBrowserHostImpl::DidUpdateFaviconURL(
}
}
void CefBrowserHostImpl::OnAudioStateChanged(bool audible) {
if (audible) {
recently_audible_timer_.Stop();
StartAudioCapturer();
} else if (audio_capturer_) {
// If you have a media playing that has a short quiet moment, web_contents
// will immediately switch to non-audible state. We don't want to stop
// audio stream so quickly, let's give the stream some time to resume
// playing.
recently_audible_timer_.Start(
FROM_HERE, kRecentlyAudibleTimeout,
base::BindOnce(&CefBrowserHostImpl::OnRecentlyAudibleTimerFired, this));
}
}
void CefBrowserHostImpl::OnRecentlyAudibleTimerFired() {
audio_capturer_.reset();
}
bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) {
// Handle the cursor message here if mouse cursor change is disabled instead
// of propegating the message to the normal handler.
@@ -2790,6 +2875,25 @@ bool CefBrowserHostImpl::HasObserver(Observer* observer) const {
return observers_.HasObserver(observer);
}
void CefBrowserHostImpl::StartAudioCapturer() {
if (!client_.get() || audio_capturer_)
return;
CefRefPtr<CefAudioHandler> audio_handler = client_->GetAudioHandler();
if (!audio_handler.get())
return;
CefAudioParameters params;
params.channel_layout = CEF_CHANNEL_LAYOUT_STEREO;
params.sample_rate = media::AudioParameters::kAudioCDSampleRate;
params.frames_per_buffer = 1024;
if (!audio_handler->GetAudioParameters(this, params))
return;
audio_capturer_.reset(new CefAudioCapturer(params, this, audio_handler));
}
CefBrowserHostImpl::NavigationLock::NavigationLock(
CefRefPtr<CefBrowserHostImpl> browser)
: browser_(browser) {
@@ -2861,18 +2965,6 @@ CefBrowserHostImpl::CefBrowserHostImpl(
platform_delegate_(std::move(platform_delegate)),
is_windowless_(platform_delegate_->IsWindowless()),
is_views_hosted_(platform_delegate_->IsViewsHosted()),
host_window_handle_(kNullWindowHandle),
is_loading_(false),
can_go_back_(false),
can_go_forward_(false),
has_document_(false),
is_fullscreen_(false),
destruction_state_(DESTRUCTION_STATE_NONE),
window_destroyed_(false),
is_in_onsetfocus_(false),
focus_on_editable_field_(false),
mouse_cursor_change_disabled_(false),
devtools_frontend_(nullptr),
extension_(extension) {
if (opener.get() && !platform_delegate_->IsViewsHosted()) {
// GetOpenerWindowHandle() only returns a value for non-views-hosted
@@ -3083,11 +3175,6 @@ void CefBrowserHostImpl::OnTitleChange(const base::string16& title) {
}
}
void CefBrowserHostImpl::OnDevToolsWebContentsDestroyed() {
devtools_observer_.reset();
devtools_frontend_ = nullptr;
}
void CefBrowserHostImpl::EnsureFileDialogManager() {
CEF_REQUIRE_UIT();
if (!file_dialog_manager_.get() && platform_delegate_) {

View File

@@ -48,9 +48,10 @@ class Widget;
}
#endif // defined(USE_AURA)
class CefAudioCapturer;
class CefBrowserInfo;
class CefBrowserPlatformDelegate;
class CefDevToolsFrontend;
class CefDevToolsManager;
class SiteInstance;
// Implementation of CefBrowser.
@@ -191,6 +192,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
const CefPoint& inspect_element_at) override;
void CloseDevTools() override;
bool HasDevTools() override;
bool SendDevToolsMessage(const void* message, size_t message_size) override;
int ExecuteDevToolsMethod(int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) override;
CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) override;
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
bool current_only) override;
void SetMouseCursorChangeDisabled(bool disabled) override;
@@ -485,7 +492,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override;
void DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& candidates) override;
const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
void OnAudioStateChanged(bool audible) override;
bool OnMessageReceived(const IPC::Message& message) override;
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
@@ -505,6 +513,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
bool HasObserver(Observer* observer) const;
class NavigationLock final {
private:
friend class CefBrowserHostImpl;
@@ -520,8 +529,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
std::unique_ptr<NavigationLock> CreateNavigationLock();
private:
class DevToolsWebContentsObserver;
static CefRefPtr<CefBrowserHostImpl> CreateInternal(
const CefBrowserSettings& settings,
CefRefPtr<CefClient> client,
@@ -578,13 +585,19 @@ class CefBrowserHostImpl : public CefBrowserHost,
void OnFullscreenModeChange(bool fullscreen);
void OnTitleChange(const base::string16& title);
void OnDevToolsWebContentsDestroyed();
// Create the CefFileDialogManager if it doesn't already exist.
void EnsureFileDialogManager();
void ConfigureAutoResize();
void StartAudioCapturer();
void OnRecentlyAudibleTimerFired();
bool EnsureDevToolsManager();
void InitializeDevToolsRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration);
CefBrowserSettings settings_;
CefRefPtr<CefClient> client_;
scoped_refptr<CefBrowserInfo> browser_info_;
@@ -593,7 +606,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate_;
const bool is_windowless_;
const bool is_views_hosted_;
CefWindowHandle host_window_handle_;
CefWindowHandle host_window_handle_ = kNullWindowHandle;
// Non-nullptr if this object owns the WebContents. Will be nullptr for popup
// browsers between the calls to WebContentsCreated() and AddNewContents(),
@@ -603,18 +616,18 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Volatile state information. All access must be protected by the state lock.
base::Lock state_lock_;
bool is_loading_;
bool can_go_back_;
bool can_go_forward_;
bool has_document_;
bool is_fullscreen_;
bool is_loading_ = false;
bool can_go_back_ = false;
bool can_go_forward_ = false;
bool has_document_ = false;
bool is_fullscreen_ = false;
// The currently focused frame, or nullptr if the main frame is focused.
CefRefPtr<CefFrameHostImpl> focused_frame_;
// Represents the current browser destruction state. Only accessed on the UI
// thread.
DestructionState destruction_state_;
DestructionState destruction_state_ = DESTRUCTION_STATE_NONE;
// Navigation will not occur while |navigation_lock_count_| > 0.
// |pending_navigation_action_| will be executed when the lock is released.
@@ -624,18 +637,18 @@ class CefBrowserHostImpl : public CefBrowserHost,
// True if the OS window hosting the browser has been destroyed. Only accessed
// on the UI thread.
bool window_destroyed_;
bool window_destroyed_ = false;
// True if currently in the OnSetFocus callback. Only accessed on the UI
// thread.
bool is_in_onsetfocus_;
bool is_in_onsetfocus_ = false;
// True if the focus is currently on an editable field on the page. Only
// accessed on the UI thread.
bool focus_on_editable_field_;
bool focus_on_editable_field_ = false;
// True if mouse cursor change is disabled.
bool mouse_cursor_change_disabled_;
bool mouse_cursor_change_disabled_ = false;
// Used for managing notification subscriptions.
std::unique_ptr<content::NotificationRegistrar> registrar_;
@@ -649,12 +662,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Used for creating and managing context menus.
std::unique_ptr<CefMenuManager> menu_manager_;
// Track the lifespan of the frontend WebContents associated with this
// browser.
std::unique_ptr<DevToolsWebContentsObserver> devtools_observer_;
// CefDevToolsFrontend will delete itself when the frontend WebContents is
// destroyed.
CefDevToolsFrontend* devtools_frontend_;
// Used for creating and managing DevTools instances.
std::unique_ptr<CefDevToolsManager> devtools_manager_;
// Observers that want to be notified of changes to this object.
base::ObserverList<Observer>::Unchecked observers_;
@@ -667,6 +676,14 @@ class CefBrowserHostImpl : public CefBrowserHost,
CefRefPtr<CefExtension> extension_;
bool is_background_host_ = false;
// Used for capturing audio for CefAudioHandler.
std::unique_ptr<CefAudioCapturer> audio_capturer_;
// Timer for determining when "recently audible" transitions to false. This
// starts running when a tab stops being audible, and is canceled if it starts
// being audible again before it fires.
base::OneShotTimer recently_audible_timer_;
// Used with auto-resize.
bool auto_resize_enabled_ = false;
gfx::Size auto_resize_min_;

View File

@@ -32,11 +32,11 @@
#include "chrome/browser/plugins/plugin_finder.h"
#include "components/constrained_window/constrained_window_views.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/network_service_instance.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "net/base/net_module.h"
#include "services/service_manager/embedder/result_codes.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#if defined(USE_AURA) && defined(USE_X11)
@@ -50,6 +50,8 @@
#include "ui/wm/core/wm_state.h"
#if defined(OS_WIN)
#include "chrome/browser/chrome_browser_main_win.h"
#include "chrome/browser/win/parental_controls.h"
#include "components/os_crypt/os_crypt.h"
#include "ui/base/cursor/cursor_loader_win.h"
#endif
@@ -124,7 +126,11 @@ void CefBrowserMainParts::PreMainMessageLoopStart() {
DCHECK(local_state);
bool os_crypt_init = OSCrypt::Init(local_state);
DCHECK(os_crypt_init);
#endif
// installer_util references strings that are normally compiled into
// setup.exe. In Chrome, these strings are in the locale files.
ChromeBrowserMainPartsWin::SetupInstallerUtilStrings();
#endif // defined(OS_WIN)
}
void CefBrowserMainParts::PostMainMessageLoopStart() {
@@ -156,8 +162,6 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
display::Screen::SetScreenInstance(views::CreateDesktopScreen());
#endif
ui::MaterialDesignController::Initialize();
if (extensions::ExtensionsEnabled()) {
// Initialize extension global objects before creating the global
// BrowserContext.
@@ -187,7 +191,7 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
CefRequestContextSettings settings;
CefContext::Get()->PopulateRequestContextSettings(&settings);
CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
// Create the global RequestContext.
global_request_context_ =
@@ -197,6 +201,12 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
CefDevToolsManagerDelegate::StartHttpHandler(browser_context);
#if defined(OS_WIN)
// Windows parental controls calls can be slow, so we do an early init here
// that calculates this value off of the UI thread.
InitializeWinParentalControls();
#endif
// Triggers initialization of the singleton instance on UI thread.
PluginFinder::GetInstance()->Init();

View File

@@ -34,11 +34,17 @@ class MessagePumpExternal : public base::MessagePumpForUI {
base::mac::ScopedNSAutoreleasePool autorelease_pool;
#endif
const bool has_more_work = DirectRunWork(delegate);
base::TimeTicks next_run_time; // is_null()
const bool has_more_work = DirectRunWork(delegate, &next_run_time);
if (!has_more_work)
break;
const base::TimeDelta& delta = base::TimeTicks::Now() - start;
if (next_run_time.is_null()) {
// We have more work that should run immediately.
next_run_time = base::TimeTicks::Now();
}
const base::TimeDelta& delta = next_run_time - start;
if (delta.InSecondsF() > max_time_slice_)
break;
}
@@ -54,26 +60,31 @@ class MessagePumpExternal : public base::MessagePumpForUI {
}
private:
bool DirectRunWork(Delegate* delegate) {
bool did_work = false;
bool did_delayed_work = false;
bool did_idle_work = false;
static bool DirectRunWork(Delegate* delegate,
base::TimeTicks* next_run_time) {
bool more_immediate_work = false;
bool more_idle_work = false;
bool more_delayed_work = false;
// Perform work & delayed work.
// If no work was found, then perform idle work.
Delegate::NextWorkInfo next_work_info = delegate->DoWork();
did_work = delegate->DoWork();
// is_immediate() returns true if the next task is ready right away.
more_immediate_work = next_work_info.is_immediate();
if (!more_immediate_work) {
// DoIdleWork() returns true if idle work was all done.
more_idle_work = !delegate->DoIdleWork();
// 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();
// Check the next PendingTask's |delayed_run_time|.
// is_max() returns true if there are no more immediate nor delayed tasks.
more_delayed_work = !next_work_info.delayed_run_time.is_max();
if (more_delayed_work && !more_idle_work) {
// The only remaining work that we know about is the PendingTask.
// Consider the run time for that task in the time slice calculation.
*next_run_time = next_work_info.delayed_run_time;
}
}
return did_work || did_delayed_work || did_idle_work;
return more_immediate_work || more_idle_work || more_delayed_work;
}
const float max_time_slice_;

View File

@@ -157,13 +157,17 @@ ProfileManager* ChromeBrowserProcessStub::profile_manager() {
PrefService* ChromeBrowserProcessStub::local_state() {
DCHECK(initialized_);
if (!local_state_) {
// Use a location that is shared by all request contexts.
const CefSettings& settings = CefContext::Get()->settings();
const base::FilePath& cache_path =
base::FilePath(CefString(&settings.cache_path));
const base::FilePath& root_cache_path =
base::FilePath(CefString(&settings.root_cache_path));
// Used for very early NetworkService initialization.
local_state_ = browser_prefs::CreatePrefService(
nullptr, cache_path, !!settings.persist_user_preferences);
// Always persist preferences for this PrefService if possible because it
// contains the cookie encryption key on Windows.
local_state_ =
browser_prefs::CreatePrefService(nullptr /* profile */, root_cache_path,
true /* persist_user_preferences */);
}
return local_state_.get();
}
@@ -370,3 +374,8 @@ ChromeBrowserProcessStub::resource_coordinator_parts() {
NOTREACHED();
return nullptr;
}
BuildState* ChromeBrowserProcessStub::GetBuildState() {
NOTREACHED();
return nullptr;
}

View File

@@ -98,6 +98,7 @@ class ChromeBrowserProcessStub : public BrowserProcess {
resource_coordinator::TabManager* GetTabManager() override;
resource_coordinator::ResourceCoordinatorParts* resource_coordinator_parts()
override;
BuildState* GetBuildState() override;
private:
bool initialized_;

View File

@@ -5,9 +5,35 @@
#include "libcef/browser/chrome_profile_stub.h"
#include "components/variations/variations_client.h"
#include "components/variations/variations_http_header_provider.h"
#include "content/public/browser/resource_context.h"
#include "net/url_request/url_request_context.h"
namespace {
class CefVariationsClient : public variations::VariationsClient {
public:
explicit CefVariationsClient(content::BrowserContext* browser_context)
: browser_context_(browser_context) {}
~CefVariationsClient() override = default;
bool IsIncognito() const override {
return browser_context_->IsOffTheRecord();
}
std::string GetVariationsHeader() const override {
return variations::VariationsHttpHeaderProvider::GetInstance()
->GetClientDataHeader(false /* is_signed_in */);
}
private:
content::BrowserContext* browser_context_;
};
} // namespace
ChromeProfileStub::ChromeProfileStub() {}
ChromeProfileStub::~ChromeProfileStub() {}
@@ -20,6 +46,12 @@ bool ChromeProfileStub::IsOffTheRecord() const {
return false;
}
variations::VariationsClient* ChromeProfileStub::GetVariationsClient() {
if (!variations_client_)
variations_client_ = std::make_unique<CefVariationsClient>(this);
return variations_client_.get();
}
scoped_refptr<base::SequencedTaskRunner> ChromeProfileStub::GetIOTaskRunner() {
NOTREACHED();
return scoped_refptr<base::SequencedTaskRunner>();

View File

@@ -22,6 +22,7 @@ class ChromeProfileStub : public Profile {
// Profile methods.
bool IsOffTheRecord() override;
bool IsOffTheRecord() const override;
variations::VariationsClient* GetVariationsClient() override;
scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override;
std::string GetProfileUserName() const override;
ProfileType GetProfileType() const override;
@@ -48,6 +49,8 @@ class ChromeProfileStub : public Profile {
void SetCreationTimeForTesting(base::Time creation_time) override;
private:
std::unique_ptr<variations::VariationsClient> variations_client_;
DISALLOW_COPY_AND_ASSIGN(ChromeProfileStub);
};

View File

@@ -77,7 +77,6 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/overlay_window.h"
@@ -102,6 +101,7 @@
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/url_loader_factory_manager.h"
#include "extensions/common/constants.h"
#include "extensions/common/switches.h"
#include "mojo/public/cpp/bindings/remote.h"
@@ -115,6 +115,8 @@
#include "services/service_manager/public/mojom/connector.mojom.h"
#include "services/service_manager/sandbox/switches.h"
#include "storage/browser/quota/quota_settings.h"
#include "third_party/blink/public/mojom/insecure_input/insecure_input_service.mojom.h"
#include "third_party/blink/public/mojom/prerender/prerender.mojom.h"
#include "third_party/blink/public/web/web_window_features.h"
#include "third_party/widevine/cdm/buildflags.h"
#include "ui/base/l10n/l10n_util.h"
@@ -129,8 +131,8 @@
#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include "base/debug/leak_annotations.h"
#include "chrome/common/chrome_paths.h"
#include "components/crash/content/app/breakpad_linux.h"
#include "components/crash/content/browser/crash_handler_host_linux.h"
#include "components/crash/core/app/breakpad_linux.h"
#include "content/public/common/content_descriptors.h"
#endif
@@ -505,6 +507,30 @@ void BindPluginInfoHost(
std::move(receiver));
}
base::FilePath GetRootCachePath() {
// The CefContext::ValidateCachePath method enforces the requirement that all
// cache_path values be either equal to or a child of root_cache_path.
return base::FilePath(
CefString(&CefContext::Get()->settings().root_cache_path));
}
// Register BrowserInterfaceBroker's GetInterface() handler callbacks for
// chrome-specific document-scoped interfaces.
// Stub implementations to silence "Empty binder for interface
// blink.mojom.[Name] for the frame/document scope" errors.
// Based on chrome/browser/chrome_browser_interface_binders.cc.
void PopulateChromeFrameBinders(
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map) {
map->Add<blink::mojom::InsecureInputService>(base::BindRepeating(
[](content::RenderFrameHost* frame_host,
mojo::PendingReceiver<blink::mojom::InsecureInputService> receiver) {
}));
map->Add<blink::mojom::PrerenderProcessor>(base::BindRepeating(
[](content::RenderFrameHost* frame_host,
mojo::PendingReceiver<blink::mojom::PrerenderProcessor> receiver) {}));
}
} // namespace
CefContentBrowserClient::CefContentBrowserClient()
@@ -600,6 +626,17 @@ bool CefContentBrowserClient::DoesSiteRequireDedicatedProcess(
return extension != nullptr;
}
void CefContentBrowserClient::OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
const url::Origin& origin,
bool is_for_isolated_world,
network::mojom::URLLoaderFactoryParams* factory_params) {
if (extensions::ExtensionsEnabled()) {
extensions::URLLoaderFactoryManager::OverrideURLLoaderFactoryParams(
browser_context, origin, is_for_isolated_world, factory_params);
}
}
void CefContentBrowserClient::GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) {
// Any schemes listed here are treated as WebUI schemes but do not get WebUI
@@ -1088,16 +1125,13 @@ CefContentBrowserClient::CreateURLLoaderThrottles(
request.resource_type, frame_tree_node_id));
Profile* profile = Profile::FromBrowserContext(browser_context);
bool is_off_the_record = profile->IsOffTheRecord();
chrome::mojom::DynamicParams dynamic_params = {
profile->GetPrefs()->GetBoolean(prefs::kForceGoogleSafeSearch),
profile->GetPrefs()->GetInteger(prefs::kForceYouTubeRestrict),
profile->GetPrefs()->GetString(prefs::kAllowedDomainsForApps),
variations::VariationsHttpHeaderProvider::GetInstance()
->GetClientDataHeader(false /* is_signed_in */)};
result.push_back(std::make_unique<GoogleURLLoaderThrottle>(
is_off_the_record, std::move(dynamic_params)));
profile->GetPrefs()->GetString(prefs::kAllowedDomainsForApps)};
result.push_back(
std::make_unique<GoogleURLLoaderThrottle>(std::move(dynamic_params)));
return result;
}
@@ -1300,10 +1334,7 @@ CefContentBrowserClient::GetNetworkContextsParentDirectory() {
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_path);
DCHECK(!user_data_path.empty());
// The CefContext::ValidateCachePath method enforces the requirement that all
// cache_path values be either equal to or a child of root_cache_path.
const base::FilePath& root_cache_path =
base::FilePath(CefString(&CefContext::Get()->settings().root_cache_path));
const auto& root_cache_path = GetRootCachePath();
// root_cache_path may sometimes be empty or a child of user_data_path, so
// only return the one path in that case.
@@ -1380,6 +1411,8 @@ CefContentBrowserClient::CreateWindowForPictureInPicture(
void CefContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map) {
PopulateChromeFrameBinders(map);
if (!extensions::ExtensionsEnabled())
return;
@@ -1404,6 +1437,11 @@ void CefContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
extension);
}
base::FilePath
CefContentBrowserClient::GetSandboxedStorageServiceDataDirectory() {
return GetRootCachePath();
}
std::string CefContentBrowserClient::GetProduct() {
// Match the logic in chrome_content_browser_client.cc GetProduct().
return ::GetProduct();
@@ -1442,16 +1480,6 @@ CefContentBrowserClient::GetPluginMimeTypesWithExternalHandlers(
return mime_types;
}
void CefContentBrowserClient::RegisterCustomScheme(const std::string& scheme) {
// Register as a Web-safe scheme so that requests for the scheme from a
// render process will be allowed in resource_dispatcher_host_impl.cc
// ShouldServiceRequest.
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
if (!policy->IsWebSafeScheme(scheme))
policy->RegisterWebSafeScheme(scheme);
}
CefRefPtr<CefRequestContextImpl> CefContentBrowserClient::request_context()
const {
return browser_main_parts_->request_context();

View File

@@ -46,6 +46,11 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
const GURL& effective_url) override;
bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context,
const GURL& effective_site_url) override;
void OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
const url::Origin& origin,
bool is_for_isolated_world,
network::mojom::URLLoaderFactoryParams* factory_params) override;
void GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) override;
void GetAdditionalViewSourceSchemes(
@@ -197,7 +202,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
content::RenderFrameHost* render_frame_host,
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map)
override;
base::FilePath GetSandboxedStorageServiceDataDirectory() override;
std::string GetProduct() override;
std::string GetChromeProduct() override;
std::string GetUserAgent() override;
@@ -205,9 +210,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers(
content::BrowserContext* browser_context) override;
// Perform browser process registration for the custom scheme.
void RegisterCustomScheme(const std::string& scheme);
CefRefPtr<CefRequestContextImpl> request_context() const;
CefDevToolsDelegate* devtools_delegate() const;

View File

@@ -37,13 +37,13 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/chrome_elf/chrome_elf_main.h"
#include "chrome/install_static/initialize_from_primary_module.h"
#include "components/crash/content/app/crashpad.h"
#include "components/crash/core/app/crashpad.h"
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#endif
#if defined(OS_MACOSX) || defined(OS_WIN)
#include "components/crash/content/app/crash_switches.h"
#include "components/crash/core/app/crash_switches.h"
#include "third_party/crashpad/crashpad/handler/handler_main.h"
#endif
@@ -97,12 +97,12 @@ void InitCrashReporter() {
#if defined(OS_MACOSX) || defined(OS_WIN)
// Based on components/crash/content/app/run_as_crashpad_handler_win.cc
// Based on components/crash/core/app/run_as_crashpad_handler_win.cc
// Remove the "--type=crashpad-handler" command-line flag that will otherwise
// confuse the crashpad handler.
// Chrome uses an embedded crashpad handler on Windows only and imports this
// function via the existing "run_as_crashpad_handler" target defined in
// components/crash/content/app/BUILD.gn. CEF uses an embedded handler on both
// components/crash/core/app/BUILD.gn. CEF uses an embedded handler on both
// Windows and macOS so we define the function here instead of using the
// existing target (because we can't use that target on macOS).
int RunAsCrashpadHandler(const base::CommandLine& command_line) {
@@ -160,6 +160,85 @@ bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) {
return true;
}
// Convert |path_str| to a normalized FilePath.
base::FilePath NormalizePath(const cef_string_t& path_str,
const char* name,
bool* has_error = nullptr) {
if (has_error)
*has_error = false;
base::FilePath path = base::FilePath(CefString(&path_str));
if (path.EndsWithSeparator()) {
// Remove the trailing separator because it will interfere with future
// equality checks.
path = path.StripTrailingSeparators();
}
if (!path.empty() && !path.IsAbsolute()) {
LOG(ERROR) << "The " << name << " directory (" << path.value()
<< ") is not an absolute path. Defaulting to empty.";
if (has_error)
*has_error = true;
path = base::FilePath();
}
return path;
}
void SetPath(cef_string_t& path_str, const base::FilePath& path) {
#if defined(OS_WIN)
CefString(&path_str).FromWString(path.value());
#else
CefString(&path_str).FromString(path.value());
#endif
}
// Convert |path_str| to a normalized FilePath and update the |path_str| value.
base::FilePath NormalizePathAndSet(cef_string_t& path_str, const char* name) {
const base::FilePath& path = NormalizePath(path_str, name);
SetPath(path_str, path);
return path;
}
// Verify that |cache_path| is valid and create it if necessary.
bool ValidateCachePath(const base::FilePath& cache_path,
const base::FilePath& root_cache_path) {
if (cache_path.empty())
return true;
if (!root_cache_path.empty() && root_cache_path != cache_path &&
!root_cache_path.IsParent(cache_path)) {
LOG(ERROR) << "The cache_path directory (" << cache_path.value()
<< ") is not a child of the root_cache_path directory ("
<< root_cache_path.value() << ")";
return false;
}
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (!base::DirectoryExists(cache_path) &&
!base::CreateDirectory(cache_path)) {
LOG(ERROR) << "The cache_path directory (" << cache_path.value()
<< ") could not be created.";
return false;
}
return true;
}
// Like NormalizePathAndSet but with additional checks specific to the
// cache_path value.
base::FilePath NormalizeCachePathAndSet(cef_string_t& path_str,
const base::FilePath& root_cache_path) {
bool has_error = false;
base::FilePath path = NormalizePath(path_str, "cache_path", &has_error);
if (has_error || !ValidateCachePath(path, root_cache_path)) {
LOG(ERROR) << "The cache_path is invalid. Defaulting to in-memory storage.";
path = base::FilePath();
}
SetPath(path_str, path);
return path;
}
} // namespace
int CefExecuteProcess(const CefMainArgs& args,
@@ -370,18 +449,23 @@ bool CefContext::Initialize(const CefMainArgs& args,
SignalChromeElf();
#endif
base::FilePath cache_path = base::FilePath(CefString(&settings_.cache_path));
if (!ValidateCachePath(cache_path)) {
// Reset to in-memory storage.
CefString(&settings_.cache_path).clear();
cache_path = base::FilePath();
}
const base::FilePath& root_cache_path =
base::FilePath(CefString(&settings_.root_cache_path));
NormalizePathAndSet(settings_.root_cache_path, "root_cache_path");
const base::FilePath& cache_path =
NormalizeCachePathAndSet(settings_.cache_path, root_cache_path);
if (root_cache_path.empty() && !cache_path.empty()) {
CefString(&settings_.root_cache_path) = CefString(&settings_.cache_path);
CefString(&settings_.root_cache_path) = cache_path.value();
}
// All other paths that need to be normalized.
NormalizePathAndSet(settings_.browser_subprocess_path,
"browser_subprocess_path");
NormalizePathAndSet(settings_.framework_dir_path, "framework_dir_path");
NormalizePathAndSet(settings_.main_bundle_path, "main_bundle_path");
NormalizePathAndSet(settings_.user_data_path, "user_data_path");
NormalizePathAndSet(settings_.resources_dir_path, "resources_dir_path");
NormalizePathAndSet(settings_.locales_dir_path, "locales_dir_path");
main_delegate_.reset(new CefMainDelegate(application));
browser_info_manager_.reset(new CefBrowserInfoManager);
@@ -392,7 +476,6 @@ bool CefContext::Initialize(const CefMainArgs& args,
#if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (windows_sandbox_info == nullptr) {
content::InitializeSandboxInfo(&sandbox_info);
windows_sandbox_info = &sandbox_info;
settings_.no_sandbox = true;
}
@@ -519,11 +602,14 @@ CefTraceSubscriber* CefContext::GetTraceSubscriber() {
return trace_subscriber_.get();
}
void CefContext::PopulateRequestContextSettings(
void CefContext::PopulateGlobalRequestContextSettings(
CefRequestContextSettings* settings) {
CefRefPtr<CefCommandLine> command_line =
CefCommandLine::GetGlobalCommandLine();
// This value was already normalized in Initialize.
CefString(&settings->cache_path) = CefString(&settings_.cache_path);
settings->persist_session_cookies =
settings_.persist_session_cookies ||
command_line->HasSwitch(switches::kPersistSessionCookies);
@@ -537,29 +623,17 @@ void CefContext::PopulateRequestContextSettings(
CefString(&settings_.accept_language_list);
}
bool CefContext::ValidateCachePath(const base::FilePath& cache_path) {
if (cache_path.empty())
return true;
void CefContext::NormalizeRequestContextSettings(
CefRequestContextSettings* settings) {
// The |root_cache_path| value was already normalized in Initialize.
const base::FilePath& root_cache_path = CefString(&settings_.root_cache_path);
NormalizeCachePathAndSet(settings->cache_path, root_cache_path);
const base::FilePath& root_cache_path =
base::FilePath(CefString(&settings_.root_cache_path));
if (!root_cache_path.empty() && root_cache_path != cache_path &&
!root_cache_path.IsParent(cache_path)) {
LOG(ERROR) << "The cache_path directory (" << cache_path.value()
<< ") is not a child of the root_cache_path directory ("
<< root_cache_path.value() << ")";
return false;
if (settings->accept_language_list.length == 0) {
// Use the global language list setting.
CefString(&settings->accept_language_list) =
CefString(&settings_.accept_language_list);
}
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (!base::DirectoryExists(cache_path) &&
!base::CreateDirectory(cache_path)) {
LOG(ERROR) << "The cache_path directory (" << cache_path.value()
<< ") could not be created.";
return false;
}
return true;
}
void CefContext::AddObserver(Observer* observer) {

View File

@@ -87,10 +87,11 @@ class CefContext {
// Populate request context settings for the global system context based on
// CefSettings and command-line flags.
void PopulateRequestContextSettings(CefRequestContextSettings* settings);
void PopulateGlobalRequestContextSettings(
CefRequestContextSettings* settings);
// Verify that |cache_path| is valid and create it if necessary.
bool ValidateCachePath(const base::FilePath& cache_path);
// Normalize and validate request context settings for user-created contexts.
void NormalizeRequestContextSettings(CefRequestContextSettings* settings);
// Manage observer objects. The observer must either outlive this object or
// remove itself before destruction. These methods can only be called on the

View File

@@ -9,7 +9,7 @@
#include "include/cef_context_menu_handler.h"
#include "libcef/common/value_base.h"
#include "content/public/common/context_menu_params.h"
#include "content/public/browser/context_menu_params.h"
// CefContextMenuParams implementation. This class is not thread safe.
class CefContextMenuParamsImpl

View File

@@ -0,0 +1,137 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/devtools/devtools_controller.h"
#include "libcef/browser/devtools/devtools_util.h"
#include "libcef/browser/thread_util.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "content/public/browser/devtools_agent_host.h"
CefDevToolsController::CefDevToolsController(
content::WebContents* inspected_contents)
: inspected_contents_(inspected_contents), weak_ptr_factory_(this) {
DCHECK(inspected_contents_);
}
CefDevToolsController::~CefDevToolsController() {
if (agent_host_) {
agent_host_->DetachClient(this);
AgentHostClosed(agent_host_.get());
}
for (auto& observer : observers_) {
observer.OnDevToolsControllerDestroyed();
}
}
bool CefDevToolsController::SendDevToolsMessage(
const base::StringPiece& message) {
CEF_REQUIRE_UIT();
if (!EnsureAgentHost())
return false;
agent_host_->DispatchProtocolMessage(
this, base::as_bytes(base::make_span(message)));
return true;
}
int CefDevToolsController::ExecuteDevToolsMethod(
int suggested_message_id,
const std::string& method,
const base::DictionaryValue* params) {
CEF_REQUIRE_UIT();
if (!EnsureAgentHost())
return 0;
// Message IDs must always be increasing and unique.
int message_id = suggested_message_id;
if (message_id < next_message_id_)
message_id = next_message_id_++;
else
next_message_id_ = message_id + 1;
base::DictionaryValue message;
message.SetIntKey("id", message_id);
message.SetStringKey("method", method);
if (params)
message.SetKey("params", params->Clone());
std::string protocol_message;
if (!base::JSONWriter::Write(message, &protocol_message))
return 0;
agent_host_->DispatchProtocolMessage(
this, base::as_bytes(base::make_span(protocol_message)));
return message_id;
}
void CefDevToolsController::AgentHostClosed(
content::DevToolsAgentHost* agent_host) {
DCHECK(agent_host == agent_host_.get());
agent_host_ = nullptr;
for (auto& observer : observers_) {
observer.OnDevToolsAgentDetached();
}
}
void CefDevToolsController::AddObserver(Observer* observer) {
CEF_REQUIRE_UIT();
observers_.AddObserver(observer);
}
void CefDevToolsController::RemoveObserver(Observer* observer) {
CEF_REQUIRE_UIT();
observers_.RemoveObserver(observer);
}
void CefDevToolsController::DispatchProtocolMessage(
content::DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) {
if (!observers_.might_have_observers())
return;
base::StringPiece str_message(reinterpret_cast<const char*>(message.data()),
message.size());
if (!devtools_util::ProtocolParser::IsValidMessage(str_message)) {
LOG(WARNING) << "Invalid message: " << str_message.substr(0, 100);
return;
}
devtools_util::ProtocolParser parser;
for (auto& observer : observers_) {
if (observer.OnDevToolsMessage(str_message)) {
continue;
}
// Only perform parsing a single time.
if (parser.Initialize(str_message) && parser.IsFailure()) {
LOG(WARNING) << "Failed to parse message: " << str_message.substr(0, 100);
}
if (parser.IsEvent()) {
observer.OnDevToolsEvent(parser.method_, parser.params_);
} else if (parser.IsResult()) {
observer.OnDevToolsMethodResult(parser.message_id_, parser.success_,
parser.params_);
}
}
}
bool CefDevToolsController::EnsureAgentHost() {
if (!agent_host_) {
agent_host_ =
content::DevToolsAgentHost::GetOrCreateFor(inspected_contents_);
if (agent_host_) {
agent_host_->AttachClient(this);
for (auto& observer : observers_) {
observer.OnDevToolsAgentAttached();
}
}
}
return !!agent_host_;
}

View File

@@ -0,0 +1,79 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_CONTROLLER_H_
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_CONTROLLER_H_
#include <memory>
#include "content/public/browser/devtools_agent_host_client.h"
#include "base/containers/span.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/values.h"
namespace content {
class WebContents;
}
class CefDevToolsController : public content::DevToolsAgentHostClient {
public:
class Observer : public base::CheckedObserver {
public:
// See CefDevToolsMessageObserver documentation.
virtual bool OnDevToolsMessage(const base::StringPiece& message) = 0;
virtual void OnDevToolsMethodResult(int message_id,
bool success,
const base::StringPiece& result) = 0;
virtual void OnDevToolsEvent(const base::StringPiece& method,
const base::StringPiece& params) = 0;
virtual void OnDevToolsAgentAttached() = 0;
virtual void OnDevToolsAgentDetached() = 0;
virtual void OnDevToolsControllerDestroyed() = 0;
protected:
~Observer() override {}
};
// |inspected_contents| will outlive this object.
explicit CefDevToolsController(content::WebContents* inspected_contents);
~CefDevToolsController() override;
// See CefBrowserHost methods of the same name for documentation.
bool SendDevToolsMessage(const base::StringPiece& message);
int ExecuteDevToolsMethod(int message_id,
const std::string& method,
const base::DictionaryValue* params);
// |observer| must outlive this object or be removed.
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
base::WeakPtr<CefDevToolsController> GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
private:
// content::DevToolsAgentHostClient implementation:
void AgentHostClosed(content::DevToolsAgentHost* agent_host) override;
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) override;
bool EnsureAgentHost();
content::WebContents* const inspected_contents_;
scoped_refptr<content::DevToolsAgentHost> agent_host_;
int next_message_id_ = 1;
base::ObserverList<Observer> observers_;
base::WeakPtrFactory<CefDevToolsController> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefDevToolsController);
};
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_CONTROLLER_H_

View File

@@ -6,13 +6,18 @@
#include <stddef.h>
#include <iomanip>
#include <utility>
#include "libcef/browser/browser_context.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/net/devtools_scheme_handler.h"
#include "libcef/common/cef_switches.h"
#include "base/base64.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/guid.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
@@ -48,6 +53,13 @@
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "storage/browser/file_system/native_file_util.h"
#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_POSIX)
#include <time.h>
#endif
namespace {
@@ -86,6 +98,71 @@ std::unique_ptr<base::DictionaryValue> BuildObjectForResponse(
return response;
}
const int kMaxLogLineLength = 1024;
void WriteTimestamp(std::stringstream& stream) {
#if defined(OS_WIN)
SYSTEMTIME local_time;
GetLocalTime(&local_time);
stream << std::setfill('0') << std::setw(2) << local_time.wMonth
<< std::setw(2) << local_time.wDay << '/' << std::setw(2)
<< local_time.wHour << std::setw(2) << local_time.wMinute
<< std::setw(2) << local_time.wSecond << '.' << std::setw(3)
<< local_time.wMilliseconds;
#elif defined(OS_POSIX)
timeval tv;
gettimeofday(&tv, nullptr);
time_t t = tv.tv_sec;
struct tm local_time;
localtime_r(&t, &local_time);
struct tm* tm_time = &local_time;
stream << std::setfill('0') << std::setw(2) << 1 + tm_time->tm_mon
<< std::setw(2) << tm_time->tm_mday << '/' << std::setw(2)
<< tm_time->tm_hour << std::setw(2) << tm_time->tm_min << std::setw(2)
<< tm_time->tm_sec << '.' << std::setw(6) << tv.tv_usec;
#else
#error Unsupported platform
#endif
}
void LogProtocolMessage(const base::FilePath& log_file,
ProtocolMessageType type,
std::string to_log) {
// Track if logging has failed, in which case we don't keep trying.
static bool log_error = false;
if (log_error)
return;
if (storage::NativeFileUtil::EnsureFileExists(log_file, nullptr) !=
base::File::FILE_OK) {
LOG(ERROR) << "Failed to create file " << log_file.value();
log_error = true;
return;
}
std::string type_label;
switch (type) {
case ProtocolMessageType::METHOD:
type_label = "METHOD";
break;
case ProtocolMessageType::RESULT:
type_label = "RESULT";
break;
case ProtocolMessageType::EVENT:
type_label = "EVENT";
break;
}
std::stringstream stream;
WriteTimestamp(stream);
stream << ": " << type_label << ": " << to_log << "\n";
const std::string& str = stream.str();
if (!base::AppendToFile(log_file, str.c_str(), str.size())) {
LOG(ERROR) << "Failed to write file " << log_file.value();
log_error = true;
}
}
} // namespace
class CefDevToolsFrontend::NetworkResourceLoader
@@ -156,11 +233,12 @@ const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
// static
CefDevToolsFrontend* CefDevToolsFrontend::Show(
CefRefPtr<CefBrowserHostImpl> inspected_browser,
CefBrowserHostImpl* inspected_browser,
const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at) {
const CefPoint& inspect_element_at,
base::OnceClosure frontend_destroyed_callback) {
CefBrowserSettings new_settings = settings;
if (!windowInfo.windowless_rendering_enabled &&
CefColorGetA(new_settings.background_color) != SK_AlphaOPAQUE) {
@@ -187,7 +265,8 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
// destroyed.
CefDevToolsFrontend* devtools_frontend = new CefDevToolsFrontend(
static_cast<CefBrowserHostImpl*>(frontend_browser.get()),
inspected_contents, inspect_element_at);
inspected_contents, inspect_element_at,
std::move(frontend_destroyed_callback));
// Need to load the URL after creating the DevTools objects.
frontend_browser->GetMainFrame()->LoadURL(GetFrontendURL());
@@ -216,23 +295,23 @@ void CefDevToolsFrontend::Close() {
frontend_browser_.get(), true));
}
void CefDevToolsFrontend::DisconnectFromTarget() {
if (!agent_host_)
return;
agent_host_->DetachClient(this);
agent_host_ = nullptr;
}
CefDevToolsFrontend::CefDevToolsFrontend(
CefRefPtr<CefBrowserHostImpl> frontend_browser,
CefBrowserHostImpl* frontend_browser,
content::WebContents* inspected_contents,
const CefPoint& inspect_element_at)
const CefPoint& inspect_element_at,
base::OnceClosure frontend_destroyed_callback)
: content::WebContentsObserver(frontend_browser->web_contents()),
frontend_browser_(frontend_browser),
inspected_contents_(inspected_contents),
inspect_element_at_(inspect_element_at),
file_manager_(frontend_browser.get(), GetPrefs()),
weak_factory_(this) {}
frontend_destroyed_callback_(std::move(frontend_destroyed_callback)),
file_manager_(frontend_browser, GetPrefs()),
protocol_log_file_(
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
switches::kDevToolsProtocolLogFile)),
weak_factory_(this) {
DCHECK(!frontend_destroyed_callback_.is_null());
}
CefDevToolsFrontend::~CefDevToolsFrontend() {}
@@ -279,6 +358,7 @@ void CefDevToolsFrontend::WebContentsDestroyed() {
agent_host_->DetachClient(this);
agent_host_ = nullptr;
}
std::move(frontend_destroyed_callback_).Run();
delete this;
}
@@ -300,6 +380,9 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
std::string protocol_message;
if (!agent_host_ || !params->GetString(0, &protocol_message))
return;
if (ProtocolLoggingEnabled()) {
LogProtocolMessage(ProtocolMessageType::METHOD, protocol_message);
}
agent_host_->DispatchProtocolMessage(
this, base::as_bytes(base::make_span(protocol_message)));
} else if (method == "loadCompleted") {
@@ -451,6 +534,14 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
base::span<const uint8_t> message) {
base::StringPiece str_message(reinterpret_cast<const char*>(message.data()),
message.size());
if (ProtocolLoggingEnabled()) {
// Quick check to avoid parsing the JSON object. Events begin with a
// "method" value whereas method results begin with an "id" value.
LogProtocolMessage(str_message.starts_with("{\"method\":")
? ProtocolMessageType::EVENT
: ProtocolMessageType::RESULT,
str_message);
}
if (str_message.length() < kMaxMessageChunkSize) {
std::string param;
base::EscapeJSONString(str_message, true, &param);
@@ -504,6 +595,23 @@ void CefDevToolsFrontend::SendMessageAck(int request_id,
CallClientFunction("DevToolsAPI.embedderMessageAck", &id_value, arg, nullptr);
}
bool CefDevToolsFrontend::ProtocolLoggingEnabled() const {
return !protocol_log_file_.empty();
}
void CefDevToolsFrontend::LogProtocolMessage(ProtocolMessageType type,
const base::StringPiece& message) {
DCHECK(ProtocolLoggingEnabled());
std::string to_log = message.substr(0, kMaxLogLineLength).as_string();
// Execute in an ordered context that allows blocking.
auto task_runner = CefContentBrowserClient::Get()->background_task_runner();
task_runner->PostTask(
FROM_HERE, base::BindOnce(::LogProtocolMessage, protocol_log_file_, type,
std::move(to_log)));
}
void CefDevToolsFrontend::AgentHostClosed(
content::DevToolsAgentHost* agent_host) {
DCHECK(agent_host == agent_host_.get());

View File

@@ -11,6 +11,7 @@
#include "libcef/browser/devtools/devtools_file_manager.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
@@ -31,36 +32,38 @@ class WebContents;
class PrefService;
enum class ProtocolMessageType {
METHOD,
RESULT,
EVENT,
};
class CefDevToolsFrontend : public content::WebContentsObserver,
public content::DevToolsAgentHostClient {
public:
static CefDevToolsFrontend* Show(
CefRefPtr<CefBrowserHostImpl> inspected_browser,
CefBrowserHostImpl* inspected_browser,
const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at);
const CefPoint& inspect_element_at,
base::OnceClosure frontend_destroyed_callback);
void Activate();
void Focus();
void InspectElementAt(int x, int y);
void Close();
void DisconnectFromTarget();
void CallClientFunction(const std::string& function_name,
const base::Value* arg1,
const base::Value* arg2,
const base::Value* arg3);
CefRefPtr<CefBrowserHostImpl> frontend_browser() const {
return frontend_browser_;
}
private:
CefDevToolsFrontend(CefRefPtr<CefBrowserHostImpl> frontend_browser,
CefDevToolsFrontend(CefBrowserHostImpl* frontend_browser,
content::WebContents* inspected_contents,
const CefPoint& inspect_element_at);
const CefPoint& inspect_element_at,
base::OnceClosure destroyed_callback);
~CefDevToolsFrontend() override;
// content::DevToolsAgentHostClient implementation.
@@ -78,12 +81,17 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
void SendMessageAck(int request_id, const base::Value* arg1);
bool ProtocolLoggingEnabled() const;
void LogProtocolMessage(ProtocolMessageType type,
const base::StringPiece& message);
PrefService* GetPrefs() const;
CefRefPtr<CefBrowserHostImpl> frontend_browser_;
content::WebContents* inspected_contents_;
scoped_refptr<content::DevToolsAgentHost> agent_host_;
CefPoint inspect_element_at_;
base::OnceClosure frontend_destroyed_callback_;
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
class NetworkResourceLoader;
@@ -93,6 +101,9 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
using ExtensionsAPIs = std::map<std::string, std::string>;
ExtensionsAPIs extensions_api_;
CefDevToolsFileManager file_manager_;
const base::FilePath protocol_log_file_;
base::WeakPtrFactory<CefDevToolsFrontend> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CefDevToolsFrontend);

View File

@@ -0,0 +1,200 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/devtools/devtools_manager.h"
#include "libcef/browser/devtools/devtools_controller.h"
#include "libcef/browser/devtools/devtools_frontend.h"
#include "content/public/browser/web_contents.h"
namespace {
// May be created on any thread but will be destroyed on the UI thread.
class CefDevToolsRegistrationImpl : public CefRegistration,
public CefDevToolsController::Observer {
public:
explicit CefDevToolsRegistrationImpl(
CefRefPtr<CefDevToolsMessageObserver> observer)
: observer_(observer) {
DCHECK(observer_);
}
~CefDevToolsRegistrationImpl() override {
CEF_REQUIRE_UIT();
// May be null if OnDevToolsControllerDestroyed was called.
if (!controller_)
return;
controller_->RemoveObserver(this);
}
void Initialize(CefBrowserHostImpl* browser,
base::WeakPtr<CefDevToolsController> controller) {
CEF_REQUIRE_UIT();
DCHECK(browser && controller);
DCHECK(!browser_ && !controller_);
browser_ = browser;
controller_ = controller;
controller_->AddObserver(this);
}
private:
// CefDevToolsController::Observer methods:
bool OnDevToolsMessage(const base::StringPiece& message) override {
CEF_REQUIRE_UIT();
return observer_->OnDevToolsMessage(browser_, message.data(),
message.size());
}
void OnDevToolsMethodResult(int message_id,
bool success,
const base::StringPiece& result) override {
CEF_REQUIRE_UIT();
observer_->OnDevToolsMethodResult(browser_, message_id, success,
result.data(), result.size());
}
void OnDevToolsEvent(const base::StringPiece& method,
const base::StringPiece& params) override {
CEF_REQUIRE_UIT();
observer_->OnDevToolsEvent(browser_, method.as_string(), params.data(),
params.size());
}
void OnDevToolsAgentAttached() override {
CEF_REQUIRE_UIT();
observer_->OnDevToolsAgentAttached(browser_);
}
void OnDevToolsAgentDetached() override {
CEF_REQUIRE_UIT();
observer_->OnDevToolsAgentDetached(browser_);
}
void OnDevToolsControllerDestroyed() override {
CEF_REQUIRE_UIT();
browser_ = nullptr;
controller_.reset();
}
CefRefPtr<CefDevToolsMessageObserver> observer_;
CefBrowserHostImpl* browser_ = nullptr;
base::WeakPtr<CefDevToolsController> controller_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefDevToolsRegistrationImpl);
DISALLOW_COPY_AND_ASSIGN(CefDevToolsRegistrationImpl);
};
} // namespace
CefDevToolsManager::CefDevToolsManager(CefBrowserHostImpl* inspected_browser)
: inspected_browser_(inspected_browser), weak_ptr_factory_(this) {
CEF_REQUIRE_UIT();
}
CefDevToolsManager::~CefDevToolsManager() {
CEF_REQUIRE_UIT();
}
void CefDevToolsManager::ShowDevTools(const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at) {
CEF_REQUIRE_UIT();
if (devtools_frontend_) {
if (!inspect_element_at.IsEmpty()) {
devtools_frontend_->InspectElementAt(inspect_element_at.x,
inspect_element_at.y);
}
devtools_frontend_->Focus();
return;
}
devtools_frontend_ = CefDevToolsFrontend::Show(
inspected_browser_, windowInfo, client, settings, inspect_element_at,
base::BindOnce(&CefDevToolsManager::OnFrontEndDestroyed,
weak_ptr_factory_.GetWeakPtr()));
}
void CefDevToolsManager::CloseDevTools() {
CEF_REQUIRE_UIT();
if (!devtools_frontend_)
return;
devtools_frontend_->Close();
}
bool CefDevToolsManager::HasDevTools() {
CEF_REQUIRE_UIT();
return !!devtools_frontend_;
}
bool CefDevToolsManager::SendDevToolsMessage(const void* message,
size_t message_size) {
CEF_REQUIRE_UIT();
if (!message || message_size == 0)
return false;
if (!EnsureController())
return false;
return devtools_controller_->SendDevToolsMessage(
base::StringPiece(static_cast<const char*>(message), message_size));
}
int CefDevToolsManager::ExecuteDevToolsMethod(
int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) {
CEF_REQUIRE_UIT();
if (method.empty())
return 0;
if (!EnsureController())
return 0;
if (params && params->IsValid()) {
CefDictionaryValueImpl* impl =
static_cast<CefDictionaryValueImpl*>(params.get());
CefValueController::AutoLock lock_scope(impl->controller());
return devtools_controller_->ExecuteDevToolsMethod(message_id, method,
impl->GetValueUnsafe());
} else {
return devtools_controller_->ExecuteDevToolsMethod(message_id, method,
nullptr);
}
}
// static
CefRefPtr<CefRegistration> CefDevToolsManager::CreateRegistration(
CefRefPtr<CefDevToolsMessageObserver> observer) {
DCHECK(observer);
return new CefDevToolsRegistrationImpl(observer);
}
void CefDevToolsManager::InitializeRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration) {
CEF_REQUIRE_UIT();
if (!EnsureController())
return;
static_cast<CefDevToolsRegistrationImpl*>(registration.get())
->Initialize(inspected_browser_, devtools_controller_->GetWeakPtr());
}
void CefDevToolsManager::OnFrontEndDestroyed() {
devtools_frontend_ = nullptr;
}
bool CefDevToolsManager::EnsureController() {
if (!devtools_controller_) {
devtools_controller_.reset(
new CefDevToolsController(inspected_browser_->web_contents()));
}
return true;
}

View File

@@ -0,0 +1,69 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_
#pragma once
#include "include/cef_browser.h"
#include "base/memory/weak_ptr.h"
class CefBrowserHostImpl;
class CefDevToolsController;
class CefDevToolsFrontend;
namespace content {
class WebContents;
}
// Manages DevTools instances. Methods must be called on the UI thread unless
// otherwise indicated.
class CefDevToolsManager {
public:
// |inspected_browser| will outlive this object.
explicit CefDevToolsManager(CefBrowserHostImpl* inspected_browser);
~CefDevToolsManager();
// See CefBrowserHost methods of the same name for documentation.
void ShowDevTools(const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at);
void CloseDevTools();
bool HasDevTools();
bool SendDevToolsMessage(const void* message, size_t message_size);
int ExecuteDevToolsMethod(int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> param);
// These methods are used to implement
// CefBrowserHost::AddDevToolsMessageObserver. CreateRegistration is safe to
// call on any thread. InitializeRegistrationOnUIThread should be called
// immediately afterwards on the UI thread.
static CefRefPtr<CefRegistration> CreateRegistration(
CefRefPtr<CefDevToolsMessageObserver> observer);
void InitializeRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration);
private:
void OnFrontEndDestroyed();
bool EnsureController();
CefBrowserHostImpl* const inspected_browser_;
// CefDevToolsFrontend will delete itself when the frontend WebContents is
// destroyed.
CefDevToolsFrontend* devtools_frontend_ = nullptr;
// Used for sending DevTools protocol messages without an active frontend.
std::unique_ptr<CefDevToolsController> devtools_controller_;
base::WeakPtrFactory<CefDevToolsManager> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefDevToolsManager);
};
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_

View File

@@ -0,0 +1,131 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/devtools/devtools_util.h"
#include "base/strings/string_number_conversions.h"
namespace devtools_util {
namespace {
bool IsValidDictionary(const base::StringPiece& str, bool allow_empty) {
return str.length() >= (allow_empty ? 2 : 3) && str[0] == '{' &&
str[str.length() - 1] == '}';
}
// Example:
// {"method":"Target.targetDestroyed","params":{"targetId":"1234..."}}
bool ParseEvent(const base::StringPiece& message,
base::StringPiece& method,
base::StringPiece& params) {
static const char kMethodStart[] = "{\"method\":\"";
static const char kMethodEnd[] = "\"";
static const char kParamsStart[] = ",\"params\":";
if (!message.starts_with(kMethodStart))
return false;
const size_t method_start = sizeof(kMethodStart) - 1;
const size_t method_end = message.find(kMethodEnd, method_start);
if (method_end < 0U)
return false;
method = message.substr(method_start, method_end - method_start);
if (method.empty())
return false;
size_t remainder_start = method_end + sizeof(kMethodEnd) - 1;
if (remainder_start == message.size() - 1) {
// No more contents.
params = base::StringPiece();
} else {
const base::StringPiece& remainder = message.substr(remainder_start);
if (remainder.starts_with(kParamsStart)) {
// Stop immediately before the message closing bracket.
remainder_start += sizeof(kParamsStart) - 1;
params =
message.substr(remainder_start, message.size() - 1 - remainder_start);
} else {
// Invalid format.
return false;
}
if (!IsValidDictionary(params, /*allow_empty=*/true))
return false;
}
return true;
}
// Examples:
// {"id":3,"result":{}}
// {"id":4,"result":{"debuggerId":"-2193881606781505058.81393575456727957"}}
// {"id":5,"error":{"code":-32000,"message":"Not supported"}}
bool ParseResult(const base::StringPiece& message,
int& message_id,
bool& success,
base::StringPiece& result) {
static const char kIdStart[] = "{\"id\":";
static const char kIdEnd[] = ",";
static const char kResultStart[] = "\"result\":";
static const char kErrorStart[] = "\"error\":";
if (!message.starts_with(kIdStart))
return false;
const size_t id_start = sizeof(kIdStart) - 1;
const size_t id_end = message.find(kIdEnd, id_start);
if (id_end < 0U)
return false;
const base::StringPiece& id_str = message.substr(id_start, id_end - id_start);
if (id_str.empty() || !base::StringToInt(id_str, &message_id))
return false;
size_t remainder_start = id_end + sizeof(kIdEnd) - 1;
const base::StringPiece& remainder = message.substr(remainder_start);
if (remainder.starts_with(kResultStart)) {
// Stop immediately before the message closing bracket.
remainder_start += sizeof(kResultStart) - 1;
result =
message.substr(remainder_start, message.size() - 1 - remainder_start);
success = true;
} else if (remainder.starts_with(kErrorStart)) {
// Stop immediately before the message closing bracket.
remainder_start += sizeof(kErrorStart) - 1;
result =
message.substr(remainder_start, message.size() - 1 - remainder_start);
success = false;
} else {
// Invalid format.
return false;
}
if (!IsValidDictionary(result, /*allow_empty=*/true))
return false;
return true;
}
} // namespace
// static
bool ProtocolParser::IsValidMessage(const base::StringPiece& message) {
return IsValidDictionary(message, /*allow_empty=*/false);
}
bool ProtocolParser::Initialize(const base::StringPiece& message) {
if (status_ != UNINITIALIZED)
return false;
if (ParseEvent(message, method_, params_)) {
status_ = EVENT;
} else if (ParseResult(message, message_id_, success_, params_)) {
status_ = RESULT;
} else {
status_ = FAILURE;
}
return true;
}
} // namespace devtools_util

View File

@@ -0,0 +1,72 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_UTIL_H_
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_UTIL_H_
#pragma once
#include "base/strings/string_piece.h"
namespace devtools_util {
// Fast parser for DevTools JSON protocol messages. This implementation makes
// certain assumptions about the JSON object structure (value order and
// formatting) to avoid stateful parsing of messages that may be large
// (sometimes > 1MB in size). The message must be a JSON dictionary that starts
// with a "method" or "id" value which is non-empty and of the expected data
// type. Messages that have a "method" value (event message) may optionally have
// a "params" dictionary. Messages that have an "id" value (result message) must
// have a "result" or "error" dictionary. The dictionary contents are not
// validated and may be empty ("{}").
//
// Example event message:
// {"method":"Target.targetDestroyed","params":{"targetId":"1234..."}}
//
// Example result messages:
// {"id":3,"result":{}}
// {"id":4,"result":{"debuggerId":"-2193881606781505058.81393575456727957"}}
// {"id":5,"error":{"code":-32000,"message":"Not supported"}}
struct ProtocolParser {
ProtocolParser() = default;
// Checks for a non-empty JSON dictionary.
static bool IsValidMessage(const base::StringPiece& message);
// Returns false if already initialized.
bool Initialize(const base::StringPiece& message);
bool IsInitialized() const { return status_ != UNINITIALIZED; }
bool IsEvent() const { return status_ == EVENT; }
bool IsResult() const { return status_ == RESULT; }
bool IsFailure() const { return status_ == FAILURE; }
void Reset() { status_ = UNINITIALIZED; }
// For event messages:
// "method" string:
base::StringPiece method_;
// For result messages:
// "id" int:
int message_id_ = 0;
// true if "result" value, false if "error" value:
bool success_ = false;
// For both:
// "params", "result" or "error" dictionary:
base::StringPiece params_;
private:
enum Status {
UNINITIALIZED,
EVENT, // Event message.
RESULT, // Result message.
FAILURE, // Parsing failure.
};
Status status_ = UNINITIALIZED;
};
} // namespace devtools_util
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_UTIL_H_

View File

@@ -0,0 +1,204 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/devtools/devtools_util.h"
#include "testing/gtest/include/gtest/gtest.h"
using namespace devtools_util;
TEST(DevToolsUtil, ProtocolParser_IsValidMessage) {
// Empty dictionary is not valid.
EXPECT_FALSE(ProtocolParser::IsValidMessage(""));
EXPECT_FALSE(ProtocolParser::IsValidMessage("{}"));
// Incorrectly formatted dictionary is not valid.
EXPECT_FALSE(ProtocolParser::IsValidMessage("{ ]"));
// Everything else is valid (we don't verify JSON structure).
EXPECT_TRUE(ProtocolParser::IsValidMessage("{ }"));
EXPECT_TRUE(ProtocolParser::IsValidMessage("{blah blah}"));
EXPECT_TRUE(ProtocolParser::IsValidMessage("{method:\"foobar\"}"));
}
TEST(DevToolsUtil, ProtocolParser_Initialize_IsFailure_Unknown) {
ProtocolParser parser;
EXPECT_FALSE(parser.IsInitialized());
// Empty message is invalid.
EXPECT_TRUE(parser.Initialize(""));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Empty dictionary is invalid.
EXPECT_TRUE(parser.Initialize("{}"));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Unrecognized dictionary type is invalid.
EXPECT_TRUE(parser.Initialize("{blah blah}"));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
}
TEST(DevToolsUtil, ProtocolParser_Initialize_IsFailure_EventMalformed) {
ProtocolParser parser;
EXPECT_FALSE(parser.IsInitialized());
// Empty method is invalid.
EXPECT_TRUE(parser.Initialize("{\"method\":\"\"}"));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Unrecognized value is invalid.
EXPECT_TRUE(parser.Initialize("{\"method\":\"foo\",oops:false}"));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Params must be a dictionary.
EXPECT_TRUE(parser.Initialize("{\"method\":\",params:[]}"));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
}
TEST(DevToolsUtil, ProtocolParser_Initialize_IsEvent) {
ProtocolParser parser;
EXPECT_FALSE(parser.IsInitialized());
// Method without params is valid.
std::string message = "{\"method\":\"Test.myMethod\"}";
EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsEvent());
EXPECT_STREQ("Test.myMethod", parser.method_.as_string().data());
EXPECT_TRUE(parser.params_.empty());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Method with empty params dictionary is valid.
message = "{\"method\":\"Test.myMethod2\",\"params\":{}}";
EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsEvent());
EXPECT_STREQ("Test.myMethod2", parser.method_.as_string().data());
EXPECT_STREQ("{}", parser.params_.as_string().data());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Method with non-empty params dictionary is valid.
message = "{\"method\":\"Test.myMethod3\",\"params\":{\"foo\":\"bar\"}}";
EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsEvent());
EXPECT_STREQ("Test.myMethod3", parser.method_.as_string().data());
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.as_string().data());
}
TEST(DevToolsUtil, ProtocolParser_Initialize_IsFailure_ResultMalformed) {
ProtocolParser parser;
EXPECT_FALSE(parser.IsInitialized());
// Empty ID is invalid.
EXPECT_TRUE(parser.Initialize("{\"id\":,result:{}}"));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Missing result or error value is invalid.
EXPECT_TRUE(parser.Initialize("{\"id\":1}"));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Unrecognized value is invalid.
EXPECT_TRUE(parser.Initialize("{\"id\":1,oops:false}"));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Result must be a dictionary.
EXPECT_TRUE(parser.Initialize("{\"id\":1,\"result\":[]}"));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Error must be a dictionary.
EXPECT_TRUE(parser.Initialize("{\"id\":1,\"error\":[]}"));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsFailure());
}
TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Result) {
ProtocolParser parser;
EXPECT_FALSE(parser.IsInitialized());
// Id with empty result dictionary is valid.
std::string message = "{\"id\":1,\"result\":{}}";
EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(1, parser.message_id_);
EXPECT_TRUE(parser.success_);
EXPECT_STREQ("{}", parser.params_.as_string().data());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Id with non-empty result dictionary is valid.
message = "{\"id\":2,\"result\":{\"foo\":\"bar\"}}";
EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(2, parser.message_id_);
EXPECT_TRUE(parser.success_);
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.as_string().data());
}
TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Error) {
ProtocolParser parser;
EXPECT_FALSE(parser.IsInitialized());
// Id with empty error dictionary is valid.
std::string message = "{\"id\":1,\"error\":{}}";
EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(1, parser.message_id_);
EXPECT_FALSE(parser.success_);
EXPECT_STREQ("{}", parser.params_.as_string().data());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
// Id with non-empty error dictionary is valid.
message = "{\"id\":2,\"error\":{\"foo\":\"bar\"}}";
EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(2, parser.message_id_);
EXPECT_FALSE(parser.success_);
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.as_string().data());
}

View File

@@ -58,8 +58,10 @@ content::WebContents* GetOwnerForGuestContents(content::WebContents* guest) {
static_cast<content::WebContentsImpl*>(guest);
content::BrowserPluginGuest* plugin_guest =
guest_impl->GetBrowserPluginGuest();
if (plugin_guest)
return plugin_guest->embedder_web_contents();
if (plugin_guest) {
return content::WebContents::FromRenderFrameHost(
plugin_guest->GetEmbedderFrame());
}
// Maybe it's a print preview dialog.
auto print_preview_controller =

View File

@@ -423,8 +423,8 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::CreateTabObject(
tab_object->id = std::make_unique<int>(new_browser->GetIdentifier());
tab_object->index = index;
tab_object->window_id = *tab_object->id;
tab_object->status = std::make_unique<std::string>(
is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete);
tab_object->status = is_loading ? api::tabs::TAB_STATUS_LOADING
: api::tabs::TAB_STATUS_COMPLETE;
tab_object->active = active;
tab_object->selected = true;
tab_object->highlighted = true;

View File

@@ -167,7 +167,7 @@ void CefExtensionsBrowserClient::LoadResourceFromResourceBundle(
bool CefExtensionsBrowserClient::AllowCrossRendererResourceLoad(
const GURL& url,
content::ResourceType resource_type,
blink::mojom::ResourceType resource_type,
ui::PageTransition page_transition,
int child_id,
bool is_incognito,

View File

@@ -55,7 +55,7 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
bool send_cors_header) override;
bool AllowCrossRendererResourceLoad(const GURL& url,
content::ResourceType resource_type,
blink::mojom::ResourceType resource_type,
ui::PageTransition page_transition,
int child_id,
bool is_incognito,

View File

@@ -32,9 +32,9 @@ const char kPdfResourceIdentifier[] = "chromium-pdf";
const char kPdfPluginName[] = "Chrome PDF Viewer";
std::string GetManifest() {
std::string manifest_contents = ui::ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_PDF_MANIFEST)
.as_string();
std::string manifest_contents =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
IDR_PDF_MANIFEST);
DCHECK(manifest_contents.find(kNameTag) != std::string::npos);
base::ReplaceFirstSubstringAfterOffset(&manifest_contents, 0, kNameTag,
kPdfPluginName);

View File

@@ -367,6 +367,11 @@ void CefFrameHostImpl::SendCommand(
if (frame_id < CefFrameHostImpl::kMainFrameId)
return;
if (!render_frame_host_ || !response_manager_) {
// detached frame has no response_manager_
return;
}
TRACE_EVENT2("cef", "CefFrameHostImpl::SendCommand", "frame_id", frame_id,
"needsResponse", responseHandler.get() ? 1 : 0);
Cef_Request_Params params;
@@ -407,6 +412,11 @@ void CefFrameHostImpl::SendCode(
if (frame_id < CefFrameHostImpl::kMainFrameId)
return;
if (!render_frame_host_ || !response_manager_) {
// detached frame has no response_manager_
return;
}
TRACE_EVENT2("cef", "CefFrameHostImpl::SendCommand", "frame_id", frame_id,
"needsResponse", responseHandler.get() ? 1 : 0);
Cef_Request_Params params;

View File

@@ -0,0 +1,83 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_route_impl.h"
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/media_router/media_sink_impl.h"
#include "libcef/browser/media_router/media_source_impl.h"
#include "libcef/browser/thread_util.h"
namespace {
// Do not keep a reference to the object returned by this method.
CefBrowserContext* GetBrowserContext(const CefBrowserContext::Getter& getter) {
CEF_REQUIRE_UIT();
DCHECK(!getter.is_null());
// Will return nullptr if the BrowserContext has been destroyed.
return getter.Run();
}
} // namespace
CefMediaRouteImpl::CefMediaRouteImpl(
const media_router::MediaRoute& route,
const CefBrowserContext::Getter& browser_context_getter)
: route_(route), browser_context_getter_(browser_context_getter) {
CEF_REQUIRE_UIT();
}
CefString CefMediaRouteImpl::GetId() {
return route_.media_route_id();
}
CefRefPtr<CefMediaSource> CefMediaRouteImpl::GetSource() {
return new CefMediaSourceImpl(route_.media_source().id());
}
CefRefPtr<CefMediaSink> CefMediaRouteImpl::GetSink() {
return new CefMediaSinkImpl(route_.media_sink_id(), route_.media_sink_name());
}
void CefMediaRouteImpl::SendRouteMessage(const void* message,
size_t message_size) {
std::string message_str(reinterpret_cast<const char*>(message), message_size);
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
[](CefRefPtr<CefMediaRouteImpl> self, std::string message_str) {
self->SendRouteMessageInternal(std::move(message_str));
},
CefRefPtr<CefMediaRouteImpl>(this), std::move(message_str)));
return;
}
SendRouteMessageInternal(std::move(message_str));
}
void CefMediaRouteImpl::Terminate() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefMediaRouteImpl::Terminate, this));
return;
}
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->TerminateRoute(
route_.media_route_id());
}
void CefMediaRouteImpl::SendRouteMessageInternal(std::string message) {
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->SendRouteMessage(
route_.media_route_id(), message);
}

View File

@@ -0,0 +1,40 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_IMPL_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_IMPL_H_
#pragma once
#include "include/cef_media_router.h"
#include "libcef/browser/browser_context.h"
#include "chrome/common/media_router/media_route.h"
// Implementation of the CefMediaRoute interface. Only created on the UI thread.
class CefMediaRouteImpl : public CefMediaRoute {
public:
CefMediaRouteImpl(const media_router::MediaRoute& route,
const CefBrowserContext::Getter& browser_context_getter);
// CefMediaRoute methods.
CefString GetId() override;
CefRefPtr<CefMediaSource> GetSource() override;
CefRefPtr<CefMediaSink> GetSink() override;
void SendRouteMessage(const void* message, size_t message_size) override;
void Terminate() override;
const media_router::MediaRoute& route() const { return route_; }
private:
void SendRouteMessageInternal(std::string message);
// Read-only after creation.
const media_router::MediaRoute route_;
const CefBrowserContext::Getter browser_context_getter_;
IMPLEMENT_REFCOUNTING(CefMediaRouteImpl);
DISALLOW_COPY_AND_ASSIGN(CefMediaRouteImpl);
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_IMPL_H_

View File

@@ -0,0 +1,290 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_router_impl.h"
#include "libcef/browser/media_router/media_route_impl.h"
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/media_router/media_sink_impl.h"
#include "libcef/browser/media_router/media_source_impl.h"
#include "libcef/browser/thread_util.h"
namespace {
// Do not keep a reference to the object returned by this method.
CefBrowserContext* GetBrowserContext(const CefBrowserContext::Getter& getter) {
CEF_REQUIRE_UIT();
DCHECK(!getter.is_null());
// Will return nullptr if the BrowserContext has been destroyed.
return getter.Run();
}
} // namespace
class CefRegistrationImpl : public CefRegistration,
public CefMediaRouterManager::Observer {
public:
explicit CefRegistrationImpl(CefRefPtr<CefMediaObserver> observer)
: observer_(observer) {
DCHECK(observer_);
}
~CefRegistrationImpl() override {
CEF_REQUIRE_UIT();
// May be null if OnMediaRouterDestroyed was called.
if (browser_context_getter_.is_null())
return;
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->RemoveObserver(this);
}
void Initialize(const CefBrowserContext::Getter& browser_context_getter) {
CEF_REQUIRE_UIT();
DCHECK(!browser_context_getter.is_null());
DCHECK(browser_context_getter_.is_null());
browser_context_getter_ = browser_context_getter;
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->AddObserver(this);
}
private:
// CefMediaRouterManager::Observer methods:
void OnMediaRouterDestroyed() override { browser_context_getter_.Reset(); }
void OnMediaSinks(
const CefMediaRouterManager::MediaSinkVector& sinks) override {
std::vector<CefRefPtr<CefMediaSink>> cef_sinks;
for (const auto& sink : sinks) {
cef_sinks.push_back(new CefMediaSinkImpl(sink.sink));
}
observer_->OnSinks(cef_sinks);
}
void OnMediaRoutes(
const CefMediaRouterManager::MediaRouteVector& routes) override {
std::vector<CefRefPtr<CefMediaRoute>> cef_routes;
for (const auto& route : routes) {
cef_routes.push_back(MakeCefRoute(route));
}
observer_->OnRoutes(cef_routes);
}
void OnMediaRouteMessages(
const media_router::MediaRoute& route,
const CefMediaRouterManager::MediaMessageVector& messages) override {
CefRefPtr<CefMediaRoute> cef_route = MakeCefRoute(route);
for (const auto& message : messages) {
if (message->type == media_router::mojom::RouteMessage::Type::TEXT) {
if (message->message.has_value()) {
const std::string& str = *(message->message);
observer_->OnRouteMessageReceived(cef_route, str.c_str(), str.size());
}
} else if (message->type ==
media_router::mojom::RouteMessage::Type::BINARY) {
if (message->data.has_value()) {
const std::vector<uint8_t>& data = *(message->data);
observer_->OnRouteMessageReceived(cef_route, data.data(),
data.size());
}
}
}
}
void OnMediaRouteStateChange(
const media_router::MediaRoute& route,
const content::PresentationConnectionStateChangeInfo& info) override {
observer_->OnRouteStateChanged(MakeCefRoute(route),
ToConnectionState(info.state));
}
CefRefPtr<CefMediaRoute> MakeCefRoute(const media_router::MediaRoute& route) {
return new CefMediaRouteImpl(route, browser_context_getter_);
}
static CefMediaObserver::ConnectionState ToConnectionState(
blink::mojom::PresentationConnectionState state) {
switch (state) {
case blink::mojom::PresentationConnectionState::CONNECTING:
return CEF_MRCS_CONNECTING;
case blink::mojom::PresentationConnectionState::CONNECTED:
return CEF_MRCS_CONNECTED;
case blink::mojom::PresentationConnectionState::CLOSED:
return CEF_MRCS_CLOSED;
case blink::mojom::PresentationConnectionState::TERMINATED:
return CEF_MRCS_TERMINATED;
}
NOTREACHED();
return CEF_MRCS_UNKNOWN;
}
CefRefPtr<CefMediaObserver> observer_;
CefBrowserContext::Getter browser_context_getter_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefRegistrationImpl);
DISALLOW_COPY_AND_ASSIGN(CefRegistrationImpl);
};
CefMediaRouterImpl::CefMediaRouterImpl() {
// Verify that our enum matches Chromium's values.
static_assert(
static_cast<int>(CEF_MRCR_TOTAL_COUNT) ==
static_cast<int>(media_router::RouteRequestResult::TOTAL_COUNT),
"enum mismatch");
}
void CefMediaRouterImpl::Initialize(
const CefBrowserContext::Getter& browser_context_getter) {
CEF_REQUIRE_UIT();
DCHECK(!browser_context_getter.is_null());
DCHECK(browser_context_getter_.is_null());
browser_context_getter_ = browser_context_getter;
}
CefRefPtr<CefRegistration> CefMediaRouterImpl::AddObserver(
CefRefPtr<CefMediaObserver> observer) {
if (!observer)
return nullptr;
CefRefPtr<CefRegistrationImpl> registration =
new CefRegistrationImpl(observer);
InitializeRegistrationOnUIThread(registration);
return registration.get();
}
CefRefPtr<CefMediaSource> CefMediaRouterImpl::GetSource(const CefString& urn) {
if (urn.empty())
return nullptr;
// Check for a valid URL and supported Cast/DIAL schemes.
GURL presentation_url(urn.ToString());
if (!media_router::IsValidPresentationUrl(presentation_url)) {
return nullptr;
}
if (presentation_url.SchemeIsHTTPOrHTTPS()) {
// We don't support tab/desktop mirroring, which is what Cast uses for
// arbitrary HTTP/HTTPS URLs (see CastMediaSource).
return nullptr;
}
return new CefMediaSourceImpl(presentation_url);
}
void CefMediaRouterImpl::NotifyCurrentSinks() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT, base::BindOnce(&CefMediaRouterImpl::NotifyCurrentSinks, this));
return;
}
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->NotifyCurrentSinks();
}
void CefMediaRouterImpl::CreateRoute(
CefRefPtr<CefMediaSource> source,
CefRefPtr<CefMediaSink> sink,
CefRefPtr<CefMediaRouteCreateCallback> callback) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefMediaRouterImpl::CreateRoute,
this, source, sink, callback));
return;
}
std::string error;
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context) {
error = "Context has already been destroyed";
} else if (!source || !source->IsValid()) {
error = "Source is empty or invalid";
} else if (!sink || !sink->IsValid()) {
error = "Sink is empty or invalid";
} else if (!sink->IsCompatibleWith(source)) {
error = "Sink is not compatible with source";
}
if (!error.empty()) {
LOG(WARNING) << "Media route creation failed: " << error;
if (callback) {
callback->OnMediaRouteCreateFinished(CEF_MRCR_UNKNOWN_ERROR, error,
nullptr);
}
return;
}
auto source_impl = static_cast<CefMediaSourceImpl*>(source.get());
auto sink_impl = static_cast<CefMediaSinkImpl*>(sink.get());
browser_context->GetMediaRouterManager()->CreateRoute(
source_impl->source().id(), sink_impl->sink().id(), url::Origin(),
base::BindOnce(&CefMediaRouterImpl::CreateRouteCallback, this, callback));
}
void CefMediaRouterImpl::NotifyCurrentRoutes() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(
&CefMediaRouterImpl::NotifyCurrentRoutes, this));
return;
}
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
browser_context->GetMediaRouterManager()->NotifyCurrentRoutes();
}
void CefMediaRouterImpl::InitializeRegistrationOnUIThread(
CefRefPtr<CefRegistrationImpl> registration) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefMediaRouterImpl::InitializeRegistrationOnUIThread,
this, registration));
return;
}
registration->Initialize(browser_context_getter_);
}
void CefMediaRouterImpl::CreateRouteCallback(
CefRefPtr<CefMediaRouteCreateCallback> callback,
const media_router::RouteRequestResult& result) {
CEF_REQUIRE_UIT();
if (result.result_code() != media_router::RouteRequestResult::OK) {
LOG(WARNING) << "Media route creation failed: " << result.error() << " ("
<< result.result_code() << ")";
}
if (!callback)
return;
CefRefPtr<CefMediaRoute> route;
if (result.result_code() == media_router::RouteRequestResult::OK &&
result.route()) {
route = new CefMediaRouteImpl(*result.route(), browser_context_getter_);
}
callback->OnMediaRouteCreateFinished(
static_cast<cef_media_route_create_result_t>(result.result_code()),
result.error(), route);
}
// static
CefRefPtr<CefMediaRouter> CefMediaRouter::GetGlobalMediaRouter() {
return CefRequestContext::GetGlobalContext()->GetMediaRouter();
}

View File

@@ -0,0 +1,49 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_
#pragma once
#include "include/cef_media_router.h"
#include "libcef/browser/browser_context.h"
#include "chrome/common/media_router/mojom/media_router.mojom.h"
class CefRegistrationImpl;
// Implementation of the CefMediaRouter interface. May be created on any thread.
class CefMediaRouterImpl : public CefMediaRouter {
public:
CefMediaRouterImpl();
// Called on the UI thread after object creation and before any other object
// methods are executed on the UI thread.
void Initialize(const CefBrowserContext::Getter& browser_context_getter);
// CefMediaRouter methods.
CefRefPtr<CefRegistration> AddObserver(
CefRefPtr<CefMediaObserver> observer) override;
CefRefPtr<CefMediaSource> GetSource(const CefString& urn) override;
void NotifyCurrentSinks() override;
void CreateRoute(CefRefPtr<CefMediaSource> source,
CefRefPtr<CefMediaSink> sink,
CefRefPtr<CefMediaRouteCreateCallback> callback) override;
void NotifyCurrentRoutes() override;
private:
void InitializeRegistrationOnUIThread(
CefRefPtr<CefRegistrationImpl> registration);
void CreateRouteCallback(CefRefPtr<CefMediaRouteCreateCallback> callback,
const media_router::RouteRequestResult& result);
// Only accessed on the UI thread. Will be non-null after Initialize().
CefBrowserContext::Getter browser_context_getter_;
IMPLEMENT_REFCOUNTING(CefMediaRouterImpl);
DISALLOW_COPY_AND_ASSIGN(CefMediaRouterImpl);
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_

View File

@@ -0,0 +1,292 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/thread_util.h"
#include "chrome/browser/media/router/media_router_factory.h"
#include "chrome/browser/media/router/media_routes_observer.h"
#include "chrome/browser/media/router/route_message_observer.h"
#include "chrome/browser/media/router/route_message_util.h"
namespace {
const int kTimeoutMs = 5 * 1000;
const char kDefaultPresentationUrl[] = "https://google.com";
} // namespace
class CefMediaRoutesObserver : public media_router::MediaRoutesObserver {
public:
explicit CefMediaRoutesObserver(CefMediaRouterManager* manager)
: media_router::MediaRoutesObserver(manager->GetMediaRouter()),
manager_(manager) {}
void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes,
const std::vector<media_router::MediaRoute::Id>&
joinable_route_ids) override {
manager_->routes_ = routes;
manager_->NotifyCurrentRoutes();
}
private:
CefMediaRouterManager* const manager_;
DISALLOW_COPY_AND_ASSIGN(CefMediaRoutesObserver);
};
// Used to receive messages if PresentationConnection is not supported.
class CefRouteMessageObserver : public media_router::RouteMessageObserver {
public:
CefRouteMessageObserver(CefMediaRouterManager* manager,
const media_router::MediaRoute& route)
: media_router::RouteMessageObserver(manager->GetMediaRouter(),
route.media_route_id()),
manager_(manager),
route_(route) {}
void OnMessagesReceived(
CefMediaRouterManager::MediaMessageVector messages) override {
manager_->OnMessagesReceived(route_, messages);
}
private:
CefMediaRouterManager* const manager_;
const media_router::MediaRoute route_;
DISALLOW_COPY_AND_ASSIGN(CefRouteMessageObserver);
};
// Used for messaging and route status notifications with Cast.
class CefPresentationConnection : public blink::mojom::PresentationConnection {
public:
explicit CefPresentationConnection(
CefMediaRouterManager* manager,
const media_router::MediaRoute& route,
media_router::mojom::RoutePresentationConnectionPtr connections)
: manager_(manager),
route_(route),
connection_receiver_(this, std::move(connections->connection_receiver)),
connection_remote_(std::move(connections->connection_remote)) {}
void OnMessage(
blink::mojom::PresentationConnectionMessagePtr message) override {
CefMediaRouterManager::MediaMessageVector messages;
if (message->is_message()) {
messages.push_back(media_router::message_util::RouteMessageFromString(
message->get_message()));
} else if (message->is_data()) {
messages.push_back(media_router::message_util::RouteMessageFromData(
message->get_data()));
}
if (!messages.empty()) {
manager_->OnMessagesReceived(route_, messages);
}
}
void DidChangeState(
blink::mojom::PresentationConnectionState state) override {
// May result in |this| being deleted, so post async and allow the call
// stack to unwind.
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefMediaRouterManager::OnRouteStateChange,
manager_->weak_ptr_factory_.GetWeakPtr(), route_,
content::PresentationConnectionStateChangeInfo(state)));
}
void DidClose(
blink::mojom::PresentationConnectionCloseReason reason) override {
DidChangeState(blink::mojom::PresentationConnectionState::CLOSED);
}
void SendRouteMessage(const std::string& message) {
connection_remote_->OnMessage(
blink::mojom::PresentationConnectionMessage::NewMessage(message));
}
private:
CefMediaRouterManager* const manager_;
const media_router::MediaRoute route_;
// Used to receive messages from the MRP.
mojo::Receiver<blink::mojom::PresentationConnection> connection_receiver_;
// Used to send messages to the MRP.
mojo::Remote<blink::mojom::PresentationConnection> connection_remote_;
DISALLOW_COPY_AND_ASSIGN(CefPresentationConnection);
};
CefMediaRouterManager::CefMediaRouterManager(CefBrowserContext* browser_context)
: browser_context_(browser_context),
query_result_manager_(GetMediaRouter()),
weak_ptr_factory_(this) {
// Perform initialization.
GetMediaRouter()->OnUserGesture();
query_result_manager_.AddObserver(this);
// A non-empty presentation URL to required for discovery of Cast devices.
query_result_manager_.SetSourcesForCastMode(
media_router::MediaCastMode::PRESENTATION,
{media_router::MediaSource::ForPresentationUrl(
GURL(kDefaultPresentationUrl))},
url::Origin());
routes_observer_ = std::make_unique<CefMediaRoutesObserver>(this);
}
CefMediaRouterManager::~CefMediaRouterManager() {
CEF_REQUIRE_UIT();
for (auto& observer : observers_) {
observers_.RemoveObserver(&observer);
observer.OnMediaRouterDestroyed();
}
query_result_manager_.RemoveObserver(this);
}
void CefMediaRouterManager::AddObserver(Observer* observer) {
CEF_REQUIRE_UIT();
observers_.AddObserver(observer);
}
void CefMediaRouterManager::RemoveObserver(Observer* observer) {
CEF_REQUIRE_UIT();
observers_.RemoveObserver(observer);
}
void CefMediaRouterManager::NotifyCurrentSinks() {
CEF_REQUIRE_UIT();
for (auto& observer : observers_) {
observer.OnMediaSinks(sinks_);
}
}
void CefMediaRouterManager::NotifyCurrentRoutes() {
CEF_REQUIRE_UIT();
for (auto& observer : observers_) {
observer.OnMediaRoutes(routes_);
}
}
void CefMediaRouterManager::CreateRoute(
const media_router::MediaSource::Id& source_id,
const media_router::MediaSink::Id& sink_id,
const url::Origin& origin,
CreateRouteResultCallback callback) {
GetMediaRouter()->CreateRoute(
source_id, sink_id, origin, nullptr /* web_contents */,
base::BindOnce(&CefMediaRouterManager::OnCreateRoute,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)),
base::TimeDelta::FromMilliseconds(kTimeoutMs), false /* incognito */);
}
void CefMediaRouterManager::SendRouteMessage(
const media_router::MediaRoute::Id& route_id,
const std::string& message) {
// Must use PresentationConnection to send messages if it exists.
auto state = GetRouteState(route_id);
if (state && state->presentation_connection_) {
state->presentation_connection_->SendRouteMessage(message);
return;
}
GetMediaRouter()->SendRouteMessage(route_id, message);
}
void CefMediaRouterManager::TerminateRoute(
const media_router::MediaRoute::Id& route_id) {
GetMediaRouter()->TerminateRoute(route_id);
}
void CefMediaRouterManager::OnResultsUpdated(const MediaSinkVector& sinks) {
sinks_ = sinks;
NotifyCurrentSinks();
}
media_router::MediaRouter* CefMediaRouterManager::GetMediaRouter() const {
CEF_REQUIRE_UIT();
return media_router::MediaRouterFactory::GetApiForBrowserContext(
browser_context_);
}
void CefMediaRouterManager::OnCreateRoute(
CreateRouteResultCallback callback,
media_router::mojom::RoutePresentationConnectionPtr connection,
const media_router::RouteRequestResult& result) {
CEF_REQUIRE_UIT();
if (result.route()) {
CreateRouteState(*result.route(), std::move(connection));
}
std::move(callback).Run(result);
}
void CefMediaRouterManager::OnRouteStateChange(
const media_router::MediaRoute& route,
const content::PresentationConnectionStateChangeInfo& info) {
CEF_REQUIRE_UIT();
if (info.state == blink::mojom::PresentationConnectionState::CLOSED ||
info.state == blink::mojom::PresentationConnectionState::TERMINATED) {
RemoveRouteState(route.media_route_id());
}
for (auto& observer : observers_) {
observer.OnMediaRouteStateChange(route, info);
}
}
void CefMediaRouterManager::OnMessagesReceived(
const media_router::MediaRoute& route,
const MediaMessageVector& messages) {
CEF_REQUIRE_UIT();
for (auto& observer : observers_) {
observer.OnMediaRouteMessages(route, messages);
}
}
void CefMediaRouterManager::CreateRouteState(
const media_router::MediaRoute& route,
media_router::mojom::RoutePresentationConnectionPtr connection) {
const auto route_id = route.media_route_id();
auto state = std::make_unique<RouteState>();
if (!connection.is_null()) {
// PresentationConnection must be used for messaging and status
// notifications if it exists.
state->presentation_connection_ =
std::make_unique<CefPresentationConnection>(this, route,
std::move(connection));
} else {
// Fallback if PresentationConnection is not supported.
state->message_observer_ =
std::make_unique<CefRouteMessageObserver>(this, route);
state->state_subscription_ =
GetMediaRouter()->AddPresentationConnectionStateChangedCallback(
route_id,
base::BindRepeating(&CefMediaRouterManager::OnRouteStateChange,
weak_ptr_factory_.GetWeakPtr(), route));
}
route_state_map_.insert(std::make_pair(route_id, std::move(state)));
}
CefMediaRouterManager::RouteState* CefMediaRouterManager::GetRouteState(
const media_router::MediaRoute::Id& route_id) {
const auto it = route_state_map_.find(route_id);
if (it != route_state_map_.end())
return it->second.get();
return nullptr;
}
void CefMediaRouterManager::RemoveRouteState(
const media_router::MediaRoute::Id& route_id) {
auto it = route_state_map_.find(route_id);
if (it != route_state_map_.end())
route_state_map_.erase(it);
}

View File

@@ -0,0 +1,125 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MANAGER_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MANAGER_H_
#pragma once
#include "include/cef_media_router.h"
#include "libcef/browser/browser_context.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "chrome/browser/media/router/media_router.h"
#include "chrome/browser/ui/media_router/query_result_manager.h"
#include "chrome/common/media_router/mojom/media_router.mojom.h"
class CefBrowserContext;
class CefMediaRoutesObserver;
class CefPresentationConnection;
class CefRouteMessageObserver;
// Manages CEF usage of MediaRouter. Owned by CefBrowserContext and only
// accessed on the UI thread.
class CefMediaRouterManager
: public media_router::QueryResultManager::Observer {
public:
using MediaRouteVector = std::vector<media_router::MediaRoute>;
using MediaSinkVector = std::vector<media_router::MediaSinkWithCastModes>;
using MediaMessageVector = std::vector<media_router::mojom::RouteMessagePtr>;
class Observer : public base::CheckedObserver {
public:
virtual void OnMediaRouterDestroyed() = 0;
virtual void OnMediaSinks(const MediaSinkVector& sinks) = 0;
virtual void OnMediaRoutes(const MediaRouteVector& routes) = 0;
virtual void OnMediaRouteMessages(const media_router::MediaRoute& route,
const MediaMessageVector& messages) = 0;
virtual void OnMediaRouteStateChange(
const media_router::MediaRoute& route,
const content::PresentationConnectionStateChangeInfo& info) = 0;
protected:
~Observer() override {}
};
explicit CefMediaRouterManager(CefBrowserContext* browser_context);
~CefMediaRouterManager() override;
// |observer| must outlive this object or be removed.
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
void NotifyCurrentSinks();
void NotifyCurrentRoutes();
using CreateRouteResultCallback =
base::OnceCallback<void(const media_router::RouteRequestResult& result)>;
void CreateRoute(const media_router::MediaSource::Id& source_id,
const media_router::MediaSink::Id& sink_id,
const url::Origin& origin,
CreateRouteResultCallback callback);
void SendRouteMessage(const media_router::MediaRoute::Id& route_id,
const std::string& message);
void TerminateRoute(const media_router::MediaRoute::Id& route_id);
// QueryResultManager::Observer methods.
void OnResultsUpdated(const MediaSinkVector& sinks) override;
private:
friend class CefMediaRoutesObserver;
friend class CefPresentationConnection;
friend class CefRouteMessageObserver;
// Do not keep a reference to the object returned by this method.
media_router::MediaRouter* GetMediaRouter() const;
void OnCreateRoute(
CreateRouteResultCallback callback,
media_router::mojom::RoutePresentationConnectionPtr connection,
const media_router::RouteRequestResult& result);
void OnRouteStateChange(
const media_router::MediaRoute& route,
const content::PresentationConnectionStateChangeInfo& info);
void OnMessagesReceived(const media_router::MediaRoute& route,
const MediaMessageVector& messages);
struct RouteState {
std::unique_ptr<CefPresentationConnection> presentation_connection_;
// Used if there is no RoutePresentationConnectionPtr.
std::unique_ptr<CefRouteMessageObserver> message_observer_;
std::unique_ptr<media_router::PresentationConnectionStateSubscription>
state_subscription_;
};
void CreateRouteState(
const media_router::MediaRoute& route,
media_router::mojom::RoutePresentationConnectionPtr connection);
RouteState* GetRouteState(const media_router::MediaRoute::Id& route_id);
void RemoveRouteState(const media_router::MediaRoute::Id& route_id);
CefBrowserContext* const browser_context_;
base::ObserverList<Observer> observers_;
media_router::QueryResultManager query_result_manager_;
std::unique_ptr<CefMediaRoutesObserver> routes_observer_;
MediaRouteVector routes_;
MediaSinkVector sinks_;
using RouteStateMap =
std::map<media_router::MediaRoute::Id, std::unique_ptr<RouteState>>;
RouteStateMap route_state_map_;
base::WeakPtrFactory<CefMediaRouterManager> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefMediaRouterManager);
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MANAGER_H_

View File

@@ -0,0 +1,138 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_sink_impl.h"
#include "libcef/browser/thread_util.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/media/router/discovery/dial/dial_media_sink_service_impl.h"
#include "chrome/browser/media/router/providers/cast/dual_media_sink_service.h"
#include "chrome/common/media_router/discovery/media_sink_internal.h"
#include "chrome/common/media_router/discovery/media_sink_service_base.h"
namespace {
using SinkServiceVector = std::vector<media_router::MediaSinkServiceBase*>;
SinkServiceVector GetSinkServices() {
CEF_REQUIRE_UIT();
auto sink_service = media_router::DualMediaSinkService::GetInstance();
return {sink_service->GetCastMediaSinkServiceImpl(),
sink_service->GetDialMediaSinkServiceImpl()};
}
void GetSinkInternalAndContinue(
SinkServiceVector services,
const media_router::MediaSink::Id& sink_id,
CefRefPtr<CefMediaSinkDeviceInfoCallback> callback) {
CEF_REQUIRE_IOT();
CefMediaSinkDeviceInfo device_info;
const media_router::MediaSinkInternal* sink_internal = nullptr;
for (auto service : services) {
sink_internal = service->GetSinkById(sink_id);
if (sink_internal)
break;
}
if (sink_internal) {
if (sink_internal->is_cast_sink()) {
const auto& cast_data = sink_internal->cast_data();
CefString(&device_info.ip_address) =
cast_data.ip_endpoint.ToStringWithoutPort();
device_info.port = cast_data.ip_endpoint.port();
CefString(&device_info.model_name) = cast_data.model_name;
} else if (sink_internal->is_dial_sink()) {
const auto& dial_data = sink_internal->dial_data();
CefString(&device_info.ip_address) = dial_data.ip_address.ToString();
if (dial_data.app_url.is_valid() && dial_data.app_url.has_port()) {
base::StringToInt(dial_data.app_url.port_piece(), &device_info.port);
}
CefString(&device_info.model_name) = dial_data.model_name;
}
}
// Execute the callback on the UI thread.
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefMediaSinkDeviceInfoCallback::OnMediaSinkDeviceInfo,
callback, device_info));
}
void GetDeviceInfo(const media_router::MediaSink::Id& sink_id,
CefRefPtr<CefMediaSinkDeviceInfoCallback> callback) {
auto next_step = base::BindOnce(
[](const media_router::MediaSink::Id& sink_id,
CefRefPtr<CefMediaSinkDeviceInfoCallback> callback) {
CEF_POST_TASK(CEF_IOT,
base::BindOnce(GetSinkInternalAndContinue,
GetSinkServices(), sink_id, callback));
},
sink_id, callback);
if (CEF_CURRENTLY_ON(CEF_UIT)) {
std::move(next_step).Run();
} else {
CEF_POST_TASK(CEF_UIT, std::move(next_step));
}
}
} // namespace
CefMediaSinkImpl::CefMediaSinkImpl(const media_router::MediaSink& sink)
: sink_(sink) {}
CefMediaSinkImpl::CefMediaSinkImpl(const media_router::MediaSink::Id& sink_id,
const std::string& sink_name)
: sink_(sink_id, sink_name, media_router::SinkIconType::GENERIC) {}
CefString CefMediaSinkImpl::GetId() {
return sink_.id();
}
bool CefMediaSinkImpl::IsValid() {
return true;
}
CefString CefMediaSinkImpl::GetName() {
return sink_.name();
}
CefString CefMediaSinkImpl::GetDescription() {
return sink_.description().value_or("");
}
CefMediaSink::IconType CefMediaSinkImpl::GetIconType() {
// Verify that our enum matches Chromium's values.
static_assert(static_cast<int>(CEF_MSIT_TOTAL_COUNT) ==
static_cast<int>(media_router::SinkIconType::TOTAL_COUNT),
"enum mismatch");
return static_cast<CefMediaSink::IconType>(sink_.icon_type());
}
void CefMediaSinkImpl::GetDeviceInfo(
CefRefPtr<CefMediaSinkDeviceInfoCallback> callback) {
::GetDeviceInfo(sink_.id(), callback);
}
bool CefMediaSinkImpl::IsCastSink() {
return sink_.provider_id() == media_router::CAST;
}
bool CefMediaSinkImpl::IsDialSink() {
return sink_.provider_id() == media_router::DIAL;
}
bool CefMediaSinkImpl::IsCompatibleWith(CefRefPtr<CefMediaSource> source) {
if (source) {
if (IsCastSink())
return source->IsCastSource();
if (IsDialSink())
return source->IsDialSource();
}
return false;
}

View File

@@ -0,0 +1,42 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SINK_IMPL_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SINK_IMPL_H_
#pragma once
#include "include/cef_media_router.h"
#include "chrome/common/media_router/media_sink.h"
// Implementation of the CefMediaSink interface. May be created on any thread.
class CefMediaSinkImpl : public CefMediaSink {
public:
explicit CefMediaSinkImpl(const media_router::MediaSink& sink);
CefMediaSinkImpl(const media_router::MediaSink::Id& sink_id,
const std::string& sink_name);
// CefMediaSink methods.
CefString GetId() override;
bool IsValid() override;
CefString GetName() override;
CefString GetDescription() override;
IconType GetIconType() override;
void GetDeviceInfo(
CefRefPtr<CefMediaSinkDeviceInfoCallback> callback) override;
bool IsCastSink() override;
bool IsDialSink() override;
bool IsCompatibleWith(CefRefPtr<CefMediaSource> source) override;
const media_router::MediaSink& sink() const { return sink_; }
private:
// Read-only after creation.
const media_router::MediaSink sink_;
IMPLEMENT_REFCOUNTING(CefMediaSinkImpl);
DISALLOW_COPY_AND_ASSIGN(CefMediaSinkImpl);
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SINK_IMPL_H_

View File

@@ -0,0 +1,28 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_source_impl.h"
CefMediaSourceImpl::CefMediaSourceImpl(
const media_router::MediaSource::Id& source_id)
: source_(source_id) {}
CefMediaSourceImpl::CefMediaSourceImpl(const GURL& presentation_url)
: source_(presentation_url) {}
CefString CefMediaSourceImpl::GetId() {
return source_.id();
}
bool CefMediaSourceImpl::IsValid() {
return source_.IsValid();
}
bool CefMediaSourceImpl::IsCastSource() {
return !IsDialSource();
}
bool CefMediaSourceImpl::IsDialSource() {
return source_.IsDialSource();
}

View File

@@ -0,0 +1,35 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_IMPL_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_IMPL_H_
#pragma once
#include "include/cef_media_router.h"
#include "chrome/common/media_router/media_source.h"
// Implementation of the CefMediaSource interface. May be created on any thread.
class CefMediaSourceImpl : public CefMediaSource {
public:
explicit CefMediaSourceImpl(const media_router::MediaSource::Id& source_id);
explicit CefMediaSourceImpl(const GURL& presentation_url);
// CefMediaSource methods.
CefString GetId() override;
bool IsValid() override;
bool IsCastSource() override;
bool IsDialSource() override;
const media_router::MediaSource& source() const { return source_; }
private:
// Read-only after creation.
const media_router::MediaSource source_;
IMPLEMENT_REFCOUNTING(CefMediaSourceImpl);
DISALLOW_COPY_AND_ASSIGN(CefMediaSourceImpl);
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_IMPL_H_

View File

@@ -11,8 +11,8 @@
#include "libcef/browser/menu_runner.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/context_menu_params.h"
namespace content {
class RenderFrameHost;

View File

@@ -176,7 +176,8 @@ ui::MouseWheelEvent CefBrowserPlatformDelegateNativeAura::TranslateUiWheelEvent(
int changed_button_flags =
TranslateUiChangedButtonFlags(mouse_event.modifiers);
return ui::MouseWheelEvent(offset, location, root_location, time_stamp, flags,
return ui::MouseWheelEvent(offset, location, root_location, time_stamp,
(ui::EF_PRECISION_SCROLLING_DELTA | flags),
changed_button_flags);
}
@@ -209,6 +210,8 @@ int CefBrowserPlatformDelegateNativeAura::TranslateUiEventModifiers(
result |= ui::EF_CAPS_LOCK_ON;
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
result |= ui::EF_NUM_LOCK_ON;
if (cef_modifiers & EVENTFLAG_ALTGR_DOWN)
result |= ui::EF_ALTGR_DOWN;
return result;
}

View File

@@ -258,10 +258,10 @@ void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {}
CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const {
if (!event.os_event)
return nullptr;
return const_cast<CefEventHandle>(
static_cast<CefEventHandle>(event.os_event->native_event()));
// TODO(cef): We need to return an XEvent* from this method, but
// |event.os_event->native_event()| now returns a ui::Event* instead.
// See https://crbug.com/965991.
return nullptr;
}
std::unique_ptr<CefMenuRunner>
@@ -313,6 +313,16 @@ ui::KeyEvent CefBrowserPlatformDelegateNativeLinux::TranslateUiKeyEvent(
return ui::KeyEvent(type, key_code, dom_code, flags, dom_key, time_stamp);
}
content::NativeWebKeyboardEvent
CefBrowserPlatformDelegateNativeLinux::TranslateWebKeyEvent(
const CefKeyEvent& key_event) const {
ui::KeyEvent ui_event = TranslateUiKeyEvent(key_event);
if (key_event.type == KEYEVENT_CHAR) {
return content::NativeWebKeyboardEvent(ui_event, key_event.character);
}
return content::NativeWebKeyboardEvent(ui_event);
}
base::TimeTicks CefBrowserPlatformDelegateNativeLinux::GetEventTimeStamp()
const {
return base::TimeTicks() + base::TimeDelta::FromSeconds(GetSystemUptime());

View File

@@ -40,6 +40,8 @@ class CefBrowserPlatformDelegateNativeLinux
// CefBrowserPlatformDelegateNativeAura methods:
ui::KeyEvent TranslateUiKeyEvent(const CefKeyEvent& key_event) const override;
content::NativeWebKeyboardEvent TranslateWebKeyEvent(
const CefKeyEvent& key_event) const override;
base::TimeTicks GetEventTimeStamp() const override;
private:

View File

@@ -526,8 +526,7 @@ CefBrowserPlatformDelegateNativeMac::TranslateWebWheelEvent(
result.delta_y = deltaY;
result.wheel_ticks_x = deltaX / scrollbarPixelsPerCocoaTick;
result.wheel_ticks_y = deltaY / scrollbarPixelsPerCocoaTick;
result.delta_units =
ui::input_types::ScrollGranularity::kScrollByPrecisePixel;
result.delta_units = ui::ScrollGranularity::kScrollByPrecisePixel;
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result.button = blink::WebMouseEvent::Button::kLeft;

View File

@@ -8,6 +8,7 @@
#include "ui/base/x/x11_util.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/events/x/x11_event_translation.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
@@ -28,13 +29,6 @@ const char kNetWMState[] = "_NET_WM_STATE";
const char kXdndProxy[] = "XdndProxy";
const char kUTF8String[] = "UTF8_STRING";
::Window FindEventTarget(const ui::PlatformEvent& xev) {
::Window target = xev->xany.window;
if (xev->type == GenericEvent)
target = static_cast<XIDeviceEvent*>(xev->xcookie.data)->event;
return target;
}
::Window FindChild(::Display* display, ::Window window) {
::Window root;
::Window parent;
@@ -109,8 +103,8 @@ CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
CWBackPixmap | CWOverrideRedirect, &swa);
CHECK(xwindow_);
if (ui::PlatformEventSource::GetInstance())
ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
DCHECK(ui::X11EventSource::HasInstance());
ui::X11EventSource::GetInstance()->AddXEventDispatcher(this);
long event_mask = FocusChangeMask | StructureNotifyMask | PropertyChangeMask;
XSelectInput(xdisplay_, xwindow_, event_mask);
@@ -148,8 +142,8 @@ CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
CefWindowX11::~CefWindowX11() {
DCHECK(!xwindow_);
if (ui::PlatformEventSource::GetInstance())
ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
DCHECK(ui::X11EventSource::HasInstance());
ui::X11EventSource::GetInstance()->RemoveXEventDispatcher(this);
}
void CefWindowX11::Close() {
@@ -288,12 +282,88 @@ views::DesktopWindowTreeHostX11* CefWindowX11::GetHost() {
}
bool CefWindowX11::CanDispatchEvent(const ui::PlatformEvent& event) {
::Window target = FindEventTarget(event);
return target == xwindow_;
DCHECK_NE(xwindow_, x11::None);
return !!current_xevent_;
}
uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
XEvent* xev = event;
DCHECK_NE(xwindow_, x11::None);
DCHECK(event);
DCHECK(current_xevent_);
ProcessXEvent(current_xevent_);
return ui::POST_DISPATCH_STOP_PROPAGATION;
}
// Called by X11EventSourceLibevent to determine whether this XEventDispatcher
// implementation is able to process the next translated event sent by it.
void CefWindowX11::CheckCanDispatchNextPlatformEvent(XEvent* xev) {
current_xevent_ = IsTargetedBy(*xev) ? xev : nullptr;
}
void CefWindowX11::PlatformEventDispatchFinished() {
current_xevent_ = nullptr;
}
ui::PlatformEventDispatcher* CefWindowX11::GetPlatformEventDispatcher() {
return this;
}
bool CefWindowX11::DispatchXEvent(XEvent* xev) {
if (!IsTargetedBy(*xev))
return false;
ProcessXEvent(xev);
return true;
}
void CefWindowX11::ContinueFocus() {
if (!focus_pending_)
return;
if (browser_.get())
browser_->SetFocus(true);
focus_pending_ = false;
}
bool CefWindowX11::TopLevelAlwaysOnTop() const {
::Window toplevel_window = FindToplevelParent(xdisplay_, xwindow_);
Atom state_atom = gfx::GetAtom("_NET_WM_STATE");
Atom state_keep_above = gfx::GetAtom("_NET_WM_STATE_KEEP_ABOVE");
Atom* states;
Atom actual_type;
int actual_format;
unsigned long num_items;
unsigned long bytes_after;
XGetWindowProperty(xdisplay_, toplevel_window, state_atom, 0, 1024,
x11::False, XA_ATOM, &actual_type, &actual_format,
&num_items, &bytes_after,
reinterpret_cast<unsigned char**>(&states));
bool always_on_top = false;
for (unsigned long i = 0; i < num_items; ++i) {
if (states[i] == state_keep_above) {
always_on_top = true;
break;
}
}
XFree(states);
return always_on_top;
}
bool CefWindowX11::IsTargetedBy(const XEvent& xev) const {
::Window target_window =
(xev.type == GenericEvent)
? static_cast<XIDeviceEvent*>(xev.xcookie.data)->event
: xev.xany.window;
return target_window == xwindow_;
}
void CefWindowX11::ProcessXEvent(XEvent* xev) {
switch (xev->type) {
case ConfigureNotify: {
DCHECK_EQ(xwindow_, xev->xconfigure.event);
@@ -402,45 +472,4 @@ uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
break;
}
}
return ui::POST_DISPATCH_STOP_PROPAGATION;
}
void CefWindowX11::ContinueFocus() {
if (!focus_pending_)
return;
if (browser_.get())
browser_->SetFocus(true);
focus_pending_ = false;
}
bool CefWindowX11::TopLevelAlwaysOnTop() const {
::Window toplevel_window = FindToplevelParent(xdisplay_, xwindow_);
Atom state_atom = gfx::GetAtom("_NET_WM_STATE");
Atom state_keep_above = gfx::GetAtom("_NET_WM_STATE_KEEP_ABOVE");
Atom* states;
Atom actual_type;
int actual_format;
unsigned long num_items;
unsigned long bytes_after;
XGetWindowProperty(xdisplay_, toplevel_window, state_atom, 0, 1024,
x11::False, XA_ATOM, &actual_type, &actual_format,
&num_items, &bytes_after,
reinterpret_cast<unsigned char**>(&states));
bool always_on_top = false;
for (unsigned long i = 0; i < num_items; ++i) {
if (states[i] == state_keep_above) {
always_on_top = true;
break;
}
}
XFree(states);
return always_on_top;
}

View File

@@ -16,6 +16,7 @@ typedef struct _XDisplay Display;
#include "base/memory/weak_ptr.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/x/x11_atom_cache.h"
@@ -25,7 +26,8 @@ class DesktopWindowTreeHostX11;
// Object wrapper for an X11 Window.
// Based on WindowTreeHostX11 and DesktopWindowTreeHostX11.
class CefWindowX11 : public ui::PlatformEventDispatcher {
class CefWindowX11 : public ui::PlatformEventDispatcher,
public ui::XEventDispatcher {
public:
CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
::Window parent_xwindow,
@@ -50,6 +52,12 @@ class CefWindowX11 : public ui::PlatformEventDispatcher {
bool CanDispatchEvent(const ui::PlatformEvent& event) override;
uint32_t DispatchEvent(const ui::PlatformEvent& event) override;
// ui::XEventDispatcher methods:
void CheckCanDispatchNextPlatformEvent(XEvent* xev) override;
void PlatformEventDispatchFinished() override;
ui::PlatformEventDispatcher* GetPlatformEventDispatcher() override;
bool DispatchXEvent(XEvent* event) override;
::Window xwindow() const { return xwindow_; }
gfx::Rect bounds() const { return bounds_; }
@@ -58,6 +66,9 @@ class CefWindowX11 : public ui::PlatformEventDispatcher {
private:
void ContinueFocus();
bool IsTargetedBy(const XEvent& xev) const;
void ProcessXEvent(XEvent* xev);
CefRefPtr<CefBrowserHostImpl> browser_;
// The display and the native X window hosting the root window.
@@ -73,6 +84,11 @@ class CefWindowX11 : public ui::PlatformEventDispatcher {
bool focus_pending_;
// Tells if this dispatcher can process next translated event based on a
// previous check in ::CheckCanDispatchNextPlatformEvent based on a XID
// target.
XEvent* current_xevent_ = nullptr;
// Must always be the last member.
base::WeakPtrFactory<CefWindowX11> weak_ptr_factory_;

View File

@@ -43,6 +43,7 @@
#include "content/public/common/url_utils.h"
#include "content/public/common/user_agent.h"
#include "ipc/ipc_channel.h"
#include "ui/base/resource/resource_bundle.h"
#include "v8/include/v8.h"
using extensions::api::cef::kSupportedAPIs;
@@ -74,6 +75,7 @@ const char* kAllowedWebUIHosts[] = {
content::kChromeUIAppCacheInternalsHost,
chrome::kChromeUIAccessibilityHost,
content::kChromeUIBlobInternalsHost,
chrome::kChromeUIChromeURLsHost,
chrome::kChromeUICreditsHost,
kChromeUIExtensionsSupportHost,
content::kChromeUIGpuHost,
@@ -118,6 +120,7 @@ const struct {
const char* host;
ChromeHostId host_id;
} kAllowedCefHosts[] = {
{chrome::kChromeUIChromeURLsHost, CHROME_WEBUI_HOSTS},
{kChromeUIExtensionsSupportHost, CHROME_EXTENSIONS_SUPPORT},
{kChromeUILicenseHost, CHROME_LICENSE},
{chrome::kChromeUIVersionHost, CHROME_VERSION},
@@ -341,16 +344,17 @@ bool OnExtensionsSupportUI(std::string* mime_type, std::string* output) {
}
bool OnLicenseUI(std::string* mime_type, std::string* output) {
base::StringPiece piece = CefContentClient::Get()->GetDataResource(
IDR_CEF_LICENSE_TXT, ui::SCALE_FACTOR_NONE);
std::string piece =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
IDR_CEF_LICENSE_TXT);
if (piece.empty()) {
NOTREACHED() << "Failed to load license txt resource.";
return false;
}
*mime_type = "text/html";
*output = "<html><head><title>License</title></head><body><pre>" +
piece.as_string() + "</pre></body></html>";
*output = "<html><head><title>License</title></head><body><pre>" + piece +
"</pre></body></html>";
return true;
}
@@ -358,9 +362,10 @@ bool OnLicenseUI(std::string* mime_type, std::string* output) {
bool OnVersionUI(Profile* profile,
std::string* mime_type,
std::string* output) {
base::StringPiece piece = CefContentClient::Get()->GetDataResource(
IDR_CEF_VERSION_HTML, ui::SCALE_FACTOR_NONE);
if (piece.empty()) {
std::string tmpl =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
IDR_CEF_VERSION_HTML);
if (tmpl.empty()) {
NOTREACHED() << "Failed to load version html resource.";
return false;
}
@@ -381,7 +386,6 @@ bool OnVersionUI(Profile* profile,
parser.Add("MODULEPATH", GetModulePath());
parser.Add("CACHEPATH", CefString(profile->GetPath().value()));
std::string tmpl = piece.as_string();
parser.Parse(&tmpl);
*mime_type = "text/html";
@@ -392,8 +396,8 @@ bool OnVersionUI(Profile* profile,
bool OnWebUIHostsUI(std::string* mime_type, std::string* output) {
std::string html =
"<html>\n<head><title>WebUI Hosts</title></head>\n"
"<body bgcolor=\"white\"><h3>WebUI Hosts</h3>\n<ul>\n";
"<html>\n<head><title>Chrome URLs</title></head>\n"
"<body bgcolor=\"white\"><h3>List of Chrome URLs</h3>\n<ul>\n";
std::vector<std::string> list;
GetAllowedHosts(&list);

View File

@@ -158,13 +158,15 @@ class InternalHandlerFactory : public CefSchemeHandlerFactory {
action.mime_type = GetMimeType(url.path());
if (!action.bytes && action.resource_id >= 0) {
action.bytes =
CefContentClient::Get()->GetDataResourceBytes(action.resource_id);
if (!action.bytes) {
std::string str =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
action.resource_id);
if (str.empty()) {
NOTREACHED() << "Failed to load internal resource for id: "
<< action.resource_id << " URL: " << url.spec().c_str();
return nullptr;
}
action.bytes = base::RefCountedString::TakeString(&str);
}
if (action.bytes) {

View File

@@ -31,6 +31,7 @@
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom.h"
namespace {
@@ -254,6 +255,23 @@ class CefBrowserURLRequest::Context
resource_request->render_frame_id = render_frame_id;
// Behave the same as a subresource load.
resource_request->fetch_request_context_type =
static_cast<int>(blink::mojom::RequestContextType::SUBRESOURCE);
resource_request->resource_type =
static_cast<int>(blink::mojom::ResourceType::kSubResource);
// Set the origin to match the request.
const GURL& url = GURL(request_->GetURL().ToString());
resource_request->request_initiator = url::Origin::Create(url);
if (request_flags & UR_FLAG_ALLOW_STORED_CREDENTIALS) {
// Include SameSite cookies.
resource_request->attach_same_site_cookies = true;
resource_request->site_for_cookies =
net::SiteForCookies::FromOrigin(*resource_request->request_initiator);
}
// SimpleURLLoader is picky about the body contents. Try to populate them
// correctly below.
auto request_body = resource_request->request_body;

View File

@@ -18,11 +18,19 @@ using network::mojom::CookieManager;
namespace {
// Do not keep a reference to the CookieManager returned by this method.
CookieManager* GetCookieManager(CefRequestContextImpl* request_context) {
// Do not keep a reference to the object returned by this method.
CefBrowserContext* GetBrowserContext(const CefBrowserContext::Getter& getter) {
CEF_REQUIRE_UIT();
return content::BrowserContext::GetDefaultStoragePartition(
request_context->GetBrowserContext())
DCHECK(!getter.is_null());
// Will return nullptr if the BrowserContext has been destroyed.
return getter.Run();
}
// Do not keep a reference to the object returned by this method.
CookieManager* GetCookieManager(CefBrowserContext* browser_context) {
CEF_REQUIRE_UIT();
return content::BrowserContext::GetDefaultStoragePartition(browser_context)
->GetCookieManagerForBrowserProcess();
}
@@ -39,6 +47,9 @@ void SetCookieCallbackImpl(CefRefPtr<CefSetCookieCallback> callback,
net::CanonicalCookie::CookieInclusionStatus status) {
if (!callback.get())
return;
if (!status.IsInclude()) {
LOG(WARNING) << "SetCookie failed with reason: " << status.GetDebugString();
}
CEF_POST_TASK(CEF_UIT, base::Bind(&CefSetCookieCallback::OnComplete,
callback.get(), status.IsInclude()));
}
@@ -53,11 +64,15 @@ void DeleteCookiesCallbackImpl(CefRefPtr<CefDeleteCookiesCallback> callback,
}
void ExecuteVisitor(CefRefPtr<CefCookieVisitor> visitor,
CefRefPtr<CefRequestContextImpl> request_context,
const CefBrowserContext::Getter& browser_context_getter,
const std::vector<net::CanonicalCookie>& cookies) {
CEF_REQUIRE_UIT();
CookieManager* cookie_manager = GetCookieManager(request_context.get());
auto browser_context = GetBrowserContext(browser_context_getter);
if (!browser_context)
return;
auto cookie_manager = GetCookieManager(browser_context);
int total = cookies.size(), count = 0;
for (const auto& cc : cookies) {
@@ -77,22 +92,24 @@ void ExecuteVisitor(CefRefPtr<CefCookieVisitor> visitor,
}
// Always execute the callback asynchronously.
void GetAllCookiesCallbackImpl(CefRefPtr<CefCookieVisitor> visitor,
CefRefPtr<CefRequestContextImpl> request_context,
const net::CookieList& cookies) {
CEF_POST_TASK(CEF_UIT,
base::Bind(&ExecuteVisitor, visitor, request_context, cookies));
void GetAllCookiesCallbackImpl(
CefRefPtr<CefCookieVisitor> visitor,
const CefBrowserContext::Getter& browser_context_getter,
const net::CookieList& cookies) {
CEF_POST_TASK(CEF_UIT, base::Bind(&ExecuteVisitor, visitor,
browser_context_getter, cookies));
}
void GetCookiesCallbackImpl(CefRefPtr<CefCookieVisitor> visitor,
CefRefPtr<CefRequestContextImpl> request_context,
const net::CookieStatusList& include_cookies,
const net::CookieStatusList&) {
void GetCookiesCallbackImpl(
CefRefPtr<CefCookieVisitor> visitor,
const CefBrowserContext::Getter& browser_context_getter,
const net::CookieStatusList& include_cookies,
const net::CookieStatusList&) {
net::CookieList cookies;
for (const auto& status : include_cookies) {
cookies.push_back(status.cookie);
}
GetAllCookiesCallbackImpl(visitor, request_context, cookies);
GetAllCookiesCallbackImpl(visitor, browser_context_getter, cookies);
}
} // namespace
@@ -100,11 +117,12 @@ void GetCookiesCallbackImpl(CefRefPtr<CefCookieVisitor> visitor,
CefCookieManagerImpl::CefCookieManagerImpl() {}
void CefCookieManagerImpl::Initialize(
CefRefPtr<CefRequestContextImpl> request_context,
CefBrowserContext::Getter browser_context_getter,
CefRefPtr<CefCompletionCallback> callback) {
DCHECK(request_context);
DCHECK(!request_context_);
request_context_ = request_context;
CEF_REQUIRE_UIT();
DCHECK(!browser_context_getter.is_null());
DCHECK(browser_context_getter_.is_null());
browser_context_getter_ = browser_context_getter;
RunAsyncCompletionOnUIThread(callback);
}
@@ -132,11 +150,14 @@ void CefCookieManagerImpl::SetSupportedSchemes(
all_schemes.push_back("wss");
}
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return;
// This will be forwarded to the CookieMonster that lives in the
// NetworkService process when the NetworkContext is created via
// CefContentBrowserClient::CreateNetworkContext.
request_context_->GetBrowserContext()->set_cookieable_schemes(
base::make_optional(all_schemes));
browser_context->set_cookieable_schemes(base::make_optional(all_schemes));
RunAsyncCompletionOnUIThread(callback);
}
@@ -153,9 +174,13 @@ bool CefCookieManagerImpl::VisitAllCookies(
return true;
}
GetCookieManager(request_context_.get())
->GetAllCookies(
base::Bind(&GetAllCookiesCallbackImpl, visitor, request_context_));
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return false;
GetCookieManager(browser_context)
->GetAllCookies(base::Bind(&GetAllCookiesCallbackImpl, visitor,
browser_context_getter_));
return true;
}
@@ -181,11 +206,17 @@ bool CefCookieManagerImpl::VisitUrlCookies(
net::CookieOptions options;
if (includeHttpOnly)
options.set_include_httponly();
options.set_same_site_cookie_context(
net::CookieOptions::SameSiteCookieContext::MakeInclusive());
GetCookieManager(request_context_.get())
->GetCookieList(
gurl, options,
base::Bind(&GetCookiesCallbackImpl, visitor, request_context_));
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return false;
GetCookieManager(browser_context)
->GetCookieList(gurl, options,
base::Bind(&GetCookiesCallbackImpl, visitor,
browser_context_getter_));
return true;
}
@@ -213,13 +244,18 @@ bool CefCookieManagerImpl::SetCookie(const CefString& url,
if (cookie.has_expires)
cef_time_to_basetime(cookie.expires, expiration_time);
net::CookieSameSite same_site =
net_service::MakeCookieSameSite(cookie.same_site);
net::CookiePriority priority =
net_service::MakeCookiePriority(cookie.priority);
auto canonical_cookie = net::CanonicalCookie::CreateSanitizedCookie(
gurl, name, value, domain, path,
base::Time(), // Creation time.
expiration_time,
base::Time(), // Last access time.
cookie.secure ? true : false, cookie.httponly ? true : false,
net::CookieSameSite::UNSPECIFIED, net::COOKIE_PRIORITY_DEFAULT);
cookie.secure ? true : false, cookie.httponly ? true : false, same_site,
priority);
if (!canonical_cookie) {
SetCookieCallbackImpl(callback,
@@ -232,8 +268,14 @@ bool CefCookieManagerImpl::SetCookie(const CefString& url,
net::CookieOptions options;
if (cookie.httponly)
options.set_include_httponly();
options.set_same_site_cookie_context(
net::CookieOptions::SameSiteCookieContext::MakeInclusive());
GetCookieManager(request_context_.get())
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return false;
GetCookieManager(browser_context)
->SetCanonicalCookie(*canonical_cookie, gurl.scheme(), options,
base::Bind(SetCookieCallbackImpl, callback));
return true;
@@ -270,7 +312,11 @@ bool CefCookieManagerImpl::DeleteCookies(
deletion_filter->cookie_name = cookie_name;
}
GetCookieManager(request_context_.get())
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return false;
GetCookieManager(browser_context)
->DeleteCookies(std::move(deletion_filter),
base::Bind(DeleteCookiesCallbackImpl, callback));
return true;
@@ -286,7 +332,11 @@ bool CefCookieManagerImpl::FlushStore(
return true;
}
GetCookieManager(request_context_.get())
auto browser_context = GetBrowserContext(browser_context_getter_);
if (!browser_context)
return false;
GetCookieManager(browser_context)
->FlushCookieStore(base::Bind(RunAsyncCompletionOnUIThread, callback));
return true;
}

View File

@@ -6,19 +6,20 @@
#define CEF_LIBCEF_BROWSER_NET_SERVICE_COOKIE_MANAGER_IMPL_H_
#include "include/cef_cookie.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/thread_util.h"
#include "base/files/file_path.h"
// Implementation of the CefCookieManager interface.
// Implementation of the CefCookieManager interface. May be created on any
// thread.
class CefCookieManagerImpl : public CefCookieManager {
public:
CefCookieManagerImpl();
// Must be called immediately after this object is created when |is_blocking|
// is false.
void Initialize(CefRefPtr<CefRequestContextImpl> request_context,
// Called on the UI thread after object creation and before any other object
// methods are executed on the UI thread.
void Initialize(CefBrowserContext::Getter browser_context_getter,
CefRefPtr<CefCompletionCallback> callback);
// CefCookieManager methods.
@@ -38,10 +39,11 @@ class CefCookieManagerImpl : public CefCookieManager {
bool FlushStore(CefRefPtr<CefCompletionCallback> callback) override;
private:
// Context that owns the cookie manager.
CefRefPtr<CefRequestContextImpl> request_context_;
// Only accessed on the UI thread. Will be non-null after Initialize().
CefBrowserContext::Getter browser_context_getter_;
IMPLEMENT_REFCOUNTING(CefCookieManagerImpl);
DISALLOW_COPY_AND_ASSIGN(CefCookieManagerImpl);
};
#endif // CEF_LIBCEF_BROWSER_NET_SERVICE_COOKIE_MANAGER_IMPL_H_

View File

@@ -475,9 +475,10 @@ void InterceptedRequest::OnReceiveRedirect(
if (current_request_uses_header_client_) {
// Use the headers we got from OnHeadersReceived as that'll contain
// Set-Cookie if it existed. May be null for synthetic redirects.
DCHECK(current_headers_);
current_response_->headers = current_headers_;
current_headers_ = nullptr;
if (current_headers_) {
current_response_->headers = current_headers_;
current_headers_ = nullptr;
}
} else {
needs_callback = true;
}
@@ -839,15 +840,26 @@ void InterceptedRequest::ContinueToBeforeRedirect(
request_.url = redirect_info.new_url;
}
// If request_ changes from POST to GET, strip POST headers.
const bool post_to_get =
request_.method == "POST" &&
redirect_info.new_method == net::HttpRequestHeaders::kGetMethod;
request_.method = redirect_info.new_method;
request_.site_for_cookies = redirect_info.new_site_for_cookies;
request_.referrer = GURL(redirect_info.new_referrer);
request_.referrer_policy = redirect_info.new_referrer_policy;
// The request method can be changed to "GET". In this case we need to
// reset the request body manually.
if (request_.method == net::HttpRequestHeaders::kGetMethod)
// reset the request body manually, and strip the POST headers.
if (request_.method == net::HttpRequestHeaders::kGetMethod) {
request_.request_body = nullptr;
if (post_to_get) {
request_.headers.RemoveHeader(net::HttpRequestHeaders::kContentLength);
request_.headers.RemoveHeader(net::HttpRequestHeaders::kContentType);
}
}
}
void InterceptedRequest::ContinueToResponseStarted(int error_code) {

View File

@@ -31,6 +31,7 @@
#include "net/base/load_flags.h"
#include "net/http/http_status_code.h"
#include "net/http/http_util.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
#include "ui/base/page_transition_types.h"
#include "url/origin.h"
@@ -1202,8 +1203,8 @@ void InitOnUIThread(
if (request.render_frame_id >= 0) {
// TODO(network): Are these main frame checks equivalent?
if (request.is_main_frame ||
static_cast<content::ResourceType>(request.resource_type) ==
content::ResourceType::kMainFrame) {
static_cast<blink::mojom::ResourceType>(request.resource_type) ==
blink::mojom::ResourceType::kMainFrame) {
frame = web_contents->GetMainFrame();
DCHECK(frame);
} else {

View File

@@ -610,9 +610,12 @@ void StreamReaderURLLoader::OnReaderSkipCompleted(int64_t bytes_skipped) {
HeadersComplete(net::HTTP_OK, -1);
} else if (bytes_skipped == byte_range_.first_byte_position()) {
// We skipped the expected number of bytes.
int64_t expected_content_length = byte_range_.last_byte_position() -
byte_range_.first_byte_position() + 1;
DCHECK_GE(expected_content_length, 0);
int64_t expected_content_length = -1;
if (byte_range_.HasLastBytePosition()) {
expected_content_length = byte_range_.last_byte_position() -
byte_range_.first_byte_position() + 1;
DCHECK_GE(expected_content_length, 0);
}
HeadersComplete(net::HTTP_OK, expected_content_length);
} else {
RequestComplete(bytes_skipped < 0 ? bytes_skipped : net::ERR_FAILED);

View File

@@ -55,7 +55,7 @@ scoped_refptr<URLLoaderFactoryGetter> URLLoaderFactoryGetter::Create(
content::devtools_instrumentation::WillCreateURLLoaderFactory(
static_cast<content::RenderFrameHostImpl*>(render_frame_host),
false /* is_navigation */, false /* is_download */,
&maybe_proxy_factory_request);
&maybe_proxy_factory_request, nullptr /* factory_override */);
}
// Allow the Content embedder to inject itself if it wants to.

View File

@@ -25,10 +25,8 @@
#include "components/viz/common/frame_sinks/begin_frame_args.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/delay_based_time_source.h"
#include "components/viz/common/gl_helper.h"
#include "components/viz/common/switches.h"
#include "content/browser/bad_message.h"
#include "content/browser/compositor/image_transport_factory.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/renderer_host/cursor_manager.h"
#include "content/browser/renderer_host/delegated_frame_host.h"
@@ -48,7 +46,6 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/common/content_switches.h"
#include "media/base/video_frame.h"
#include "ui/base/cursor/types/cursor_types.h"
#include "ui/compositor/compositor.h"
#include "ui/events/blink/blink_event_util.h"
#include "ui/events/gesture_detection/gesture_provider_config_helper.h"
@@ -236,15 +233,11 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
external_begin_frame_enabled_ = use_external_begin_frame;
content::ImageTransportFactory* factory =
content::ImageTransportFactory::GetInstance();
ui::ContextFactoryPrivate* context_factory_private =
factory->GetContextFactoryPrivate();
auto context_factory = content::GetContextFactory();
// Matching the attributes from RecyclableCompositorMac.
compositor_.reset(new ui::Compositor(
context_factory_private->AllocateFrameSinkId(),
content::GetContextFactory(), context_factory_private,
context_factory->AllocateFrameSinkId(), context_factory,
base::ThreadTaskRunnerHandle::Get(), false /* enable_pixel_canvas */,
use_external_begin_frame));
compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
@@ -349,6 +342,12 @@ void CefRenderWidgetHostViewOSR::Show() {
if (is_showing_)
return;
if (!content::GpuDataManagerImpl::GetInstance()->IsGpuCompositingDisabled() &&
!browser_impl_ &&
(!parent_host_view_ || !parent_host_view_->browser_impl_)) {
return;
}
is_showing_ = true;
// If the viz::LocalSurfaceIdAllocation is invalid, we may have been evicted,
@@ -441,8 +440,14 @@ base::Optional<SkColor> CefRenderWidgetHostViewOSR::GetBackgroundColor() {
void CefRenderWidgetHostViewOSR::UpdateBackgroundColor() {}
bool CefRenderWidgetHostViewOSR::LockMouse(bool request_unadjusted_movement) {
return false;
blink::mojom::PointerLockResult CefRenderWidgetHostViewOSR::LockMouse(
bool request_unadjusted_movement) {
return blink::mojom::PointerLockResult::kPermissionDenied;
}
blink::mojom::PointerLockResult CefRenderWidgetHostViewOSR::ChangeMouseLock(
bool request_unadjusted_movement) {
return blink::mojom::PointerLockResult::kPermissionDenied;
}
void CefRenderWidgetHostViewOSR::UnlockMouse() {}
@@ -555,9 +560,16 @@ void CefRenderWidgetHostViewOSR::InitAsPopup(
handler->OnPopupShow(browser_impl_.get(), true);
popup_position_ = pos;
CefRect view_rect;
handler->GetViewRect(browser_impl_.get(), view_rect);
gfx::Rect client_pos(pos.x() - view_rect.x, pos.y() - view_rect.y,
pos.width(), pos.height());
popup_position_ = client_pos;
CefRect widget_pos(client_pos.x(), client_pos.y(), client_pos.width(),
client_pos.height());
CefRect widget_pos(pos.x(), pos.y(), pos.width(), pos.height());
if (handler.get())
handler->OnPopupSize(browser_impl_.get(), widget_pos);
@@ -582,39 +594,29 @@ void CefRenderWidgetHostViewOSR::UpdateCursor(
browser_impl_->GetClient()->GetRenderHandler();
CHECK(handler);
const content::CursorInfo& cursor_info = cursor.info();
const auto& ui_cursor = cursor.cursor();
const cef_cursor_type_t cursor_type =
static_cast<cef_cursor_type_t>(cursor_info.type);
static_cast<cef_cursor_type_t>(ui_cursor.type());
CefCursorInfo custom_cursor_info;
if (cursor_info.type == ui::CursorType::kCustom) {
custom_cursor_info.hotspot.x = cursor_info.hotspot.x();
custom_cursor_info.hotspot.y = cursor_info.hotspot.y();
custom_cursor_info.image_scale_factor = cursor_info.image_scale_factor;
custom_cursor_info.buffer = cursor_info.custom_image.getPixels();
custom_cursor_info.size.width = cursor_info.custom_image.width();
custom_cursor_info.size.height = cursor_info.custom_image.height();
if (ui_cursor.type() == ui::mojom::CursorType::kCustom) {
custom_cursor_info.hotspot.x = ui_cursor.custom_hotspot().x();
custom_cursor_info.hotspot.y = ui_cursor.custom_hotspot().y();
custom_cursor_info.image_scale_factor = ui_cursor.image_scale_factor();
custom_cursor_info.buffer = ui_cursor.custom_bitmap().getPixels();
custom_cursor_info.size.width = ui_cursor.custom_bitmap().width();
custom_cursor_info.size.height = ui_cursor.custom_bitmap().height();
}
#if defined(USE_AURA)
content::WebCursor web_cursor(cursor_info);
content::WebCursor web_cursor(ui_cursor);
ui::PlatformCursor platform_cursor;
if (cursor_info.type == ui::CursorType::kCustom) {
ui::Cursor ui_cursor(ui::CursorType::kCustom);
SkBitmap bitmap;
gfx::Point hotspot;
float scale_factor;
web_cursor.CreateScaledBitmapAndHotspotFromCustomData(&bitmap, &hotspot,
&scale_factor);
ui_cursor.set_custom_bitmap(bitmap);
ui_cursor.set_custom_hotspot(hotspot);
ui_cursor.set_device_scale_factor(scale_factor);
if (ui_cursor.type() == ui::mojom::CursorType::kCustom) {
// |web_cursor| owns the resulting |platform_cursor|.
platform_cursor = web_cursor.GetPlatformCursor(ui_cursor);
} else {
platform_cursor = GetPlatformCursor(cursor_info.type);
platform_cursor = GetPlatformCursor(ui_cursor.type());
}
handler->OnCursorChange(browser_impl_.get(), platform_cursor, cursor_type,
@@ -1059,8 +1061,8 @@ void CefRenderWidgetHostViewOSR::SendExternalBeginFrame() {
if (render_widget_host_)
render_widget_host_->ProgressFlingIfNeeded(frame_time);
compositor_->context_factory_private()->IssueExternalBeginFrame(
compositor_.get(), begin_frame_args, /* force= */ true,
compositor_->IssueExternalBeginFrame(
begin_frame_args, /* force= */ true,
base::BindOnce(&CefRenderWidgetHostViewOSR::OnFrameComplete,
weak_ptr_factory_.GetWeakPtr()));
@@ -1072,9 +1074,18 @@ void CefRenderWidgetHostViewOSR::SendExternalBeginFrame() {
void CefRenderWidgetHostViewOSR::SendKeyEvent(
const content::NativeWebKeyboardEvent& event) {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::SendKeyEvent");
if (render_widget_host_ && render_widget_host_->GetView()) {
content::RenderWidgetHostImpl* target_host = render_widget_host_;
// If there are multiple widgets on the page (such as when there are
// out-of-process iframes), pick the one that should process this event.
if (render_widget_host_ && render_widget_host_->delegate()) {
target_host = render_widget_host_->delegate()->GetFocusedRenderWidgetHost(
render_widget_host_);
}
if (target_host && target_host->GetView()) {
// Direct routing requires that events go directly to the View.
render_widget_host_->ForwardKeyboardEventWithLatencyInfo(
target_host->ForwardKeyboardEventWithLatencyInfo(
event, ui::LatencyInfo(event.GetType() == blink::WebInputEvent::kChar ||
event.GetType() ==
blink::WebInputEvent::kRawKeyDown
@@ -1388,8 +1399,8 @@ void CefRenderWidgetHostViewOSR::UpdateFrameRate() {
}
gfx::Size CefRenderWidgetHostViewOSR::SizeInPixels() {
return gfx::ConvertSizeToPixel(current_device_scale_factor_,
GetViewBounds().size());
return gfx::ScaleToCeiledSize(GetViewBounds().size(),
current_device_scale_factor_);
}
#if defined(OS_MACOSX)

View File

@@ -28,7 +28,7 @@
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/renderer_host/text_input_manager.h"
#include "content/public/common/widget_type.h"
#include "ui/base/cursor/types/cursor_types.h"
#include "ui/base/mojom/cursor_type.mojom-shared.h"
#include "ui/compositor/compositor.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/gesture_detection/filtered_gesture_provider.h"
@@ -49,7 +49,6 @@
#endif
#if defined(USE_AURA)
#include "third_party/blink/public/platform/web_cursor_info.h"
#include "ui/base/cursor/cursor.h"
#endif
@@ -124,7 +123,10 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
void SetBackgroundColor(SkColor color) override;
base::Optional<SkColor> GetBackgroundColor() override;
void UpdateBackgroundColor() override;
bool LockMouse(bool request_unadjusted_movement) override;
blink::mojom::PointerLockResult LockMouse(
bool request_unadjusted_movement) override;
blink::mojom::PointerLockResult ChangeMouseLock(
bool request_unadjusted_movement) override;
void UnlockMouse() override;
void TakeFallbackContentFrom(content::RenderWidgetHostView* view) override;
@@ -321,7 +323,7 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
void UpdateBackgroundColorFromRenderer(SkColor color);
#if defined(USE_AURA)
ui::PlatformCursor GetPlatformCursor(ui::CursorType type);
ui::PlatformCursor GetPlatformCursor(ui::mojom::CursorType type);
#endif
// The background color of the web content.

View File

@@ -5,8 +5,6 @@
#include "libcef/browser/osr/render_widget_host_view_osr.h"
#include "third_party/blink/public/platform/web_cursor_info.h"
#if defined(USE_X11)
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
@@ -23,110 +21,108 @@ namespace {
// Based on ui/base/cursor/cursor_loader_x11.cc.
using blink::WebCursorInfo;
int ToCursorID(ui::CursorType type) {
int ToCursorID(ui::mojom::CursorType type) {
switch (type) {
case ui::CursorType::kPointer:
case ui::mojom::CursorType::kPointer:
return XC_left_ptr;
case ui::CursorType::kCross:
case ui::mojom::CursorType::kCross:
return XC_crosshair;
case ui::CursorType::kHand:
case ui::mojom::CursorType::kHand:
return XC_hand2;
case ui::CursorType::kIBeam:
case ui::mojom::CursorType::kIBeam:
return XC_xterm;
case ui::CursorType::kWait:
case ui::mojom::CursorType::kWait:
return XC_watch;
case ui::CursorType::kHelp:
case ui::mojom::CursorType::kHelp:
return XC_question_arrow;
case ui::CursorType::kEastResize:
case ui::mojom::CursorType::kEastResize:
return XC_right_side;
case ui::CursorType::kNorthResize:
case ui::mojom::CursorType::kNorthResize:
return XC_top_side;
case ui::CursorType::kNorthEastResize:
case ui::mojom::CursorType::kNorthEastResize:
return XC_top_right_corner;
case ui::CursorType::kNorthWestResize:
case ui::mojom::CursorType::kNorthWestResize:
return XC_top_left_corner;
case ui::CursorType::kSouthResize:
case ui::mojom::CursorType::kSouthResize:
return XC_bottom_side;
case ui::CursorType::kSouthEastResize:
case ui::mojom::CursorType::kSouthEastResize:
return XC_bottom_right_corner;
case ui::CursorType::kSouthWestResize:
case ui::mojom::CursorType::kSouthWestResize:
return XC_bottom_left_corner;
case ui::CursorType::kWestResize:
case ui::mojom::CursorType::kWestResize:
return XC_left_side;
case ui::CursorType::kNorthSouthResize:
case ui::mojom::CursorType::kNorthSouthResize:
return XC_sb_v_double_arrow;
case ui::CursorType::kEastWestResize:
case ui::mojom::CursorType::kEastWestResize:
return XC_sb_h_double_arrow;
case ui::CursorType::kNorthEastSouthWestResize:
case ui::mojom::CursorType::kNorthEastSouthWestResize:
return XC_left_ptr;
case ui::CursorType::kNorthWestSouthEastResize:
case ui::mojom::CursorType::kNorthWestSouthEastResize:
return XC_left_ptr;
case ui::CursorType::kColumnResize:
case ui::mojom::CursorType::kColumnResize:
return XC_sb_h_double_arrow;
case ui::CursorType::kRowResize:
case ui::mojom::CursorType::kRowResize:
return XC_sb_v_double_arrow;
case ui::CursorType::kMiddlePanning:
case ui::mojom::CursorType::kMiddlePanning:
return XC_fleur;
case ui::CursorType::kEastPanning:
case ui::mojom::CursorType::kEastPanning:
return XC_sb_right_arrow;
case ui::CursorType::kNorthPanning:
case ui::mojom::CursorType::kNorthPanning:
return XC_sb_up_arrow;
case ui::CursorType::kNorthEastPanning:
case ui::mojom::CursorType::kNorthEastPanning:
return XC_top_right_corner;
case ui::CursorType::kNorthWestPanning:
case ui::mojom::CursorType::kNorthWestPanning:
return XC_top_left_corner;
case ui::CursorType::kSouthPanning:
case ui::mojom::CursorType::kSouthPanning:
return XC_sb_down_arrow;
case ui::CursorType::kSouthEastPanning:
case ui::mojom::CursorType::kSouthEastPanning:
return XC_bottom_right_corner;
case ui::CursorType::kSouthWestPanning:
case ui::mojom::CursorType::kSouthWestPanning:
return XC_bottom_left_corner;
case ui::CursorType::kWestPanning:
case ui::mojom::CursorType::kWestPanning:
return XC_sb_left_arrow;
case ui::CursorType::kMove:
case ui::mojom::CursorType::kMove:
return XC_fleur;
case ui::CursorType::kVerticalText:
case ui::mojom::CursorType::kVerticalText:
return XC_left_ptr;
case ui::CursorType::kCell:
case ui::mojom::CursorType::kCell:
return XC_left_ptr;
case ui::CursorType::kContextMenu:
case ui::mojom::CursorType::kContextMenu:
return XC_left_ptr;
case ui::CursorType::kAlias:
case ui::mojom::CursorType::kAlias:
return XC_left_ptr;
case ui::CursorType::kProgress:
case ui::mojom::CursorType::kProgress:
return XC_left_ptr;
case ui::CursorType::kNoDrop:
case ui::mojom::CursorType::kNoDrop:
return XC_left_ptr;
case ui::CursorType::kCopy:
case ui::mojom::CursorType::kCopy:
return XC_left_ptr;
case ui::CursorType::kNotAllowed:
case ui::mojom::CursorType::kNotAllowed:
return XC_left_ptr;
case ui::CursorType::kZoomIn:
case ui::mojom::CursorType::kZoomIn:
return XC_left_ptr;
case ui::CursorType::kZoomOut:
case ui::mojom::CursorType::kZoomOut:
return XC_left_ptr;
case ui::CursorType::kGrab:
case ui::mojom::CursorType::kGrab:
return XC_left_ptr;
case ui::CursorType::kGrabbing:
case ui::mojom::CursorType::kGrabbing:
return XC_left_ptr;
case ui::CursorType::kMiddlePanningVertical:
case ui::mojom::CursorType::kMiddlePanningVertical:
return XC_left_ptr;
case ui::CursorType::kMiddlePanningHorizontal:
case ui::mojom::CursorType::kMiddlePanningHorizontal:
return XC_left_ptr;
case ui::CursorType::kDndNone:
case ui::mojom::CursorType::kDndNone:
return XC_left_ptr;
case ui::CursorType::kDndMove:
case ui::mojom::CursorType::kDndMove:
return XC_left_ptr;
case ui::CursorType::kDndCopy:
case ui::mojom::CursorType::kDndCopy:
return XC_left_ptr;
case ui::CursorType::kDndLink:
case ui::mojom::CursorType::kDndLink:
return XC_left_ptr;
case ui::CursorType::kNull:
case ui::mojom::CursorType::kNull:
return XC_left_ptr;
case ui::CursorType::kCustom:
case ui::CursorType::kNone:
case ui::mojom::CursorType::kCustom:
case ui::mojom::CursorType::kNone:
break;
}
NOTREACHED();
@@ -184,9 +180,9 @@ XCursorCache* cursor_cache = nullptr;
#endif // defined(USE_X11)
ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor(
ui::CursorType type) {
ui::mojom::CursorType type) {
#if defined(USE_X11)
if (type == ui::CursorType::kNone) {
if (type == ui::mojom::CursorType::kNone) {
if (!invisible_cursor_) {
invisible_cursor_.reset(new ui::XScopedCursor(ui::CreateInvisibleCursor(),
gfx::GetXDisplay()));

View File

@@ -10,7 +10,6 @@
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/content_browser_client.h"
#include "third_party/blink/public/platform/web_cursor_info.h"
#include "ui/resources/grit/ui_unscaled_resources.h"
namespace {
@@ -39,112 +38,110 @@ class CefCompositorHostWin : public gfx::WindowImpl {
// From content/common/cursors/webcursor_win.cc.
using blink::WebCursorInfo;
LPCWSTR ToCursorID(ui::CursorType type) {
LPCWSTR ToCursorID(ui::mojom::CursorType type) {
switch (type) {
case ui::CursorType::kPointer:
case ui::mojom::CursorType::kPointer:
return IDC_ARROW;
case ui::CursorType::kCross:
case ui::mojom::CursorType::kCross:
return IDC_CROSS;
case ui::CursorType::kHand:
case ui::mojom::CursorType::kHand:
return IDC_HAND;
case ui::CursorType::kIBeam:
case ui::mojom::CursorType::kIBeam:
return IDC_IBEAM;
case ui::CursorType::kWait:
case ui::mojom::CursorType::kWait:
return IDC_WAIT;
case ui::CursorType::kHelp:
case ui::mojom::CursorType::kHelp:
return IDC_HELP;
case ui::CursorType::kEastResize:
case ui::mojom::CursorType::kEastResize:
return IDC_SIZEWE;
case ui::CursorType::kNorthResize:
case ui::mojom::CursorType::kNorthResize:
return IDC_SIZENS;
case ui::CursorType::kNorthEastResize:
case ui::mojom::CursorType::kNorthEastResize:
return IDC_SIZENESW;
case ui::CursorType::kNorthWestResize:
case ui::mojom::CursorType::kNorthWestResize:
return IDC_SIZENWSE;
case ui::CursorType::kSouthResize:
case ui::mojom::CursorType::kSouthResize:
return IDC_SIZENS;
case ui::CursorType::kSouthEastResize:
case ui::mojom::CursorType::kSouthEastResize:
return IDC_SIZENWSE;
case ui::CursorType::kSouthWestResize:
case ui::mojom::CursorType::kSouthWestResize:
return IDC_SIZENESW;
case ui::CursorType::kWestResize:
case ui::mojom::CursorType::kWestResize:
return IDC_SIZEWE;
case ui::CursorType::kNorthSouthResize:
case ui::mojom::CursorType::kNorthSouthResize:
return IDC_SIZENS;
case ui::CursorType::kEastWestResize:
case ui::mojom::CursorType::kEastWestResize:
return IDC_SIZEWE;
case ui::CursorType::kNorthEastSouthWestResize:
case ui::mojom::CursorType::kNorthEastSouthWestResize:
return IDC_SIZENESW;
case ui::CursorType::kNorthWestSouthEastResize:
case ui::mojom::CursorType::kNorthWestSouthEastResize:
return IDC_SIZENWSE;
case ui::CursorType::kColumnResize:
case ui::mojom::CursorType::kColumnResize:
return MAKEINTRESOURCE(IDC_COLRESIZE);
case ui::CursorType::kRowResize:
case ui::mojom::CursorType::kRowResize:
return MAKEINTRESOURCE(IDC_ROWRESIZE);
case ui::CursorType::kMiddlePanning:
case ui::mojom::CursorType::kMiddlePanning:
return MAKEINTRESOURCE(IDC_PAN_MIDDLE);
case ui::CursorType::kEastPanning:
case ui::mojom::CursorType::kEastPanning:
return MAKEINTRESOURCE(IDC_PAN_EAST);
case ui::CursorType::kNorthPanning:
case ui::mojom::CursorType::kNorthPanning:
return MAKEINTRESOURCE(IDC_PAN_NORTH);
case ui::CursorType::kNorthEastPanning:
case ui::mojom::CursorType::kNorthEastPanning:
return MAKEINTRESOURCE(IDC_PAN_NORTH_EAST);
case ui::CursorType::kNorthWestPanning:
case ui::mojom::CursorType::kNorthWestPanning:
return MAKEINTRESOURCE(IDC_PAN_NORTH_WEST);
case ui::CursorType::kSouthPanning:
case ui::mojom::CursorType::kSouthPanning:
return MAKEINTRESOURCE(IDC_PAN_SOUTH);
case ui::CursorType::kSouthEastPanning:
case ui::mojom::CursorType::kSouthEastPanning:
return MAKEINTRESOURCE(IDC_PAN_SOUTH_EAST);
case ui::CursorType::kSouthWestPanning:
case ui::mojom::CursorType::kSouthWestPanning:
return MAKEINTRESOURCE(IDC_PAN_SOUTH_WEST);
case ui::CursorType::kWestPanning:
case ui::mojom::CursorType::kWestPanning:
return MAKEINTRESOURCE(IDC_PAN_WEST);
case ui::CursorType::kMove:
case ui::mojom::CursorType::kMove:
return IDC_SIZEALL;
case ui::CursorType::kVerticalText:
case ui::mojom::CursorType::kVerticalText:
return MAKEINTRESOURCE(IDC_VERTICALTEXT);
case ui::CursorType::kCell:
case ui::mojom::CursorType::kCell:
return MAKEINTRESOURCE(IDC_CELL);
case ui::CursorType::kContextMenu:
case ui::mojom::CursorType::kContextMenu:
return IDC_ARROW;
case ui::CursorType::kAlias:
case ui::mojom::CursorType::kAlias:
return MAKEINTRESOURCE(IDC_ALIAS);
case ui::CursorType::kProgress:
case ui::mojom::CursorType::kProgress:
return IDC_APPSTARTING;
case ui::CursorType::kNoDrop:
case ui::mojom::CursorType::kNoDrop:
return IDC_NO;
case ui::CursorType::kCopy:
case ui::mojom::CursorType::kCopy:
return MAKEINTRESOURCE(IDC_COPYCUR);
case ui::CursorType::kNone:
case ui::mojom::CursorType::kNone:
return MAKEINTRESOURCE(IDC_CURSOR_NONE);
case ui::CursorType::kNotAllowed:
case ui::mojom::CursorType::kNotAllowed:
return IDC_NO;
case ui::CursorType::kZoomIn:
case ui::mojom::CursorType::kZoomIn:
return MAKEINTRESOURCE(IDC_ZOOMIN);
case ui::CursorType::kZoomOut:
case ui::mojom::CursorType::kZoomOut:
return MAKEINTRESOURCE(IDC_ZOOMOUT);
case ui::CursorType::kGrab:
case ui::mojom::CursorType::kGrab:
return MAKEINTRESOURCE(IDC_HAND_GRAB);
case ui::CursorType::kGrabbing:
case ui::mojom::CursorType::kGrabbing:
return MAKEINTRESOURCE(IDC_HAND_GRABBING);
case ui::CursorType::kNull:
case ui::mojom::CursorType::kNull:
return IDC_NO;
case ui::CursorType::kMiddlePanningVertical:
case ui::mojom::CursorType::kMiddlePanningVertical:
return MAKEINTRESOURCE(IDC_PAN_MIDDLE_VERTICAL);
case ui::CursorType::kMiddlePanningHorizontal:
case ui::mojom::CursorType::kMiddlePanningHorizontal:
return MAKEINTRESOURCE(IDC_PAN_MIDDLE_HORIZONTAL);
// TODO(cef): Find better cursors for these things
case ui::CursorType::kDndNone:
case ui::mojom::CursorType::kDndNone:
return IDC_ARROW;
case ui::CursorType::kDndMove:
case ui::mojom::CursorType::kDndMove:
return IDC_ARROW;
case ui::CursorType::kDndCopy:
case ui::mojom::CursorType::kDndCopy:
return IDC_ARROW;
case ui::CursorType::kDndLink:
case ui::mojom::CursorType::kDndLink:
return IDC_ARROW;
case ui::CursorType::kCustom:
case ui::mojom::CursorType::kCustom:
break;
}
NOTREACHED();
@@ -158,7 +155,7 @@ bool IsSystemCursorID(LPCWSTR cursor_id) {
} // namespace
ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor(
ui::CursorType type) {
ui::mojom::CursorType type) {
HMODULE module_handle = NULL;
const wchar_t* cursor_id = ToCursorID(type);
if (!IsSystemCursorID(cursor_id)) {

View File

@@ -7,7 +7,6 @@
#include "base/memory/shared_memory_mapping.h"
#include "base/trace_event/trace_event.h"
#include "components/viz/common/resources/resource_sizes.h"
#include "mojo/public/cpp/base/shared_memory_utils.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkCanvas.h"
@@ -74,7 +73,7 @@ void SoftwareOutputDeviceProxy::Resize(const gfx::Size& viewport_pixel_size,
}
#if !defined(OS_WIN)
auto shm = mojo::CreateReadOnlySharedMemoryRegion(required_bytes);
auto shm = base::ReadOnlySharedMemoryRegion::Create(required_bytes);
if (!shm.IsValid()) {
DLOG(ERROR) << "Failed to allocate " << required_bytes << " bytes";
return;

View File

@@ -27,6 +27,7 @@ class CefVideoConsumerOSR : public viz::mojom::FrameSinkVideoConsumer {
mojo::PendingRemote<viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
callbacks) override;
void OnStopped() override;
void OnLog(const std::string& message) override {}
CefRenderWidgetHostViewOSR* const view_;
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;

View File

@@ -29,8 +29,11 @@ void CefWebContentsViewOSR::WebContentsCreated(
DCHECK(!web_contents_);
web_contents_ = web_contents;
// Call this again for popup browsers now that the view should exist.
RenderViewCreated(web_contents_->GetRenderViewHost());
auto host = web_contents_->GetRenderViewHost();
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(host->GetWidget()->GetView());
if (view)
view->InstallTransparency();
}
gfx::NativeView CefWebContentsViewOSR::GetNativeView() const {
@@ -123,15 +126,6 @@ CefWebContentsViewOSR::CreateViewForChildWidget(
void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) {}
void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) {
if (!host)
return;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(host->GetWidget()->GetView());
if (view)
view->InstallTransparency();
}
void CefWebContentsViewOSR::RenderViewReady() {}
void CefWebContentsViewOSR::RenderViewHostChanged(

View File

@@ -50,7 +50,6 @@ class CefWebContentsViewOSR : public content::WebContentsView,
content::RenderWidgetHostViewBase* CreateViewForChildWidget(
content::RenderWidgetHost* render_widget_host) override;
void SetPageTitle(const base::string16& title) override;
void RenderViewCreated(content::RenderViewHost* host) override;
void RenderViewReady() override;
void RenderViewHostChanged(content::RenderViewHost* old_host,
content::RenderViewHost* new_host) override;

View File

@@ -18,6 +18,7 @@
#include "base/values.h"
#include "chrome/browser/accessibility/accessibility_ui.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/net/prediction_options.h"
#include "chrome/browser/net/profile_network_context_service.h"
#include "chrome/browser/net/system_network_context_manager.h"
@@ -82,6 +83,7 @@ std::string GetAcceptLanguageList(Profile* profile) {
} // namespace
const char kUserPrefsFileName[] = "UserPrefs.json";
const char kLocalPrefsFileName[] = "LocalPrefs.json";
std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
const base::FilePath& cache_path,
@@ -117,8 +119,8 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
// Used to store user preferences.
scoped_refptr<PersistentPrefStore> user_pref_store;
if (store_on_disk) {
const base::FilePath& pref_path =
cache_path.AppendASCII(browser_prefs::kUserPrefsFileName);
const base::FilePath& pref_path = cache_path.AppendASCII(
profile ? kUserPrefsFileName : kLocalPrefsFileName);
scoped_refptr<JsonPrefStore> json_pref_store = new JsonPrefStore(
pref_path, std::unique_ptr<PrefFilter>(), sequenced_task_runner);
factory.set_user_prefs(json_pref_store.get());
@@ -177,6 +179,7 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
CefMediaCaptureDevicesDispatcher::RegisterPrefs(registry.get());
certificate_transparency::prefs::RegisterPrefs(registry.get());
flags_ui::PrefServiceFlagsStorage::RegisterPrefs(registry.get());
media_router::RegisterLocalStatePrefs(registry.get());
PluginInfoHostImpl::RegisterUserPrefs(registry.get());
PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get());
ProfileNetworkContextService::RegisterLocalStatePrefs(registry.get());
@@ -200,7 +203,7 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
// From Chrome::RegisterBrowserUserPrefs.
registry->RegisterBooleanPref(prefs::kPrintPreviewUseSystemDefaultPrinter,
true);
false);
if (command_line->HasSwitch(switches::kEnablePreferenceTesting)) {
// Preferences used with unit tests.
@@ -225,6 +228,7 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
extensions::ExtensionPrefs::RegisterProfilePrefs(registry.get());
HostContentSettingsMap::RegisterProfilePrefs(registry.get());
language::LanguagePrefs::RegisterProfilePrefs(registry.get());
media_router::RegisterProfilePrefs(registry.get());
ProfileNetworkContextService::RegisterProfilePrefs(registry.get());
const std::string& locale =

View File

@@ -116,10 +116,10 @@ void FillInDictionaryFromPdfPrintSettings(
print_settings.SetInteger(kSettingMarginsType, margin_type);
if (margin_type == CUSTOM_MARGINS) {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
dict->SetDouble(kSettingMarginTop, pdf_settings.margin_top);
dict->SetDouble(kSettingMarginRight, pdf_settings.margin_right);
dict->SetDouble(kSettingMarginBottom, pdf_settings.margin_bottom);
dict->SetDouble(kSettingMarginLeft, pdf_settings.margin_left);
dict->SetInteger(kSettingMarginTop, pdf_settings.margin_top);
dict->SetInteger(kSettingMarginRight, pdf_settings.margin_right);
dict->SetInteger(kSettingMarginBottom, pdf_settings.margin_bottom);
dict->SetInteger(kSettingMarginLeft, pdf_settings.margin_left);
print_settings.Set(kSettingMarginsCustom, std::move(dict));
}
@@ -151,7 +151,7 @@ void SavePdfFile(scoped_refptr<base::RefCountedSharedMemoryMapping> data,
DCHECK_GT(data->size(), 0U);
MetafileSkia metafile;
metafile.InitFromData(static_cast<const void*>(data->front()), data->size());
metafile.InitFromData(*data);
base::File file(path,
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);

View File

@@ -7,7 +7,6 @@
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/net_service/cookie_manager_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/task_runner_impl.h"
@@ -315,7 +314,7 @@ CefString CefRequestContextImpl::GetCachePath() {
CefRefPtr<CefCookieManager> CefRequestContextImpl::GetCookieManager(
CefRefPtr<CefCompletionCallback> callback) {
CefRefPtr<CefCookieManagerImpl> cookie_manager = new CefCookieManagerImpl();
cookie_manager->Initialize(this, callback);
InitializeCookieManagerOnUIThread(cookie_manager, callback);
return cookie_manager.get();
}
@@ -594,6 +593,12 @@ CefRefPtr<CefExtension> CefRequestContextImpl::GetExtension(
return GetBrowserContext()->extension_system()->GetExtension(extension_id);
}
CefRefPtr<CefMediaRouter> CefRequestContextImpl::GetMediaRouter() {
CefRefPtr<CefMediaRouterImpl> media_router = new CefMediaRouterImpl();
InitializeMediaRouterOnUIThread(media_router);
return media_router.get();
}
void CefRequestContextImpl::OnRenderFrameCreated(int render_process_id,
int render_frame_id,
int frame_tree_node_id,
@@ -640,9 +645,15 @@ void CefRequestContextImpl::Initialize() {
// Share storage with |config_.other|.
browser_context_ =
CefBrowserContext::GetForContext(config_.other->GetBrowserContext());
DCHECK(browser_context_);
}
if (!browser_context_) {
if (!config_.is_global) {
// User-specified settings need to be normalized.
CefContext::Get()->NormalizeRequestContextSettings(&config_.settings);
}
const base::FilePath& cache_path =
base::FilePath(CefString(&config_.settings.cache_path));
if (!cache_path.empty()) {
@@ -656,17 +667,17 @@ void CefRequestContextImpl::Initialize() {
// Create a new CefBrowserContext instance. If the cache path is non-
// empty then this new instance will become the globally registered
// CefBrowserContext for that path. Otherwise, this new instance will
// be a completely isolated "incongento mode" context.
// be a completely isolated "incognito mode" context.
browser_context_ = new CefBrowserContext(config_.settings);
browser_context_->Initialize();
} else {
// Share the same settings as the existing context.
config_.settings = browser_context_->GetSettings();
}
// We'll disassociate from |browser_context_| on destruction.
browser_context_->AddCefRequestContext(this);
// Force our settings to match |browser_context_|.
config_.settings = browser_context_->GetSettings();
if (config_.other) {
// Clear the reference to |config_.other| after setting
// |request_context_getter_|. This is the reverse order of checks in
@@ -761,6 +772,35 @@ void CefRequestContextImpl::ResolveHostInternal(
helper->Start(browser_context, origin);
}
void CefRequestContextImpl::InitializeCookieManagerOnUIThread(
CefRefPtr<CefCookieManagerImpl> cookie_manager,
CefRefPtr<CefCompletionCallback> callback) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::Bind(&CefRequestContextImpl::InitializeCookieManagerOnUIThread,
this, cookie_manager, callback));
return;
}
auto browser_context = GetBrowserContext();
cookie_manager->Initialize(browser_context->getter(), callback);
}
void CefRequestContextImpl::InitializeMediaRouterOnUIThread(
CefRefPtr<CefMediaRouterImpl> media_router) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::Bind(&CefRequestContextImpl::InitializeMediaRouterOnUIThread,
this, media_router));
return;
}
auto browser_context = GetBrowserContext();
media_router->Initialize(browser_context->getter());
}
CefBrowserContext* CefRequestContextImpl::browser_context() const {
return browser_context_;
}

View File

@@ -8,6 +8,8 @@
#include "include/cef_request_context.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/media_router/media_router_impl.h"
#include "libcef/browser/net_service/cookie_manager_impl.h"
#include "libcef/browser/thread_util.h"
class CefBrowserContext;
@@ -75,6 +77,7 @@ class CefRequestContextImpl : public CefRequestContext {
bool HasExtension(const CefString& extension_id) override;
bool GetExtensions(std::vector<CefString>& extension_ids) override;
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
CefRefPtr<CefMediaRouter> GetMediaRouter() override;
const CefRequestContextSettings& settings() const { return config_.settings; }
@@ -147,6 +150,12 @@ class CefRequestContextImpl : public CefRequestContext {
CefRefPtr<CefResolveCallback> callback,
CefBrowserContext* browser_context);
void InitializeCookieManagerOnUIThread(
CefRefPtr<CefCookieManagerImpl> cookie_manager,
CefRefPtr<CefCompletionCallback> callback);
void InitializeMediaRouterOnUIThread(
CefRefPtr<CefMediaRouterImpl> media_router);
CefBrowserContext* browser_context() const;
// We must disassociate from this on destruction.

View File

@@ -114,11 +114,13 @@ const char kPluginPolicy_Block[] = "block";
const char kEnablePreferenceTesting[] = "enable-preference-testing";
// Enable print preview.
extern const char kEnablePrintPreview[] = "enable-print-preview";
const char kEnablePrintPreview[] = "enable-print-preview";
// Disable the timeout for delivering new browser info to the renderer process.
extern const char kDisableNewBrowserInfoTimeout[] =
"disable-new-browser-info-timeout";
const char kDisableNewBrowserInfoTimeout[] = "disable-new-browser-info-timeout";
// File used for logging DevTools protocol messages.
const char kDevToolsProtocolLogFile[] = "devtools-protocol-log-file";
#if defined(OS_MACOSX)
// Path to the framework directory.

View File

@@ -53,6 +53,7 @@ extern const char kPluginPolicy_Block[];
extern const char kEnablePreferenceTesting[];
extern const char kEnablePrintPreview[];
extern const char kDisableNewBrowserInfoTimeout[];
extern const char kDevToolsProtocolLogFile[];
#if defined(OS_MACOSX)
extern const char kFrameworkDirPath[];

View File

@@ -9,7 +9,6 @@
#include "include/cef_stream.h"
#include "include/cef_version.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/extensions/pdf_extension_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h"
@@ -30,6 +29,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pepper_flash.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/pepper_plugin_info.h"
@@ -162,10 +162,12 @@ bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) {
std::string manifest_data;
if (!base::ReadFileToString(manifest_path, &manifest_data))
return false;
std::unique_ptr<base::Value> manifest_value(base::Value::ToUniquePtrValue(
std::move(base::JSONReader::Read(manifest_data,
base::JSON_ALLOW_TRAILING_COMMAS)
.value())));
auto json_manifest_value =
base::JSONReader::Read(manifest_data, base::JSON_ALLOW_TRAILING_COMMAS);
if (!json_manifest_value.has_value())
return false;
std::unique_ptr<base::Value> manifest_value(
base::Value::ToUniquePtrValue(std::move(json_manifest_value.value())));
if (!manifest_value.get())
return false;
base::DictionaryValue* manifest = nullptr;
@@ -292,9 +294,15 @@ void CefContentClient::AddCustomScheme(const SchemeInfo& scheme_info) {
DCHECK(!scheme_info_list_locked_);
scheme_info_list_.push_back(scheme_info);
if (CefContentBrowserClient::Get()) {
CefContentBrowserClient::Get()->RegisterCustomScheme(
scheme_info.scheme_name);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kProcessType)) {
// Register as a Web-safe scheme in the browser process so that requests for
// the scheme from a render process will be allowed in
// resource_dispatcher_host_impl.cc ShouldServiceRequest.
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
if (!policy->IsWebSafeScheme(scheme_info.scheme_name))
policy->RegisterWebSafeScheme(scheme_info.scheme_name);
}
}

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