Compare commits

..

47 Commits
4515 ... 4430

Author SHA1 Message Date
Marshall Greenblatt
19ba7216a0 Update to Chromium version 90.0.4430.212 2021-05-26 11:01:23 -04:00
Marshall Greenblatt
3c44b04c4e Restore support for CreateBrowserSync with NULL |request_context| (see issue #2969)
This was unintentionally lost during the Chrome runtime refactoring effort.
2021-05-20 15:17:13 -04:00
Marshall Greenblatt
7a604aacf4 Fix crash closing DevTools window (fixes issue #3111) 2021-05-05 12:50:21 -04:00
Marshall Greenblatt
f03d75a333 Fix crash in OnGuestDetached when unloading PDF (fixes issue #3121) 2021-05-04 13:34:02 -04:00
Marshall Greenblatt
c53c523f4d Restore async CreateBrowser behavior (fixes issue #3116, fixes issue #3118)
Restore the async CreateBrowser behavior that existed prior to commit 691c9c2
because executing synchronously (for example, from inside OnContextInitialized)
causes issues on MacOS and possibly other platforms.
2021-04-29 17:35:45 -04:00
Marshall Greenblatt
5c92ffb78d Update to Chromium version 90.0.4430.93 2021-04-28 21:46:42 -04:00
Marshall Greenblatt
044c82849e chrome: Support configuration of accept language (see issue #2969)
This change adds support for CEF settings configuration of accept_language_list.
If specified, this value will take precedence over the "intl.accept_languages"
preference which is controlled by chrome://settings/languages.
2021-04-28 14:32:30 -04:00
Marshall Greenblatt
02ae4597d8 chrome: Support configuration of user agent and locale (see issue #2969)
This change adds support for CefSettings and command-line configuration of
user_agent, user_agent_product (formerly product_version) and locale.
2021-04-27 12:49:17 -04:00
Marshall Greenblatt
f2f0bfbdb5 Windows: Disable iterator debugging for cef_sandbox builds (fixes issue #3109)
Iterator debugging has been disabled by default (_HAS_ITERATOR_DEBUGGING=0)
for CEF/Chromium builds using clang/LLVM since 2018. Inversely, it is enabled
by default (_ITERATOR_DEBUG_LEVEL=2) for the MSVC Debug build configuration.
In order to minimize configuration-related headaches for MSVC-based clients
we have been building the Debug cef_sandbox.lib with iterator debugging
enabled. Recently, we have identified a number of crashes that may be due to
bugs in current clang/LLVM or MSVC versions but in any case can be resolved by
disabling iterator debugging:

- Crash when loading chrome://sandbox.
- Crash if an application lists libraries that utilize iterators after
  cef_sandbox.lib in the linker order.

To resolve these crashes we will now disable iterator debugging by default
for the cef_sandbox.lib builds. Client applications that link cef_sandbox.lib
will now also need to build with iterator debugging disabled by setting
_HAS_ITERATOR_DEBUGGING=0 or _ITERATOR_DEBUG_LEVEL=0 in their project
configuration (this will be done for you if you use cef_variables.cmake from
the binary distribution).

In addition to the crash fixes mentioned above, this change also:

- Reduces the size of the Debug cef_sandbox.lib by ~10MB.
- May result in faster Debug executables (see https://crbug.com/539996).
2021-04-26 18:21:19 -04:00
Marshall Greenblatt
d330790ec6 ceftests: Add missing newline at end of file 2021-04-23 21:02:12 -04:00
Marshall Greenblatt
af832bf118 Linux: cefclient: Don't use std::make_unique which requires C++14 2021-04-23 21:02:00 -04:00
Marshall Greenblatt
cd9342c39f Update to Chromium version 90.0.4430.85 2021-04-22 21:12:14 -04:00
Marshall Greenblatt
74c66a3a43 Fix extension loading test failure 2021-04-22 13:41:29 -04:00
Marshall Greenblatt
f718c8947c Fix crash closing DevTools window (fixes issue #3111) 2021-04-20 12:18:26 -04:00
Marshall Greenblatt
c6a4331904 chrome: Support configuration of renderer prefs (see issue #2969) 2021-04-17 21:25:34 -04:00
Marshall Greenblatt
af0e86206a Update to Chromium version 90.0.4430.72 2021-04-15 17:34:45 -04:00
Marshall Greenblatt
e37ceabdf8 chrome: Don't rely on CREATE_STATUS_CREATED for disk-based profiles (see issue #2969) 2021-04-15 13:34:22 -04:00
Marshall Greenblatt
7823df5a45 cefclient: Fix slow loading of the Views image cache (see issue #2969) 2021-04-14 22:30:43 -04:00
Marshall Greenblatt
691c9c2dcc Wait for CefBrowserContext initialization (see issue #2969)
With the Chrome runtime, Profile initialization may be asynchronous. Code that
waited on CefBrowserContext creation now needs to wait on CefBrowserContext
initialization instead.
2021-04-14 21:05:50 -04:00
Marshall Greenblatt
c48a79756c Fix crash when navigating to an unregistered scheme (fixes issue #3105)
The policy->CanAccessDataForOrigin CHECK in NavigationRequest::
GetOriginForURLLoaderFactory was failing because unregistered schemes
(which are already considered non-standard schemes) didn't trigger the
registered non-standard scheme allowance that we previously added in
ChildProcessSecurityPolicyImpl::CanAccessDataForOrigin. This change
modifies GetOriginForURLLoaderFactory to always return an opaque/unique
origin for non-standard schemes resulting in unregistered and non-standard
schemes receiving the same treatment.

New test coverage has been added for this condition, and can be run with:
ceftests --gtest_filter=CorsTest.*CustomUnregistered*
2021-04-12 16:53:44 -04:00
Marshall Greenblatt
d4386da6c3 chrome: mac: Fix exception_port_.is_valid() failure (see issue #2969)
Fixes the following startup error:
FATAL:crashpad_client_mac.cc(499) Check failed: exception_port_.is_valid()
2021-04-11 21:46:35 -04:00
Marshall Greenblatt
8656f19907 mac: ceftests: Fix helper app linker errors (see issue #2969) 2021-04-11 21:45:34 -04:00
Marshall Greenblatt
df150f8ae0 chrome: Support usage of the Chrome toolbar from Views (see issue #2969) 2021-04-11 21:44:37 -04:00
Marshall Greenblatt
d98971fc9e chrome: Fix assertion when clicking the incognito profile button (see issue #2969)
Profile::IsIncognitoProfile() currently returns false for CEF incognito profiles
because they are not the primary OTR profile. At the same time, we don't
necessarily want IsIncognitoProfile() to return true for CEF profiles because,
among other things, that causes the BrowserView to apply the dark toolbar theme.
Instead, this change updates ProfileMenu expectations to support the CEF
incognito profiles without otherwise modifying the incognito behavior.

Note that the IsIncognitoProfile() implementation has recently changed in
https://crrev.com/7bf6eb2497 and the conclusions in this commit will likely need
to be revisited in an upcoming Chromium update.
2021-04-11 21:41:25 -04:00
Marshall Greenblatt
10b7a443cb chrome: Fix FrameTest and RequestHandlerTest failures (see issue #2969) 2021-04-09 22:26:09 -04:00
Marshall Greenblatt
fe5b0df2fa chrome: Fix PreferenceTest failures (see issue #2969) 2021-04-09 22:04:35 -04:00
Marshall Greenblatt
5bfcfaab73 Move cookieable scheme configuration to settings (see issue #2969)
The Chrome runtime requires that cookieable scheme information be available
at Profile initialization time because it also triggers NetworkContext creation
at the same time. To make this possible, and to avoid various race conditions
when setting state, the cookieable scheme configuration has been added as
|cookieable_schemes_list| and |cookieable_schemes_exclude_defaults| in
CefSettings and CefBrowserContextSettings. The CefCookieManager::
SetSupportedSchemes and CefBrowserProcessHandler::GetCookieableSchemes methods
are no longer required and have been removed.

This change also modifies chrome to delay OffTheRecordProfileImpl initialization
so that |ChromeBrowserContext::profile_| can be set before
ChromeContentBrowserClientCef::ConfigureNetworkContextParams calls
CefBrowserContext::FromBrowserContext to retrieve the ChromeBrowserContext
and associated cookieable scheme information. Otherwise, the
ChromeBrowserContext will not be matched and the NetworkContext will not be
configured correctly.

The CookieTest suite now passes with the Chrome runtime enabled.
2021-04-09 15:54:31 -04:00
Marshall Greenblatt
f048a5ddba Fix server thread assertion on CEF shutdown (see issue #2969)
The server thread was not guaranteed to be released in the correct scope on
CEF shutdown. This resulted in occasional thread_restrictions assertions on
ceftests shutdown after running the URLRequestTest suite with the Chrome
runtime enabled.
2021-04-09 15:53:45 -04:00
Marshall Greenblatt
9f05dc2447 chrome: Support customization of context menus (see issue #2969) 2021-04-08 19:43:21 -04:00
Marshall Greenblatt
4d20de09f3 Fix URL rewrite on browser creation (see issue #2969)
The WebUITest suite now passes with the Chrome runtime enabled.
2021-04-07 19:23:47 -04:00
Marshall Greenblatt
c04a578821 Avoid potential use-after-free of CefIOThreadState (see issue #2969)
The problem occured while executing multiple URLRequestTest with the Chrome
runtime.
2021-04-07 19:23:41 -04:00
Marshall Greenblatt
44829818b0 chrome: Support client-created request contexts (see issue #2969)
RequestContextTest and URLRequestTest suites now pass with the Chrome runtime
enabled.
2021-04-07 19:22:55 -04:00
Marshall Greenblatt
cd40496573 chrome: Fix CorsTest.RedirectPost307HttpSchemeToCustomNonStandardScheme failure (see issue #2969) 2021-04-05 15:57:07 -04:00
Marshall Greenblatt
210c1d6b4f chrome: Fix NavigationTest and ResourceRequestHandlerTest failures (see issue #2969) 2021-04-05 15:57:00 -04:00
Marshall Greenblatt
c04592e2a7 chrome: Add support for reparenting of popups with Views (see issue #2969) 2021-04-05 15:55:45 -04:00
Marshall Greenblatt
6ad29642e2 Update to Chromium version 90.0.4430.51 2021-04-01 19:48:06 -04:00
Marshall Greenblatt
1b36d3538c Customize the 'platform' crash key value for ARM builds (see issue #2981, see issue #2773) 2021-03-31 11:05:18 -04:00
Marshall Greenblatt
d399c7220a cefclient: Simplify ClientPrintHandlerGtk for single browser usage (see issue #2196) 2021-03-30 12:51:49 -04:00
Marshall Greenblatt
1cd3f8a3af Move GetPrintHandler to CefClient (see issue #2196)
This new location is preferred because we now know the associated CefBrowser
for all CefPrintHandler callbacks.
2021-03-30 12:30:04 -04:00
Marshall Greenblatt
35a360fe66 Remove CefBrowserSettings.web_security (fixes issue #3058) 2021-03-25 13:08:46 -04:00
Marshall Greenblatt
2ecefdf30b Fix crash in MediaRouterEnabled due to missing pref registration (see issue #2900) 2021-03-24 15:14:29 -04:00
Corentin Dumont
0ad85c19aa Windows: Fix out-of-sync timestamps in OSR mode (fixes issue #3102) 2021-03-23 16:14:01 -04:00
Marshall Greenblatt
1232df3646 Fix potential use-after-free of V8TrackArrayBuffer (fixes issue #3074) 2021-03-23 15:58:17 -04:00
Marshall Greenblatt
dc12a89f28 Revert "Fix potential use-after-free of V8TrackArrayBuffer (fixes issue #3074)"
This reverts commit 8d23e96edf.
2021-03-22 19:45:34 -04:00
Marshall Greenblatt
4011b1e2ab Mac: Fix "fatal error: 'include/cef_pack_resources.h' file not found"
This occurs on a clean build of the ceftests target.
2021-03-22 19:45:21 -04:00
Marshall Greenblatt
8d23e96edf Fix potential use-after-free of V8TrackArrayBuffer (fixes issue #3074) 2021-03-22 13:55:18 -04:00
Marshall Greenblatt
2e4c4750b6 Update to Chromium version 90.0.4430.30 2021-03-19 10:21:25 -04:00
386 changed files with 5462 additions and 7881 deletions

View File

@@ -125,6 +125,7 @@ if (is_mac) {
import("//build/config/mac/rules.gni")
import("//build/util/version.gni")
import("//media/cdm/library_cdm/cdm_paths.gni")
import("//build/config/mac/base_rules.gni")
# Template to compile .xib and .storyboard files.
#
@@ -261,6 +262,12 @@ if (is_clang) {
assert(!clang_use_chrome_plugins)
}
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.
assert(enable_dsyms)
}
#
# Local variables.
@@ -357,9 +364,6 @@ if (is_win) {
# Required by content_switches.cc
"//media:media_buildflags",
# Required by crash_keys.cc (from base/stl_util.h)
"//third_party/abseil-cpp:absl",
]
}
}
@@ -428,8 +432,6 @@ static_library("libcef_static") {
"libcef/browser/browser_context.h",
"libcef/browser/browser_context_keyed_service_factories.cc",
"libcef/browser/browser_context_keyed_service_factories.h",
"libcef/browser/browser_frame.cc",
"libcef/browser/browser_frame.h",
"libcef/browser/browser_host_base.cc",
"libcef/browser/browser_host_base.h",
"libcef/browser/browser_host_create.cc",
@@ -437,8 +439,8 @@ static_library("libcef_static") {
"libcef/browser/browser_info.h",
"libcef/browser/browser_info_manager.cc",
"libcef/browser/browser_info_manager.h",
"libcef/browser/browser_manager.cc",
"libcef/browser/browser_manager.h",
"libcef/browser/browser_message_filter.cc",
"libcef/browser/browser_message_filter.h",
"libcef/browser/browser_message_loop.cc",
"libcef/browser/browser_message_loop.h",
"libcef/browser/browser_platform_delegate.cc",
@@ -486,8 +488,6 @@ static_library("libcef_static") {
"libcef/browser/extensions/api/storage/sync_value_store_cache.h",
"libcef/browser/extensions/api/tabs/tabs_api.cc",
"libcef/browser/extensions/api/tabs/tabs_api.h",
"libcef/browser/extensions/alloy_extensions_util.cc",
"libcef/browser/extensions/alloy_extensions_util.h",
"libcef/browser/extensions/browser_extensions_util.cc",
"libcef/browser/extensions/browser_extensions_util.h",
"libcef/browser/extensions/browser_platform_delegate_background.cc",
@@ -561,6 +561,8 @@ static_library("libcef_static") {
"libcef/browser/native/browser_platform_delegate_native.h",
"libcef/browser/native/cursor_util.h",
"libcef/browser/native/cursor_util.cc",
"libcef/browser/navigate_params.cc",
"libcef/browser/navigate_params.h",
"libcef/browser/navigation_entry_impl.cc",
"libcef/browser/navigation_entry_impl.h",
"libcef/browser/net/chrome_scheme_handler.cc",
@@ -674,6 +676,10 @@ static_library("libcef_static") {
"libcef/common/app_manager.cc",
"libcef/common/app_manager.h",
"libcef/common/base_impl.cc",
"libcef/common/cef_message_generator.cc",
"libcef/common/cef_message_generator.h",
"libcef/common/cef_messages.cc",
"libcef/common/cef_messages.h",
"libcef/common/cef_switches.cc",
"libcef/common/cef_switches.h",
"libcef/common/chrome/chrome_content_client_cef.cc",
@@ -710,6 +716,10 @@ static_library("libcef_static") {
"libcef/common/net/net_resource_provider.h",
"libcef/common/net/scheme_registration.cc",
"libcef/common/net/scheme_registration.h",
"libcef/common/net/upload_data.cc",
"libcef/common/net/upload_data.h",
"libcef/common/net/upload_element.cc",
"libcef/common/net/upload_element.h",
"libcef/common/net/url_util.cc",
"libcef/common/net/url_util.h",
"libcef/common/net_service/net_service_util.cc",
@@ -727,14 +737,14 @@ static_library("libcef_static") {
"libcef/common/resource_util.h",
"libcef/common/response_impl.cc",
"libcef/common/response_impl.h",
"libcef/common/response_manager.cc",
"libcef/common/response_manager.h",
"libcef/common/scheme_registrar_impl.cc",
"libcef/common/scheme_registrar_impl.h",
"libcef/common/string_list_impl.cc",
"libcef/common/string_map_impl.cc",
"libcef/common/string_multimap_impl.cc",
"libcef/common/string_types_impl.cc",
"libcef/common/string_util.cc",
"libcef/common/string_util.h",
"libcef/common/task_impl.cc",
"libcef/common/task_runner_impl.cc",
"libcef/common/task_runner_impl.h",
@@ -760,12 +770,16 @@ static_library("libcef_static") {
"libcef/features/runtime_checks.h",
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
"libcef/renderer/alloy/alloy_content_renderer_client.h",
"libcef/renderer/alloy/alloy_render_frame_observer.cc",
"libcef/renderer/alloy/alloy_render_frame_observer.h",
"libcef/renderer/alloy/alloy_render_thread_observer.cc",
"libcef/renderer/alloy/alloy_render_thread_observer.h",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.cc",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.h",
"libcef/renderer/browser_impl.cc",
"libcef/renderer/browser_impl.h",
"libcef/renderer/browser_manager.cc",
"libcef/renderer/browser_manager.h",
"libcef/renderer/chrome/chrome_content_renderer_client_cef.cc",
"libcef/renderer/chrome/chrome_content_renderer_client_cef.h",
"libcef/renderer/dom_document_impl.cc",
@@ -784,8 +798,8 @@ static_library("libcef_static") {
"libcef/renderer/render_frame_observer.h",
"libcef/renderer/render_frame_util.cc",
"libcef/renderer/render_frame_util.h",
"libcef/renderer/render_manager.cc",
"libcef/renderer/render_manager.h",
"libcef/renderer/render_thread_observer.cc",
"libcef/renderer/render_thread_observer.h",
"libcef/renderer/render_urlrequest_impl.cc",
"libcef/renderer/render_urlrequest_impl.h",
"libcef/renderer/thread_util.h",
@@ -795,10 +809,6 @@ static_library("libcef_static") {
# For Chrome runtime support.
"//chrome/app/chrome_main_delegate.cc",
"//chrome/app/chrome_main_delegate.h",
# Part of //content//test::test_support which is testingonly.
"//content/public/test/scoped_web_ui_controller_factory_registration.cc",
"//content/public/test/scoped_web_ui_controller_factory_registration.h",
]
configs += [
@@ -825,7 +835,6 @@ static_library("libcef_static") {
deps = [
":cef_make_headers",
"libcef/common/mojom",
":libcef_static_unittested",
@@ -1654,29 +1663,6 @@ if (is_mac) {
# Executable/app targets.
#
# Source files for TeamCity GTest integration.
# See tests/gtest/teamcity/README.cef for details.
source_set("gtest_teamcity") {
testonly = true
sources = [
"tests/gtest/teamcity/include/teamcity_gtest.h",
"tests/gtest/teamcity/src/teamcity_gtest.cpp",
"tests/gtest/teamcity/src/teamcity_gtest.h",
"tests/gtest/teamcity/src/teamcity_messages.cpp",
"tests/gtest/teamcity/src/teamcity_messages.h",
]
deps = [
"//testing/gtest",
]
configs += [
"libcef/features:config",
"//build/config:precompiled_headers",
]
}
if (is_mac) {
# Helper for generating the CEF app bundle.
template("cef_app") {
@@ -2004,7 +1990,6 @@ if (is_mac) {
gypi_paths2.shared_sources_mac_helper +
gypi_paths2.ceftests_sources_mac_helper
helper_deps = [
":gtest_teamcity",
"//testing/gtest",
]
helper_defines = [
@@ -2025,7 +2010,6 @@ if (is_mac) {
":ceftests_resources_bundle_data",
":ceftests_resources_bundle_data_english",
":ceftests_xibs",
":gtest_teamcity",
"//testing/gtest",
]
frameworks = [
@@ -2244,7 +2228,6 @@ if (is_mac) {
deps = [
":libcef",
":libcef_dll_wrapper",
":gtest_teamcity",
"//testing/gtest",
]

View File

@@ -7,6 +7,6 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/92.0.4515.159',
'depot_tools_checkout': '58542b7fef'
'chromium_checkout': 'refs/tags/90.0.4430.212',
'depot_tools_checkout': '9757ad5883'
}

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=d723a9f6637cec523b158a6750d3a64698b407c3$
# $hash=f1877c7a493342351e284cb6c14e6f223461facb$
#
{
@@ -40,7 +40,6 @@
'include/cef_find_handler.h',
'include/cef_focus_handler.h',
'include/cef_frame.h',
'include/cef_frame_handler.h',
'include/cef_image.h',
'include/cef_jsdialog_handler.h',
'include/cef_keyboard_handler.h',
@@ -138,7 +137,6 @@
'include/capi/cef_find_handler_capi.h',
'include/capi/cef_focus_handler_capi.h',
'include/capi/cef_frame_capi.h',
'include/capi/cef_frame_handler_capi.h',
'include/capi/cef_image_capi.h',
'include/capi/cef_jsdialog_handler_capi.h',
'include/capi/cef_keyboard_handler_capi.h',
@@ -302,8 +300,6 @@
'libcef_dll/ctocpp/focus_handler_ctocpp.h',
'libcef_dll/cpptoc/frame_cpptoc.cc',
'libcef_dll/cpptoc/frame_cpptoc.h',
'libcef_dll/ctocpp/frame_handler_ctocpp.cc',
'libcef_dll/ctocpp/frame_handler_ctocpp.h',
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.cc',
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h',
'libcef_dll/cpptoc/image_cpptoc.cc',
@@ -614,8 +610,6 @@
'libcef_dll/cpptoc/focus_handler_cpptoc.h',
'libcef_dll/ctocpp/frame_ctocpp.cc',
'libcef_dll/ctocpp/frame_ctocpp.h',
'libcef_dll/cpptoc/frame_handler_cpptoc.cc',
'libcef_dll/cpptoc/frame_handler_cpptoc.h',
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.cc',
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h',
'libcef_dll/ctocpp/image_ctocpp.cc',

View File

@@ -22,6 +22,7 @@
'include/base/cef_platform_thread.h',
'include/base/cef_ref_counted.h',
'include/base/cef_scoped_ptr.h',
'include/base/cef_string16.h',
'include/base/cef_template_util.h',
'include/base/cef_thread_checker.h',
'include/base/cef_trace_event.h',
@@ -127,6 +128,7 @@
'libcef_dll/base/cef_lock_impl.cc',
'libcef_dll/base/cef_logging.cc',
'libcef_dll/base/cef_ref_counted.cc',
'libcef_dll/base/cef_string16.cc',
'libcef_dll/base/cef_thread_checker_impl.cc',
'libcef_dll/base/cef_weak_ptr.cc',
],
@@ -471,7 +473,6 @@
'tests/ceftests/extensions/extension_test_handler.h',
'tests/ceftests/extensions/view_unittest.cc',
'tests/ceftests/file_util_unittest.cc',
'tests/ceftests/frame_handler_unittest.cc',
'tests/ceftests/frame_unittest.cc',
'tests/ceftests/image_unittest.cc',
'tests/ceftests/image_util.cc',

View File

@@ -75,6 +75,7 @@ typedef unsigned short uint16;
#endif
// UTF-16 character type.
// This should be kept synchronized with base/strings/string16.h
#ifndef char16
#if defined(WCHAR_T_IS_UTF16)
typedef wchar_t char16;

223
include/base/cef_string16.h Normal file
View File

@@ -0,0 +1,223 @@
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2013
// Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_BASE_CEF_STRING16_H_
#define CEF_INCLUDE_BASE_CEF_STRING16_H_
#pragma once
#if defined(BASE_STRINGS_STRING16_H_)
// Do nothing if the Chromium header has already been included.
// This can happen in cases where Chromium code is used directly by the
// client application. When using Chromium code directly always include
// the Chromium header first to avoid type conflicts.
#elif defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "base/strings/string16.h"
#else // !USING_CHROMIUM_INCLUDES
// The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be
// updated to match.
// WHAT:
// A version of std::basic_string that provides 2-byte characters even when
// wchar_t is not implemented as a 2-byte type. You can access this class as
// string16. We also define char16, which string16 is based upon.
//
// WHY:
// On Windows, wchar_t is 2 bytes, and it can conveniently handle UTF-16/UCS-2
// data. Plenty of existing code operates on strings encoded as UTF-16.
//
// On many other platforms, sizeof(wchar_t) is 4 bytes by default. We can make
// it 2 bytes by using the GCC flag -fshort-wchar. But then std::wstring fails
// at run time, because it calls some functions (like wcslen) that come from
// the system's native C library -- which was built with a 4-byte wchar_t!
// It's wasteful to use 4-byte wchar_t strings to carry UTF-16 data, and it's
// entirely improper on those systems where the encoding of wchar_t is defined
// as UTF-32.
//
// Here, we define string16, which is similar to std::wstring but replaces all
// libc functions with custom, 2-byte-char compatible routines. It is capable
// of carrying UTF-16-encoded data.
#include <stdio.h>
#include <string>
#include "include/base/cef_basictypes.h"
#if defined(WCHAR_T_IS_UTF16)
namespace base {
typedef wchar_t char16;
typedef std::wstring string16;
typedef std::char_traits<wchar_t> string16_char_traits;
} // namespace base
#elif defined(WCHAR_T_IS_UTF32)
#include <stdint.h> // For uint16_t
#include "include/base/cef_macros.h"
namespace cef {
namespace base {
typedef uint16_t char16;
// char16 versions of the functions required by string16_char_traits; these
// are based on the wide character functions of similar names ("w" or "wcs"
// instead of "c16").
int c16memcmp(const char16* s1, const char16* s2, size_t n);
size_t c16len(const char16* s);
const char16* c16memchr(const char16* s, char16 c, size_t n);
char16* c16memmove(char16* s1, const char16* s2, size_t n);
char16* c16memcpy(char16* s1, const char16* s2, size_t n);
char16* c16memset(char16* s, char16 c, size_t n);
struct string16_char_traits {
typedef char16 char_type;
typedef int int_type;
// int_type needs to be able to hold each possible value of char_type, and in
// addition, the distinct value of eof().
COMPILE_ASSERT(sizeof(int_type) > sizeof(char_type), unexpected_type_width);
typedef std::streamoff off_type;
typedef mbstate_t state_type;
typedef std::fpos<state_type> pos_type;
static void assign(char_type& c1, const char_type& c2) { c1 = c2; }
static bool eq(const char_type& c1, const char_type& c2) { return c1 == c2; }
static bool lt(const char_type& c1, const char_type& c2) { return c1 < c2; }
static int compare(const char_type* s1, const char_type* s2, size_t n) {
return c16memcmp(s1, s2, n);
}
static size_t length(const char_type* s) { return c16len(s); }
static const char_type* find(const char_type* s,
size_t n,
const char_type& a) {
return c16memchr(s, a, n);
}
static char_type* move(char_type* s1, const char_type* s2, int_type n) {
return c16memmove(s1, s2, n);
}
static char_type* copy(char_type* s1, const char_type* s2, size_t n) {
return c16memcpy(s1, s2, n);
}
static char_type* assign(char_type* s, size_t n, char_type a) {
return c16memset(s, a, n);
}
static int_type not_eof(const int_type& c) {
return eq_int_type(c, eof()) ? 0 : c;
}
static char_type to_char_type(const int_type& c) { return char_type(c); }
static int_type to_int_type(const char_type& c) { return int_type(c); }
static bool eq_int_type(const int_type& c1, const int_type& c2) {
return c1 == c2;
}
static int_type eof() { return static_cast<int_type>(EOF); }
};
typedef std::basic_string<char16, string16_char_traits> string16;
} // namespace base
} // namespace cef
namespace base {
typedef cef::base::char16 char16;
typedef cef::base::string16 string16;
extern std::ostream& operator<<(std::ostream& out, const string16& str);
// This is required by googletest to print a readable output on test failures.
extern void PrintTo(const string16& str, std::ostream* out);
} // namespace base
// The string class will be explicitly instantiated only once, in string16.cc.
//
// std::basic_string<> in GNU libstdc++ contains a static data member,
// _S_empty_rep_storage, to represent empty strings. When an operation such
// as assignment or destruction is performed on a string, causing its existing
// data member to be invalidated, it must not be freed if this static data
// member is being used. Otherwise, it counts as an attempt to free static
// (and not allocated) data, which is a memory error.
//
// Generally, due to C++ template magic, _S_empty_rep_storage will be marked
// as a coalesced symbol, meaning that the linker will combine multiple
// instances into a single one when generating output.
//
// If a string class is used by multiple shared libraries, a problem occurs.
// Each library will get its own copy of _S_empty_rep_storage. When strings
// are passed across a library boundary for alteration or destruction, memory
// errors will result. GNU libstdc++ contains a configuration option,
// --enable-fully-dynamic-string (_GLIBCXX_FULLY_DYNAMIC_STRING), which
// disables the static data member optimization, but it's a good optimization
// and non-STL code is generally at the mercy of the system's STL
// configuration. Fully-dynamic strings are not the default for GNU libstdc++
// libstdc++ itself or for the libstdc++ installations on the systems we care
// about, such as Mac OS X and relevant flavors of Linux.
//
// See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196 .
//
// To avoid problems, string classes need to be explicitly instantiated only
// once, in exactly one library. All other string users see it via an "extern"
// declaration. This is precisely how GNU libstdc++ handles
// std::basic_string<char> (string) and std::basic_string<wchar_t> (wstring).
//
// This also works around a Mac OS X linker bug in ld64-85.2.1 (Xcode 3.1.2),
// in which the linker does not fully coalesce symbols when dead code
// stripping is enabled. This bug causes the memory errors described above
// to occur even when a std::basic_string<> does not cross shared library
// boundaries, such as in statically-linked executables.
//
// TODO(mark): File this bug with Apple and update this note with a bug number.
extern template class std::basic_string<cef::base::char16,
cef::base::string16_char_traits>;
#endif // WCHAR_T_IS_UTF32
#endif // !USING_CHROMIUM_INCLUDES
#endif // CEF_INCLUDE_BASE_CEF_STRING16_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=6e192c6e8a59c37e98e458578a287dd36b8ed90f$
// $hash=09b6ebd4116e983b4af634f1efa17b326a3fc517$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
@@ -57,10 +57,10 @@ struct _cef_browser_host_t;
struct _cef_client_t;
///
// Structure used to represent a browser. When used in the browser process the
// functions of this structure may be called on any thread unless otherwise
// indicated in the comments. When used in the render process the functions of
// this structure may only be called on the main thread.
// Structure used to represent a browser window. When used in the browser
// process the functions of this structure may be called on any thread unless
// otherwise indicated in the comments. When used in the render process the
// functions of this structure may only be called on the main thread.
///
typedef struct _cef_browser_t {
///
@@ -68,12 +68,6 @@ typedef struct _cef_browser_t {
///
cef_base_ref_counted_t base;
///
// True if this object is currently valid. This will return false (0) after
// cef_life_span_handler_t::OnBeforeClose is called.
///
int(CEF_CALLBACK* is_valid)(struct _cef_browser_t* self);
///
// Returns the browser host object. This function can only be called in the
// browser process.
@@ -135,7 +129,7 @@ typedef struct _cef_browser_t {
struct _cef_browser_t* that);
///
// Returns true (1) if the browser is a popup.
// Returns true (1) if the window is a popup window.
///
int(CEF_CALLBACK* is_popup)(struct _cef_browser_t* self);
@@ -145,19 +139,13 @@ typedef struct _cef_browser_t {
int(CEF_CALLBACK* has_document)(struct _cef_browser_t* self);
///
// Returns the main (top-level) frame for the browser. In the browser process
// this will return a valid object until after
// cef_life_span_handler_t::OnBeforeClose is called. In the renderer process
// this will return NULL if the main frame is hosted in a different renderer
// process (e.g. for cross-origin sub-frames). The main frame object will
// change during cross-origin navigation or re-navigation after renderer
// process termination (due to crashes, etc).
// Returns the main (top-level) frame for the browser window.
///
struct _cef_frame_t*(CEF_CALLBACK* get_main_frame)(
struct _cef_browser_t* self);
///
// Returns the focused frame for the browser.
// Returns the focused frame for the browser window.
///
struct _cef_frame_t*(CEF_CALLBACK* get_focused_frame)(
struct _cef_browser_t* self);
@@ -286,10 +274,10 @@ typedef struct _cef_download_image_callback_t {
} cef_download_image_callback_t;
///
// Structure used to represent the browser process aspects of a browser. The
// functions of this structure can only be called in the browser process. They
// may be called on any thread in that process unless otherwise indicated in the
// comments.
// Structure used to represent the browser process aspects of a browser window.
// The functions of this structure can only be called in the browser process.
// They may be called on any thread in that process unless otherwise indicated
// in the comments.
///
typedef struct _cef_browser_host_t {
///
@@ -318,12 +306,11 @@ typedef struct _cef_browser_host_t {
///
// Helper for closing a browser. Call this function from the top-level window
// close handler (if any). Internally this calls CloseBrowser(false (0)) if
// the close has not yet been initiated. This function returns false (0) while
// the close is pending and true (1) after the close has completed. See
// close_browser() and cef_life_span_handler_t::do_close() documentation for
// additional usage information. This function must be called on the browser
// process UI thread.
// close handler. Internally this calls CloseBrowser(false (0)) if the close
// has not yet been initiated. This function returns false (0) while the close
// is pending and true (1) after the close has completed. See close_browser()
// and cef_life_span_handler_t::do_close() documentation for additional usage
// information. This function must be called on the browser process UI thread.
///
int(CEF_CALLBACK* try_close_browser)(struct _cef_browser_host_t* self);
@@ -333,19 +320,18 @@ typedef struct _cef_browser_host_t {
void(CEF_CALLBACK* set_focus)(struct _cef_browser_host_t* self, int focus);
///
// Retrieve the window handle (if any) for this browser. If this browser is
// wrapped in a cef_browser_view_t this function should be called on the
// browser process UI thread and it will return the handle for the top-level
// native window.
// Retrieve the window handle for this browser. If this browser is wrapped in
// a cef_browser_view_t this function should be called on the browser process
// UI thread and it will return the handle for the top-level native window.
///
cef_window_handle_t(CEF_CALLBACK* get_window_handle)(
struct _cef_browser_host_t* self);
///
// Retrieve the window handle (if any) of the browser that opened this
// browser. Will return NULL for non-popup browsers or if this browser is
// wrapped in a cef_browser_view_t. This function can be used in combination
// with custom handling of modal windows.
// Retrieve the window handle of the browser that opened this browser. Will
// return NULL for non-popup windows or if this browser is wrapped in a
// cef_browser_view_t. This function can be used in combination with custom
// handling of modal windows.
///
cef_window_handle_t(CEF_CALLBACK* get_opener_window_handle)(
struct _cef_browser_host_t* self);
@@ -923,9 +909,9 @@ typedef struct _cef_browser_host_t {
} cef_browser_host_t;
///
// Create a new browser using the window parameters specified by |windowInfo|.
// All values will be copied internally and the actual window (if any) will be
// created on the UI thread. If |request_context| is NULL the global request
// Create a new browser window using the window parameters specified by
// |windowInfo|. All values will be copied internally and the actual window will
// be created on the UI thread. If |request_context| is NULL the global request
// context will be used. This function can be called on any browser process
// thread and will not block. The optional |extra_info| parameter provides an
// opportunity to specify extra information specific to the created browser that
@@ -941,11 +927,11 @@ CEF_EXPORT int cef_browser_host_create_browser(
struct _cef_request_context_t* request_context);
///
// Create a new browser using the window parameters specified by |windowInfo|.
// If |request_context| is NULL the global request context will be used. This
// function can only be called on the browser process UI thread. The optional
// |extra_info| parameter provides an opportunity to specify extra information
// specific to the created browser that will be passed to
// Create a new browser window using the window parameters specified by
// |windowInfo|. If |request_context| is NULL the global request context will be
// used. This function can only be called on the browser process UI thread. The
// optional |extra_info| parameter provides an opportunity to specify extra
// information specific to the created browser that will be passed to
// cef_render_process_handler_t::on_browser_created() in the render process.
///
CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync(

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=845a1d1dda63a06f4ae33ed39acfd2599b46a885$
// $hash=14eca959988209ba8f95037a47192fd50d64f2f1$
//
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
@@ -49,7 +49,6 @@
#include "include/capi/cef_drag_handler_capi.h"
#include "include/capi/cef_find_handler_capi.h"
#include "include/capi/cef_focus_handler_capi.h"
#include "include/capi/cef_frame_handler_capi.h"
#include "include/capi/cef_jsdialog_handler_capi.h"
#include "include/capi/cef_keyboard_handler_capi.h"
#include "include/capi/cef_life_span_handler_capi.h"
@@ -123,14 +122,6 @@ typedef struct _cef_client_t {
struct _cef_focus_handler_t*(CEF_CALLBACK* get_focus_handler)(
struct _cef_client_t* self);
///
// Return the handler for events related to cef_frame_t lifespan. This
// function will be called once during cef_browser_t creation and the result
// will be cached for performance reasons.
///
struct _cef_frame_handler_t*(CEF_CALLBACK* get_frame_handler)(
struct _cef_client_t* self);
///
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.
@@ -177,8 +168,8 @@ typedef struct _cef_client_t {
///
// Called when a new message is received from a different process. Return true
// (1) if the message was handled or false (0) otherwise. It is safe to keep
// a reference to |message| outside of this callback.
// (1) if the message was handled or false (0) otherwise. Do not keep a
// reference to or attempt to access the message outside of this callback.
///
int(CEF_CALLBACK* on_process_message_received)(
struct _cef_client_t* self,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=872fd1e811d41f56f03da0da75a8f2e89cad40cd$
// $hash=bce865a34f45e6dee8f413f0d6bd7f4c37ab55c0$
//
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
@@ -242,12 +242,10 @@ typedef struct _cef_frame_t {
struct _cef_urlrequest_client_t* client);
///
// Send a message to the specified |target_process|. Ownership of the message
// contents will be transferred and the |message| reference will be
// invalidated. Message delivery is not guaranteed in all cases (for example,
// if the browser is closing, navigating, or if the target process crashes).
// Send an ACK message back from the target process if confirmation is
// required.
// Send a message to the specified |target_process|. Message delivery is not
// guaranteed in all cases (for example, if the browser is closing,
// navigating, or if the target process crashes). Send an ACK message back
// from the target process if confirmation is required.
///
void(CEF_CALLBACK* send_process_message)(
struct _cef_frame_t* self,

View File

@@ -1,191 +0,0 @@
// Copyright (c) 2021 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=503984bf98aa52ff67ce52f26a560bbb1d4439bc$
//
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#include "include/capi/cef_frame_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Implement this structure to handle events related to cef_frame_t life span.
// The order of callbacks is:
//
// (1) During initial cef_browser_host_t creation and navigation of the main
// frame: - cef_frame_handler_t::OnFrameCreated => The initial main frame object
// has been
// created. Any commands will be queued until the frame is attached.
// - cef_frame_handler_t::OnMainFrameChanged => The initial main frame object
// has
// been assigned to the browser.
// - cef_life_span_handler_t::OnAfterCreated => The browser is now valid and can
// be
// used.
// - cef_frame_handler_t::OnFrameAttached => The initial main frame object is
// now
// connected to its peer in the renderer process. Commands can be routed.
//
// (2) During further cef_browser_host_t navigation/loading of the main frame
// and/or sub-frames: - cef_frame_handler_t::OnFrameCreated => A new main frame
// or sub-frame object has
// been created. Any commands will be queued until the frame is attached.
// - cef_frame_handler_t::OnFrameAttached => A new main frame or sub-frame
// object is
// now connected to its peer in the renderer process. Commands can be routed.
// - cef_frame_handler_t::OnFrameDetached => An existing main frame or sub-frame
// object has lost its connection to the renderer process. If multiple objects
// are detached at the same time then notifications will be sent for any
// sub-frame objects before the main frame object. Commands can no longer be
// routed and will be discarded.
// - cef_frame_handler_t::OnMainFrameChanged => A new main frame object has been
// assigned to the browser. This will only occur with cross-origin navigation
// or re-navigation after renderer process termination (due to crashes, etc).
//
// (3) During final cef_browser_host_t destruction of the main frame: -
// cef_frame_handler_t::OnFrameDetached => Any sub-frame objects have lost their
// connection to the renderer process. Commands can no longer be routed and
// will be discarded.
// - cef_life_span_handler_t::OnBeforeClose => The browser has been destroyed. -
// cef_frame_handler_t::OnFrameDetached => The main frame object have lost its
// connection to the renderer process. Notifications will be sent for any
// sub-frame objects before the main frame object. Commands can no longer be
// routed and will be discarded.
// - cef_frame_handler_t::OnMainFrameChanged => The final main frame object has
// been
// removed from the browser.
//
// Cross-origin navigation and/or loading receives special handling.
//
// When the main frame navigates to a different origin the OnMainFrameChanged
// callback (2) will be executed with the old and new main frame objects.
//
// When a new sub-frame is loaded in, or an existing sub-frame is navigated to,
// a different origin from the parent frame, a temporary sub-frame object will
// first be created in the parent's renderer process. That temporary sub-frame
// will then be discarded after the real cross-origin sub-frame is created in
// the new/target renderer process. The client will receive cross-origin
// navigation callbacks (2) for the transition from the temporary sub-frame to
// the real sub-frame. The temporary sub-frame will not recieve or execute
// commands during this transitional period (any sent commands will be
// discarded).
//
// When a new popup browser is created in a different origin from the parent
// browser, a temporary main frame object for the popup will first be created in
// the parent's renderer process. That temporary main frame will then be
// discarded after the real cross-origin main frame is created in the new/target
// renderer process. The client will recieve creation and initial navigation
// callbacks (1) for the temporary main frame, followed by cross-origin
// navigation callbacks (2) for the transition from the temporary main frame to
// the real main frame. The temporary main frame may receive and execute
// commands during this transitional period (any sent commands may be executed,
// but the behavior is potentially undesirable since they execute in the parent
// browser's renderer process and not the new/target renderer process).
//
// Callbacks will not be executed for placeholders that may be created during
// pre-commit navigation for sub-frames that do not yet exist in the renderer
// process. Placeholders will have cef_frame_t::get_identifier() == -4.
//
// The functions of this structure will be called on the UI thread unless
// otherwise indicated.
///
typedef struct _cef_frame_handler_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called when a new frame is created. This will be the first notification
// that references |frame|. Any commands that require transport to the
// associated renderer process (LoadRequest, SendProcessMessage, GetSource,
// etc.) will be queued until OnFrameAttached is called for |frame|.
///
void(CEF_CALLBACK* on_frame_created)(struct _cef_frame_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame);
///
// Called when a frame can begin routing commands to/from the associated
// renderer process. Any commands that were queued have now been dispatched.
///
void(CEF_CALLBACK* on_frame_attached)(struct _cef_frame_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame);
///
// Called when a frame loses its connection to the renderer process and will
// be destroyed. Any pending or future commands will be discarded and
// cef_frame_t::is_valid() will now return false (0) for |frame|. If called
// after cef_life_span_handler_t::on_before_close() during browser destruction
// then cef_browser_t::is_valid() will return false (0) for |browser|.
///
void(CEF_CALLBACK* on_frame_detached)(struct _cef_frame_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame);
///
// Called when the main frame changes due to (a) initial browser creation, (b)
// final browser destruction, (c) cross-origin navigation or (d) re-navigation
// after renderer process termination (due to crashes, etc). |old_frame| will
// be NULL and |new_frame| will be non-NULL when a main frame is assigned to
// |browser| for the first time. |old_frame| will be non-NULL and |new_frame|
// will be NULL and when a main frame is removed from |browser| for the last
// time. Both |old_frame| and |new_frame| will be non-NULL for cross-origin
// navigations or re-navigation after renderer process termination. This
// function will be called after on_frame_created() for |new_frame| and/or
// after on_frame_detached() for |old_frame|. If called after
// cef_life_span_handler_t::on_before_close() during browser destruction then
// cef_browser_t::is_valid() will return false (0) for |browser|.
///
void(CEF_CALLBACK* on_main_frame_changed)(struct _cef_frame_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* old_frame,
struct _cef_frame_t* new_frame);
} cef_frame_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_FRAME_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=e44bb89a337942c82bfa246275b4b033821b2782$
// $hash=d7521ac4f73dabd876344400a165d15954c770b0$
//
#ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
@@ -101,10 +101,8 @@ typedef struct _cef_life_span_handler_t {
int* no_javascript_access);
///
// Called after a new browser is created. It is now safe to begin performing
// actions with |browser|. cef_frame_handler_t callbacks related to initial
// main frame creation will arrive before this callback. See
// cef_frame_handler_t documentation for additional usage information.
// Called after a new browser is created. This callback will be the first
// notification that references |browser|.
///
void(CEF_CALLBACK* on_after_created)(struct _cef_life_span_handler_t* self,
struct _cef_browser_t* browser);
@@ -204,14 +202,13 @@ typedef struct _cef_life_span_handler_t {
///
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any functions on the browser
// object (other than IsValid, GetIdentifier or IsSame) after this callback
// returns. cef_frame_handler_t callbacks related to final main frame
// destruction will arrive after this callback and cef_browser_t::IsValid will
// return false (0) at that time. Any in-progress network requests associated
// with |browser| will be aborted when the browser is destroyed, and
// object (other than GetIdentifier or IsSame) after this callback returns.
// This callback will be the last notification that references |browser| on
// the UI thread. Any in-progress network requests associated with |browser|
// will be aborted when the browser is destroyed, and
// cef_resource_request_handler_t callbacks related to those requests may
// still arrive on the IO thread after this callback. See cef_frame_handler_t
// and do_close() documentation for additional usage information.
// still arrive on the IO thread after this function is called. See do_close()
// documentation for additional usage information.
///
void(CEF_CALLBACK* on_before_close)(struct _cef_life_span_handler_t* self,
struct _cef_browser_t* browser);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=4ebf99611a11cc8714d710c37417fbd9f50f0618$
// $hash=41339414bca54054046a8f7fbce402a0e0dd8020$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_
@@ -73,7 +73,7 @@ typedef struct _cef_render_process_handler_t {
///
// Called after a browser has been created. When browsing cross-origin a new
// browser will be created before the old browser with the same identifier is
// destroyed. |extra_info| is an optional read-only value originating from
// destroyed. |extra_info| is a read-only value originating from
// cef_browser_host_t::cef_browser_host_create_browser(),
// cef_browser_host_t::cef_browser_host_create_browser_sync(),
// cef_life_span_handler_t::on_before_popup() or
@@ -150,8 +150,8 @@ typedef struct _cef_render_process_handler_t {
///
// Called when a new message is received from a different process. Return true
// (1) if the message was handled or false (0) otherwise. It is safe to keep a
// reference to |message| outside of this callback.
// (1) if the message was handled or false (0) otherwise. Do not keep a
// reference to or attempt to access the message outside of this callback.
///
int(CEF_CALLBACK* on_process_message_received)(
struct _cef_render_process_handler_t* self,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=f74bf4d33914d56d760f1bf5aadcf2651740c711$
// $hash=d8b5b641cc036a9cd9375442254d558b066ada69$
//
#ifndef CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_
@@ -214,7 +214,7 @@ CEF_EXPORT void cef_is_web_plugin_unstable(
// D. "x-cdm-interface-versions": Interface API version (e.g. "8").
// E. "x-cdm-host-versions": Host API version (e.g. "8").
// F. "version": CDM version (e.g. "1.4.8.903").
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp09,avc1").
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1").
//
// A through E are used to verify compatibility with the current Chromium
// version. If the CDM is not compatible the registration will fail and

View File

@@ -42,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 "7fb6a7510f39c359767b3a893c9ebfb5fb5973d7"
#define CEF_API_HASH_UNIVERSAL "d026196d35d8894a836ab3a3d033b84195cdb835"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "0a848e5b676ddc931dbb5b174a64eb7be7f7dfbf"
#define CEF_API_HASH_PLATFORM "4150bd26e7bf639a9b1f3e5860af8c76eeae8570"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "4c666fab20ab43dddf2f7ac6543197a1fecee389"
#define CEF_API_HASH_PLATFORM "5cc32f88bd134410eff86b21095138b339d572f2"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "5f756efd08c6e10629fe1f81e9266c7af71aa5ce"
#define CEF_API_HASH_PLATFORM "b227b3fdd6142a9d8ff0f2252a71425f15960800"
#endif
#ifdef __cplusplus

View File

@@ -52,21 +52,14 @@ class CefBrowserHost;
class CefClient;
///
// Class used to represent a browser. When used in the browser process the
// methods of this class may be called on any thread unless otherwise indicated
// in the comments. When used in the render process the methods of this class
// may only be called on the main thread.
// Class used to represent a browser window. When used in the browser process
// the methods of this class may be called on any thread unless otherwise
// indicated in the comments. When used in the render process the methods of
// this class may only be called on the main thread.
///
/*--cef(source=library)--*/
class CefBrowser : public virtual CefBaseRefCounted {
public:
///
// True if this object is currently valid. This will return false after
// CefLifeSpanHandler::OnBeforeClose is called.
///
/*--cef()--*/
virtual bool IsValid() = 0;
///
// Returns the browser host object. This method can only be called in the
// browser process.
@@ -137,7 +130,7 @@ class CefBrowser : public virtual CefBaseRefCounted {
virtual bool IsSame(CefRefPtr<CefBrowser> that) = 0;
///
// Returns true if the browser is a popup.
// Returns true if the window is a popup window.
///
/*--cef()--*/
virtual bool IsPopup() = 0;
@@ -149,19 +142,13 @@ class CefBrowser : public virtual CefBaseRefCounted {
virtual bool HasDocument() = 0;
///
// Returns the main (top-level) frame for the browser. In the browser process
// this will return a valid object until after
// CefLifeSpanHandler::OnBeforeClose is called. In the renderer process this
// will return NULL if the main frame is hosted in a different renderer
// process (e.g. for cross-origin sub-frames). The main frame object will
// change during cross-origin navigation or re-navigation after renderer
// process termination (due to crashes, etc).
// Returns the main (top-level) frame for the browser window.
///
/*--cef()--*/
virtual CefRefPtr<CefFrame> GetMainFrame() = 0;
///
// Returns the focused frame for the browser.
// Returns the focused frame for the browser window.
///
/*--cef()--*/
virtual CefRefPtr<CefFrame> GetFocusedFrame() = 0;
@@ -274,9 +261,10 @@ class CefDownloadImageCallback : public virtual CefBaseRefCounted {
};
///
// Class used to represent the browser process aspects of a browser. The methods
// of this class can only be called in the browser process. They may be called
// on any thread in that process unless otherwise indicated in the comments.
// Class used to represent the browser process aspects of a browser window. The
// methods of this class can only be called in the browser process. They may be
// called on any thread in that process unless otherwise indicated in the
// comments.
///
/*--cef(source=library)--*/
class CefBrowserHost : public virtual CefBaseRefCounted {
@@ -287,14 +275,14 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
typedef cef_paint_element_type_t PaintElementType;
///
// Create a new browser using the window parameters specified by |windowInfo|.
// All values will be copied internally and the actual window (if any) will be
// created on the UI thread. If |request_context| is empty the global request
// context will be used. This method can be called on any browser process
// thread and will not block. The optional |extra_info| parameter provides an
// opportunity to specify extra information specific to the created browser
// that will be passed to CefRenderProcessHandler::OnBrowserCreated() in the
// render process.
// Create a new browser window using the window parameters specified by
// |windowInfo|. All values will be copied internally and the actual window
// will be created on the UI thread. If |request_context| is empty the
// global request context will be used. This method can be called on any
// browser process thread and will not block. The optional |extra_info|
// parameter provides an opportunity to specify extra information specific
// to the created browser that will be passed to
// CefRenderProcessHandler::OnBrowserCreated() in the render process.
///
/*--cef(optional_param=client,optional_param=url,
optional_param=request_context,optional_param=extra_info)--*/
@@ -306,12 +294,13 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
CefRefPtr<CefRequestContext> request_context);
///
// Create a new browser using the window parameters specified by |windowInfo|.
// If |request_context| is empty the global request context will be used. This
// method can only be called on the browser process UI thread. The optional
// |extra_info| parameter provides an opportunity to specify extra information
// specific to the created browser that will be passed to
// CefRenderProcessHandler::OnBrowserCreated() in the render process.
// Create a new browser window using the window parameters specified by
// |windowInfo|. If |request_context| is empty the global request context
// will be used. This method can only be called on the browser process UI
// thread. The optional |extra_info| parameter provides an opportunity to
// specify extra information specific to the created browser that will be
// passed to CefRenderProcessHandler::OnBrowserCreated() in the render
// process.
///
/*--cef(optional_param=client,optional_param=url,
optional_param=request_context,optional_param=extra_info)--*/
@@ -344,9 +333,9 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
///
// Helper for closing a browser. Call this method from the top-level window
// close handler (if any). Internally this calls CloseBrowser(false) if the
// close has not yet been initiated. This method returns false while the close
// is pending and true after the close has completed. See CloseBrowser() and
// close handler. Internally this calls CloseBrowser(false) if the close has
// not yet been initiated. This method returns false while the close is
// pending and true after the close has completed. See CloseBrowser() and
// CefLifeSpanHandler::DoClose() documentation for additional usage
// information. This method must be called on the browser process UI thread.
///
@@ -360,19 +349,18 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
virtual void SetFocus(bool focus) = 0;
///
// Retrieve the window handle (if any) for this browser. If this browser is
// wrapped in a CefBrowserView this method should be called on the browser
// process UI thread and it will return the handle for the top-level native
// window.
// Retrieve the window handle for this browser. If this browser is wrapped in
// a CefBrowserView this method should be called on the browser process UI
// thread and it will return the handle for the top-level native window.
///
/*--cef()--*/
virtual CefWindowHandle GetWindowHandle() = 0;
///
// Retrieve the window handle (if any) of the browser that opened this
// browser. Will return NULL for non-popup browsers or if this browser is
// wrapped in a CefBrowserView. This method can be used in combination with
// custom handling of modal windows.
// Retrieve the window handle of the browser that opened this browser. Will
// return NULL for non-popup windows or if this browser is wrapped in a
// CefBrowserView. This method can be used in combination with custom handling
// of modal windows.
///
/*--cef()--*/
virtual CefWindowHandle GetOpenerWindowHandle() = 0;

View File

@@ -47,7 +47,6 @@
#include "include/cef_drag_handler.h"
#include "include/cef_find_handler.h"
#include "include/cef_focus_handler.h"
#include "include/cef_frame_handler.h"
#include "include/cef_jsdialog_handler.h"
#include "include/cef_keyboard_handler.h"
#include "include/cef_life_span_handler.h"
@@ -116,14 +115,6 @@ class CefClient : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() { return nullptr; }
///
// Return the handler for events related to CefFrame lifespan. This method
// will be called once during CefBrowser creation and the result will be
// cached for performance reasons.
///
/*--cef()--*/
virtual CefRefPtr<CefFrameHandler> GetFrameHandler() { return nullptr; }
///
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.
@@ -170,8 +161,8 @@ class CefClient : public virtual CefBaseRefCounted {
///
// Called when a new message is received from a different process. Return true
// if the message was handled or false otherwise. It is safe to keep a
// reference to |message| outside of this callback.
// if the message was handled or false otherwise. Do not keep a reference to
// or attempt to access the message outside of this callback.
///
/*--cef()--*/
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,

View File

@@ -246,12 +246,10 @@ class CefFrame : public virtual CefBaseRefCounted {
CefRefPtr<CefURLRequestClient> client) = 0;
///
// Send a message to the specified |target_process|. Ownership of the message
// contents will be transferred and the |message| reference will be
// invalidated. Message delivery is not guaranteed in all cases (for example,
// if the browser is closing, navigating, or if the target process crashes).
// Send an ACK message back from the target process if confirmation is
// required.
// Send a message to the specified |target_process|. Message delivery is not
// guaranteed in all cases (for example, if the browser is closing,
// navigating, or if the target process crashes). Send an ACK message back
// from the target process if confirmation is required.
///
/*--cef()--*/
virtual void SendProcessMessage(CefProcessId target_process,

View File

@@ -1,172 +0,0 @@
// Copyright (c) 2021 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_FRAME_HANDLER_H_
#define CEF_INCLUDE_CEF_FRAME_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "include/cef_frame.h"
///
// Implement this interface to handle events related to CefFrame life span. The
// order of callbacks is:
//
// (1) During initial CefBrowserHost creation and navigation of the main frame:
// - CefFrameHandler::OnFrameCreated => The initial main frame object has been
// created. Any commands will be queued until the frame is attached.
// - CefFrameHandler::OnMainFrameChanged => The initial main frame object has
// been assigned to the browser.
// - CefLifeSpanHandler::OnAfterCreated => The browser is now valid and can be
// used.
// - CefFrameHandler::OnFrameAttached => The initial main frame object is now
// connected to its peer in the renderer process. Commands can be routed.
//
// (2) During further CefBrowserHost navigation/loading of the main frame and/or
// sub-frames:
// - CefFrameHandler::OnFrameCreated => A new main frame or sub-frame object has
// been created. Any commands will be queued until the frame is attached.
// - CefFrameHandler::OnFrameAttached => A new main frame or sub-frame object is
// now connected to its peer in the renderer process. Commands can be routed.
// - CefFrameHandler::OnFrameDetached => An existing main frame or sub-frame
// object has lost its connection to the renderer process. If multiple objects
// are detached at the same time then notifications will be sent for any
// sub-frame objects before the main frame object. Commands can no longer be
// routed and will be discarded.
// - CefFrameHandler::OnMainFrameChanged => A new main frame object has been
// assigned to the browser. This will only occur with cross-origin navigation
// or re-navigation after renderer process termination (due to crashes, etc).
//
// (3) During final CefBrowserHost destruction of the main frame:
// - CefFrameHandler::OnFrameDetached => Any sub-frame objects have lost their
// connection to the renderer process. Commands can no longer be routed and
// will be discarded.
// - CefLifeSpanHandler::OnBeforeClose => The browser has been destroyed.
// - CefFrameHandler::OnFrameDetached => The main frame object have lost its
// connection to the renderer process. Notifications will be sent for any
// sub-frame objects before the main frame object. Commands can no longer be
// routed and will be discarded.
// - CefFrameHandler::OnMainFrameChanged => The final main frame object has been
// removed from the browser.
//
// Cross-origin navigation and/or loading receives special handling.
//
// When the main frame navigates to a different origin the OnMainFrameChanged
// callback (2) will be executed with the old and new main frame objects.
//
// When a new sub-frame is loaded in, or an existing sub-frame is navigated to,
// a different origin from the parent frame, a temporary sub-frame object will
// first be created in the parent's renderer process. That temporary sub-frame
// will then be discarded after the real cross-origin sub-frame is created in
// the new/target renderer process. The client will receive cross-origin
// navigation callbacks (2) for the transition from the temporary sub-frame to
// the real sub-frame. The temporary sub-frame will not recieve or execute
// commands during this transitional period (any sent commands will be
// discarded).
//
// When a new popup browser is created in a different origin from the parent
// browser, a temporary main frame object for the popup will first be created in
// the parent's renderer process. That temporary main frame will then be
// discarded after the real cross-origin main frame is created in the new/target
// renderer process. The client will recieve creation and initial navigation
// callbacks (1) for the temporary main frame, followed by cross-origin
// navigation callbacks (2) for the transition from the temporary main frame to
// the real main frame. The temporary main frame may receive and execute
// commands during this transitional period (any sent commands may be executed,
// but the behavior is potentially undesirable since they execute in the parent
// browser's renderer process and not the new/target renderer process).
//
// Callbacks will not be executed for placeholders that may be created during
// pre-commit navigation for sub-frames that do not yet exist in the renderer
// process. Placeholders will have CefFrame::GetIdentifier() == -4.
//
// The methods of this class will be called on the UI thread unless otherwise
// indicated.
///
/*--cef(source=client)--*/
class CefFrameHandler : public virtual CefBaseRefCounted {
public:
///
// Called when a new frame is created. This will be the first notification
// that references |frame|. Any commands that require transport to the
// associated renderer process (LoadRequest, SendProcessMessage, GetSource,
// etc.) will be queued until OnFrameAttached is called for |frame|.
///
/*--cef()--*/
virtual void OnFrameCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {}
///
// Called when a frame can begin routing commands to/from the associated
// renderer process. Any commands that were queued have now been dispatched.
///
/*--cef()--*/
virtual void OnFrameAttached(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {}
///
// Called when a frame loses its connection to the renderer process and will
// be destroyed. Any pending or future commands will be discarded and
// CefFrame::IsValid() will now return false for |frame|. If called after
// CefLifeSpanHandler::OnBeforeClose() during browser destruction then
// CefBrowser::IsValid() will return false for |browser|.
///
/*--cef()--*/
virtual void OnFrameDetached(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {}
///
// Called when the main frame changes due to (a) initial browser creation, (b)
// final browser destruction, (c) cross-origin navigation or (d) re-navigation
// after renderer process termination (due to crashes, etc). |old_frame| will
// be NULL and |new_frame| will be non-NULL when a main frame is assigned to
// |browser| for the first time. |old_frame| will be non-NULL and |new_frame|
// will be NULL and when a main frame is removed from |browser| for the last
// time. Both |old_frame| and |new_frame| will be non-NULL for cross-origin
// navigations or re-navigation after renderer process termination. This
// method will be called after OnFrameCreated() for |new_frame| and/or after
// OnFrameDetached() for |old_frame|. If called after
// CefLifeSpanHandler::OnBeforeClose() during browser destruction then
// CefBrowser::IsValid() will return false for |browser|.
///
/*--cef(optional_param=old_frame,optional_param=new_frame)--*/
virtual void OnMainFrameChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> old_frame,
CefRefPtr<CefFrame> new_frame) {}
};
#endif // CEF_INCLUDE_CEF_FRAME_HANDLER_H_

View File

@@ -95,10 +95,8 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
}
///
// Called after a new browser is created. It is now safe to begin performing
// actions with |browser|. CefFrameHandler callbacks related to initial main
// frame creation will arrive before this callback. See CefFrameHandler
// documentation for additional usage information.
// Called after a new browser is created. This callback will be the first
// notification that references |browser|.
///
/*--cef()--*/
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) {}
@@ -197,14 +195,13 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
///
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any methods on the browser
// object (other than IsValid, GetIdentifier or IsSame) after this callback
// returns. CefFrameHandler callbacks related to final main frame destruction
// will arrive after this callback and CefBrowser::IsValid will return false
// at that time. Any in-progress network requests associated with |browser|
// object (other than GetIdentifier or IsSame) after this callback returns.
// This callback will be the last notification that references |browser| on
// the UI thread. Any in-progress network requests associated with |browser|
// will be aborted when the browser is destroyed, and
// CefResourceRequestHandler callbacks related to those requests may still
// arrive on the IO thread after this callback. See CefFrameHandler and
// DoClose() documentation for additional usage information.
// arrive on the IO thread after this method is called. See DoClose()
// documentation for additional usage information.
///
/*--cef()--*/
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) {}

View File

@@ -66,11 +66,11 @@ class CefRenderProcessHandler : public virtual CefBaseRefCounted {
///
// Called after a browser has been created. When browsing cross-origin a new
// browser will be created before the old browser with the same identifier is
// destroyed. |extra_info| is an optional read-only value originating from
// destroyed. |extra_info| is a read-only value originating from
// CefBrowserHost::CreateBrowser(), CefBrowserHost::CreateBrowserSync(),
// CefLifeSpanHandler::OnBeforePopup() or CefBrowserView::CreateBrowserView().
///
/*--cef(optional_param=extra_info)--*/
/*--cef()--*/
virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDictionaryValue> extra_info) {}
@@ -134,8 +134,8 @@ class CefRenderProcessHandler : public virtual CefBaseRefCounted {
///
// Called when a new message is received from a different process. Return true
// if the message was handled or false otherwise. It is safe to keep a
// reference to |message| outside of this callback.
// if the message was handled or false otherwise. Do not keep a reference to
// or attempt to access the message outside of this callback.
///
/*--cef()--*/
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,

View File

@@ -191,7 +191,7 @@ class CefRegisterCdmCallback : public virtual CefBaseRefCounted {
// D. "x-cdm-interface-versions": Interface API version (e.g. "8").
// E. "x-cdm-host-versions": Host API version (e.g. "8").
// F. "version": CDM version (e.g. "1.4.8.903").
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp09,avc1").
// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1").
//
// A through E are used to verify compatibility with the current Chromium
// version. If the CDM is not compatible the registration will fail and

View File

@@ -34,6 +34,7 @@
#include <memory.h>
#include <string>
#include "include/base/cef_string16.h"
#include "include/internal/cef_string_types.h"
#if defined(USING_CHROMIUM_INCLUDES)
@@ -79,63 +80,45 @@ struct CefStringTraitsWide {
cef_string_utf8_clear(&cstr);
return str;
}
static inline bool from_string(const std::string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf8_to_wide(data, length, s) ? true : false;
}
static inline bool from_string(const std::string& str, struct_type* s) {
return from_string(str.data(), str.length(), s);
return cef_string_utf8_to_wide(str.c_str(), str.length(), s) ? true : false;
}
static inline std::wstring to_wstring(const struct_type* s) {
return std::wstring(s->str, s->length);
}
static inline bool from_wstring(const std::wstring::value_type* data,
size_t length,
struct_type* s) {
return cef_string_wide_set(data, length, s, true) ? true : false;
}
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return from_wstring(str.data(), str.length(), s);
return cef_string_wide_set(str.c_str(), str.length(), s, true) ? true
: false;
}
#if defined(WCHAR_T_IS_UTF32)
static inline std::u16string to_string16(const struct_type* s) {
static inline base::string16 to_string16(const struct_type* s) {
cef_string_utf16_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_wide_to_utf16(s->str, s->length, &cstr);
std::u16string str;
base::string16 str;
if (cstr.length > 0) {
str = std::u16string(
reinterpret_cast<std::u16string::value_type*>(cstr.str), cstr.length);
str = base::string16(
reinterpret_cast<base::string16::value_type*>(cstr.str), cstr.length);
}
cef_string_utf16_clear(&cstr);
return str;
}
static inline bool from_string16(const std::u16string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf16_to_wide(reinterpret_cast<const char16*>(data),
length, s)
static inline bool from_string16(const base::string16& str, struct_type* s) {
return cef_string_utf16_to_wide(
reinterpret_cast<const char16*>(str.c_str()), str.length(), s)
? true
: false;
}
#else // WCHAR_T_IS_UTF32
static inline std::u16string to_string16(const struct_type* s) {
return std::u16string(
reinterpret_cast<const std::u16string::value_type*>(s->str), s->length);
static inline base::string16 to_string16(const struct_type* s) {
return base::string16(
reinterpret_cast<const base::string16::value_type*>(s->str), s->length);
}
static inline bool from_string16(const std::u16string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_wide_set(reinterpret_cast<const wchar_t*>(data), length,
s, true)
? true
: false;
static inline bool from_string16(const base::string16& str, struct_type* s) {
return cef_string_wide_set(str.c_str(), str.length(), s, true) ? true
: false;
}
#endif // WCHAR_T_IS_UTF32
static inline bool from_string16(const std::u16string& str, struct_type* s) {
return from_string16(str.data(), str.length(), s);
}
};
///
@@ -170,13 +153,8 @@ struct CefStringTraitsUTF8 {
static inline std::string to_string(const struct_type* s) {
return std::string(s->str, s->length);
}
static inline bool from_string(const std::string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf8_copy(data, length, s) ? true : false;
}
static inline bool from_string(const std::string& str, struct_type* s) {
return from_string(str.c_str(), str.length(), s);
return cef_string_utf8_copy(str.c_str(), str.length(), s) ? true : false;
}
static inline std::wstring to_wstring(const struct_type* s) {
cef_string_wide_t cstr;
@@ -188,37 +166,27 @@ struct CefStringTraitsUTF8 {
cef_string_wide_clear(&cstr);
return str;
}
static inline bool from_wstring(const std::wstring::value_type* data,
size_t length,
struct_type* s) {
return cef_string_wide_to_utf8(data, length, s) ? true : false;
}
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return from_wstring(str.data(), str.length(), s);
return cef_string_wide_to_utf8(str.c_str(), str.length(), s) ? true : false;
}
static inline std::u16string to_string16(const struct_type* s) {
static inline base::string16 to_string16(const struct_type* s) {
cef_string_utf16_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_utf8_to_utf16(s->str, s->length, &cstr);
std::u16string str;
base::string16 str;
if (cstr.length > 0) {
str = std::u16string(
reinterpret_cast<std::u16string::value_type*>(cstr.str), cstr.length);
str = base::string16(
reinterpret_cast<base::string16::value_type*>(cstr.str), cstr.length);
}
cef_string_utf16_clear(&cstr);
return str;
}
static inline bool from_string16(const std::u16string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf16_to_utf8(reinterpret_cast<const char16*>(data),
length, s)
static inline bool from_string16(const base::string16& str, struct_type* s) {
return cef_string_utf16_to_utf8(
reinterpret_cast<const char16*>(str.c_str()), str.length(), s)
? true
: false;
}
static inline bool from_string16(const std::u16string& str, struct_type* s) {
return from_string16(str.data(), str.length(), s);
}
};
///
@@ -260,13 +228,9 @@ struct CefStringTraitsUTF16 {
cef_string_utf8_clear(&cstr);
return str;
}
static inline bool from_string(const std::string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf8_to_utf16(data, length, s) ? true : false;
}
static inline bool from_string(const std::string& str, struct_type* s) {
return from_string(str.data(), str.length(), s);
return cef_string_utf8_to_utf16(str.c_str(), str.length(), s) ? true
: false;
}
#if defined(WCHAR_T_IS_UTF32)
static inline std::wstring to_wstring(const struct_type* s) {
@@ -279,39 +243,29 @@ struct CefStringTraitsUTF16 {
cef_string_wide_clear(&cstr);
return str;
}
static inline bool from_wstring(const std::wstring::value_type* data,
size_t length,
struct_type* s) {
return cef_string_wide_to_utf16(data, length, s) ? true : false;
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ? true
: false;
}
#else // WCHAR_T_IS_UTF32
static inline std::wstring to_wstring(const struct_type* s) {
return std::wstring(s->str, s->length);
}
static inline bool from_wstring(const std::wstring::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf16_set(data, length, s, true) ? true : false;
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? true
: false;
}
#endif // WCHAR_T_IS_UTF32
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return from_wstring(str.data(), str.length(), s);
static inline base::string16 to_string16(const struct_type* s) {
return base::string16(
reinterpret_cast<const base::string16::value_type*>(s->str), s->length);
}
static inline std::u16string to_string16(const struct_type* s) {
return std::u16string(
reinterpret_cast<const std::u16string::value_type*>(s->str), s->length);
}
static inline bool from_string16(const std::u16string::value_type* data,
size_t length,
struct_type* s) {
return cef_string_utf16_set(reinterpret_cast<const char16*>(data), length,
s, true)
static inline bool from_string16(const base::string16& str, struct_type* s) {
return cef_string_utf16_set(reinterpret_cast<const char16*>(str.c_str()),
str.length(), s, true)
? true
: false;
}
static inline bool from_string16(const std::u16string& str, struct_type* s) {
return from_string16(str.data(), str.length(), s);
}
};
///
@@ -369,10 +323,9 @@ class CefStringBase {
CefStringBase(const std::string& src) : string_(NULL), owner_(false) {
FromString(src);
}
CefStringBase(const char* src, size_t length = 0)
: string_(NULL), owner_(false) {
CefStringBase(const char* src) : string_(NULL), owner_(false) {
if (src)
FromString(src, length);
FromString(std::string(src));
}
///
@@ -383,32 +336,24 @@ class CefStringBase {
CefStringBase(const std::wstring& src) : string_(NULL), owner_(false) {
FromWString(src);
}
CefStringBase(const wchar_t* src, size_t length = 0)
: string_(NULL), owner_(false) {
CefStringBase(const wchar_t* src) : string_(NULL), owner_(false) {
if (src)
FromWString(src, length);
FromWString(std::wstring(src));
}
#if defined(WCHAR_T_IS_UTF32)
///
// Create a new string from an existing string16. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
CefStringBase(const std::u16string& src) : string_(NULL), owner_(false) {
CefStringBase(const base::string16& src) : string_(NULL), owner_(false) {
FromString16(src);
}
CefStringBase(const std::u16string::value_type* src, size_t length = 0)
: string_(NULL), owner_(false) {
CefStringBase(const char16* src) : string_(NULL), owner_(false) {
if (src)
FromString16(src, length);
}
#if defined(WCHAR_T_IS_UTF32)
CefStringBase(const char16* src, size_t length = 0)
: string_(NULL), owner_(false) {
if (src) {
FromString16(reinterpret_cast<const std::u16string::value_type*>(src),
length);
}
FromString16(base::string16(
reinterpret_cast<const base::string16::value_type*>(src)));
}
#endif // WCHAR_T_IS_UTF32
@@ -647,23 +592,6 @@ class CefStringBase {
return traits::from_string(str, string_);
}
///
// Set this string's data from existing |data| and optional |length|. Data
// will be always copied. Translation will occur if necessary based on the
// underlying string type.
///
bool FromString(const std::string::value_type* data, size_t length = 0) {
if (data && length == 0) {
length = std::char_traits<std::string::value_type>::length(data);
}
if (!data || length == 0) {
clear();
return true;
}
AllocIfNeeded();
return traits::from_string(data, length, string_);
}
///
// Return this string's data as a std::wstring. Translation will occur if
// necessary based on the underlying string type.
@@ -688,29 +616,13 @@ class CefStringBase {
return traits::from_wstring(str, string_);
}
///
// Set this string's data from existing |data| and optional |length|. Data
// will be always copied. Translation will occur if necessary based on the
// underlying string type.
///
bool FromWString(const std::wstring::value_type* data, size_t length = 0) {
if (data && length == 0) {
length = std::char_traits<std::wstring::value_type>::length(data);
}
if (!data || length == 0) {
clear();
return true;
}
AllocIfNeeded();
return traits::from_wstring(data, length, string_);
}
///
// Return this string's data as a string16. Translation will occur if
// necessary based on the underlying string type.
///
std::u16string ToString16() const {
base::string16 ToString16() const {
if (empty())
return std::u16string();
return base::string16();
return traits::to_string16(string_);
}
@@ -719,7 +631,7 @@ class CefStringBase {
// copied. Translation will occur if necessary based on the underlying string
// type.
///
bool FromString16(const std::u16string& str) {
bool FromString16(const base::string16& str) {
if (str.empty()) {
clear();
return true;
@@ -728,23 +640,6 @@ class CefStringBase {
return traits::from_string16(str, string_);
}
///
// Set this string's data from existing |data| and optional |length|. Data
// will be always copied. Translation will occur if necessary based on the
// underlying string type.
///
bool FromString16(const std::u16string::value_type* data, size_t length = 0) {
if (data && length == 0) {
length = std::char_traits<std::u16string::value_type>::length(data);
}
if (!data || length == 0) {
clear();
return true;
}
AllocIfNeeded();
return traits::from_string16(data, length, string_);
}
///
// Comparison operator overloads.
///
@@ -775,8 +670,8 @@ class CefStringBase {
FromString(str);
return *this;
}
CefStringBase& operator=(const std::string::value_type* str) {
FromString(str);
CefStringBase& operator=(const char* str) {
FromString(std::string(str));
return *this;
}
operator std::wstring() const { return ToWString(); }
@@ -784,22 +679,19 @@ class CefStringBase {
FromWString(str);
return *this;
}
CefStringBase& operator=(const std::wstring::value_type* str) {
FromWString(str);
return *this;
}
operator std::u16string() const { return ToString16(); }
CefStringBase& operator=(const std::u16string& str) {
FromString16(str);
return *this;
}
CefStringBase& operator=(const std::u16string::value_type* str) {
FromString16(str);
CefStringBase& operator=(const wchar_t* str) {
FromWString(std::wstring(str));
return *this;
}
#if defined(WCHAR_T_IS_UTF32)
operator base::string16() const { return ToString16(); }
CefStringBase& operator=(const base::string16& str) {
FromString16(str);
return *this;
}
CefStringBase& operator=(const char16* str) {
FromString16(reinterpret_cast<const std::u16string::value_type*>(str));
FromString16(base::string16(
reinterpret_cast<const base::string16::value_type*>(str)));
return *this;
}
#endif // WCHAR_T_IS_UTF32

View File

@@ -1458,6 +1458,7 @@ typedef enum {
// CefShutdown() are guaranteed to run.
///
TID_FILE_BACKGROUND,
TID_FILE = TID_FILE_BACKGROUND,
///
// Used for blocking tasks (e.g. file system access) that affect UI or

View File

@@ -151,9 +151,10 @@ class CefPoint : public CefStructBase<CefPointTraits> {
public:
typedef CefStructBase<CefPointTraits> parent;
CefPoint() {}
CefPoint() : parent() {}
CefPoint(const cef_point_t& r) : parent(r) {}
CefPoint(int x, int y) { Set(x, y); }
CefPoint(const CefPoint& r) : parent(r) {}
CefPoint(int x, int y) : parent() { Set(x, y); }
bool IsEmpty() const { return x <= 0 && y <= 0; }
void Set(int x_val, int y_val) { x = x_val, y = y_val; }
@@ -187,9 +188,12 @@ class CefRect : public CefStructBase<CefRectTraits> {
public:
typedef CefStructBase<CefRectTraits> parent;
CefRect() {}
CefRect() : parent() {}
CefRect(const cef_rect_t& r) : parent(r) {}
CefRect(int x, int y, int width, int height) { Set(x, y, width, height); }
CefRect(const CefRect& r) : parent(r) {}
CefRect(int x, int y, int width, int height) : parent() {
Set(x, y, width, height);
}
bool IsEmpty() const { return width <= 0 || height <= 0; }
void Set(int x_val, int y_val, int width_val, int height_val) {
@@ -236,9 +240,10 @@ class CefSize : public CefStructBase<CefSizeTraits> {
public:
typedef CefStructBase<CefSizeTraits> parent;
CefSize() {}
CefSize() : parent() {}
CefSize(const cef_size_t& r) : parent(r) {}
CefSize(int width, int height) { Set(width, height); }
CefSize(const CefSize& r) : parent(r) {}
CefSize(int width, int height) : parent() { Set(width, height); }
bool IsEmpty() const { return width <= 0 || height <= 0; }
void Set(int width_val, int height_val) {
@@ -274,9 +279,10 @@ class CefRange : public CefStructBase<CefRangeTraits> {
public:
typedef CefStructBase<CefRangeTraits> parent;
CefRange() {}
CefRange() : parent() {}
CefRange(const cef_range_t& r) : parent(r) {}
CefRange(int from, int to) { Set(from, to); }
CefRange(const CefRange& r) : parent(r) {}
CefRange(int from, int to) : parent() { Set(from, to); }
void Set(int from_val, int to_val) { from = from_val, to = to_val; }
};
@@ -309,9 +315,10 @@ class CefInsets : public CefStructBase<CefInsetsTraits> {
public:
typedef CefStructBase<CefInsetsTraits> parent;
CefInsets() {}
CefInsets() : parent() {}
CefInsets(const cef_insets_t& r) : parent(r) {}
CefInsets(int top, int left, int bottom, int right) {
CefInsets(const CefInsets& r) : parent(r) {}
CefInsets(int top, int left, int bottom, int right) : parent() {
Set(top, left, bottom, right);
}
@@ -349,9 +356,10 @@ class CefDraggableRegion : public CefStructBase<CefDraggableRegionTraits> {
public:
typedef CefStructBase<CefDraggableRegionTraits> parent;
CefDraggableRegion() {}
CefDraggableRegion() : parent() {}
CefDraggableRegion(const cef_draggable_region_t& r) : parent(r) {}
CefDraggableRegion(const CefRect& bounds, bool draggable) {
CefDraggableRegion(const CefDraggableRegion& r) : parent(r) {}
CefDraggableRegion(const CefRect& bounds, bool draggable) : parent() {
Set(bounds, draggable);
}
@@ -397,14 +405,16 @@ class CefScreenInfo : public CefStructBase<CefScreenInfoTraits> {
public:
typedef CefStructBase<CefScreenInfoTraits> parent;
CefScreenInfo() {}
CefScreenInfo() : parent() {}
CefScreenInfo(const cef_screen_info_t& r) : parent(r) {}
CefScreenInfo(const CefScreenInfo& r) : parent(r) {}
CefScreenInfo(float device_scale_factor,
int depth,
int depth_per_component,
bool is_monochrome,
const CefRect& rect,
const CefRect& available_rect) {
const CefRect& available_rect)
: parent() {
Set(device_scale_factor, depth, depth_per_component, is_monochrome, rect,
available_rect);
}
@@ -796,10 +806,11 @@ class CefTime : public CefStructBase<CefTimeTraits> {
public:
typedef CefStructBase<CefTimeTraits> parent;
CefTime() {}
CefTime() : parent() {}
CefTime(const cef_time_t& r) : parent(r) {}
explicit CefTime(time_t r) { SetTimeT(r); }
explicit CefTime(double r) { SetDoubleT(r); }
CefTime(const CefTime& r) : parent(r) {}
explicit CefTime(time_t r) : parent() { SetTimeT(r); }
explicit CefTime(double r) : parent() { SetDoubleT(r); }
// Converts to/from time_t.
void SetTimeT(time_t r) { cef_time_from_timet(r, this); }

View File

@@ -48,12 +48,7 @@
#define CEF_REQUIRE_UI_THREAD() DCHECK(CefCurrentlyOn(TID_UI));
#define CEF_REQUIRE_IO_THREAD() DCHECK(CefCurrentlyOn(TID_IO));
#define CEF_REQUIRE_FILE_BACKGROUND_THREAD() \
DCHECK(CefCurrentlyOn(TID_FILE_BACKGROUND));
#define CEF_REQUIRE_FILE_USER_VISIBLE_THREAD() \
DCHECK(CefCurrentlyOn(TID_FILE_USER_VISIBLE));
#define CEF_REQUIRE_FILE_USER_BLOCKING_THREAD() \
DCHECK(CefCurrentlyOn(TID_FILE_USER_BLOCKING));
#define CEF_REQUIRE_FILE_THREAD() DCHECK(CefCurrentlyOn(TID_FILE));
#define CEF_REQUIRE_RENDERER_THREAD() DCHECK(CefCurrentlyOn(TID_RENDERER));
// Use this struct in conjuction with refcounted types to ensure that an
@@ -91,12 +86,7 @@ struct CefDeleteOnThread {
struct CefDeleteOnUIThread : public CefDeleteOnThread<TID_UI> {};
struct CefDeleteOnIOThread : public CefDeleteOnThread<TID_IO> {};
struct CefDeleteOnFileBackgroundThread
: public CefDeleteOnThread<TID_FILE_BACKGROUND> {};
struct CefDeleteOnFileUserVisibleThread
: public CefDeleteOnThread<TID_FILE_USER_VISIBLE> {};
struct CefDeleteOnFileUserBlockingThread
: public CefDeleteOnThread<TID_FILE_USER_BLOCKING> {};
struct CefDeleteOnFileThread : public CefDeleteOnThread<TID_FILE> {};
struct CefDeleteOnRendererThread : public CefDeleteOnThread<TID_RENDERER> {};
// Same as IMPLEMENT_REFCOUNTING() but using the specified Destructor.
@@ -124,6 +114,7 @@ struct CefDeleteOnRendererThread : public CefDeleteOnThread<TID_RENDERER> {};
#define IMPLEMENT_REFCOUNTING_DELETE_ON_IOT(ClassName) \
IMPLEMENT_REFCOUNTING_EX(ClassName, CefDeleteOnIOThread)
///
// Helper class to manage a scoped copy of |argv|.
///

View File

@@ -46,7 +46,7 @@
// The below classes implement support for routing aynchronous messages between
// JavaScript running in the renderer process and C++ running in the browser
// process. An application interacts with the router by passing it data from
// standard CEF C++ callbacks (OnBeforeBrowse, OnProcessMessageReceived,
// standard CEF C++ callbacks (OnBeforeBrowse, OnProcessMessageRecieved,
// OnContextCreated, etc). The renderer-side router supports generic JavaScript
// callback registration and execution while the browser-side router supports
// application-specific logic via one or more application-provided Handler

View File

@@ -309,14 +309,25 @@ AlloyBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;
}
void AlloyBrowserContext::SetCorsOriginAccessListForOrigin(
TargetBrowserContexts target_mode,
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) {
// This method is called for Extension support.
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, std::move(closure));
}
ChromeZoomLevelPrefs* AlloyBrowserContext::GetZoomLevelPrefs() {
return static_cast<ChromeZoomLevelPrefs*>(
GetStoragePartition(nullptr)->GetZoomLevelDelegate());
GetStoragePartition(this, nullptr)->GetZoomLevelDelegate());
}
scoped_refptr<network::SharedURLLoaderFactory>
AlloyBrowserContext::GetURLLoaderFactory() {
return GetDefaultStoragePartition()->GetURLLoaderFactoryForBrowserProcess();
return GetDefaultStoragePartition(this)
->GetURLLoaderFactoryForBrowserProcess();
}
base::FilePath AlloyBrowserContext::GetPath() {
@@ -338,11 +349,18 @@ AlloyBrowserContext::CreateZoomLevelDelegate(
zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
}
bool AlloyBrowserContext::IsOffTheRecord() const {
// Alloy contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false;
}
content::DownloadManagerDelegate*
AlloyBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_) {
download_manager_delegate_.reset(
new CefDownloadManagerDelegate(GetDownloadManager()));
content::DownloadManager* manager =
BrowserContext::GetDownloadManager(this);
download_manager_delegate_.reset(new CefDownloadManagerDelegate(manager));
}
return download_manager_delegate_.get();
}

View File

@@ -60,10 +60,17 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
content::ResourceContext* GetResourceContext() override;
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
void SetCorsOriginAccessListForOrigin(
TargetBrowserContexts target_mode,
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) override;
base::FilePath GetPath() override;
base::FilePath GetPath() const override;
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath& partition_path) override;
bool IsOffTheRecord() const override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;

View File

@@ -21,6 +21,7 @@
#include "libcef/browser/osr/osr_util.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/drag_data_impl.h"
#include "libcef/common/net/url_util.h"
@@ -639,7 +640,7 @@ void AlloyBrowserHostImpl::SendExternalBeginFrame() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&AlloyBrowserHostImpl::SendExternalBeginFrame, this));
base::Bind(&AlloyBrowserHostImpl::SendExternalBeginFrame, this));
return;
}
@@ -654,8 +655,8 @@ void AlloyBrowserHostImpl::SendTouchEvent(const CefTouchEvent& event) {
}
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SendTouchEvent,
this, event));
CEF_POST_TASK(CEF_UIT, base::Bind(&AlloyBrowserHostImpl::SendTouchEvent,
this, event));
return;
}
@@ -800,10 +801,10 @@ bool AlloyBrowserHostImpl::MaybeAllowNavigation(
// The PDF viewer will load the PDF extension in the guest view, and print
// preview will load chrome://print in the guest view. All other navigations
// are passed to the owner browser.
CEF_POST_TASK(CEF_UIT,
base::BindOnce(
base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
this, nullptr, params));
CEF_POST_TASK(
CEF_UIT,
base::Bind(base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
this, nullptr, params));
return false;
}
@@ -1077,8 +1078,8 @@ void AlloyBrowserHostImpl::DragSourceEndedAt(
void AlloyBrowserHostImpl::SetAudioMuted(bool mute) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SetAudioMuted,
this, mute));
CEF_POST_TASK(CEF_UIT,
base::Bind(&AlloyBrowserHostImpl::SetAudioMuted, this, mute));
return;
}
if (!web_contents())
@@ -1190,9 +1191,9 @@ void AlloyBrowserHostImpl::UpdateTargetURL(content::WebContents* source,
bool AlloyBrowserHostImpl::DidAddMessageToConsole(
content::WebContents* source,
blink::mojom::ConsoleMessageLevel level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) {
const base::string16& source_id) {
return contents_delegate_->DidAddMessageToConsole(source, level, message,
line_no, source_id);
}

View File

@@ -22,11 +22,12 @@
#include "libcef/browser/menu_manager.h"
#include "libcef/browser/request_context_impl.h"
#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "extensions/common/mojom/view_type.mojom-forward.h"
#include "extensions/common/view_type.h"
class CefAudioCapturer;
class CefBrowserInfo;
@@ -221,9 +222,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
bool DidAddMessageToConsole(content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) override;
const base::string16& source_id) override;
void BeforeUnloadFired(content::WebContents* source,
bool proceed,
bool* proceed_to_fire_unload) override;

View File

@@ -25,7 +25,6 @@
#include "base/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/media/router/chrome_media_router_factory.h"
#include "chrome/browser/net/system_network_context_manager.h"
@@ -109,7 +108,7 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
#endif // defined(TOOLKIT_VIEWS)
}
void AlloyBrowserMainParts::PreCreateMainMessageLoop() {
void AlloyBrowserMainParts::PreMainMessageLoopStart() {
#if defined(USE_AURA) && defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif
@@ -129,7 +128,7 @@ void AlloyBrowserMainParts::PreCreateMainMessageLoop() {
media_router::ChromeMediaRouterFactory::DoPlatformInit();
}
void AlloyBrowserMainParts::PostCreateMainMessageLoop() {
void AlloyBrowserMainParts::PostMainMessageLoopStart() {
#if defined(OS_LINUX)
printing::PrintingContextLinux::SetCreatePrintDialogFunction(
&CefPrintDialogLinux::CreatePrintDialog);
@@ -153,10 +152,9 @@ int AlloyBrowserMainParts::PreCreateThreads() {
return 0;
}
int AlloyBrowserMainParts::PreMainMessageLoopRun() {
void AlloyBrowserMainParts::PreMainMessageLoopRun() {
#if defined(USE_AURA)
screen_ = views::CreateDesktopScreen();
display::Screen::SetScreenInstance(screen_.get());
display::Screen::SetScreenInstance(views::CreateDesktopScreen());
#endif
if (extensions::ExtensionsEnabled()) {
@@ -175,14 +173,14 @@ int AlloyBrowserMainParts::PreMainMessageLoopRun() {
// ChromeBrowserMainExtraPartsProfiles for details.
cef::EnsureBrowserContextKeyedServiceFactoriesBuilt();
background_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::BEST_EFFORT,
background_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_visible_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::USER_VISIBLE,
user_visible_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_blocking_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::USER_BLOCKING,
user_blocking_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
CefRequestContextSettings settings;
@@ -206,8 +204,6 @@ int AlloyBrowserMainParts::PreMainMessageLoopRun() {
PluginFinder::GetInstance()->Init();
scheme::RegisterWebUIControllerFactory();
return content::RESULT_CODE_NORMAL_EXIT;
}
void AlloyBrowserMainParts::PostMainMessageLoopRun() {

View File

@@ -24,9 +24,6 @@ class ExtensionsClient;
} // namespace extensions
#if defined(USE_AURA)
namespace display {
class Screen;
}
namespace wm {
class WMState;
}
@@ -50,10 +47,10 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
int PreEarlyInitialization() override;
void ToolkitInitialized() override;
void PreCreateMainMessageLoop() override;
void PostCreateMainMessageLoop() override;
void PreMainMessageLoopStart() override;
void PostMainMessageLoopStart() override;
int PreCreateThreads() override;
int PreMainMessageLoopRun() override;
void PreMainMessageLoopRun() override;
void PostMainMessageLoopRun() override;
void PostDestroyThreads() override;
@@ -94,7 +91,6 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner_;
#if defined(USE_AURA)
std::unique_ptr<display::Screen> screen_;
std::unique_ptr<wm::WMState> wm_state_;
#endif

View File

@@ -12,10 +12,9 @@
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/alloy/alloy_browser_main.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_frame.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_manager.h"
#include "libcef/browser/browser_message_filter.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
@@ -36,6 +35,7 @@
#include "libcef/browser/x509_certificate_impl.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/command_line_impl.h"
#include "libcef/common/extensions/extensions_util.h"
@@ -98,7 +98,6 @@
#include "content/public/common/storage_quota_params.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/user_agent.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_message_filter.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/extension_registry.h"
@@ -239,10 +238,9 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
RunNow(std::move(callback_), allow);
}
} else {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefAllowCertificateErrorCallbackImpl::Continue, this,
allow));
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefAllowCertificateErrorCallbackImpl::Continue,
this, allow));
}
}
@@ -255,7 +253,7 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
CEF_REQUIRE_UIT();
std::move(callback).Run(
allow ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE
: content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
: content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
}
CallbackType callback_;
@@ -504,6 +502,8 @@ void AlloyContentBrowserClient::RenderProcessWillLaunch(
const int id = host->GetID();
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
host->AddFilter(new CefBrowserMessageFilter(id));
if (extensions::ExtensionsEnabled()) {
host->AddFilter(new extensions::ExtensionMessageFilter(id, profile));
host->AddFilter(
@@ -782,7 +782,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
CefRefPtr<CefCommandLineImpl> commandLinePtr(
new CefCommandLineImpl(command_line, false, false));
handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
ignore_result(commandLinePtr->Detach(nullptr));
commandLinePtr->Detach(nullptr);
}
}
}
@@ -855,7 +855,7 @@ void AlloyContentBrowserClient::AllowCertificateError(
// A sub-resource has a certificate error. The user doesn't really
// have a context for making the right decision, so block the request
// hard.
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
return;
}
@@ -882,7 +882,7 @@ void AlloyContentBrowserClient::AllowCertificateError(
// |callback| may be null if the user executed it despite returning false.
callback = callbackImpl->Disconnect();
if (!callback.is_null()) {
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
}
}
}
@@ -988,9 +988,9 @@ void AlloyContentBrowserClient::DidCreatePpapiPlugin(
new ChromeBrowserPepperHostFactory(browser_host)));
}
std::unique_ptr<content::DevToolsManagerDelegate>
AlloyContentBrowserClient::CreateDevToolsManagerDelegate() {
return std::make_unique<CefDevToolsManagerDelegate>();
content::DevToolsManagerDelegate*
AlloyContentBrowserClient::GetDevToolsManagerDelegate() {
return new CefDevToolsManagerDelegate();
}
std::vector<std::unique_ptr<content::NavigationThrottle>>
@@ -1044,14 +1044,6 @@ void AlloyContentBrowserClient::ExposeInterfacesToRenderer(
content::RenderProcessHost* host) {
associated_registry->AddInterface(
base::BindRepeating(&BindPluginInfoHost, host->GetID()));
if (extensions::ExtensionsEnabled()) {
associated_registry->AddInterface(base::BindRepeating(
&extensions::EventRouter::BindForRenderer, host->GetID()));
}
CefBrowserManager::ExposeInterfacesToRenderer(registry, associated_registry,
host);
}
std::unique_ptr<net::ClientCertStore>
@@ -1159,7 +1151,7 @@ bool AlloyContentBrowserClient::WillCreateURLLoaderFactory(
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
base::Optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -1252,12 +1244,11 @@ bool AlloyContentBrowserClient::HandleExternalProtocol(
const GURL& url,
content::WebContents::OnceGetter web_contents_getter,
int child_id,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
// Call the other HandleExternalProtocol variant.
return false;
@@ -1276,8 +1267,8 @@ bool AlloyContentBrowserClient::HandleExternalProtocol(
// nothing handles the request.
auto request_handler = net_service::CreateInterceptedRequestHandler(
web_contents_getter, frame_tree_node_id, resource_request,
base::BindRepeating(CefBrowserPlatformDelegate::HandleExternalProtocol,
resource_request.url));
base::Bind(CefBrowserPlatformDelegate::HandleExternalProtocol,
resource_request.url));
net_service::ProxyURLLoaderFactory::CreateProxy(
web_contents_getter, std::move(receiver), std::move(request_handler));
@@ -1300,8 +1291,6 @@ void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) {
PopulateChromeFrameBinders(map);
CefBrowserFrame::RegisterBrowserInterfaceBindersForFrame(render_frame_host,
map);
if (!extensions::ExtensionsEnabled())
return;
@@ -1373,7 +1362,7 @@ bool AlloyContentBrowserClient::ArePersistentMediaDeviceIDsAllowed(
content::BrowserContext* browser_context,
const GURL& url,
const GURL& site_for_cookies,
const absl::optional<url::Origin>& top_frame_origin) {
const base::Optional<url::Origin>& top_frame_origin) {
// Persistent MediaDevice IDs are allowed if cookies are allowed.
return CookieSettingsFactory::GetForProfile(
Profile::FromBrowserContext(browser_context))

View File

@@ -109,8 +109,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
std::string GetDefaultDownloadName() override;
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
std::unique_ptr<content::DevToolsManagerDelegate>
CreateDevToolsManagerDelegate() override;
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
std::vector<std::unique_ptr<content::NavigationThrottle>>
CreateThrottlesForNavigation(
content::NavigationHandle* navigation_handle) override;
@@ -158,7 +157,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
base::Optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -180,12 +179,11 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
const GURL& url,
content::WebContents::OnceGetter web_contents_getter,
int child_id,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
bool HandleExternalProtocol(
@@ -211,7 +209,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
content::BrowserContext* browser_context,
const GURL& scope,
const GURL& site_for_cookies,
const absl::optional<url::Origin>& top_frame_origin) override;
const base::Optional<url::Origin>& top_frame_origin) override;
bool ShouldAllowPluginCreation(
const url::Origin& embedder_origin,
const content::PepperPluginInfo& plugin_info) override;

View File

@@ -68,11 +68,10 @@ content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
extensions::GetExtensionForUrl(browser_context, gurl);
}
if (create_params.extension) {
if (create_params.extension_host_type ==
extensions::mojom::ViewType::kInvalid) {
if (create_params.extension_host_type == extensions::VIEW_TYPE_INVALID) {
// Default to dialog behavior.
create_params.extension_host_type =
extensions::mojom::ViewType::kExtensionDialog;
extensions::VIEW_TYPE_EXTENSION_DIALOG;
}
// Extension resources will fail to load if we don't use a SiteInstance
@@ -192,7 +191,7 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type) {
extensions::ViewType host_type) {
REQUIRE_ALLOY_RUNTIME();
DCHECK(primary_);
@@ -203,15 +202,14 @@ void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
auto alloy_browser = static_cast<AlloyBrowserHostImpl*>(browser_);
if (host_type == extensions::mojom::ViewType::kExtensionDialog ||
host_type == extensions::mojom::ViewType::kExtensionPopup) {
if (host_type == extensions::VIEW_TYPE_EXTENSION_DIALOG ||
host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) {
// Create an extension host that we own.
extension_host_ = new extensions::CefExtensionViewHost(
alloy_browser, extension, web_contents_, url, host_type);
// Trigger load of the extension URL.
extension_host_->CreateRendererSoon();
} else if (host_type ==
extensions::mojom::ViewType::kExtensionBackgroundPage) {
} else if (host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
is_background_host_ = true;
alloy_browser->is_background_host_ = true;
// Create an extension host that will be owned by ProcessManager.
@@ -379,12 +377,12 @@ void CefBrowserPlatformDelegateAlloy::PrintToPDF(
return;
printing::CefPrintViewManager::PdfPrintCallback pdf_callback;
if (callback.get()) {
pdf_callback = base::BindOnce(&CefPdfPrintCallback::OnPdfPrintFinished,
callback.get(), path);
pdf_callback = base::Bind(&CefPdfPrintCallback::OnPdfPrintFinished,
callback.get(), path);
}
GetPrintViewManager(actionable_contents)
->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path),
settings, std::move(pdf_callback));
settings, pdf_callback);
}
void CefBrowserPlatformDelegateAlloy::Find(int identifier,
@@ -453,7 +451,7 @@ void CefBrowserPlatformDelegateAlloy::DestroyExtensionHost() {
if (!extension_host_)
return;
if (extension_host_->extension_host_type() ==
extensions::mojom::ViewType::kExtensionBackgroundPage) {
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
DCHECK(is_background_host_);
// Close notification for background pages arrives via CloseContents.
// The extension host will be deleted by

View File

@@ -33,7 +33,7 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
void BrowserCreated(CefBrowserHostBase* browser) override;
void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type) override;
extensions::ViewType host_type) override;
extensions::ExtensionHost* GetExtensionHost() const override;
void BrowserDestroyed(CefBrowserHostBase* browser) override;
void SendCaptureLostEvent() override;

View File

@@ -6,7 +6,6 @@
#include "libcef/browser/alloy/chrome_profile_alloy.h"
#include "base/no_destructor.h"
#include "components/profile_metrics/browser_profile_type.h"
#include "components/variations/variations_client.h"
#include "components/variations/variations_ids_provider.h"
#include "net/url_request/url_request_context.h"
@@ -36,10 +35,7 @@ class CefVariationsClient : public variations::VariationsClient {
} // namespace
ChromeProfileAlloy::ChromeProfileAlloy() {
profile_metrics::SetBrowserProfileType(
this, profile_metrics::BrowserProfileType::kRegular);
}
ChromeProfileAlloy::ChromeProfileAlloy() {}
ChromeProfileAlloy::~ChromeProfileAlloy() {}
@@ -48,15 +44,13 @@ bool ChromeProfileAlloy::IsOffTheRecord() {
}
bool ChromeProfileAlloy::IsOffTheRecord() const {
// Alloy contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false;
}
const Profile::OTRProfileID& ChromeProfileAlloy::GetOTRProfileID() const {
NOTREACHED();
static base::NoDestructor<Profile::OTRProfileID> otr_profile_id(
Profile::OTRProfileID::PrimaryID());
"ProfileImp::NoOTRProfileID");
return *otr_profile_id;
}
@@ -77,8 +71,7 @@ std::string ChromeProfileAlloy::GetProfileUserName() const {
}
Profile* ChromeProfileAlloy::GetOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id,
bool create_if_needed) {
const Profile::OTRProfileID& otr_profile_id) {
NOTREACHED();
return nullptr;
}
@@ -122,6 +115,11 @@ ChromeProfileAlloy::GetExtensionSpecialStoragePolicy() {
return nullptr;
}
PrefService* ChromeProfileAlloy::GetOffTheRecordPrefs() {
NOTREACHED();
return nullptr;
}
bool ChromeProfileAlloy::IsSameOrParent(Profile* profile) {
NOTREACHED();
return false;

View File

@@ -26,8 +26,8 @@ class ChromeProfileAlloy : public Profile {
variations::VariationsClient* GetVariationsClient() override;
scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override;
std::string GetProfileUserName() const override;
Profile* GetOffTheRecordProfile(const Profile::OTRProfileID& otr_profile_id,
bool create_if_needed) override;
Profile* GetOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) override;
std::vector<Profile*> GetAllOffTheRecordProfiles() override;
void DestroyOffTheRecordProfile(Profile* otr_profile) override;
bool HasOffTheRecordProfile(
@@ -38,6 +38,7 @@ class ChromeProfileAlloy : public Profile {
bool IsSupervised() const override;
bool IsChild() const override;
ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
PrefService* GetOffTheRecordPrefs() override;
bool IsSameOrParent(Profile* profile) override;
base::Time GetStartTime() const override;
base::FilePath last_selected_directory() override;

View File

@@ -56,3 +56,10 @@ bool ChromeProfileManagerAlloy::IsValidProfile(const void* profile) {
return !!CefBrowserContext::FromBrowserContext(
static_cast<const content::BrowserContext*>(profile));
}
Profile* ChromeProfileManagerAlloy::GetLastUsedProfile(
const base::FilePath& user_data_dir) {
// Override this method to avoid having to register prefs::kProfileLastUsed,
// usage of which doesn't make sense for CEF.
return GetActiveBrowserContext()->AsProfile();
}

View File

@@ -18,6 +18,7 @@ class ChromeProfileManagerAlloy : public ProfileManager {
Profile* GetProfile(const base::FilePath& profile_dir) override;
bool IsValidProfile(const void* profile) override;
Profile* GetLastUsedProfile(const base::FilePath& user_data_dir) override;
private:
DISALLOW_COPY_AND_ASSIGN(ChromeProfileManagerAlloy);

View File

@@ -110,9 +110,7 @@ void CefAudioCapturer::Capture(const media::AudioBus* source,
pts.InMilliseconds());
}
void CefAudioCapturer::OnCaptureError(
media::AudioCapturerSource::ErrorCode code,
const std::string& message) {
void CefAudioCapturer::OnCaptureError(const std::string& message) {
audio_handler_->OnAudioStreamError(browser_, message);
StopStream();
}

View File

@@ -33,8 +33,7 @@ class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback {
base::TimeTicks audio_capture_time,
double volume,
bool key_pressed) override;
void OnCaptureError(media::AudioCapturerSource::ErrorCode code,
const std::string& message) override;
void OnCaptureError(const std::string& message) override;
void OnCaptureMuted(bool is_muted) override {}
void StopStream();

View File

@@ -44,7 +44,7 @@ class StreamCreatedCallbackAdapter final
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted,
const absl::optional<base::UnguessableToken>& stream_id) override {
const base::Optional<base::UnguessableToken>& stream_id) override {
DCHECK(!initially_muted); // Loopback streams shouldn't be started muted.
callback_.Run(std::move(stream), std::move(client_receiver),
std::move(data_pipe));

View File

@@ -8,7 +8,6 @@
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/browser_util.h"
#include "content/public/browser/focused_node_details.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/navigation_entry.h"
@@ -17,8 +16,6 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_view_host.h"
#include "third_party/blink/public/mojom/favicon/favicon_url.mojom.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
using content::KeyboardEventProcessingResult;
@@ -130,9 +127,9 @@ void CefBrowserContentsDelegate::UpdateTargetURL(content::WebContents* source,
bool CefBrowserContentsDelegate::DidAddMessageToConsole(
content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) {
const base::string16& source_id) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
// Use LOGSEVERITY_DEBUG for unrecognized |level| values.
@@ -234,6 +231,18 @@ bool CefBrowserContentsDelegate::HandleKeyboardEvent(
void CefBrowserContentsDelegate::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) {
browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */);
if (render_frame_host->GetParent() == nullptr) {
// May be already registered if the renderer crashed previously.
auto render_view_host = render_frame_host->GetRenderViewHost();
if (!registrar_->IsRegistered(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host))) {
registrar_->Add(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host));
}
}
}
void CefBrowserContentsDelegate::RenderFrameHostChanged(
@@ -243,13 +252,6 @@ void CefBrowserContentsDelegate::RenderFrameHostChanged(
RenderFrameCreated(new_host);
}
void CefBrowserContentsDelegate::RenderFrameHostStateChanged(
content::RenderFrameHost* host,
content::RenderFrameHost::LifecycleState old_state,
content::RenderFrameHost::LifecycleState new_state) {
browser_info_->FrameHostStateChanged(host, old_state, new_state);
}
void CefBrowserContentsDelegate::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
const auto frame_id = CefFrameHostImpl::MakeFrameId(render_frame_host);
@@ -261,6 +263,17 @@ void CefBrowserContentsDelegate::RenderFrameDeleted(
}
}
void CefBrowserContentsDelegate::RenderViewDeleted(
content::RenderViewHost* render_view_host) {
if (registrar_->IsRegistered(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host))) {
registrar_->Remove(
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(render_view_host));
}
}
void CefBrowserContentsDelegate::RenderViewReady() {
if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) {
@@ -315,8 +328,7 @@ void CefBrowserContentsDelegate::OnFrameFocused(
OnStateChanged(State::kFocusedFrame);
}
void CefBrowserContentsDelegate::DocumentAvailableInMainFrame(
content::RenderFrameHost* render_frame_host) {
void CefBrowserContentsDelegate::DocumentAvailableInMainFrame() {
has_document_ = true;
OnStateChanged(State::kDocument);
@@ -412,6 +424,18 @@ void CefBrowserContentsDelegate::DidFailLoad(
OnLoadEnd(frame, validated_url, error_code);
}
bool CefBrowserContentsDelegate::OnMessageReceived(
const IPC::Message& message,
content::RenderFrameHost* render_frame_host) {
// Messages may arrive after a frame is detached. Ignore those messages.
auto frame = browser_info_->GetFrameForHost(render_frame_host);
if (frame) {
return static_cast<CefFrameHostImpl*>(frame.get())
->OnMessageReceived(message);
}
return false;
}
void CefBrowserContentsDelegate::TitleWasSet(content::NavigationEntry* entry) {
// |entry| may be NULL if a popup is created via window.open and never
// navigated.
@@ -458,13 +482,6 @@ void CefBrowserContentsDelegate::OnWebContentsFocused(
}
}
void CefBrowserContentsDelegate::OnFocusChangedInPage(
content::FocusedNodeDetails* details) {
focus_on_editable_field_ =
details->focus_type != blink::mojom::blink::FocusType::kNone &&
details->is_editable_node;
}
void CefBrowserContentsDelegate::WebContentsDestroyed() {
auto wc = web_contents();
ObserveWebContents(nullptr);
@@ -477,12 +494,15 @@ void CefBrowserContentsDelegate::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(type, content::NOTIFICATION_LOAD_STOP);
DCHECK(type == content::NOTIFICATION_LOAD_STOP ||
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE);
if (type == content::NOTIFICATION_LOAD_STOP) {
content::NavigationController* controller =
content::Source<content::NavigationController>(source).ptr();
OnTitleChange(controller->GetWebContents()->GetTitle());
} else if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) {
focus_on_editable_field_ = *content::Details<bool>(details).ptr();
}
}
@@ -572,7 +592,7 @@ void CefBrowserContentsDelegate::OnLoadError(CefRefPtr<CefFrame> frame,
}
}
void CefBrowserContentsDelegate::OnTitleChange(const std::u16string& title) {
void CefBrowserContentsDelegate::OnTitleChange(const base::string16& title) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
handler->OnTitleChange(browser(), title);

View File

@@ -10,7 +10,6 @@
#include "libcef/browser/frame_host_impl.h"
#include "base/callback_list.h"
#include "base/observer_list.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -88,9 +87,9 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
bool DidAddMessageToConsole(content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) override;
const base::string16& source_id) override;
void DidNavigateMainFramePostCommit(
content::WebContents* web_contents) override;
void EnterFullscreenModeForTab(
@@ -108,16 +107,12 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
content::RenderFrameHost* new_host) override;
void RenderFrameHostStateChanged(
content::RenderFrameHost* host,
content::RenderFrameHost::LifecycleState old_state,
content::RenderFrameHost::LifecycleState new_state) override;
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
void RenderViewReady() override;
void RenderProcessGone(base::TerminationStatus status) override;
void OnFrameFocused(content::RenderFrameHost* render_frame_host) override;
void DocumentAvailableInMainFrame(
content::RenderFrameHost* render_frame_host) override;
void DocumentAvailableInMainFrame() override;
void LoadProgressChanged(double progress) override;
void DidStopLoading() override;
void DidFinishNavigation(
@@ -125,6 +120,8 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void DidFailLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code) override;
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
void TitleWasSet(content::NavigationEntry* entry) override;
void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override;
@@ -133,7 +130,6 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
void OnWebContentsFocused(
content::RenderWidgetHost* render_widget_host) override;
void OnFocusChangedInPage(content::FocusedNodeDetails* details) override;
void WebContentsDestroyed() override;
// NotificationObserver methods.
@@ -167,7 +163,7 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void OnLoadStart(CefRefPtr<CefFrame> frame,
ui::PageTransition transition_type);
void OnLoadError(CefRefPtr<CefFrame> frame, const GURL& url, int error_code);
void OnTitleChange(const std::u16string& title);
void OnTitleChange(const base::string16& title);
void OnFullscreenModeChange(bool fullscreen);
void OnStateChanged(State state_changed);

View File

@@ -229,9 +229,7 @@ void CefBrowserContext::RemoveCefRequestContext(
// Delete ourselves when the reference count reaches zero.
if (request_context_set_.empty()) {
Shutdown();
// Allow the current call stack to unwind before deleting |this|.
content::BrowserThread::DeleteSoon(CEF_UIT, FROM_HERE, this);
delete this;
}
}
@@ -302,9 +300,9 @@ void CefBrowserContext::OnRenderFrameCreated(
frame_tree_node_id, handler);
CEF_POST_TASK(CEF_IOT,
base::BindOnce(&CefIOThreadState::AddHandler, iothread_state_,
render_process_id, render_frame_id,
frame_tree_node_id, handler));
base::Bind(&CefIOThreadState::AddHandler, iothread_state_,
render_process_id, render_frame_id,
frame_tree_node_id, handler));
}
}
@@ -334,9 +332,9 @@ void CefBrowserContext::OnRenderFrameDeleted(
handler_map_.RemoveHandler(render_process_id, render_frame_id,
frame_tree_node_id);
CEF_POST_TASK(CEF_IOT, base::BindOnce(&CefIOThreadState::RemoveHandler,
iothread_state_, render_process_id,
render_frame_id, frame_tree_node_id));
CEF_POST_TASK(CEF_IOT, base::Bind(&CefIOThreadState::RemoveHandler,
iothread_state_, render_process_id,
render_frame_id, frame_tree_node_id));
}
if (is_main_frame) {
@@ -440,16 +438,15 @@ void CefBrowserContext::RegisterSchemeHandlerFactory(
const CefString& scheme_name,
const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory) {
CEF_POST_TASK(
CEF_IOT,
base::BindOnce(&CefIOThreadState::RegisterSchemeHandlerFactory,
iothread_state_, scheme_name, domain_name, factory));
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefIOThreadState::RegisterSchemeHandlerFactory,
iothread_state_, scheme_name, domain_name, factory));
}
void CefBrowserContext::ClearSchemeHandlerFactories() {
CEF_POST_TASK(CEF_IOT,
base::BindOnce(&CefIOThreadState::ClearSchemeHandlerFactories,
iothread_state_));
base::Bind(&CefIOThreadState::ClearSchemeHandlerFactories,
iothread_state_));
}
void CefBrowserContext::LoadExtension(
@@ -485,7 +482,8 @@ bool CefBrowserContext::IsPrintPreviewSupported() const {
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
CEF_REQUIRE_UIT();
auto browser_context = AsBrowserContext();
return browser_context->GetDefaultStoragePartition()->GetNetworkContext();
return browser_context->GetDefaultStoragePartition(browser_context)
->GetNetworkContext();
}
CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
@@ -519,7 +517,7 @@ CefBrowserContext::GetGlobalCookieableSchemes() {
CefString(&settings.cookieable_schemes_list),
!settings.cookieable_schemes_exclude_defaults);
}
return absl::nullopt;
return base::nullopt;
}());
return *schemes;
}

View File

@@ -16,10 +16,9 @@
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/optional.h"
#include "chrome/common/plugin.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/origin.h"
/*
@@ -201,7 +200,7 @@ class CefBrowserContext {
CefMediaRouterManager* GetMediaRouterManager();
using CookieableSchemes = absl::optional<std::vector<std::string>>;
using CookieableSchemes = base::Optional<std::vector<std::string>>;
// Returns the schemes associated with this context specifically, or the
// global configuration if unset.
@@ -237,9 +236,6 @@ class CefBrowserContext {
base::FilePath cache_path_;
private:
// For DeleteSoon().
friend class base::DeleteHelper<CefBrowserContext>;
scoped_refptr<CefIOThreadState> iothread_state_;
CookieableSchemes cookieable_schemes_;
std::unique_ptr<CefMediaRouterManager> media_router_manager_;

View File

@@ -1,77 +0,0 @@
// Copyright 2021 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/browser_frame.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/thread_util.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
CefBrowserFrame::CefBrowserFrame(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<cef::mojom::BrowserFrame> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)) {}
CefBrowserFrame::~CefBrowserFrame() = default;
// static
void CefBrowserFrame::RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) {
map->Add<cef::mojom::BrowserFrame>(base::BindRepeating(
[](content::RenderFrameHost* frame_host,
mojo::PendingReceiver<cef::mojom::BrowserFrame> receiver) {
// This object is bound to the lifetime of |frame_host| and the mojo
// connection. See FrameServiceBase for details.
new CefBrowserFrame(frame_host, std::move(receiver));
}));
}
void CefBrowserFrame::SendMessage(const std::string& name,
base::Value arguments) {
// Always associate with the newly created RFH, which may be speculative when
// navigating cross-origin.
if (auto host = GetFrameHost(/*prefer_speculative=*/true)) {
host->SendMessage(name, std::move(arguments));
}
}
void CefBrowserFrame::FrameAttached() {
// Always send to the newly created RFH, which may be speculative when
// navigating cross-origin.
if (auto host = GetFrameHost(/*prefer_speculative=*/true)) {
host->FrameAttached();
}
}
void CefBrowserFrame::DidFinishFrameLoad(const GURL& validated_url,
int http_status_code) {
if (auto host = GetFrameHost()) {
host->DidFinishFrameLoad(validated_url, http_status_code);
}
}
void CefBrowserFrame::UpdateDraggableRegions(
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) {
if (auto host = GetFrameHost()) {
host->UpdateDraggableRegions(std::move(regions));
}
}
CefRefPtr<CefFrameHostImpl> CefBrowserFrame::GetFrameHost(
bool prefer_speculative) const {
CEF_REQUIRE_UIT();
auto rfh = render_frame_host();
if (auto browser = CefBrowserHostBase::GetBrowserForHost(rfh)) {
return browser->browser_info()->GetFrameForHost(rfh, nullptr,
prefer_speculative);
}
NOTREACHED();
return nullptr;
}

View File

@@ -1,51 +0,0 @@
// Copyright 2021 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_BROWSER_FRAME_H_
#define CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_
#pragma once
#include "libcef/browser/frame_host_impl.h"
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "content/public/browser/frame_service_base.h"
#include "mojo/public/cpp/bindings/binder_map.h"
// Implementation of the BrowserFrame mojo interface.
// This is implemented separately from CefFrameHostImpl to better manage the
// association with the RenderFrameHost (which may be speculative, etc.), and so
// that messages are always routed to the most appropriate CefFrameHostImpl
// instance. Lifespan is tied to the RFH via FrameServiceBase.
class CefBrowserFrame
: public content::FrameServiceBase<cef::mojom::BrowserFrame> {
public:
CefBrowserFrame(content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<cef::mojom::BrowserFrame> receiver);
~CefBrowserFrame() override;
// Called from the ContentBrowserClient method of the same name.
static void RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map);
private:
// cef::mojom::BrowserFrame methods:
void SendMessage(const std::string& name, base::Value arguments) override;
void FrameAttached() override;
void DidFinishFrameLoad(const GURL& validated_url,
int32_t http_status_code) override;
void UpdateDraggableRegions(
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions)
override;
// FrameServiceBase methods:
bool ShouldCloseOnFinishNavigation() const override { return false; }
CefRefPtr<CefFrameHostImpl> GetFrameHost(
bool prefer_speculative = false) const;
DISALLOW_COPY_AND_ASSIGN(CefBrowserFrame);
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_

View File

@@ -232,7 +232,8 @@ void CefBrowserHostBase::StartDownload(const CefString& url) {
if (!browser_context)
return;
content::DownloadManager* manager = browser_context->GetDownloadManager();
content::DownloadManager* manager =
content::BrowserContext::GetDownloadManager(browser_context);
if (!manager)
return;
@@ -366,7 +367,7 @@ void CefBrowserHostBase::GetNavigationEntries(
CefRefPtr<CefNavigationEntryImpl> entry =
new CefNavigationEntryImpl(controller.GetEntryAtIndex(current));
visitor->Visit(entry.get(), true, current, total);
ignore_result(entry->Detach(nullptr));
entry->Detach(nullptr);
} else {
// Visit all entries.
bool cont = true;
@@ -374,7 +375,7 @@ void CefBrowserHostBase::GetNavigationEntries(
CefRefPtr<CefNavigationEntryImpl> entry =
new CefNavigationEntryImpl(controller.GetEntryAtIndex(i));
cont = visitor->Visit(entry.get(), (i == current), i, total);
ignore_result(entry->Detach(nullptr));
entry->Detach(nullptr);
}
}
}
@@ -496,10 +497,6 @@ void CefBrowserHostBase::SendMouseWheelEvent(const CefMouseEvent& event,
}
}
bool CefBrowserHostBase::IsValid() {
return browser_info_->browser() == this;
}
CefRefPtr<CefBrowserHost> CefBrowserHostBase::GetHost() {
return this;
}

View File

@@ -18,7 +18,7 @@
#include "base/observer_list.h"
#include "base/synchronization/lock.h"
#include "extensions/common/mojom/view_type.mojom.h"
#include "extensions/common/view_type.h"
namespace extensions {
class Extension;
@@ -86,8 +86,7 @@ struct CefBrowserCreateParams {
// ProcessManager::CreateBackgroundHost. Currently used with the alloy
// runtime only.
const extensions::Extension* extension = nullptr;
extensions::mojom::ViewType extension_host_type =
extensions::mojom::ViewType::kInvalid;
extensions::ViewType extension_host_type = extensions::VIEW_TYPE_INVALID;
};
// Base class for CefBrowserHost implementations. Includes functionality that is
@@ -183,7 +182,6 @@ class CefBrowserHostBase : public CefBrowserHost,
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
// CefBrowser methods:
bool IsValid() override;
CefRefPtr<CefBrowserHost> GetHost() override;
bool CanGoBack() override;
void GoBack() override;

View File

@@ -15,12 +15,10 @@
#include "ipc/ipc_message.h"
CefBrowserInfo::FrameInfo::~FrameInfo() {
#if DCHECK_IS_ON()
if (frame_ && !IsCurrentMainFrame()) {
// Should already be Detached.
DCHECK(!frame_->GetRenderFrameHost());
if (frame_ && !is_main_frame_) {
// Disassociate sub-frames from the browser.
frame_->Detach();
}
#endif
}
CefBrowserInfo::CefBrowserInfo(int browser_id,
@@ -34,9 +32,7 @@ CefBrowserInfo::CefBrowserInfo(int browser_id,
DCHECK_GT(browser_id, 0);
}
CefBrowserInfo::~CefBrowserInfo() {
DCHECK(frame_info_set_.empty());
}
CefBrowserInfo::~CefBrowserInfo() {}
CefRefPtr<CefBrowserHostBase> CefBrowserInfo::browser() const {
base::AutoLock lock_scope(lock_);
@@ -44,29 +40,11 @@ CefRefPtr<CefBrowserHostBase> CefBrowserInfo::browser() const {
}
void CefBrowserInfo::SetBrowser(CefRefPtr<CefBrowserHostBase> browser) {
NotificationStateLock lock_scope(this);
if (browser) {
DCHECK(!browser_);
// Cache the associated frame handler.
if (auto client = browser->GetClient()) {
frame_handler_ = client->GetFrameHandler();
}
} else {
DCHECK(browser_);
}
auto old_browser = browser_;
base::AutoLock lock_scope(lock_);
browser_ = browser;
if (!browser_) {
RemoveAllFrames(old_browser);
// Any future calls to MaybeExecuteFrameNotification will now fail.
// NotificationStateLock already took a reference for the delivery of any
// notifications that are currently queued due to RemoveAllFrames.
frame_handler_ = nullptr;
if (!browser) {
RemoveAllFrames();
}
}
@@ -90,7 +68,7 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
->render_manager()
->current_frame_host() != host);
NotificationStateLock lock_scope(this);
base::AutoLock lock_scope(lock_);
DCHECK(browser_);
const auto it = frame_id_map_.find(frame_id);
@@ -108,8 +86,14 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
if (!info->is_guest_view_ && info->is_speculative_ && !is_speculative) {
// Upgrade the frame info from speculative to non-speculative.
if (info->is_main_frame_) {
// Set the main frame object.
SetMainFrame(browser_, info->frame_);
if (main_frame_) {
// Update the existing main frame object.
main_frame_->SetRenderFrameHost(host);
info->frame_ = main_frame_;
} else {
// Set the main frame object.
main_frame_ = info->frame_;
}
}
info->is_speculative_ = false;
MaybeUpdateFrameTreeNodeIdMap(info);
@@ -127,13 +111,17 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
// Guest views don't get their own CefBrowser or CefFrame objects.
if (!is_guest_view) {
// Create a new frame object.
frame_info->frame_ = new CefFrameHostImpl(this, host);
MaybeNotifyFrameCreated(frame_info->frame_);
if (is_main_frame && !is_speculative) {
SetMainFrame(browser_, frame_info->frame_);
if (is_main_frame && main_frame_ && !is_speculative) {
// Update the existing main frame object.
main_frame_->SetRenderFrameHost(host);
frame_info->frame_ = main_frame_;
} else {
// Create a new frame object.
frame_info->frame_ = new CefFrameHostImpl(this, host);
if (is_main_frame && !is_speculative) {
main_frame_ = frame_info->frame_;
}
}
#if DCHECK_IS_ON()
// Check that the frame info hasn't changed unexpectedly.
DCHECK_EQ(frame_id, frame_info->frame_->GetIdentifier());
@@ -153,36 +141,10 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
frame_info_set_.insert(base::WrapUnique(frame_info));
}
void CefBrowserInfo::FrameHostStateChanged(
content::RenderFrameHost* host,
content::RenderFrameHost::LifecycleState old_state,
content::RenderFrameHost::LifecycleState new_state) {
CEF_REQUIRE_UIT();
// We currently only care about BackForwardCache state changes.
bool added_to_bfcache =
new_state ==
content::RenderFrameHost::LifecycleState::kInBackForwardCache;
bool removed_from_bfcache =
old_state ==
content::RenderFrameHost::LifecycleState::kInBackForwardCache;
if (!added_to_bfcache && !removed_from_bfcache)
return;
base::AutoLock lock_scope(lock_);
const auto frame_id = CefFrameHostImpl::MakeFrameId(host);
auto it = frame_id_map_.find(frame_id);
DCHECK(it != frame_id_map_.end());
DCHECK((!it->second->is_in_bfcache_ && added_to_bfcache) ||
(it->second->is_in_bfcache_ && removed_from_bfcache));
it->second->is_in_bfcache_ = added_to_bfcache;
}
void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
CEF_REQUIRE_UIT();
NotificationStateLock lock_scope(this);
base::AutoLock lock_scope(lock_);
const auto frame_id = CefFrameHostImpl::MakeFrameId(host);
@@ -212,25 +174,19 @@ void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
// And finally delete the frame info.
{
auto it2 = frame_info_set_.find(frame_info);
// Explicitly Detach everything but the current main frame.
const auto& frame_info = *it2;
if (frame_info->frame_ && !frame_info->IsCurrentMainFrame()) {
if (frame_info->frame_->Detach())
MaybeNotifyFrameDetached(browser_, frame_info->frame_);
}
frame_info_set_.erase(it2);
}
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetMainFrame() {
NotificationStateLock lock_scope(this);
// Early exit if called post-destruction.
if (!browser_)
return nullptr;
CHECK(main_frame_);
base::AutoLock lock_scope(lock_);
DCHECK(browser_);
if (!main_frame_) {
// Create a temporary object that will eventually be updated with real
// routing information.
main_frame_ =
new CefFrameHostImpl(this, true, CefFrameHostImpl::kInvalidFrameId);
}
return main_frame_;
}
@@ -239,29 +195,25 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::CreateTempSubFrame(
CefRefPtr<CefFrameHostImpl> parent = GetFrameForId(parent_frame_id);
if (!parent)
parent = GetMainFrame();
// Intentionally not notifying for temporary frames.
return new CefFrameHostImpl(this, parent->GetIdentifier());
return new CefFrameHostImpl(this, false, parent->GetIdentifier());
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForHost(
const content::RenderFrameHost* host,
bool* is_guest_view,
bool prefer_speculative) const {
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
if (!host)
return nullptr;
return GetFrameForId(CefFrameHostImpl::MakeFrameId(host), is_guest_view,
prefer_speculative);
return GetFrameForId(CefFrameHostImpl::MakeFrameId(host), is_guest_view);
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForRoute(
int32_t render_process_id,
int32_t render_routing_id,
bool* is_guest_view,
bool prefer_speculative) const {
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
@@ -270,13 +222,12 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForRoute(
return GetFrameForId(
CefFrameHostImpl::MakeFrameId(render_process_id, render_routing_id),
is_guest_view, prefer_speculative);
is_guest_view);
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForId(
int64_t frame_id,
bool* is_guest_view,
bool prefer_speculative) const {
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
@@ -295,7 +246,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForId(
return nullptr;
}
if (info->is_speculative_ && !prefer_speculative) {
if (info->is_speculative_) {
if (info->is_main_frame_ && main_frame_) {
// Always prefer the non-speculative main frame.
return main_frame_;
@@ -340,9 +291,8 @@ CefBrowserInfo::FrameHostList CefBrowserInfo::GetAllFrames() const {
base::AutoLock lock_scope(lock_);
FrameHostList frames;
for (const auto& info : frame_info_set_) {
if (info->frame_ && !info->is_speculative_ && !info->is_in_bfcache_) {
if (info->frame_ && !info->is_speculative_)
frames.insert(info->frame_);
}
}
return frames;
}
@@ -378,30 +328,6 @@ bool CefBrowserInfo::IsNavigationLocked(base::OnceClosure pending_action) {
return false;
}
void CefBrowserInfo::MaybeExecuteFrameNotification(
FrameNotifyOnceAction pending_action) {
CefRefPtr<CefFrameHandler> frame_handler;
{
base::AutoLock lock_scope_(notification_lock_);
if (!frame_handler_) {
// No notifications will be executed.
return;
}
if (notification_state_lock_) {
// Queue the notification until the lock is released.
notification_state_lock_->queue_.push(std::move(pending_action));
return;
}
frame_handler = frame_handler_;
}
// Execute immediately if not locked.
std::move(pending_action).Run(frame_handler);
}
void CefBrowserInfo::MaybeUpdateFrameTreeNodeIdMap(FrameInfo* info) {
lock_.AssertAcquired();
@@ -455,150 +381,24 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForFrameTreeNodeInternal(
return nullptr;
}
// Passing in |browser| here because |browser_| may already be cleared.
void CefBrowserInfo::SetMainFrame(CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> frame) {
void CefBrowserInfo::RemoveAllFrames() {
lock_.AssertAcquired();
DCHECK(browser);
DCHECK(!frame || frame->IsMain());
CefRefPtr<CefFrameHostImpl> old_frame;
if (main_frame_) {
old_frame = main_frame_;
if (old_frame->Detach())
MaybeNotifyFrameDetached(browser, old_frame);
}
main_frame_ = frame;
MaybeNotifyMainFrameChanged(browser, old_frame, main_frame_);
}
void CefBrowserInfo::MaybeNotifyFrameCreated(
CefRefPtr<CefFrameHostImpl> frame) {
CEF_REQUIRE_UIT();
// Never notify for temporary objects.
DCHECK(!frame->is_temporary());
MaybeExecuteFrameNotification(base::BindOnce(
[](scoped_refptr<CefBrowserInfo> self, CefRefPtr<CefFrameHostImpl> frame,
CefRefPtr<CefFrameHandler> handler) {
if (auto browser = self->browser()) {
handler->OnFrameCreated(browser, frame);
}
},
scoped_refptr<CefBrowserInfo>(this), frame));
}
// Passing in |browser| here because |browser_| may already be cleared.
void CefBrowserInfo::MaybeNotifyFrameDetached(
CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> frame) {
CEF_REQUIRE_UIT();
// Never notify for temporary objects.
DCHECK(!frame->is_temporary());
MaybeExecuteFrameNotification(base::BindOnce(
[](CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> frame,
CefRefPtr<CefFrameHandler> handler) {
handler->OnFrameDetached(browser, frame);
},
browser, frame));
}
// Passing in |browser| here because |browser_| may already be cleared.
void CefBrowserInfo::MaybeNotifyMainFrameChanged(
CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> old_frame,
CefRefPtr<CefFrameHostImpl> new_frame) {
CEF_REQUIRE_UIT();
// Never notify for temporary objects.
DCHECK(!old_frame || !old_frame->is_temporary());
DCHECK(!new_frame || !new_frame->is_temporary());
MaybeExecuteFrameNotification(base::BindOnce(
[](CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> old_frame,
CefRefPtr<CefFrameHostImpl> new_frame,
CefRefPtr<CefFrameHandler> handler) {
handler->OnMainFrameChanged(browser, old_frame, new_frame);
},
browser, old_frame, new_frame));
}
void CefBrowserInfo::RemoveAllFrames(
CefRefPtr<CefBrowserHostBase> old_browser) {
lock_.AssertAcquired();
// Make sure any callbacks will see the correct state (e.g. like
// CefBrowser::GetMainFrame returning nullptr and CefBrowser::IsValid
// returning false).
DCHECK(!browser_);
DCHECK(old_browser);
// Clear the lookup maps.
frame_id_map_.clear();
frame_tree_node_id_map_.clear();
// Explicitly Detach everything but the current main frame.
// Explicitly Detach main frames.
for (auto& info : frame_info_set_) {
if (info->frame_ && !info->IsCurrentMainFrame()) {
if (info->frame_->Detach())
MaybeNotifyFrameDetached(old_browser, info->frame_);
}
if (info->frame_ && info->is_main_frame_)
info->frame_->Detach();
}
if (main_frame_)
SetMainFrame(old_browser, nullptr);
if (main_frame_) {
main_frame_->Detach();
main_frame_ = nullptr;
}
// And finally delete the frame info.
frame_info_set_.clear();
}
CefBrowserInfo::NotificationStateLock::NotificationStateLock(
CefBrowserInfo* browser_info)
: browser_info_(browser_info) {
// Take the navigation state lock.
{
base::AutoLock lock_scope_(browser_info_->notification_lock_);
CHECK(!browser_info_->notification_state_lock_);
browser_info_->notification_state_lock_ = this;
// We may need this on destruction, and the original might be cleared.
frame_handler_ = browser_info_->frame_handler_;
}
// Take the browser info state lock.
browser_info_lock_scope_.reset(new base::AutoLock(browser_info_->lock_));
}
CefBrowserInfo::NotificationStateLock::~NotificationStateLock() {
// Unlock in reverse order.
browser_info_lock_scope_.reset();
{
base::AutoLock lock_scope_(browser_info_->notification_lock_);
CHECK_EQ(this, browser_info_->notification_state_lock_);
browser_info_->notification_state_lock_ = nullptr;
}
if (!queue_.empty()) {
DCHECK(frame_handler_);
scoped_refptr<NavigationLock> nav_lock;
if (CEF_CURRENTLY_ON_UIT()) {
// Don't navigate while inside callbacks.
nav_lock = browser_info_->CreateNavigationLock();
}
// Empty the queue of pending actions. Any of these actions might result in
// the acquisition of a new NotificationStateLock.
while (!queue_.empty()) {
std::move(queue_.front()).Run(frame_handler_);
queue_.pop();
}
}
}

View File

@@ -6,7 +6,6 @@
#define CEF_LIBCEF_BROWSER_BROWSER_INFO_H_
#pragma once
#include <queue>
#include <set>
#include <unordered_map>
@@ -19,10 +18,12 @@
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
#include "base/values.h"
#include "content/public/browser/render_frame_host.h"
namespace content {
class RenderFrameHost;
}
class CefBrowserHostBase;
class CefFrameHandler;
class CefFrameHostImpl;
// CefBrowserInfo is used to associate a browser ID and render view/process
@@ -59,13 +60,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// true).
void MaybeCreateFrame(content::RenderFrameHost* host, bool is_guest_view);
// Used to track state changes such as entering/exiting the BackForwardCache.
// Called from CefBrowserContentsDelegate::RenderFrameHostStateChanged.
void FrameHostStateChanged(
content::RenderFrameHost* host,
content::RenderFrameHost::LifecycleState old_state,
content::RenderFrameHost::LifecycleState new_state);
// Remove the frame record for |host|. Called for the main frame when the
// RenderView is destroyed, or for a sub-frame when the associated RenderFrame
// is destroyed in the renderer process.
@@ -94,8 +88,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// UI thread.
CefRefPtr<CefFrameHostImpl> GetFrameForHost(
const content::RenderFrameHost* host,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
bool* is_guest_view = nullptr) const;
// Returns the frame object matching the specified IDs or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
@@ -105,8 +98,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
CefRefPtr<CefFrameHostImpl> GetFrameForRoute(
int32_t render_process_id,
int32_t render_routing_id,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
bool* is_guest_view = nullptr) const;
// Returns the frame object matching the specified ID or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
@@ -115,8 +107,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// thread.
CefRefPtr<CefFrameHostImpl> GetFrameForId(
int64_t frame_id,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
bool* is_guest_view = nullptr) const;
// Returns the frame object matching the specified ID or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
@@ -155,16 +146,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// thread.
bool IsNavigationLocked(base::OnceClosure pending_action);
using FrameNotifyOnceAction =
base::OnceCallback<void(CefRefPtr<CefFrameHandler>)>;
// Specifies a CefFrameHandler notification action whose execution may need
// to be blocked on release of a potentially held NotificationStateLock. If no
// CefFrameHandler exists then the action will be discarded without executing.
// If the NotificationStateLock is not currently held then the action will be
// executed immediately.
void MaybeExecuteFrameNotification(FrameNotifyOnceAction pending_action);
private:
friend class base::RefCountedThreadSafe<CefBrowserInfo>;
@@ -173,17 +154,12 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
struct FrameInfo {
~FrameInfo();
inline bool IsCurrentMainFrame() const {
return frame_ && is_main_frame_ && !is_speculative_ && !is_in_bfcache_;
}
content::RenderFrameHost* host_;
int64_t frame_id_; // Combination of render_process_id + render_routing_id.
int frame_tree_node_id_;
bool is_guest_view_;
bool is_main_frame_;
bool is_speculative_;
bool is_in_bfcache_ = false;
CefRefPtr<CefFrameHostImpl> frame_;
};
@@ -193,17 +169,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
int frame_tree_node_id,
bool* is_guest_view = nullptr) const;
void SetMainFrame(CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> frame);
void MaybeNotifyFrameCreated(CefRefPtr<CefFrameHostImpl> frame);
void MaybeNotifyFrameDetached(CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> frame);
void MaybeNotifyMainFrameChanged(CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefFrameHostImpl> old_frame,
CefRefPtr<CefFrameHostImpl> new_frame);
void RemoveAllFrames(CefRefPtr<CefBrowserHostBase> old_browser);
void RemoveAllFrames();
int browser_id_;
bool is_popup_;
@@ -214,29 +180,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// Only accessed on the UI thread.
base::WeakPtr<NavigationLock> navigation_lock_;
// Used instead of |base::AutoLock(lock_)| in situations that might generate
// CefFrameHandler notifications. Any notifications passed to
// MaybeExecuteFrameNotification() will be queued until the lock is released,
// and then executed in order.
class NotificationStateLock final {
public:
explicit NotificationStateLock(CefBrowserInfo* browser_info);
~NotificationStateLock();
protected:
friend class CefBrowserInfo;
CefBrowserInfo* const browser_info_;
CefRefPtr<CefFrameHandler> frame_handler_;
std::unique_ptr<base::AutoLock> browser_info_lock_scope_;
std::queue<FrameNotifyOnceAction> queue_;
};
mutable base::Lock notification_lock_;
// These members must be protected by |notification_lock_|.
NotificationStateLock* notification_state_lock_ = nullptr;
CefRefPtr<CefFrameHandler> frame_handler_;
mutable base::Lock lock_;
// The below members must be protected by |lock_|.

View File

@@ -10,6 +10,7 @@
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/values_impl.h"
@@ -17,7 +18,6 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
@@ -95,9 +95,9 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
// Continue any pending NewBrowserInfo request.
auto it = pending_new_browser_info_map_.find(frame_id);
if (it != pending_new_browser_info_map_.end()) {
SendNewBrowserInfoResponse(
render_process_id, browser_info, /*is_guest_view=*/false,
std::move(it->second->callback), it->second->callback_runner);
SendNewBrowserInfoResponse(render_process_id, browser_info,
false /* is_guest_view */,
it->second->reply_msg);
pending_new_browser_info_map_.erase(it);
}
@@ -262,15 +262,12 @@ void CefBrowserInfoManager::WebContentsCreated(
extra_info = pending_popup->extra_info;
}
void CefBrowserInfoManager::OnGetNewBrowserInfo(
int render_process_id,
int render_routing_id,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) {
void CefBrowserInfoManager::OnGetNewBrowserInfo(int render_process_id,
int render_routing_id,
IPC::Message* reply_msg) {
DCHECK_NE(render_process_id, content::ChildProcessHost::kInvalidUniqueID);
DCHECK_GT(render_routing_id, 0);
DCHECK(callback);
auto callback_runner = base::SequencedTaskRunnerHandle::Get();
DCHECK(reply_msg);
base::AutoLock lock_scope(browser_info_lock_);
@@ -282,7 +279,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
if (browser_info.get()) {
// Send the response immediately.
SendNewBrowserInfoResponse(render_process_id, browser_info, is_guest_view,
std::move(callback), callback_runner);
reply_msg);
return;
}
@@ -300,8 +297,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
pending->render_process_id = render_process_id;
pending->render_routing_id = render_routing_id;
pending->timeout_id = timeout_id;
pending->callback = std::move(callback);
pending->callback_runner = callback_runner;
pending->reply_msg = reply_msg;
pending_new_browser_info_map_.insert(
std::make_pair(frame_id, std::move(pending)));
@@ -441,13 +437,11 @@ void CefBrowserInfoManager::RenderProcessHostDestroyed(
PendingNewBrowserInfoMap::iterator it =
pending_new_browser_info_map_.begin();
while (it != pending_new_browser_info_map_.end()) {
const auto& info = it->second;
if (info->render_process_id == render_process_id) {
CancelNewBrowserInfoResponse(info.get());
auto info = it->second.get();
if (info->render_process_id == render_process_id)
it = pending_new_browser_info_map_.erase(it);
} else {
else
++it;
}
}
}
@@ -528,47 +522,44 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
int render_process_id,
scoped_refptr<CefBrowserInfo> browser_info,
bool is_guest_view,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_runner) {
if (!callback_runner->RunsTasksInCurrentSequence()) {
callback_runner->PostTask(
FROM_HERE,
base::BindOnce(&CefBrowserInfoManager::SendNewBrowserInfoResponse,
render_process_id, browser_info, is_guest_view,
std::move(callback), callback_runner));
IPC::Message* reply_msg) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::Bind(&CefBrowserInfoManager::SendNewBrowserInfoResponse,
render_process_id, browser_info, is_guest_view, reply_msg));
return;
}
auto params = cef::mojom::NewBrowserInfo::New();
params->is_guest_view = is_guest_view;
content::RenderProcessHost* host =
content::RenderProcessHost::FromID(render_process_id);
if (!host) {
delete reply_msg;
return;
}
CefProcessHostMsg_GetNewBrowserInfo_Params params;
params.is_guest_view = is_guest_view;
if (browser_info) {
params->browser_id = browser_info->browser_id();
params->is_windowless = browser_info->is_windowless();
params->is_popup = browser_info->is_popup();
params.browser_id = browser_info->browser_id();
params.is_windowless = browser_info->is_windowless();
params.is_popup = browser_info->is_popup();
auto extra_info = browser_info->extra_info();
if (extra_info) {
auto extra_info_impl =
static_cast<CefDictionaryValueImpl*>(extra_info.get());
auto extra_info_value = base::WrapUnique(extra_info_impl->CopyValue());
params->extra_info = std::move(*extra_info_value);
auto extra_info_value = extra_info_impl->CopyValue();
extra_info_value->Swap(&params.extra_info);
}
} else {
// The new browser info response has timed out.
params->browser_id = -1;
params.browser_id = -1;
}
std::move(callback).Run(std::move(params));
}
// static
void CefBrowserInfoManager::CancelNewBrowserInfoResponse(
PendingNewBrowserInfo* pending_info) {
SendNewBrowserInfoResponse(pending_info->render_process_id,
/*browser_info=*/nullptr, /*is_guest_view=*/false,
std::move(pending_info->callback),
pending_info->callback_runner);
CefProcessHostMsg_GetNewBrowserInfo::WriteReplyParams(reply_msg, params);
host->Send(reply_msg);
}
// static
@@ -591,7 +582,9 @@ void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse(int64_t frame_id,
<< pending_info->render_process_id << " and routing id "
<< pending_info->render_routing_id;
CancelNewBrowserInfoResponse(pending_info.get());
SendNewBrowserInfoResponse(pending_info->render_process_id, nullptr,
false /* is_guest_view */,
pending_info->reply_msg);
g_info_manager->pending_new_browser_info_map_.erase(it);
}
}

View File

@@ -14,9 +14,7 @@
#include "libcef/browser/browser_info.h"
#include "base/sequenced_task_runner.h"
#include "base/synchronization/lock.h"
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "content/public/browser/render_process_host_observer.h"
#include "third_party/blink/public/mojom/window_features/window_features.mojom.h"
#include "ui/base/window_open_disposition.h"
@@ -35,6 +33,10 @@ class WebContents;
class WebContentsView;
} // namespace content
namespace IPC {
class Message;
}
class CefBrowserHostBase;
class CefBrowserPlatformDelegate;
@@ -95,17 +97,16 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
std::unique_ptr<CefBrowserPlatformDelegate>& platform_delegate,
CefRefPtr<CefDictionaryValue>& extra_info);
// Called from CefBrowserManager::GetNewBrowserInfo for delivering
// Called from CefBrowserMessageFilter::OnGetNewBrowserInfo for delivering
// browser info to the renderer process. If the browser info already exists
// the response will be sent immediately. Otherwise, the response will be sent
// when CreatePopupBrowserInfo creates the browser info. The info will already
// exist for explicitly created browsers and guest views. It may sometimes
// already exist for traditional popup browsers depending on timing. See
// comments on PendingPopup for more information.
void OnGetNewBrowserInfo(
int render_process_id,
int render_routing_id,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback);
void OnGetNewBrowserInfo(int render_process_id,
int render_routing_id,
IPC::Message* reply_msg);
// Called from CefBrowserHostBase::DestroyBrowser() when a browser is
// destroyed.
@@ -162,7 +163,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Creates the OSR views for windowless popups.
// - WebContentsCreated (UIT):
// Creates the CefBrowserHost representation for the popup.
// - CefBrowserManager::GetNewBrowserInfo (IOT)
// - CefBrowserMessageFilter::OnGetNewBrowserInfo (IOT)
// Passes information about the popup to the renderer process.
struct PendingPopup {
// Track the last method that modified this PendingPopup instance. There may
@@ -208,24 +209,19 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
int render_process_id,
scoped_refptr<CefBrowserInfo> browser_info,
bool is_guest_view,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_runner);
IPC::Message* reply_msg);
// Time out a response if it's still pending.
static void TimeoutNewBrowserInfoResponse(int64_t frame_id, int timeout_id);
// Pending request for OnGetNewBrowserInfo.
struct PendingNewBrowserInfo {
int render_process_id;
int render_routing_id;
int timeout_id;
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback;
scoped_refptr<base::SequencedTaskRunner> callback_runner;
IPC::Message* reply_msg;
};
// Cancel a response that is still pending.
static void CancelNewBrowserInfoResponse(PendingNewBrowserInfo* pending_info);
// Time out a response if it's still pending.
static void TimeoutNewBrowserInfoResponse(int64_t frame_id, int timeout_id);
mutable base::Lock browser_info_lock_;
// Access to the below members must be protected by |browser_info_lock_|.

View File

@@ -1,56 +0,0 @@
// Copyright 2021 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/browser_manager.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/origin_whitelist_impl.h"
#include "content/public/browser/render_process_host.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/service_manager/public/cpp/binder_registry.h"
CefBrowserManager::CefBrowserManager(int render_process_id)
: render_process_id_(render_process_id) {}
CefBrowserManager::~CefBrowserManager() = default;
// static
void CefBrowserManager::ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* host) {
registry->AddInterface(base::BindRepeating(
[](int render_process_id,
mojo::PendingReceiver<cef::mojom::BrowserManager> receiver) {
mojo::MakeSelfOwnedReceiver(
std::make_unique<CefBrowserManager>(render_process_id),
std::move(receiver));
},
host->GetID()));
}
// static
mojo::Remote<cef::mojom::RenderManager>
CefBrowserManager::GetRenderManagerForProcess(
content::RenderProcessHost* host) {
mojo::Remote<cef::mojom::RenderManager> client;
host->BindReceiver(client.BindNewPipeAndPassReceiver());
return client;
}
void CefBrowserManager::GetNewRenderThreadInfo(
cef::mojom::BrowserManager::GetNewRenderThreadInfoCallback callback) {
auto info = cef::mojom::NewRenderThreadInfo::New();
GetCrossOriginWhitelistEntries(&info->cross_origin_whitelist_entries);
std::move(callback).Run(std::move(info));
}
void CefBrowserManager::GetNewBrowserInfo(
int32_t render_frame_routing_id,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) {
CefBrowserInfoManager::GetInstance()->OnGetNewBrowserInfo(
render_process_id_, render_frame_routing_id, std::move(callback));
}

View File

@@ -1,54 +0,0 @@
// Copyright 2021 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_BROWSER_MANAGER_H_
#define CEF_LIBCEF_BROWSER_BROWSER_MANAGER_H_
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/binder_registry.h"
namespace blink {
class AssociatedInterfaceRegistry;
}
namespace content {
class RenderProcessHost;
}
class CefBrowserManager : public cef::mojom::BrowserManager {
public:
explicit CefBrowserManager(int render_process_id);
~CefBrowserManager() override;
// Called from the ContentBrowserClient method of the same name.
// |associated_registry| is used for interfaces which must be associated with
// some IPC::ChannelProxy, meaning that messages on the interface retain FIFO
// with respect to legacy Chrome IPC messages sent or dispatched on the
// channel.
static void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* host);
// Connects to CefRenderManager in the render process.
static mojo::Remote<cef::mojom::RenderManager> GetRenderManagerForProcess(
content::RenderProcessHost* host);
private:
// cef::mojom::BrowserManager methods:
void GetNewRenderThreadInfo(
cef::mojom::BrowserManager::GetNewRenderThreadInfoCallback callback)
override;
void GetNewBrowserInfo(
int32_t render_frame_routing_id,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) override;
// The process ID of the renderer.
const int render_process_id_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserManager);
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_MANAGER_H_

View File

@@ -0,0 +1,55 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/browser_message_filter.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/origin_whitelist_impl.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/values_impl.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "content/public/common/child_process_host.h"
CefBrowserMessageFilter::CefBrowserMessageFilter(int render_process_id)
: content::BrowserMessageFilter(ExtensionMsgStart),
render_process_id_(render_process_id) {}
CefBrowserMessageFilter::~CefBrowserMessageFilter() {}
void CefBrowserMessageFilter::OnFilterRemoved() {
render_process_id_ = content::ChildProcessHost::kInvalidUniqueID;
content::BrowserMessageFilter::OnFilterRemoved();
}
bool CefBrowserMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(CefBrowserMessageFilter, message)
IPC_MESSAGE_HANDLER(CefProcessHostMsg_GetNewRenderThreadInfo,
OnGetNewRenderThreadInfo)
IPC_MESSAGE_HANDLER_DELAY_REPLY(CefProcessHostMsg_GetNewBrowserInfo,
OnGetNewBrowserInfo)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void CefBrowserMessageFilter::OnGetNewRenderThreadInfo(
CefProcessHostMsg_GetNewRenderThreadInfo_Params* params) {
GetCrossOriginWhitelistEntries(&params->cross_origin_whitelist_entries);
}
void CefBrowserMessageFilter::OnGetNewBrowserInfo(int render_frame_routing_id,
IPC::Message* reply_msg) {
if (render_process_id_ != content::ChildProcessHost::kInvalidUniqueID) {
CefBrowserInfoManager::GetInstance()->OnGetNewBrowserInfo(
render_process_id_, render_frame_routing_id, reply_msg);
} else {
delete reply_msg;
}
}

View File

@@ -0,0 +1,40 @@
// Copyright (c) 2012 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_BROWSER_MESSAGE_FILTER_H_
#define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_FILTER_H_
#include <stdint.h>
#include <string>
#include "content/public/browser/browser_message_filter.h"
struct CefProcessHostMsg_GetNewBrowserInfo_Params;
struct CefProcessHostMsg_GetNewRenderThreadInfo_Params;
// This class sends and receives control messages on the browser process.
class CefBrowserMessageFilter : public content::BrowserMessageFilter {
public:
explicit CefBrowserMessageFilter(int render_process_id);
~CefBrowserMessageFilter() override;
// IPC::ChannelProxy::MessageFilter implementation.
void OnFilterRemoved() override;
bool OnMessageReceived(const IPC::Message& message) override;
private:
// Message handlers.
void OnGetNewRenderThreadInfo(
CefProcessHostMsg_GetNewRenderThreadInfo_Params* params);
void OnGetNewBrowserInfo(int render_frame_routing_id,
IPC::Message* reply_msg);
int render_process_id_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserMessageFilter);
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_FILTER_H_

View File

@@ -76,7 +76,7 @@ void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostBase* browser) {
void CefBrowserPlatformDelegate::CreateExtensionHost(
const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type) {
extensions::ViewType host_type) {
NOTREACHED();
}

View File

@@ -15,7 +15,7 @@
#include "include/views/cef_browser_view.h"
#include "base/callback_forward.h"
#include "extensions/common/mojom/view_type.mojom-forward.h"
#include "extensions/common/view_type.h"
#include "third_party/blink/public/common/page/drag_operation.h"
#include "third_party/blink/public/mojom/page/drag.mojom-forward.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -134,7 +134,7 @@ class CefBrowserPlatformDelegate {
// Called from AlloyBrowserHostImpl::Create.
virtual void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type);
extensions::ViewType host_type);
// Returns the current extension host.
virtual extensions::ExtensionHost* GetExtensionHost() const;

View File

@@ -115,7 +115,7 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
}
return std::move(native_delegate);
} else if (create_params.extension_host_type ==
extensions::mojom::ViewType::kExtensionBackgroundPage) {
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
// Creating a background extension host without a window.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo(), background_color);

View File

@@ -6,11 +6,8 @@
#include "libcef/browser/thread_util.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/off_the_record_profile_impl.h"
#include "chrome/browser/profiles/profile_keep_alive_types.h"
#include "chrome/browser/profiles/scoped_profile_keep_alive.h"
ChromeBrowserContext::ChromeBrowserContext(
const CefRequestContextSettings& settings)
@@ -19,18 +16,15 @@ ChromeBrowserContext::ChromeBrowserContext(
ChromeBrowserContext::~ChromeBrowserContext() = default;
content::BrowserContext* ChromeBrowserContext::AsBrowserContext() {
CHECK(!destroyed_);
return profile_;
}
Profile* ChromeBrowserContext::AsProfile() {
CHECK(!destroyed_);
return profile_;
}
bool ChromeBrowserContext::IsInitialized() const {
CEF_REQUIRE_UIT();
CHECK(!destroyed_);
return !!profile_;
}
@@ -63,8 +57,9 @@ void ChromeBrowserContext::InitializeAsync(base::OnceClosure initialized_cb) {
// synchronously or asynchronously.
profile_manager->CreateProfileAsync(
cache_path_,
base::BindRepeating(&ChromeBrowserContext::ProfileCreated,
weak_ptr_factory_.GetWeakPtr()));
base::Bind(&ChromeBrowserContext::ProfileCreated,
weak_ptr_factory_.GetWeakPtr()),
/*name=*/base::string16(), /*icon_url=*/std::string());
return;
} else {
// All profile directories must be relative to |user_data_dir|.
@@ -79,21 +74,13 @@ void ChromeBrowserContext::InitializeAsync(base::OnceClosure initialized_cb) {
void ChromeBrowserContext::Shutdown() {
CefBrowserContext::Shutdown();
// Allow potential deletion of the Profile at some future point (controlled
// by ProfileManager).
profile_keep_alive_.reset();
// |g_browser_process| may be nullptr during shutdown.
if (g_browser_process) {
if (should_destroy_) {
g_browser_process->profile_manager()
->GetPrimaryUserProfile()
->DestroyOffTheRecordProfile(profile_);
} else if (profile_) {
OnProfileWillBeDestroyed(profile_);
}
if (should_destroy_ && g_browser_process) {
g_browser_process->profile_manager()
->GetPrimaryUserProfile()
->DestroyOffTheRecordProfile(profile_);
}
profile_ = nullptr;
}
void ChromeBrowserContext::ProfileCreated(Profile* profile,
@@ -106,16 +93,12 @@ void ChromeBrowserContext::ProfileCreated(Profile* profile,
CHECK(!profile);
CHECK(!profile_);
// Profile creation may access the filesystem.
base::ScopedAllowBlockingForTesting allow_blocking;
// Creation of a disk-based profile failed for some reason. Create a
// new/unique OffTheRecord profile instead.
const auto& profile_id = Profile::OTRProfileID::CreateUniqueForCEF();
parent_profile =
g_browser_process->profile_manager()->GetPrimaryUserProfile();
profile_ = parent_profile->GetOffTheRecordProfile(
profile_id, /*create_if_needed=*/true);
profile_ = parent_profile->GetOffTheRecordProfile(profile_id);
otr_profile = static_cast<OffTheRecordProfileImpl*>(profile_);
status = Profile::CreateStatus::CREATE_STATUS_INITIALIZED;
should_destroy_ = true;
@@ -124,9 +107,6 @@ void ChromeBrowserContext::ProfileCreated(Profile* profile,
// *CREATED isn't always sent for a disk-based profile that already
// exists.
profile_ = profile;
profile_->AddObserver(this);
profile_keep_alive_.reset(new ScopedProfileKeepAlive(
profile_, ProfileKeepAliveOrigin::kAppWindow));
}
if (status == Profile::CreateStatus::CREATE_STATUS_INITIALIZED) {
@@ -148,10 +128,3 @@ void ChromeBrowserContext::ProfileCreated(Profile* profile,
}
}
}
void ChromeBrowserContext::OnProfileWillBeDestroyed(Profile* profile) {
CHECK_EQ(profile_, profile);
profile_->RemoveObserver(this);
profile_ = nullptr;
destroyed_ = true;
}

View File

@@ -10,13 +10,10 @@
#include "base/memory/weak_ptr.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_observer.h"
class ScopedProfileKeepAlive;
// See CefBrowserContext documentation for usage. Only accessed on the UI thread
// unless otherwise indicated.
class ChromeBrowserContext : public CefBrowserContext, public ProfileObserver {
class ChromeBrowserContext : public CefBrowserContext {
public:
explicit ChromeBrowserContext(const CefRequestContextSettings& settings);
@@ -29,9 +26,6 @@ class ChromeBrowserContext : public CefBrowserContext, public ProfileObserver {
void StoreOrTriggerInitCallback(base::OnceClosure callback) override;
void Shutdown() override;
// ProfileObserver overrides.
void OnProfileWillBeDestroyed(Profile* profile) override;
private:
~ChromeBrowserContext() override;
@@ -41,9 +35,6 @@ class ChromeBrowserContext : public CefBrowserContext, public ProfileObserver {
Profile* profile_ = nullptr;
bool should_destroy_ = false;
bool destroyed_ = false;
std::unique_ptr<ScopedProfileKeepAlive> profile_keep_alive_;
std::vector<base::OnceClosure> init_callbacks_;
base::WeakPtrFactory<ChromeBrowserContext> weak_ptr_factory_;

View File

@@ -156,9 +156,9 @@ void ChromeBrowserDelegate::UpdateTargetURL(content::WebContents* source,
bool ChromeBrowserDelegate::DidAddMessageToConsole(
content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) {
const base::string16& source_id) {
if (auto delegate = GetDelegateForWebContents(source)) {
return delegate->DidAddMessageToConsole(source, log_level, message, line_no,
source_id);

View File

@@ -12,7 +12,7 @@
#include "libcef/browser/browser_info.h"
#include "libcef/browser/chrome/browser_delegate.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "base/optional.h"
class CefBrowserContentsDelegate;
class CefRequestContextImpl;
@@ -70,9 +70,9 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
bool DidAddMessageToConsole(content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
const base::string16& message,
int32_t line_no,
const std::u16string& source_id) override;
const base::string16& source_id) override;
void DidNavigateMainFramePostCommit(
content::WebContents* web_contents) override;
void EnterFullscreenModeForTab(

View File

@@ -9,7 +9,6 @@
#include "libcef/browser/net/chrome_scheme_handler.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
ChromeBrowserMainExtraPartsCef::ChromeBrowserMainExtraPartsCef() = default;
@@ -25,14 +24,14 @@ void ChromeBrowserMainExtraPartsCef::PostProfileInit() {
}
void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
background_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::BEST_EFFORT,
background_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_visible_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::USER_VISIBLE,
user_visible_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_blocking_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::USER_BLOCKING,
user_blocking_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
scheme::RegisterWebUIControllerFactory();

View File

@@ -5,9 +5,8 @@
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
#include "libcef/browser/browser_frame.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_manager.h"
#include "libcef/browser/browser_message_filter.h"
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
#include "libcef/browser/context.h"
@@ -42,15 +41,13 @@ namespace {
void HandleExternalProtocolHelper(
ChromeContentBrowserClientCef* self,
content::WebContents::OnceGetter web_contents_getter,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
const network::ResourceRequest& resource_request) {
// Match the logic of the original call in
// NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
self->HandleExternalProtocol(
resource_request.url, std::move(web_contents_getter),
content::ChildProcessHost::kInvalidUniqueID, frame_tree_node_id,
navigation_data,
content::ChildProcessHost::kInvalidUniqueID, navigation_data,
resource_request.resource_type ==
static_cast<int>(blink::mojom::ResourceType::kMainFrame),
static_cast<ui::PageTransition>(resource_request.transition_type),
@@ -123,7 +120,7 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
CefRefPtr<CefCommandLineImpl> commandLinePtr(
new CefCommandLineImpl(command_line, false, false));
handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
ignore_result(commandLinePtr->Detach(nullptr));
commandLinePtr->Detach(nullptr);
}
}
}
@@ -132,6 +129,9 @@ void ChromeContentBrowserClientCef::RenderProcessWillLaunch(
content::RenderProcessHost* host) {
ChromeContentBrowserClient::RenderProcessWillLaunch(host);
const int id = host->GetID();
host->AddFilter(new CefBrowserMessageFilter(id));
// If the renderer process crashes then the host may already have
// CefBrowserInfoManager as an observer. Try to remove it first before adding
// to avoid DCHECKs.
@@ -199,7 +199,7 @@ bool ChromeContentBrowserClientCef::WillCreateURLLoaderFactory(
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
base::Optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -238,12 +238,11 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
const GURL& url,
content::WebContents::OnceGetter web_contents_getter,
int child_id,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
// |out_factory| will be non-nullptr when this method is initially called
// from NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
@@ -256,9 +255,9 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
// HandleExternalProtocolHelper. Forward to the chrome layer for default
// handling.
return ChromeContentBrowserClient::HandleExternalProtocol(
url, std::move(web_contents_getter), child_id, frame_tree_node_id,
navigation_data, is_main_frame, page_transition, has_user_gesture,
initiating_origin, nullptr);
url, std::move(web_contents_getter), child_id, navigation_data,
is_main_frame, page_transition, has_user_gesture, initiating_origin,
nullptr);
}
bool ChromeContentBrowserClientCef::HandleExternalProtocol(
@@ -273,9 +272,8 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
// HandleExternalProtocolHelper may be called if nothing handles the request.
auto request_handler = net_service::CreateInterceptedRequestHandler(
web_contents_getter, frame_tree_node_id, resource_request,
base::BindRepeating(HandleExternalProtocolHelper, base::Unretained(this),
web_contents_getter, frame_tree_node_id,
navigation_data, resource_request));
base::Bind(HandleExternalProtocolHelper, base::Unretained(this),
web_contents_getter, navigation_data, resource_request));
net_service::ProxyURLLoaderFactory::CreateProxy(
web_contents_getter, std::move(receiver), std::move(request_handler));
@@ -355,27 +353,6 @@ bool ChromeContentBrowserClientCef::IsWebUIAllowedToMakeNetworkRequests(
return scheme::IsWebUIAllowedToMakeNetworkRequests(origin);
}
void ChromeContentBrowserClientCef::ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* host) {
ChromeContentBrowserClient::ExposeInterfacesToRenderer(
registry, associated_registry, host);
CefBrowserManager::ExposeInterfacesToRenderer(registry, associated_registry,
host);
}
void ChromeContentBrowserClientCef::RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) {
ChromeContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
render_frame_host, map);
CefBrowserFrame::RegisterBrowserInterfaceBindersForFrame(render_frame_host,
map);
}
CefRefPtr<CefRequestContextImpl>
ChromeContentBrowserClientCef::request_context() const {
return browser_main_parts_->request_context();

View File

@@ -48,7 +48,7 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
base::Optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -60,12 +60,11 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
const GURL& url,
content::WebContents::OnceGetter web_contents_getter,
int child_id,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
bool HandleExternalProtocol(
@@ -96,13 +95,6 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
LoginAuthRequiredCallback auth_required_callback) override;
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) override;
void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* render_process_host) override;
void RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override;
CefRefPtr<CefRequestContextImpl> request_context() const;

View File

@@ -111,7 +111,7 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
}
void SetAccelerator(int command_id,
absl::optional<ui::Accelerator> accel) override {
base::Optional<ui::Accelerator> accel) override {
// No-op if already at the default state.
if (!accel && !GetItemInfo(command_id))
return;
@@ -127,7 +127,7 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
ItemInfo() {}
bool checked = false;
absl::optional<ui::Accelerator> accel;
base::Optional<ui::Accelerator> accel;
};
ItemInfo* GetItemInfo(int command_id) {

View File

@@ -74,7 +74,7 @@ ToolbarView* ChromeBrowserView::OverrideCreateToolbar(
BrowserView* browser_view) {
if (cef_delegate()) {
auto toolbar_type = cef_delegate()->GetChromeToolbarType();
absl::optional<ToolbarView::DisplayMode> display_mode;
base::Optional<ToolbarView::DisplayMode> display_mode;
switch (toolbar_type) {
case CEF_CTT_NORMAL:
display_mode = ToolbarView::DisplayMode::NORMAL;

View File

@@ -9,7 +9,7 @@ CefRefPtr<CefToolbarViewImpl> CefToolbarViewImpl::Create(
CefRefPtr<CefViewDelegate> delegate,
Browser* browser,
BrowserView* browser_view,
absl::optional<ToolbarView::DisplayMode> display_mode) {
base::Optional<ToolbarView::DisplayMode> display_mode) {
CEF_REQUIRE_UIT_RETURN(nullptr);
CefRefPtr<CefToolbarViewImpl> view =
new CefToolbarViewImpl(delegate, browser, browser_view, display_mode);
@@ -24,7 +24,7 @@ CefToolbarViewImpl::CefToolbarViewImpl(
CefRefPtr<CefViewDelegate> delegate,
Browser* browser,
BrowserView* browser_view,
absl::optional<ToolbarView::DisplayMode> display_mode)
base::Optional<ToolbarView::DisplayMode> display_mode)
: ParentClass(delegate),
browser_(browser),
browser_view_(browser_view),

View File

@@ -24,7 +24,7 @@ class CefToolbarViewImpl
CefRefPtr<CefViewDelegate> delegate,
Browser* browser,
BrowserView* browser_view,
absl::optional<ToolbarView::DisplayMode> display_mode);
base::Optional<ToolbarView::DisplayMode> display_mode);
static const char* const kTypeString;
@@ -38,7 +38,7 @@ class CefToolbarViewImpl
CefToolbarViewImpl(CefRefPtr<CefViewDelegate> delegate,
Browser* browser,
BrowserView* browser_view,
absl::optional<ToolbarView::DisplayMode> display_mode);
base::Optional<ToolbarView::DisplayMode> display_mode);
// CefViewImpl methods:
CefToolbarViewView* CreateRootView() override;
@@ -46,7 +46,7 @@ class CefToolbarViewImpl
Browser* const browser_;
BrowserView* const browser_view_;
absl::optional<ToolbarView::DisplayMode> const display_mode_;
base::Optional<ToolbarView::DisplayMode> const display_mode_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefToolbarViewImpl);
DISALLOW_COPY_AND_ASSIGN(CefToolbarViewImpl);

View File

@@ -7,5 +7,5 @@
CefToolbarViewView::CefToolbarViewView(CefViewDelegate* cef_delegate,
Browser* browser,
BrowserView* browser_view,
absl::optional<DisplayMode> display_mode)
base::Optional<DisplayMode> display_mode)
: ParentClass(cef_delegate, browser, browser_view, display_mode) {}

View File

@@ -18,7 +18,7 @@ class CefToolbarViewView : public CefViewView<ToolbarView, CefViewDelegate> {
explicit CefToolbarViewView(CefViewDelegate* cef_delegate,
Browser* browser,
BrowserView* browser_view,
absl::optional<DisplayMode> display_mode);
base::Optional<DisplayMode> display_mode);
private:
DISALLOW_COPY_AND_ASSIGN(CefToolbarViewView);

View File

@@ -294,12 +294,10 @@ void CefSetOSModalLoop(bool osModalLoop) {
return;
}
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(CefSetOSModalLoop, osModalLoop));
return;
}
base::CurrentThread::Get()->set_os_modal_loop(osModalLoop);
if (CEF_CURRENTLY_ON_UIT())
base::CurrentThread::Get()->set_os_modal_loop(osModalLoop);
else
CEF_POST_TASK(CEF_UIT, base::Bind(CefSetOSModalLoop, osModalLoop));
#endif // defined(OS_WIN)
}

View File

@@ -119,7 +119,7 @@ bool CefContextMenuParamsImpl::GetDictionarySuggestions(
if (const_value().dictionary_suggestions.empty())
return false;
std::vector<std::u16string>::const_iterator it =
std::vector<base::string16>::const_iterator it =
const_value().dictionary_suggestions.begin();
for (; it != const_value().dictionary_suggestions.end(); ++it)
suggestions.push_back(*it);

View File

@@ -91,7 +91,7 @@ void CefDevToolsController::RemoveObserver(Observer* observer) {
void CefDevToolsController::DispatchProtocolMessage(
content::DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) {
if (observers_.empty())
if (!observers_.might_have_observers())
return;
base::StringPiece str_message(reinterpret_cast<const char*>(message.data()),

View File

@@ -15,7 +15,6 @@
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/util/values/values_util.h"
#include "base/values.h"
@@ -35,7 +34,7 @@ void WriteToFile(const base::FilePath& path, const std::string& content) {
void AppendToFile(const base::FilePath& path, const std::string& content) {
DCHECK(!path.empty());
base::AppendToFile(path, base::StringPiece(content));
base::AppendToFile(path, content.c_str(), content.size());
}
} // namespace
@@ -45,35 +44,35 @@ CefDevToolsFileManager::CefDevToolsFileManager(
PrefService* prefs)
: browser_impl_(browser_impl),
prefs_(prefs),
file_task_runner_(
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})),
file_task_runner_(base::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock()})),
weak_factory_(this) {}
void CefDevToolsFileManager::SaveToFile(const std::string& url,
const std::string& content,
bool save_as) {
Save(url, content, save_as,
base::BindOnce(&CefDevToolsFileManager::FileSavedAs,
weak_factory_.GetWeakPtr(), url),
base::BindOnce(&CefDevToolsFileManager::CanceledFileSaveAs,
weak_factory_.GetWeakPtr(), url));
base::Bind(&CefDevToolsFileManager::FileSavedAs,
weak_factory_.GetWeakPtr(), url),
base::Bind(&CefDevToolsFileManager::CanceledFileSaveAs,
weak_factory_.GetWeakPtr(), url));
}
void CefDevToolsFileManager::AppendToFile(const std::string& url,
const std::string& content) {
Append(url, content,
base::BindOnce(&CefDevToolsFileManager::AppendedTo,
weak_factory_.GetWeakPtr(), url));
base::Bind(&CefDevToolsFileManager::AppendedTo,
weak_factory_.GetWeakPtr(), url));
}
void CefDevToolsFileManager::Save(const std::string& url,
const std::string& content,
bool save_as,
SaveCallback saveCallback,
CancelCallback cancelCallback) {
const SaveCallback& saveCallback,
const CancelCallback& cancelCallback) {
auto it = saved_files_.find(url);
if (it != saved_files_.end() && !save_as) {
SaveAsFileSelected(url, content, std::move(saveCallback), it->second);
SaveAsFileSelected(url, content, saveCallback, it->second);
return;
}
@@ -83,7 +82,7 @@ void CefDevToolsFileManager::Save(const std::string& url,
const base::Value* path_value;
if (file_map->Get(base::MD5String(url), &path_value)) {
absl::optional<base::FilePath> path = util::ValueToFilePath(*path_value);
base::Optional<base::FilePath> path = util::ValueToFilePath(*path_value);
if (path)
initial_path = std::move(*path);
}
@@ -116,29 +115,28 @@ void CefDevToolsFileManager::Save(const std::string& url,
}
browser_impl_->RunFileChooser(
params,
base::BindOnce(&CefDevToolsFileManager::SaveAsDialogDismissed,
weak_factory_.GetWeakPtr(), url, content,
std::move(saveCallback), std::move(cancelCallback)));
params, base::Bind(&CefDevToolsFileManager::SaveAsDialogDismissed,
weak_factory_.GetWeakPtr(), url, content, saveCallback,
cancelCallback));
}
void CefDevToolsFileManager::SaveAsDialogDismissed(
const std::string& url,
const std::string& content,
SaveCallback saveCallback,
CancelCallback cancelCallback,
const SaveCallback& saveCallback,
const CancelCallback& cancelCallback,
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths) {
if (file_paths.size() == 1) {
SaveAsFileSelected(url, content, std::move(saveCallback), file_paths[0]);
SaveAsFileSelected(url, content, saveCallback, file_paths[0]);
} else {
std::move(cancelCallback).Run();
cancelCallback.Run();
}
}
void CefDevToolsFileManager::SaveAsFileSelected(const std::string& url,
const std::string& content,
SaveCallback callback,
const SaveCallback& callback,
const base::FilePath& path) {
*g_last_save_path.Pointer() = path;
saved_files_[url] = path;
@@ -147,7 +145,7 @@ void CefDevToolsFileManager::SaveAsFileSelected(const std::string& url,
base::DictionaryValue* files_map = update.Get();
files_map->SetKey(base::MD5String(url), util::FilePathToValue(path));
std::string file_system_path = path.AsUTF8Unsafe();
std::move(callback).Run(file_system_path);
callback.Run(file_system_path);
file_task_runner_->PostTask(FROM_HERE,
base::BindOnce(&::WriteToFile, path, content));
}
@@ -168,11 +166,11 @@ void CefDevToolsFileManager::CanceledFileSaveAs(const std::string& url) {
void CefDevToolsFileManager::Append(const std::string& url,
const std::string& content,
AppendCallback callback) {
const AppendCallback& callback) {
auto it = saved_files_.find(url);
if (it == saved_files_.end())
return;
std::move(callback).Run();
callback.Run();
file_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&::AppendToFile, it->second, content));
}

View File

@@ -36,31 +36,31 @@ class CefDevToolsFileManager {
private:
// SaveToFile implementation:
typedef base::OnceCallback<void(const std::string&)> SaveCallback;
typedef base::OnceCallback<void()> CancelCallback;
typedef base::Callback<void(const std::string&)> SaveCallback;
typedef base::Callback<void()> CancelCallback;
void Save(const std::string& url,
const std::string& content,
bool save_as,
SaveCallback saveCallback,
CancelCallback cancelCallback);
const SaveCallback& saveCallback,
const CancelCallback& cancelCallback);
void SaveAsDialogDismissed(const std::string& url,
const std::string& content,
SaveCallback saveCallback,
CancelCallback cancelCallback,
const SaveCallback& saveCallback,
const CancelCallback& cancelCallback,
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths);
void SaveAsFileSelected(const std::string& url,
const std::string& content,
SaveCallback callback,
const SaveCallback& callback,
const base::FilePath& path);
void FileSavedAs(const std::string& url, const std::string& file_system_path);
void CanceledFileSaveAs(const std::string& url);
// AppendToFile implementation:
typedef base::OnceCallback<void(void)> AppendCallback;
typedef base::Callback<void(void)> AppendCallback;
void Append(const std::string& url,
const std::string& content,
AppendCallback callback);
const AppendCallback& callback);
void AppendedTo(const std::string& url);
void CallClientFunction(const std::string& function_name,

View File

@@ -160,7 +160,7 @@ void LogProtocolMessage(const base::FilePath& log_file,
WriteTimestamp(stream);
stream << ": " << type_label << ": " << to_log << "\n";
const std::string& str = stream.str();
if (!base::AppendToFile(log_file, base::StringPiece(str))) {
if (!base::AppendToFile(log_file, str.c_str(), str.size())) {
LOG(ERROR) << "Failed to write file " << log_file.value();
log_error = true;
}
@@ -294,8 +294,8 @@ void CefDevToolsFrontend::InspectElementAt(int x, int y) {
void CefDevToolsFrontend::Close() {
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&AlloyBrowserHostImpl::CloseBrowser,
frontend_browser_.get(), true));
base::Bind(&AlloyBrowserHostImpl::CloseBrowser,
frontend_browser_.get(), true));
}
CefDevToolsFrontend::CefDevToolsFrontend(
@@ -323,8 +323,8 @@ void CefDevToolsFrontend::ReadyToCommitNavigation(
content::RenderFrameHost* frame = navigation_handle->GetRenderFrameHost();
if (navigation_handle->IsInMainFrame()) {
frontend_host_ = content::DevToolsFrontendHost::Create(
frame, base::BindRepeating(
&CefDevToolsFrontend::HandleMessageFromDevToolsFrontend,
frame,
base::Bind(&CefDevToolsFrontend::HandleMessageFromDevToolsFrontend,
base::Unretained(this)));
return;
}
@@ -338,8 +338,7 @@ void CefDevToolsFrontend::ReadyToCommitNavigation(
content::DevToolsFrontendHost::SetupExtensionsAPI(frame, script);
}
void CefDevToolsFrontend::DocumentAvailableInMainFrame(
content::RenderFrameHost* render_frame_host) {
void CefDevToolsFrontend::DocumentAvailableInMainFrame() {
// Don't call AttachClient multiple times for the same DevToolsAgentHost.
// Otherwise it will call AgentHostClosed which closes the DevTools window.
// This may happen in cases where the DevTools content fails to load.
@@ -367,11 +366,13 @@ void CefDevToolsFrontend::WebContentsDestroyed() {
}
void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
base::Value message) {
const std::string& message) {
std::string method;
base::ListValue* params = nullptr;
base::DictionaryValue* dict = nullptr;
if (!message.GetAsDictionary(&dict) || !dict->GetString("method", &method)) {
base::Optional<base::Value> parsed_message = base::JSONReader::Read(message);
if (!parsed_message || !parsed_message->GetAsDictionary(&dict) ||
!dict->GetString("method", &method)) {
return;
}
int request_id = 0;
@@ -389,7 +390,8 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
this, base::as_bytes(base::make_span(protocol_message)));
} else if (method == "loadCompleted") {
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
u"DevToolsAPI.setUseSoftMenu(true);", base::NullCallback());
base::ASCIIToUTF16("DevToolsAPI.setUseSoftMenu(true);"),
base::NullCallback());
} else if (method == "loadNetworkResource" && params->GetSize() == 3) {
// TODO(pfeldman): handle some of the embedder messages in content.
std::string url;
@@ -459,8 +461,8 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
SendMessageAck(request_id, &response);
return;
} else {
auto* partition =
web_contents()->GetBrowserContext()->GetStoragePartitionForUrl(gurl);
auto* partition = content::BrowserContext::GetStoragePartitionForSite(
web_contents()->GetBrowserContext(), gurl);
url_loader_factory = partition->GetURLLoaderFactoryForBrowserProcess();
}
@@ -491,7 +493,8 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
update.Get()->RemoveWithoutPathExpansion(name, nullptr);
} else if (method == "requestFileSystems") {
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
u"DevToolsAPI.fileSystemsLoaded([]);", base::NullCallback());
base::ASCIIToUTF16("DevToolsAPI.fileSystemsLoaded([]);"),
base::NullCallback());
} else if (method == "reattach") {
if (!agent_host_)
return;
@@ -549,7 +552,7 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
std::string param;
base::EscapeJSONString(str_message, true, &param);
std::string code = "DevToolsAPI.dispatchMessage(" + param + ");";
std::u16string javascript = base::UTF8ToUTF16(code);
base::string16 javascript = base::UTF8ToUTF16(code);
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
javascript, base::NullCallback());
return;
@@ -563,7 +566,7 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
&param);
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," +
std::to_string(pos ? 0 : total_size) + ");";
std::u16string javascript = base::UTF8ToUTF16(code);
base::string16 javascript = base::UTF8ToUTF16(code);
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
javascript, base::NullCallback());
}
@@ -606,7 +609,7 @@ void CefDevToolsFrontend::LogProtocolMessage(ProtocolMessageType type,
const base::StringPiece& message) {
DCHECK(ProtocolLoggingEnabled());
std::string to_log(message.substr(0, kMaxLogLineLength));
std::string to_log = message.substr(0, kMaxLogLineLength).as_string();
// Execute in an ordered context that allows blocking.
auto task_runner = CefTaskRunnerManager::Get()->GetBackgroundTaskRunner();

View File

@@ -70,14 +70,13 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
void AgentHostClosed(content::DevToolsAgentHost* agent_host) override;
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) override;
void HandleMessageFromDevToolsFrontend(base::Value message);
void HandleMessageFromDevToolsFrontend(const std::string& message);
private:
// WebContentsObserver overrides
void ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) override;
void DocumentAvailableInMainFrame(
content::RenderFrameHost* render_frame_host) override;
void DocumentAvailableInMainFrame() override;
void WebContentsDestroyed() override;
void SendMessageAck(int request_id, const base::Value* arg1);

View File

@@ -62,7 +62,7 @@ class CefDevToolsRegistrationImpl : public CefRegistration,
void OnDevToolsEvent(const base::StringPiece& method,
const base::StringPiece& params) override {
CEF_REQUIRE_UIT();
observer_->OnDevToolsEvent(browser_, std::string(method), params.data(),
observer_->OnDevToolsEvent(browser_, method.as_string(), params.data(),
params.size());
}

View File

@@ -83,7 +83,7 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsEvent) {
EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsEvent());
EXPECT_STREQ("Test.myMethod", parser.method_.data());
EXPECT_STREQ("Test.myMethod", parser.method_.as_string().data());
EXPECT_TRUE(parser.params_.empty());
parser.Reset();
@@ -94,8 +94,8 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsEvent) {
EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsEvent());
EXPECT_STREQ("Test.myMethod2", parser.method_.data());
EXPECT_STREQ("{}", parser.params_.data());
EXPECT_STREQ("Test.myMethod2", parser.method_.as_string().data());
EXPECT_STREQ("{}", parser.params_.as_string().data());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
@@ -105,8 +105,8 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsEvent) {
EXPECT_TRUE(parser.Initialize(message));
EXPECT_TRUE(parser.IsInitialized());
EXPECT_TRUE(parser.IsEvent());
EXPECT_STREQ("Test.myMethod3", parser.method_.data());
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.data());
EXPECT_STREQ("Test.myMethod3", parser.method_.as_string().data());
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.as_string().data());
}
TEST(DevToolsUtil, ProtocolParser_Initialize_IsFailure_ResultMalformed) {
@@ -162,7 +162,7 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Result) {
EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(1, parser.message_id_);
EXPECT_TRUE(parser.success_);
EXPECT_STREQ("{}", parser.params_.data());
EXPECT_STREQ("{}", parser.params_.as_string().data());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
@@ -174,7 +174,7 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Result) {
EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(2, parser.message_id_);
EXPECT_TRUE(parser.success_);
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.data());
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.as_string().data());
}
TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Error) {
@@ -188,7 +188,7 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Error) {
EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(1, parser.message_id_);
EXPECT_FALSE(parser.success_);
EXPECT_STREQ("{}", parser.params_.data());
EXPECT_STREQ("{}", parser.params_.as_string().data());
parser.Reset();
EXPECT_FALSE(parser.IsInitialized());
@@ -200,5 +200,5 @@ TEST(DevToolsUtil, ProtocolParser_Initialize_IsResult_Error) {
EXPECT_TRUE(parser.IsResult());
EXPECT_EQ(2, parser.message_id_);
EXPECT_FALSE(parser.success_);
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.data());
EXPECT_STREQ("{\"foo\":\"bar\"}", parser.params_.as_string().data());
}

View File

@@ -153,7 +153,7 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::MixedContentStatus::UNKNOWN, suggested_path,
absl::nullopt /*download_schedule*/,
base::nullopt /*download_schedule*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE);
}
}
@@ -172,7 +172,7 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
std::move(callback).Run(path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::MixedContentStatus::UNKNOWN,
path, absl::nullopt /*download_schedule*/,
path, base::nullopt /*download_schedule*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE);
}
@@ -195,17 +195,17 @@ class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
void Cancel() override {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefDownloadItemCallbackImpl::DoCancel, this));
base::Bind(&CefDownloadItemCallbackImpl::DoCancel, this));
}
void Pause() override {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefDownloadItemCallbackImpl::DoPause, this));
base::Bind(&CefDownloadItemCallbackImpl::DoPause, this));
}
void Resume() override {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefDownloadItemCallbackImpl::DoResume, this));
base::Bind(&CefDownloadItemCallbackImpl::DoResume, this));
}
private:
@@ -289,7 +289,7 @@ void CefDownloadManagerDelegate::OnDownloadUpdated(DownloadItem* download) {
handler->OnDownloadUpdated(browser.get(), download_item.get(), callback);
ignore_result(download_item->Detach(nullptr));
download_item->Detach(nullptr);
}
}
@@ -358,7 +358,7 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DownloadItem::MixedContentStatus::UNKNOWN,
item->GetForcedFilePath(), absl::nullopt /*download_schedule*/,
item->GetForcedFilePath(), base::nullopt /*download_schedule*/,
download::DOWNLOAD_INTERRUPT_REASON_NONE);
return true;
}
@@ -384,7 +384,7 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
handler->OnBeforeDownload(browser.get(), download_item.get(),
suggested_name.value(), callbackObj);
ignore_result(download_item->Detach(nullptr));
download_item->Detach(nullptr);
}
return true;

View File

@@ -1,20 +0,0 @@
// Copyright 2021 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
#include "libcef/browser/extensions/alloy_extensions_util.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
namespace extensions {
namespace alloy {
int GetTabIdForWebContents(content::WebContents* web_contents) {
auto browser = AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
if (!browser)
return -1;
return browser->GetIdentifier();
}
} // namespace alloy
} // namespace extensions

View File

@@ -1,21 +0,0 @@
// Copyright 2021 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_ALLOY_EXTENSIONS_UTIL_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_ALLOY_EXTENSIONS_UTIL_H_
namespace content {
class WebContents;
}
namespace extensions {
namespace alloy {
// Returns the tabId for |web_contents|, or -1 if not found.
int GetTabIdForWebContents(content::WebContents* web_contents);
} // namespace alloy
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_ALLOY_EXTENSIONS_UTIL_H_

View File

@@ -56,7 +56,7 @@ void SyncValueStoreCache::RunWithValueStoreForExtension(
// A neat way to implement unlimited storage; if the extension has the
// unlimited storage permission, force through all calls to Set().
if (extension->permissions_data()->HasAPIPermission(
mojom::APIPermissionID::kUnlimitedStorage)) {
APIPermission::kUnlimitedStorage)) {
WeakUnlimitedSettingsStorage unlimited_storage(storage);
std::move(callback).Run(&unlimited_storage);
} else {

View File

@@ -6,15 +6,10 @@
#include "libcef/browser/extensions/extension_web_contents_observer.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "components/zoom/zoom_controller.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/site_instance.h"
#include "extensions/browser/extension_api_frame_id_map.h"
#include "extensions/browser/extension_zoom_request_client.h"
#include "extensions/common/error_utils.h"
@@ -22,8 +17,6 @@
#include "extensions/common/permissions/permissions_data.h"
#include "third_party/blink/public/common/page/page_zoom.h"
using zoom::ZoomController;
namespace extensions {
namespace cef {
@@ -104,148 +97,6 @@ ExtensionFunction::ResponseAction TabsCreateFunction::Run() {
: NoArguments());
}
BaseAPIFunction::BaseAPIFunction() : cef_details_(this) {}
content::WebContents* BaseAPIFunction::GetWebContents(int tab_id) {
// Find a browser that we can access, or set |error_| and return nullptr.
CefRefPtr<AlloyBrowserHostImpl> browser =
cef_details_.GetBrowserForTabIdFirstTime(tab_id, &error_);
if (!browser)
return nullptr;
return browser->web_contents();
}
ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
std::unique_ptr<tabs::Update::Params> params(
tabs::Update::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
tab_id_ = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id_);
if (!web_contents)
return RespondNow(Error(std::move(error_)));
web_contents_ = web_contents;
// TODO(rafaelw): handle setting remaining tab properties:
// -title
// -favIconUrl
// Navigate the tab to a new location if the url is different.
if (params->update_properties.url.get()) {
std::string updated_url = *params->update_properties.url;
if (!UpdateURL(updated_url, tab_id_, &error_))
return RespondNow(Error(std::move(error_)));
}
bool active = false;
// TODO(rafaelw): Setting |active| from js doesn't make much sense.
// Move tab selection management up to window.
if (params->update_properties.selected.get())
active = *params->update_properties.selected;
// The 'active' property has replaced 'selected'.
if (params->update_properties.active.get())
active = *params->update_properties.active;
if (active) {
// TODO: Activate the tab at |tab_id_|.
NOTIMPLEMENTED();
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
}
if (params->update_properties.highlighted.get() &&
*params->update_properties.highlighted) {
// TODO: Highlight the tab at |tab_id_|.
NOTIMPLEMENTED();
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
}
if (params->update_properties.pinned.get() &&
*params->update_properties.pinned) {
// TODO: Pin the tab at |tab_id_|.
NOTIMPLEMENTED();
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
}
if (params->update_properties.muted.get()) {
// TODO: Mute/unmute the tab at |tab_id_|.
NOTIMPLEMENTED();
return RespondNow(Error(ErrorUtils::FormatErrorMessage(
tabs_constants::kCannotUpdateMuteCaptured,
base::NumberToString(tab_id_))));
}
if (params->update_properties.opener_tab_id.get()) {
int opener_id = *params->update_properties.opener_tab_id;
if (opener_id == tab_id_)
return RespondNow(Error("Cannot set a tab's opener to itself."));
// TODO: Set the opener for the tab at |tab_id_|.
NOTIMPLEMENTED();
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
}
if (params->update_properties.auto_discardable.get()) {
// TODO: Set auto-discardable state for the tab at |tab_id_|.
NOTIMPLEMENTED();
}
return RespondNow(GetResult());
}
bool TabsUpdateFunction::UpdateURL(const std::string& url_string,
int tab_id,
std::string* error) {
GURL url;
if (!ExtensionTabUtil::PrepareURLForNavigation(url_string, extension(), &url,
error)) {
return false;
}
const bool is_javascript_scheme = url.SchemeIs(url::kJavaScriptScheme);
// JavaScript URLs are forbidden in chrome.tabs.update().
if (is_javascript_scheme) {
*error = tabs_constants::kJavaScriptUrlsNotAllowedInTabsUpdate;
return false;
}
content::NavigationController::LoadURLParams load_params(url);
// Treat extension-initiated navigations as renderer-initiated so that the URL
// does not show in the omnibox until it commits. This avoids URL spoofs
// since URLs can be opened on behalf of untrusted content.
load_params.is_renderer_initiated = true;
// All renderer-initiated navigations need to have an initiator origin.
load_params.initiator_origin = extension()->origin();
// |source_site_instance| needs to be set so that a renderer process
// compatible with |initiator_origin| is picked by Site Isolation.
load_params.source_site_instance = content::SiteInstance::CreateForURL(
web_contents_->GetBrowserContext(),
load_params.initiator_origin->GetURL());
// Marking the navigation as initiated via an API means that the focus
// will stay in the omnibox - see https://crbug.com/1085779.
load_params.transition_type = ui::PAGE_TRANSITION_FROM_API;
web_contents_->GetController().LoadURLWithParams(load_params);
DCHECK_EQ(url,
web_contents_->GetController().GetPendingEntry()->GetVirtualURL());
return true;
}
ExtensionFunction::ResponseValue TabsUpdateFunction::GetResult() {
if (!has_callback())
return NoArguments();
return ArgumentList(tabs::Get::Results::Create(*cef_details_.CreateTabObject(
AlloyBrowserHostImpl::GetBrowserForContents(web_contents_),
/*opener_browser_id=*/-1, /*active=*/true, tab_id_)));
}
ExecuteCodeInTabFunction::ExecuteCodeInTabFunction()
: cef_details_(this), execute_tab_id_(-1) {}
@@ -277,8 +128,7 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
execute_tab_id_ = browser->GetIdentifier();
details_ = std::move(details);
set_host_id(
mojom::HostID(mojom::HostID::HostType::kExtensions, extension()->id()));
set_host_id(HostID(HostID::EXTENSIONS, extension()->id()));
return set_init_result(SUCCESS);
}
@@ -332,7 +182,7 @@ bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage(std::string* error) {
execute_tab_id_, error)) {
if (is_about_url &&
extension()->permissions_data()->active_permissions().HasAPIPermission(
mojom::APIPermissionID::kTab)) {
APIPermission::kTab)) {
*error = ErrorUtils::FormatErrorMessage(
manifest_errors::kCannotAccessAboutUrl,
rfh->GetLastCommittedURL().spec(),
@@ -393,124 +243,165 @@ bool TabsRemoveCSSFunction::ShouldRemoveCSS() const {
return true;
}
ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() {
ZoomAPIFunction::ZoomAPIFunction() : cef_details_(this) {}
content::WebContents* ZoomAPIFunction::GetWebContents(int tab_id) {
// Find a browser that we can access, or set |error_| and return nullptr.
CefRefPtr<AlloyBrowserHostImpl> browser =
cef_details_.GetBrowserForTabIdFirstTime(tab_id, &error_);
if (!browser)
return nullptr;
return browser->web_contents();
}
void ZoomAPIFunction::SendResponse(bool success) {
ResponseValue response;
if (success) {
response = ArgumentList(std::move(results_));
} else {
response = results_ ? ErrorWithArguments(std::move(results_), error_)
: Error(error_);
}
Respond(std::move(response));
}
ExtensionFunction::ResponseAction ZoomAPIFunction::Run() {
if (RunAsync())
return RespondLater();
// TODO(devlin): Track these down and eliminate them if possible. We
// shouldn't return results and an error.
if (results_)
return RespondNow(ErrorWithArguments(std::move(results_), error_));
return RespondNow(Error(error_));
}
bool TabsSetZoomFunction::RunAsync() {
std::unique_ptr<tabs::SetZoom::Params> params(
tabs::SetZoom::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id);
if (!web_contents)
return RespondNow(Error(std::move(error_)));
return false;
GURL url(web_contents->GetVisibleURL());
if (extension()->permissions_data()->IsRestrictedUrl(url, &error_))
return RespondNow(Error(std::move(error_)));
return false;
ZoomController* zoom_controller =
ZoomController::FromWebContents(web_contents);
zoom::ZoomController* zoom_controller =
zoom::ZoomController::FromWebContents(web_contents);
double zoom_level =
params->zoom_factor > 0
? blink::PageZoomFactorToZoomLevel(params->zoom_factor)
: zoom_controller->GetDefaultZoomLevel();
auto client = base::MakeRefCounted<ExtensionZoomRequestClient>(extension());
scoped_refptr<extensions::ExtensionZoomRequestClient> client(
new extensions::ExtensionZoomRequestClient(extension()));
if (!zoom_controller->SetZoomLevelByClient(zoom_level, client)) {
// Tried to zoom a tab in disabled mode.
return RespondNow(Error(tabs_constants::kCannotZoomDisabledTabError));
error_ = keys::kCannotZoomDisabledTabError;
return false;
}
return RespondNow(NoArguments());
SendResponse(true);
return true;
}
ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() {
bool TabsGetZoomFunction::RunAsync() {
std::unique_ptr<tabs::GetZoom::Params> params(
tabs::GetZoom::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id);
if (!web_contents)
return RespondNow(Error(std::move(error_)));
return false;
double zoom_level =
zoom::ZoomController::FromWebContents(web_contents)->GetZoomLevel();
double zoom_factor = blink::PageZoomLevelToZoomFactor(zoom_level);
return RespondNow(ArgumentList(tabs::GetZoom::Results::Create(zoom_factor)));
results_ = tabs::GetZoom::Results::Create(zoom_factor);
SendResponse(true);
return true;
}
ExtensionFunction::ResponseAction TabsSetZoomSettingsFunction::Run() {
bool TabsSetZoomSettingsFunction::RunAsync() {
using api::tabs::ZoomSettings;
std::unique_ptr<tabs::SetZoomSettings::Params> params(
tabs::SetZoomSettings::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id);
if (!web_contents)
return RespondNow(Error(std::move(error_)));
return false;
GURL url(web_contents->GetVisibleURL());
std::string error;
if (extension()->permissions_data()->IsRestrictedUrl(url, &error_))
return RespondNow(Error(std::move(error_)));
return false;
// "per-origin" scope is only available in "automatic" mode.
if (params->zoom_settings.scope == tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN &&
params->zoom_settings.mode != tabs::ZOOM_SETTINGS_MODE_AUTOMATIC &&
params->zoom_settings.mode != tabs::ZOOM_SETTINGS_MODE_NONE) {
return RespondNow(Error(tabs_constants::kPerOriginOnlyInAutomaticError));
error_ = keys::kPerOriginOnlyInAutomaticError;
return false;
}
// Determine the correct internal zoom mode to set |web_contents| to from the
// user-specified |zoom_settings|.
ZoomController::ZoomMode zoom_mode = ZoomController::ZOOM_MODE_DEFAULT;
zoom::ZoomController::ZoomMode zoom_mode =
zoom::ZoomController::ZOOM_MODE_DEFAULT;
switch (params->zoom_settings.mode) {
case tabs::ZOOM_SETTINGS_MODE_NONE:
case tabs::ZOOM_SETTINGS_MODE_AUTOMATIC:
switch (params->zoom_settings.scope) {
case tabs::ZOOM_SETTINGS_SCOPE_NONE:
case tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN:
zoom_mode = ZoomController::ZOOM_MODE_DEFAULT;
zoom_mode = zoom::ZoomController::ZOOM_MODE_DEFAULT;
break;
case tabs::ZOOM_SETTINGS_SCOPE_PER_TAB:
zoom_mode = ZoomController::ZOOM_MODE_ISOLATED;
zoom_mode = zoom::ZoomController::ZOOM_MODE_ISOLATED;
}
break;
case tabs::ZOOM_SETTINGS_MODE_MANUAL:
zoom_mode = ZoomController::ZOOM_MODE_MANUAL;
zoom_mode = zoom::ZoomController::ZOOM_MODE_MANUAL;
break;
case tabs::ZOOM_SETTINGS_MODE_DISABLED:
zoom_mode = ZoomController::ZOOM_MODE_DISABLED;
zoom_mode = zoom::ZoomController::ZOOM_MODE_DISABLED;
}
ZoomController::FromWebContents(web_contents)->SetZoomMode(zoom_mode);
zoom::ZoomController::FromWebContents(web_contents)->SetZoomMode(zoom_mode);
return RespondNow(NoArguments());
SendResponse(true);
return true;
}
ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
bool TabsGetZoomSettingsFunction::RunAsync() {
std::unique_ptr<tabs::GetZoomSettings::Params> params(
tabs::GetZoomSettings::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
EXTENSION_FUNCTION_PRERUN_VALIDATE(params);
int tab_id = params->tab_id ? *params->tab_id : -1;
content::WebContents* web_contents = GetWebContents(tab_id);
if (!web_contents)
return RespondNow(Error(std::move(error_)));
ZoomController* zoom_controller =
ZoomController::FromWebContents(web_contents);
return false;
zoom::ZoomController* zoom_controller =
zoom::ZoomController::FromWebContents(web_contents);
ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode();
zoom::ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode();
api::tabs::ZoomSettings zoom_settings;
ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
zoom_settings.default_zoom_factor = std::make_unique<double>(
blink::PageZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()));
zoom_settings.default_zoom_factor.reset(
new double(blink::PageZoomLevelToZoomFactor(
zoom_controller->GetDefaultZoomLevel())));
return RespondNow(
ArgumentList(api::tabs::GetZoomSettings::Results::Create(zoom_settings)));
results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
SendResponse(true);
return true;
}
} // namespace cef

View File

@@ -42,37 +42,6 @@ class TabsCreateFunction : public ExtensionFunction {
const CefExtensionFunctionDetails cef_details_;
};
class BaseAPIFunction : public ExtensionFunction {
public:
BaseAPIFunction();
protected:
~BaseAPIFunction() override {}
// Gets the WebContents for |tab_id| if it is specified. Otherwise get the
// WebContents for the active tab in the current window. Calling this function
// may set |error_|.
content::WebContents* GetWebContents(int tab_id);
std::string error_;
const CefExtensionFunctionDetails cef_details_;
};
class TabsUpdateFunction : public BaseAPIFunction {
private:
~TabsUpdateFunction() override {}
ResponseAction Run() override;
bool UpdateURL(const std::string& url, int tab_id, std::string* error);
ResponseValue GetResult();
DECLARE_EXTENSION_FUNCTION("tabs.update", TABS_UPDATE)
int tab_id_ = -1;
content::WebContents* web_contents_ = nullptr;
};
// Implement API calls tabs.executeScript, tabs.insertCSS, and tabs.removeCSS.
class ExecuteCodeInTabFunction : public ExecuteCodeFunction {
public:
@@ -139,44 +108,58 @@ class ZoomAPIFunction : public ExtensionFunction {
// may set |error_|.
content::WebContents* GetWebContents(int tab_id);
virtual bool RunAsync() = 0;
// Responds with success/failure. |results_| or |error_| should be set
// accordingly.
void SendResponse(bool success);
// Exposed versions of ExtensionFunction::results_ and
// ExtensionFunction::error_ that are curried into the response.
// These need to keep the same name to avoid breaking existing
// implementations, but this should be temporary with crbug.com/648275
// and crbug.com/634140.
std::unique_ptr<base::ListValue> results_;
std::string error_;
private:
ResponseAction Run() final;
const CefExtensionFunctionDetails cef_details_;
};
class TabsSetZoomFunction : public BaseAPIFunction {
class TabsSetZoomFunction : public ZoomAPIFunction {
private:
~TabsSetZoomFunction() override {}
ResponseAction Run() override;
bool RunAsync() override;
DECLARE_EXTENSION_FUNCTION("tabs.setZoom", TABS_SETZOOM)
};
class TabsGetZoomFunction : public BaseAPIFunction {
class TabsGetZoomFunction : public ZoomAPIFunction {
private:
~TabsGetZoomFunction() override {}
ResponseAction Run() override;
bool RunAsync() override;
DECLARE_EXTENSION_FUNCTION("tabs.getZoom", TABS_GETZOOM)
};
class TabsSetZoomSettingsFunction : public BaseAPIFunction {
class TabsSetZoomSettingsFunction : public ZoomAPIFunction {
private:
~TabsSetZoomSettingsFunction() override {}
ResponseAction Run() override;
bool RunAsync() override;
DECLARE_EXTENSION_FUNCTION("tabs.setZoomSettings", TABS_SETZOOMSETTINGS)
};
class TabsGetZoomSettingsFunction : public BaseAPIFunction {
class TabsGetZoomSettingsFunction : public ZoomAPIFunction {
private:
~TabsGetZoomSettingsFunction() override {}
ResponseAction Run() override;
bool RunAsync() override;
DECLARE_EXTENSION_FUNCTION("tabs.getZoomSettings", TABS_GETZOOMSETTINGS)
};

View File

@@ -54,8 +54,8 @@ void GetAllGuestsForOwnerContents(content::WebContents* owner,
std::vector<content::WebContents*>* guests) {
content::BrowserPluginGuestManager* plugin_guest_manager =
owner->GetBrowserContext()->GetGuestManager();
plugin_guest_manager->ForEachGuest(
owner, base::BindRepeating(InsertWebContents, guests));
plugin_guest_manager->ForEachGuest(owner,
base::Bind(InsertWebContents, guests));
}
content::WebContents* GetOwnerForGuestContents(content::WebContents* guest) {

View File

@@ -29,8 +29,8 @@ void CefBrowserPlatformDelegateBackground::CloseHostWindow() {
// No host window, so continue browser destruction now. Do it asynchronously
// so the call stack has a chance to unwind.
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&AlloyBrowserHostImpl::WindowDestroyed,
static_cast<AlloyBrowserHostImpl*>(browser_)));
base::Bind(&AlloyBrowserHostImpl::WindowDestroyed,
static_cast<AlloyBrowserHostImpl*>(browser_)));
}
CefWindowHandle CefBrowserPlatformDelegateBackground::GetHostWindowHandle()

View File

@@ -51,7 +51,6 @@ const char* const kSupportedAPIs[] = {
"tabs",
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsCreateFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsUpdateFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsExecuteScriptFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsInsertCSSFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsRemoveCSSFunction),
@@ -96,7 +95,6 @@ void ChromeFunctionRegistry::RegisterAll(ExtensionFunctionRegistry* registry) {
registry->RegisterFunction<cefimpl::TabsRemoveCSSFunction>();
registry->RegisterFunction<cefimpl::TabsGetFunction>();
registry->RegisterFunction<cefimpl::TabsCreateFunction>();
registry->RegisterFunction<cefimpl::TabsUpdateFunction>();
registry->RegisterFunction<cefimpl::TabsSetZoomFunction>();
registry->RegisterFunction<cefimpl::TabsGetZoomFunction>();
registry->RegisterFunction<cefimpl::TabsSetZoomSettingsFunction>();

View File

@@ -23,7 +23,7 @@ CefComponentExtensionResourceManager::CefComponentExtensionResourceManager() {
base::Value dict(base::Value::Type::DICTIONARY);
pdf_extension_util::AddStrings(
pdf_extension_util::PdfViewerContext::kPdfViewer, &dict);
pdf_extension_util::AddAdditionalData(/*enable_annotations=*/true, &dict);
pdf_extension_util::AddAdditionalData(&dict);
ui::TemplateReplacements pdf_viewer_replacements;
ui::TemplateReplacementsFromDictionaryValue(

View File

@@ -17,7 +17,7 @@ CefExtensionBackgroundHost::CefExtensionBackgroundHost(
const Extension* extension,
content::WebContents* host_contents,
const GURL& url,
mojom::ViewType host_type)
ViewType host_type)
: ExtensionHost(new CefExtensionHostDelegate(browser),
extension,
host_contents->GetBrowserContext(),
@@ -28,7 +28,7 @@ CefExtensionBackgroundHost::CefExtensionBackgroundHost(
DCHECK(!deleted_callback_.is_null());
// Only used for background pages.
DCHECK(host_type == mojom::ViewType::kExtensionBackgroundPage);
DCHECK(host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
}
CefExtensionBackgroundHost::~CefExtensionBackgroundHost() {

View File

@@ -29,7 +29,7 @@ class CefExtensionBackgroundHost : public ExtensionHost {
const Extension* extension,
content::WebContents* host_contents,
const GURL& url,
mojom::ViewType host_type);
ViewType host_type);
~CefExtensionBackgroundHost() override;
// content::WebContentsDelegate methods:

View File

@@ -7,11 +7,11 @@
#include "libcef/browser/browser_context.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/navigate_params.h"
#include "libcef/browser/thread_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
@@ -81,9 +81,10 @@ class CefGetExtensionLoadFileCallbackImpl
return;
}
base::ThreadPool::PostTaskAndReplyWithResult(
base::PostTaskAndReplyWithResult(
FROM_HERE,
{base::MayBlock(), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
{base::ThreadPool(), base::MayBlock(),
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
base::BindOnce(LoadFileFromStream, file, stream), std::move(callback));
}
@@ -318,12 +319,24 @@ base::DictionaryValue* CefExtensionFunctionDetails::OpenTab(
GURL url;
if (params.url.get()) {
std::string url_string = *params.url;
if (!ExtensionTabUtil::PrepareURLForNavigation(
url_string, function()->extension(), &url, error_message)) {
url = ExtensionTabUtil::ResolvePossiblyRelativeURL(url_string,
function()->extension());
if (!url.is_valid()) {
if (error_message) {
*error_message =
ErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, url_string);
}
return nullptr;
}
}
// Don't let extensions crash the browser or renderers.
if (ExtensionTabUtil::IsKillURL(url)) {
if (error_message)
*error_message = keys::kNoCrashBrowserError;
return nullptr;
}
// Default to foreground for the new tab. The presence of 'active' property
// will override this default.
bool active = true;

View File

@@ -13,7 +13,6 @@
#include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -447,10 +446,10 @@ void CefExtensionSystem::RegisterExtensionWithRequestContexts(
// manifest settings.
content::GetIOThreadTaskRunner({})->PostTaskAndReply(
FROM_HERE,
base::BindOnce(&InfoMap::AddExtension, info_map(),
base::RetainedRef(extension), base::Time::Now(),
true, // incognito_enabled
false), // notifications_disabled
base::Bind(&InfoMap::AddExtension, info_map(),
base::RetainedRef(extension), base::Time::Now(),
true, // incognito_enabled
false), // notifications_disabled
std::move(callback));
}
@@ -460,8 +459,8 @@ void CefExtensionSystem::UnregisterExtensionWithRequestContexts(
const std::string& extension_id,
const UnloadedExtensionReason reason) {
content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(&InfoMap::RemoveExtension, info_map(),
extension_id, reason));
FROM_HERE,
base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
}
const base::OneShotEvent& CefExtensionSystem::ready() const {
@@ -548,8 +547,7 @@ scoped_refptr<const Extension> CefExtensionSystem::CreateExtension(
// Tests should continue to use the Manifest::COMMAND_LINE value here
// Some Chrome APIs will cause undesired effects if this is incorrect
// e.g.: alarms API has 1 minute minimum applied to Packed Extensions
info.internal ? mojom::ManifestLocation::kComponent
: mojom::ManifestLocation::kCommandLine,
info.internal ? Manifest::COMPONENT : Manifest::COMMAND_LINE,
*info.manifest, flags, utf8_error);
}
@@ -635,9 +633,9 @@ void CefExtensionSystem::NotifyExtensionLoaded(const Extension* extension) {
// extension.
RegisterExtensionWithRequestContexts(
extension,
base::BindOnce(
&CefExtensionSystem::OnExtensionRegisteredWithRequestContexts,
weak_ptr_factory_.GetWeakPtr(), base::WrapRefCounted(extension)));
base::Bind(&CefExtensionSystem::OnExtensionRegisteredWithRequestContexts,
weak_ptr_factory_.GetWeakPtr(),
base::WrapRefCounted(extension)));
// Tell renderers about the loaded extension.
renderer_helper_->OnExtensionLoaded(*extension);

View File

@@ -25,7 +25,7 @@ CefExtensionViewHost::CefExtensionViewHost(AlloyBrowserHostImpl* browser,
const Extension* extension,
content::WebContents* host_contents,
const GURL& url,
mojom::ViewType host_type)
ViewType host_type)
: ExtensionHost(new CefExtensionHostDelegate(browser),
extension,
host_contents->GetBrowserContext(),
@@ -33,8 +33,8 @@ CefExtensionViewHost::CefExtensionViewHost(AlloyBrowserHostImpl* browser,
url,
host_type) {
// Only used for dialogs and popups.
DCHECK(host_type == mojom::ViewType::kExtensionDialog ||
host_type == mojom::ViewType::kExtensionPopup);
DCHECK(host_type == VIEW_TYPE_EXTENSION_DIALOG ||
host_type == VIEW_TYPE_EXTENSION_POPUP);
}
CefExtensionViewHost::~CefExtensionViewHost() {}
@@ -76,7 +76,7 @@ bool CefExtensionViewHost::PreHandleGestureEvent(
}
WebContents* CefExtensionViewHost::GetVisibleWebContents() const {
if (extension_host_type() == mojom::ViewType::kExtensionPopup)
if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP)
return host_contents();
return nullptr;
}

View File

@@ -31,7 +31,7 @@ class CefExtensionViewHost : public ExtensionHost,
const Extension* extension,
content::WebContents* host_contents,
const GURL& url,
mojom::ViewType host_type);
ViewType host_type);
~CefExtensionViewHost() override;
// ExtensionHost methods:

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