mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Compare commits
46 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1701b8e6d5 | ||
|
c410c950de | ||
|
c8b1a8cb23 | ||
|
74eca7268f | ||
|
3d8f1c9064 | ||
|
e997249d53 | ||
|
3ccd305f6d | ||
|
99c85e32ac | ||
|
6da73a3d31 | ||
|
44f7b57e79 | ||
|
331f668eee | ||
|
14bd14567f | ||
|
69ce47ae4c | ||
|
0580f93839 | ||
|
3c3e543b44 | ||
|
fae4a6f0bd | ||
|
91ba12468b | ||
|
739021e4a8 | ||
|
853ea8846a | ||
|
9f45038464 | ||
|
39993d8c0c | ||
|
0f68a0d7a3 | ||
|
a0566e64d8 | ||
|
fe5b0dd668 | ||
|
c0e7854782 | ||
|
be6642df3f | ||
|
ed079792b6 | ||
|
0783b4c57d | ||
|
b537fc929b | ||
|
708d90a6ff | ||
|
5065aba1b4 | ||
|
65234a6830 | ||
|
b67cbc47e3 | ||
|
4fe529e2dc | ||
|
260dd0ca24 | ||
|
dca0435d2f | ||
|
62c93f01f4 | ||
|
81a0648ee1 | ||
|
744a194a6e | ||
|
96dc172980 | ||
|
f1effba336 | ||
|
d10cc16236 | ||
|
da1c3179a9 | ||
|
2e33954032 | ||
|
f60476b848 | ||
|
29c21f58e8 |
82
BUILD.gn
82
BUILD.gn
@@ -465,12 +465,22 @@ source_set("libcef_static") {
|
||||
"libcef/browser/alloy/alloy_browser_main.h",
|
||||
"libcef/browser/alloy/alloy_content_browser_client.cc",
|
||||
"libcef/browser/alloy/alloy_content_browser_client.h",
|
||||
"libcef/browser/alloy/alloy_download_manager_delegate.cc",
|
||||
"libcef/browser/alloy/alloy_download_manager_delegate.h",
|
||||
"libcef/browser/alloy/alloy_download_util.cc",
|
||||
"libcef/browser/alloy/alloy_download_util.h",
|
||||
"libcef/browser/alloy/alloy_web_contents_view_delegate.cc",
|
||||
"libcef/browser/alloy/alloy_web_contents_view_delegate.h",
|
||||
"libcef/browser/alloy/browser_platform_delegate_alloy.cc",
|
||||
"libcef/browser/alloy/browser_platform_delegate_alloy.h",
|
||||
"libcef/browser/alloy/devtools/alloy_devtools_window_runner.cc",
|
||||
"libcef/browser/alloy/devtools/alloy_devtools_window_runner.h",
|
||||
"libcef/browser/alloy/devtools/devtools_file_manager.cc",
|
||||
"libcef/browser/alloy/devtools/devtools_file_manager.h",
|
||||
"libcef/browser/alloy/devtools/devtools_frontend.cc",
|
||||
"libcef/browser/alloy/devtools/devtools_frontend.h",
|
||||
"libcef/browser/alloy/devtools/devtools_manager_delegate.cc",
|
||||
"libcef/browser/alloy/devtools/devtools_manager_delegate.h",
|
||||
"libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.cc",
|
||||
"libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h",
|
||||
"libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.cc",
|
||||
@@ -528,9 +538,14 @@ source_set("libcef_static") {
|
||||
"libcef/browser/chrome/chrome_content_browser_client_cef.h",
|
||||
"libcef/browser/chrome/chrome_context_menu_handler.cc",
|
||||
"libcef/browser/chrome/chrome_context_menu_handler.h",
|
||||
"libcef/browser/chrome/chrome_devtools_window_runner.cc",
|
||||
"libcef/browser/chrome/chrome_devtools_window_runner.h",
|
||||
"libcef/browser/chrome/chrome_startup_browser_creator.cc",
|
||||
"libcef/browser/chrome/chrome_startup_browser_creator.h",
|
||||
"libcef/browser/chrome/chrome_web_contents_view_delegate_cef.h",
|
||||
"libcef/browser/chrome_crash_reporter_client_stub.cc",
|
||||
"libcef/browser/chrome/extensions/chrome_extension_util.cc",
|
||||
"libcef/browser/chrome/extensions/chrome_extension_util.h",
|
||||
"libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.cc",
|
||||
"libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.h",
|
||||
"libcef/browser/chrome/views/browser_platform_delegate_chrome_child_window.cc",
|
||||
@@ -555,18 +570,16 @@ source_set("libcef_static") {
|
||||
"libcef/browser/context_menu_params_impl.h",
|
||||
"libcef/browser/devtools/devtools_controller.cc",
|
||||
"libcef/browser/devtools/devtools_controller.h",
|
||||
"libcef/browser/devtools/devtools_file_manager.cc",
|
||||
"libcef/browser/devtools/devtools_file_manager.h",
|
||||
"libcef/browser/devtools/devtools_frontend.cc",
|
||||
"libcef/browser/devtools/devtools_frontend.h",
|
||||
"libcef/browser/devtools/devtools_manager.cc",
|
||||
"libcef/browser/devtools/devtools_manager.h",
|
||||
"libcef/browser/devtools/devtools_manager_delegate.cc",
|
||||
"libcef/browser/devtools/devtools_manager_delegate.h",
|
||||
"libcef/browser/devtools/devtools_protocol_manager.cc",
|
||||
"libcef/browser/devtools/devtools_protocol_manager.h",
|
||||
"libcef/browser/devtools/devtools_window_runner.h",
|
||||
"libcef/browser/devtools/devtools_window_runner_create.cc",
|
||||
"libcef/browser/download_item_impl.cc",
|
||||
"libcef/browser/download_item_impl.h",
|
||||
"libcef/browser/download_manager_delegate.cc",
|
||||
"libcef/browser/download_manager_delegate.h",
|
||||
"libcef/browser/download_manager_delegate_impl.cc",
|
||||
"libcef/browser/download_manager_delegate_impl.h",
|
||||
"libcef/browser/extension_impl.cc",
|
||||
"libcef/browser/extension_impl.h",
|
||||
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.cc",
|
||||
@@ -774,6 +787,8 @@ source_set("libcef_static") {
|
||||
"libcef/browser/views/browser_view_view.h",
|
||||
"libcef/browser/views/button_impl.h",
|
||||
"libcef/browser/views/button_view.h",
|
||||
"libcef/browser/views/color_provider_tracker.cc",
|
||||
"libcef/browser/views/color_provider_tracker.h",
|
||||
"libcef/browser/views/display_impl.cc",
|
||||
"libcef/browser/views/display_impl.h",
|
||||
"libcef/browser/views/fill_layout_impl.cc",
|
||||
@@ -809,7 +824,11 @@ source_set("libcef_static") {
|
||||
"libcef/browser/views/view_util.cc",
|
||||
"libcef/browser/views/view_util.h",
|
||||
"libcef/browser/views/view_view.h",
|
||||
"libcef/browser/views/widget.cc",
|
||||
"libcef/browser/views/widget.h",
|
||||
"libcef/browser/views/widget_destruction_observer.h",
|
||||
"libcef/browser/views/widget_impl.cc",
|
||||
"libcef/browser/views/widget_impl.h",
|
||||
"libcef/browser/views/window_impl.cc",
|
||||
"libcef/browser/views/window_impl.h",
|
||||
"libcef/browser/views/window_view.cc",
|
||||
@@ -917,6 +936,8 @@ source_set("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",
|
||||
@@ -933,8 +954,6 @@ source_set("libcef_static") {
|
||||
"libcef/renderer/extensions/extensions_renderer_api_provider.h",
|
||||
"libcef/renderer/extensions/extensions_renderer_client.cc",
|
||||
"libcef/renderer/extensions/extensions_renderer_client.h",
|
||||
"libcef/renderer/extensions/print_render_frame_helper_delegate.cc",
|
||||
"libcef/renderer/extensions/print_render_frame_helper_delegate.h",
|
||||
"libcef/renderer/frame_impl.cc",
|
||||
"libcef/renderer/frame_impl.h",
|
||||
"libcef/renderer/render_frame_observer.cc",
|
||||
@@ -1123,27 +1142,30 @@ source_set("libcef_static") {
|
||||
"libcef/common/util_linux.cc",
|
||||
]
|
||||
|
||||
if (ozone_platform_x11) {
|
||||
sources += [
|
||||
"libcef/browser/native/window_x11.cc",
|
||||
"libcef/browser/native/window_x11.h",
|
||||
]
|
||||
}
|
||||
|
||||
deps += [
|
||||
"//build/config/freetype",
|
||||
"//third_party/fontconfig",
|
||||
]
|
||||
|
||||
if (is_linux && !ozone_platform_x11) {
|
||||
deps += [
|
||||
"//third_party/angle:libEGL",
|
||||
if (ozone_platform_x11) {
|
||||
sources += [
|
||||
"libcef/browser/native/window_x11.cc",
|
||||
"libcef/browser/native/window_x11.h",
|
||||
]
|
||||
} else {
|
||||
deps += [ "//third_party/angle:libEGL" ]
|
||||
}
|
||||
|
||||
if (use_dbus) {
|
||||
deps += [ "//dbus" ]
|
||||
defines = [ "USE_DBUS" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (is_mac) {
|
||||
sources += includes_mac + [
|
||||
"libcef/browser/chrome/chrome_content_browser_client_cef_mac.mm",
|
||||
"libcef/browser/chrome/chrome_web_contents_view_delegate_cef_mac.mm",
|
||||
"libcef/browser/native/browser_platform_delegate_native_mac.h",
|
||||
"libcef/browser/native/browser_platform_delegate_native_mac.mm",
|
||||
"libcef/browser/native/cursor_util_mac.mm",
|
||||
@@ -1165,6 +1187,10 @@ source_set("libcef_static") {
|
||||
"//chrome/app/chrome_main_mac.h",
|
||||
"//chrome/app/chrome_main_mac.mm",
|
||||
]
|
||||
} else {
|
||||
sources += [
|
||||
"libcef/browser/chrome/chrome_web_contents_view_delegate_cef.cc",
|
||||
]
|
||||
}
|
||||
|
||||
if (ozone_platform_x11) {
|
||||
@@ -1478,6 +1504,20 @@ action("make_config_header") {
|
||||
args = rebase_path(outputs + [ "$root_out_dir/args.gn" ], root_build_dir)
|
||||
}
|
||||
|
||||
# Generate cef_color_ids.h.
|
||||
action("make_colorids_header") {
|
||||
script = "tools/make_colorids_header.py"
|
||||
|
||||
inputs = [
|
||||
"//ui/color/color_id.h",
|
||||
"//components/color/color_id.h",
|
||||
"//chrome/browser/ui/color/chrome_color_id.h",
|
||||
]
|
||||
outputs = [ "$root_out_dir/includes/include/cef_color_ids.h" ]
|
||||
|
||||
args = rebase_path(outputs + inputs, root_build_dir)
|
||||
}
|
||||
|
||||
# Generate pack files and associated CEF header files.
|
||||
group("cef_make_headers") {
|
||||
deps = [
|
||||
@@ -1486,6 +1526,7 @@ group("cef_make_headers") {
|
||||
":make_pack_header_command_ids",
|
||||
":make_api_hash_header",
|
||||
":make_config_header",
|
||||
":make_colorids_header",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1964,6 +2005,7 @@ if (is_mac) {
|
||||
]
|
||||
frameworks = [
|
||||
"AppKit.framework",
|
||||
"IOSurface.framework",
|
||||
"OpenGL.framework",
|
||||
]
|
||||
defines = [
|
||||
|
@@ -7,5 +7,6 @@
|
||||
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
||||
|
||||
{
|
||||
'chromium_checkout': 'refs/tags/124.0.6367.0'
|
||||
'chromium_checkout': 'refs/tags/125.0.6422.142',
|
||||
'depot_tools_checkout': '3e4ab13934'
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@
|
||||
'include/base/cef_weak_ptr.h',
|
||||
'include/base/internal/cef_bind_internal.h',
|
||||
'include/base/internal/cef_callback_internal.h',
|
||||
'include/base/internal/cef_color_id_macros.inc',
|
||||
'include/base/internal/cef_lock_impl.h',
|
||||
'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h',
|
||||
'include/base/internal/cef_scoped_policy.h',
|
||||
@@ -55,6 +56,8 @@
|
||||
'include/internal/cef_types.h',
|
||||
'include/internal/cef_types_content_settings.h',
|
||||
'include/internal/cef_types_geometry.h',
|
||||
'include/internal/cef_types_runtime.h',
|
||||
'include/internal/cef_types_color.h',
|
||||
],
|
||||
'includes_capi': [
|
||||
'include/capi/cef_base_capi.h',
|
||||
@@ -315,6 +318,7 @@
|
||||
'tests/cefclient/resources/binary_transfer.html',
|
||||
'tests/cefclient/resources/binding.html',
|
||||
'tests/cefclient/resources/dialogs.html',
|
||||
'tests/cefclient/resources/draggable.html',
|
||||
'tests/cefclient/resources/hang.html',
|
||||
'tests/cefclient/resources/ipc_performance.html',
|
||||
'tests/cefclient/resources/localstorage.html',
|
||||
|
@@ -304,8 +304,9 @@ if(OS_MAC)
|
||||
# Standard libraries.
|
||||
set(CEF_STANDARD_LIBS
|
||||
-lpthread
|
||||
"-framework Cocoa"
|
||||
"-framework AppKit"
|
||||
"-framework Cocoa"
|
||||
"-framework IOSurface"
|
||||
)
|
||||
|
||||
# Find the newest available base SDK.
|
||||
|
50
include/base/internal/cef_color_id_macros.inc
Normal file
50
include/base/internal/cef_color_id_macros.inc
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// The following macros are used to declare both the color id enumerations and
|
||||
// the stringized names of the enumeration elements for use in dump_colors. To
|
||||
// stringize the element names, define STRINGIZE_COLOR_IDS prior to including
|
||||
// this file. This file is intended to be included just before and just after
|
||||
// the enumeration or string array declarations.
|
||||
|
||||
#if !defined(COLOR_ID_MACROS_DEFINED)
|
||||
#define COLOR_ID_MACROS_DEFINED
|
||||
#if defined(STRINGIZE_COLOR_IDS)
|
||||
// Convert first token to string, throw away the rest.
|
||||
#define D1(enum_name) #enum_name
|
||||
#define D2(enum_name, enum_value) #enum_name
|
||||
#else // defined(STRINGIZE_COLOR_IDS)
|
||||
// Declare enum with optional assigned value.
|
||||
#define D1(enum_name) enum_name
|
||||
#define D2(enum_name, enum_value) enum_name = enum_value
|
||||
#endif // defined(STRINGIZE_COLOR_IDS)
|
||||
// Select which token in the declaration is the assigned value.
|
||||
// Use first and optional third token, ignore optional second.
|
||||
#define E1(enum_name) D1(enum_name)
|
||||
#define E2(enum_name, old_enum_name) D1(enum_name)
|
||||
#define E3(enum_name, old_enum_name, enum_value) D2(enum_name, enum_value)
|
||||
#define GET_E(_1, _2, _3, macro_name, ...) macro_name
|
||||
#if defined(COMPILER_MSVC)
|
||||
// Workaround for MSVC not properly expanding __VA_ARGS__.
|
||||
#define EXPAND(x) x
|
||||
#define E_CPONLY(...) EXPAND(E(__VA_ARGS__))
|
||||
#define E(...) EXPAND(GET_E(__VA_ARGS__, E3, E2, E1)(__VA_ARGS__)),
|
||||
#else // !defined(COMPILER_MSVC)
|
||||
#define E_CPONLY(...) E(__VA_ARGS__)
|
||||
#define E(...) GET_E(__VA_ARGS__, E3, E2, E1)(__VA_ARGS__),
|
||||
#endif // !defined(COMPILER_MSVC)
|
||||
#else // !defined(COLOR_ID_MACROS_DEFINED)
|
||||
#undef D1
|
||||
#undef D2
|
||||
#undef E1
|
||||
#undef E2
|
||||
#undef E3
|
||||
#if defined(COMPILER_MSVC)
|
||||
#undef EXPAND
|
||||
#endif
|
||||
#undef E_CPONLY
|
||||
#undef GET_E
|
||||
#undef E
|
||||
#undef COLOR_ID_MACROS_DEFINED
|
||||
#endif // !defined(COLOR_ID_MACROS_DEFINED)
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=abcb584dbf5965834f415a0f2daeda3e361696b2$
|
||||
// $hash=6ee74f31d37a1b5ab3c9c5ccbe2dce9841329b38$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||
@@ -911,6 +911,8 @@ typedef struct _cef_browser_host_t {
|
||||
/// Returns the extension hosted in this browser or NULL if no extension is
|
||||
/// hosted. See cef_request_context_t::LoadExtension for details.
|
||||
///
|
||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
||||
///
|
||||
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
@@ -919,6 +921,8 @@ typedef struct _cef_browser_host_t {
|
||||
/// script. Background hosts do not have a window and are not displayable. See
|
||||
/// cef_request_context_t::LoadExtension for details.
|
||||
///
|
||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
||||
///
|
||||
int(CEF_CALLBACK* is_background_host)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
@@ -985,6 +989,13 @@ typedef struct _cef_browser_host_t {
|
||||
///
|
||||
int(CEF_CALLBACK* is_render_process_unresponsive)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this browser (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t(CEF_CALLBACK* get_runtime_style)(
|
||||
struct _cef_browser_host_t* self);
|
||||
} cef_browser_host_t;
|
||||
|
||||
///
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=60a08a60be70e8fe5df17f18f8e5758e1830d5e1$
|
||||
// $hash=7ecfb07a95315ff81937e9f68d419122fc88f1b7$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
|
||||
@@ -117,12 +117,13 @@ typedef struct _cef_download_handler_t {
|
||||
|
||||
///
|
||||
/// Called before a download begins. |suggested_name| is the suggested name
|
||||
/// for the download file. By default the download will be canceled. Execute
|
||||
/// |callback| either asynchronously or in this function to continue the
|
||||
/// download if desired. Do not keep a reference to |download_item| outside of
|
||||
/// this function.
|
||||
/// for the download file. Return true (1) and execute |callback| either
|
||||
/// asynchronously or in this function to continue or cancel the download.
|
||||
/// Return false (0) to proceed with default handling (cancel with Alloy
|
||||
/// style, download shelf with Chrome style). Do not keep a reference to
|
||||
/// |download_item| outside of this function.
|
||||
///
|
||||
void(CEF_CALLBACK* on_before_download)(
|
||||
int(CEF_CALLBACK* on_before_download)(
|
||||
struct _cef_download_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_download_item_t* download_item,
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=0ca2b788f70f8c9f5b2706d691d8e063be00ed19$
|
||||
// $hash=634054ad25154c30fb4ec630fe7fb79b0cf1f9b3$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
|
||||
@@ -54,6 +54,8 @@ struct _cef_request_context_t;
|
||||
/// Object representing an extension. Methods may be called on any thread unless
|
||||
/// otherwise indicated.
|
||||
///
|
||||
/// WARNING: This API is deprecated and will be removed in ~M127.
|
||||
///
|
||||
typedef struct _cef_extension_t {
|
||||
///
|
||||
/// Base structure.
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=5cfff4465a586d2b2ea7b54a9549096faec415f6$
|
||||
// $hash=ebac34c9b85de780ce7524211c5dd61a80d4576c$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
|
||||
@@ -80,6 +80,8 @@ typedef struct _cef_get_extension_resource_callback_t {
|
||||
/// cef_request_context_t::LoadExtension for information about extension
|
||||
/// loading.
|
||||
///
|
||||
/// WARNING: This API is deprecated and will be removed in ~M127.
|
||||
///
|
||||
typedef struct _cef_extension_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=5309b2f6da62526ed92c928c0918bc27898cf03b$
|
||||
// $hash=5151b6ea3c06e46a75f2cd7679044a2891063d29$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_
|
||||
@@ -149,17 +149,27 @@ typedef struct _cef_render_handler_t {
|
||||
/// Called when an element has been rendered to the shared texture handle.
|
||||
/// |type| indicates whether the element is the view or the popup widget.
|
||||
/// |dirtyRects| contains the set of rectangles in pixel coordinates that need
|
||||
/// to be repainted. |shared_handle| is the handle for a D3D11 Texture2D that
|
||||
/// can be accessed via ID3D11Device using the OpenSharedResource function.
|
||||
/// This function is only called when cef_window_tInfo::shared_texture_enabled
|
||||
/// is set to true (1), and is currently only supported on Windows.
|
||||
/// to be repainted. |info| contains the shared handle; on Windows it is a
|
||||
/// HANDLE to a texture that can be opened with D3D11 OpenSharedResource, on
|
||||
/// macOS it is an IOSurface pointer that can be opened with Metal or OpenGL,
|
||||
/// and on Linux it contains several planes, each with an fd to the underlying
|
||||
/// system native buffer.
|
||||
///
|
||||
void(CEF_CALLBACK* on_accelerated_paint)(struct _cef_render_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_paint_element_type_t type,
|
||||
size_t dirtyRectsCount,
|
||||
cef_rect_t const* dirtyRects,
|
||||
void* shared_handle);
|
||||
/// The underlying implementation uses a pool to deliver frames. As a result,
|
||||
/// the handle may differ every frame depending on how many frames are in-
|
||||
/// progress. The handle's resource cannot be cached and cannot be accessed
|
||||
/// outside of this callback. It should be reopened each time this callback is
|
||||
/// executed and the contents should be copied to a texture owned by the
|
||||
/// client application. The contents of |info| will be released back to the
|
||||
/// pool after this callback returns.
|
||||
///
|
||||
void(CEF_CALLBACK* on_accelerated_paint)(
|
||||
struct _cef_render_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_paint_element_type_t type,
|
||||
size_t dirtyRectsCount,
|
||||
cef_rect_t const* dirtyRects,
|
||||
const cef_accelerated_paint_info_t* info);
|
||||
|
||||
///
|
||||
/// Called to retrieve the size of the touch handle for the specified
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=23302ef6e4458aa3e7065aeaca3421a6f0b58361$
|
||||
// $hash=2c496139ca9a59303b1493ee93d2c3ae96a956c0$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
|
||||
@@ -253,6 +253,8 @@ typedef struct _cef_request_context_t {
|
||||
/// See https://developer.chrome.com/extensions for extension implementation
|
||||
/// and usage documentation.
|
||||
///
|
||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
||||
///
|
||||
void(CEF_CALLBACK* load_extension)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* root_directory,
|
||||
struct _cef_dictionary_value_t* manifest,
|
||||
@@ -264,6 +266,8 @@ typedef struct _cef_request_context_t {
|
||||
/// access to the extension (see HasExtension). This function must be called
|
||||
/// on the browser process UI thread.
|
||||
///
|
||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
||||
///
|
||||
int(CEF_CALLBACK* did_load_extension)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* extension_id);
|
||||
|
||||
@@ -273,6 +277,8 @@ typedef struct _cef_request_context_t {
|
||||
/// extension (see DidLoadExtension). This function must be called on the
|
||||
/// browser process UI thread.
|
||||
///
|
||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
||||
///
|
||||
int(CEF_CALLBACK* has_extension)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* extension_id);
|
||||
|
||||
@@ -282,6 +288,8 @@ typedef struct _cef_request_context_t {
|
||||
/// extension ID values. Returns true (1) on success. This function must be
|
||||
/// called on the browser process UI thread.
|
||||
///
|
||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
||||
///
|
||||
int(CEF_CALLBACK* get_extensions)(struct _cef_request_context_t* self,
|
||||
cef_string_list_t extension_ids);
|
||||
|
||||
@@ -290,6 +298,8 @@ typedef struct _cef_request_context_t {
|
||||
/// extension is accessible in this context (see HasExtension). This function
|
||||
/// must be called on the browser process UI thread.
|
||||
///
|
||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
||||
///
|
||||
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
|
||||
struct _cef_request_context_t* self,
|
||||
const cef_string_t* extension_id);
|
||||
@@ -368,6 +378,39 @@ typedef struct _cef_request_context_t {
|
||||
const cef_string_t* top_level_url,
|
||||
cef_content_setting_types_t content_type,
|
||||
cef_content_setting_values_t value);
|
||||
|
||||
///
|
||||
/// Sets the Chrome color scheme for all browsers that share this request
|
||||
/// context. |variant| values of SYSTEM, LIGHT and DARK change the underlying
|
||||
/// color mode (e.g. light vs dark). Other |variant| values determine how
|
||||
/// |user_color| will be applied in the current color mode. If |user_color| is
|
||||
/// transparent (0) the default color will be used.
|
||||
///
|
||||
void(CEF_CALLBACK* set_chrome_color_scheme)(
|
||||
struct _cef_request_context_t* self,
|
||||
cef_color_variant_t variant,
|
||||
cef_color_t user_color);
|
||||
|
||||
///
|
||||
/// Returns the current Chrome color scheme mode (SYSTEM, LIGHT or DARK). Must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
cef_color_variant_t(CEF_CALLBACK* get_chrome_color_scheme_mode)(
|
||||
struct _cef_request_context_t* self);
|
||||
|
||||
///
|
||||
/// Returns the current Chrome color scheme color, or transparent (0) for the
|
||||
/// default color. Must be called on the browser process UI thread.
|
||||
///
|
||||
cef_color_t(CEF_CALLBACK* get_chrome_color_scheme_color)(
|
||||
struct _cef_request_context_t* self);
|
||||
|
||||
///
|
||||
/// Returns the current Chrome color scheme variant. Must be called on the
|
||||
/// browser process UI thread.
|
||||
///
|
||||
cef_color_variant_t(CEF_CALLBACK* get_chrome_color_scheme_variant)(
|
||||
struct _cef_request_context_t* self);
|
||||
} cef_request_context_t;
|
||||
|
||||
///
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=2e5a3b3b1f427a7eb1e6a447fe0d31c5ace49469$
|
||||
// $hash=1c2fbbffaf51e90a2d55bfa7eb3fa3a4e315f4ac$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
|
||||
@@ -93,6 +93,13 @@ typedef struct _cef_browser_view_t {
|
||||
///
|
||||
void(CEF_CALLBACK* set_prefer_accelerators)(struct _cef_browser_view_t* self,
|
||||
int prefer_accelerators);
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this BrowserView (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t(CEF_CALLBACK* get_runtime_style)(
|
||||
struct _cef_browser_view_t* self);
|
||||
} cef_browser_view_t;
|
||||
|
||||
///
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=1f2a6e206b86945386bef57167b80e2fb6067c59$
|
||||
// $hash=a0a9f2bfcdf8e05d3d1114fcd8860caaa726ec98$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_
|
||||
@@ -141,6 +141,13 @@ typedef struct _cef_browser_view_delegate_t {
|
||||
struct _cef_browser_view_delegate_t* self,
|
||||
struct _cef_browser_view_t* browser_view,
|
||||
cef_gesture_command_t gesture_command);
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style for this BrowserView. See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t(CEF_CALLBACK* get_browser_runtime_style)(
|
||||
struct _cef_browser_view_delegate_t* self);
|
||||
} cef_browser_view_delegate_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=0ea5c2c5c1a8e8349f199a46642631be0c1bfb6b$
|
||||
// $hash=08f13de764f30261616372dfffb7f97c57957f73$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_
|
||||
@@ -339,18 +339,29 @@ typedef struct _cef_view_t {
|
||||
|
||||
///
|
||||
/// Sets the background color for this View. The background color will be
|
||||
/// automatically reset if the current theme changes. See
|
||||
/// cef_view_delegate_t::OnThemeChanged for related documentation.
|
||||
/// automatically reset when cef_view_delegate_t::OnThemeChanged is called.
|
||||
///
|
||||
void(CEF_CALLBACK* set_background_color)(struct _cef_view_t* self,
|
||||
cef_color_t color);
|
||||
|
||||
///
|
||||
/// Returns the background color for this View. If the background color has
|
||||
/// not been explicitly set then the current theme color will be returned.
|
||||
/// Returns the background color for this View. If the background color is
|
||||
/// unset then the current `GetThemeColor(CEF_ColorPrimaryBackground)` value
|
||||
/// will be returned. If this View belongs to an overlay (created with
|
||||
/// cef_window_t::AddOverlayView), and the background color is unset, then a
|
||||
/// value of transparent (0) will be returned.
|
||||
///
|
||||
cef_color_t(CEF_CALLBACK* get_background_color)(struct _cef_view_t* self);
|
||||
|
||||
///
|
||||
/// Returns the current theme color associated with |color_id|, or the
|
||||
/// placeholder color (red) if unset. See cef_color_ids.h for standard ID
|
||||
/// values. Standard colors can be overridden and custom colors can be added
|
||||
/// using cef_window_t::SetThemeColor.
|
||||
///
|
||||
cef_color_t(CEF_CALLBACK* get_theme_color)(struct _cef_view_t* self,
|
||||
int color_id);
|
||||
|
||||
///
|
||||
/// Convert |point| from this View's coordinate system to DIP screen
|
||||
/// coordinates. This View must belong to a Window when calling this function.
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=d3624baa94bb722c48880b4319f5d5e8035eaa46$
|
||||
// $hash=0f562c026f64ca19a32834dcc1e1cd3a98be2f1f$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_
|
||||
@@ -143,11 +143,22 @@ typedef struct _cef_view_delegate_t {
|
||||
|
||||
///
|
||||
/// Called when the theme for |view| has changed, after the new theme colors
|
||||
/// have already been applied. This will be called at least one time when
|
||||
/// |view| is added to a parent View. Further theme changes can be disabled by
|
||||
/// passing the `--force-dark-mode` or `--force-light-mode` command-line flag.
|
||||
/// Optionally use this callback to override the new theme colors by calling
|
||||
/// the appropriate cef_view_t functions (SetBackgroundColor, etc).
|
||||
/// have already been applied. Views are notified via the component hierarchy
|
||||
/// in depth-first reverse order (children before parents).
|
||||
///
|
||||
/// This will be called in the following cases:
|
||||
///
|
||||
/// 1. When |view|, or a parent of |view|, is added to a Window. 2. When the
|
||||
/// native/OS or Chrome theme changes for the Window that contains
|
||||
/// |view|. See CefWindowDelegate::OnThemeColorsChanged documentation.
|
||||
/// 3. When the client explicitly calls cef_window_t::ThemeChanged on the
|
||||
/// Window
|
||||
/// that contains |view|.
|
||||
///
|
||||
/// Optionally use this callback to override the new per-View theme colors by
|
||||
/// calling cef_view_t::SetBackgroundColor or the appropriate component-
|
||||
/// specific function. See cef_window_t::SetThemeColor documentation for how
|
||||
/// to customize additional Window theme colors.
|
||||
///
|
||||
void(CEF_CALLBACK* on_theme_changed)(struct _cef_view_delegate_t* self,
|
||||
struct _cef_view_t* view);
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=dbe89dfdd14eb114e3f2d16fbfc55624bb91e7ce$
|
||||
// $hash=dd32b58ec9aca0e04a1d30ccf94a741995fcc094$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_
|
||||
@@ -364,6 +364,50 @@ typedef struct _cef_window_t {
|
||||
/// Remove all keyboard accelerators.
|
||||
///
|
||||
void(CEF_CALLBACK* remove_all_accelerators)(struct _cef_window_t* self);
|
||||
|
||||
///
|
||||
/// Override a standard theme color or add a custom color associated with
|
||||
/// |color_id|. See cef_color_ids.h for standard ID values. Recommended usage
|
||||
/// is as follows:
|
||||
///
|
||||
/// 1. Customize the default native/OS theme by calling SetThemeColor before
|
||||
/// showing the first Window. When done setting colors call
|
||||
/// CefWindow::ThemeChanged to trigger CefViewDelegate::OnThemeChanged
|
||||
/// notifications.
|
||||
/// 2. Customize the current native/OS or Chrome theme after it changes by
|
||||
/// calling SetThemeColor from the CefWindowDelegate::OnThemeColorsChanged
|
||||
/// callback. CefViewDelegate::OnThemeChanged notifications will then be
|
||||
/// triggered automatically.
|
||||
///
|
||||
/// The configured color will be available immediately via
|
||||
/// cef_view_t::GetThemeColor and will be applied to each View in this
|
||||
/// Window's component hierarchy when cef_view_delegate_t::OnThemeChanged is
|
||||
/// called. See OnThemeColorsChanged documentation for additional details.
|
||||
///
|
||||
/// Clients wishing to add custom colors should use |color_id| values >=
|
||||
/// CEF_ChromeColorsEnd.
|
||||
///
|
||||
void(CEF_CALLBACK* set_theme_color)(struct _cef_window_t* self,
|
||||
int color_id,
|
||||
cef_color_t color);
|
||||
|
||||
///
|
||||
/// Trigger cef_view_delegate_t::OnThemeChanged callbacks for each View in
|
||||
/// this Window's component hierarchy. Unlike a native/OS or Chrome theme
|
||||
/// change this function does not reset theme colors to standard values and
|
||||
/// does not result in a call to cef_window_delegate_t::OnThemeColorsChanged.
|
||||
///
|
||||
/// Do not call this function from cef_window_delegate_t::OnThemeColorsChanged
|
||||
/// or cef_view_delegate_t::OnThemeChanged.
|
||||
///
|
||||
void(CEF_CALLBACK* theme_changed)(struct _cef_window_t* self);
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this Window (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t(CEF_CALLBACK* get_runtime_style)(
|
||||
struct _cef_window_t* self);
|
||||
} cef_window_t;
|
||||
|
||||
///
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=c1c2705cdef7d9189557b57531dc2d53e9f68d0c$
|
||||
// $hash=e8c9e32caa8d317a7cb6ff2f0ad6be49cf1b7ad1$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
|
||||
@@ -182,6 +182,20 @@ typedef struct _cef_window_delegate_t {
|
||||
struct _cef_window_t* window,
|
||||
float* titlebar_height);
|
||||
|
||||
///
|
||||
/// Return whether the view should accept the initial mouse-down event,
|
||||
/// allowing it to respond to click-through behavior. If STATE_ENABLED is
|
||||
/// returned, the view will be sent a mouseDown: message for an initial mouse-
|
||||
/// down event, activating the view with one click, instead of clicking first
|
||||
/// to make the window active and then clicking the view.
|
||||
///
|
||||
/// This function is only supported on macOS. For more details, refer to the
|
||||
/// documentation of acceptsFirstMouse.
|
||||
///
|
||||
cef_state_t(CEF_CALLBACK* accepts_first_mouse)(
|
||||
struct _cef_window_delegate_t* self,
|
||||
struct _cef_window_t* window);
|
||||
|
||||
///
|
||||
/// Return true (1) if |window| can be resized.
|
||||
///
|
||||
@@ -224,6 +238,50 @@ typedef struct _cef_window_delegate_t {
|
||||
int(CEF_CALLBACK* on_key_event)(struct _cef_window_delegate_t* self,
|
||||
struct _cef_window_t* window,
|
||||
const cef_key_event_t* event);
|
||||
|
||||
///
|
||||
/// Called after the native/OS or Chrome theme for |window| has changed.
|
||||
/// |chrome_theme| will be true (1) if the notification is for a Chrome theme.
|
||||
///
|
||||
/// Native/OS theme colors are configured globally and do not need to be
|
||||
/// customized for each Window individually. An example of a native/OS theme
|
||||
/// change that triggers this callback is when the user switches between dark
|
||||
/// and light mode during application lifespan. Native/OS theme changes can be
|
||||
/// disabled by passing the `--force-dark-mode` or `--force-light-mode`
|
||||
/// command-line flag.
|
||||
///
|
||||
/// Chrome theme colors will be applied and this callback will be triggered
|
||||
/// if/when a BrowserView is added to the Window's component hierarchy. Chrome
|
||||
/// theme colors can be configured on a per-RequestContext basis using
|
||||
/// cef_request_context_t::SetChromeColorScheme or (Chrome runtime only) by
|
||||
/// visiting chrome://settings/manageProfile. Any theme changes using those
|
||||
/// mechanisms will also trigger this callback. Chrome theme colors will be
|
||||
/// persisted and restored from disk cache with the Chrome runtime, and with
|
||||
/// the Alloy runtime if persist_user_preferences is set to true (1) via
|
||||
/// CefSettings or cef_request_context_tSettings.
|
||||
///
|
||||
/// This callback is not triggered on Window creation so clients that wish to
|
||||
/// customize the initial native/OS theme must call
|
||||
/// cef_window_t::SetThemeColor and cef_window_t::ThemeChanged before showing
|
||||
/// the first Window.
|
||||
///
|
||||
/// Theme colors will be reset to standard values before this callback is
|
||||
/// called for the first affected Window. Call cef_window_t::SetThemeColor
|
||||
/// from inside this callback to override a standard color or add a custom
|
||||
/// color. cef_view_delegate_t::OnThemeChanged will be called after this
|
||||
/// callback for the complete |window| component hierarchy.
|
||||
///
|
||||
void(CEF_CALLBACK* on_theme_colors_changed)(
|
||||
struct _cef_window_delegate_t* self,
|
||||
struct _cef_window_t* window,
|
||||
int chrome_theme);
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style for this Window. See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t(CEF_CALLBACK* get_window_runtime_style)(
|
||||
struct _cef_window_delegate_t* self);
|
||||
} cef_window_delegate_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -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 "a741045ff32b6feeaedf4e767ee0a18ed1c68007"
|
||||
#define CEF_API_HASH_UNIVERSAL "73e8743408bfeba0df3b567bfd04b2eb642df11d"
|
||||
#if defined(OS_WIN)
|
||||
#define CEF_API_HASH_PLATFORM "1180df9630b71b08a4c4874aa66484c3ca391327"
|
||||
#define CEF_API_HASH_PLATFORM "3a73f4c69062c6f413e00c1821f6e6df91a2a787"
|
||||
#elif defined(OS_MAC)
|
||||
#define CEF_API_HASH_PLATFORM "eaed012692fa480863cb78189e21ddf738fb8d5d"
|
||||
#define CEF_API_HASH_PLATFORM "f5fb92747082f06a9c42724b0b717accc29e3879"
|
||||
#elif defined(OS_LINUX)
|
||||
#define CEF_API_HASH_PLATFORM "e17a9dca9ce61905920a734e71333729578da10e"
|
||||
#define CEF_API_HASH_PLATFORM "8775d620c6b17725bddba2c1c3a21353b4d8acb1"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -942,6 +942,8 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
||||
/// Returns the extension hosted in this browser or NULL if no extension is
|
||||
/// hosted. See CefRequestContext::LoadExtension for details.
|
||||
///
|
||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefExtension> GetExtension() = 0;
|
||||
|
||||
@@ -950,6 +952,8 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
||||
/// Background hosts do not have a window and are not displayable. See
|
||||
/// CefRequestContext::LoadExtension for details.
|
||||
///
|
||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsBackgroundHost() = 0;
|
||||
|
||||
@@ -1018,6 +1022,13 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsRenderProcessUnresponsive() = 0;
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this browser (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
|
||||
virtual cef_runtime_style_t GetRuntimeStyle() = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_BROWSER_H_
|
||||
|
@@ -106,17 +106,19 @@ class CefDownloadHandler : public virtual CefBaseRefCounted {
|
||||
|
||||
///
|
||||
/// Called before a download begins. |suggested_name| is the suggested name
|
||||
/// for the download file. By default the download will be canceled. Execute
|
||||
/// |callback| either asynchronously or in this method to continue the
|
||||
/// download if desired. Do not keep a reference to |download_item| outside of
|
||||
/// this method.
|
||||
/// for the download file. Return true and execute |callback| either
|
||||
/// asynchronously or in this method to continue or cancel the download.
|
||||
/// Return false to proceed with default handling (cancel with Alloy style,
|
||||
/// download shelf with Chrome style). Do not keep a reference to
|
||||
/// |download_item| outside of this method.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnBeforeDownload(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDownloadItem> download_item,
|
||||
const CefString& suggested_name,
|
||||
CefRefPtr<CefBeforeDownloadCallback> callback) = 0;
|
||||
virtual bool OnBeforeDownload(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDownloadItem> download_item,
|
||||
const CefString& suggested_name,
|
||||
CefRefPtr<CefBeforeDownloadCallback> callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Called when a download's status or progress information has been updated.
|
||||
|
@@ -48,6 +48,8 @@ class CefRequestContext;
|
||||
/// Object representing an extension. Methods may be called on any thread unless
|
||||
/// otherwise indicated.
|
||||
///
|
||||
/// WARNING: This API is deprecated and will be removed in ~M127.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefExtension : public CefBaseRefCounted {
|
||||
public:
|
||||
|
@@ -70,6 +70,8 @@ class CefGetExtensionResourceCallback : public CefBaseRefCounted {
|
||||
/// The methods of this class will be called on the UI thread. See
|
||||
/// CefRequestContext::LoadExtension for information about extension loading.
|
||||
///
|
||||
/// WARNING: This API is deprecated and will be removed in ~M127.
|
||||
///
|
||||
/*--cef(source=client)--*/
|
||||
class CefExtensionHandler : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
|
@@ -152,16 +152,25 @@ class CefRenderHandler : public virtual CefBaseRefCounted {
|
||||
/// Called when an element has been rendered to the shared texture handle.
|
||||
/// |type| indicates whether the element is the view or the popup widget.
|
||||
/// |dirtyRects| contains the set of rectangles in pixel coordinates that need
|
||||
/// to be repainted. |shared_handle| is the handle for a D3D11 Texture2D that
|
||||
/// can be accessed via ID3D11Device using the OpenSharedResource method. This
|
||||
/// method is only called when CefWindowInfo::shared_texture_enabled is set to
|
||||
/// true, and is currently only supported on Windows.
|
||||
/// to be repainted. |info| contains the shared handle; on Windows it is a
|
||||
/// HANDLE to a texture that can be opened with D3D11 OpenSharedResource, on
|
||||
/// macOS it is an IOSurface pointer that can be opened with Metal or OpenGL,
|
||||
/// and on Linux it contains several planes, each with an fd to the underlying
|
||||
/// system native buffer.
|
||||
///
|
||||
/// The underlying implementation uses a pool to deliver frames. As a result,
|
||||
/// the handle may differ every frame depending on how many frames are
|
||||
/// in-progress. The handle's resource cannot be cached and cannot be accessed
|
||||
/// outside of this callback. It should be reopened each time this callback is
|
||||
/// executed and the contents should be copied to a texture owned by the
|
||||
/// client application. The contents of |info| will be released back to the
|
||||
/// pool after this callback returns.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
|
||||
PaintElementType type,
|
||||
const RectList& dirtyRects,
|
||||
void* shared_handle) {}
|
||||
const CefAcceleratedPaintInfo& info) {}
|
||||
|
||||
///
|
||||
/// Called to retrieve the size of the touch handle for the specified
|
||||
|
@@ -266,6 +266,8 @@ class CefRequestContext : public CefPreferenceManager {
|
||||
/// See https://developer.chrome.com/extensions for extension implementation
|
||||
/// and usage documentation.
|
||||
///
|
||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
||||
///
|
||||
/*--cef(optional_param=manifest,optional_param=handler)--*/
|
||||
virtual void LoadExtension(const CefString& root_directory,
|
||||
CefRefPtr<CefDictionaryValue> manifest,
|
||||
@@ -277,6 +279,8 @@ class CefRequestContext : public CefPreferenceManager {
|
||||
/// access to the extension (see HasExtension). This method must be called on
|
||||
/// the browser process UI thread.
|
||||
///
|
||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool DidLoadExtension(const CefString& extension_id) = 0;
|
||||
|
||||
@@ -286,6 +290,8 @@ class CefRequestContext : public CefPreferenceManager {
|
||||
/// extension (see DidLoadExtension). This method must be called on the
|
||||
/// browser process UI thread.
|
||||
///
|
||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool HasExtension(const CefString& extension_id) = 0;
|
||||
|
||||
@@ -295,6 +301,8 @@ class CefRequestContext : public CefPreferenceManager {
|
||||
/// extension ID values. Returns true on success. This method must be called
|
||||
/// on the browser process UI thread.
|
||||
///
|
||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetExtensions(std::vector<CefString>& extension_ids) = 0;
|
||||
|
||||
@@ -303,6 +311,8 @@ class CefRequestContext : public CefPreferenceManager {
|
||||
/// extension is accessible in this context (see HasExtension). This method
|
||||
/// must be called on the browser process UI thread.
|
||||
///
|
||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefExtension> GetExtension(
|
||||
const CefString& extension_id) = 0;
|
||||
@@ -381,6 +391,38 @@ class CefRequestContext : public CefPreferenceManager {
|
||||
const CefString& top_level_url,
|
||||
cef_content_setting_types_t content_type,
|
||||
cef_content_setting_values_t value) = 0;
|
||||
|
||||
///
|
||||
/// Sets the Chrome color scheme for all browsers that share this request
|
||||
/// context. |variant| values of SYSTEM, LIGHT and DARK change the underlying
|
||||
/// color mode (e.g. light vs dark). Other |variant| values determine how
|
||||
/// |user_color| will be applied in the current color mode. If |user_color| is
|
||||
/// transparent (0) the default color will be used.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetChromeColorScheme(cef_color_variant_t variant,
|
||||
cef_color_t user_color) = 0;
|
||||
|
||||
///
|
||||
/// Returns the current Chrome color scheme mode (SYSTEM, LIGHT or DARK). Must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef(default_retval=CEF_COLOR_VARIANT_SYSTEM)--*/
|
||||
virtual cef_color_variant_t GetChromeColorSchemeMode() = 0;
|
||||
|
||||
///
|
||||
/// Returns the current Chrome color scheme color, or transparent (0) for the
|
||||
/// default color. Must be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef(default_retval=0)--*/
|
||||
virtual cef_color_t GetChromeColorSchemeColor() = 0;
|
||||
|
||||
///
|
||||
/// Returns the current Chrome color scheme variant. Must be called on the
|
||||
/// browser process UI thread.
|
||||
///
|
||||
/*--cef(default_retval=CEF_COLOR_VARIANT_SYSTEM)--*/
|
||||
virtual cef_color_variant_t GetChromeColorSchemeVariant() = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_
|
||||
|
@@ -70,6 +70,7 @@ struct CefWindowInfoTraits {
|
||||
target->shared_texture_enabled = src->shared_texture_enabled;
|
||||
target->external_begin_frame_enabled = src->external_begin_frame_enabled;
|
||||
target->window = src->window;
|
||||
target->runtime_style = src->runtime_style;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -110,6 +111,7 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||
void SetAsWindowless(CefWindowHandle parent) {
|
||||
windowless_rendering_enabled = true;
|
||||
parent_window = parent;
|
||||
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -71,6 +71,7 @@ struct CefWindowInfoTraits {
|
||||
target->shared_texture_enabled = src->shared_texture_enabled;
|
||||
target->external_begin_frame_enabled = src->external_begin_frame_enabled;
|
||||
target->view = src->view;
|
||||
target->runtime_style = src->runtime_style;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -112,6 +113,7 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||
void SetAsWindowless(CefWindowHandle parent) {
|
||||
windowless_rendering_enabled = true;
|
||||
parent_view = parent;
|
||||
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -2925,21 +2925,6 @@ typedef enum {
|
||||
RESPONSE_FILTER_ERROR
|
||||
} cef_response_filter_status_t;
|
||||
|
||||
///
|
||||
/// Describes how to interpret the components of a pixel.
|
||||
///
|
||||
typedef enum {
|
||||
///
|
||||
/// RGBA with 8 bits per pixel (32bits total).
|
||||
///
|
||||
CEF_COLOR_TYPE_RGBA_8888,
|
||||
|
||||
///
|
||||
/// BGRA with 8 bits per pixel (32bits total).
|
||||
///
|
||||
CEF_COLOR_TYPE_BGRA_8888,
|
||||
} cef_color_type_t;
|
||||
|
||||
///
|
||||
/// Describes how to interpret the alpha component of a pixel.
|
||||
///
|
||||
@@ -3854,6 +3839,20 @@ typedef enum {
|
||||
CEF_ZOOM_COMMAND_IN,
|
||||
} cef_zoom_command_t;
|
||||
|
||||
///
|
||||
/// Specifies the color variants supported by
|
||||
/// CefRequestContext::SetChromeThemeColor.
|
||||
///
|
||||
typedef enum {
|
||||
CEF_COLOR_VARIANT_SYSTEM,
|
||||
CEF_COLOR_VARIANT_LIGHT,
|
||||
CEF_COLOR_VARIANT_DARK,
|
||||
CEF_COLOR_VARIANT_TONAL_SPOT,
|
||||
CEF_COLOR_VARIANT_NEUTRAL,
|
||||
CEF_COLOR_VARIANT_VIBRANT,
|
||||
CEF_COLOR_VARIANT_EXPRESSIVE,
|
||||
} cef_color_variant_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
57
include/internal/cef_types_color.h
Normal file
57
include/internal/cef_types_color.h
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2024 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.
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_COLOR_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_COLOR_H_
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Describes how to interpret the components of a pixel.
|
||||
///
|
||||
typedef enum {
|
||||
///
|
||||
/// RGBA with 8 bits per pixel (32bits total).
|
||||
///
|
||||
CEF_COLOR_TYPE_RGBA_8888,
|
||||
|
||||
///
|
||||
/// BGRA with 8 bits per pixel (32bits total).
|
||||
///
|
||||
CEF_COLOR_TYPE_BGRA_8888,
|
||||
} cef_color_type_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_COLOR_H_
|
@@ -380,6 +380,13 @@ typedef enum {
|
||||
/// a requesting-origin/top-level-site combination and persistent.
|
||||
CEF_CONTENT_SETTING_TYPE_TOP_LEVEL_TPCD_TRIAL,
|
||||
|
||||
/// Content Setting for a first-party origin trial that allows websites to
|
||||
/// enable third-party cookie deprecation.
|
||||
/// ALLOW (default): no effect (e.g. third-party cookies allowed, if not
|
||||
/// blocked otherwise).
|
||||
/// BLOCK: third-party cookies blocked, but 3PCD mitigations enabled.
|
||||
CEF_CONTENT_SETTING_TOP_LEVEL_TPCD_ORIGIN_TRIAL,
|
||||
|
||||
/// Content setting used to indicate whether entering picture-in-picture
|
||||
/// automatically should be enabled.
|
||||
CEF_CONTENT_SETTING_TYPE_AUTO_PICTURE_IN_PICTURE,
|
||||
@@ -428,6 +435,15 @@ typedef enum {
|
||||
/// Pointer Lock API allows a site to hide the cursor and have exclusive
|
||||
/// access to mouse inputs.
|
||||
CEF_CONTENT_SETTING_TYPE_POINTER_LOCK,
|
||||
|
||||
/// Website setting which is used for UnusedSitePermissionsService to store
|
||||
/// auto-revoked notification permissions from abusive sites.
|
||||
REVOKED_ABUSIVE_NOTIFICATION_PERMISSIONS,
|
||||
|
||||
/// Content setting that controls tracking protection status per site.
|
||||
/// BLOCK: Protections enabled. This is the default state.
|
||||
/// ALLOW: Protections disabled.
|
||||
TRACKING_PROTECTION,
|
||||
} cef_content_setting_types_t;
|
||||
|
||||
///
|
||||
|
@@ -43,7 +43,9 @@ typedef struct _XDisplay XDisplay;
|
||||
|
||||
#include "include/internal/cef_export.h"
|
||||
#include "include/internal/cef_string.h"
|
||||
#include "include/internal/cef_types_color.h"
|
||||
#include "include/internal/cef_types_geometry.h"
|
||||
#include "include/internal/cef_types_runtime.h"
|
||||
|
||||
// Handle types.
|
||||
#if defined(CEF_X11)
|
||||
@@ -135,8 +137,65 @@ typedef struct _cef_window_info_t {
|
||||
/// Pointer for the new browser window. Only used with windowed rendering.
|
||||
///
|
||||
cef_window_handle_t window;
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style. Alloy style will always be used if
|
||||
/// |windowless_rendering_enabled| is true. See cef_runtime_style_t
|
||||
/// documentation for details.
|
||||
///
|
||||
cef_runtime_style_t runtime_style;
|
||||
} cef_window_info_t;
|
||||
|
||||
///
|
||||
/// Structure containing the plane information of the shared texture.
|
||||
/// Sync with native_pixmap_handle.h
|
||||
///
|
||||
typedef struct _cef_accelerated_paint_native_pixmap_plane_info_t {
|
||||
///
|
||||
/// The strides and offsets in bytes to be used when accessing the buffers via
|
||||
/// a memory mapping. One per plane per entry. Size in bytes of the plane is
|
||||
/// necessary to map the buffers.
|
||||
///
|
||||
uint32_t stride;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
|
||||
///
|
||||
/// File descriptor for the underlying memory object (usually dmabuf).
|
||||
///
|
||||
int fd;
|
||||
} cef_accelerated_paint_native_pixmap_plane_t;
|
||||
|
||||
#define kAcceleratedPaintMaxPlanes 4
|
||||
|
||||
///
|
||||
/// Structure containing shared texture information for the OnAcceleratedPaint
|
||||
/// callback. Resources will be released to the underlying pool for reuse when
|
||||
/// the callback returns from client code.
|
||||
///
|
||||
typedef struct _cef_accelerated_paint_info_t {
|
||||
///
|
||||
/// Planes of the shared texture, usually file descriptors of dmabufs.
|
||||
///
|
||||
cef_accelerated_paint_native_pixmap_plane_t
|
||||
planes[kAcceleratedPaintMaxPlanes];
|
||||
|
||||
///
|
||||
/// Plane count.
|
||||
///
|
||||
int plane_count;
|
||||
|
||||
///
|
||||
/// Modifier could be used with EGL driver.
|
||||
///
|
||||
uint64_t modifier;
|
||||
|
||||
///
|
||||
/// The pixel format of the texture.
|
||||
///
|
||||
cef_color_type_t format;
|
||||
} cef_accelerated_paint_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -35,7 +35,9 @@
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#include "include/internal/cef_string.h"
|
||||
#include "include/internal/cef_types_color.h"
|
||||
#include "include/internal/cef_types_geometry.h"
|
||||
#include "include/internal/cef_types_runtime.h"
|
||||
|
||||
// Handle types.
|
||||
// Actually NSCursor*
|
||||
@@ -44,6 +46,8 @@
|
||||
#define cef_event_handle_t void*
|
||||
// Actually NSView*
|
||||
#define cef_window_handle_t void*
|
||||
// Actually IOSurface*
|
||||
#define cef_shared_texture_handle_t void*
|
||||
|
||||
#define kNullCursorHandle NULL
|
||||
#define kNullEventHandle NULL
|
||||
@@ -134,8 +138,32 @@ typedef struct _cef_window_info_t {
|
||||
/// rendering.
|
||||
///
|
||||
cef_window_handle_t view;
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style. Alloy style will always be used if
|
||||
/// |windowless_rendering_enabled| is true or if |parent_view| is provided.
|
||||
/// See cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t runtime_style;
|
||||
} cef_window_info_t;
|
||||
|
||||
///
|
||||
/// Structure containing shared texture information for the OnAcceleratedPaint
|
||||
/// callback. Resources will be released to the underlying pool for reuse when
|
||||
/// the callback returns from client code.
|
||||
///
|
||||
typedef struct _cef_accelerated_paint_info_t {
|
||||
///
|
||||
/// Handle for the shared texture IOSurface.
|
||||
///
|
||||
cef_shared_texture_handle_t shared_texture_io_surface;
|
||||
|
||||
///
|
||||
/// The pixel format of the texture.
|
||||
///
|
||||
cef_color_type_t format;
|
||||
} cef_accelerated_paint_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
88
include/internal/cef_types_runtime.h
Normal file
88
include/internal/cef_types_runtime.h
Normal file
@@ -0,0 +1,88 @@
|
||||
// Copyright (c) 2024 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.
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_RUNTIME_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_RUNTIME_H_
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// CEF supports both a Chrome runtime (based on the Chrome UI layer) and an
|
||||
/// Alloy runtime (based on the Chromium content layer). The Chrome runtime
|
||||
/// provides the full Chrome UI and browser functionality whereas the Alloy
|
||||
/// runtime provides less default browser functionality but adds additional
|
||||
/// client callbacks and support for windowless (off-screen) rendering. For
|
||||
/// additional comparative details on runtime types see
|
||||
/// https://bitbucket.org/chromiumembedded/cef/wiki/Architecture.md#markdown-header-cef3
|
||||
///
|
||||
/// Each runtime is composed of a bootstrap component and a style component. The
|
||||
/// bootstrap component is configured via CefSettings.chrome_runtime and cannot
|
||||
/// be changed after CefInitialize. The style component is individually
|
||||
/// configured for each window/browser at creation time and, in combination with
|
||||
/// the Chrome bootstrap, different styles can be mixed during runtime.
|
||||
///
|
||||
/// Windowless rendering will always use Alloy style. Windowed rendering with a
|
||||
/// default window or client-provided parent window can configure the style via
|
||||
/// CefWindowInfo.runtime_style. Windowed rendering with the Views framework can
|
||||
/// configure the style via CefWindowDelegate::GetWindowRuntimeStyle and
|
||||
/// CefBrowserViewDelegate::GetBrowserRuntimeStyle. Alloy style Windows with the
|
||||
/// Views framework can host only Alloy style BrowserViews but Chrome style
|
||||
/// Windows can host both style BrowserViews. Additionally, a Chrome style
|
||||
/// Window can host at most one Chrome style BrowserView but potentially
|
||||
/// multiple Alloy style BrowserViews. See CefWindowInfo.runtime_style
|
||||
/// documentation for any additional platform-specific limitations.
|
||||
///
|
||||
typedef enum {
|
||||
///
|
||||
/// Use the default runtime style. The default style will match the
|
||||
/// CefSettings.chrome_runtime value in most cases. See above documentation
|
||||
/// for exceptions.
|
||||
///
|
||||
CEF_RUNTIME_STYLE_DEFAULT,
|
||||
|
||||
///
|
||||
/// Use the Chrome runtime style. Only supported with the Chrome runtime.
|
||||
///
|
||||
CEF_RUNTIME_STYLE_CHROME,
|
||||
|
||||
///
|
||||
/// Use the Alloy runtime style. Supported with both the Alloy and Chrome
|
||||
/// runtime.
|
||||
///
|
||||
CEF_RUNTIME_STYLE_ALLOY,
|
||||
} cef_runtime_style_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_RUNTIME_H_
|
@@ -37,12 +37,15 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include "include/internal/cef_string.h"
|
||||
#include "include/internal/cef_types_color.h"
|
||||
#include "include/internal/cef_types_geometry.h"
|
||||
#include "include/internal/cef_types_runtime.h"
|
||||
|
||||
// Handle types.
|
||||
#define cef_cursor_handle_t HCURSOR
|
||||
#define cef_event_handle_t MSG*
|
||||
#define cef_window_handle_t HWND
|
||||
#define cef_shared_texture_handle_t HANDLE
|
||||
|
||||
#define kNullCursorHandle NULL
|
||||
#define kNullEventHandle NULL
|
||||
@@ -102,8 +105,33 @@ typedef struct _cef_window_info_t {
|
||||
/// Handle for the new browser window. Only used with windowed rendering.
|
||||
///
|
||||
cef_window_handle_t window;
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style. Alloy style will always be used if
|
||||
/// |windowless_rendering_enabled| is true. See cef_runtime_style_t
|
||||
/// documentation for details.
|
||||
///
|
||||
cef_runtime_style_t runtime_style;
|
||||
} cef_window_info_t;
|
||||
|
||||
///
|
||||
/// Structure containing shared texture information for the OnAcceleratedPaint
|
||||
/// callback. Resources will be released to the underlying pool for reuse when
|
||||
/// the callback returns from client code.
|
||||
///
|
||||
typedef struct _cef_accelerated_paint_info_t {
|
||||
///
|
||||
/// Handle for the shared texture. The shared texture is instantiated
|
||||
/// without a keyed mutex.
|
||||
///
|
||||
cef_shared_texture_handle_t shared_texture_handle;
|
||||
|
||||
///
|
||||
/// The pixel format of the texture.
|
||||
///
|
||||
cef_color_type_t format;
|
||||
} cef_accelerated_paint_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -750,4 +750,14 @@ struct CefMediaSinkDeviceInfoTraits {
|
||||
///
|
||||
using CefMediaSinkDeviceInfo = CefStructBase<CefMediaSinkDeviceInfoTraits>;
|
||||
|
||||
///
|
||||
/// Class representing accelerated paint info.
|
||||
///
|
||||
class CefAcceleratedPaintInfo : public cef_accelerated_paint_info_t {
|
||||
public:
|
||||
CefAcceleratedPaintInfo() : cef_accelerated_paint_info_t{} {}
|
||||
CefAcceleratedPaintInfo(const cef_accelerated_paint_info_t& r)
|
||||
: cef_accelerated_paint_info_t(r) {}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
|
||||
|
@@ -73,6 +73,7 @@ struct CefWindowInfoTraits {
|
||||
target->shared_texture_enabled = src->shared_texture_enabled;
|
||||
target->external_begin_frame_enabled = src->external_begin_frame_enabled;
|
||||
target->window = src->window;
|
||||
target->runtime_style = src->runtime_style;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -130,6 +131,7 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||
void SetAsWindowless(CefWindowHandle parent) {
|
||||
windowless_rendering_enabled = TRUE;
|
||||
parent_window = parent;
|
||||
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -107,6 +107,13 @@ class CefBrowserView : public CefView {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetPreferAccelerators(bool prefer_accelerators) = 0;
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this BrowserView (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
|
||||
virtual cef_runtime_style_t GetRuntimeStyle() = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_H_
|
||||
|
@@ -140,6 +140,15 @@ class CefBrowserViewDelegate : public CefViewDelegate {
|
||||
cef_gesture_command_t gesture_command) {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style for this BrowserView. See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
|
||||
virtual cef_runtime_style_t GetBrowserRuntimeStyle() {
|
||||
return CEF_RUNTIME_STYLE_DEFAULT;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_DELEGATE_H_
|
||||
|
@@ -358,19 +358,30 @@ class CefView : public CefBaseRefCounted {
|
||||
|
||||
///
|
||||
/// Sets the background color for this View. The background color will be
|
||||
/// automatically reset if the current theme changes. See
|
||||
/// CefViewDelegate::OnThemeChanged for related documentation.
|
||||
/// automatically reset when CefViewDelegate::OnThemeChanged is called.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetBackgroundColor(cef_color_t color) = 0;
|
||||
|
||||
///
|
||||
/// Returns the background color for this View. If the background color has
|
||||
/// not been explicitly set then the current theme color will be returned.
|
||||
/// Returns the background color for this View. If the background color is
|
||||
/// unset then the current `GetThemeColor(CEF_ColorPrimaryBackground)` value
|
||||
/// will be returned. If this View belongs to an overlay (created with
|
||||
/// CefWindow::AddOverlayView), and the background color is unset, then a
|
||||
/// value of transparent (0) will be returned.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual cef_color_t GetBackgroundColor() = 0;
|
||||
|
||||
///
|
||||
/// Returns the current theme color associated with |color_id|, or the
|
||||
/// placeholder color (red) if unset. See cef_color_ids.h for standard ID
|
||||
/// values. Standard colors can be overridden and custom colors can be added
|
||||
/// using CefWindow::SetThemeColor.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual cef_color_t GetThemeColor(int color_id) = 0;
|
||||
|
||||
///
|
||||
/// Convert |point| from this View's coordinate system to DIP screen
|
||||
/// coordinates. This View must belong to a Window when calling this method.
|
||||
|
@@ -134,11 +134,21 @@ class CefViewDelegate : public virtual CefBaseRefCounted {
|
||||
|
||||
///
|
||||
/// Called when the theme for |view| has changed, after the new theme colors
|
||||
/// have already been applied. This will be called at least one time when
|
||||
/// |view| is added to a parent View. Further theme changes can be disabled by
|
||||
/// passing the `--force-dark-mode` or `--force-light-mode` command-line flag.
|
||||
/// Optionally use this callback to override the new theme colors by calling
|
||||
/// the appropriate CefView methods (SetBackgroundColor, etc).
|
||||
/// have already been applied. Views are notified via the component hierarchy
|
||||
/// in depth-first reverse order (children before parents).
|
||||
///
|
||||
/// This will be called in the following cases:
|
||||
///
|
||||
/// 1. When |view|, or a parent of |view|, is added to a Window.
|
||||
/// 2. When the native/OS or Chrome theme changes for the Window that contains
|
||||
/// |view|. See CefWindowDelegate::OnThemeColorsChanged documentation.
|
||||
/// 3. When the client explicitly calls CefWindow::ThemeChanged on the Window
|
||||
/// that contains |view|.
|
||||
///
|
||||
/// Optionally use this callback to override the new per-View theme colors by
|
||||
/// calling CefView::SetBackgroundColor or the appropriate component-specific
|
||||
/// method. See CefWindow::SetThemeColor documentation for how to customize
|
||||
/// additional Window theme colors.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnThemeChanged(CefRefPtr<CefView> view) {}
|
||||
|
@@ -377,6 +377,50 @@ class CefWindow : public CefPanel {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void RemoveAllAccelerators() = 0;
|
||||
|
||||
///
|
||||
/// Override a standard theme color or add a custom color associated with
|
||||
/// |color_id|. See cef_color_ids.h for standard ID values. Recommended usage
|
||||
/// is as follows:
|
||||
///
|
||||
/// 1. Customize the default native/OS theme by calling SetThemeColor before
|
||||
/// showing the first Window. When done setting colors call
|
||||
/// CefWindow::ThemeChanged to trigger CefViewDelegate::OnThemeChanged
|
||||
/// notifications.
|
||||
/// 2. Customize the current native/OS or Chrome theme after it changes by
|
||||
/// calling SetThemeColor from the CefWindowDelegate::OnThemeColorsChanged
|
||||
/// callback. CefViewDelegate::OnThemeChanged notifications will then be
|
||||
/// triggered automatically.
|
||||
///
|
||||
/// The configured color will be available immediately via
|
||||
/// CefView::GetThemeColor and will be applied to each View in this Window's
|
||||
/// component hierarchy when CefViewDelegate::OnThemeChanged is called. See
|
||||
/// OnThemeColorsChanged documentation for additional details.
|
||||
///
|
||||
/// Clients wishing to add custom colors should use |color_id| values >=
|
||||
/// CEF_ChromeColorsEnd.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetThemeColor(int color_id, cef_color_t color) = 0;
|
||||
|
||||
///
|
||||
/// Trigger CefViewDelegate::OnThemeChanged callbacks for each View in this
|
||||
/// Window's component hierarchy. Unlike a native/OS or Chrome theme change
|
||||
/// this method does not reset theme colors to standard values and does not
|
||||
/// result in a call to CefWindowDelegate::OnThemeColorsChanged.
|
||||
///
|
||||
/// Do not call this method from CefWindowDelegate::OnThemeColorsChanged or
|
||||
/// CefViewDelegate::OnThemeChanged.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void ThemeChanged() = 0;
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this Window (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
|
||||
virtual cef_runtime_style_t GetRuntimeStyle() = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_H_
|
||||
|
@@ -164,12 +164,11 @@ class CefWindowDelegate : public CefPanelDelegate {
|
||||
}
|
||||
|
||||
///
|
||||
/// Return whether the titlebar height should be overridden,
|
||||
/// and sets the height of the titlebar in |titlebar_height|.
|
||||
/// On macOS, it can also be used to adjust the vertical position
|
||||
/// of the traffic light buttons in frameless windows.
|
||||
/// The buttons will be positioned halfway down the titlebar
|
||||
/// at a height of |titlebar_height| / 2.
|
||||
/// Return whether the titlebar height should be overridden, and sets the
|
||||
/// height of the titlebar in |titlebar_height|. On macOS, it can also be used
|
||||
/// to adjust the vertical position of the traffic light buttons in frameless
|
||||
/// windows. The buttons will be positioned halfway down the titlebar at a
|
||||
/// height of |titlebar_height| / 2.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetTitlebarHeight(CefRefPtr<CefWindow> window,
|
||||
@@ -177,6 +176,21 @@ class CefWindowDelegate : public CefPanelDelegate {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Return whether the view should accept the initial mouse-down event,
|
||||
/// allowing it to respond to click-through behavior. If STATE_ENABLED is
|
||||
/// returned, the view will be sent a mouseDown: message for an initial
|
||||
/// mouse-down event, activating the view with one click, instead of clicking
|
||||
/// first to make the window active and then clicking the view.
|
||||
///
|
||||
/// This method is only supported on macOS. For more details, refer to the
|
||||
/// documentation of acceptsFirstMouse.
|
||||
///
|
||||
/*--cef(default_retval=STATE_DEFAULT)--*/
|
||||
virtual cef_state_t AcceptsFirstMouse(CefRefPtr<CefWindow> window) {
|
||||
return STATE_DEFAULT;
|
||||
}
|
||||
|
||||
///
|
||||
/// Return true if |window| can be resized.
|
||||
///
|
||||
@@ -222,6 +236,50 @@ class CefWindowDelegate : public CefPanelDelegate {
|
||||
const CefKeyEvent& event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Called after the native/OS or Chrome theme for |window| has changed.
|
||||
/// |chrome_theme| will be true if the notification is for a Chrome theme.
|
||||
///
|
||||
/// Native/OS theme colors are configured globally and do not need to be
|
||||
/// customized for each Window individually. An example of a native/OS theme
|
||||
/// change that triggers this callback is when the user switches between dark
|
||||
/// and light mode during application lifespan. Native/OS theme changes can be
|
||||
/// disabled by passing the `--force-dark-mode` or `--force-light-mode`
|
||||
/// command-line flag.
|
||||
///
|
||||
/// Chrome theme colors will be applied and this callback will be triggered
|
||||
/// if/when a BrowserView is added to the Window's component hierarchy. Chrome
|
||||
/// theme colors can be configured on a per-RequestContext basis using
|
||||
/// CefRequestContext::SetChromeColorScheme or (Chrome runtime only) by
|
||||
/// visiting chrome://settings/manageProfile. Any theme changes using those
|
||||
/// mechanisms will also trigger this callback. Chrome theme colors will be
|
||||
/// persisted and restored from disk cache with the Chrome runtime, and with
|
||||
/// the Alloy runtime if persist_user_preferences is set to true via
|
||||
/// CefSettings or CefRequestContextSettings.
|
||||
///
|
||||
/// This callback is not triggered on Window creation so clients that wish to
|
||||
/// customize the initial native/OS theme must call CefWindow::SetThemeColor
|
||||
/// and CefWindow::ThemeChanged before showing the first Window.
|
||||
///
|
||||
/// Theme colors will be reset to standard values before this callback is
|
||||
/// called for the first affected Window. Call CefWindow::SetThemeColor from
|
||||
/// inside this callback to override a standard color or add a custom color.
|
||||
/// CefViewDelegate::OnThemeChanged will be called after this callback for the
|
||||
/// complete |window| component hierarchy.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnThemeColorsChanged(CefRefPtr<CefWindow> window,
|
||||
bool chrome_theme) {}
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style for this Window. See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
|
||||
virtual cef_runtime_style_t GetWindowRuntimeStyle() {
|
||||
return CEF_RUNTIME_STYLE_DEFAULT;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/download_manager_delegate.h"
|
||||
#include "libcef/browser/alloy/alloy_download_manager_delegate.h"
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
#include "libcef/browser/prefs/browser_prefs.h"
|
||||
#include "libcef/browser/ssl_host_state_delegate.h"
|
||||
@@ -297,15 +297,6 @@ bool AlloyBrowserContext::UnloadExtension(const CefString& extension_id) {
|
||||
return extension_system()->UnloadExtension(extension_id);
|
||||
}
|
||||
|
||||
bool AlloyBrowserContext::IsPrintPreviewSupported() const {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!extensions::PrintPreviewEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
|
||||
}
|
||||
|
||||
content::ClientHintsControllerDelegate*
|
||||
AlloyBrowserContext::GetClientHintsControllerDelegate() {
|
||||
return nullptr;
|
||||
@@ -345,7 +336,7 @@ content::DownloadManagerDelegate*
|
||||
AlloyBrowserContext::GetDownloadManagerDelegate() {
|
||||
if (!download_manager_delegate_) {
|
||||
download_manager_delegate_ =
|
||||
std::make_unique<CefDownloadManagerDelegate>(GetDownloadManager());
|
||||
std::make_unique<AlloyDownloadManagerDelegate>(GetDownloadManager());
|
||||
}
|
||||
return download_manager_delegate_.get();
|
||||
}
|
||||
@@ -461,6 +452,12 @@ void AlloyBrowserContext::RebuildTable(
|
||||
enumerator->OnComplete(true);
|
||||
}
|
||||
|
||||
void AlloyBrowserContext::BuildVisitedLinkTable(
|
||||
const scoped_refptr<VisitedLinkEnumerator>& enumerator) {
|
||||
// Called when visited links will not or cannot be loaded from disk.
|
||||
enumerator->OnVisitedLinkComplete(true);
|
||||
}
|
||||
|
||||
DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!download_prefs_) {
|
||||
@@ -469,6 +466,13 @@ DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() {
|
||||
return download_prefs_.get();
|
||||
}
|
||||
|
||||
void AlloyBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
|
||||
visitedlink_master_->AddURLs(urls);
|
||||
void AlloyBrowserContext::AddVisitedURLs(
|
||||
const GURL& url,
|
||||
const std::vector<GURL>& redirect_chain,
|
||||
ui::PageTransition /*transition*/) {
|
||||
if (!redirect_chain.empty()) {
|
||||
visitedlink_master_->AddURLs(redirect_chain);
|
||||
} else {
|
||||
visitedlink_master_->AddURL(url);
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
#include "components/proxy_config/pref_proxy_config_tracker.h"
|
||||
#include "components/visitedlink/browser/visitedlink_delegate.h"
|
||||
|
||||
class CefDownloadManagerDelegate;
|
||||
class AlloyDownloadManagerDelegate;
|
||||
class CefSSLHostStateDelegate;
|
||||
class CefVisitedLinkListener;
|
||||
class PrefService;
|
||||
@@ -56,7 +56,9 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
|
||||
bool GetExtensions(std::vector<CefString>& extension_ids) override;
|
||||
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
|
||||
bool UnloadExtension(const CefString& extension_id) override;
|
||||
bool IsPrintPreviewSupported() const override;
|
||||
void AddVisitedURLs(const GURL& url,
|
||||
const std::vector<GURL>& redirect_chain,
|
||||
ui::PageTransition transition) override;
|
||||
|
||||
// content::BrowserContext overrides.
|
||||
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
|
||||
@@ -108,17 +110,16 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
|
||||
|
||||
// visitedlink::VisitedLinkDelegate methods.
|
||||
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
|
||||
void BuildVisitedLinkTable(
|
||||
const scoped_refptr<VisitedLinkEnumerator>& enumerator) override;
|
||||
|
||||
// Manages extensions.
|
||||
extensions::CefExtensionSystem* extension_system() const {
|
||||
return extension_system_;
|
||||
}
|
||||
|
||||
// Called from AlloyBrowserHostImpl::DidFinishNavigation to update the table
|
||||
// of visited links.
|
||||
void AddVisitedURLs(const std::vector<GURL>& urls);
|
||||
|
||||
// Called from DownloadPrefs::FromBrowserContext.
|
||||
// Called from DownloadPrefs::FromBrowserContext via
|
||||
// alloy::GetDownloadPrefsFromBrowserContext.
|
||||
DownloadPrefs* GetDownloadPrefs();
|
||||
|
||||
private:
|
||||
@@ -127,7 +128,7 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
|
||||
std::unique_ptr<PrefService> pref_service_;
|
||||
std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
|
||||
|
||||
std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_;
|
||||
std::unique_ptr<AlloyDownloadManagerDelegate> download_manager_delegate_;
|
||||
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
|
||||
std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_master_;
|
||||
// |visitedlink_listener_| is owned by visitedlink_master_.
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/alloy/alloy_browser_context.h"
|
||||
#include "libcef/browser/alloy/browser_platform_delegate_alloy.h"
|
||||
#include "libcef/browser/audio_capturer.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
@@ -17,7 +16,7 @@
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/devtools/devtools_manager.h"
|
||||
#include "libcef/browser/extensions/browser_extensions_util.h"
|
||||
#include "libcef/browser/hang_monitor.h"
|
||||
#include "libcef/browser/media_access_query.h"
|
||||
#include "libcef/browser/osr/osr_util.h"
|
||||
@@ -29,7 +28,7 @@
|
||||
#include "libcef/common/net/url_util.h"
|
||||
#include "libcef/common/request_impl.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
#include "libcef/features/runtime.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/functional/bind.h"
|
||||
@@ -73,11 +72,15 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
|
||||
CefBrowserPlatformDelegate::Create(create_params);
|
||||
CHECK(platform_delegate);
|
||||
|
||||
// Expect runtime style to match.
|
||||
CHECK(platform_delegate->IsAlloyStyle());
|
||||
|
||||
const bool is_devtools_popup = !!create_params.devtools_opener;
|
||||
|
||||
scoped_refptr<CefBrowserInfo> info =
|
||||
CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
|
||||
is_devtools_popup, platform_delegate->IsWindowless(),
|
||||
platform_delegate->IsPrintPreviewSupported(),
|
||||
create_params.extra_info);
|
||||
|
||||
bool own_web_contents = false;
|
||||
@@ -101,8 +104,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
|
||||
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser = CreateInternal(
|
||||
create_params.settings, create_params.client, web_contents,
|
||||
own_web_contents, info,
|
||||
static_cast<AlloyBrowserHostImpl*>(create_params.devtools_opener.get()),
|
||||
own_web_contents, info, FromBaseChecked(create_params.devtools_opener),
|
||||
is_devtools_popup, request_context_impl, std::move(platform_delegate),
|
||||
cef_extension);
|
||||
if (!browser) {
|
||||
@@ -181,8 +183,8 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
|
||||
// 1. Notify the opener browser's platform delegate. With Views this will
|
||||
// result in a call to CefBrowserViewDelegate::OnPopupBrowserViewCreated().
|
||||
// Do this first for consistency with the Chrome runtime.
|
||||
opener->platform_delegate_->PopupBrowserCreated(browser.get(),
|
||||
is_devtools_popup);
|
||||
opener->platform_delegate_->PopupBrowserCreated(
|
||||
browser->platform_delegate(), browser.get(), is_devtools_popup);
|
||||
}
|
||||
|
||||
// 2. Notify the browser's LifeSpanHandler. This must always be the first
|
||||
@@ -200,36 +202,38 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
|
||||
return browser;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::FromBaseChecked(
|
||||
CefRefPtr<CefBrowserHostBase> host_base) {
|
||||
if (!host_base) {
|
||||
return nullptr;
|
||||
}
|
||||
CHECK(host_base->IsAlloyStyle());
|
||||
return static_cast<AlloyBrowserHostImpl*>(host_base.get());
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForHost(
|
||||
const content::RenderViewHost* host) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForHost(host);
|
||||
return static_cast<AlloyBrowserHostImpl*>(browser.get());
|
||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForHost(
|
||||
const content::RenderFrameHost* host) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForHost(host);
|
||||
return static_cast<AlloyBrowserHostImpl*>(browser.get());
|
||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForContents(
|
||||
const content::WebContents* contents) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForContents(contents);
|
||||
return static_cast<AlloyBrowserHostImpl*>(browser.get());
|
||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForContents(contents));
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForGlobalId(
|
||||
const content::GlobalRenderFrameHostId& global_id) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForGlobalId(global_id);
|
||||
return static_cast<AlloyBrowserHostImpl*>(browser.get());
|
||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForGlobalId(global_id));
|
||||
}
|
||||
|
||||
// AlloyBrowserHostImpl methods.
|
||||
@@ -333,42 +337,6 @@ void AlloyBrowserHostImpl::StopFinding(bool clearSelection) {
|
||||
}
|
||||
}
|
||||
|
||||
void AlloyBrowserHostImpl::ShowDevToolsOnUIThread(
|
||||
std::unique_ptr<CefShowDevToolsParams> params) {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!EnsureDevToolsManager()) {
|
||||
return;
|
||||
}
|
||||
devtools_manager_->ShowDevTools(params->window_info_, params->client_,
|
||||
params->settings_,
|
||||
params->inspect_element_at_);
|
||||
}
|
||||
|
||||
void AlloyBrowserHostImpl::CloseDevTools() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&AlloyBrowserHostImpl::CloseDevTools, this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!devtools_manager_) {
|
||||
return;
|
||||
}
|
||||
devtools_manager_->CloseDevTools();
|
||||
}
|
||||
|
||||
bool AlloyBrowserHostImpl::HasDevTools() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
DCHECK(false) << "called on invalid thread";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!devtools_manager_) {
|
||||
return false;
|
||||
}
|
||||
return devtools_manager_->HasDevTools();
|
||||
}
|
||||
|
||||
void AlloyBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
|
||||
const CefSize& min_size,
|
||||
const CefSize& max_size) {
|
||||
@@ -636,8 +604,9 @@ void AlloyBrowserHostImpl::CancelContextMenu() {
|
||||
|
||||
bool AlloyBrowserHostImpl::MaybeAllowNavigation(
|
||||
content::RenderFrameHost* opener,
|
||||
bool is_guest_view,
|
||||
const content::OpenURLParams& params) {
|
||||
const bool is_guest_view = extensions::IsBrowserPluginGuest(
|
||||
content::WebContents::FromRenderFrameHost(opener));
|
||||
if (is_guest_view && !params.is_pdf &&
|
||||
!params.url.SchemeIs(extensions::kExtensionScheme) &&
|
||||
!params.url.SchemeIs(content::kChromeUIScheme)) {
|
||||
@@ -649,7 +618,7 @@ bool AlloyBrowserHostImpl::MaybeAllowNavigation(
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(
|
||||
base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
|
||||
this, nullptr, params));
|
||||
this, nullptr, params, base::NullCallback()));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -957,8 +926,11 @@ bool AlloyBrowserHostImpl::IsAudioMuted() {
|
||||
|
||||
content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) {
|
||||
auto target_contents = contents_delegate_->OpenURLFromTab(source, params);
|
||||
const content::OpenURLParams& params,
|
||||
base::OnceCallback<void(content::NavigationHandle&)>
|
||||
navigation_handle_callback) {
|
||||
auto target_contents = contents_delegate_->OpenURLFromTabEx(
|
||||
source, params, navigation_handle_callback);
|
||||
if (target_contents) {
|
||||
// Start a navigation in the current browser that will result in the
|
||||
// creation of a new render process.
|
||||
@@ -1175,7 +1147,8 @@ void AlloyBrowserHostImpl::WebContentsCreated(
|
||||
|
||||
scoped_refptr<CefBrowserInfo> info =
|
||||
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
|
||||
new_contents, platform_delegate->IsWindowless(), extra_info);
|
||||
new_contents, platform_delegate->IsWindowless(),
|
||||
platform_delegate->IsPrintPreviewSupported(), extra_info);
|
||||
CHECK(info.get());
|
||||
CHECK(info->is_popup());
|
||||
|
||||
@@ -1303,8 +1276,8 @@ void AlloyBrowserHostImpl::ExitPictureInPicture() {
|
||||
}
|
||||
|
||||
bool AlloyBrowserHostImpl::IsBackForwardCacheSupported() {
|
||||
// Disabled due to issue #3237.
|
||||
return false;
|
||||
// Disabled with Alloy bootstrap due to issue #3237.
|
||||
return cef::IsChromeRuntimeEnabled();
|
||||
}
|
||||
|
||||
content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
|
||||
@@ -1312,17 +1285,24 @@ content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
|
||||
return content::PreloadingEligibility::kEligible;
|
||||
}
|
||||
|
||||
void AlloyBrowserHostImpl::DraggableRegionsChanged(
|
||||
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
|
||||
content::WebContents* contents) {
|
||||
contents_delegate_->DraggableRegionsChanged(regions, contents);
|
||||
}
|
||||
|
||||
// content::WebContentsObserver methods.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void AlloyBrowserHostImpl::DidFinishNavigation(
|
||||
content::NavigationHandle* navigation_handle) {
|
||||
if (web_contents()) {
|
||||
auto cef_browser_context =
|
||||
static_cast<AlloyBrowserContext*>(web_contents()->GetBrowserContext());
|
||||
auto cef_browser_context = CefBrowserContext::FromBrowserContext(
|
||||
web_contents()->GetBrowserContext());
|
||||
if (cef_browser_context) {
|
||||
cef_browser_context->AddVisitedURLs(
|
||||
navigation_handle->GetRedirectChain());
|
||||
navigation_handle->GetURL(), navigation_handle->GetRedirectChain(),
|
||||
navigation_handle->GetPageTransition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -62,6 +62,11 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||
static CefRefPtr<AlloyBrowserHostImpl> Create(
|
||||
CefBrowserCreateParams& create_params);
|
||||
|
||||
// Safe (checked) conversion from CefBrowserHostBase to AlloyBrowserHostImpl.
|
||||
// Use this method instead of static_cast.
|
||||
static CefRefPtr<AlloyBrowserHostImpl> FromBaseChecked(
|
||||
CefRefPtr<CefBrowserHostBase> host_base);
|
||||
|
||||
// Returns the browser associated with the specified RenderViewHost.
|
||||
static CefRefPtr<AlloyBrowserHostImpl> GetBrowserForHost(
|
||||
const content::RenderViewHost* host);
|
||||
@@ -85,8 +90,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||
bool matchCase,
|
||||
bool findNext) override;
|
||||
void StopFinding(bool clearSelection) override;
|
||||
void CloseDevTools() override;
|
||||
bool HasDevTools() override;
|
||||
bool IsWindowRenderingDisabled() override;
|
||||
void WasResized() override;
|
||||
void WasHidden(bool hidden) override;
|
||||
@@ -126,9 +129,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||
void ExecuteChromeCommand(int command_id,
|
||||
cef_window_open_disposition_t disposition) override;
|
||||
|
||||
// Returns true if windowless rendering is enabled.
|
||||
// CefBrowserHostBase methods:
|
||||
bool IsWindowless() const override;
|
||||
|
||||
bool IsAlloyStyle() const override { return true; }
|
||||
bool IsVisible() const override;
|
||||
|
||||
// Returns true if this browser supports picture-in-picture.
|
||||
@@ -147,7 +150,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||
void CancelContextMenu();
|
||||
|
||||
bool MaybeAllowNavigation(content::RenderFrameHost* opener,
|
||||
bool is_guest_view,
|
||||
const content::OpenURLParams& params) override;
|
||||
|
||||
// Convert from view DIP coordinates to screen coordinates. If
|
||||
@@ -182,7 +184,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||
// content::WebContentsDelegate methods.
|
||||
content::WebContents* OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) override;
|
||||
const content::OpenURLParams& params,
|
||||
base::OnceCallback<void(content::NavigationHandle&)>
|
||||
navigation_handle_callback) override;
|
||||
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
|
||||
bool is_main_frame_navigation) override;
|
||||
void AddNewContents(content::WebContents* source,
|
||||
@@ -277,6 +281,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||
bool IsBackForwardCacheSupported() override;
|
||||
content::PreloadingEligibility IsPrerender2Supported(
|
||||
content::WebContents& web_contents) override;
|
||||
void DraggableRegionsChanged(
|
||||
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
|
||||
content::WebContents* contents) override;
|
||||
|
||||
// content::WebContentsObserver methods.
|
||||
using content::WebContentsObserver::BeforeUnloadFired;
|
||||
@@ -290,10 +297,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||
override;
|
||||
void WebContentsDestroyed() override;
|
||||
|
||||
protected:
|
||||
void ShowDevToolsOnUIThread(
|
||||
std::unique_ptr<CefShowDevToolsParams> params) override;
|
||||
|
||||
private:
|
||||
friend class CefBrowserPlatformDelegateAlloy;
|
||||
|
||||
|
@@ -9,11 +9,11 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "libcef/browser/alloy/devtools/devtools_manager_delegate.h"
|
||||
#include "libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/browser_context_keyed_service_factories.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/devtools/devtools_manager_delegate.h"
|
||||
#include "libcef/browser/extensions/extension_system_factory.h"
|
||||
#include "libcef/browser/file_dialog_runner.h"
|
||||
#include "libcef/browser/net/chrome_scheme_handler.h"
|
||||
@@ -55,6 +55,9 @@
|
||||
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
|
||||
#include "ui/events/devices/x11/touch_factory_x11.h"
|
||||
#endif
|
||||
#if defined(USE_DBUS)
|
||||
#include "chrome/browser/ui/views/dark_mode_manager_linux.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_AURA)
|
||||
@@ -127,22 +130,6 @@ class LinuxUiGetterImpl : public ui::LinuxUiGetter {
|
||||
}
|
||||
};
|
||||
|
||||
ui::LinuxUi* GetLinuxUI() {
|
||||
// We can't use GtkUi in combination with multi-threaded-message-loop because
|
||||
// Chromium's GTK implementation doesn't use GDK threads.
|
||||
if (!!CefContext::Get()->settings().multi_threaded_message_loop) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If the ozone backend hasn't provided a LinuxUiDelegate, don't try to create
|
||||
// a LinuxUi instance as this may result in a crash in toolkit initialization.
|
||||
if (!ui::LinuxUiDelegate::GetInstance()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ui::GetDefaultLinuxUi();
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_LINUX)
|
||||
|
||||
void ProcessSingletonNotificationCallbackImpl(
|
||||
@@ -204,7 +191,8 @@ AlloyBrowserMainParts::~AlloyBrowserMainParts() {
|
||||
}
|
||||
|
||||
void AlloyBrowserMainParts::ToolkitInitialized() {
|
||||
SetConstrainedWindowViewsClient(CreateAlloyConstrainedWindowViewsClient());
|
||||
SetConstrainedWindowViewsClient(
|
||||
CreateAlloyConstrainedWindowViewsClient(nullptr));
|
||||
#if defined(USE_AURA)
|
||||
CHECK(aura::Env::GetInstance());
|
||||
|
||||
@@ -220,7 +208,9 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
// Based on chrome_browser_main_extra_parts_views_linux.cc
|
||||
if (auto linux_ui = GetLinuxUI()) {
|
||||
// |linux_ui| will be nullptr with multi-threaded-message-loop. See
|
||||
// CefUiThread::InitializeBrowserRunner.
|
||||
if (auto linux_ui = ui::GetDefaultLinuxUi()) {
|
||||
linux_ui_getter_ = std::make_unique<LinuxUiGetterImpl>();
|
||||
ui::LinuxUi::SetInstance(linux_ui);
|
||||
|
||||
@@ -229,6 +219,13 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
|
||||
ui::CursorFactory::GetInstance()->ObserveThemeChanges();
|
||||
}
|
||||
|
||||
#if defined(USE_DBUS)
|
||||
if (!ui::NativeTheme::IsForcedDarkMode() &&
|
||||
!ui::NativeTheme::IsForcedLightMode()) {
|
||||
dark_mode_manager_ = std::make_unique<ui::DarkModeManagerLinux>();
|
||||
}
|
||||
#endif
|
||||
|
||||
auto printing_delegate = new CefPrintingContextLinuxDelegate();
|
||||
auto default_delegate =
|
||||
ui::PrintingContextLinuxDelegate::SetInstance(printing_delegate);
|
||||
|
@@ -6,10 +6,11 @@
|
||||
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "content/public/browser/browser_main_parts.h"
|
||||
@@ -31,7 +32,10 @@ class LayoutProvider;
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
namespace ui {
|
||||
class LinuxUiGetter;
|
||||
}
|
||||
#if defined(USE_DBUS)
|
||||
class DarkModeManagerLinux;
|
||||
#endif
|
||||
} // namespace ui
|
||||
#endif
|
||||
|
||||
class CefDevToolsDelegate;
|
||||
@@ -99,6 +103,9 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
std::unique_ptr<ui::LinuxUiGetter> linux_ui_getter_;
|
||||
#if defined(USE_DBUS)
|
||||
std::unique_ptr<ui::DarkModeManagerLinux> dark_mode_manager_;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_main.h"
|
||||
#include "libcef/browser/alloy/alloy_web_contents_view_delegate.h"
|
||||
#include "libcef/browser/alloy/devtools/devtools_manager_delegate.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/browser_frame.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
@@ -21,7 +22,6 @@
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/certificate_query.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/devtools/devtools_manager_delegate.h"
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
||||
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
||||
@@ -92,6 +92,7 @@
|
||||
#include "components/pdf/browser/pdf_navigation_throttle.h"
|
||||
#include "components/pdf/browser/pdf_url_loader_request_interceptor.h"
|
||||
#include "components/pdf/common/constants.h"
|
||||
#include "components/pdf/common/pdf_util.h"
|
||||
#include "components/policy/core/common/policy_pref_names.h"
|
||||
#include "components/spellcheck/common/spellcheck.mojom.h"
|
||||
#include "components/version_info/version_info.h"
|
||||
@@ -449,7 +450,7 @@ bool AlloyContentBrowserClient::DoesSiteRequireDedicatedProcess(
|
||||
}
|
||||
|
||||
bool AlloyContentBrowserClient::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
|
||||
base::StringPiece scheme,
|
||||
std::string_view scheme,
|
||||
bool is_embedded_origin_secure) {
|
||||
// This is needed to bypass the normal SameSite rules for any chrome:// page
|
||||
// embedding a secure origin, regardless of the registrable domains of any
|
||||
@@ -470,7 +471,7 @@ bool AlloyContentBrowserClient::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
|
||||
|
||||
bool AlloyContentBrowserClient::
|
||||
ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
|
||||
base::StringPiece scheme,
|
||||
std::string_view scheme,
|
||||
bool is_embedded_origin_secure) {
|
||||
return is_embedded_origin_secure && scheme == content::kChromeUIScheme;
|
||||
}
|
||||
@@ -625,10 +626,6 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
process ? CefBrowserContext::FromBrowserContext(browser_context)
|
||||
: nullptr;
|
||||
if (cef_browser_context) {
|
||||
if (cef_browser_context->IsPrintPreviewSupported()) {
|
||||
command_line->AppendSwitch(switches::kEnablePrintPreview);
|
||||
}
|
||||
|
||||
// Based on ChromeContentBrowserClientExtensionsPart::
|
||||
// AppendExtraRendererCommandLineSwitches
|
||||
if (extensions::ProcessMap::Get(browser_context)
|
||||
@@ -917,10 +914,10 @@ void AlloyContentBrowserClient::
|
||||
},
|
||||
&render_frame_host));
|
||||
|
||||
associated_registry.AddInterface<pdf::mojom::PdfService>(base::BindRepeating(
|
||||
associated_registry.AddInterface<pdf::mojom::PdfHost>(base::BindRepeating(
|
||||
[](content::RenderFrameHost* render_frame_host,
|
||||
mojo::PendingAssociatedReceiver<pdf::mojom::PdfService> receiver) {
|
||||
pdf::PDFDocumentHelper::BindPdfService(
|
||||
mojo::PendingAssociatedReceiver<pdf::mojom::PdfHost> receiver) {
|
||||
pdf::PDFDocumentHelper::BindPdfHost(
|
||||
std::move(receiver), render_frame_host,
|
||||
std::make_unique<ChromePDFDocumentHelperClient>());
|
||||
},
|
||||
@@ -1183,6 +1180,7 @@ void AlloyContentBrowserClient::WillCreateURLLoaderFactory(
|
||||
int render_process_id,
|
||||
URLLoaderFactoryType type,
|
||||
const url::Origin& request_initiator,
|
||||
const net::IsolationInfo& isolation_info,
|
||||
std::optional<int64_t> navigation_id,
|
||||
ukm::SourceIdObj ukm_source_id,
|
||||
network::URLLoaderFactoryBuilder& factory_builder,
|
||||
|
@@ -45,10 +45,10 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
||||
bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context,
|
||||
const GURL& effective_site_url) override;
|
||||
bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
|
||||
base::StringPiece scheme,
|
||||
std::string_view scheme,
|
||||
bool is_embedded_origin_secure) override;
|
||||
bool ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
|
||||
base::StringPiece scheme,
|
||||
std::string_view scheme,
|
||||
bool is_embedded_origin_secure) override;
|
||||
void OverrideURLLoaderFactoryParams(
|
||||
content::BrowserContext* browser_context,
|
||||
@@ -186,6 +186,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
||||
int render_process_id,
|
||||
URLLoaderFactoryType type,
|
||||
const url::Origin& request_initiator,
|
||||
const net::IsolationInfo& isolation_info,
|
||||
std::optional<int64_t> navigation_id,
|
||||
ukm::SourceIdObj ukm_source_id,
|
||||
network::URLLoaderFactoryBuilder& factory_builder,
|
||||
|
22
libcef/browser/alloy/alloy_download_manager_delegate.cc
Normal file
22
libcef/browser/alloy/alloy_download_manager_delegate.cc
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/alloy/alloy_download_manager_delegate.h"
|
||||
|
||||
#include "chrome/common/chrome_constants.h"
|
||||
#include "components/download/public/common/download_item.h"
|
||||
|
||||
AlloyDownloadManagerDelegate::AlloyDownloadManagerDelegate(
|
||||
content::DownloadManager* manager)
|
||||
: CefDownloadManagerDelegateImpl(manager, /*alloy_bootstrap=*/true) {}
|
||||
|
||||
void AlloyDownloadManagerDelegate::GetNextId(
|
||||
content::DownloadIdCallback callback) {
|
||||
static uint32_t next_id = download::DownloadItem::kInvalidId + 1;
|
||||
std::move(callback).Run(next_id++);
|
||||
}
|
||||
|
||||
std::string AlloyDownloadManagerDelegate::ApplicationClientIdForFileScanning() {
|
||||
return std::string(chrome::kApplicationClientIDStringForAVScanning);
|
||||
}
|
26
libcef/browser/alloy/alloy_download_manager_delegate.h
Normal file
26
libcef/browser/alloy/alloy_download_manager_delegate.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
|
||||
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
|
||||
#pragma once
|
||||
|
||||
#include "libcef/browser/download_manager_delegate_impl.h"
|
||||
|
||||
// Specialization for the Alloy bootstrap.
|
||||
class AlloyDownloadManagerDelegate : public CefDownloadManagerDelegateImpl {
|
||||
public:
|
||||
explicit AlloyDownloadManagerDelegate(content::DownloadManager* manager);
|
||||
|
||||
AlloyDownloadManagerDelegate(const AlloyDownloadManagerDelegate&) = delete;
|
||||
AlloyDownloadManagerDelegate& operator=(const AlloyDownloadManagerDelegate&) =
|
||||
delete;
|
||||
|
||||
private:
|
||||
// DownloadManagerDelegate methods.
|
||||
void GetNextId(content::DownloadIdCallback callback) override;
|
||||
std::string ApplicationClientIdForFileScanning() override;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
|
@@ -10,6 +10,8 @@ namespace alloy {
|
||||
|
||||
DownloadPrefs* GetDownloadPrefsFromBrowserContext(
|
||||
content::BrowserContext* context) {
|
||||
// This function is only called with Alloy bootstrap, so the static_cast is
|
||||
// safe.
|
||||
return static_cast<AlloyBrowserContext*>(context)->GetDownloadPrefs();
|
||||
}
|
||||
|
||||
|
@@ -18,11 +18,14 @@
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "chrome/browser/printing/print_view_manager.h"
|
||||
#include "chrome/browser/printing/printing_init.h"
|
||||
#include "chrome/browser/task_manager/web_contents_tags.h"
|
||||
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
||||
#include "chrome/browser/ui/tab_helpers.h"
|
||||
#include "components/find_in_page/find_tab_helper.h"
|
||||
#include "components/find_in_page/find_types.h"
|
||||
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
|
||||
#include "components/performance_manager/embedder/performance_manager_registry.h"
|
||||
#include "components/permissions/permission_request_manager.h"
|
||||
#include "components/zoom/zoom_controller.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
@@ -31,13 +34,18 @@
|
||||
#include "pdf/pdf_features.h"
|
||||
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const char kAttachedHelpersUserDataKey[] = "CefAttachedHelpers";
|
||||
|
||||
} // namespace
|
||||
|
||||
CefBrowserPlatformDelegateAlloy::CefBrowserPlatformDelegateAlloy()
|
||||
: weak_ptr_factory_(this) {}
|
||||
|
||||
content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
|
||||
CefBrowserCreateParams& create_params,
|
||||
bool& own_web_contents) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
DCHECK(primary_);
|
||||
|
||||
if (!create_params.request_context) {
|
||||
@@ -100,7 +108,7 @@ void CefBrowserPlatformDelegateAlloy::WebContentsCreated(
|
||||
CefBrowserPlatformDelegate::WebContentsCreated(web_contents, owned);
|
||||
|
||||
if (primary_) {
|
||||
find_in_page::FindTabHelper::CreateForWebContents(web_contents);
|
||||
AttachHelpers(web_contents);
|
||||
|
||||
if (owned) {
|
||||
SetOwnedWebContents(web_contents);
|
||||
@@ -118,7 +126,6 @@ void CefBrowserPlatformDelegateAlloy::AddNewContents(
|
||||
const blink::mojom::WindowFeatures& window_features,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
DCHECK(primary_);
|
||||
|
||||
CefRefPtr<AlloyBrowserHostImpl> owner =
|
||||
@@ -162,16 +169,10 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
|
||||
}
|
||||
|
||||
DCHECK(!web_contents_->GetDelegate());
|
||||
web_contents_->SetDelegate(static_cast<AlloyBrowserHostImpl*>(browser));
|
||||
web_contents_->SetDelegate(
|
||||
AlloyBrowserHostImpl::FromBaseChecked(browser).get());
|
||||
|
||||
permissions::PermissionRequestManager::CreateForWebContents(web_contents_);
|
||||
PrefsTabHelper::CreateForWebContents(web_contents_);
|
||||
printing::PrintViewManager::CreateForWebContents(web_contents_);
|
||||
zoom::ZoomController::CreateForWebContents(web_contents_);
|
||||
|
||||
javascript_dialogs::TabModalDialogManager::CreateForWebContents(
|
||||
web_contents_,
|
||||
CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(web_contents_));
|
||||
AttachHelpers(web_contents_);
|
||||
|
||||
// Used for print preview and JavaScript dialogs.
|
||||
web_contents_dialog_helper_ =
|
||||
@@ -190,12 +191,12 @@ void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
|
||||
DCHECK(browser_);
|
||||
DCHECK(!extension_host_);
|
||||
|
||||
auto alloy_browser = static_cast<AlloyBrowserHostImpl*>(browser_);
|
||||
auto alloy_browser = AlloyBrowserHostImpl::FromBaseChecked(browser_);
|
||||
|
||||
if (host_type == extensions::mojom::ViewType::kExtensionPopup) {
|
||||
// Create an extension host that we own.
|
||||
extension_host_ = new extensions::CefExtensionViewHost(
|
||||
alloy_browser, extension, web_contents_, url, host_type);
|
||||
alloy_browser.get(), extension, web_contents_, url, host_type);
|
||||
// Trigger load of the extension URL.
|
||||
extension_host_->CreateRendererSoon();
|
||||
} else if (host_type ==
|
||||
@@ -204,7 +205,7 @@ void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
|
||||
alloy_browser->is_background_host_ = true;
|
||||
// Create an extension host that will be owned by ProcessManager.
|
||||
extension_host_ = new extensions::CefExtensionBackgroundHost(
|
||||
alloy_browser,
|
||||
alloy_browser.get(),
|
||||
base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
extension, web_contents_, url, host_type);
|
||||
@@ -312,19 +313,6 @@ void CefBrowserPlatformDelegateAlloy::ConfigureAutoResize() {
|
||||
}
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
|
||||
// Print preview is not currently supported with OSR.
|
||||
if (IsWindowless()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto cef_browser_context =
|
||||
CefBrowserContext::FromBrowserContext(web_contents_->GetBrowserContext());
|
||||
return cef_browser_context->IsPrintPreviewSupported();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateAlloy::Find(const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
@@ -414,3 +402,47 @@ void CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted() {
|
||||
DCHECK(extension_host_);
|
||||
extension_host_ = nullptr;
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateAlloy::AttachHelpers(
|
||||
content::WebContents* web_contents) {
|
||||
// If already attached, nothing to be done.
|
||||
base::SupportsUserData::Data* attached_tag =
|
||||
web_contents->GetUserData(&kAttachedHelpersUserDataKey);
|
||||
if (attached_tag) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Mark as attached.
|
||||
web_contents->SetUserData(&kAttachedHelpersUserDataKey,
|
||||
std::make_unique<base::SupportsUserData::Data>());
|
||||
|
||||
// Create all the helpers.
|
||||
if (cef::IsAlloyRuntimeEnabled()) {
|
||||
find_in_page::FindTabHelper::CreateForWebContents(web_contents);
|
||||
permissions::PermissionRequestManager::CreateForWebContents(web_contents);
|
||||
PrefsTabHelper::CreateForWebContents(web_contents);
|
||||
printing::InitializePrintingForWebContents(web_contents);
|
||||
zoom::ZoomController::CreateForWebContents(web_contents);
|
||||
|
||||
javascript_dialogs::TabModalDialogManager::CreateForWebContents(
|
||||
web_contents, CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(
|
||||
web_contents));
|
||||
} else {
|
||||
if (IsWindowless()) {
|
||||
// Logic from ChromeContentBrowserClientCef::GetWebContentsViewDelegate
|
||||
// which is not called for windowless browsers. Needs to be done before
|
||||
// calling AttachTabHelpers.
|
||||
if (auto* registry =
|
||||
performance_manager::PerformanceManagerRegistry::GetInstance()) {
|
||||
registry->MaybeCreatePageNodeForWebContents(web_contents);
|
||||
}
|
||||
}
|
||||
|
||||
// Adopt the WebContents now, so all observers are in place, as the network
|
||||
// requests for its initial navigation will start immediately
|
||||
TabHelpers::AttachTabHelpers(web_contents);
|
||||
|
||||
// Make the tab show up in the task manager.
|
||||
task_manager::WebContentsTags::CreateForTabContents(web_contents);
|
||||
}
|
||||
}
|
||||
|
@@ -51,10 +51,10 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
||||
bool PreHandleGestureEvent(content::WebContents* source,
|
||||
const blink::WebGestureEvent& event) override;
|
||||
bool IsNeverComposited(content::WebContents* web_contents) override;
|
||||
bool IsAlloyStyle() const override { return true; }
|
||||
void SetAutoResizeEnabled(bool enabled,
|
||||
const CefSize& min_size,
|
||||
const CefSize& max_size) override;
|
||||
bool IsPrintPreviewSupported() const override;
|
||||
void Find(const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
@@ -88,6 +88,10 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
||||
|
||||
void ConfigureAutoResize();
|
||||
|
||||
// Attach all the associated helpers that are needed for the WebContents. It
|
||||
// is safe to call this on a WebContents that was already attached.
|
||||
void AttachHelpers(content::WebContents* web_contents);
|
||||
|
||||
// Non-nullptr if this object owns the WebContents. Will be nullptr for popup
|
||||
// browsers between the calls to WebContentsCreated() and AddNewContents(),
|
||||
// and may never be set if the parent browser is destroyed during popup
|
||||
|
@@ -370,6 +370,12 @@ ChromeBrowserProcessAlloy::subresource_filter_ruleset_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
subresource_filter::RulesetService*
|
||||
ChromeBrowserProcessAlloy::fingerprinting_protection_ruleset_service() {
|
||||
DCHECK(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
StartupData* ChromeBrowserProcessAlloy::startup_data() {
|
||||
DCHECK(false);
|
||||
return nullptr;
|
||||
|
@@ -92,6 +92,8 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
|
||||
safe_browsing::SafeBrowsingService* safe_browsing_service() override;
|
||||
subresource_filter::RulesetService* subresource_filter_ruleset_service()
|
||||
override;
|
||||
subresource_filter::RulesetService*
|
||||
fingerprinting_protection_ruleset_service() override;
|
||||
StartupData* startup_data() override;
|
||||
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
|
||||
|
@@ -0,0 +1,46 @@
|
||||
// Copyright 2024 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/alloy/devtools/alloy_devtools_window_runner.h"
|
||||
|
||||
#include "libcef/browser/alloy/devtools/devtools_frontend.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
void AlloyDevToolsWindowRunner::ShowDevTools(
|
||||
CefBrowserHostBase* opener,
|
||||
std::unique_ptr<CefShowDevToolsParams> params) {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (devtools_frontend_) {
|
||||
if (!params->inspect_element_at_.IsEmpty()) {
|
||||
devtools_frontend_->InspectElementAt(params->inspect_element_at_.x,
|
||||
params->inspect_element_at_.y);
|
||||
}
|
||||
devtools_frontend_->Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
auto alloy_browser = AlloyBrowserHostImpl::FromBaseChecked(opener);
|
||||
devtools_frontend_ = CefDevToolsFrontend::Show(
|
||||
alloy_browser.get(), params->window_info_, params->client_,
|
||||
params->settings_, params->inspect_element_at_,
|
||||
base::BindOnce(&AlloyDevToolsWindowRunner::OnFrontEndDestroyed,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
void AlloyDevToolsWindowRunner::CloseDevTools() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (devtools_frontend_) {
|
||||
devtools_frontend_->Close();
|
||||
}
|
||||
}
|
||||
|
||||
bool AlloyDevToolsWindowRunner::HasDevTools() {
|
||||
CEF_REQUIRE_UIT();
|
||||
return !!devtools_frontend_;
|
||||
}
|
||||
|
||||
void AlloyDevToolsWindowRunner::OnFrontEndDestroyed() {
|
||||
CEF_REQUIRE_UIT();
|
||||
devtools_frontend_ = nullptr;
|
||||
}
|
40
libcef/browser/alloy/devtools/alloy_devtools_window_runner.h
Normal file
40
libcef/browser/alloy/devtools/alloy_devtools_window_runner.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright 2024 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_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_
|
||||
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_
|
||||
#pragma once
|
||||
|
||||
#include "libcef/browser/devtools/devtools_window_runner.h"
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
|
||||
class CefDevToolsFrontend;
|
||||
|
||||
// Creates and runs a DevTools window instance. Only accessed on the UI thread.
|
||||
class AlloyDevToolsWindowRunner : public CefDevToolsWindowRunner {
|
||||
public:
|
||||
AlloyDevToolsWindowRunner() = default;
|
||||
|
||||
AlloyDevToolsWindowRunner(const AlloyDevToolsWindowRunner&) = delete;
|
||||
AlloyDevToolsWindowRunner& operator=(const AlloyDevToolsWindowRunner&) =
|
||||
delete;
|
||||
|
||||
// CefDevToolsWindowRunner methods:
|
||||
void ShowDevTools(CefBrowserHostBase* opener,
|
||||
std::unique_ptr<CefShowDevToolsParams> params) override;
|
||||
void CloseDevTools() override;
|
||||
bool HasDevTools() override;
|
||||
|
||||
private:
|
||||
void OnFrontEndDestroyed();
|
||||
|
||||
// CefDevToolsFrontend will delete itself when the frontend WebContents is
|
||||
// destroyed.
|
||||
CefDevToolsFrontend* devtools_frontend_ = nullptr;
|
||||
|
||||
base::WeakPtrFactory<AlloyDevToolsWindowRunner> weak_ptr_factory_{this};
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_
|
@@ -2,7 +2,7 @@
|
||||
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
|
||||
// governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/devtools/devtools_file_manager.h"
|
||||
#include "libcef/browser/alloy/devtools/devtools_file_manager.h"
|
||||
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
|
||||
@@ -35,7 +35,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, std::string_view(content));
|
||||
}
|
||||
|
||||
} // namespace
|
@@ -2,8 +2,8 @@
|
||||
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
|
||||
// governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
|
||||
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
|
||||
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
|
||||
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
|
||||
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
@@ -79,4 +79,4 @@ class CefDevToolsFileManager {
|
||||
base::WeakPtrFactory<CefDevToolsFileManager> weak_factory_;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
|
||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
|
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/devtools/devtools_frontend.h"
|
||||
#include "libcef/browser/alloy/devtools/devtools_frontend.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/alloy/devtools/devtools_manager_delegate.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/devtools/devtools_manager_delegate.h"
|
||||
#include "libcef/browser/net/devtools_scheme_handler.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/task_runner_manager.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
|
||||
#include "base/base64.h"
|
||||
#include "base/command_line.h"
|
||||
@@ -165,7 +166,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, std::string_view(str))) {
|
||||
LOG(ERROR) << "Failed to write file " << log_file.value();
|
||||
log_error = true;
|
||||
}
|
||||
@@ -199,7 +200,7 @@ class CefDevToolsFrontend::NetworkResourceLoader
|
||||
response_headers_ = response_head.headers;
|
||||
}
|
||||
|
||||
void OnDataReceived(base::StringPiece chunk,
|
||||
void OnDataReceived(std::string_view chunk,
|
||||
base::OnceClosure resume) override {
|
||||
base::Value chunkValue;
|
||||
|
||||
@@ -243,6 +244,8 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
|
||||
const CefBrowserSettings& settings,
|
||||
const CefPoint& inspect_element_at,
|
||||
base::OnceClosure frontend_destroyed_callback) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
|
||||
CefBrowserSettings new_settings = settings;
|
||||
if (!windowInfo.windowless_rendering_enabled &&
|
||||
CefColorGetA(new_settings.background_color) != SK_AlphaOPAQUE) {
|
||||
@@ -252,11 +255,14 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
|
||||
}
|
||||
|
||||
CefBrowserCreateParams create_params;
|
||||
create_params.MaybeSetWindowInfo(windowInfo, /*allow_alloy_style=*/true,
|
||||
/*allow_chrome_style=*/false);
|
||||
|
||||
if (inspected_browser->is_views_hosted()) {
|
||||
create_params.popup_with_views_hosted_opener = true;
|
||||
} else {
|
||||
create_params.window_info = std::make_unique<CefWindowInfo>(windowInfo);
|
||||
}
|
||||
create_params.popup_with_alloy_style_opener = true;
|
||||
|
||||
create_params.client = client;
|
||||
create_params.settings = new_settings;
|
||||
create_params.devtools_opener = inspected_browser;
|
||||
@@ -271,8 +277,7 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
|
||||
// CefDevToolsFrontend will delete itself when the frontend WebContents is
|
||||
// destroyed.
|
||||
CefDevToolsFrontend* devtools_frontend = new CefDevToolsFrontend(
|
||||
static_cast<AlloyBrowserHostImpl*>(frontend_browser.get()),
|
||||
inspected_contents, inspect_element_at,
|
||||
frontend_browser.get(), inspected_contents, inspect_element_at,
|
||||
std::move(frontend_destroyed_callback));
|
||||
|
||||
// Need to load the URL after creating the DevTools objects.
|
||||
@@ -572,8 +577,8 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
|
||||
return;
|
||||
}
|
||||
|
||||
base::StringPiece str_message(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
std::string_view str_message(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
if (ProtocolLoggingEnabled()) {
|
||||
// Quick check to avoid parsing the JSON object. Events begin with a
|
||||
// "method" value whereas method results begin with an "id" value.
|
||||
@@ -590,7 +595,7 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
|
||||
size_t total_size = str_message.length();
|
||||
for (size_t pos = 0; pos < str_message.length();
|
||||
pos += kMaxMessageChunkSize) {
|
||||
base::StringPiece str_message_chunk =
|
||||
std::string_view str_message_chunk =
|
||||
str_message.substr(pos, kMaxMessageChunkSize);
|
||||
|
||||
CallClientFunction(
|
||||
@@ -638,7 +643,7 @@ bool CefDevToolsFrontend::ProtocolLoggingEnabled() const {
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::LogProtocolMessage(ProtocolMessageType type,
|
||||
const base::StringPiece& message) {
|
||||
const std::string_view& message) {
|
||||
DCHECK(ProtocolLoggingEnabled());
|
||||
|
||||
std::string to_log(message.substr(0, kMaxLogLineLength));
|
@@ -2,13 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
||||
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
||||
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
||||
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/devtools/devtools_file_manager.h"
|
||||
#include "libcef/browser/alloy/devtools/devtools_file_manager.h"
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
@@ -87,7 +87,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
|
||||
|
||||
bool ProtocolLoggingEnabled() const;
|
||||
void LogProtocolMessage(ProtocolMessageType type,
|
||||
const base::StringPiece& message);
|
||||
const std::string_view& message);
|
||||
|
||||
PrefService* GetPrefs() const;
|
||||
|
||||
@@ -111,4 +111,4 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
|
||||
base::WeakPtrFactory<CefDevToolsFrontend> weak_factory_;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/devtools/devtools_manager_delegate.h"
|
||||
#include "libcef/browser/alloy/devtools/devtools_manager_delegate.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
|
||||
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
|
||||
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
|
||||
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
|
||||
|
||||
#include "content/public/browser/devtools_manager_delegate.h"
|
||||
|
||||
@@ -32,4 +32,4 @@ class CefDevToolsManagerDelegate : public content::DevToolsManagerDelegate {
|
||||
bool HasBundledFrontendResources() override;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
|
||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
|
@@ -15,7 +15,10 @@ namespace {
|
||||
class AlloyConstrainedWindowViewsClient
|
||||
: public constrained_window::ConstrainedWindowViewsClient {
|
||||
public:
|
||||
AlloyConstrainedWindowViewsClient() = default;
|
||||
explicit AlloyConstrainedWindowViewsClient(
|
||||
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
|
||||
chrome_client)
|
||||
: chrome_client_(std::move(chrome_client)) {}
|
||||
|
||||
AlloyConstrainedWindowViewsClient(const AlloyConstrainedWindowViewsClient&) =
|
||||
delete;
|
||||
@@ -26,6 +29,12 @@ class AlloyConstrainedWindowViewsClient
|
||||
// ConstrainedWindowViewsClient methods:
|
||||
web_modal::ModalDialogHost* GetModalDialogHost(
|
||||
gfx::NativeWindow parent) override {
|
||||
if (chrome_client_) {
|
||||
if (auto dialog_host = chrome_client_->GetModalDialogHost(parent)) {
|
||||
return dialog_host;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto browser = GetPreferredBrowser(parent)) {
|
||||
return browser->platform_delegate()->GetWebContentsModalDialogHost();
|
||||
}
|
||||
@@ -34,6 +43,12 @@ class AlloyConstrainedWindowViewsClient
|
||||
}
|
||||
|
||||
gfx::NativeView GetDialogHostView(gfx::NativeWindow parent) override {
|
||||
if (chrome_client_) {
|
||||
if (auto host_view = chrome_client_->GetDialogHostView(parent)) {
|
||||
return host_view;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto dialog_host = GetModalDialogHost(parent)) {
|
||||
return dialog_host->GetHostView();
|
||||
}
|
||||
@@ -66,11 +81,17 @@ class AlloyConstrainedWindowViewsClient
|
||||
|
||||
return browser;
|
||||
}
|
||||
|
||||
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
|
||||
chrome_client_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
|
||||
CreateAlloyConstrainedWindowViewsClient() {
|
||||
return std::make_unique<AlloyConstrainedWindowViewsClient>();
|
||||
CreateAlloyConstrainedWindowViewsClient(
|
||||
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
|
||||
chrome_client) {
|
||||
return std::make_unique<AlloyConstrainedWindowViewsClient>(
|
||||
std::move(chrome_client));
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@
|
||||
|
||||
// Creates a ConstrainedWindowViewsClient for the Chrome environment.
|
||||
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
|
||||
CreateAlloyConstrainedWindowViewsClient();
|
||||
CreateAlloyConstrainedWindowViewsClient(
|
||||
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
|
||||
chrome_client);
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_CONSTRAINED_WINDOW_VIEWS_CLIENT_H_
|
||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_CONSTRAINED_WINDOW_VIEWS_CLIENT_H_
|
||||
|
@@ -44,14 +44,20 @@ AlloyWebContentsDialogHelper::GetWebContentsModalDialogHost() {
|
||||
|
||||
gfx::NativeView AlloyWebContentsDialogHelper::GetHostView() const {
|
||||
// Windowless rendering uses GetAcceleratedWidget() instead.
|
||||
if (browser_delegate_->IsWindowless()) {
|
||||
return gfx::NativeView();
|
||||
if (!browser_delegate_->IsWindowless()) {
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// This is supported with all configurations except MacOS with external
|
||||
// parent because we can't provide a gfx::NativeView or a
|
||||
// gfx::AcceleratedWidget on that platform (it's an arbitrary internal
|
||||
// Chromium type). This code should not be reached in that case because
|
||||
// print preview is disabled.
|
||||
DCHECK(!browser_delegate_->HasExternalParent());
|
||||
#endif
|
||||
if (auto widget = browser_delegate_->GetWindowWidget()) {
|
||||
return widget->GetNativeView();
|
||||
}
|
||||
}
|
||||
|
||||
if (auto widget = browser_delegate_->GetWindowWidget()) {
|
||||
return widget->GetNativeView();
|
||||
}
|
||||
DCHECK(false);
|
||||
NOTIMPLEMENTED();
|
||||
return gfx::NativeView();
|
||||
}
|
||||
|
||||
@@ -59,15 +65,13 @@ gfx::AcceleratedWidget AlloyWebContentsDialogHelper::GetAcceleratedWidget()
|
||||
const {
|
||||
#if defined(USE_AURA)
|
||||
// Windowed rendering uses GetHostView() instead.
|
||||
if (!browser_delegate_->IsWindowless()) {
|
||||
return gfx::kNullAcceleratedWidget;
|
||||
}
|
||||
|
||||
if (auto parent_widget = browser_delegate_->GetHostWindowHandle()) {
|
||||
return parent_widget;
|
||||
if (browser_delegate_->IsWindowless()) {
|
||||
if (auto parent_widget = browser_delegate_->GetHostWindowHandle()) {
|
||||
return parent_widget;
|
||||
}
|
||||
}
|
||||
#endif // defined(USE_AURA)
|
||||
DCHECK(false);
|
||||
NOTIMPLEMENTED();
|
||||
return gfx::kNullAcceleratedWidget;
|
||||
}
|
||||
|
||||
|
@@ -117,7 +117,10 @@ void CefAudioCapturer::OnCaptureError(
|
||||
media::AudioCapturerSource::ErrorCode code,
|
||||
const std::string& message) {
|
||||
audio_handler_->OnAudioStreamError(browser_, message);
|
||||
StopStream();
|
||||
|
||||
if (code != media::AudioCapturerSource::ErrorCode::kSocketError) {
|
||||
StopStream();
|
||||
}
|
||||
}
|
||||
|
||||
void CefAudioCapturer::StopStream() {
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "services/network/public/mojom/url_response_head.mojom.h"
|
||||
#include "third_party/blink/public/mojom/favicon/favicon_url.mojom.h"
|
||||
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
|
||||
#include "third_party/blink/public/mojom/page/draggable_region.mojom.h"
|
||||
#include "third_party/blink/public/mojom/widget/platform_widget.mojom-test-utils.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -93,8 +94,7 @@ void CefBrowserContentsDelegate::ObserveWebContents(
|
||||
// Make sure MaybeCreateFrame is called at least one time.
|
||||
// Create the frame representation before OnAfterCreated is called for a new
|
||||
// browser.
|
||||
browser_info_->MaybeCreateFrame(new_contents->GetPrimaryMainFrame(),
|
||||
false /* is_guest_view */);
|
||||
browser_info_->MaybeCreateFrame(new_contents->GetPrimaryMainFrame());
|
||||
|
||||
// Make sure RenderWidgetCreated is called at least one time. This Observer
|
||||
// is registered too late to catch the initial creation.
|
||||
@@ -112,9 +112,11 @@ void CefBrowserContentsDelegate::RemoveObserver(Observer* observer) {
|
||||
|
||||
// |source| may be NULL for navigations in the current tab, or if the
|
||||
// navigation originates from a guest view via MaybeAllowNavigation.
|
||||
content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
|
||||
content::WebContents* CefBrowserContentsDelegate::OpenURLFromTabEx(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) {
|
||||
const content::OpenURLParams& params,
|
||||
base::OnceCallback<void(content::NavigationHandle&)>&
|
||||
navigation_handle_callback) {
|
||||
bool cancel = false;
|
||||
|
||||
if (auto c = client()) {
|
||||
@@ -133,8 +135,13 @@ content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
|
||||
}
|
||||
}
|
||||
|
||||
if (!cancel) {
|
||||
// TODO: Do something with |navigation_handle_callback|.
|
||||
return web_contents();
|
||||
}
|
||||
|
||||
// Returning nullptr will cancel the navigation.
|
||||
return cancel ? nullptr : web_contents();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::LoadingStateChanged(
|
||||
@@ -228,11 +235,9 @@ void CefBrowserContentsDelegate::CanDownload(
|
||||
base::OnceCallback<void(bool)> callback) {
|
||||
bool allow = true;
|
||||
|
||||
if (auto delegate = platform_delegate()) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetDownloadHandler()) {
|
||||
allow = handler->CanDownload(browser(), url.spec(), request_method);
|
||||
}
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetDownloadHandler()) {
|
||||
allow = handler->CanDownload(browser(), url.spec(), request_method);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,9 +299,26 @@ bool CefBrowserContentsDelegate::HandleKeyboardEvent(
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::DraggableRegionsChanged(
|
||||
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
|
||||
content::WebContents* contents) {
|
||||
// Already converted to window bounds in WebViewImpl::DraggableRegionsChanged.
|
||||
std::vector<cef::mojom::DraggableRegionEntryPtr> cef_regions;
|
||||
if (!regions.empty()) {
|
||||
cef_regions.reserve(regions.size());
|
||||
for (const auto& region : regions) {
|
||||
auto cef_region = cef::mojom::DraggableRegionEntry::New(
|
||||
region->bounds, region->draggable);
|
||||
cef_regions.emplace_back(std::move(cef_region));
|
||||
}
|
||||
}
|
||||
|
||||
browser_info_->GetMainFrame()->UpdateDraggableRegions(std::move(cef_regions));
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::RenderFrameCreated(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */);
|
||||
browser_info_->MaybeCreateFrame(render_frame_host);
|
||||
if (render_frame_host->GetParent() == nullptr) {
|
||||
auto render_view_host = render_frame_host->GetRenderViewHost();
|
||||
auto base_background_color = platform_delegate()->GetBackgroundColor();
|
||||
@@ -546,6 +568,10 @@ void CefBrowserContentsDelegate::DidFinishLoad(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& validated_url) {
|
||||
auto frame = browser_info_->GetFrameForHost(render_frame_host);
|
||||
if (!frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
frame->RefreshAttributes();
|
||||
|
||||
int http_status_code = 0;
|
||||
|
@@ -80,10 +80,15 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
||||
void AddObserver(Observer* observer);
|
||||
void RemoveObserver(Observer* observer);
|
||||
|
||||
// WebContentsDelegate methods:
|
||||
content::WebContents* OpenURLFromTab(
|
||||
// Same as OpenURLFromTab but only taking |navigation_handle_callback|
|
||||
// if the return value is non-nullptr.
|
||||
content::WebContents* OpenURLFromTabEx(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) override;
|
||||
const content::OpenURLParams& params,
|
||||
base::OnceCallback<void(content::NavigationHandle&)>&
|
||||
navigation_handle_callback);
|
||||
|
||||
// WebContentsDelegate methods:
|
||||
void LoadingStateChanged(content::WebContents* source,
|
||||
bool should_show_loading_ui) override;
|
||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||
@@ -105,6 +110,9 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
||||
bool HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
void DraggableRegionsChanged(
|
||||
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
|
||||
content::WebContents* contents) override;
|
||||
|
||||
// WebContentsObserver methods:
|
||||
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
|
||||
|
@@ -14,7 +14,6 @@
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/frame_util.h"
|
||||
#include "libcef/features/runtime.h"
|
||||
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/lazy_instance.h"
|
||||
@@ -284,8 +283,7 @@ std::vector<CefBrowserContext*> CefBrowserContext::GetAll() {
|
||||
void CefBrowserContext::OnRenderFrameCreated(
|
||||
CefRequestContextImpl* request_context,
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool is_main_frame,
|
||||
bool is_guest_view) {
|
||||
bool is_main_frame) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(frame_util::IsValidGlobalId(global_id));
|
||||
|
||||
@@ -303,8 +301,7 @@ void CefBrowserContext::OnRenderFrameCreated(
|
||||
void CefBrowserContext::OnRenderFrameDeleted(
|
||||
CefRequestContextImpl* request_context,
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool is_main_frame,
|
||||
bool is_guest_view) {
|
||||
bool is_main_frame) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(frame_util::IsValidGlobalId(global_id));
|
||||
|
||||
@@ -396,10 +393,6 @@ bool CefBrowserContext::UnloadExtension(const CefString& extension_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefBrowserContext::IsPrintPreviewSupported() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
|
||||
CEF_REQUIRE_UIT();
|
||||
auto browser_context = AsBrowserContext();
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include "base/task/sequenced_task_runner_helpers.h"
|
||||
#include "chrome/common/plugin.mojom.h"
|
||||
#include "services/network/public/mojom/network_context.mojom.h"
|
||||
#include "ui/base/page_transition_types.h"
|
||||
#include "url/origin.h"
|
||||
|
||||
/*
|
||||
@@ -131,14 +132,12 @@ class CefBrowserContext {
|
||||
// Called from CefRequestContextImpl::OnRenderFrameCreated.
|
||||
void OnRenderFrameCreated(CefRequestContextImpl* request_context,
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool is_main_frame,
|
||||
bool is_guest_view);
|
||||
bool is_main_frame);
|
||||
|
||||
// Called from CefRequestContextImpl::OnRenderFrameDeleted.
|
||||
void OnRenderFrameDeleted(CefRequestContextImpl* request_context,
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool is_main_frame,
|
||||
bool is_guest_view);
|
||||
bool is_main_frame);
|
||||
|
||||
// Returns the handler that matches the specified IDs. Pass -1 for unknown
|
||||
// values. If |require_frame_match| is true only exact matches will be
|
||||
@@ -172,8 +171,11 @@ class CefBrowserContext {
|
||||
// Called from CefExtensionImpl::Unload().
|
||||
virtual bool UnloadExtension(const CefString& extension_id);
|
||||
|
||||
// Returns true if this context supports print preview.
|
||||
virtual bool IsPrintPreviewSupported() const;
|
||||
// Called from AlloyBrowserHostImpl::DidFinishNavigation to update the table
|
||||
// of visited links.
|
||||
virtual void AddVisitedURLs(const GURL& url,
|
||||
const std::vector<GURL>& redirect_chain,
|
||||
ui::PageTransition transition) = 0;
|
||||
|
||||
network::mojom::NetworkContext* GetNetworkContext();
|
||||
|
||||
|
@@ -5,7 +5,9 @@
|
||||
#include "libcef/browser/browser_frame.h"
|
||||
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/frame_util.h"
|
||||
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
@@ -57,26 +59,31 @@ void CefBrowserFrame::FrameAttached(
|
||||
bool reattached) {
|
||||
// Always send to the newly created RFH, which may be speculative when
|
||||
// navigating cross-origin.
|
||||
if (auto host = GetFrameHost(/*prefer_speculative=*/true)) {
|
||||
bool is_excluded;
|
||||
if (auto host = GetFrameHost(/*prefer_speculative=*/true, &is_excluded)) {
|
||||
host->FrameAttached(std::move(render_frame), reattached);
|
||||
} else if (is_excluded) {
|
||||
VLOG(1) << "frame "
|
||||
<< frame_util::GetFrameDebugString(
|
||||
render_frame_host()->GetGlobalFrameToken())
|
||||
<< " attach denied";
|
||||
mojo::Remote<cef::mojom::RenderFrame> render_frame_remote;
|
||||
render_frame_remote.Bind(std::move(render_frame));
|
||||
render_frame_remote->FrameAttachedAck(/*allow=*/false);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserFrame::UpdateDraggableRegions(
|
||||
std::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) {
|
||||
if (auto host = GetFrameHost()) {
|
||||
if (auto host = GetFrameHost(/*prefer_speculative=*/false)) {
|
||||
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);
|
||||
}
|
||||
DCHECK(false);
|
||||
return nullptr;
|
||||
bool prefer_speculative,
|
||||
bool* is_excluded) const {
|
||||
return CefBrowserInfoManager::GetFrameHost(
|
||||
render_frame_host(), prefer_speculative,
|
||||
/*browser_info=*/nullptr, is_excluded);
|
||||
}
|
||||
|
@@ -48,8 +48,8 @@ class CefBrowserFrame
|
||||
// FrameServiceBase methods:
|
||||
bool ShouldCloseOnFinishNavigation() const override { return false; }
|
||||
|
||||
CefRefPtr<CefFrameHostImpl> GetFrameHost(
|
||||
bool prefer_speculative = false) const;
|
||||
CefRefPtr<CefFrameHostImpl> GetFrameHost(bool prefer_speculative,
|
||||
bool* is_excluded = nullptr) const;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/extensions/browser_extensions_util.h"
|
||||
#include "libcef/browser/hang_monitor.h"
|
||||
#include "libcef/browser/image_impl.h"
|
||||
#include "libcef/browser/navigation_entry_impl.h"
|
||||
@@ -83,6 +84,12 @@ class WebContentsUserDataAdapter : public base::SupportsUserData::Data {
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::FromBrowser(
|
||||
CefRefPtr<CefBrowser> browser) {
|
||||
return static_cast<CefBrowserHostBase*>(browser.get());
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForHost(
|
||||
const content::RenderViewHost* host) {
|
||||
@@ -115,7 +122,18 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForContents(
|
||||
const content::WebContents* contents) {
|
||||
DCHECK(contents);
|
||||
CEF_REQUIRE_UIT();
|
||||
return WebContentsUserDataAdapter::Get(contents);
|
||||
if (auto browser = WebContentsUserDataAdapter::Get(contents)) {
|
||||
return browser;
|
||||
}
|
||||
|
||||
// Try the owner WebContents if |contents| originates from an excluded view
|
||||
// such as the PDF viewer or Print Preview. This is safe to call even if Alloy
|
||||
// extensions are disabled.
|
||||
if (auto* owner_contents = extensions::GetOwnerForGuestContents(contents)) {
|
||||
return WebContentsUserDataAdapter::Get(owner_contents);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -135,10 +153,8 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalId(
|
||||
return GetBrowserForHost(render_frame_host);
|
||||
} else {
|
||||
// Use the thread-safe approach.
|
||||
bool is_guest_view = false;
|
||||
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(
|
||||
global_id, &is_guest_view);
|
||||
if (info && !is_guest_view) {
|
||||
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(global_id);
|
||||
if (info) {
|
||||
auto browser = info->browser();
|
||||
if (!browser) {
|
||||
LOG(WARNING) << "Found browser id " << info->browser_id()
|
||||
@@ -168,10 +184,9 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalToken(
|
||||
return GetBrowserForHost(render_frame_host);
|
||||
} else {
|
||||
// Use the thread-safe approach.
|
||||
bool is_guest_view = false;
|
||||
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(
|
||||
global_token, &is_guest_view);
|
||||
if (info && !is_guest_view) {
|
||||
auto info =
|
||||
CefBrowserInfoManager::GetInstance()->GetBrowserInfo(global_token);
|
||||
if (info) {
|
||||
auto browser = info->browser();
|
||||
if (!browser) {
|
||||
LOG(WARNING) << "Found browser id " << info->browser_id()
|
||||
@@ -251,7 +266,8 @@ void CefBrowserHostBase::InitializeBrowser() {
|
||||
void CefBrowserHostBase::DestroyBrowser() {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
devtools_manager_.reset();
|
||||
devtools_protocol_manager_.reset();
|
||||
devtools_window_runner_.reset();
|
||||
media_stream_registrar_.reset();
|
||||
|
||||
platform_delegate_.reset();
|
||||
@@ -562,6 +578,30 @@ void CefBrowserHostBase::ShowDevTools(const CefWindowInfo& windowInfo,
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::CloseDevTools() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&CefBrowserHostBase::CloseDevTools, this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (devtools_window_runner_) {
|
||||
devtools_window_runner_->CloseDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::HasDevTools() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
DCHECK(false) << "called on invalid thread";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (devtools_window_runner_) {
|
||||
return devtools_window_runner_->HasDevTools();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::SendDevToolsMessage(const void* message,
|
||||
size_t message_size) {
|
||||
if (!message || message_size == 0) {
|
||||
@@ -580,10 +620,10 @@ bool CefBrowserHostBase::SendDevToolsMessage(const void* message,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureDevToolsManager()) {
|
||||
if (!EnsureDevToolsProtocolManager()) {
|
||||
return false;
|
||||
}
|
||||
return devtools_manager_->SendDevToolsMessage(message, message_size);
|
||||
return devtools_protocol_manager_->SendDevToolsMessage(message, message_size);
|
||||
}
|
||||
|
||||
int CefBrowserHostBase::ExecuteDevToolsMethod(
|
||||
@@ -598,10 +638,11 @@ int CefBrowserHostBase::ExecuteDevToolsMethod(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!EnsureDevToolsManager()) {
|
||||
if (!EnsureDevToolsProtocolManager()) {
|
||||
return 0;
|
||||
}
|
||||
return devtools_manager_->ExecuteDevToolsMethod(message_id, method, params);
|
||||
return devtools_protocol_manager_->ExecuteDevToolsMethod(message_id, method,
|
||||
params);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRegistration> CefBrowserHostBase::AddDevToolsMessageObserver(
|
||||
@@ -609,7 +650,7 @@ CefRefPtr<CefRegistration> CefBrowserHostBase::AddDevToolsMessageObserver(
|
||||
if (!observer) {
|
||||
return nullptr;
|
||||
}
|
||||
auto registration = CefDevToolsManager::CreateRegistration(observer);
|
||||
auto registration = CefDevToolsProtocolManager::CreateRegistration(observer);
|
||||
InitializeDevToolsRegistrationOnUIThread(registration);
|
||||
return registration.get();
|
||||
}
|
||||
@@ -731,6 +772,10 @@ bool CefBrowserHostBase::IsRenderProcessUnresponsive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
cef_runtime_style_t CefBrowserHostBase::GetRuntimeStyle() {
|
||||
return IsAlloyStyle() ? CEF_RUNTIME_STYLE_ALLOY : CEF_RUNTIME_STYLE_CHROME;
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::ReplaceMisspelling(const CefString& word) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(
|
||||
@@ -948,8 +993,8 @@ int CefBrowserHostBase::GetIdentifier() {
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::IsSame(CefRefPtr<CefBrowser> that) {
|
||||
auto impl = static_cast<CefBrowserHostBase*>(that.get());
|
||||
return (impl == this);
|
||||
auto impl = FromBrowser(that);
|
||||
return (impl.get() == this);
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::HasDocument() {
|
||||
@@ -1086,12 +1131,12 @@ CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForHost(
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalId(
|
||||
const content::GlobalRenderFrameHostId& global_id) {
|
||||
return browser_info_->GetFrameForGlobalId(global_id, nullptr);
|
||||
return browser_info_->GetFrameForGlobalId(global_id);
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalToken(
|
||||
const content::GlobalRenderFrameHostToken& global_token) {
|
||||
return browser_info_->GetFrameForGlobalToken(global_token, nullptr);
|
||||
return browser_info_->GetFrameForGlobalToken(global_token);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::AddObserver(Observer* observer) {
|
||||
@@ -1143,6 +1188,12 @@ bool CefBrowserHostBase::Navigate(const content::OpenURLParams& params) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::ShowDevToolsOnUIThread(
|
||||
std::unique_ptr<CefShowDevToolsParams> params) {
|
||||
CEF_REQUIRE_UIT();
|
||||
GetDevToolsWindowRunner()->ShowDevTools(this, std::move(params));
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::ViewText(const std::string& text) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
@@ -1196,7 +1247,6 @@ void CefBrowserHostBase::SelectFileListenerDestroyed(
|
||||
|
||||
bool CefBrowserHostBase::MaybeAllowNavigation(
|
||||
content::RenderFrameHost* opener,
|
||||
bool is_guest_view,
|
||||
const content::OpenURLParams& params) {
|
||||
return true;
|
||||
}
|
||||
@@ -1244,10 +1294,6 @@ SkColor CefBrowserHostBase::GetBackgroundColor() const {
|
||||
&settings_, IsWindowless() ? STATE_ENABLED : STATE_DISABLED);
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::IsWindowless() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
content::WebContents* CefBrowserHostBase::GetWebContents() const {
|
||||
CEF_REQUIRE_UIT();
|
||||
return contents_delegate_->web_contents();
|
||||
@@ -1270,6 +1316,13 @@ CefMediaStreamRegistrar* CefBrowserHostBase::GetMediaStreamRegistrar() {
|
||||
return media_stream_registrar_.get();
|
||||
}
|
||||
|
||||
CefDevToolsWindowRunner* CefBrowserHostBase::GetDevToolsWindowRunner() {
|
||||
if (!devtools_window_runner_) {
|
||||
devtools_window_runner_ = CefDevToolsWindowRunner::Create();
|
||||
}
|
||||
return devtools_window_runner_.get();
|
||||
}
|
||||
|
||||
views::Widget* CefBrowserHostBase::GetWindowWidget() const {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!platform_delegate_) {
|
||||
@@ -1321,14 +1374,15 @@ bool CefBrowserHostBase::IsVisible() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::EnsureDevToolsManager() {
|
||||
bool CefBrowserHostBase::EnsureDevToolsProtocolManager() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!contents_delegate_->web_contents()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!devtools_manager_) {
|
||||
devtools_manager_ = std::make_unique<CefDevToolsManager>(this);
|
||||
if (!devtools_protocol_manager_) {
|
||||
devtools_protocol_manager_ =
|
||||
std::make_unique<CefDevToolsProtocolManager>(this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1344,10 +1398,10 @@ void CefBrowserHostBase::InitializeDevToolsRegistrationOnUIThread(
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EnsureDevToolsManager()) {
|
||||
if (!EnsureDevToolsProtocolManager()) {
|
||||
return;
|
||||
}
|
||||
devtools_manager_->InitializeRegistrationOnUIThread(registration);
|
||||
devtools_protocol_manager_->InitializeRegistrationOnUIThread(registration);
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::EnsureFileDialogManager() {
|
||||
|
@@ -13,7 +13,8 @@
|
||||
#include "libcef/browser/browser_contents_delegate.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/devtools/devtools_manager.h"
|
||||
#include "libcef/browser/devtools/devtools_protocol_manager.h"
|
||||
#include "libcef/browser/devtools/devtools_window_runner.h"
|
||||
#include "libcef/browser/file_dialog_manager.h"
|
||||
#include "libcef/browser/frame_host_impl.h"
|
||||
#include "libcef/browser/media_stream_registrar.h"
|
||||
@@ -27,15 +28,19 @@ namespace extensions {
|
||||
class Extension;
|
||||
}
|
||||
|
||||
class RenderViewContextMenuObserver;
|
||||
|
||||
// Parameters that are passed to the runtime-specific Create methods.
|
||||
struct CefBrowserCreateParams {
|
||||
CefBrowserCreateParams() = default;
|
||||
|
||||
// Copy constructor used with the chrome runtime only.
|
||||
// Copy constructor used with Chrome style only.
|
||||
CefBrowserCreateParams(const CefBrowserCreateParams& that) {
|
||||
operator=(that);
|
||||
}
|
||||
CefBrowserCreateParams& operator=(const CefBrowserCreateParams& that) {
|
||||
DCHECK(that.IsChromeStyle());
|
||||
|
||||
// Not all parameters can be copied.
|
||||
client = that.client;
|
||||
url = that.url;
|
||||
@@ -43,14 +48,29 @@ struct CefBrowserCreateParams {
|
||||
request_context = that.request_context;
|
||||
extra_info = that.extra_info;
|
||||
if (that.window_info) {
|
||||
MaybeSetWindowInfo(*that.window_info);
|
||||
MaybeSetWindowInfo(*that.window_info, /*allow_alloy_style=*/false,
|
||||
/*allow_chrome_style=*/true);
|
||||
}
|
||||
browser_view = that.browser_view;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Initialize |window_info| with expected defaults before passing to a client
|
||||
// callback. |opener| will be non-nullptr for popups, DevTools windows, etc.
|
||||
static void InitWindowInfo(CefWindowInfo* window_info,
|
||||
CefBrowserHostBase* opener);
|
||||
|
||||
// Set |window_info| if appropriate (see below).
|
||||
void MaybeSetWindowInfo(const CefWindowInfo& window_info);
|
||||
void MaybeSetWindowInfo(const CefWindowInfo& window_info,
|
||||
bool allow_alloy_style,
|
||||
bool allow_chrome_style);
|
||||
|
||||
// Returns true if |window_info| indicates creation of a Chrome style window.
|
||||
static bool IsChromeStyle(const CefWindowInfo* window_info);
|
||||
bool IsChromeStyle() const;
|
||||
|
||||
// Returns true if parameters indicate windowless (off-screen) rendering.
|
||||
bool IsWindowless() const;
|
||||
|
||||
// Platform-specific window creation info. Will be nullptr for Views-hosted
|
||||
// browsers except when using the Chrome runtime with a native parent handle.
|
||||
@@ -65,6 +85,10 @@ struct CefBrowserCreateParams {
|
||||
// PopupWebContentsCreated).
|
||||
bool popup_with_views_hosted_opener = false;
|
||||
|
||||
// True if this browser is a popup and has an Alloy style opener. Only used
|
||||
// with the Chrome runtime.
|
||||
bool popup_with_alloy_style_opener = false;
|
||||
|
||||
// Client implementation. May be nullptr.
|
||||
CefRefPtr<CefClient> client;
|
||||
|
||||
@@ -95,23 +119,6 @@ struct CefBrowserCreateParams {
|
||||
extensions::mojom::ViewType::kInvalid;
|
||||
};
|
||||
|
||||
// Parameters passed to ShowDevToolsOnUIThread().
|
||||
struct CefShowDevToolsParams {
|
||||
CefShowDevToolsParams(const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings,
|
||||
const CefPoint& inspect_element_at)
|
||||
: window_info_(windowInfo),
|
||||
client_(client),
|
||||
settings_(settings),
|
||||
inspect_element_at_(inspect_element_at) {}
|
||||
|
||||
CefWindowInfo window_info_;
|
||||
CefRefPtr<CefClient> client_;
|
||||
CefBrowserSettings settings_;
|
||||
CefPoint inspect_element_at_;
|
||||
};
|
||||
|
||||
// Base class for CefBrowserHost implementations. Includes functionality that is
|
||||
// shared by the alloy and chrome runtimes. All methods are thread-safe unless
|
||||
// otherwise indicated.
|
||||
@@ -136,6 +143,11 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
static CefRefPtr<CefBrowserHostBase> Create(
|
||||
CefBrowserCreateParams& create_params);
|
||||
|
||||
// Safe conversion from CefBrowserHostBase to CefBrowserHostBase.
|
||||
// Use this method instead of static_cast.
|
||||
static CefRefPtr<CefBrowserHostBase> FromBrowser(
|
||||
CefRefPtr<CefBrowser> browser);
|
||||
|
||||
// Returns the browser associated with the specified RenderViewHost.
|
||||
static CefRefPtr<CefBrowserHostBase> GetBrowserForHost(
|
||||
const content::RenderViewHost* host);
|
||||
@@ -216,6 +228,8 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings,
|
||||
const CefPoint& inspect_element_at) override;
|
||||
void CloseDevTools() override;
|
||||
bool HasDevTools() override;
|
||||
void ReplaceMisspelling(const CefString& word) override;
|
||||
void AddWordToDictionary(const CefString& word) override;
|
||||
void SendKeyEvent(const CefKeyEvent& event) override;
|
||||
@@ -240,6 +254,7 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
bool IsFullscreen() override;
|
||||
void ExitFullscreen(bool will_cause_resize) override;
|
||||
bool IsRenderProcessUnresponsive() override;
|
||||
cef_runtime_style_t GetRuntimeStyle() override;
|
||||
|
||||
// CefBrowser methods:
|
||||
bool IsValid() override;
|
||||
@@ -270,7 +285,8 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
void OnStateChanged(CefBrowserContentsState state_changed) override;
|
||||
void OnWebContentsDestroyed(content::WebContents* web_contents) override;
|
||||
|
||||
// Returns the frame associated with the specified RenderFrameHost.
|
||||
// Returns the frame object matching the specified |host| or nullptr if no
|
||||
// match is found. Must be called on the UI thread.
|
||||
CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host);
|
||||
|
||||
// Returns the frame associated with the specified global ID/token. See
|
||||
@@ -310,7 +326,6 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
|
||||
// Called from CefBrowserInfoManager::MaybeAllowNavigation.
|
||||
virtual bool MaybeAllowNavigation(content::RenderFrameHost* opener,
|
||||
bool is_guest_view,
|
||||
const content::OpenURLParams& params);
|
||||
|
||||
// Helpers for executing client callbacks. Must be called on the UI thread.
|
||||
@@ -330,7 +345,11 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
SkColor GetBackgroundColor() const;
|
||||
|
||||
// Returns true if windowless rendering is enabled.
|
||||
virtual bool IsWindowless() const;
|
||||
virtual bool IsWindowless() const = 0;
|
||||
|
||||
// Returns the runtime style of this browser.
|
||||
virtual bool IsAlloyStyle() const = 0;
|
||||
bool IsChromeStyle() const { return !IsAlloyStyle(); }
|
||||
|
||||
// Accessors that must be called on the UI thread.
|
||||
content::WebContents* GetWebContents() const;
|
||||
@@ -342,6 +361,7 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
return contents_delegate_.get();
|
||||
}
|
||||
CefMediaStreamRegistrar* GetMediaStreamRegistrar();
|
||||
CefDevToolsWindowRunner* GetDevToolsWindowRunner();
|
||||
|
||||
CefRefPtr<CefUnresponsiveProcessCallback> unresponsive_process_callback()
|
||||
const {
|
||||
@@ -352,6 +372,13 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
unresponsive_process_callback_ = callback;
|
||||
}
|
||||
|
||||
RenderViewContextMenuObserver* context_menu_observer() const {
|
||||
return context_menu_observer_;
|
||||
}
|
||||
void set_context_menu_observer(RenderViewContextMenuObserver* observer) {
|
||||
context_menu_observer_ = observer;
|
||||
}
|
||||
|
||||
// Returns the Widget owner for the browser window. Only used with windowed
|
||||
// browsers.
|
||||
views::Widget* GetWindowWidget() const;
|
||||
@@ -378,7 +405,7 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
virtual bool IsVisible() const;
|
||||
|
||||
protected:
|
||||
bool EnsureDevToolsManager();
|
||||
bool EnsureDevToolsProtocolManager();
|
||||
void InitializeDevToolsRegistrationOnUIThread(
|
||||
CefRefPtr<CefRegistration> registration);
|
||||
|
||||
@@ -386,8 +413,7 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
virtual bool Navigate(const content::OpenURLParams& params);
|
||||
|
||||
// Called from ShowDevTools to perform the actual show.
|
||||
virtual void ShowDevToolsOnUIThread(
|
||||
std::unique_ptr<CefShowDevToolsParams> params) = 0;
|
||||
void ShowDevToolsOnUIThread(std::unique_ptr<CefShowDevToolsParams> params);
|
||||
|
||||
// Create the CefFileDialogManager if it doesn't already exist.
|
||||
bool EnsureFileDialogManager();
|
||||
@@ -403,6 +429,7 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
// Only accessed on the UI thread.
|
||||
std::unique_ptr<CefBrowserContentsDelegate> contents_delegate_;
|
||||
CefRefPtr<CefUnresponsiveProcessCallback> unresponsive_process_callback_;
|
||||
RenderViewContextMenuObserver* context_menu_observer_ = nullptr;
|
||||
|
||||
// Observers that want to be notified of changes to this object.
|
||||
// Only accessed on the UI thread.
|
||||
@@ -421,8 +448,11 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
bool is_fullscreen_ = false;
|
||||
CefRefPtr<CefFrameHostImpl> focused_frame_;
|
||||
|
||||
// Used for creating and managing DevTools instances.
|
||||
std::unique_ptr<CefDevToolsManager> devtools_manager_;
|
||||
// Used for managing DevTools instances without a frontend.
|
||||
std::unique_ptr<CefDevToolsProtocolManager> devtools_protocol_manager_;
|
||||
|
||||
// Used for creating and running the DevTools window frontend.
|
||||
std::unique_ptr<CefDevToolsWindowRunner> devtools_window_runner_;
|
||||
|
||||
std::unique_ptr<CefMediaStreamRegistrar> media_stream_registrar_;
|
||||
|
||||
|
@@ -65,8 +65,9 @@ bool CefBrowserHost::CreateBrowser(
|
||||
|
||||
// Verify windowless rendering requirements.
|
||||
if (windowInfo.windowless_rendering_enabled &&
|
||||
!client->GetRenderHandler().get()) {
|
||||
DCHECK(false) << "CefRenderHandler implementation is required";
|
||||
(!client || !client->GetRenderHandler().get())) {
|
||||
LOG(ERROR)
|
||||
<< "Windowless rendering requires a CefRenderHandler implementation";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -133,13 +134,15 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
||||
|
||||
// Verify windowless rendering requirements.
|
||||
if (windowInfo.windowless_rendering_enabled &&
|
||||
!client->GetRenderHandler().get()) {
|
||||
DCHECK(false) << "CefRenderHandler implementation is required";
|
||||
(!client || !client->GetRenderHandler().get())) {
|
||||
LOG(ERROR)
|
||||
<< "Windowless rendering requires a CefRenderHandler implementation";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CefBrowserCreateParams create_params;
|
||||
create_params.MaybeSetWindowInfo(windowInfo);
|
||||
create_params.MaybeSetWindowInfo(windowInfo, /*allow_alloy_style=*/true,
|
||||
/*allow_chrome_style=*/true);
|
||||
create_params.client = client;
|
||||
create_params.url = url;
|
||||
create_params.settings = settings;
|
||||
@@ -149,18 +152,121 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
||||
return CefBrowserHostBase::Create(create_params);
|
||||
}
|
||||
|
||||
// static
|
||||
bool CefBrowserCreateParams::IsChromeStyle(const CefWindowInfo* window_info) {
|
||||
if (!cef::IsChromeRuntimeEnabled()) {
|
||||
return false;
|
||||
}
|
||||
if (!window_info) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Both CHROME and DEFAULT indicate Chrome style with Chrome bootstrap.
|
||||
return window_info->runtime_style == CEF_RUNTIME_STYLE_CHROME ||
|
||||
window_info->runtime_style == CEF_RUNTIME_STYLE_DEFAULT;
|
||||
}
|
||||
|
||||
bool CefBrowserCreateParams::IsChromeStyle() const {
|
||||
if (!cef::IsChromeRuntimeEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool chrome_style_via_window_info = IsChromeStyle(window_info.get());
|
||||
|
||||
if (popup_with_alloy_style_opener) {
|
||||
// Creating a popup where the opener is Alloy style.
|
||||
if (chrome_style_via_window_info &&
|
||||
window_info->runtime_style == CEF_RUNTIME_STYLE_CHROME) {
|
||||
// Only use Chrome style for the popup if the client explicitly sets
|
||||
// CHROME (and not DEFAULT) via CefWindowInfo.runtime_style.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (browser_view) {
|
||||
// Must match the BrowserView style. GetRuntimeStyle() will not return
|
||||
// DEFAULT.
|
||||
return browser_view->GetRuntimeStyle() == CEF_RUNTIME_STYLE_CHROME;
|
||||
}
|
||||
|
||||
// Chrome style does not support windowless rendering.
|
||||
return chrome_style_via_window_info && !IsWindowless();
|
||||
}
|
||||
|
||||
bool CefBrowserCreateParams::IsWindowless() const {
|
||||
return window_info && window_info->windowless_rendering_enabled && client &&
|
||||
client->GetRenderHandler().get();
|
||||
}
|
||||
|
||||
// static
|
||||
void CefBrowserCreateParams::InitWindowInfo(CefWindowInfo* window_info,
|
||||
CefBrowserHostBase* opener) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
window_info->SetAsPopup(nullptr, CefString());
|
||||
#endif
|
||||
|
||||
if (cef::IsChromeRuntimeEnabled() && opener->IsAlloyStyle()) {
|
||||
// Give the popup the same runtime style as the opener.
|
||||
window_info->runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserCreateParams::MaybeSetWindowInfo(
|
||||
const CefWindowInfo& new_window_info) {
|
||||
if (!cef::IsChromeRuntimeEnabled() ||
|
||||
const CefWindowInfo& new_window_info,
|
||||
bool allow_alloy_style,
|
||||
bool allow_chrome_style) {
|
||||
if (!cef::IsChromeRuntimeEnabled()) {
|
||||
// Chrome style is not supported wih the Alloy bootstrap.
|
||||
allow_chrome_style = false;
|
||||
}
|
||||
|
||||
if (allow_chrome_style && new_window_info.windowless_rendering_enabled) {
|
||||
// Chrome style is not supported with windowles rendering.
|
||||
allow_chrome_style = false;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
if (allow_chrome_style &&
|
||||
chrome_child_window::HasParentHandle(new_window_info)) {
|
||||
// Chrome style is not supported with native parent on MacOS. See issue
|
||||
// #3294.
|
||||
allow_chrome_style = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
DCHECK(allow_alloy_style || allow_chrome_style);
|
||||
|
||||
bool reset_style = false;
|
||||
if (new_window_info.runtime_style == CEF_RUNTIME_STYLE_ALLOY &&
|
||||
!allow_alloy_style) {
|
||||
LOG(ERROR) << "Alloy style is not supported for this browser";
|
||||
reset_style = true;
|
||||
} else if (new_window_info.runtime_style == CEF_RUNTIME_STYLE_CHROME &&
|
||||
!allow_chrome_style) {
|
||||
LOG(ERROR) << "Chrome style is not supported for this browser";
|
||||
reset_style = true;
|
||||
}
|
||||
|
||||
const bool is_chrome_style =
|
||||
allow_chrome_style && IsChromeStyle(&new_window_info);
|
||||
if (!is_chrome_style ||
|
||||
chrome_child_window::HasParentHandle(new_window_info)) {
|
||||
window_info = std::make_unique<CefWindowInfo>(new_window_info);
|
||||
if (cef::IsChromeRuntimeEnabled() && !allow_chrome_style) {
|
||||
// Only Alloy style is allowed.
|
||||
window_info->runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||
} else if (reset_style) {
|
||||
// Use the default style.
|
||||
window_info->runtime_style = CEF_RUNTIME_STYLE_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::Create(
|
||||
CefBrowserCreateParams& create_params) {
|
||||
if (cef::IsChromeRuntimeEnabled()) {
|
||||
if (create_params.IsChromeStyle()) {
|
||||
if (auto browser =
|
||||
chrome_child_window::MaybeCreateChildBrowser(create_params)) {
|
||||
return browser.get();
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/frame_util.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
@@ -29,10 +30,12 @@ CefBrowserInfo::FrameInfo::~FrameInfo() {
|
||||
CefBrowserInfo::CefBrowserInfo(int browser_id,
|
||||
bool is_popup,
|
||||
bool is_windowless,
|
||||
bool print_preview_enabled,
|
||||
CefRefPtr<CefDictionaryValue> extra_info)
|
||||
: browser_id_(browser_id),
|
||||
is_popup_(is_popup),
|
||||
is_windowless_(is_windowless),
|
||||
print_preview_enabled_(print_preview_enabled),
|
||||
extra_info_(extra_info) {
|
||||
DCHECK_GT(browser_id, 0);
|
||||
|
||||
@@ -92,10 +95,14 @@ void CefBrowserInfo::SetClosing() {
|
||||
is_closing_ = true;
|
||||
}
|
||||
|
||||
void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
|
||||
bool is_guest_view) {
|
||||
void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
if (CefBrowserInfoManager::IsExcludedFrameHost(host)) {
|
||||
// Don't create a FrameHost for an excluded type.
|
||||
return;
|
||||
}
|
||||
|
||||
const auto global_id = host->GetGlobalId();
|
||||
const bool is_main_frame = (host->GetParent() == nullptr);
|
||||
|
||||
@@ -121,11 +128,10 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
|
||||
#if DCHECK_IS_ON()
|
||||
// Check that the frame info hasn't changed unexpectedly.
|
||||
DCHECK_EQ(info->global_id_, global_id);
|
||||
DCHECK_EQ(info->is_guest_view_, is_guest_view);
|
||||
DCHECK_EQ(info->is_main_frame_, is_main_frame);
|
||||
#endif
|
||||
|
||||
if (!info->is_guest_view_ && info->is_speculative_ && !is_speculative) {
|
||||
if (info->is_speculative_ && !is_speculative) {
|
||||
// Upgrade the frame info from speculative to non-speculative.
|
||||
if (info->is_main_frame_) {
|
||||
// Set the main frame object.
|
||||
@@ -139,28 +145,23 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
|
||||
auto frame_info = new FrameInfo;
|
||||
frame_info->host_ = host;
|
||||
frame_info->global_id_ = global_id;
|
||||
frame_info->is_guest_view_ = is_guest_view;
|
||||
frame_info->is_main_frame_ = is_main_frame;
|
||||
frame_info->is_speculative_ = is_speculative;
|
||||
|
||||
// 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 DCHECK_IS_ON()
|
||||
// Check that the frame info hasn't changed unexpectedly.
|
||||
DCHECK(host->GetGlobalFrameToken() == *frame_info->frame_->frame_token());
|
||||
DCHECK_EQ(frame_info->is_main_frame_, frame_info->frame_->IsMain());
|
||||
#endif
|
||||
// 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_);
|
||||
}
|
||||
|
||||
browser_->request_context()->OnRenderFrameCreated(global_id, is_main_frame,
|
||||
is_guest_view);
|
||||
#if DCHECK_IS_ON()
|
||||
// Check that the frame info hasn't changed unexpectedly.
|
||||
DCHECK(host->GetGlobalFrameToken() == *frame_info->frame_->frame_token());
|
||||
DCHECK_EQ(frame_info->is_main_frame_, frame_info->frame_->IsMain());
|
||||
#endif
|
||||
|
||||
browser_->request_context()->OnRenderFrameCreated(global_id, is_main_frame);
|
||||
|
||||
// Populate the lookup maps.
|
||||
frame_id_map_.insert(std::make_pair(global_id, frame_info));
|
||||
@@ -210,10 +211,11 @@ void CefBrowserInfo::FrameHostStateChanged(
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
auto it = frame_id_map_.find(host->GetGlobalId());
|
||||
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;
|
||||
if (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) {
|
||||
@@ -223,12 +225,14 @@ void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
|
||||
|
||||
const auto global_id = host->GetGlobalId();
|
||||
auto it = frame_id_map_.find(global_id);
|
||||
DCHECK(it != frame_id_map_.end());
|
||||
if (it == frame_id_map_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto frame_info = it->second;
|
||||
|
||||
browser_->request_context()->OnRenderFrameDeleted(
|
||||
global_id, frame_info->is_main_frame_, frame_info->is_guest_view_);
|
||||
browser_->request_context()->OnRenderFrameDeleted(global_id,
|
||||
frame_info->is_main_frame_);
|
||||
|
||||
// Remove from the lookup maps.
|
||||
frame_id_map_.erase(it);
|
||||
@@ -279,29 +283,19 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::CreateTempSubFrame(
|
||||
|
||||
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForHost(
|
||||
const content::RenderFrameHost* host,
|
||||
bool* is_guest_view,
|
||||
bool prefer_speculative) const {
|
||||
if (is_guest_view) {
|
||||
*is_guest_view = false;
|
||||
}
|
||||
|
||||
if (!host) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GetFrameForGlobalId(
|
||||
const_cast<content::RenderFrameHost*>(host)->GetGlobalId(), is_guest_view,
|
||||
const_cast<content::RenderFrameHost*>(host)->GetGlobalId(),
|
||||
prefer_speculative);
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId(
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool* is_guest_view,
|
||||
bool prefer_speculative) const {
|
||||
if (is_guest_view) {
|
||||
*is_guest_view = false;
|
||||
}
|
||||
|
||||
if (!frame_util::IsValidGlobalId(global_id)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -312,13 +306,6 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId(
|
||||
if (it != frame_id_map_.end()) {
|
||||
const auto info = it->second;
|
||||
|
||||
if (info->is_guest_view_) {
|
||||
if (is_guest_view) {
|
||||
*is_guest_view = true;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (info->is_speculative_ && !prefer_speculative) {
|
||||
if (info->is_main_frame_ && main_frame_) {
|
||||
// Always prefer the non-speculative main frame.
|
||||
@@ -338,12 +325,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId(
|
||||
|
||||
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalToken(
|
||||
const content::GlobalRenderFrameHostToken& global_token,
|
||||
bool* is_guest_view,
|
||||
bool prefer_speculative) const {
|
||||
if (is_guest_view) {
|
||||
*is_guest_view = false;
|
||||
}
|
||||
|
||||
if (!frame_util::IsValidGlobalToken(global_token)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -359,7 +341,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalToken(
|
||||
global_id = it->second;
|
||||
}
|
||||
|
||||
return GetFrameForGlobalId(global_id, is_guest_view, prefer_speculative);
|
||||
return GetFrameForGlobalId(global_id, prefer_speculative);
|
||||
}
|
||||
|
||||
CefBrowserInfo::FrameHostList CefBrowserInfo::GetAllFrames() const {
|
||||
|
@@ -37,6 +37,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
CefBrowserInfo(int browser_id,
|
||||
bool is_popup,
|
||||
bool is_windowless,
|
||||
bool print_preview_enabled,
|
||||
CefRefPtr<CefDictionaryValue> extra_info);
|
||||
|
||||
CefBrowserInfo(const CefBrowserInfo&) = delete;
|
||||
@@ -45,6 +46,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
int browser_id() const { return browser_id_; }
|
||||
bool is_popup() const { return is_popup_; }
|
||||
bool is_windowless() const { return is_windowless_; }
|
||||
bool print_preview_enabled() const { return print_preview_enabled_; }
|
||||
CefRefPtr<CefDictionaryValue> extra_info() const { return extra_info_; }
|
||||
|
||||
// May return NULL if the browser has not yet been created or if the browser
|
||||
@@ -65,10 +67,8 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
// Ensure that a frame record exists for |host|. Called for the main frame
|
||||
// when the RenderView is created, or for a sub-frame when the associated
|
||||
// RenderFrame is created in the renderer process.
|
||||
// Called from CefBrowserContentsDelegate::RenderFrameCreated (is_guest_view =
|
||||
// false) or CefMimeHandlerViewGuestDelegate::OnGuestAttached (is_guest_view =
|
||||
// true).
|
||||
void MaybeCreateFrame(content::RenderFrameHost* host, bool is_guest_view);
|
||||
// Called from CefBrowserContentsDelegate::RenderFrameCreated.
|
||||
void MaybeCreateFrame(content::RenderFrameHost* host);
|
||||
|
||||
// Used to track state changes such as entering/exiting the BackForwardCache.
|
||||
// Called from CefBrowserContentsDelegate::RenderFrameHostStateChanged.
|
||||
@@ -100,32 +100,22 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
const content::GlobalRenderFrameHostId& parent_global_id);
|
||||
|
||||
// Returns the frame object matching the specified host or nullptr if no match
|
||||
// is found. Nullptr will also be returned if a guest view match is found
|
||||
// because we don't create frame objects for guest views. If |is_guest_view|
|
||||
// is non-nullptr it will be set to true in this case. Must be called on the
|
||||
// UI thread.
|
||||
// is found. Must be called on the UI thread.
|
||||
CefRefPtr<CefFrameHostImpl> GetFrameForHost(
|
||||
const content::RenderFrameHost* host,
|
||||
bool* is_guest_view = nullptr,
|
||||
bool prefer_speculative = false) const;
|
||||
|
||||
// Returns the frame object matching the specified ID/token or nullptr if no
|
||||
// match is found. Nullptr will also be returned if a guest view match is
|
||||
// found because we don't create frame objects for guest views. If
|
||||
// |is_guest_view| is non-nullptr it will be set to true in this case. Safe to
|
||||
// call from any thread.
|
||||
// match is found. Safe to call from any thread.
|
||||
CefRefPtr<CefFrameHostImpl> GetFrameForGlobalId(
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool* is_guest_view = nullptr,
|
||||
bool prefer_speculative = false) const;
|
||||
CefRefPtr<CefFrameHostImpl> GetFrameForGlobalToken(
|
||||
const content::GlobalRenderFrameHostToken& global_token,
|
||||
bool* is_guest_view = nullptr,
|
||||
bool prefer_speculative = false) const;
|
||||
|
||||
// Returns all non-speculative frame objects that currently exist. Guest views
|
||||
// will be excluded because they don't have a frame object. Safe to call from
|
||||
// any thread.
|
||||
// Returns all non-speculative frame objects that currently exist. Safe to
|
||||
// call from any thread.
|
||||
using FrameHostList = std::set<CefRefPtr<CefFrameHostImpl>>;
|
||||
FrameHostList GetAllFrames() const;
|
||||
|
||||
@@ -182,7 +172,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
|
||||
content::RenderFrameHost* host_;
|
||||
content::GlobalRenderFrameHostId global_id_;
|
||||
bool is_guest_view_;
|
||||
bool is_main_frame_;
|
||||
bool is_speculative_;
|
||||
bool is_in_bfcache_ = false;
|
||||
@@ -201,9 +190,10 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
|
||||
void RemoveAllFrames(CefRefPtr<CefBrowserHostBase> old_browser);
|
||||
|
||||
int browser_id_;
|
||||
bool is_popup_;
|
||||
bool is_windowless_;
|
||||
const int browser_id_;
|
||||
const bool is_popup_;
|
||||
const bool is_windowless_;
|
||||
const bool print_preview_enabled_;
|
||||
CefRefPtr<CefDictionaryValue> extra_info_;
|
||||
|
||||
// Navigation will be blocked while |navigation_lock_| exists.
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
#include "libcef/common/frame_util.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
#include "libcef/features/runtime.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/logging.h"
|
||||
@@ -66,11 +66,13 @@ CefBrowserInfoManager* CefBrowserInfoManager::GetInstance() {
|
||||
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreateBrowserInfo(
|
||||
bool is_popup,
|
||||
bool is_windowless,
|
||||
bool print_preview_enabled,
|
||||
CefRefPtr<CefDictionaryValue> extra_info) {
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
|
||||
scoped_refptr<CefBrowserInfo> browser_info = new CefBrowserInfo(
|
||||
++next_browser_id_, is_popup, is_windowless, extra_info);
|
||||
scoped_refptr<CefBrowserInfo> browser_info =
|
||||
new CefBrowserInfo(++next_browser_id_, is_popup, is_windowless,
|
||||
print_preview_enabled, extra_info);
|
||||
browser_info_list_.push_back(browser_info);
|
||||
|
||||
return browser_info;
|
||||
@@ -79,24 +81,23 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreateBrowserInfo(
|
||||
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
|
||||
content::WebContents* new_contents,
|
||||
bool is_windowless,
|
||||
bool print_preview_enabled,
|
||||
CefRefPtr<CefDictionaryValue> extra_info) {
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
auto frame_host = new_contents->GetPrimaryMainFrame();
|
||||
|
||||
scoped_refptr<CefBrowserInfo> browser_info =
|
||||
new CefBrowserInfo(++next_browser_id_, true, is_windowless, extra_info);
|
||||
browser_info_list_.push_back(browser_info);
|
||||
scoped_refptr<CefBrowserInfo> browser_info;
|
||||
{
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
browser_info = new CefBrowserInfo(++next_browser_id_, true, is_windowless,
|
||||
print_preview_enabled, extra_info);
|
||||
browser_info_list_.push_back(browser_info);
|
||||
}
|
||||
|
||||
// Continue any pending NewBrowserInfo request.
|
||||
auto it =
|
||||
pending_new_browser_info_map_.find(frame_host->GetGlobalFrameToken());
|
||||
if (it != pending_new_browser_info_map_.end()) {
|
||||
SendNewBrowserInfoResponse(browser_info, /*is_guest_view=*/false,
|
||||
std::move(it->second->callback),
|
||||
it->second->callback_runner);
|
||||
pending_new_browser_info_map_.erase(it);
|
||||
}
|
||||
ContinueNewBrowserInfo(frame_host->GetGlobalFrameToken(), browser_info,
|
||||
/*is_excluded=*/false);
|
||||
|
||||
return browser_info;
|
||||
}
|
||||
@@ -129,10 +130,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
bool handled = false;
|
||||
|
||||
CefWindowInfo window_info;
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
window_info.SetAsPopup(nullptr, CefString());
|
||||
#endif
|
||||
CefBrowserCreateParams::InitWindowInfo(&window_info, browser.get());
|
||||
|
||||
auto pending_popup = std::make_unique<CefBrowserInfoManager::PendingPopup>();
|
||||
pending_popup->step = PendingPopup::CAN_CREATE_WINDOW;
|
||||
@@ -185,10 +183,12 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
|
||||
if (allow) {
|
||||
CefBrowserCreateParams create_params;
|
||||
create_params.MaybeSetWindowInfo(window_info);
|
||||
create_params.MaybeSetWindowInfo(window_info, /*allow_alloy_style=*/true,
|
||||
/*allow_chrome_style=*/true);
|
||||
|
||||
if (!handled) {
|
||||
// Use default Browser creation if OnBeforePopup was unhandled.
|
||||
// Use default Browser creation with Chrome style if OnBeforePopup was
|
||||
// unhandled.
|
||||
// TODO(chrome): Expose a mechanism for the client to choose default
|
||||
// creation.
|
||||
pending_popup->use_default_browser_creation = true;
|
||||
@@ -196,6 +196,10 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
|
||||
create_params.popup_with_views_hosted_opener = ShouldCreateViewsHostedPopup(
|
||||
browser, pending_popup->use_default_browser_creation);
|
||||
|
||||
// Potentially use Alloy style with the Chrome runtime.
|
||||
create_params.popup_with_alloy_style_opener = browser->IsAlloyStyle();
|
||||
|
||||
create_params.settings = pending_popup->settings;
|
||||
create_params.client = pending_popup->client;
|
||||
create_params.extra_info = pending_popup->extra_info;
|
||||
@@ -204,6 +208,11 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
CefBrowserPlatformDelegate::Create(create_params);
|
||||
CHECK(pending_popup->platform_delegate.get());
|
||||
|
||||
// Expect runtime style to match.
|
||||
pending_popup->alloy_style = !create_params.IsChromeStyle();
|
||||
CHECK_EQ(pending_popup->alloy_style,
|
||||
pending_popup->platform_delegate->IsAlloyStyle());
|
||||
|
||||
// Between the calls to CanCreateWindow and GetCustomWebContentsView
|
||||
// RenderViewHostImpl::CreateNewWindow() will call
|
||||
// RenderProcessHostImpl::FilterURL() which, in the case of "javascript:"
|
||||
@@ -223,9 +232,9 @@ void CefBrowserInfoManager::GetCustomWebContentsView(
|
||||
content::WebContentsView** view,
|
||||
content::RenderViewHostDelegateView** delegate_view) {
|
||||
CEF_REQUIRE_UIT();
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
|
||||
auto pending_popup = PopPendingPopup(PendingPopup::CAN_CREATE_WINDOW,
|
||||
PendingPopup::CAN_CREATE_WINDOW,
|
||||
opener_global_id, target_url);
|
||||
DCHECK(pending_popup.get());
|
||||
DCHECK(pending_popup->platform_delegate.get());
|
||||
@@ -249,13 +258,10 @@ void CefBrowserInfoManager::WebContentsCreated(
|
||||
content::WebContents* new_contents) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// GET_CUSTOM_WEB_CONTENTS_VIEW is only used with the alloy runtime.
|
||||
const auto previous_step = cef::IsAlloyRuntimeEnabled()
|
||||
? PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW
|
||||
: PendingPopup::CAN_CREATE_WINDOW;
|
||||
|
||||
auto pending_popup =
|
||||
PopPendingPopup(previous_step, opener_global_id, target_url);
|
||||
// GET_CUSTOM_WEB_CONTENTS_VIEW is only used with Alloy style.
|
||||
auto pending_popup = PopPendingPopup(
|
||||
PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW,
|
||||
PendingPopup::CAN_CREATE_WINDOW, opener_global_id, target_url);
|
||||
DCHECK(pending_popup.get());
|
||||
DCHECK(pending_popup->platform_delegate.get());
|
||||
|
||||
@@ -264,8 +270,8 @@ void CefBrowserInfoManager::WebContentsCreated(
|
||||
platform_delegate = std::move(pending_popup->platform_delegate);
|
||||
extra_info = pending_popup->extra_info;
|
||||
|
||||
// AddWebContents (the next step) is only used with the Chrome runtime.
|
||||
if (cef::IsChromeRuntimeEnabled()) {
|
||||
// AddWebContents (the next step) is only used with Chrome style.
|
||||
if (!pending_popup->alloy_style) {
|
||||
pending_popup->step = PendingPopup::WEB_CONTENTS_CREATED;
|
||||
pending_popup->new_contents = new_contents;
|
||||
PushPendingPopup(std::move(pending_popup));
|
||||
@@ -280,8 +286,10 @@ bool CefBrowserInfoManager::AddWebContents(content::WebContents* new_contents) {
|
||||
// chrome::AddWebContents is called directly from the Chrome UI (profile
|
||||
// settings, etc).
|
||||
auto pending_popup =
|
||||
PopPendingPopup(PendingPopup::WEB_CONTENTS_CREATED, new_contents);
|
||||
PopPendingPopup(PendingPopup::WEB_CONTENTS_CREATED,
|
||||
PendingPopup::WEB_CONTENTS_CREATED, new_contents);
|
||||
if (pending_popup) {
|
||||
DCHECK(!pending_popup->alloy_style);
|
||||
return !pending_popup->use_default_browser_creation;
|
||||
}
|
||||
|
||||
@@ -299,15 +307,13 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
|
||||
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
|
||||
bool is_guest_view = false;
|
||||
|
||||
scoped_refptr<CefBrowserInfo> browser_info =
|
||||
GetBrowserInfoInternal(global_token, &is_guest_view);
|
||||
GetBrowserInfoInternal(global_token);
|
||||
|
||||
if (browser_info) {
|
||||
// Send the response immediately.
|
||||
SendNewBrowserInfoResponse(browser_info, is_guest_view, std::move(callback),
|
||||
callback_runner);
|
||||
SendNewBrowserInfoResponse(browser_info, /*is_excluded=*/false,
|
||||
std::move(callback), callback_runner);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -338,6 +344,54 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
|
||||
global_token, timeout_id),
|
||||
kNewBrowserInfoResponseTimeoutMs);
|
||||
}
|
||||
|
||||
// Check for excluded content (PDF viewer or print preview).
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT,
|
||||
base::BindOnce(
|
||||
&CefBrowserInfoManager::CheckExcludedNewBrowserInfoOnUIThread,
|
||||
global_token));
|
||||
}
|
||||
|
||||
// static
|
||||
void CefBrowserInfoManager::CheckExcludedNewBrowserInfoOnUIThread(
|
||||
const content::GlobalRenderFrameHostToken& global_token) {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!g_info_manager) {
|
||||
return;
|
||||
}
|
||||
|
||||
// May return nullptr for PDF renderer process.
|
||||
auto* rfh = content::RenderFrameHost::FromFrameToken(global_token);
|
||||
if (!rfh) {
|
||||
return;
|
||||
}
|
||||
|
||||
// PDF viewer and print preview create multiple renderer processes. These
|
||||
// excluded processes are not tracked by CefBrowserInfo.
|
||||
CefBrowserInfo* browser_info;
|
||||
bool is_excluded;
|
||||
GetFrameHost(rfh, /*prefer_speculative=*/true, &browser_info, &is_excluded);
|
||||
if (browser_info && is_excluded) {
|
||||
g_info_manager->ContinueNewBrowserInfo(global_token, browser_info,
|
||||
/*is_excluded=*/true);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserInfoManager::ContinueNewBrowserInfo(
|
||||
const content::GlobalRenderFrameHostToken& global_token,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
bool is_excluded) {
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
|
||||
// Continue any pending NewBrowserInfo request.
|
||||
auto it = pending_new_browser_info_map_.find(global_token);
|
||||
if (it != pending_new_browser_info_map_.end()) {
|
||||
SendNewBrowserInfoResponse(browser_info, is_excluded,
|
||||
std::move(it->second->callback),
|
||||
it->second->callback_runner);
|
||||
pending_new_browser_info_map_.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserInfoManager::RemoveBrowserInfo(
|
||||
@@ -386,17 +440,15 @@ void CefBrowserInfoManager::DestroyAllBrowsers() {
|
||||
}
|
||||
|
||||
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool* is_guest_view) {
|
||||
const content::GlobalRenderFrameHostId& global_id) {
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
return GetBrowserInfoInternal(global_id, is_guest_view);
|
||||
return GetBrowserInfoInternal(global_id);
|
||||
}
|
||||
|
||||
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
|
||||
const content::GlobalRenderFrameHostToken& global_token,
|
||||
bool* is_guest_view) {
|
||||
const content::GlobalRenderFrameHostToken& global_token) {
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
return GetBrowserInfoInternal(global_token, is_guest_view);
|
||||
return GetBrowserInfoInternal(global_token);
|
||||
}
|
||||
|
||||
bool CefBrowserInfoManager::MaybeAllowNavigation(
|
||||
@@ -405,15 +457,14 @@ bool CefBrowserInfoManager::MaybeAllowNavigation(
|
||||
CefRefPtr<CefBrowserHostBase>& browser_out) const {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
bool is_guest_view = false;
|
||||
auto browser = extensions::GetOwnerBrowserForHost(opener, &is_guest_view);
|
||||
auto browser = CefBrowserHostBase::GetBrowserForHost(opener);
|
||||
if (!browser) {
|
||||
// Print preview uses a modal dialog where we don't own the WebContents.
|
||||
// Allow that navigation to proceed.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!browser->MaybeAllowNavigation(opener, is_guest_view, params)) {
|
||||
if (!browser->MaybeAllowNavigation(opener, params)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -434,6 +485,83 @@ bool CefBrowserInfoManager::ShouldCreateViewsHostedPopup(
|
||||
!use_default_browser_creation;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefFrameHostImpl> CefBrowserInfoManager::GetFrameHost(
|
||||
content::RenderFrameHost* rfh,
|
||||
bool prefer_speculative,
|
||||
CefBrowserInfo** browser_info,
|
||||
bool* is_excluded) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(rfh);
|
||||
|
||||
const bool is_pdf_process = rfh->GetProcess()->IsPdf();
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
const bool is_browser_process_guest =
|
||||
extensions::IsBrowserPluginGuest(web_contents);
|
||||
const bool is_print_preview_dialog =
|
||||
extensions::IsPrintPreviewDialog(web_contents);
|
||||
|
||||
bool excluded =
|
||||
is_pdf_process || is_browser_process_guest || is_print_preview_dialog;
|
||||
|
||||
CefRefPtr<CefFrameHostImpl> frame;
|
||||
|
||||
// A BrowserHost may match an excluded RFH type. Some associations are
|
||||
// registered directly via CefBrowserInfo::MaybeCreateFrame and some are
|
||||
// discovered indirectly via extensions::GetOwnerForGuestContents.
|
||||
auto browser = CefBrowserHostBase::GetBrowserForHost(rfh);
|
||||
if (browser && !excluded) {
|
||||
frame = browser->browser_info()->GetFrameForHost(rfh, prefer_speculative);
|
||||
}
|
||||
|
||||
if (browser_info) {
|
||||
*browser_info = browser ? browser->browser_info().get() : nullptr;
|
||||
}
|
||||
|
||||
if (is_excluded) {
|
||||
*is_excluded = excluded;
|
||||
}
|
||||
|
||||
if (VLOG_IS_ON(1)) {
|
||||
const std::string& debug_string =
|
||||
frame_util::GetFrameDebugString(rfh->GetGlobalFrameToken());
|
||||
const bool is_main = rfh->GetParent() == nullptr;
|
||||
|
||||
VLOG(1) << "frame " << debug_string << ", pdf_process=" << is_pdf_process
|
||||
<< ", browser_process_guest=" << is_browser_process_guest
|
||||
<< ", print_preview_dialog=" << is_print_preview_dialog
|
||||
<< ", main=" << is_main << (browser ? "" : ", has no BrowserHost")
|
||||
<< (frame ? "" : ", has no FrameHost");
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
// static
|
||||
bool CefBrowserInfoManager::IsExcludedFrameHost(content::RenderFrameHost* rfh) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(rfh);
|
||||
|
||||
const bool is_pdf_process = rfh->GetProcess()->IsPdf();
|
||||
if (is_pdf_process) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
const bool is_browser_process_guest =
|
||||
extensions::IsBrowserPluginGuest(web_contents);
|
||||
if (is_browser_process_guest) {
|
||||
return true;
|
||||
}
|
||||
const bool is_print_preview_dialog =
|
||||
extensions::IsPrintPreviewDialog(web_contents);
|
||||
if (is_print_preview_dialog) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CefBrowserInfoManager::BrowserInfoList
|
||||
CefBrowserInfoManager::GetBrowserInfoList() {
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
@@ -490,16 +618,21 @@ void CefBrowserInfoManager::PushPendingPopup(
|
||||
|
||||
std::unique_ptr<CefBrowserInfoManager::PendingPopup>
|
||||
CefBrowserInfoManager::PopPendingPopup(
|
||||
PendingPopup::Step previous_step,
|
||||
PendingPopup::Step previous_step_alloy,
|
||||
PendingPopup::Step previous_step_chrome,
|
||||
const content::GlobalRenderFrameHostId& opener_global_id,
|
||||
const GURL& target_url) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(frame_util::IsValidGlobalId(opener_global_id));
|
||||
DCHECK_LE(previous_step, PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW);
|
||||
DCHECK_LE(previous_step_alloy, PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW);
|
||||
DCHECK_LE(previous_step_chrome, PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW);
|
||||
|
||||
PendingPopupList::iterator it = pending_popup_list_.begin();
|
||||
for (; it != pending_popup_list_.end(); ++it) {
|
||||
PendingPopup* popup = it->get();
|
||||
const auto previous_step =
|
||||
popup->alloy_style ? previous_step_alloy : previous_step_chrome;
|
||||
|
||||
if (popup->step == previous_step &&
|
||||
popup->opener_global_id == opener_global_id &&
|
||||
popup->target_url == target_url) {
|
||||
@@ -514,14 +647,19 @@ CefBrowserInfoManager::PopPendingPopup(
|
||||
}
|
||||
|
||||
std::unique_ptr<CefBrowserInfoManager::PendingPopup>
|
||||
CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step previous_step,
|
||||
CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step previous_step_alloy,
|
||||
PendingPopup::Step previous_step_chrome,
|
||||
content::WebContents* new_contents) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK_GE(previous_step, PendingPopup::WEB_CONTENTS_CREATED);
|
||||
DCHECK_GE(previous_step_alloy, PendingPopup::WEB_CONTENTS_CREATED);
|
||||
DCHECK_GE(previous_step_chrome, PendingPopup::WEB_CONTENTS_CREATED);
|
||||
|
||||
PendingPopupList::iterator it = pending_popup_list_.begin();
|
||||
for (; it != pending_popup_list_.end(); ++it) {
|
||||
PendingPopup* popup = it->get();
|
||||
const auto previous_step =
|
||||
popup->alloy_style ? previous_step_alloy : previous_step_chrome;
|
||||
|
||||
if (popup->step == previous_step && popup->new_contents == new_contents) {
|
||||
// Transfer ownership of the pointer.
|
||||
it->release();
|
||||
@@ -534,26 +672,16 @@ CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step previous_step,
|
||||
}
|
||||
|
||||
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool* is_guest_view) {
|
||||
const content::GlobalRenderFrameHostId& global_id) {
|
||||
browser_info_lock_.AssertAcquired();
|
||||
|
||||
if (is_guest_view) {
|
||||
*is_guest_view = false;
|
||||
}
|
||||
|
||||
if (!frame_util::IsValidGlobalId(global_id)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (const auto& browser_info : browser_info_list_) {
|
||||
bool is_guest_view_tmp;
|
||||
auto frame =
|
||||
browser_info->GetFrameForGlobalId(global_id, &is_guest_view_tmp);
|
||||
if (frame || is_guest_view_tmp) {
|
||||
if (is_guest_view) {
|
||||
*is_guest_view = is_guest_view_tmp;
|
||||
}
|
||||
auto frame = browser_info->GetFrameForGlobalId(global_id);
|
||||
if (frame) {
|
||||
return browser_info;
|
||||
}
|
||||
}
|
||||
@@ -562,26 +690,16 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
|
||||
}
|
||||
|
||||
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
|
||||
const content::GlobalRenderFrameHostToken& global_token,
|
||||
bool* is_guest_view) {
|
||||
const content::GlobalRenderFrameHostToken& global_token) {
|
||||
browser_info_lock_.AssertAcquired();
|
||||
|
||||
if (is_guest_view) {
|
||||
*is_guest_view = false;
|
||||
}
|
||||
|
||||
if (!frame_util::IsValidGlobalToken(global_token)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (const auto& browser_info : browser_info_list_) {
|
||||
bool is_guest_view_tmp;
|
||||
auto frame =
|
||||
browser_info->GetFrameForGlobalToken(global_token, &is_guest_view_tmp);
|
||||
if (frame || is_guest_view_tmp) {
|
||||
if (is_guest_view) {
|
||||
*is_guest_view = is_guest_view_tmp;
|
||||
}
|
||||
auto frame = browser_info->GetFrameForGlobalToken(global_token);
|
||||
if (frame) {
|
||||
return browser_info;
|
||||
}
|
||||
}
|
||||
@@ -592,25 +710,26 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
|
||||
// static
|
||||
void CefBrowserInfoManager::SendNewBrowserInfoResponse(
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
bool is_guest_view,
|
||||
bool is_excluded,
|
||||
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
|
||||
scoped_refptr<base::SequencedTaskRunner> callback_runner) {
|
||||
if (!callback_runner->RunsTasksInCurrentSequence()) {
|
||||
callback_runner->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&CefBrowserInfoManager::SendNewBrowserInfoResponse,
|
||||
browser_info, is_guest_view, std::move(callback),
|
||||
browser_info, is_excluded, std::move(callback),
|
||||
callback_runner));
|
||||
return;
|
||||
}
|
||||
|
||||
auto params = cef::mojom::NewBrowserInfo::New();
|
||||
params->is_guest_view = is_guest_view;
|
||||
params->is_excluded = is_excluded;
|
||||
|
||||
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->print_preview_enabled = browser_info->print_preview_enabled();
|
||||
|
||||
auto extra_info = browser_info->extra_info();
|
||||
if (extra_info) {
|
||||
@@ -630,7 +749,7 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
|
||||
// static
|
||||
void CefBrowserInfoManager::CancelNewBrowserInfoResponse(
|
||||
PendingNewBrowserInfo* pending_info) {
|
||||
SendNewBrowserInfoResponse(/*browser_info=*/nullptr, /*is_guest_view=*/false,
|
||||
SendNewBrowserInfoResponse(/*browser_info=*/nullptr, /*is_excluded=*/false,
|
||||
std::move(pending_info->callback),
|
||||
pending_info->callback_runner);
|
||||
}
|
||||
@@ -655,15 +774,21 @@ void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse(
|
||||
return;
|
||||
}
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
// This method should never be called for a PDF renderer.
|
||||
content::RenderProcessHost* process =
|
||||
content::RenderProcessHost::FromID(global_token.child_id);
|
||||
DCHECK(!process || !process->IsPdf());
|
||||
#endif
|
||||
// Cases where we expect to time out are:
|
||||
// - With the Chrome runtime when chrome::AddWebContents or
|
||||
// WebContents::Create are called directly from the Chrome UI (profile
|
||||
// settings, etc). A RFH will exist without a matching CefBrowserHost.
|
||||
// - When the PDF renderer is loaded in the print preview dialog. There will
|
||||
// be no RFH in this case.
|
||||
// Any additional cases should be debugged and, if possible,
|
||||
// extensions::GetOwnerForGuestContents should be improved to find the
|
||||
// associated CefBrowserHost.
|
||||
const bool has_rfh =
|
||||
!!content::RenderFrameHost::FromFrameToken(global_token);
|
||||
|
||||
LOG(ERROR) << "Timeout of new browser info response for frame "
|
||||
<< frame_util::GetFrameDebugString(global_token);
|
||||
<< frame_util::GetFrameDebugString(global_token)
|
||||
<< " (has_rfh=" << has_rfh << ")";
|
||||
|
||||
CancelNewBrowserInfoResponse(pending_info.get());
|
||||
g_info_manager->pending_new_browser_info_map_.erase(it);
|
||||
|
@@ -58,6 +58,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(
|
||||
bool is_popup,
|
||||
bool is_windowless,
|
||||
bool print_preview_enabled,
|
||||
CefRefPtr<CefDictionaryValue> extra_info);
|
||||
|
||||
// Called from WebContentsDelegate::WebContentsCreated when a new browser is
|
||||
@@ -67,6 +68,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
scoped_refptr<CefBrowserInfo> CreatePopupBrowserInfo(
|
||||
content::WebContents* new_contents,
|
||||
bool is_windowless,
|
||||
bool print_preview_enabled,
|
||||
CefRefPtr<CefDictionaryValue> extra_info);
|
||||
|
||||
// Called from ContentBrowserClient::CanCreateWindow. See comments on
|
||||
@@ -108,9 +110,9 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
// 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.
|
||||
// exist for explicitly created browsers. It may sometimes already exist for
|
||||
// traditional popup browsers depending on timing. See comments on
|
||||
// PendingPopup for more information.
|
||||
void OnGetNewBrowserInfo(
|
||||
const content::GlobalRenderFrameHostToken& global_token,
|
||||
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback);
|
||||
@@ -124,16 +126,11 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
|
||||
// Returns the CefBrowserInfo matching the specified ID/token or nullptr if no
|
||||
// match is found. It is allowed to add new callers of this method but
|
||||
// consider using CefBrowserHostBase::GetBrowserForGlobalId/Token() or
|
||||
// extensions::GetOwnerBrowserForGlobalId() instead. If |is_guest_view| is
|
||||
// non-nullptr it will be set to true if the ID/token matches a guest view
|
||||
// associated with the returned browser info instead of the browser itself.
|
||||
// consider using CefBrowserHostBase::GetBrowserForGlobalId/Token() instead.
|
||||
scoped_refptr<CefBrowserInfo> GetBrowserInfo(
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool* is_guest_view = nullptr);
|
||||
const content::GlobalRenderFrameHostId& global_id);
|
||||
scoped_refptr<CefBrowserInfo> GetBrowserInfo(
|
||||
const content::GlobalRenderFrameHostToken& global_token,
|
||||
bool* is_guest_view = nullptr);
|
||||
const content::GlobalRenderFrameHostToken& global_token);
|
||||
|
||||
// Returns all existing CefBrowserInfo objects.
|
||||
using BrowserInfoList = std::list<scoped_refptr<CefBrowserInfo>>;
|
||||
@@ -149,6 +146,18 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
static bool ShouldCreateViewsHostedPopup(CefRefPtr<CefBrowserHostBase> opener,
|
||||
bool use_default_browser_creation);
|
||||
|
||||
// Returns the FrameHost associated with |rfh|, if any. |browser_info| and
|
||||
// |is_excluded| will be populated if non-nullptr. An excluded type will not
|
||||
// have a FrameHost but |browser_info| may still be populated if the
|
||||
// association is known.
|
||||
static CefRefPtr<CefFrameHostImpl> GetFrameHost(content::RenderFrameHost* rfh,
|
||||
bool prefer_speculative,
|
||||
CefBrowserInfo** browser_info,
|
||||
bool* is_excluded);
|
||||
|
||||
// Returns true if |rfh| should be excluded (no FrameHost created).
|
||||
static bool IsExcludedFrameHost(content::RenderFrameHost* rfh);
|
||||
|
||||
private:
|
||||
// RenderProcessHostObserver methods:
|
||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
@@ -157,7 +166,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
// - CanCreateWindow (UIT):
|
||||
// Provides an opportunity to cancel the popup (calls OnBeforePopup) and
|
||||
// creates the new platform delegate for the popup. If the popup owner is
|
||||
// an extension guest view then the popup is canceled and
|
||||
// an extension guest view (PDF viewer) then the popup is canceled and
|
||||
// WebContentsDelegate::OpenURLFromTab is called via the
|
||||
// CefBrowserHostBase::MaybeAllowNavigation implementation.
|
||||
// And then the following calls may occur at the same time:
|
||||
@@ -179,6 +188,9 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
WEB_CONTENTS_CREATED,
|
||||
} step;
|
||||
|
||||
// True if this popup is Alloy style, otherwise Chrome style.
|
||||
bool alloy_style;
|
||||
|
||||
// Initial state from ViewHostMsg_CreateWindow.
|
||||
// |target_url| will be empty if a popup is created via window.open() and
|
||||
// never navigated. For example: javascript:window.open();
|
||||
@@ -195,7 +207,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate;
|
||||
|
||||
// True if default Browser or tab creation should proceed from
|
||||
// AddWebContents (chrome runtime only).
|
||||
// AddWebContents (Chrome style only).
|
||||
bool use_default_browser_creation = false;
|
||||
|
||||
// The newly created WebContents (set in WebContentsCreated).
|
||||
@@ -207,27 +219,36 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
|
||||
// Used after CanCreateWindow is called.
|
||||
std::unique_ptr<PendingPopup> PopPendingPopup(
|
||||
PendingPopup::Step previous_step,
|
||||
PendingPopup::Step previous_step_alloy,
|
||||
PendingPopup::Step previous_step_chrome,
|
||||
const content::GlobalRenderFrameHostId& opener_global_id,
|
||||
const GURL& target_url);
|
||||
|
||||
// Used after WebContentsCreated is called.
|
||||
std::unique_ptr<PendingPopup> PopPendingPopup(
|
||||
PendingPopup::Step previous_step,
|
||||
PendingPopup::Step previous_step_alloy,
|
||||
PendingPopup::Step previous_step_chrome,
|
||||
content::WebContents* new_contents);
|
||||
|
||||
// Retrieves the BrowserInfo matching the specified ID/token.
|
||||
scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal(
|
||||
const content::GlobalRenderFrameHostId& global_id,
|
||||
bool* is_guest_view);
|
||||
const content::GlobalRenderFrameHostId& global_id);
|
||||
scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal(
|
||||
const content::GlobalRenderFrameHostToken& global_token);
|
||||
|
||||
// Check for excluded frames that can be responded to immediately.
|
||||
static void CheckExcludedNewBrowserInfoOnUIThread(
|
||||
const content::GlobalRenderFrameHostToken& global_token);
|
||||
|
||||
void ContinueNewBrowserInfo(
|
||||
const content::GlobalRenderFrameHostToken& global_token,
|
||||
bool* is_guest_view);
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
bool is_excluded);
|
||||
|
||||
// Send the response for a pending OnGetNewBrowserInfo request.
|
||||
static void SendNewBrowserInfoResponse(
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
bool is_guest_view,
|
||||
bool is_excluded,
|
||||
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
|
||||
scoped_refptr<base::SequencedTaskRunner> callback_runner);
|
||||
|
||||
|
@@ -4,12 +4,21 @@
|
||||
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "include/views/cef_window.h"
|
||||
#include "include/views/cef_window_delegate.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/browser/views/browser_view_impl.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/logging.h"
|
||||
#include "chrome/browser/platform_util.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/shell_integration.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
@@ -28,6 +37,39 @@ void ExecuteExternalProtocol(const GURL& url) {
|
||||
CEF_POST_TASK(TID_UI, base::BindOnce(&platform_util::OpenExternal, url));
|
||||
}
|
||||
|
||||
// Default popup window delegate implementation.
|
||||
class PopupWindowDelegate : public CefWindowDelegate {
|
||||
public:
|
||||
explicit PopupWindowDelegate(CefRefPtr<CefBrowserView> browser_view)
|
||||
: browser_view_(browser_view) {}
|
||||
|
||||
PopupWindowDelegate(const PopupWindowDelegate&) = delete;
|
||||
PopupWindowDelegate& operator=(const PopupWindowDelegate&) = delete;
|
||||
|
||||
void OnWindowCreated(CefRefPtr<CefWindow> window) override {
|
||||
window->AddChildView(browser_view_);
|
||||
window->Show();
|
||||
browser_view_->RequestFocus();
|
||||
}
|
||||
|
||||
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override {
|
||||
browser_view_ = nullptr;
|
||||
}
|
||||
|
||||
bool CanClose(CefRefPtr<CefWindow> window) override {
|
||||
CefRefPtr<CefBrowser> browser = browser_view_->GetBrowser();
|
||||
if (browser) {
|
||||
return browser->GetHost()->TryCloseBrowser();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
CefRefPtr<CefBrowserView> browser_view_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(PopupWindowDelegate);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() = default;
|
||||
@@ -147,10 +189,14 @@ views::Widget* CefBrowserPlatformDelegate::GetWindowWidget() const {
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserView> CefBrowserPlatformDelegate::GetBrowserView() const {
|
||||
DCHECK(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::SetBrowserView(
|
||||
CefRefPtr<CefBrowserView> browser_view) {
|
||||
DCHECK(false);
|
||||
}
|
||||
|
||||
web_modal::WebContentsModalDialogHost*
|
||||
CefBrowserPlatformDelegate::GetWebContentsModalDialogHost() const {
|
||||
DCHECK(false);
|
||||
@@ -162,11 +208,79 @@ void CefBrowserPlatformDelegate::PopupWebContentsCreated(
|
||||
CefRefPtr<CefClient> client,
|
||||
content::WebContents* new_web_contents,
|
||||
CefBrowserPlatformDelegate* new_platform_delegate,
|
||||
bool is_devtools) {}
|
||||
bool is_devtools) {
|
||||
// Default popup handling may not be Views-hosted.
|
||||
if (!new_platform_delegate->IsViewsHosted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserViewDelegate> new_delegate;
|
||||
|
||||
CefRefPtr<CefBrowserViewDelegate> opener_delegate;
|
||||
auto browser_view = GetBrowserView();
|
||||
if (browser_view) {
|
||||
// When |this| (the popup opener) is Views-hosted use the current delegate.
|
||||
opener_delegate =
|
||||
static_cast<CefBrowserViewImpl*>(browser_view.get())->delegate();
|
||||
}
|
||||
if (!opener_delegate) {
|
||||
opener_delegate =
|
||||
new_platform_delegate->GetDefaultBrowserViewDelegateForPopupOpener();
|
||||
}
|
||||
if (opener_delegate) {
|
||||
new_delegate = opener_delegate->GetDelegateForPopupBrowserView(
|
||||
browser_view, settings, client, is_devtools);
|
||||
}
|
||||
|
||||
// Create a new BrowserView for the popup.
|
||||
CefRefPtr<CefBrowserViewImpl> new_browser_view =
|
||||
CefBrowserViewImpl::CreateForPopup(settings, new_delegate, is_devtools);
|
||||
|
||||
// Associate the PlatformDelegate with the new BrowserView.
|
||||
new_platform_delegate->SetBrowserView(new_browser_view);
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::PopupBrowserCreated(
|
||||
CefBrowserPlatformDelegate* new_platform_delegate,
|
||||
CefBrowserHostBase* new_browser,
|
||||
bool is_devtools) {}
|
||||
bool is_devtools) {
|
||||
// Default popup handling may not be Views-hosted.
|
||||
if (!new_platform_delegate->IsViewsHosted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserView> new_browser_view =
|
||||
CefBrowserView::GetForBrowser(new_browser);
|
||||
CHECK(new_browser_view);
|
||||
|
||||
bool popup_handled = false;
|
||||
|
||||
CefRefPtr<CefBrowserViewDelegate> opener_delegate;
|
||||
auto browser_view = GetBrowserView();
|
||||
if (browser_view) {
|
||||
// When |this| (the popup opener) is Views-hosted use the current delegate.
|
||||
opener_delegate =
|
||||
static_cast<CefBrowserViewImpl*>(browser_view.get())->delegate();
|
||||
}
|
||||
if (!opener_delegate) {
|
||||
opener_delegate =
|
||||
new_platform_delegate->GetDefaultBrowserViewDelegateForPopupOpener();
|
||||
}
|
||||
if (opener_delegate) {
|
||||
popup_handled = opener_delegate->OnPopupBrowserViewCreated(
|
||||
browser_view, new_browser_view.get(), is_devtools);
|
||||
}
|
||||
|
||||
if (!popup_handled) {
|
||||
CefWindow::CreateTopLevelWindow(
|
||||
new PopupWindowDelegate(new_browser_view.get()));
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserViewDelegate>
|
||||
CefBrowserPlatformDelegate::GetDefaultBrowserViewDelegateForPopupOpener() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkColor CefBrowserPlatformDelegate::GetBackgroundColor() const {
|
||||
DCHECK(false);
|
||||
@@ -434,6 +548,34 @@ void CefBrowserPlatformDelegate::SetAccessibilityState(
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegate::IsPrintPreviewSupported() const {
|
||||
if (IsWindowless()) {
|
||||
// Not supported with windowless rendering.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (web_contents_) {
|
||||
auto cef_browser_context = CefBrowserContext::FromBrowserContext(
|
||||
web_contents_->GetBrowserContext());
|
||||
if (cef_browser_context->AsProfile()->GetPrefs()->GetBoolean(
|
||||
prefs::kPrintPreviewDisabled)) {
|
||||
// Disabled on the Profile.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kDisablePrintPreview)) {
|
||||
// Disabled explicitly via the command-line.
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool default_disabled = IsAlloyStyle();
|
||||
if (default_disabled &&
|
||||
!command_line->HasSwitch(switches::kEnablePrintPreview)) {
|
||||
// Default disabled and not enabled explicitly via the command-line.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -88,7 +88,7 @@ class CefBrowserPlatformDelegate {
|
||||
static std::unique_ptr<CefBrowserPlatformDelegate> Create(
|
||||
const CefBrowserCreateParams& create_params);
|
||||
|
||||
// Called from AlloyBrowserHostImpl::Create.
|
||||
// Called from BrowserHost::Create.
|
||||
// Wait for the call to WebContentsCreated(owned=true) before taking ownership
|
||||
// of the resulting WebContents object.
|
||||
virtual content::WebContents* CreateWebContents(
|
||||
@@ -136,12 +136,12 @@ class CefBrowserPlatformDelegate {
|
||||
// See WebContentsObserver documentation.
|
||||
virtual void RenderViewReady();
|
||||
|
||||
// Called after the owning AlloyBrowserHostImpl is created. Will only be
|
||||
// Called after the owning BrowserHost is created. Will only be
|
||||
// called a single time per instance. Do not send any client notifications
|
||||
// from this method.
|
||||
virtual void BrowserCreated(CefBrowserHostBase* browser);
|
||||
|
||||
// Called from AlloyBrowserHostImpl::Create.
|
||||
// Called from BrowserHost::Create.
|
||||
virtual void CreateExtensionHost(const extensions::Extension* extension,
|
||||
const GURL& url,
|
||||
extensions::mojom::ViewType host_type);
|
||||
@@ -157,9 +157,9 @@ class CefBrowserPlatformDelegate {
|
||||
// BrowserDestroyed().
|
||||
virtual void NotifyBrowserDestroyed();
|
||||
|
||||
// Called before the owning AlloyBrowserHostImpl is destroyed. Will only be
|
||||
// Called before the owning BrowserHost is destroyed. Will only be
|
||||
// called a single time per instance. All references to the
|
||||
// AlloyBrowserHostImpl and WebContents should be cleared when this method is
|
||||
// BrowserHost and WebContents should be cleared when this method is
|
||||
// called. Do not send any client notifications from this method.
|
||||
virtual void BrowserDestroyed(CefBrowserHostBase* browser);
|
||||
|
||||
@@ -182,35 +182,48 @@ class CefBrowserPlatformDelegate {
|
||||
// rendering.
|
||||
virtual views::Widget* GetWindowWidget() const;
|
||||
|
||||
// Returns the BrowserView associated with this browser. Only used with views-
|
||||
// Returns the BrowserView associated with this browser. Only used with Views-
|
||||
// based browsers.
|
||||
virtual CefRefPtr<CefBrowserView> GetBrowserView() const;
|
||||
|
||||
// Sets the BrowserView associated with this browser. Only used with
|
||||
// Views-based browsers.
|
||||
virtual void SetBrowserView(CefRefPtr<CefBrowserView> browser_view);
|
||||
|
||||
// Returns the WebContentsModalDialogHost associated with this browser.
|
||||
virtual web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
|
||||
const;
|
||||
|
||||
// Called after the WebContents have been created for a new popup browser
|
||||
// parented to this browser but before the AlloyBrowserHostImpl is created for
|
||||
// the popup. |is_devtools| will be true if the popup will host DevTools. This
|
||||
// parented to this browser but before the BrowserHost is created for the
|
||||
// popup. |is_devtools| will be true if the popup will host DevTools. This
|
||||
// method will be called before WebContentsCreated() is called on
|
||||
// |new_platform_delegate|. Do not make the new browser visible in this
|
||||
// |new_platform_delegate|. Does not make the new browser visible in this
|
||||
// callback.
|
||||
virtual void PopupWebContentsCreated(
|
||||
void PopupWebContentsCreated(
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
content::WebContents* new_web_contents,
|
||||
CefBrowserPlatformDelegate* new_platform_delegate,
|
||||
bool is_devtools);
|
||||
|
||||
// Called after the AlloyBrowserHostImpl is created for a new popup browser
|
||||
// parented to this browser. |is_devtools| will be true if the popup will host
|
||||
// DevTools. This method will be called immediately after
|
||||
// Called after the BrowserHost is created for a new popup browser parented to
|
||||
// this browser. |is_devtools| will be true if the popup will host DevTools.
|
||||
// This method will be called immediately after
|
||||
// CefLifeSpanHandler::OnAfterCreated() for the popup browser. It is safe to
|
||||
// make the new browser visible in this callback (for example, add the browser
|
||||
// to a window and show it).
|
||||
virtual void PopupBrowserCreated(CefBrowserHostBase* new_browser,
|
||||
bool is_devtools);
|
||||
void PopupBrowserCreated(CefBrowserPlatformDelegate* new_platform_delegate,
|
||||
CefBrowserHostBase* new_browser,
|
||||
bool is_devtools);
|
||||
|
||||
// Called from PopupWebContentsCreated/PopupBrowserCreated to retrieve the
|
||||
// default BrowserViewDelegate in cases where this is a new Views-based popup
|
||||
// and the opener is either not Views-based or doesn't implement the
|
||||
// BrowserViewDelegate. Only implemented for specific configurations where
|
||||
// special handling of new popups is required for proper functioning.
|
||||
virtual CefRefPtr<CefBrowserViewDelegate>
|
||||
GetDefaultBrowserViewDelegateForPopupOpener();
|
||||
|
||||
// Returns the background color for the browser. The alpha component will be
|
||||
// either SK_AlphaTRANSPARENT or SK_AlphaOPAQUE (e.g. fully transparent or
|
||||
@@ -294,6 +307,11 @@ class CefBrowserPlatformDelegate {
|
||||
// be called on multiple threads.
|
||||
virtual bool IsViewsHosted() const;
|
||||
|
||||
// Returns the runtime style implemented by this delegate. May be called on
|
||||
// multiple threads.
|
||||
virtual bool IsAlloyStyle() const = 0;
|
||||
bool IsChromeStyle() const { return !IsAlloyStyle(); }
|
||||
|
||||
// Returns true if this delegate implements a browser with external
|
||||
// (client-provided) parent window. May be called on multiple threads.
|
||||
virtual bool HasExternalParent() const;
|
||||
|
@@ -18,7 +18,6 @@
|
||||
#include "libcef/browser/chrome/views/chrome_child_window.h"
|
||||
#include "libcef/browser/extensions/browser_platform_delegate_background.h"
|
||||
#include "libcef/browser/views/browser_platform_delegate_views.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "libcef/browser/native/browser_platform_delegate_native_win.h"
|
||||
@@ -59,10 +58,10 @@ std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
|
||||
std::move(native_delegate), use_shared_texture, use_external_begin_frame);
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
return std::make_unique<CefBrowserPlatformDelegateOsrMac>(
|
||||
std::move(native_delegate));
|
||||
std::move(native_delegate), use_shared_texture, use_external_begin_frame);
|
||||
#elif BUILDFLAG(IS_LINUX)
|
||||
return std::make_unique<CefBrowserPlatformDelegateOsrLinux>(
|
||||
std::move(native_delegate), use_external_begin_frame);
|
||||
std::move(native_delegate), use_shared_texture, use_external_begin_frame);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -71,14 +70,11 @@ std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
|
||||
// static
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
||||
const CefBrowserCreateParams& create_params) {
|
||||
const bool is_windowless =
|
||||
create_params.window_info &&
|
||||
create_params.window_info->windowless_rendering_enabled &&
|
||||
create_params.client && create_params.client->GetRenderHandler().get();
|
||||
const bool is_windowless = create_params.IsWindowless();
|
||||
const SkColor background_color = CefContext::Get()->GetBackgroundColor(
|
||||
&create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED);
|
||||
|
||||
if (cef::IsChromeRuntimeEnabled()) {
|
||||
if (create_params.IsChromeStyle()) {
|
||||
CefWindowInfo window_info;
|
||||
if (create_params.window_info) {
|
||||
window_info = *create_params.window_info;
|
||||
@@ -124,8 +120,6 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
||||
CreateNativeDelegate(*create_params.window_info, background_color);
|
||||
if (is_windowless) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
|
||||
const bool use_shared_texture =
|
||||
create_params.window_info->shared_texture_enabled;
|
||||
|
||||
|
@@ -12,12 +12,17 @@
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "chrome/browser/ui/page_action/page_action_icon_type.h"
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "third_party/blink/public/mojom/page/draggable_region.mojom-forward.h"
|
||||
#include "third_party/skia/include/core/SkRegion.h"
|
||||
#include "ui/base/window_open_disposition.h"
|
||||
|
||||
class Browser;
|
||||
class Profile;
|
||||
|
||||
namespace content {
|
||||
class NavigationHandle;
|
||||
}
|
||||
|
||||
namespace cef {
|
||||
|
||||
// Delegate for the chrome Browser object. Lifespan is controlled by the Browser
|
||||
@@ -39,15 +44,16 @@ class BrowserDelegate : public content::WebContentsDelegate {
|
||||
scoped_refptr<CreateParams> cef_params,
|
||||
const Browser* opener);
|
||||
|
||||
~BrowserDelegate() override = default;
|
||||
|
||||
// Optionally override Browser creation in
|
||||
// DevToolsWindow::CreateDevToolsBrowser. The returned Browser, if any, will
|
||||
// take ownership of |devtools_contents|.
|
||||
virtual Browser* CreateDevToolsBrowser(
|
||||
static Browser* CreateDevToolsBrowser(
|
||||
Profile* profile,
|
||||
Browser* opener,
|
||||
std::unique_ptr<content::WebContents>& devtools_contents) = 0;
|
||||
content::WebContents* inspected_web_contents,
|
||||
std::unique_ptr<content::WebContents>& devtools_contents);
|
||||
|
||||
~BrowserDelegate() override = default;
|
||||
|
||||
// Optionally override chrome::AddWebContents behavior. This is most often
|
||||
// called via Browser::AddNewContents for new popup browsers and provides an
|
||||
@@ -150,16 +156,22 @@ class BrowserDelegate : public content::WebContentsDelegate {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Set the draggable region relative to web contents.
|
||||
// Called from DraggableRegionsHostImpl::UpdateDraggableRegions.
|
||||
virtual void UpdateDraggableRegion(const SkRegion& region) {}
|
||||
|
||||
// Called at the end of a fullscreen transition.
|
||||
virtual void WindowFullscreenStateChanged() {}
|
||||
|
||||
// Returns true if this browser has a Views-hosted opener. Only
|
||||
// applicable for Browsers of type picture_in_picture and devtools.
|
||||
virtual bool HasViewsHostedOpener() const { return false; }
|
||||
|
||||
// Same as OpenURLFromTab but only taking |navigation_handle_callback|
|
||||
// if the return value is non-nullptr.
|
||||
virtual content::WebContents* OpenURLFromTabEx(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params,
|
||||
base::OnceCallback<void(content::NavigationHandle&)>&
|
||||
navigation_handle_callback) {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace cef
|
||||
|
@@ -119,11 +119,6 @@ CefEventHandle CefBrowserPlatformDelegateChrome::GetEventHandle(
|
||||
return native_delegate_->GetEventHandle(event);
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegateChrome::IsPrintPreviewSupported() const {
|
||||
return chrome_browser_ && !chrome_browser_->profile()->GetPrefs()->GetBoolean(
|
||||
prefs::kPrintPreviewDisabled);
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserPlatformDelegateChrome::GetParentWindowHandle()
|
||||
const {
|
||||
return GetHostWindowHandle();
|
||||
@@ -143,6 +138,9 @@ gfx::NativeWindow CefBrowserPlatformDelegateChrome::GetNativeWindow() const {
|
||||
if (chrome_browser_ && chrome_browser_->window()) {
|
||||
return chrome_browser_->window()->GetNativeWindow();
|
||||
}
|
||||
DCHECK(false);
|
||||
if (web_contents_) {
|
||||
return web_contents_->GetTopLevelNativeWindow();
|
||||
}
|
||||
NOTIMPLEMENTED();
|
||||
return gfx::NativeWindow();
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ class CefBrowserPlatformDelegateChrome
|
||||
void ViewText(const std::string& text) override;
|
||||
CefEventHandle GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const override;
|
||||
bool IsPrintPreviewSupported() const override;
|
||||
bool IsAlloyStyle() const override { return false; }
|
||||
|
||||
// CefBrowserPlatformDelegateNative::WindowlessHandler methods:
|
||||
CefWindowHandle GetParentWindowHandle() const override;
|
||||
|
@@ -11,11 +11,13 @@
|
||||
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/history/history_service_factory.h"
|
||||
#include "chrome/browser/prefs/session_startup_pref.h"
|
||||
#include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h"
|
||||
#include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h"
|
||||
#include "chrome/browser/profiles/off_the_record_profile_impl.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "components/history/core/browser/history_service.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -139,6 +141,29 @@ void ChromeBrowserContext::Shutdown() {
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeBrowserContext::AddVisitedURLs(
|
||||
const GURL& url,
|
||||
const std::vector<GURL>& redirect_chain,
|
||||
ui::PageTransition transition) {
|
||||
auto* profile = AsProfile();
|
||||
if (profile->IsOffTheRecord()) {
|
||||
// Don't persist state.
|
||||
return;
|
||||
}
|
||||
|
||||
// Called from DidFinishNavigation by Alloy style browsers. Chrome style
|
||||
// browsers will handle this via HistoryTabHelper.
|
||||
if (auto history_service = HistoryServiceFactory::GetForProfile(
|
||||
profile, ServiceAccessType::IMPLICIT_ACCESS)) {
|
||||
history::HistoryAddPageArgs add_page_args;
|
||||
add_page_args.url = url;
|
||||
add_page_args.redirects = redirect_chain;
|
||||
add_page_args.transition = transition;
|
||||
add_page_args.time = base::Time::Now();
|
||||
history_service->AddPage(std::move(add_page_args));
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeBrowserContext::ProfileCreated(CreateStatus status,
|
||||
Profile* profile) {
|
||||
Profile* parent_profile = nullptr;
|
||||
|
@@ -34,6 +34,9 @@ class ChromeBrowserContext : public CefBrowserContext, public ProfileObserver {
|
||||
bool IsInitialized() const override;
|
||||
void StoreOrTriggerInitCallback(base::OnceClosure callback) override;
|
||||
void Shutdown() override;
|
||||
void AddVisitedURLs(const GURL& url,
|
||||
const std::vector<GURL>& redirect_chain,
|
||||
ui::PageTransition transition) override;
|
||||
|
||||
// ProfileObserver overrides.
|
||||
void OnProfileWillBeDestroyed(Profile* profile) override;
|
||||
|
@@ -2,16 +2,17 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "libcef/browser/chrome/chrome_browser_delegate.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "libcef/browser/browser_contents_delegate.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/chrome/chrome_browser_context.h"
|
||||
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
|
||||
#include "libcef/browser/chrome/chrome_devtools_window_runner.h"
|
||||
#include "libcef/browser/chrome/views/chrome_browser_view.h"
|
||||
#include "libcef/browser/chrome/views/chrome_child_window.h"
|
||||
#include "libcef/browser/hang_monitor.h"
|
||||
@@ -21,12 +22,14 @@
|
||||
#include "libcef/browser/views/window_impl.h"
|
||||
#include "libcef/common/app_manager.h"
|
||||
#include "libcef/common/frame_util.h"
|
||||
#include "third_party/blink/public/mojom/page/draggable_region.mojom.h"
|
||||
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_tabstrip.h"
|
||||
#include "content/public/browser/global_routing_id.h"
|
||||
#include "content/public/browser/keyboard_event_processing_result.h"
|
||||
#include "content/public/browser/navigation_handle.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "content/public/common/input/native_web_keyboard_event.h"
|
||||
@@ -53,23 +56,35 @@ ChromeBrowserDelegate::ChromeBrowserDelegate(
|
||||
|
||||
ChromeBrowserDelegate::~ChromeBrowserDelegate() = default;
|
||||
|
||||
// static
|
||||
Browser* ChromeBrowserDelegate::CreateDevToolsBrowser(
|
||||
Profile* profile,
|
||||
Browser* opener,
|
||||
content::WebContents* inspected_web_contents,
|
||||
std::unique_ptr<content::WebContents>& devtools_contents) {
|
||||
// |opener| is the same value that will be passed to the ChromeBrowserDelegate
|
||||
// constructor for the new popup Browser. It may be nullptr in certain rare
|
||||
// constructor for the new popup Browser. It may be nullptr in certain
|
||||
// situations (e.g. if DevTools is launched for a WebContents that is not a
|
||||
// Browser Tab). In that case, the popup browser host will instead be created
|
||||
// via SetAsDelegate.
|
||||
auto opener_browser_host =
|
||||
// Browser Tab).
|
||||
CefRefPtr<CefBrowserHostBase> opener_browser_host =
|
||||
opener ? ChromeBrowserHostImpl::GetBrowserForBrowser(opener) : nullptr;
|
||||
if (!opener_browser_host) {
|
||||
return nullptr;
|
||||
// |inspected_web_contents| may be an Alloy style browser.
|
||||
opener_browser_host =
|
||||
CefBrowserHostBase::GetBrowserForContents(inspected_web_contents);
|
||||
if (!opener_browser_host) {
|
||||
// The popup browser host will instead be created via SetAsDelegate.
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// We expect openers and popups to have the same Profile.
|
||||
CHECK_EQ(opener->profile(), profile);
|
||||
CHECK_EQ(
|
||||
CefRequestContextImpl::GetProfile(opener_browser_host->request_context()),
|
||||
profile);
|
||||
if (opener) {
|
||||
CHECK_EQ(opener->profile(), profile);
|
||||
}
|
||||
|
||||
//
|
||||
// 1. Get configuration settings from the user and create the new platform
|
||||
@@ -84,25 +99,26 @@ Browser* ChromeBrowserDelegate::CreateDevToolsBrowser(
|
||||
CefBrowserCreateParams create_params;
|
||||
CefWindowInfo window_info;
|
||||
|
||||
auto* devtools_window_runner = static_cast<ChromeDevToolsWindowRunner*>(
|
||||
opener_browser_host->GetDevToolsWindowRunner());
|
||||
auto pending_show_devtools_params =
|
||||
devtools_window_runner->TakePendingParams();
|
||||
|
||||
// If |client| is empty, or if the user clears |client| in
|
||||
// OnBeforeDevToolsPopup, we'll use the result of GetDefaultClient() later on
|
||||
// in CreateBrowserHost().
|
||||
if (pending_show_devtools_params_) {
|
||||
if (pending_show_devtools_params) {
|
||||
// Start with the params passed to CefBrowserHost::ShowDevTools().
|
||||
create_params.client = pending_show_devtools_params_->client_;
|
||||
create_params.settings = pending_show_devtools_params_->settings_;
|
||||
window_info = pending_show_devtools_params_->window_info_;
|
||||
|
||||
// Pending params are only used a single time.
|
||||
pending_show_devtools_params_.reset();
|
||||
create_params.client = pending_show_devtools_params->client_;
|
||||
create_params.settings = pending_show_devtools_params->settings_;
|
||||
window_info = pending_show_devtools_params->window_info_;
|
||||
} else {
|
||||
// Start with the same client and settings as the opener.
|
||||
create_params.client = opener_client;
|
||||
create_params.settings = opener_browser_host->settings();
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
window_info.SetAsPopup(nullptr, CefString());
|
||||
#endif
|
||||
CefBrowserCreateParams::InitWindowInfo(&window_info,
|
||||
opener_browser_host.get());
|
||||
}
|
||||
|
||||
// Start with the same extra info as the opener, for consistency with
|
||||
@@ -121,10 +137,14 @@ Browser* ChromeBrowserDelegate::CreateDevToolsBrowser(
|
||||
create_params.settings, create_params.extra_info, &use_default_window);
|
||||
}
|
||||
|
||||
if (opener_browser_host->platform_delegate()->HasExternalParent()) {
|
||||
if (window_info.windowless_rendering_enabled) {
|
||||
LOG(ERROR)
|
||||
<< "Windowless rendering is not supported for this DevTools window";
|
||||
} else if (opener_browser_host->platform_delegate()->HasExternalParent()) {
|
||||
// A parent window handle for DevTools creation is only supported if the
|
||||
// opener also has an external parent.
|
||||
create_params.MaybeSetWindowInfo(window_info);
|
||||
create_params.MaybeSetWindowInfo(window_info, /*allow_alloy_style=*/false,
|
||||
/*allow_chrome_style=*/true);
|
||||
} else if (chrome_child_window::HasParentHandle(window_info)) {
|
||||
LOG(ERROR) << "Parent window handle not supported for this DevTools window";
|
||||
}
|
||||
@@ -132,20 +152,24 @@ Browser* ChromeBrowserDelegate::CreateDevToolsBrowser(
|
||||
create_params.popup_with_views_hosted_opener =
|
||||
CefBrowserInfoManager::ShouldCreateViewsHostedPopup(opener_browser_host,
|
||||
use_default_window);
|
||||
create_params.popup_with_alloy_style_opener = false;
|
||||
|
||||
auto platform_delegate = CefBrowserPlatformDelegate::Create(create_params);
|
||||
CHECK(platform_delegate);
|
||||
|
||||
// Expect runtime style to match.
|
||||
CHECK(platform_delegate->IsChromeStyle());
|
||||
|
||||
//
|
||||
// 2. Create the new browser host. Logical equivalent of WebContentsCreated()
|
||||
// for normal popups.
|
||||
// 2. Create the new browser host. Logical equivalent of
|
||||
// WebContentsCreated() for normal popups.
|
||||
//
|
||||
|
||||
// Create a new browser host that remains alive until the associated
|
||||
// WebContents is destroyed. Associate that browser host with the WebContents
|
||||
// and execute initial client callbacks. Deliver required information to the
|
||||
// renderer process.
|
||||
auto browser_host = CreateBrowserHostForPopup(
|
||||
// WebContents is destroyed. Associate that browser host with the
|
||||
// WebContents and execute initial client callbacks. Deliver required
|
||||
// information to the renderer process.
|
||||
auto browser_host = ChromeBrowserDelegate::CreateBrowserHostForPopup(
|
||||
devtools_contents.get(), create_params.settings, create_params.client,
|
||||
create_params.extra_info, std::move(platform_delegate),
|
||||
/*is_devtools_popup=*/true, opener_browser_host);
|
||||
@@ -169,10 +193,10 @@ Browser* ChromeBrowserDelegate::CreateDevToolsBrowser(
|
||||
std::move(chrome_params));
|
||||
|
||||
// Give the opener browser a reference to the new DevTools browser. Do this
|
||||
// last because don't want the client to attempt access to the DevTools
|
||||
// browser via opener browser methods (e.g. ShowDevTools, CloseDevTools, etc)
|
||||
// while creation is still in progress.
|
||||
opener_browser_host->SetDevToolsBrowserHost(browser_host->GetWeakPtr());
|
||||
// last because we don't want the client to attempt access to the DevTools
|
||||
// browser via opener browser methods (e.g. ShowDevTools, CloseDevTools,
|
||||
// etc) while creation is still in progress.
|
||||
devtools_window_runner->SetDevToolsBrowserHost(browser_host->GetWeakPtr());
|
||||
|
||||
auto browser = browser_host->browser();
|
||||
CHECK(browser);
|
||||
@@ -203,7 +227,8 @@ std::unique_ptr<content::WebContents> ChromeBrowserDelegate::AddWebContents(
|
||||
void ChromeBrowserDelegate::OnWebContentsCreated(
|
||||
content::WebContents* new_contents) {
|
||||
// Necessary to receive LoadingStateChanged calls during initial navigation.
|
||||
// This will be called again in Browser::SetAsDelegate, which should be fine.
|
||||
// This will be called again in Browser::SetAsDelegate, which should be
|
||||
// fine.
|
||||
new_contents->SetDelegate(browser_);
|
||||
|
||||
SetAsDelegate(new_contents, /*set_delegate=*/true);
|
||||
@@ -233,14 +258,18 @@ void ChromeBrowserDelegate::SetAsDelegate(content::WebContents* web_contents,
|
||||
auto platform_delegate = CefBrowserPlatformDelegate::Create(create_params_);
|
||||
CHECK(platform_delegate);
|
||||
|
||||
// Expect runtime style to match.
|
||||
CHECK(platform_delegate->IsChromeStyle());
|
||||
|
||||
auto browser_info = CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
|
||||
is_devtools_popup, /*is_windowless=*/false, create_params_.extra_info);
|
||||
is_devtools_popup, /*is_windowless=*/false,
|
||||
platform_delegate->IsPrintPreviewSupported(), create_params_.extra_info);
|
||||
|
||||
auto request_context_impl =
|
||||
CefRequestContextImpl::GetOrCreateForRequestContext(
|
||||
create_params_.request_context);
|
||||
|
||||
CreateBrowserHost(web_contents, create_params_.settings,
|
||||
CreateBrowserHost(browser_, web_contents, create_params_.settings,
|
||||
create_params_.client, std::move(platform_delegate),
|
||||
browser_info, is_devtools_popup, /*opener=*/nullptr,
|
||||
request_context_impl);
|
||||
@@ -427,9 +456,23 @@ const std::optional<SkRegion> ChromeBrowserDelegate::GetDraggableRegion()
|
||||
return draggable_region_;
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::UpdateDraggableRegion(const SkRegion& region) {
|
||||
DCHECK(SupportsDraggableRegion());
|
||||
draggable_region_ = region;
|
||||
void ChromeBrowserDelegate::DraggableRegionsChanged(
|
||||
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
|
||||
content::WebContents* contents) {
|
||||
if (SupportsDraggableRegion()) {
|
||||
SkRegion sk_region;
|
||||
for (const auto& region : regions) {
|
||||
sk_region.op(
|
||||
SkIRect::MakeLTRB(region->bounds.x(), region->bounds.y(),
|
||||
region->bounds.x() + region->bounds.width(),
|
||||
region->bounds.y() + region->bounds.height()),
|
||||
region->draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
|
||||
}
|
||||
|
||||
draggable_region_ = sk_region;
|
||||
} else if (auto delegate = GetDelegateForWebContents(contents)) {
|
||||
delegate->DraggableRegionsChanged(regions, contents);
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::WindowFullscreenStateChanged() {
|
||||
@@ -477,17 +520,19 @@ void ChromeBrowserDelegate::WebContentsCreated(
|
||||
}
|
||||
|
||||
// Create a new browser host that remains alive until the associated
|
||||
// WebContents is destroyed. Associate that browser host with the WebContents
|
||||
// and execute initial client callbacks. Deliver required information to the
|
||||
// renderer process.
|
||||
// WebContents is destroyed. Associate that browser host with the
|
||||
// WebContents and execute initial client callbacks. Deliver required
|
||||
// information to the renderer process.
|
||||
CreateBrowserHostForPopup(new_contents, settings, client, extra_info,
|
||||
std::move(platform_delegate),
|
||||
/*is_devtools_popup=*/false, opener);
|
||||
}
|
||||
|
||||
content::WebContents* ChromeBrowserDelegate::OpenURLFromTab(
|
||||
content::WebContents* ChromeBrowserDelegate::OpenURLFromTabEx(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) {
|
||||
const content::OpenURLParams& params,
|
||||
base::OnceCallback<void(content::NavigationHandle&)>&
|
||||
navigation_handle_callback) {
|
||||
// |source| may be nullptr when opening a link from chrome UI such as the
|
||||
// Reading List sidebar. In that case we default to using the Browser's
|
||||
// currently active WebContents.
|
||||
@@ -499,7 +544,8 @@ content::WebContents* ChromeBrowserDelegate::OpenURLFromTab(
|
||||
// Return nullptr to cancel the navigation. Otherwise, proceed with default
|
||||
// chrome handling.
|
||||
if (auto delegate = GetDelegateForWebContents(source)) {
|
||||
return delegate->OpenURLFromTab(source, params);
|
||||
return delegate->OpenURLFromTabEx(source, params,
|
||||
navigation_handle_callback);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -592,20 +638,16 @@ bool ChromeBrowserDelegate::HandleKeyboardEvent(
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::SetPendingShowDevToolsParams(
|
||||
std::unique_ptr<CefShowDevToolsParams> params) {
|
||||
DCHECK(!pending_show_devtools_params_);
|
||||
pending_show_devtools_params_ = std::move(params);
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserDelegate::CreateBrowserHost(
|
||||
Browser* browser,
|
||||
content::WebContents* web_contents,
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
bool is_devtools_popup,
|
||||
CefRefPtr<ChromeBrowserHostImpl> opener,
|
||||
CefRefPtr<CefBrowserHostBase> opener,
|
||||
CefRefPtr<CefRequestContextImpl> request_context_impl) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(web_contents);
|
||||
@@ -615,6 +657,7 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserDelegate::CreateBrowserHost(
|
||||
|
||||
// If |opener| is non-nullptr it must be a popup window.
|
||||
DCHECK(!opener.get() || browser_info->is_popup());
|
||||
DCHECK(browser || opener);
|
||||
|
||||
if (!client) {
|
||||
if (auto app = CefAppManager::Get()->GetApplication()) {
|
||||
@@ -628,15 +671,20 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserDelegate::CreateBrowserHost(
|
||||
LOG(WARNING) << "Creating a chrome browser without a client";
|
||||
}
|
||||
|
||||
// Get or create a ChromeBrowserContext for the browser Profile. Creation may
|
||||
// be necessary when selecting a new or incognito Profile for the first time
|
||||
// via the Chrome UI.
|
||||
auto chrome_browser_context =
|
||||
ChromeBrowserContext::GetOrCreateForProfile(browser_->profile());
|
||||
Profile* profile =
|
||||
browser ? browser->profile()
|
||||
: Profile::FromBrowserContext(web_contents->GetBrowserContext());
|
||||
|
||||
// If the provided CefRequestContext matches the ChromeBrowserContext then use
|
||||
// the provided one, as it will have the preferred CefRequestContextHandler.
|
||||
// Otherwise, get or create a CefRequestContext that matches.
|
||||
// Get or create a ChromeBrowserContext for the browser Profile. Creation
|
||||
// may be necessary when selecting a new or incognito Profile for the first
|
||||
// time via the Chrome UI.
|
||||
auto* chrome_browser_context =
|
||||
ChromeBrowserContext::GetOrCreateForProfile(profile);
|
||||
|
||||
// If the provided CefRequestContext matches the ChromeBrowserContext then
|
||||
// use the provided one, as it will have the preferred
|
||||
// CefRequestContextHandler. Otherwise, get or create a CefRequestContext
|
||||
// that matches.
|
||||
if (chrome_browser_context != request_context_impl->GetBrowserContext()) {
|
||||
CefRefPtr<CefRequestContextHandler> handler;
|
||||
if (auto app = CefAppManager::Get()->GetApplication()) {
|
||||
@@ -658,12 +706,13 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserDelegate::CreateBrowserHost(
|
||||
// The Chrome browser for a normal popup won't be created until
|
||||
// AddNewContents().
|
||||
if (!opener) {
|
||||
browser_host->SetBrowser(browser_);
|
||||
browser_host->SetBrowser(browser);
|
||||
}
|
||||
|
||||
return browser_host;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl>
|
||||
ChromeBrowserDelegate::CreateBrowserHostForPopup(
|
||||
content::WebContents* web_contents,
|
||||
@@ -672,10 +721,13 @@ ChromeBrowserDelegate::CreateBrowserHostForPopup(
|
||||
CefRefPtr<CefDictionaryValue> extra_info,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
bool is_devtools_popup,
|
||||
CefRefPtr<ChromeBrowserHostImpl> opener) {
|
||||
CefRefPtr<CefBrowserHostBase> opener) {
|
||||
DCHECK(opener);
|
||||
|
||||
auto browser_info =
|
||||
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
|
||||
web_contents, /*is_windowless=*/false, extra_info);
|
||||
web_contents, /*is_windowless=*/false,
|
||||
platform_delegate->IsPrintPreviewSupported(), extra_info);
|
||||
CHECK(browser_info->is_popup());
|
||||
|
||||
// Popups must share the same RequestContext as the parent.
|
||||
@@ -684,7 +736,7 @@ ChromeBrowserDelegate::CreateBrowserHostForPopup(
|
||||
|
||||
// We don't officially own |web_contents| until AddNewContents() is called.
|
||||
// However, we need to install observers/delegates here.
|
||||
return CreateBrowserHost(web_contents, settings, client,
|
||||
return CreateBrowserHost(/*browser=*/nullptr, web_contents, settings, client,
|
||||
std::move(platform_delegate), browser_info,
|
||||
is_devtools_popup, opener, request_context_impl);
|
||||
}
|
||||
@@ -750,4 +802,14 @@ std::unique_ptr<BrowserDelegate> BrowserDelegate::Create(
|
||||
opener);
|
||||
}
|
||||
|
||||
// static
|
||||
Browser* BrowserDelegate::CreateDevToolsBrowser(
|
||||
Profile* profile,
|
||||
Browser* opener,
|
||||
content::WebContents* inspected_web_contents,
|
||||
std::unique_ptr<content::WebContents>& devtools_contents) {
|
||||
return ChromeBrowserDelegate::CreateDevToolsBrowser(
|
||||
profile, opener, inspected_web_contents, devtools_contents);
|
||||
}
|
||||
|
||||
} // namespace cef
|
||||
|
@@ -52,11 +52,13 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
||||
|
||||
~ChromeBrowserDelegate() override;
|
||||
|
||||
// cef::BrowserDelegate methods:
|
||||
Browser* CreateDevToolsBrowser(
|
||||
static Browser* CreateDevToolsBrowser(
|
||||
Profile* profile,
|
||||
Browser* opener,
|
||||
std::unique_ptr<content::WebContents>& devtools_contents) override;
|
||||
content::WebContents* inspected_web_contents,
|
||||
std::unique_ptr<content::WebContents>& devtools_contents);
|
||||
|
||||
// cef::BrowserDelegate methods:
|
||||
std::unique_ptr<content::WebContents> AddWebContents(
|
||||
std::unique_ptr<content::WebContents> new_contents) override;
|
||||
void OnWebContentsCreated(content::WebContents* new_contents) override;
|
||||
@@ -85,9 +87,13 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
||||
std::optional<bool> SupportsWindowFeature(int feature) const override;
|
||||
bool SupportsDraggableRegion() const override;
|
||||
const std::optional<SkRegion> GetDraggableRegion() const override;
|
||||
void UpdateDraggableRegion(const SkRegion& region) override;
|
||||
void WindowFullscreenStateChanged() override;
|
||||
bool HasViewsHostedOpener() const override;
|
||||
content::WebContents* OpenURLFromTabEx(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params,
|
||||
base::OnceCallback<void(content::NavigationHandle&)>&
|
||||
navigation_handle_callback) override;
|
||||
|
||||
// WebContentsDelegate methods:
|
||||
void WebContentsCreated(content::WebContents* source_contents,
|
||||
@@ -96,9 +102,6 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents) override;
|
||||
content::WebContents* OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) override;
|
||||
void LoadingStateChanged(content::WebContents* source,
|
||||
bool should_show_loading_ui) override;
|
||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||
@@ -120,31 +123,32 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
||||
bool HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
|
||||
void SetPendingShowDevToolsParams(
|
||||
std::unique_ptr<CefShowDevToolsParams> params);
|
||||
void DraggableRegionsChanged(
|
||||
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
|
||||
content::WebContents* contents) override;
|
||||
|
||||
Browser* browser() const { return browser_; }
|
||||
|
||||
private:
|
||||
CefRefPtr<ChromeBrowserHostImpl> CreateBrowserHost(
|
||||
static CefRefPtr<ChromeBrowserHostImpl> CreateBrowserHost(
|
||||
Browser* browser,
|
||||
content::WebContents* web_contents,
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
bool is_devtools_popup,
|
||||
CefRefPtr<ChromeBrowserHostImpl> opener,
|
||||
CefRefPtr<CefBrowserHostBase> opener,
|
||||
CefRefPtr<CefRequestContextImpl> request_context_impl);
|
||||
|
||||
CefRefPtr<ChromeBrowserHostImpl> CreateBrowserHostForPopup(
|
||||
static CefRefPtr<ChromeBrowserHostImpl> CreateBrowserHostForPopup(
|
||||
content::WebContents* web_contents,
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
CefRefPtr<CefDictionaryValue> extra_info,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
bool is_devtools_popup,
|
||||
CefRefPtr<ChromeBrowserHostImpl> opener);
|
||||
CefRefPtr<CefBrowserHostBase> opener);
|
||||
|
||||
CefBrowserContentsDelegate* GetDelegateForWebContents(
|
||||
content::WebContents* web_contents) const;
|
||||
@@ -166,8 +170,6 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
||||
std::optional<bool> show_status_bubble_;
|
||||
std::optional<SkRegion> draggable_region_;
|
||||
mutable std::optional<bool> frameless_pip_;
|
||||
|
||||
std::unique_ptr<CefShowDevToolsParams> pending_show_devtools_params_;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_DELEGATE_H_
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
|
||||
#include "libcef/browser/chrome/chrome_browser_delegate.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/browser/views/browser_view_impl.h"
|
||||
#include "libcef/common/net/url_util.h"
|
||||
@@ -14,7 +13,6 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/notreached.h"
|
||||
#include "chrome/browser/devtools/devtools_window.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser_commands.h"
|
||||
#include "chrome/browser/ui/browser_navigator.h"
|
||||
@@ -57,36 +55,42 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::Create(
|
||||
return browser_host;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::FromBaseChecked(
|
||||
CefRefPtr<CefBrowserHostBase> host_base) {
|
||||
if (!host_base) {
|
||||
return nullptr;
|
||||
}
|
||||
CHECK(host_base->IsChromeStyle());
|
||||
return static_cast<ChromeBrowserHostImpl*>(host_base.get());
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForHost(
|
||||
const content::RenderViewHost* host) {
|
||||
REQUIRE_CHROME_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForHost(host);
|
||||
return static_cast<ChromeBrowserHostImpl*>(browser.get());
|
||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForHost(
|
||||
const content::RenderFrameHost* host) {
|
||||
REQUIRE_CHROME_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForHost(host);
|
||||
return static_cast<ChromeBrowserHostImpl*>(browser.get());
|
||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForContents(
|
||||
const content::WebContents* contents) {
|
||||
REQUIRE_CHROME_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForContents(contents);
|
||||
return static_cast<ChromeBrowserHostImpl*>(browser.get());
|
||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForContents(contents));
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForGlobalId(
|
||||
const content::GlobalRenderFrameHostId& global_id) {
|
||||
REQUIRE_CHROME_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForGlobalId(global_id);
|
||||
return static_cast<ChromeBrowserHostImpl*>(browser.get());
|
||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForGlobalId(global_id));
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -142,7 +146,12 @@ void ChromeBrowserHostImpl::OnWebContentsDestroyed(
|
||||
// CefBrowserInfoManager::DestroyAllBrowsers().
|
||||
if (platform_delegate_) {
|
||||
platform_delegate_->WebContentsDestroyed(web_contents);
|
||||
DestroyBrowser();
|
||||
|
||||
// Destroy the browser asynchronously to allow the current call stack
|
||||
// to unwind (we may have been called via the TabStripModel owned by the
|
||||
// Browser).
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&ChromeBrowserHostImpl::DestroyBrowser, this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,73 +217,6 @@ void ChromeBrowserHostImpl::StopFinding(bool clearSelection) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::ShowDevToolsOnUIThread(
|
||||
std::unique_ptr<CefShowDevToolsParams> params) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
if (!browser_) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* web_contents = GetWebContents();
|
||||
if (!web_contents) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* profile = CefRequestContextImpl::GetProfile(request_context());
|
||||
if (!DevToolsWindow::AllowDevToolsFor(profile, web_contents)) {
|
||||
LOG(WARNING) << "DevTools is not allowed for this browser";
|
||||
return;
|
||||
}
|
||||
|
||||
auto inspect_element_at = params->inspect_element_at_;
|
||||
|
||||
if (!devtools_browser_host_) {
|
||||
// Configure parameters for ChromeBrowserDelegate::CreateDevToolsBrowser
|
||||
// which will be called indirectly to create the DevTools window.
|
||||
auto chrome_browser_delegate =
|
||||
static_cast<ChromeBrowserDelegate*>(browser_->cef_delegate());
|
||||
chrome_browser_delegate->SetPendingShowDevToolsParams(std::move(params));
|
||||
}
|
||||
|
||||
// Focus the existing DevTools window or create a new one.
|
||||
if (!inspect_element_at.IsEmpty()) {
|
||||
DevToolsWindow::InspectElement(web_contents->GetPrimaryMainFrame(),
|
||||
inspect_element_at.x, inspect_element_at.y);
|
||||
} else {
|
||||
DevToolsWindow::OpenDevToolsWindow(web_contents, profile,
|
||||
DevToolsOpenedByAction::kUnknown);
|
||||
}
|
||||
|
||||
// The DevTools browser host should now exist.
|
||||
DCHECK(devtools_browser_host_);
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::CloseDevTools() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&ChromeBrowserHostImpl::CloseDevTools, this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (devtools_browser_host_) {
|
||||
devtools_browser_host_->TryCloseBrowser();
|
||||
}
|
||||
}
|
||||
|
||||
bool ChromeBrowserHostImpl::HasDevTools() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
DCHECK(false) << "called on invalid thread";
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!devtools_browser_host_;
|
||||
}
|
||||
|
||||
bool ChromeBrowserHostImpl::IsWindowRenderingDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::WasResized() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
@@ -537,13 +479,13 @@ Browser* ChromeBrowserHostImpl::CreateBrowser(
|
||||
|
||||
void ChromeBrowserHostImpl::Attach(content::WebContents* web_contents,
|
||||
bool is_devtools_popup,
|
||||
CefRefPtr<ChromeBrowserHostImpl> opener) {
|
||||
CefRefPtr<CefBrowserHostBase> opener) {
|
||||
DCHECK(web_contents);
|
||||
|
||||
if (opener) {
|
||||
// Give the opener browser's platform delegate an opportunity to modify the
|
||||
// new browser's platform delegate.
|
||||
opener->platform_delegate_->PopupWebContentsCreated(
|
||||
opener->platform_delegate()->PopupWebContentsCreated(
|
||||
settings_, client_, web_contents, platform_delegate_.get(),
|
||||
is_devtools_popup);
|
||||
}
|
||||
@@ -569,7 +511,8 @@ void ChromeBrowserHostImpl::Attach(content::WebContents* web_contents,
|
||||
// CefBrowserHost::GetWindowHandle() will return kNullWindowHandle in
|
||||
// OnAfterCreated(), which breaks client expectations (e.g. clients expect
|
||||
// everything about the browser to be valid at that time).
|
||||
opener->platform_delegate_->PopupBrowserCreated(this, is_devtools_popup);
|
||||
opener->platform_delegate()->PopupBrowserCreated(platform_delegate_.get(),
|
||||
this, is_devtools_popup);
|
||||
}
|
||||
|
||||
// 2. Notify the browser's LifeSpanHandler. This must always be the first
|
||||
@@ -606,13 +549,6 @@ void ChromeBrowserHostImpl::SetBrowser(Browser* browser) {
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SetDevToolsBrowserHost(
|
||||
base::WeakPtr<ChromeBrowserHostImpl> devtools_browser_host) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(!devtools_browser_host_);
|
||||
devtools_browser_host_ = devtools_browser_host;
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::WindowDestroyed() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (auto view = chrome_browser_view()) {
|
||||
|
@@ -38,6 +38,11 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
||||
static CefRefPtr<ChromeBrowserHostImpl> Create(
|
||||
const CefBrowserCreateParams& params);
|
||||
|
||||
// Safe (checked) conversion from CefBrowserHostBase to ChromeBrowserHostImpl.
|
||||
// Use this method instead of static_cast.
|
||||
static CefRefPtr<ChromeBrowserHostImpl> FromBaseChecked(
|
||||
CefRefPtr<CefBrowserHostBase> host_base);
|
||||
|
||||
// Returns the browser associated with the specified RenderViewHost.
|
||||
static CefRefPtr<ChromeBrowserHostImpl> GetBrowserForHost(
|
||||
const content::RenderViewHost* host);
|
||||
@@ -62,6 +67,10 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
||||
// CefBrowserHostBase methods called from CefFrameHostImpl:
|
||||
void OnSetFocus(cef_focus_source_t source) override;
|
||||
|
||||
// CefBrowserHostBase methods:
|
||||
bool IsWindowless() const override { return false; }
|
||||
bool IsAlloyStyle() const override { return false; }
|
||||
|
||||
// CefBrowserHost methods:
|
||||
void CloseBrowser(bool force_close) override;
|
||||
bool TryCloseBrowser() override;
|
||||
@@ -72,9 +81,7 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
||||
bool matchCase,
|
||||
bool findNext) override;
|
||||
void StopFinding(bool clearSelection) override;
|
||||
void CloseDevTools() override;
|
||||
bool HasDevTools() override;
|
||||
bool IsWindowRenderingDisabled() override;
|
||||
bool IsWindowRenderingDisabled() override { return false; }
|
||||
void WasResized() override;
|
||||
void WasHidden(bool hidden) override;
|
||||
void NotifyScreenInfoChanged() override;
|
||||
@@ -124,8 +131,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
||||
|
||||
protected:
|
||||
bool Navigate(const content::OpenURLParams& params) override;
|
||||
void ShowDevToolsOnUIThread(
|
||||
std::unique_ptr<CefShowDevToolsParams> params) override;
|
||||
|
||||
private:
|
||||
friend class ChromeBrowserDelegate;
|
||||
@@ -147,7 +152,7 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
||||
// created. Must be called on the UI thread.
|
||||
void Attach(content::WebContents* web_contents,
|
||||
bool is_devtools_popup,
|
||||
CefRefPtr<ChromeBrowserHostImpl> opener);
|
||||
CefRefPtr<CefBrowserHostBase> opener);
|
||||
|
||||
// Called from ChromeBrowserDelegate::AddNewContents to take ownership of a
|
||||
// popup WebContents. |browser_create_params| may be empty for default Browser
|
||||
@@ -161,9 +166,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
||||
// before the new Browser is added. Must be called on the UI thread.
|
||||
void SetBrowser(Browser* browser);
|
||||
|
||||
void SetDevToolsBrowserHost(
|
||||
base::WeakPtr<ChromeBrowserHostImpl> devtools_browser_host);
|
||||
|
||||
// CefBrowserHostBase methods:
|
||||
void WindowDestroyed() override;
|
||||
bool WillBeDestroyed() const override;
|
||||
@@ -178,8 +180,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
||||
Browser* browser_ = nullptr;
|
||||
CefWindowHandle host_window_handle_ = kNullWindowHandle;
|
||||
|
||||
base::WeakPtr<ChromeBrowserHostImpl> devtools_browser_host_;
|
||||
|
||||
base::WeakPtrFactory<ChromeBrowserHostImpl> weak_ptr_factory_{this};
|
||||
};
|
||||
|
||||
|
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
|
||||
|
||||
#include "libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
|
||||
#include "libcef/browser/chrome/chrome_context_menu_handler.h"
|
||||
#include "libcef/browser/chrome/chrome_startup_browser_creator.h"
|
||||
#include "libcef/browser/context.h"
|
||||
@@ -13,6 +14,8 @@
|
||||
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/views/chrome_constrained_window_views_client.h"
|
||||
#include "components/constrained_window/constrained_window_views.h"
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
#include "base/linux_util.h"
|
||||
@@ -67,7 +70,7 @@ void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
|
||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
||||
|
||||
scheme::RegisterWebUIControllerFactory();
|
||||
context_menu::RegisterMenuCreatedCallback();
|
||||
context_menu::RegisterCallbacks();
|
||||
file_dialog_runner::RegisterFactory();
|
||||
permission_prompt::RegisterCreateCallback();
|
||||
|
||||
@@ -78,3 +81,9 @@ void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChromeBrowserMainExtraPartsCef::ToolkitInitialized() {
|
||||
// Override the default Chrome client.
|
||||
SetConstrainedWindowViewsClient(CreateAlloyConstrainedWindowViewsClient(
|
||||
CreateChromeConstrainedWindowViewsClient()));
|
||||
}
|
||||
|
@@ -44,6 +44,7 @@ class ChromeBrowserMainExtraPartsCef : public ChromeBrowserMainExtraParts {
|
||||
void PostProfileInit(Profile* profile, bool is_initial_profile) override;
|
||||
void PostBrowserStart() override;
|
||||
void PreMainMessageLoopRun() override;
|
||||
void ToolkitInitialized() override;
|
||||
|
||||
CefRefPtr<CefRequestContextImpl> global_request_context_;
|
||||
|
||||
|
@@ -8,10 +8,10 @@
|
||||
#include <tuple>
|
||||
|
||||
#include "libcef/browser/browser_frame.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_manager.h"
|
||||
#include "libcef/browser/certificate_query.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"
|
||||
#include "libcef/browser/net/chrome_scheme_handler.h"
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "components/performance_manager/embedder/performance_manager_registry.h"
|
||||
#include "content/public/browser/navigation_throttle.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
@@ -43,6 +44,10 @@
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
|
||||
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
#include "libcef/browser/chrome/chrome_web_contents_view_delegate_cef.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
void HandleExternalProtocolHelper(
|
||||
@@ -113,6 +118,14 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
|
||||
// Propagate the following switches to all command lines (along with any
|
||||
// associated values) if present in the browser command line.
|
||||
static const char* const kSwitchNames[] = {
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
switches::kFrameworkDirPath,
|
||||
switches::kMainBundlePath,
|
||||
#endif
|
||||
switches::kLocalesDirPath,
|
||||
switches::kLogItems,
|
||||
switches::kLogSeverity,
|
||||
switches::kResourcesDirPath,
|
||||
switches::kUserAgentProductAndVersion,
|
||||
};
|
||||
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames);
|
||||
@@ -120,6 +133,19 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
|
||||
|
||||
const std::string& process_type =
|
||||
command_line->GetSwitchValueASCII(switches::kProcessType);
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
if (process_type == switches::kZygoteProcess &&
|
||||
browser_cmd->HasSwitch(switches::kBrowserSubprocessPath)) {
|
||||
// Force use of the sub-process executable path for the zygote process.
|
||||
const base::FilePath& subprocess_path =
|
||||
browser_cmd->GetSwitchValuePath(switches::kBrowserSubprocessPath);
|
||||
if (!subprocess_path.empty()) {
|
||||
command_line->SetProgram(subprocess_path);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (process_type == switches::kRendererProcess) {
|
||||
// Propagate the following switches to the renderer command line (along with
|
||||
// any associated values) if present in the browser command line.
|
||||
@@ -210,7 +236,7 @@ void ChromeContentBrowserClientCef::OverrideWebkitPrefs(
|
||||
ChromeContentBrowserClient::OverrideWebkitPrefs(web_contents, prefs);
|
||||
|
||||
SkColor base_background_color;
|
||||
auto browser = ChromeBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
auto browser = CefBrowserHostBase::GetBrowserForContents(web_contents);
|
||||
if (browser) {
|
||||
renderer_prefs::SetCefPrefs(browser->settings(), *prefs);
|
||||
|
||||
@@ -232,6 +258,7 @@ void ChromeContentBrowserClientCef::WillCreateURLLoaderFactory(
|
||||
int render_process_id,
|
||||
URLLoaderFactoryType type,
|
||||
const url::Origin& request_initiator,
|
||||
const net::IsolationInfo& isolation_info,
|
||||
std::optional<int64_t> navigation_id,
|
||||
ukm::SourceIdObj ukm_source_id,
|
||||
network::URLLoaderFactoryBuilder& factory_builder,
|
||||
@@ -248,9 +275,9 @@ void ChromeContentBrowserClientCef::WillCreateURLLoaderFactory(
|
||||
if (!CefBrowserContext::FromProfile(profile)) {
|
||||
ChromeContentBrowserClient::WillCreateURLLoaderFactory(
|
||||
browser_context, frame, render_process_id, type, request_initiator,
|
||||
navigation_id, ukm_source_id, factory_builder, header_client,
|
||||
bypass_redirect_checks, disable_secure_dns, factory_override,
|
||||
navigation_response_task_runner);
|
||||
isolation_info, navigation_id, ukm_source_id, factory_builder,
|
||||
header_client, bypass_redirect_checks, disable_secure_dns,
|
||||
factory_override, navigation_response_task_runner);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -279,7 +306,7 @@ void ChromeContentBrowserClientCef::WillCreateURLLoaderFactory(
|
||||
// TODO(chrome): Is it necessary to proxy |header_client| callbacks?
|
||||
ChromeContentBrowserClient::WillCreateURLLoaderFactory(
|
||||
browser_context, frame, render_process_id, type, request_initiator,
|
||||
navigation_id, ukm_source_id, factory_builder,
|
||||
isolation_info, navigation_id, ukm_source_id, factory_builder,
|
||||
/*header_client=*/nullptr, bypass_redirect_checks, disable_secure_dns,
|
||||
handler_override, navigation_response_task_runner);
|
||||
|
||||
@@ -471,6 +498,22 @@ void ChromeContentBrowserClientCef::RegisterBrowserInterfaceBindersForFrame(
|
||||
map);
|
||||
}
|
||||
|
||||
std::unique_ptr<content::WebContentsViewDelegate>
|
||||
ChromeContentBrowserClientCef::GetWebContentsViewDelegate(
|
||||
content::WebContents* web_contents) {
|
||||
// From ChromeContentBrowserClient::GetWebContentsViewDelegate. Windowless
|
||||
// browsers don't call this method and use
|
||||
// CefBrowserPlatformDelegateAlloy::AttachHelpers instead.
|
||||
if (auto* registry =
|
||||
performance_manager::PerformanceManagerRegistry::GetInstance()) {
|
||||
registry->MaybeCreatePageNodeForWebContents(web_contents);
|
||||
}
|
||||
|
||||
// Used to customize context menu behavior for Alloy style. Called during
|
||||
// WebContents::Create() so we don't yet have an associated BrowserHost.
|
||||
return CreateWebContentsViewDelegate(web_contents);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContextImpl>
|
||||
ChromeContentBrowserClientCef::request_context() const {
|
||||
return browser_main_parts_->request_context();
|
||||
@@ -490,3 +533,15 @@ scoped_refptr<base::SingleThreadTaskRunner>
|
||||
ChromeContentBrowserClientCef::user_blocking_task_runner() const {
|
||||
return browser_main_parts_->user_blocking_task_runner();
|
||||
}
|
||||
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
// Defined in a separate .mm file on MacOS to work around
|
||||
// ChromeWebContentsViewDelegateViewsMac containing ObjC references.
|
||||
|
||||
// static
|
||||
std::unique_ptr<content::WebContentsViewDelegate>
|
||||
ChromeContentBrowserClientCef::CreateWebContentsViewDelegate(
|
||||
content::WebContents* web_contents) {
|
||||
return std::make_unique<ChromeWebContentsViewDelegateCef>(web_contents);
|
||||
}
|
||||
#endif
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
|
||||
#include "chrome/browser/chrome_content_browser_client.h"
|
||||
#include "content/public/browser/web_contents_view_delegate.h"
|
||||
|
||||
class ChromeBrowserMainExtraPartsCef;
|
||||
|
||||
@@ -61,6 +62,7 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
|
||||
int render_process_id,
|
||||
URLLoaderFactoryType type,
|
||||
const url::Origin& request_initiator,
|
||||
const net::IsolationInfo& isolation_info,
|
||||
std::optional<int64_t> navigation_id,
|
||||
ukm::SourceIdObj ukm_source_id,
|
||||
network::URLLoaderFactoryBuilder& factory_builder,
|
||||
@@ -126,6 +128,8 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
|
||||
void RegisterBrowserInterfaceBindersForFrame(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override;
|
||||
std::unique_ptr<content::WebContentsViewDelegate> GetWebContentsViewDelegate(
|
||||
content::WebContents* web_contents) override;
|
||||
|
||||
CefRefPtr<CefRequestContextImpl> request_context() const;
|
||||
|
||||
@@ -134,6 +138,9 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
|
||||
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner() const;
|
||||
|
||||
private:
|
||||
static std::unique_ptr<content::WebContentsViewDelegate>
|
||||
CreateWebContentsViewDelegate(content::WebContents* web_contents);
|
||||
|
||||
ChromeBrowserMainExtraPartsCef* browser_main_parts_ = nullptr;
|
||||
};
|
||||
|
||||
|
@@ -0,0 +1,14 @@
|
||||
// Copyright 2024 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
|
||||
|
||||
#include "libcef/browser/chrome/chrome_web_contents_view_delegate_cef.h"
|
||||
|
||||
// static
|
||||
std::unique_ptr<content::WebContentsViewDelegate> ChromeContentBrowserClientCef::CreateWebContentsViewDelegate(content::WebContents* web_contents) {
|
||||
return std::make_unique<ChromeWebContentsViewDelegateCef>(web_contents);
|
||||
}
|
||||
|
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "libcef/browser/chrome/chrome_context_menu_handler.h"
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/context_menu_params_impl.h"
|
||||
#include "libcef/browser/simple_menu_model_impl.h"
|
||||
@@ -14,6 +17,64 @@ namespace context_menu {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int kInvalidCommandId = -1;
|
||||
const cef_event_flags_t kEmptyEventFlags = static_cast<cef_event_flags_t>(0);
|
||||
|
||||
class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback {
|
||||
public:
|
||||
using Callback =
|
||||
base::OnceCallback<void(int /*command_id*/, int /*event_flags*/)>;
|
||||
|
||||
explicit CefRunContextMenuCallbackImpl(Callback callback)
|
||||
: callback_(std::move(callback)) {}
|
||||
|
||||
CefRunContextMenuCallbackImpl(const CefRunContextMenuCallbackImpl&) = delete;
|
||||
CefRunContextMenuCallbackImpl& operator=(
|
||||
const CefRunContextMenuCallbackImpl&) = delete;
|
||||
|
||||
~CefRunContextMenuCallbackImpl() override {
|
||||
if (!callback_.is_null()) {
|
||||
// The callback is still pending. Cancel it now.
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
RunNow(std::move(callback_), kInvalidCommandId, kEmptyEventFlags);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&CefRunContextMenuCallbackImpl::RunNow,
|
||||
std::move(callback_), kInvalidCommandId,
|
||||
kEmptyEventFlags));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Continue(int command_id, cef_event_flags_t event_flags) override {
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
if (!callback_.is_null()) {
|
||||
RunNow(std::move(callback_), command_id, event_flags);
|
||||
callback_.Reset();
|
||||
}
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&CefRunContextMenuCallbackImpl::Continue,
|
||||
this, command_id, event_flags));
|
||||
}
|
||||
}
|
||||
|
||||
void Cancel() override { Continue(kInvalidCommandId, kEmptyEventFlags); }
|
||||
|
||||
bool IsDisconnected() const { return callback_.is_null(); }
|
||||
void Disconnect() { callback_.Reset(); }
|
||||
|
||||
private:
|
||||
static void RunNow(Callback callback, int command_id, int event_flags) {
|
||||
CEF_REQUIRE_UIT();
|
||||
std::move(callback).Run(command_id, event_flags);
|
||||
}
|
||||
|
||||
Callback callback_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefRunContextMenuCallbackImpl);
|
||||
};
|
||||
|
||||
// Lifespan is controlled by RenderViewContextMenu.
|
||||
class CefContextMenuObserver : public RenderViewContextMenuObserver,
|
||||
public CefSimpleMenuModelImpl::StateDelegate {
|
||||
@@ -21,7 +82,10 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
|
||||
CefContextMenuObserver(RenderViewContextMenu* context_menu,
|
||||
CefRefPtr<CefBrowserHostBase> browser,
|
||||
CefRefPtr<CefContextMenuHandler> handler)
|
||||
: context_menu_(context_menu), browser_(browser), handler_(handler) {}
|
||||
: context_menu_(context_menu), browser_(browser), handler_(handler) {
|
||||
// This remains valid until the next time a context menu is created.
|
||||
browser_->set_context_menu_observer(this);
|
||||
}
|
||||
|
||||
CefContextMenuObserver(const CefContextMenuObserver&) = delete;
|
||||
CefContextMenuObserver& operator=(const CefContextMenuObserver&) = delete;
|
||||
@@ -130,6 +194,29 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
|
||||
}
|
||||
}
|
||||
|
||||
bool HandleShow() {
|
||||
if (model_->GetCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRunContextMenuCallbackImpl> callbackImpl(
|
||||
new CefRunContextMenuCallbackImpl(
|
||||
base::BindOnce(&CefContextMenuObserver::ExecuteCommandCallback,
|
||||
weak_ptr_factory_.GetWeakPtr())));
|
||||
|
||||
bool handled = handler_->RunContextMenu(browser_, GetFrame(), params_,
|
||||
model_, callbackImpl.get());
|
||||
if (!handled && callbackImpl->IsDisconnected()) {
|
||||
LOG(ERROR) << "Should return true from RunContextMenu when executing the "
|
||||
"callback";
|
||||
handled = true;
|
||||
}
|
||||
if (!handled) {
|
||||
callbackImpl->Disconnect();
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
private:
|
||||
struct ItemInfo {
|
||||
ItemInfo() = default;
|
||||
@@ -169,6 +256,7 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
|
||||
// May return nullptr if the frame is destroyed while the menu is pending.
|
||||
auto* rfh = context_menu_->GetRenderFrameHost();
|
||||
if (rfh) {
|
||||
// May return nullptr for excluded views.
|
||||
frame = browser_->GetFrameForHost(rfh);
|
||||
}
|
||||
if (!frame) {
|
||||
@@ -177,6 +265,14 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
|
||||
return frame;
|
||||
}
|
||||
|
||||
void ExecuteCommandCallback(int command_id, int event_flags) {
|
||||
if (command_id != kInvalidCommandId) {
|
||||
context_menu_->ExecuteCommand(command_id, event_flags);
|
||||
}
|
||||
context_menu_->Cancel();
|
||||
OnMenuClosed();
|
||||
}
|
||||
|
||||
RenderViewContextMenu* const context_menu_;
|
||||
CefRefPtr<CefBrowserHostBase> browser_;
|
||||
CefRefPtr<CefContextMenuHandler> handler_;
|
||||
@@ -186,6 +282,8 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
|
||||
// Map of command_id to ItemInfo.
|
||||
using ItemInfoMap = std::map<int, ItemInfo>;
|
||||
ItemInfoMap iteminfomap_;
|
||||
|
||||
base::WeakPtrFactory<CefContextMenuObserver> weak_ptr_factory_{this};
|
||||
};
|
||||
|
||||
std::unique_ptr<RenderViewContextMenuObserver> MenuCreatedCallback(
|
||||
@@ -199,16 +297,44 @@ std::unique_ptr<RenderViewContextMenuObserver> MenuCreatedCallback(
|
||||
handler);
|
||||
}
|
||||
}
|
||||
|
||||
// Don't leave the old pointer, if any.
|
||||
browser->set_context_menu_observer(nullptr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool MenuShowHandlerCallback(RenderViewContextMenu* context_menu) {
|
||||
auto browser = CefBrowserHostBase::GetBrowserForContents(
|
||||
context_menu->source_web_contents());
|
||||
if (browser && browser->context_menu_observer()) {
|
||||
return static_cast<CefContextMenuObserver*>(
|
||||
browser->context_menu_observer())
|
||||
->HandleShow();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void RegisterMenuCreatedCallback() {
|
||||
void RegisterCallbacks() {
|
||||
RenderViewContextMenu::RegisterMenuCreatedCallback(
|
||||
base::BindRepeating(&MenuCreatedCallback));
|
||||
RenderViewContextMenu::RegisterMenuShowHandlerCallback(
|
||||
base::BindRepeating(&MenuShowHandlerCallback));
|
||||
}
|
||||
|
||||
bool HandleContextMenu(content::WebContents* opener,
|
||||
const content::ContextMenuParams& params) {
|
||||
auto browser = CefBrowserHostBase::GetBrowserForContents(opener);
|
||||
if (browser && browser->IsAlloyStyle()) {
|
||||
AlloyBrowserHostImpl::FromBaseChecked(browser)->ShowContextMenu(params);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Continue with creating the RenderViewContextMenu.
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace context_menu
|
||||
|
@@ -6,10 +6,20 @@
|
||||
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTEXT_MENU_HANDLER_H_
|
||||
#pragma once
|
||||
|
||||
#include "content/public/browser/context_menu_params.h"
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
namespace context_menu {
|
||||
|
||||
// Register the context menu created callback.
|
||||
void RegisterMenuCreatedCallback();
|
||||
// Register RenderViewContextMenu callbacks.
|
||||
void RegisterCallbacks();
|
||||
|
||||
// Returns true if the menu was handled.
|
||||
bool HandleContextMenu(content::WebContents* opener,
|
||||
const content::ContextMenuParams& params);
|
||||
|
||||
} // namespace context_menu
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user