Compare commits

..

24 Commits
6478 ... 6367

Author SHA1 Message Date
pkv
9bd638fc40 alloy: Fix audio capturer crash on exit (fixes #3689) 2024-05-21 14:01:55 -04:00
Marshall Greenblatt
c712fb473a Update to Chromium version 124.0.6367.207 2024-05-14 13:44:55 +00:00
Marshall Greenblatt
091246b436 Update to Chromium version 124.0.6367.201 2024-05-10 14:44:05 +00:00
Marshall Greenblatt
30772e7742 Update depot_tools to fix race when downloading gsutil
See https://issues.chromium.org/issues/338040708
2024-05-09 10:32:57 -04:00
Marshall Greenblatt
ff7dcd851e Revert unretained dangling ptr detector crash by default (fixes #3693) 2024-05-06 16:56:41 -04:00
Marshall Greenblatt
a6e684abf1 Fix credentials mode for fetch request redirect (fixes #3675)
Also verified that https://browseraudit.com/ gives the same results
both with and without `--disable-request-handling-for-testing`.
2024-05-06 15:11:57 -04:00
Marshall Greenblatt
fe315c5108 alloy: Add missing geolocation pref registration (fixes #3694) 2024-05-06 11:57:39 -04:00
Marshall Greenblatt
b6e819b329 Update to Chromium version 124.0.6367.119 2024-05-03 13:52:49 +00:00
Marshall Greenblatt
6d871a1a27 Update depot_tools to fix NPM deps parsing error
Fix failures like:

[Error: 1> Key 'deps' error:
1> Key 'src/third_party/js_code_coverage' error:
1> Missing keys: 'object_name', 'sha256sum', 'size_bytes'

Due to https://crrev.com/df2193f222 and
https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5473744

See also https://magpcss.org/ceforum/viewtopic.php?f=6&t=19773&p=55193#p55193
2024-04-29 11:19:13 -04:00
reito
77c1e82898 osr: Implement shared texture support (fixes #1006, fixes #2575)
Adds support for the OnAcceleratedPaint callback. Verified to work
on macOS and Windows. Linux support is present but not implemented
for cefclient, so it is not verified to work.

To test:
Run `cefclient --off-screen-rendering-enabled --shared-texture-enabled`
2024-04-27 17:02:46 -04:00
Marshall Greenblatt
ccc63c9e55 Update to Chromium version 124.0.6367.60 2024-04-16 13:52:24 +00:00
Marshall Greenblatt
e461d8f247 Avoid possible reentrancy of ThemeChanged (see #3671)
The call to SelectNativeTheme from ChromeBrowserFrame::Initialized was
causing Widget::ThemeChanged reentrancy via OnColorProviderCacheResetMissed
when running with `--enable-chrome-runtime --use-native`. Make all calls to
ThemeChanged async to avoid this and possible future issues.
2024-04-14 21:44:28 -04:00
Jacobo Aragunde Pérez
1482ffe749 tools: Use raw strings for regexps in python scripts (fixes #3677)
Starting with Python 3.12, use of invalid escape sequences in strings
is reported as a SyntaxWarning and will become a SyntaxError at a
later point.

Regular expressions use the backslash character a lot, which result in
warnings of this kind. Python docs recommend to generally use raw
strings for this purpose.
2024-04-12 12:20:18 -04:00
Nik Pavlov
c45f88643a mac: views: Add customization point for acceptsFirstMouse (fixes #3680) 2024-04-12 12:20:12 -04:00
Nik Pavlov
e5bd17cd14 Fix how CefV8ValueImpl differentiates INT and UINT types (fixes #3657) 2024-04-12 12:20:06 -04:00
Marshall Greenblatt
e011687449 views: Fix destruction issues with CefOverlayViewHost 2024-04-11 15:55:23 -04:00
Marshall Greenblatt
6fafa6521f distrib: Add missing cef_color_id_macros.inc (see #3671) 2024-04-11 11:37:32 -04:00
Marshall Greenblatt
99cbd3571f win: Fix MSVC compile error with cef_color_ids.h (see #3671)
Copy and modify ui/color/color_id_macros.inc to include an MSVC
workaround for `__VA_ARGS__` expansion.
2024-04-11 11:37:24 -04:00
Marshall Greenblatt
326524d83f cefclient: Add missing draggable.html resource reference 2024-04-11 11:37:18 -04:00
Marshall Greenblatt
41036f7624 Update to Chromium version 124.0.6367.29 2024-04-09 18:40:59 -04:00
Marshall Greenblatt
759cdc7584 views: Add support for OS and Chrome themes (fixes #3610, fixes #3671)
Controls now respect OS and Chrome themes by default for both Alloy
and Chrome runtimes. Chrome themes (mode and colors) can be configured
using the new CefRequestContext::SetChromeColorScheme method. Individual
theme colors can be overridden using the new CefWindowDelegate::
OnThemeColorsChanged and CefWindow::SetThemeColor methods.

The `--force-light-mode` and `--force-dark-mode` command-line flags are
now respected on all platforms as an override for the OS theme.

The current Chrome theme, if any, will take precedence over the OS theme
when determining light/dark status. On Windows and MacOS the titlebar
color will also be updated to match the light/dark theme.

Testable as follows:
- Run: `cefclient --enable-chrome-runtime` OR
       `cefclient --use-views --persist-user-preferences --cache-path=...`
  - App launches with default OS light/dark theme colors.
  - Change OS dark/light theme under system settings. Notice that theme
    colors change as expected.
  - Right click, select items from the new Theme sub-menu. Notice that
    theme colors behave as expected.
  - Exit and relaunch the app. Notice that the last-used theme colors are
    applied on app restart.
- Add `--background-color=green` to above command-line.
  - Perform the same actions as above. Notice that all controls start
    and remain green throughout (except some icons with Chrome runtime).
- Add `--force-light-mode` or `--force-dark-mode` to above command-line.
  - Perform the same actions as above. Notice that OS dark/light theme
    changes are ignored, but Chrome theme changes work as expected.
2024-04-09 16:23:35 -04:00
Marshall Greenblatt
8a9a766d6d views: Generate cef_color_ids.h header (see #3671) 2024-04-09 16:21:12 -04:00
Marshall Greenblatt
7dbc1daaef mac: Enable allocator shim to fix builds (see #3061)
This is a workaround for https://crbug.com/326898585
2024-04-06 11:52:51 -04:00
Marshall Greenblatt
e683ed880c Update to Chromium version 124.0.6367.18 2024-03-28 11:37:23 -04:00
1151 changed files with 11336 additions and 12307 deletions

1
.gitignore vendored
View File

@@ -51,5 +51,6 @@ Thumbs.db
/binary_distrib
/docs
# CEF generated files
/include/cef_config.h
/include/cef_version.h
.ccls-cache/

349
BUILD.gn
View File

@@ -99,7 +99,6 @@ import("//build/config/locales.gni")
import("//build/config/ozone.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni")
import("//cef/libcef/features/features.gni")
import("//chrome/common/features.gni")
import("//content/public/app/mac_helpers.gni")
import("//extensions/buildflags/buildflags.gni")
@@ -252,7 +251,8 @@ if (is_linux) {
# Set by GetRequiredArgs() in //cef/tools/gn_args.py.
#
# Enable support for Print Preview.
# Set ENABLE_PRINTING=1 ENABLE_BASIC_PRINTING=1.
assert(enable_basic_printing)
assert(enable_print_preview)
# Enable support for Widevine CDM.
@@ -349,10 +349,6 @@ if (is_win) {
"//build/config:precompiled_headers",
]
public_configs = [
"libcef/features:config",
]
if (is_component_build) {
# Avoid linker errors with content_switches.cc in component build by not
# defining CONTENT_EXPORT.
@@ -461,14 +457,32 @@ source_set("libcef_test_support") {
source_set("libcef_static") {
sources = includes_common +
gypi_paths.autogen_cpp_includes + [
"libcef/browser/alloy/alloy_browser_context.cc",
"libcef/browser/alloy/alloy_browser_context.h",
"libcef/browser/alloy/alloy_browser_host_impl.cc",
"libcef/browser/alloy/alloy_browser_host_impl.h",
"libcef/browser/alloy/alloy_browser_main.cc",
"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_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/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",
"libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h",
"libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.cc",
"libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.h",
"libcef/browser/alloy/chrome_browser_process_alloy.cc",
"libcef/browser/alloy/chrome_browser_process_alloy.h",
"libcef/browser/alloy/chrome_profile_manager_alloy.cc",
"libcef/browser/alloy/chrome_profile_manager_alloy.h",
"libcef/browser/alloy/chrome_profile_alloy.cc",
"libcef/browser/alloy/chrome_profile_alloy.h",
"libcef/browser/audio_capturer.cc",
"libcef/browser/audio_capturer.h",
"libcef/browser/audio_loopback_stream_creator.cc",
@@ -477,6 +491,8 @@ source_set("libcef_static") {
"libcef/browser/browser_contents_delegate.h",
"libcef/browser/browser_context.cc",
"libcef/browser/browser_context.h",
"libcef/browser/browser_context_keyed_service_factories.cc",
"libcef/browser/browser_context_keyed_service_factories.h",
"libcef/browser/browser_frame.cc",
"libcef/browser/browser_frame.h",
"libcef/browser/browser_host_base.cc",
@@ -512,14 +528,9 @@ 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",
@@ -544,18 +555,62 @@ 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_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/devtools/devtools_file_manager.cc",
"libcef/browser/devtools/devtools_file_manager.h",
"libcef/browser/devtools/devtools_frontend.cc",
"libcef/browser/devtools/devtools_frontend.h",
"libcef/browser/devtools/devtools_manager.cc",
"libcef/browser/devtools/devtools_manager.h",
"libcef/browser/devtools/devtools_manager_delegate.cc",
"libcef/browser/devtools/devtools_manager_delegate.h",
"libcef/browser/download_item_impl.cc",
"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",
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.h",
"libcef/browser/extensions/api/storage/sync_value_store_cache.cc",
"libcef/browser/extensions/api/storage/sync_value_store_cache.h",
"libcef/browser/extensions/api/tabs/tabs_api.cc",
"libcef/browser/extensions/api/tabs/tabs_api.h",
"libcef/browser/extensions/alloy_extensions_util.cc",
"libcef/browser/extensions/alloy_extensions_util.h",
"libcef/browser/extensions/browser_extensions_util.cc",
"libcef/browser/extensions/browser_extensions_util.h",
"libcef/browser/extensions/browser_platform_delegate_background.cc",
"libcef/browser/extensions/browser_platform_delegate_background.h",
"libcef/browser/extensions/chrome_api_registration.cc",
"libcef/browser/extensions/chrome_api_registration.h",
"libcef/browser/extensions/component_extension_resource_manager.cc",
"libcef/browser/extensions/component_extension_resource_manager.h",
"libcef/browser/extensions/extensions_api_client.cc",
"libcef/browser/extensions/extensions_api_client.h",
"libcef/browser/extensions/extensions_browser_api_provider.cc",
"libcef/browser/extensions/extensions_browser_api_provider.h",
"libcef/browser/extensions/extensions_browser_client.cc",
"libcef/browser/extensions/extensions_browser_client.h",
"libcef/browser/extensions/extension_background_host.cc",
"libcef/browser/extensions/extension_background_host.h",
"libcef/browser/extensions/extension_function_details.cc",
"libcef/browser/extensions/extension_function_details.h",
"libcef/browser/extensions/extension_host_delegate.cc",
"libcef/browser/extensions/extension_host_delegate.h",
"libcef/browser/extensions/extension_system.cc",
"libcef/browser/extensions/extension_system.h",
"libcef/browser/extensions/extension_system_factory.cc",
"libcef/browser/extensions/extension_system_factory.h",
"libcef/browser/extensions/extension_view_host.cc",
"libcef/browser/extensions/extension_view_host.h",
"libcef/browser/extensions/extension_web_contents_observer.cc",
"libcef/browser/extensions/extension_web_contents_observer.h",
"libcef/browser/extensions/mime_handler_view_guest_delegate.cc",
"libcef/browser/extensions/mime_handler_view_guest_delegate.h",
"libcef/browser/extensions/value_store/cef_value_store.cc",
"libcef/browser/extensions/value_store/cef_value_store.h",
"libcef/browser/extensions/value_store/cef_value_store_factory.cc",
"libcef/browser/extensions/value_store/cef_value_store_factory.h",
"libcef/browser/file_dialog_manager.cc",
"libcef/browser/file_dialog_manager.h",
"libcef/browser/file_dialog_runner.cc",
@@ -578,6 +633,8 @@ source_set("libcef_static") {
"libcef/browser/main_runner.h",
"libcef/browser/media_access_query.cc",
"libcef/browser/media_access_query.h",
"libcef/browser/media_capture_devices_dispatcher.cc",
"libcef/browser/media_capture_devices_dispatcher.h",
"libcef/browser/media_router/media_route_impl.cc",
"libcef/browser/media_router/media_route_impl.h",
"libcef/browser/media_router/media_router_impl.cc",
@@ -606,6 +663,12 @@ source_set("libcef_static") {
"libcef/browser/net/chrome_scheme_handler.cc",
"libcef/browser/net/chrome_scheme_handler.h",
"libcef/browser/net/crlset_file_util_impl.cc",
"libcef/browser/net/devtools_scheme_handler.cc",
"libcef/browser/net/devtools_scheme_handler.h",
"libcef/browser/net/internal_scheme_handler.cc",
"libcef/browser/net/internal_scheme_handler.h",
"libcef/browser/net/scheme_handler.cc",
"libcef/browser/net/scheme_handler.h",
"libcef/browser/net/throttle_handler.cc",
"libcef/browser/net/throttle_handler.h",
"libcef/browser/net_service/browser_urlrequest_impl.cc",
@@ -661,6 +724,8 @@ source_set("libcef_static") {
"libcef/browser/prefs/pref_helper.h",
"libcef/browser/prefs/pref_registrar.cc",
"libcef/browser/prefs/pref_registrar.h",
"libcef/browser/prefs/pref_store.cc",
"libcef/browser/prefs/pref_store.h",
"libcef/browser/prefs/renderer_prefs.cc",
"libcef/browser/prefs/renderer_prefs.h",
"libcef/browser/print_settings_impl.cc",
@@ -677,6 +742,10 @@ source_set("libcef_static") {
"libcef/browser/server_impl.h",
"libcef/browser/simple_menu_model_impl.cc",
"libcef/browser/simple_menu_model_impl.h",
"libcef/browser/speech_recognition_manager_delegate.cc",
"libcef/browser/speech_recognition_manager_delegate.h",
"libcef/browser/ssl_host_state_delegate.cc",
"libcef/browser/ssl_host_state_delegate.h",
"libcef/browser/ssl_info_impl.cc",
"libcef/browser/ssl_info_impl.h",
"libcef/browser/ssl_status_impl.cc",
@@ -759,6 +828,12 @@ source_set("libcef_static") {
"libcef/browser/xml_reader_impl.h",
"libcef/browser/zip_reader_impl.cc",
"libcef/browser/zip_reader_impl.h",
"libcef/common/alloy/alloy_content_client.cc",
"libcef/common/alloy/alloy_content_client.h",
"libcef/common/alloy/alloy_main_delegate.cc",
"libcef/common/alloy/alloy_main_delegate.h",
"libcef/common/alloy/alloy_main_runner_delegate.cc",
"libcef/common/alloy/alloy_main_runner_delegate.h",
"libcef/common/app_manager.cc",
"libcef/common/app_manager.h",
"libcef/common/base_impl.cc",
@@ -778,6 +853,14 @@ source_set("libcef_static") {
"libcef/common/crash_reporting.h",
"libcef/common/drag_data_impl.cc",
"libcef/common/drag_data_impl.h",
"libcef/common/extensions/chrome_generated_schemas.cc",
"libcef/common/extensions/chrome_generated_schemas.h",
"libcef/common/extensions/extensions_api_provider.cc",
"libcef/common/extensions/extensions_api_provider.h",
"libcef/common/extensions/extensions_client.cc",
"libcef/common/extensions/extensions_client.h",
"libcef/common/extensions/extensions_util.cc",
"libcef/common/extensions/extensions_util.h",
"libcef/common/file_util_impl.cc",
"libcef/common/frame_util.cc",
"libcef/common/frame_util.h",
@@ -787,6 +870,8 @@ source_set("libcef_static") {
"libcef/common/main_runner_handler.h",
"libcef/common/net/http_header_utils.cc",
"libcef/common/net/http_header_utils.h",
"libcef/common/net/net_resource_provider.cc",
"libcef/common/net/net_resource_provider.h",
"libcef/common/net/scheme_registration.cc",
"libcef/common/net/scheme_registration.h",
"libcef/common/net/url_util.cc",
@@ -836,6 +921,12 @@ source_set("libcef_static") {
"libcef/common/waitable_event_impl.h",
"libcef/features/runtime.h",
"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_thread_observer.cc",
"libcef/renderer/alloy/alloy_render_thread_observer.h",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.cc",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.h",
"libcef/renderer/browser_impl.cc",
"libcef/renderer/browser_impl.h",
"libcef/renderer/chrome/chrome_content_renderer_client_cef.cc",
@@ -848,6 +939,8 @@ 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",
@@ -865,121 +958,6 @@ source_set("libcef_static") {
"//chrome/app/chrome_main_delegate.h",
]
if (enable_alloy_bootstrap) {
sources += [
"libcef/browser/alloy/alloy_browser_context.cc",
"libcef/browser/alloy/alloy_browser_context.h",
"libcef/browser/alloy/alloy_browser_main.cc",
"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/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_javascript_dialog_manager_delegate.cc",
"libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h",
"libcef/browser/alloy/chrome_browser_process_alloy.cc",
"libcef/browser/alloy/chrome_browser_process_alloy.h",
"libcef/browser/alloy/chrome_profile_manager_alloy.cc",
"libcef/browser/alloy/chrome_profile_manager_alloy.h",
"libcef/browser/alloy/chrome_profile_alloy.cc",
"libcef/browser/alloy/chrome_profile_alloy.h",
"libcef/browser/browser_context_keyed_service_factories.cc",
"libcef/browser/browser_context_keyed_service_factories.h",
"libcef/browser/extension_impl.cc",
"libcef/browser/extension_impl.h",
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.cc",
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.h",
"libcef/browser/extensions/api/storage/sync_value_store_cache.cc",
"libcef/browser/extensions/api/storage/sync_value_store_cache.h",
"libcef/browser/extensions/api/tabs/tabs_api.cc",
"libcef/browser/extensions/api/tabs/tabs_api.h",
"libcef/browser/extensions/alloy_extensions_util.cc",
"libcef/browser/extensions/alloy_extensions_util.h",
"libcef/browser/extensions/browser_platform_delegate_background.cc",
"libcef/browser/extensions/browser_platform_delegate_background.h",
"libcef/browser/extensions/chrome_api_registration.cc",
"libcef/browser/extensions/chrome_api_registration.h",
"libcef/browser/extensions/component_extension_resource_manager.cc",
"libcef/browser/extensions/component_extension_resource_manager.h",
"libcef/browser/extensions/extensions_api_client.cc",
"libcef/browser/extensions/extensions_api_client.h",
"libcef/browser/extensions/extensions_browser_api_provider.cc",
"libcef/browser/extensions/extensions_browser_api_provider.h",
"libcef/browser/extensions/extensions_browser_client.cc",
"libcef/browser/extensions/extensions_browser_client.h",
"libcef/browser/extensions/extension_background_host.cc",
"libcef/browser/extensions/extension_background_host.h",
"libcef/browser/extensions/extension_function_details.cc",
"libcef/browser/extensions/extension_function_details.h",
"libcef/browser/extensions/extension_host_delegate.cc",
"libcef/browser/extensions/extension_host_delegate.h",
"libcef/browser/extensions/extension_system.cc",
"libcef/browser/extensions/extension_system.h",
"libcef/browser/extensions/extension_system_factory.cc",
"libcef/browser/extensions/extension_system_factory.h",
"libcef/browser/extensions/extension_view_host.cc",
"libcef/browser/extensions/extension_view_host.h",
"libcef/browser/extensions/extension_web_contents_observer.cc",
"libcef/browser/extensions/extension_web_contents_observer.h",
"libcef/browser/extensions/mime_handler_view_guest_delegate.cc",
"libcef/browser/extensions/mime_handler_view_guest_delegate.h",
"libcef/browser/extensions/value_store/cef_value_store.cc",
"libcef/browser/extensions/value_store/cef_value_store.h",
"libcef/browser/extensions/value_store/cef_value_store_factory.cc",
"libcef/browser/extensions/value_store/cef_value_store_factory.h",
"libcef/browser/media_capture_devices_dispatcher.cc",
"libcef/browser/media_capture_devices_dispatcher.h",
"libcef/browser/net/devtools_scheme_handler.cc",
"libcef/browser/net/devtools_scheme_handler.h",
"libcef/browser/net/internal_scheme_handler.cc",
"libcef/browser/net/internal_scheme_handler.h",
"libcef/browser/net/scheme_handler.cc",
"libcef/browser/net/scheme_handler.h",
"libcef/browser/prefs/pref_store.cc",
"libcef/browser/prefs/pref_store.h",
"libcef/browser/speech_recognition_manager_delegate.cc",
"libcef/browser/speech_recognition_manager_delegate.h",
"libcef/browser/ssl_host_state_delegate.cc",
"libcef/browser/ssl_host_state_delegate.h",
"libcef/common/alloy/alloy_content_client.cc",
"libcef/common/alloy/alloy_content_client.h",
"libcef/common/alloy/alloy_main_delegate.cc",
"libcef/common/alloy/alloy_main_delegate.h",
"libcef/common/alloy/alloy_main_runner_delegate.cc",
"libcef/common/alloy/alloy_main_runner_delegate.h",
"libcef/common/extensions/chrome_generated_schemas.cc",
"libcef/common/extensions/chrome_generated_schemas.h",
"libcef/common/extensions/extensions_api_provider.cc",
"libcef/common/extensions/extensions_api_provider.h",
"libcef/common/extensions/extensions_client.cc",
"libcef/common/extensions/extensions_client.h",
"libcef/common/extensions/extensions_util.cc",
"libcef/common/extensions/extensions_util.h",
"libcef/common/net/net_resource_provider.cc",
"libcef/common/net/net_resource_provider.h",
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
"libcef/renderer/alloy/alloy_content_renderer_client.h",
"libcef/renderer/alloy/alloy_render_frame_observer.cc",
"libcef/renderer/alloy/alloy_render_frame_observer.h",
"libcef/renderer/alloy/alloy_render_thread_observer.cc",
"libcef/renderer/alloy/alloy_render_thread_observer.h",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.cc",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.h",
]
}
configs += [
"libcef/features:config",
"//build/config:precompiled_headers",
@@ -1017,6 +995,7 @@ source_set("libcef_static") {
# Normal build dependencies. Should be sorted alphabetically.
"//base:base_static",
"//base/third_party/dynamic_annotations",
"//cc",
"//chrome:dependencies",
"//chrome:packed_resources",
@@ -1127,6 +1106,12 @@ source_set("libcef_static") {
deps += [ "//content:sandbox_helper_win" ]
}
libs = [
"comctl32.lib",
# For D3D11_DECODER_PROFILE_H264_VLD_NOFGT.
"dxguid.lib",
]
data_deps = [
"//chrome/elevation_service",
]
@@ -1166,8 +1151,6 @@ source_set("libcef_static") {
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",
@@ -1189,10 +1172,6 @@ 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) {
@@ -1243,30 +1222,19 @@ config("libcef_autogen_config") {
}
}
# Configuration that supports #include paths relative to src/cef/ for CEF
# client-side code. CEF library-side code (Chromium code and cef/libcef/
# directory) uses #include paths relative to src/. See libcef/features:config
# for CEF library-side configuration.
config("libcef_includes_config") {
include_dirs = [
# cef/include/ directory and CEF client-side code use #includes relative to
# the cef/ directory.
".",
# CEF generated header files that also need to be discoverable.
# These #includes from client-side code will not be prefixed with cef/.
# They will be copied to the include/ directory in the binary distribution.
"$root_out_dir/includes/cef",
]
}
# Configuration that will be applied to all targets that depend on
# libcef_dll_wrapper.
config("libcef_dll_wrapper_config") {
configs = [
":libcef_autogen_config",
":libcef_includes_config",
include_dirs = [
# CEF sources use include paths relative to the CEF root directory.
".",
# CEF generates some header files that also need to be discoverable.
# They will be copied to the include/ directory in the binary distribution.
"$root_out_dir/includes",
]
configs = [ ":libcef_autogen_config" ]
if (is_win) {
if (current_cpu == "x86") {
# Set the initial stack size to 0.5MiB, instead of the 1.5MiB minimum
@@ -1314,23 +1282,20 @@ static_library("libcef_dll_wrapper") {
if (is_win) {
static_library("cef_sandbox") {
sources = [ "libcef_dll/sandbox/sandbox_win.cc" ]
configs += [ ":libcef_includes_config" ]
deps = [
":make_config_header",
"libcef/features",
"//sandbox",
]
# CEF sources use include paths relative to the CEF root directory.
include_dirs = [ "." ]
deps = [ "libcef/features", "//sandbox" ]
}
}
if (is_mac) {
static_library("cef_sandbox") {
sources = [ "libcef_dll/sandbox/sandbox_mac.mm" ]
configs += [ ":libcef_includes_config" ]
# CEF sources use include paths relative to the CEF root directory.
include_dirs = [ "." ]
deps = [
":make_config_header",
"//build/config:executable_deps",
"//sandbox/mac:seatbelt",
"//sandbox/mac:seatbelt"
]
}
}
@@ -1386,7 +1351,7 @@ template("make_pack_header") {
# Generate cef_pack_resources.h.
make_pack_header("resources") {
header = "$root_out_dir/includes/cef/include/cef_pack_resources.h"
header = "$root_out_dir/includes/include/cef_pack_resources.h"
inputs = [
"$root_gen_dir/base/tracing/protos/grit/tracing_proto_resources.h",
"$root_gen_dir/cef/grit/cef_resources.h",
@@ -1450,7 +1415,7 @@ make_pack_header("resources") {
# Generate cef_pack_strings.h.
make_pack_header("strings") {
header = "$root_out_dir/includes/cef/include/cef_pack_strings.h"
header = "$root_out_dir/includes/include/cef_pack_strings.h"
inputs = [
"$root_gen_dir/cef/grit/cef_strings.h",
"$root_gen_dir/chrome/grit/branded_strings.h",
@@ -1488,7 +1453,7 @@ make_pack_header("strings") {
# Generate cef_command_ids.h.
make_pack_header("command_ids") {
header = "$root_out_dir/includes/cef/include/cef_command_ids.h"
header = "$root_out_dir/includes/include/cef_command_ids.h"
inputs = [
"//chrome/app/chrome_command_ids.h",
]
@@ -1506,29 +1471,18 @@ action("make_api_hash_header") {
gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes
include_dir = [ "include" ]
outputs = [ "$root_out_dir/includes/cef/include/cef_api_hash.h" ]
outputs = [ "$root_out_dir/includes/include/cef_api_hash.h" ]
args = rebase_path(outputs + include_dir, root_build_dir)
}
# This no-op action lists args.gn as an output, allowing it to be referenced as
# an input (trigger) for other actions. Otherwise, GN will complain that no
# target generates the args.gn file because its below the $root_out_dir.
action("args_gn_source") {
script = "//build/noop.py"
outputs = [ "$root_out_dir/args.gn" ]
}
# Generate cef_config.h.
action("make_config_header") {
script = "tools/make_config_header.py"
deps = [ ":args_gn_source" ]
outputs = [ "$root_out_dir/includes/include/cef_config.h" ]
inputs = [ "$root_out_dir/args.gn" ]
outputs = [ "$root_out_dir/includes/cef/include/cef_config.h" ]
args = rebase_path(outputs + inputs, root_build_dir)
args = rebase_path(outputs + [ "$root_out_dir/args.gn" ], root_build_dir)
}
# Generate cef_color_ids.h.
@@ -1540,7 +1494,7 @@ action("make_colorids_header") {
"//components/color/color_id.h",
"//chrome/browser/ui/color/chrome_color_id.h",
]
outputs = [ "$root_out_dir/includes/cef/include/cef_color_ids.h" ]
outputs = [ "$root_out_dir/includes/include/cef_color_ids.h" ]
args = rebase_path(outputs + inputs, root_build_dir)
}
@@ -1751,12 +1705,6 @@ if (is_mac) {
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.
configs += [ "//build/config/win:delayloads" ]
libs = [
"comctl32.lib",
# For D3D11_DECODER_PROFILE_H264_VLD_NOFGT.
"dxguid.lib",
]
}
if (is_linux && !is_debug && !use_partition_alloc_as_malloc) {
@@ -1976,6 +1924,13 @@ if (is_mac) {
]
}
bundle_data("cefclient_resources_bundle_data_extensions_set_page_color") {
sources = gypi_paths2.cefclient_sources_resources_extensions_set_page_color
outputs = [
"{{bundle_resources_dir}}/extensions/set_page_color/{{source_file_part}}",
]
}
bundle_data("cefclient_resources_bundle_data_english") {
sources = [
"tests/cefclient/resources/mac/English.lproj/InfoPlist.strings",
@@ -2025,6 +1980,7 @@ if (is_mac) {
gypi_paths2.cefclient_sources_mac
deps = [
":cefclient_resources_bundle_data",
":cefclient_resources_bundle_data_extensions_set_page_color",
":cefclient_resources_bundle_data_english",
":cefclient_xibs",
]
@@ -2214,6 +2170,11 @@ if (is_mac) {
gypi_paths2.cefclient_sources_resources
outputs = [ "${root_out_dir}/cefclient_files/{{source_file_part}}" ]
}
copy("copy_cefclient_files_extensions_set_page_color") {
sources = gypi_paths2.cefclient_sources_resources_extensions_set_page_color
outputs = [ "${root_out_dir}/cefclient_files/extensions/set_page_color/{{source_file_part}}" ]
}
}
executable("cefclient") {
@@ -2271,13 +2232,8 @@ if (is_mac) {
if (target_cpu != "arm64") {
libs += [
"glu32.lib",
"opengl32.lib",
]
ldflags = [
"/DELAYLOAD:glu32.dll",
"/DELAYLOAD:oleaut32.dll",
"/DELAYLOAD:opengl32.dll",
"glu32.lib"
]
}
}
@@ -2289,6 +2245,7 @@ if (is_mac) {
deps += [
":copy_cefclient_files",
":copy_cefclient_files_extensions_set_page_color",
]
libs = [

View File

@@ -7,6 +7,6 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/126.0.6478.183',
'depot_tools_checkout': 'fca881606e'
'chromium_checkout': 'refs/tags/124.0.6367.207',
'depot_tools_checkout': '19199514e8'
}

View File

@@ -240,18 +240,16 @@ PRINT_CEF_CONFIG()
# Define the API documentation target.
#
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile")
find_package(Doxygen)
if(DOXYGEN_FOUND)
add_custom_target(apidocs ALL
# Generate documentation in the docs/html directory.
COMMAND "${DOXYGEN_EXECUTABLE}" Doxyfile
# Write a docs/index.html file.
COMMAND ${CMAKE_COMMAND} -E echo "<html><head><meta http-equiv=\"refresh\" content=\"0;URL='html/index.html'\"/></head></html>" > docs/index.html
WORKING_DIRECTORY "${CEF_ROOT}"
COMMENT "Generating API documentation with Doxygen..."
VERBATIM )
else()
message(WARNING "Doxygen must be installed to generate API documentation.")
endif()
endif()
find_package(Doxygen)
if(DOXYGEN_FOUND)
add_custom_target(apidocs ALL
# Generate documentation in the docs/html directory.
COMMAND "${DOXYGEN_EXECUTABLE}" Doxyfile
# Write a docs/index.html file.
COMMAND ${CMAKE_COMMAND} -E echo "<html><head><meta http-equiv=\"refresh\" content=\"0;URL='html/index.html'\"/></head></html>" > docs/index.html
WORKING_DIRECTORY "${CEF_ROOT}"
COMMENT "Generating API documentation with Doxygen..."
VERBATIM )
else()
message(WARNING "Doxygen must be installed to generate API documentation.")
endif()

View File

@@ -20,6 +20,7 @@
'include/base/cef_logging.h',
'include/base/cef_macros.h',
'include/base/cef_platform_thread.h',
'include/base/cef_ptr_util.h',
'include/base/cef_ref_counted.h',
'include/base/cef_scoped_refptr.h',
'include/base/cef_thread_checker.h',
@@ -53,10 +54,9 @@
'include/internal/cef_time.h',
'include/internal/cef_trace_event_internal.h',
'include/internal/cef_types.h',
'include/internal/cef_types_color.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',
@@ -166,6 +166,8 @@
'shared_sources_browser': [
'tests/shared/browser/client_app_browser.cc',
'tests/shared/browser/client_app_browser.h',
'tests/shared/browser/extension_util.cc',
'tests/shared/browser/extension_util.h',
'tests/shared/browser/file_util.cc',
'tests/shared/browser/file_util.h',
'tests/shared/browser/geometry_util.cc',
@@ -335,6 +337,13 @@
'tests/cefclient/resources/window.html',
'tests/cefclient/resources/xmlhttprequest.html',
],
'cefclient_sources_resources_extensions_set_page_color': [
'tests/cefclient/resources/extensions/set_page_color/icon.png',
'tests/cefclient/resources/extensions/set_page_color/manifest.json',
'tests/cefclient/resources/extensions/set_page_color/popup.html',
'tests/cefclient/resources/extensions/set_page_color/popup.js',
'tests/cefclient/resources/extensions/set_page_color/README.md',
],
'cefclient_sources_win': [
'tests/cefclient/browser/browser_window_osr_win.cc',
'tests/cefclient/browser/browser_window_osr_win.h',
@@ -481,6 +490,13 @@
'tests/ceftests/dom_unittest.cc',
'tests/ceftests/download_unittest.cc',
'tests/ceftests/draggable_regions_unittest.cc',
'tests/ceftests/extensions/background_unittest.cc',
'tests/ceftests/extensions/chrome_alarms_unittest.cc',
'tests/ceftests/extensions/chrome_storage_unittest.cc',
'tests/ceftests/extensions/chrome_tabs_unittest.cc',
'tests/ceftests/extensions/extension_test_handler.cc',
'tests/ceftests/extensions/extension_test_handler.h',
'tests/ceftests/extensions/view_unittest.cc',
'tests/ceftests/file_util_unittest.cc',
'tests/ceftests/frame_handler_unittest.cc',
'tests/ceftests/frame_unittest.cc',

View File

@@ -69,28 +69,7 @@
#if defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "build/build_config.h"
#include "cef/libcef/features/features.h"
// The following #defines are used in cef/include/ headers and CEF client-side
// code. CEF library-side code should use BUILDFLAG checks directly instead of
// these #defines. CEF client-side code will get these #defines from
// cef_config.h so any changes must also be reflected in
// tools/make_config_header.py.
#if BUILDFLAG(IS_LINUX)
#include "ui/base/ozone_buildflags.h"
#if BUILDFLAG(IS_OZONE_X11)
#define CEF_X11 1
#endif
#endif
#if !BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
#define DISABLE_ALLOY_BOOTSTRAP 1
#endif
#else // !USING_CHROMIUM_INCLUDES
#include "include/cef_config.h"
// The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be
// updated to match.

View File

@@ -0,0 +1,60 @@
// Copyright (c) 2021 Marshall A. Greenblatt. Portions copyright (c) 2015
// Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef INCLUDE_BASE_CEF_PTR_UTIL_H_
#define INCLUDE_BASE_CEF_PTR_UTIL_H_
#pragma once
#if defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "base/memory/ptr_util.h"
#else // !USING_CHROMIUM_INCLUDES
// The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be
// updated to match.
#include <memory>
#include <utility>
namespace base {
///
/// Helper to transfer ownership of a raw pointer to a std::unique_ptr<T>.
/// Note that std::unique_ptr<T> has very different semantics from
/// std::unique_ptr<T[]>: do not use this helper for array allocations.
///
template <typename T>
std::unique_ptr<T> WrapUnique(T* ptr) {
return std::unique_ptr<T>(ptr);
}
} // namespace base
#endif // INCLUDE_BASE_CEF_PTR_UTIL_H_

View File

@@ -66,7 +66,6 @@
// updated to match.
#include <stddef.h>
#include <tuple>
#include <utility>

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=6ee74f31d37a1b5ab3c9c5ccbe2dce9841329b38$
// $hash=abcb584dbf5965834f415a0f2daeda3e361696b2$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
@@ -911,8 +911,6 @@ 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);
@@ -921,8 +919,6 @@ 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);
///
@@ -989,13 +985,6 @@ 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;
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=bf7208a86ee17f63fd7163cef8c3a13373a1f1c8$
// $hash=5644fdc2453dd083079bf9e3616b687eeb49f250$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_
@@ -86,20 +86,13 @@ typedef struct _cef_dialog_handler_t {
/// to show the default title ("Open" or "Save" depending on the mode).
/// |default_file_path| is the path with optional directory and/or file name
/// component that should be initially selected in the dialog.
/// |accept_filters| are used to restrict the selectable file types and may be
/// any combination of valid lower-cased MIME types (e.g. "text/*" or
/// "image/*") and individual file extensions (e.g. ".txt" or ".png").
/// |accept_extensions| provides the semicolon-delimited expansion of MIME
/// types to file extensions (if known, or NULL string otherwise).
/// |accept_descriptions| provides the descriptions for MIME types (if known,
/// or NULL string otherwise). For example, the "image/*" mime type might have
/// extensions ".png;.jpg;.bmp;..." and description "Image Files".
/// |accept_filters|, |accept_extensions| and |accept_descriptions| will all
/// be the same size. To display a custom dialog return true (1) and execute
/// |callback| either inline or at a later time. To display the default dialog
/// return false (0). If this function returns false (0) it may be called an
/// additional time for the same dialog (both before and after MIME type
/// expansion).
/// |accept_filters| are used to restrict the selectable file types and may
/// any combination of (a) valid lower-cased MIME types (e.g. "text/*" or
/// "image/*"), (b) individual file extensions (e.g. ".txt" or ".png"), or (c)
/// combined description and file extension delimited using "|" and ";" (e.g.
/// "Image Types|.png;.gif;.jpg"). To display a custom dialog return true (1)
/// and execute |callback| either inline or at a later time. To display the
/// default dialog return false (0).
///
int(CEF_CALLBACK* on_file_dialog)(
struct _cef_dialog_handler_t* self,
@@ -108,8 +101,6 @@ typedef struct _cef_dialog_handler_t {
const cef_string_t* title,
const cef_string_t* default_file_path,
cef_string_list_t accept_filters,
cef_string_list_t accept_extensions,
cef_string_list_t accept_descriptions,
struct _cef_file_dialog_callback_t* callback);
} cef_dialog_handler_t;

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=7ecfb07a95315ff81937e9f68d419122fc88f1b7$
// $hash=60a08a60be70e8fe5df17f18f8e5758e1830d5e1$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
@@ -117,13 +117,12 @@ typedef struct _cef_download_handler_t {
///
/// Called before a download begins. |suggested_name| is the suggested name
/// 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.
/// 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.
///
int(CEF_CALLBACK* on_before_download)(
void(CEF_CALLBACK* on_before_download)(
struct _cef_download_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_download_item_t* download_item,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=634054ad25154c30fb4ec630fe7fb79b0cf1f9b3$
// $hash=0ca2b788f70f8c9f5b2706d691d8e063be00ed19$
//
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
@@ -54,8 +54,6 @@ 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.

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=ebac34c9b85de780ce7524211c5dd61a80d4576c$
// $hash=5cfff4465a586d2b2ea7b54a9549096faec415f6$
//
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
@@ -80,8 +80,6 @@ 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.

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=2c496139ca9a59303b1493ee93d2c3ae96a956c0$
// $hash=7df03921b2ee743fb059f13e545ccf89904eb060$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@@ -253,8 +253,6 @@ 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,
@@ -266,8 +264,6 @@ 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);
@@ -277,8 +273,6 @@ 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);
@@ -288,8 +282,6 @@ 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);
@@ -298,8 +290,6 @@ 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);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=5dd4948a92af2ad69e2171f2dffb8f2c23e5c147$
// $hash=3a188f380f8044060ea93fdca0b3d231df88979d$
//
#ifndef CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_
@@ -611,6 +611,7 @@ typedef struct _cef_v8value_t {
///
int(CEF_CALLBACK* set_value_byaccessor)(struct _cef_v8value_t* self,
const cef_string_t* key,
cef_v8_accesscontrol_t settings,
cef_v8_propertyattribute_t attribute);
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=da2edf5e08eb45942b6a82109aa86682c202ccac$
// $hash=db81a65aba3c2d1213744ad4251322acf97c608c$
//
#ifndef CEF_INCLUDE_CAPI_TEST_CEF_TEST_HELPERS_CAPI_H_
@@ -67,14 +67,6 @@ CEF_EXPORT void cef_execute_java_script_with_user_gesture_for_tests(
///
CEF_EXPORT void cef_set_data_directory_for_tests(const cef_string_t* dir);
///
/// Returns true (1) if |feature_name| is enabled by default, command line or
/// field trial. This supports a short list of curated values that are queried
/// by unit tests.
///
CEF_EXPORT int cef_is_feature_enabled_for_tests(
const cef_string_t* feature_name);
#ifdef __cplusplus
}
#endif

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=1c2fbbffaf51e90a2d55bfa7eb3fa3a4e315f4ac$
// $hash=2e5a3b3b1f427a7eb1e6a447fe0d31c5ace49469$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
@@ -93,13 +93,6 @@ 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;
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=a0a9f2bfcdf8e05d3d1114fcd8860caaa726ec98$
// $hash=1f2a6e206b86945386bef57167b80e2fb6067c59$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_
@@ -141,13 +141,6 @@ 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

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=dd32b58ec9aca0e04a1d30ccf94a741995fcc094$
// $hash=2abb3759a22a95ffc0207f0538c645a74a5030c6$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_
@@ -401,13 +401,6 @@ typedef struct _cef_window_t {
/// 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;
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=e8c9e32caa8d317a7cb6ff2f0ad6be49cf1b7ad1$
// $hash=e6bbc33db1b5ed3832982f8799e14557204f4028$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
@@ -275,13 +275,6 @@ typedef struct _cef_window_delegate_t {
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

View File

@@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "ed1dfa5ff8a041241f8fb72eb7454811f358f0d3"
#define CEF_API_HASH_UNIVERSAL "35035b76d79ba0c7144aedb63d72b7988d372706"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "0d99d1b9b85b2efab91a39d6fc325bb6d56fd524"
#define CEF_API_HASH_PLATFORM "9227cf2e0abf4f378e31e6095d503a91b2da59af"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "e585e190387e31a71267207b66d175e213991470"
#define CEF_API_HASH_PLATFORM "fe0bdc49d209ee3cf108bdb72faec21316f9d0e0"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "09d3e280ed38f7a082b794c56ff71c52f86f0ea8"
#define CEF_API_HASH_PLATFORM "df471096e6600c025ac0655b5eaa9818f075b8ba"
#endif
#ifdef __cplusplus

View File

@@ -39,7 +39,6 @@
#pragma once
#include <vector>
#include "include/cef_base.h"
#include "include/cef_devtools_message_observer.h"
#include "include/cef_drag_data.h"
@@ -943,8 +942,6 @@ 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;
@@ -953,8 +950,6 @@ 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;
@@ -1023,13 +1018,6 @@ 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_

View File

@@ -40,7 +40,6 @@
#include <map>
#include <vector>
#include "include/cef_base.h"
///

View File

@@ -39,7 +39,6 @@
#pragma once
#include <vector>
#include "include/cef_base.h"
#include "include/cef_callback.h"

View File

@@ -77,30 +77,21 @@ class CefDialogHandler : public virtual CefBaseRefCounted {
/// empty to show the default title ("Open" or "Save" depending on the mode).
/// |default_file_path| is the path with optional directory and/or file name
/// component that should be initially selected in the dialog.
/// |accept_filters| are used to restrict the selectable file types and may be
/// any combination of valid lower-cased MIME types (e.g. "text/*" or
/// "image/*") and individual file extensions (e.g. ".txt" or ".png").
/// |accept_extensions| provides the semicolon-delimited expansion of MIME
/// types to file extensions (if known, or empty string otherwise).
/// |accept_descriptions| provides the descriptions for MIME types (if known,
/// or empty string otherwise). For example, the "image/*" mime type might
/// have extensions ".png;.jpg;.bmp;..." and description "Image Files".
/// |accept_filters|, |accept_extensions| and |accept_descriptions| will all
/// be the same size. To display a custom dialog return true and execute
/// |callback| either inline or at a later time. To display the default dialog
/// return false. If this method returns false it may be called an additional
/// time for the same dialog (both before and after MIME type expansion).
/// |accept_filters| are used to restrict the selectable file types and may
/// any combination of (a) valid lower-cased MIME types (e.g. "text/*" or
/// "image/*"), (b) individual file extensions (e.g. ".txt" or ".png"), or (c)
/// combined description and file extension delimited using "|" and ";" (e.g.
/// "Image Types|.png;.gif;.jpg"). To display a custom dialog return true and
/// execute |callback| either inline or at a later time. To display the
/// default dialog return false.
///
/*--cef(optional_param=title,optional_param=default_file_path,
optional_param=accept_filters,optional_param=accept_extensions,
optional_param=accept_descriptions)--*/
optional_param=accept_filters)--*/
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
const std::vector<CefString>& accept_extensions,
const std::vector<CefString>& accept_descriptions,
CefRefPtr<CefFileDialogCallback> callback) {
return false;
}

View File

@@ -39,7 +39,6 @@
#pragma once
#include <map>
#include "include/cef_base.h"
class CefDOMDocument;

View File

@@ -106,19 +106,17 @@ class CefDownloadHandler : public virtual CefBaseRefCounted {
///
/// Called before a download begins. |suggested_name| is the suggested name
/// 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.
/// 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.
///
/*--cef()--*/
virtual bool OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback> callback) {
return false;
}
virtual void OnBeforeDownload(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback> callback) = 0;
///
/// Called when a download's status or progress information has been updated.

View File

@@ -39,7 +39,6 @@
#pragma once
#include <vector>
#include "include/cef_base.h"
#include "include/cef_image.h"
#include "include/cef_stream.h"

View File

@@ -48,8 +48,6 @@ 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:

View File

@@ -70,8 +70,6 @@ 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:

View File

@@ -39,7 +39,6 @@
#pragma once
#include <vector>
#include "include/cef_base.h"
#include "include/cef_callback.h"
#include "include/cef_registration.h"

View File

@@ -40,7 +40,6 @@
#include <map>
#include <vector>
#include "include/cef_base.h"
class CefPostData;

View File

@@ -266,8 +266,6 @@ 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,
@@ -279,8 +277,6 @@ 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;
@@ -290,8 +286,6 @@ 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;
@@ -301,8 +295,6 @@ 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;
@@ -311,8 +303,6 @@ 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;

View File

@@ -39,7 +39,6 @@
#pragma once
#include <map>
#include "include/cef_base.h"
///

View File

@@ -39,7 +39,6 @@
#pragma once
#include <map>
#include "include/cef_base.h"
#include "include/cef_callback.h"
#include "include/cef_request.h"

View File

@@ -40,6 +40,7 @@
#include "include/cef_base.h"
#include "include/cef_values.h"
#include "include/cef_x509_certificate.h"
///

View File

@@ -39,7 +39,6 @@
#pragma once
#include <vector>
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "include/cef_frame.h"
@@ -435,6 +434,7 @@ class CefV8ArrayBufferReleaseCallback : public virtual CefBaseRefCounted {
/*--cef(source=library,no_debugct_check)--*/
class CefV8Value : public virtual CefBaseRefCounted {
public:
typedef cef_v8_accesscontrol_t AccessControl;
typedef cef_v8_propertyattribute_t PropertyAttribute;
///
@@ -793,7 +793,9 @@ class CefV8Value : public virtual CefBaseRefCounted {
/// will return true even though assignment failed.
///
/*--cef(capi_name=set_value_byaccessor,optional_param=key)--*/
virtual bool SetValue(const CefString& key, PropertyAttribute attribute) = 0;
virtual bool SetValue(const CefString& key,
AccessControl settings,
PropertyAttribute attribute) = 0;
///
/// Read the keys for the object's values into the specified vector. Integer-

View File

@@ -39,7 +39,6 @@
#pragma once
#include <vector>
#include "include/cef_base.h"
class CefBinaryValue;

View File

@@ -70,7 +70,6 @@ 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;
}
};
@@ -111,7 +110,6 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
void SetAsWindowless(CefWindowHandle parent) {
windowless_rendering_enabled = true;
parent_window = parent;
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
}
};

View File

@@ -71,7 +71,6 @@ 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;
}
};
@@ -113,7 +112,6 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
void SetAsWindowless(CefWindowHandle parent) {
windowless_rendering_enabled = true;
parent_view = parent;
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
}
};

View File

@@ -235,14 +235,12 @@ typedef struct _cef_settings_t {
///
cef_string_t main_bundle_path;
#if !defined(DISABLE_ALLOY_BOOTSTRAP)
///
/// Set to true (1) to enable use of the Chrome runtime in CEF. This feature
/// is considered experimental and is not recommended for most users at this
/// time. See issue #2969 for details.
///
int chrome_runtime;
#endif
///
/// Set to true (1) to have the browser process message loop run in a separate
@@ -1239,6 +1237,16 @@ typedef enum {
CEF_TEXT_INPUT_MODE_MAX = CEF_TEXT_INPUT_MODE_SEARCH,
} cef_text_input_mode_t;
///
/// V8 access control values.
///
typedef enum {
V8_ACCESS_CONTROL_DEFAULT = 0,
V8_ACCESS_CONTROL_ALL_CAN_READ = 1,
V8_ACCESS_CONTROL_ALL_CAN_WRITE = 1 << 1,
V8_ACCESS_CONTROL_PROHIBITS_OVERWRITING = 1 << 2
} cef_v8_accesscontrol_t;
///
/// V8 property attribute values.
///
@@ -3463,18 +3471,18 @@ typedef enum {
CEF_CPAIT_COOKIE_CONTROLS,
CEF_CPAIT_FILE_SYSTEM_ACCESS,
CEF_CPAIT_FIND,
CEF_CPAIT_MEMORY_SAVER,
CEF_CPAIT_HIGH_EFFICIENCY,
CEF_CPAIT_INTENT_PICKER,
CEF_CPAIT_LOCAL_CARD_MIGRATION,
CEF_CPAIT_MANAGE_PASSWORDS,
CEF_CPAIT_PAYMENTS_OFFER_NOTIFICATION,
CEF_CPAIT_PRICE_TRACKING,
CEF_CPAIT_PWA_INSTALL,
CEF_CPAIT_QR_CODE_GENERATOR_DEPRECATED,
CEF_CPAIT_READER_MODE_DEPRECATED,
CEF_CPAIT_QR_CODE_GENERATOR,
CEF_CPAIT_READER_MODE,
CEF_CPAIT_SAVE_AUTOFILL_ADDRESS,
CEF_CPAIT_SAVE_CARD,
CEF_CPAIT_SEND_TAB_TO_SELF_DEPRECATED,
CEF_CPAIT_SEND_TAB_TO_SELF,
CEF_CPAIT_SHARING_HUB,
CEF_CPAIT_SIDE_SEARCH,
CEF_CPAIT_SMS_REMOTE_FETCHER,
@@ -3486,9 +3494,7 @@ typedef enum {
CEF_CPAIT_MANDATORY_REAUTH,
CEF_CPAIT_PRICE_INSIGHTS,
CEF_CPAIT_PRICE_READ_ANYTHING,
CEF_CPAIT_PRODUCT_SPECIFICATIONS,
CEF_CPAIT_LENS_OVERLAY,
CEF_CPAIT_MAX_VALUE = CEF_CPAIT_LENS_OVERLAY,
CEF_CPAIT_MAX_VALUE = CEF_CPAIT_PRICE_READ_ANYTHING,
} cef_chrome_page_action_icon_type_t;
///
@@ -3634,14 +3640,12 @@ typedef enum {
CEF_PERMISSION_TYPE_MIDI_SYSEX = 1 << 13,
CEF_PERMISSION_TYPE_MULTIPLE_DOWNLOADS = 1 << 14,
CEF_PERMISSION_TYPE_NOTIFICATIONS = 1 << 15,
CEF_PERMISSION_TYPE_KEYBOARD_LOCK = 1 << 16,
CEF_PERMISSION_TYPE_POINTER_LOCK = 1 << 17,
CEF_PERMISSION_TYPE_PROTECTED_MEDIA_IDENTIFIER = 1 << 18,
CEF_PERMISSION_TYPE_REGISTER_PROTOCOL_HANDLER = 1 << 19,
CEF_PERMISSION_TYPE_STORAGE_ACCESS = 1 << 20,
CEF_PERMISSION_TYPE_VR_SESSION = 1 << 21,
CEF_PERMISSION_TYPE_WINDOW_MANAGEMENT = 1 << 22,
CEF_PERMISSION_TYPE_FILE_SYSTEM_ACCESS = 1 << 23,
CEF_PERMISSION_TYPE_PROTECTED_MEDIA_IDENTIFIER = 1 << 16,
CEF_PERMISSION_TYPE_REGISTER_PROTOCOL_HANDLER = 1 << 17,
CEF_PERMISSION_TYPE_STORAGE_ACCESS = 1 << 18,
CEF_PERMISSION_TYPE_VR_SESSION = 1 << 19,
CEF_PERMISSION_TYPE_WINDOW_MANAGEMENT = 1 << 20,
CEF_PERMISSION_TYPE_FILE_SYSTEM_ACCESS = 1 << 21,
} cef_permission_request_types_t;
///

View File

@@ -380,13 +380,6 @@ 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,
@@ -435,15 +428,6 @@ 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;
///

View File

@@ -32,6 +32,7 @@
#pragma once
#include "include/base/cef_build.h"
#include "include/cef_config.h"
#if defined(OS_LINUX)
@@ -44,7 +45,6 @@ typedef struct _XDisplay XDisplay;
#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)
@@ -136,13 +136,6 @@ 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;
///

View File

@@ -37,7 +37,6 @@
#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*
@@ -138,13 +137,6 @@ 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;
///

View File

@@ -1,88 +0,0 @@
// 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_

View File

@@ -39,7 +39,6 @@
#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
@@ -105,13 +104,6 @@ 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;
///

View File

@@ -387,9 +387,7 @@ struct CefSettingsTraits {
&target->framework_dir_path, copy);
cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length,
&target->main_bundle_path, copy);
#if !defined(DISABLE_ALLOY_BOOTSTRAP)
target->chrome_runtime = src->chrome_runtime;
#endif
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
target->external_message_pump = src->external_message_pump;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;

View File

@@ -73,7 +73,6 @@ 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;
}
};
@@ -131,7 +130,6 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
void SetAsWindowless(CefWindowHandle parent) {
windowless_rendering_enabled = TRUE;
parent_window = parent;
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
}
};

View File

@@ -67,12 +67,4 @@ void CefExecuteJavaScriptWithUserGestureForTests(CefRefPtr<CefFrame> frame,
/*--cef()--*/
void CefSetDataDirectoryForTests(const CefString& dir);
///
/// Returns true if |feature_name| is enabled by default, command line or field
/// trial. This supports a short list of curated values that are queried by unit
/// tests.
///
/*--cef()--*/
bool CefIsFeatureEnabledForTests(const CefString& feature_name);
#endif // CEF_INCLUDE_TEST_CEF_TEST_HELPERS_H_

View File

@@ -49,7 +49,6 @@
#endif
#include <map>
#include "include/cef_base.h"
#include "include/cef_request.h"

View File

@@ -107,13 +107,6 @@ 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_

View File

@@ -140,15 +140,6 @@ 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_

View File

@@ -414,13 +414,6 @@ class CefWindow : public CefPanel {
///
/*--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_

View File

@@ -271,15 +271,6 @@ class CefWindowDelegate : public CefPanelDelegate {
/*--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_

View File

@@ -2,24 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_browser_context.h"
#include "libcef/browser/alloy/alloy_browser_context.h"
#include <map>
#include <memory>
#include <utility>
#include "libcef/browser/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"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "cef/libcef/browser/alloy/alloy_download_manager_delegate.h"
#include "cef/libcef/browser/extensions/extension_system.h"
#include "cef/libcef/browser/prefs/browser_prefs.h"
#include "cef/libcef/browser/ssl_host_state_delegate.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/cef_switches.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "chrome/browser/font_family_cache.h"
#include "chrome/browser/permissions/permission_manager_factory.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
@@ -194,10 +195,6 @@ void AlloyBrowserContext::Shutdown() {
ChromePluginServiceFilter::GetInstance()->UnregisterProfile(this);
// Clear this reference before the associated KeyedServiceFactory is destroyed
// by PerformInterlockedTwoPhaseShutdown().
extension_system_ = nullptr;
// Remove any BrowserContextKeyedServiceFactory associations. This must be
// called before the ProxyService owned by AlloyBrowserContext is destroyed.
// The SimpleDependencyManager should always be passed after the
@@ -300,6 +297,15 @@ 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;
@@ -339,7 +345,7 @@ content::DownloadManagerDelegate*
AlloyBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_) {
download_manager_delegate_ =
std::make_unique<AlloyDownloadManagerDelegate>(GetDownloadManager());
std::make_unique<CefDownloadManagerDelegate>(GetDownloadManager());
}
return download_manager_delegate_.get();
}
@@ -432,11 +438,6 @@ AlloyBrowserContext::GetProfileCloudPolicyManager() {
return nullptr;
}
policy::CloudPolicyManager* AlloyBrowserContext::GetCloudPolicyManager() {
DCHECK(false);
return nullptr;
}
policy::ProfilePolicyConnector*
AlloyBrowserContext::GetProfilePolicyConnector() {
DCHECK(false);
@@ -460,12 +461,6 @@ 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_) {
@@ -474,13 +469,6 @@ DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() {
return download_prefs_.get();
}
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);
}
void AlloyBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
visitedlink_master_->AddURLs(urls);
}

View File

@@ -6,16 +6,16 @@
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_
#pragma once
#include "base/memory/raw_ptr.h"
#include "cef/include/cef_request_context_handler.h"
#include "cef/libcef/browser/alloy/chrome_profile_alloy.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/request_context_handler_map.h"
#include "include/cef_request_context_handler.h"
#include "libcef/browser/alloy/chrome_profile_alloy.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/request_context_handler_map.h"
#include "chrome/browser/download/download_prefs.h"
#include "components/proxy_config/pref_proxy_config_tracker.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
class AlloyDownloadManagerDelegate;
class CefDownloadManagerDelegate;
class CefSSLHostStateDelegate;
class CefVisitedLinkListener;
class PrefService;
@@ -56,9 +56,7 @@ 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;
void AddVisitedURLs(const GURL& url,
const std::vector<GURL>& redirect_chain,
ui::PageTransition transition) override;
bool IsPrintPreviewSupported() const override;
// content::BrowserContext overrides.
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
@@ -94,7 +92,6 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
policy::SchemaRegistryService* GetPolicySchemaRegistryService() override;
policy::UserCloudPolicyManager* GetUserCloudPolicyManager() override;
policy::ProfileCloudPolicyManager* GetProfileCloudPolicyManager() override;
policy::CloudPolicyManager* GetCloudPolicyManager() override;
policy::ProfilePolicyConnector* GetProfilePolicyConnector() override;
const policy::ProfilePolicyConnector* GetProfilePolicyConnector()
const override;
@@ -111,16 +108,17 @@ 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 DownloadPrefs::FromBrowserContext via
// alloy::GetDownloadPrefsFromBrowserContext.
// Called from AlloyBrowserHostImpl::DidFinishNavigation to update the table
// of visited links.
void AddVisitedURLs(const std::vector<GURL>& urls);
// Called from DownloadPrefs::FromBrowserContext.
DownloadPrefs* GetDownloadPrefs();
private:
@@ -129,14 +127,14 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
std::unique_ptr<PrefService> pref_service_;
std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
std::unique_ptr<AlloyDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<CefDownloadManagerDelegate> 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_.
raw_ptr<CefVisitedLinkListener> visitedlink_listener_ = nullptr;
CefVisitedLinkListener* visitedlink_listener_ = nullptr;
// Owned by the KeyedService system.
raw_ptr<extensions::CefExtensionSystem> extension_system_ = nullptr;
extensions::CefExtensionSystem* extension_system_ = nullptr;
// The key to index KeyedService instances created by
// SimpleKeyedServiceFactory.

View File

@@ -3,35 +3,37 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include <memory>
#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"
#include "libcef/browser/browser_info.h"
#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/hang_monitor.h"
#include "libcef/browser/media_access_query.h"
#include "libcef/browser/osr/osr_util.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/drag_data_impl.h"
#include "libcef/common/frame_util.h"
#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 "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "cef/libcef/browser/alloy/browser_platform_delegate_alloy.h"
#include "cef/libcef/browser/audio_capturer.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/browser_info.h"
#include "cef/libcef/browser/browser_info_manager.h"
#include "cef/libcef/browser/browser_platform_delegate.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/extensions/browser_extensions_util.h"
#include "cef/libcef/browser/hang_monitor.h"
#include "cef/libcef/browser/media_access_query.h"
#include "cef/libcef/browser/osr/osr_util.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/cef_switches.h"
#include "cef/libcef/common/drag_data_impl.h"
#include "cef/libcef/common/frame_util.h"
#include "cef/libcef/common/net/url_util.h"
#include "cef/libcef/common/request_impl.h"
#include "cef/libcef/common/values_impl.h"
#include "cef/libcef/features/runtime.h"
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h"
#include "components/zoom/page_zoom.h"
@@ -49,13 +51,10 @@
#include "content/public/common/input/native_web_keyboard_event.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "net/base/net_errors.h"
#include "ui/events/base_event_utils.h"
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
#include "extensions/common/extension.h"
#endif
using content::KeyboardEventProcessingResult;
namespace {
@@ -74,19 +73,11 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
CefBrowserPlatformDelegate::Create(create_params);
CHECK(platform_delegate);
// Expect runtime style to match.
CHECK(platform_delegate->IsAlloyStyle());
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
const bool is_devtools_popup = !!create_params.devtools_opener;
#else
const bool is_devtools_popup = false;
#endif
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;
@@ -98,7 +89,6 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
auto request_context_impl =
static_cast<CefRequestContextImpl*>(create_params.request_context.get());
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
CefRefPtr<CefExtension> cef_extension;
if (create_params.extension) {
auto cef_browser_context = request_context_impl->GetBrowserContext();
@@ -106,39 +96,25 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
cef_browser_context->GetExtension(create_params.extension->id());
CHECK(cef_extension);
}
#endif
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
auto platform_delegate_ptr = platform_delegate.get();
#endif
CefRefPtr<AlloyBrowserHostImpl> browser = CreateInternal(
create_params.settings, create_params.client, web_contents,
own_web_contents, info,
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
FromBaseChecked(create_params.devtools_opener),
#else
/*opener=*/nullptr,
#endif
is_devtools_popup, request_context_impl, std::move(platform_delegate)
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
cef_extension
#endif
);
static_cast<AlloyBrowserHostImpl*>(create_params.devtools_opener.get()),
is_devtools_popup, request_context_impl, std::move(platform_delegate),
cef_extension);
if (!browser) {
return nullptr;
}
GURL url = url_util::MakeGURL(create_params.url, /*fixup=*/true);
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
if (create_params.extension) {
platform_delegate_ptr->CreateExtensionHost(
create_params.extension, url, create_params.extension_host_type);
} else
#endif
if (!url.is_empty()) {
} else if (!url.is_empty()) {
content::OpenURLParams params(url, content::Referrer(),
WindowOpenDisposition::CURRENT_TAB,
CefFrameHostImpl::kPageTransitionExplicit,
@@ -159,12 +135,8 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
CefRefPtr<AlloyBrowserHostImpl> opener,
bool is_devtools_popup,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
CefRefPtr<CefExtension> extension
#endif
) {
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension) {
CEF_REQUIRE_UIT();
DCHECK(web_contents);
DCHECK(browser_info);
@@ -195,12 +167,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
CefRefPtr<AlloyBrowserHostImpl> browser = new AlloyBrowserHostImpl(
settings, client, web_contents, browser_info, opener, request_context,
std::move(platform_delegate)
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
extension
#endif
);
std::move(platform_delegate), extension);
browser->InitializeBrowser();
if (!browser->CreateHostWindow()) {
@@ -214,8 +181,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->platform_delegate(), browser.get(), is_devtools_popup);
opener->platform_delegate_->PopupBrowserCreated(browser.get(),
is_devtools_popup);
}
// 2. Notify the browser's LifeSpanHandler. This must always be the first
@@ -233,38 +200,36 @@ 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) {
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
REQUIRE_ALLOY_RUNTIME();
auto browser = CefBrowserHostBase::GetBrowserForHost(host);
return static_cast<AlloyBrowserHostImpl*>(browser.get());
}
// static
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForHost(
const content::RenderFrameHost* host) {
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
REQUIRE_ALLOY_RUNTIME();
auto browser = CefBrowserHostBase::GetBrowserForHost(host);
return static_cast<AlloyBrowserHostImpl*>(browser.get());
}
// static
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForContents(
const content::WebContents* contents) {
return FromBaseChecked(CefBrowserHostBase::GetBrowserForContents(contents));
REQUIRE_ALLOY_RUNTIME();
auto browser = CefBrowserHostBase::GetBrowserForContents(contents);
return static_cast<AlloyBrowserHostImpl*>(browser.get());
}
// static
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForGlobalId(
const content::GlobalRenderFrameHostId& global_id) {
return FromBaseChecked(CefBrowserHostBase::GetBrowserForGlobalId(global_id));
REQUIRE_ALLOY_RUNTIME();
auto browser = CefBrowserHostBase::GetBrowserForGlobalId(global_id);
return static_cast<AlloyBrowserHostImpl*>(browser.get());
}
// AlloyBrowserHostImpl methods.
@@ -368,6 +333,42 @@ 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) {
@@ -383,7 +384,6 @@ void AlloyBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
}
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
CefRefPtr<CefExtension> AlloyBrowserHostImpl::GetExtension() {
return extension_;
}
@@ -391,7 +391,6 @@ CefRefPtr<CefExtension> AlloyBrowserHostImpl::GetExtension() {
bool AlloyBrowserHostImpl::IsBackgroundHost() {
return is_background_host_;
}
#endif
bool AlloyBrowserHostImpl::CanExecuteChromeCommand(int command_id) {
return false;
@@ -581,6 +580,17 @@ void AlloyBrowserHostImpl::DestroyBrowser() {
destruction_state_ = DESTRUCTION_STATE_COMPLETED;
// Notify that this browser has been destroyed. These must be delivered in
// the expected order.
// 1. Notify the platform delegate. With Views this will result in a call to
// CefBrowserViewDelegate::OnBrowserDestroyed().
platform_delegate_->NotifyBrowserDestroyed();
// 2. Notify the browser's LifeSpanHandler. This must always be the last
// notification for this browser.
OnBeforeClose();
// Destroy any platform constructs first.
if (javascript_dialog_manager_.get()) {
javascript_dialog_manager_->Destroy();
@@ -589,8 +599,16 @@ void AlloyBrowserHostImpl::DestroyBrowser() {
menu_manager_->Destroy();
}
// Disassociate the platform delegate from this browser. This will trigger
// WebContents destruction in most cases.
// Notify any observers that may have state associated with this browser.
OnBrowserDestroyed();
// If the WebContents still exists at this point, signal destruction before
// browser destruction.
if (web_contents()) {
WebContentsDestroyed();
}
// Disassociate the platform delegate from this browser.
platform_delegate_->BrowserDestroyed(this);
// Delete objects created by the platform delegate that may be referenced by
@@ -618,9 +636,8 @@ 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)) {
@@ -632,7 +649,7 @@ bool AlloyBrowserHostImpl::MaybeAllowNavigation(
CEF_POST_TASK(CEF_UIT,
base::BindOnce(
base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
this, nullptr, params, base::NullCallback()));
this, nullptr, params));
return false;
}
@@ -640,13 +657,11 @@ bool AlloyBrowserHostImpl::MaybeAllowNavigation(
return true;
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
extensions::ExtensionHost* AlloyBrowserHostImpl::GetExtensionHost() const {
CEF_REQUIRE_UIT();
DCHECK(platform_delegate_);
return platform_delegate_->GetExtensionHost();
}
#endif
void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
if (!CEF_CURRENTLY_ON_UIT()) {
@@ -942,11 +957,8 @@ bool AlloyBrowserHostImpl::IsAudioMuted() {
content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>
navigation_handle_callback) {
auto target_contents = contents_delegate_->OpenURLFromTabEx(
source, params, navigation_handle_callback);
const content::OpenURLParams& params) {
auto target_contents = contents_delegate_->OpenURLFromTab(source, params);
if (target_contents) {
// Start a navigation in the current browser that will result in the
// creation of a new render process.
@@ -958,13 +970,11 @@ content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
return nullptr;
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool AlloyBrowserHostImpl::ShouldAllowRendererInitiatedCrossProcessNavigation(
bool is_main_frame_navigation) {
return platform_delegate_->ShouldAllowRendererInitiatedCrossProcessNavigation(
is_main_frame_navigation);
}
#endif
void AlloyBrowserHostImpl::AddNewContents(
content::WebContents* source,
@@ -1106,13 +1116,11 @@ bool AlloyBrowserHostImpl::HandleKeyboardEvent(
return false;
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool AlloyBrowserHostImpl::PreHandleGestureEvent(
content::WebContents* source,
const blink::WebGestureEvent& event) {
return platform_delegate_->PreHandleGestureEvent(source, event);
}
#endif
bool AlloyBrowserHostImpl::CanDragEnter(content::WebContents* source,
const content::DropData& data,
@@ -1167,8 +1175,7 @@ void AlloyBrowserHostImpl::WebContentsCreated(
scoped_refptr<CefBrowserInfo> info =
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
new_contents, platform_delegate->IsWindowless(),
platform_delegate->IsPrintPreviewSupported(), extra_info);
new_contents, platform_delegate->IsWindowless(), extra_info);
CHECK(info.get());
CHECK(info->is_popup());
@@ -1184,14 +1191,10 @@ void AlloyBrowserHostImpl::WebContentsCreated(
// We don't officially own |new_contents| until AddNewContents() is called.
// However, we need to install observers/delegates here.
CefRefPtr<AlloyBrowserHostImpl> browser = CreateInternal(
settings, client, new_contents, /*own_web_contents=*/false, info, opener,
/*is_devtools_popup=*/false, request_context, std::move(platform_delegate)
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
/*extension=*/nullptr
#endif
);
CefRefPtr<AlloyBrowserHostImpl> browser =
CreateInternal(settings, client, new_contents, /*own_web_contents=*/false,
info, opener, /*is_devtools_popup=*/false, request_context,
std::move(platform_delegate), /*extension=*/nullptr);
}
void AlloyBrowserHostImpl::RendererUnresponsive(
@@ -1210,7 +1213,11 @@ void AlloyBrowserHostImpl::RendererResponsive(
content::JavaScriptDialogManager*
AlloyBrowserHostImpl::GetJavaScriptDialogManager(content::WebContents* source) {
return CefBrowserHostBase::GetJavaScriptDialogManager();
if (!javascript_dialog_manager_) {
javascript_dialog_manager_ =
std::make_unique<CefJavaScriptDialogManager>(this);
}
return javascript_dialog_manager_.get();
}
void AlloyBrowserHostImpl::RunFileChooser(
@@ -1275,12 +1282,10 @@ bool AlloyBrowserHostImpl::CheckMediaAccessPermission(
security_origin, type);
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool AlloyBrowserHostImpl::IsNeverComposited(
content::WebContents* web_contents) {
return platform_delegate_->IsNeverComposited(web_contents);
}
#endif
content::PictureInPictureResult AlloyBrowserHostImpl::EnterPictureInPicture(
content::WebContents* web_contents) {
@@ -1298,12 +1303,8 @@ void AlloyBrowserHostImpl::ExitPictureInPicture() {
}
bool AlloyBrowserHostImpl::IsBackForwardCacheSupported() {
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
return true;
#else
// Disabled with Alloy bootstrap due to issue #3237.
return cef::IsChromeRuntimeEnabled();
#endif
// Disabled due to issue #3237.
return false;
}
content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
@@ -1311,24 +1312,17 @@ 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 = CefBrowserContext::FromBrowserContext(
web_contents()->GetBrowserContext());
auto cef_browser_context =
static_cast<AlloyBrowserContext*>(web_contents()->GetBrowserContext());
if (cef_browser_context) {
cef_browser_context->AddVisitedURLs(
navigation_handle->GetURL(), navigation_handle->GetRedirectChain(),
navigation_handle->GetPageTransition());
navigation_handle->GetRedirectChain());
}
}
}
@@ -1361,46 +1355,34 @@ void AlloyBrowserHostImpl::OnRecentlyAudibleTimerFired() {
}
void AlloyBrowserHostImpl::AccessibilityEventReceived(
const ui::AXUpdatesAndEvents& details) {
const content::AXEventNotificationDetails& content_event_bundle) {
// Only needed in windowless mode.
if (IsWindowless()) {
if (!web_contents() || !platform_delegate_) {
return;
}
platform_delegate_->AccessibilityEventReceived(details);
platform_delegate_->AccessibilityEventReceived(content_event_bundle);
}
}
void AlloyBrowserHostImpl::AccessibilityLocationChangesReceived(
const std::vector<ui::AXLocationChanges>& details) {
const std::vector<content::AXLocationChangeNotificationDetails>& locData) {
// Only needed in windowless mode.
if (IsWindowless()) {
if (!web_contents() || !platform_delegate_) {
return;
}
platform_delegate_->AccessibilityLocationChangesReceived(details);
platform_delegate_->AccessibilityLocationChangesReceived(locData);
}
}
void AlloyBrowserHostImpl::WebContentsDestroyed() {
// In case we're notified before the CefBrowserContentsDelegate,
// reset it first for consistent state in DestroyWebContents.
if (GetWebContents()) {
contents_delegate_->WebContentsDestroyed();
}
auto wc = web_contents();
content::WebContentsObserver::Observe(nullptr);
DestroyWebContents(wc);
if (destruction_state_ < DESTRUCTION_STATE_COMPLETED) {
// We were not called via DestroyBrowser. This can occur when (for example)
// a pending popup WebContents is destroyed during parent WebContents
// destruction. Try to close the associated browser now.
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::CloseBrowser,
this, /*force_close=*/true));
if (platform_delegate_) {
platform_delegate_->WebContentsDestroyed(wc);
}
}
@@ -1437,12 +1419,8 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<AlloyBrowserHostImpl> opener,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
CefRefPtr<CefExtension> extension
#endif
)
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension)
: CefBrowserHostBase(settings,
client,
std::move(platform_delegate),
@@ -1450,12 +1428,8 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
request_context),
content::WebContentsObserver(web_contents),
opener_(kNullWindowHandle),
is_windowless_(platform_delegate_->IsWindowless())
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
extension_(extension)
#endif
{
is_windowless_(platform_delegate_->IsWindowless()),
extension_(extension) {
contents_delegate_->ObserveWebContents(web_contents);
if (opener.get() && !is_views_hosted_) {

View File

@@ -11,22 +11,21 @@
#include <string>
#include <vector>
#include "include/cef_browser.h"
#include "include/cef_client.h"
#include "include/cef_frame.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/javascript_dialog_manager.h"
#include "libcef/browser/menu_manager.h"
#include "libcef/browser/request_context_impl.h"
#include "base/synchronization/lock.h"
#include "cef/include/cef_browser.h"
#include "cef/include/cef_client.h"
#include "cef/include/cef_frame.h"
#include "cef/libcef/browser/browser_host_base.h"
#include "cef/libcef/browser/browser_info.h"
#include "cef/libcef/browser/frame_host_impl.h"
#include "cef/libcef/browser/menu_manager.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
#include "extensions/common/mojom/view_type.mojom-forward.h"
#endif
class CefAudioCapturer;
class CefBrowserInfo;
@@ -63,11 +62,6 @@ 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);
@@ -91,6 +85,8 @@ 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;
@@ -124,17 +120,15 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
CefRefPtr<CefExtension> GetExtension() override;
bool IsBackgroundHost() override;
#endif
bool CanExecuteChromeCommand(int command_id) override;
void ExecuteChromeCommand(int command_id,
cef_window_open_disposition_t disposition) override;
// CefBrowserHostBase methods:
// Returns true if windowless rendering is enabled.
bool IsWindowless() const override;
bool IsAlloyStyle() const override { return true; }
bool IsVisible() const override;
// Returns true if this browser supports picture-in-picture.
@@ -153,6 +147,7 @@ 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
@@ -169,10 +164,8 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void UpdateDragOperation(ui::mojom::DragOperation operation,
bool document_is_handling_drag);
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
// Accessors that must be called on the UI thread.
extensions::ExtensionHost* GetExtensionHost() const;
#endif
void OnSetFocus(cef_focus_source_t source) override;
@@ -189,13 +182,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
// content::WebContentsDelegate methods.
content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>
navigation_handle_callback) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
const content::OpenURLParams& params) override;
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
bool is_main_frame_navigation) override;
#endif
void AddNewContents(content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
@@ -226,10 +215,8 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
bool HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) override;
#endif
bool CanDragEnter(content::WebContents* source,
const content::DropData& data,
blink::DragOperationsMask operations_allowed) override;
@@ -283,18 +270,13 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const url::Origin& security_origin,
blink::mojom::MediaStreamType type) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool IsNeverComposited(content::WebContents* web_contents) override;
#endif
content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents) override;
void ExitPictureInPicture() override;
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;
@@ -302,11 +284,16 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
content::NavigationHandle* navigation_handle) override;
void OnAudioStateChanged(bool audible) override;
void AccessibilityEventReceived(
const ui::AXUpdatesAndEvents& details) override;
const content::AXEventNotificationDetails& content_event_bundle) override;
void AccessibilityLocationChangesReceived(
const std::vector<ui::AXLocationChanges>& details) override;
const std::vector<content::AXLocationChangeNotificationDetails>& locData)
override;
void WebContentsDestroyed() override;
protected:
void ShowDevToolsOnUIThread(
std::unique_ptr<CefShowDevToolsParams> params) override;
private:
friend class CefBrowserPlatformDelegateAlloy;
@@ -319,12 +306,8 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
CefRefPtr<AlloyBrowserHostImpl> opener,
bool is_devtools_popup,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
CefRefPtr<CefExtension> extension
#endif
);
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension);
AlloyBrowserHostImpl(
const CefBrowserSettings& settings,
@@ -333,12 +316,8 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<AlloyBrowserHostImpl> opener,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
CefRefPtr<CefExtension> extension
#endif
);
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension);
// Give the platform delegate an opportunity to create the host window.
bool CreateHostWindow();
@@ -349,10 +328,8 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
CefWindowHandle opener_;
const bool is_windowless_;
CefWindowHandle host_window_handle_ = kNullWindowHandle;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
CefRefPtr<CefExtension> extension_;
bool is_background_host_ = false;
#endif
// Represents the current browser destruction state. Only accessed on the UI
// thread.
@@ -362,6 +339,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
// on the UI thread.
bool window_destroyed_ = false;
// Used for creating and managing JavaScript dialogs.
std::unique_ptr<CefJavaScriptDialogManager> javascript_dialog_manager_;
// Used for creating and managing context menus.
std::unique_ptr<CefMenuManager> menu_manager_;

View File

@@ -2,31 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_browser_main.h"
#include "libcef/browser/alloy/alloy_browser_main.h"
#include <stdint.h>
#include <memory>
#include <string>
#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"
#include "libcef/browser/permission_prompt.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/command_line_impl.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net/net_resource_provider.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/thread_pool.h"
#include "cef/libcef/browser/alloy/devtools/devtools_manager_delegate.h"
#include "cef/libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/browser_context_keyed_service_factories.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/extensions/extension_system_factory.h"
#include "cef/libcef/browser/file_dialog_runner.h"
#include "cef/libcef/browser/net/chrome_scheme_handler.h"
#include "cef/libcef/browser/permission_prompt.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/app_manager.h"
#include "cef/libcef/common/command_line_impl.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "cef/libcef/common/net/net_resource_provider.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_process_singleton.h"
#include "chrome/browser/media/router/chrome_media_router_factory.h"
@@ -50,7 +51,6 @@
#include "ui/native_theme/native_theme.h"
#if BUILDFLAG(IS_LINUX)
#include "components/password_manager/core/browser/password_manager_switches.h"
#include "ui/base/ozone_buildflags.h"
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
#include "ui/events/devices/x11/touch_factory_x11.h"
@@ -90,11 +90,11 @@
#if BUILDFLAG(IS_LINUX)
#include "base/path_service.h"
#include "cef/libcef/browser/printing/print_dialog_linux.h"
#include "chrome/browser/themes/theme_service_aura_linux.h"
#include "chrome/browser/ui/views/theme_profile_key.h"
#include "chrome/grit/branded_strings.h"
#include "components/os_crypt/sync/key_storage_config_linux.h"
#include "libcef/browser/printing/print_dialog_linux.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/l10n/l10n_util.h"
@@ -191,8 +191,7 @@ AlloyBrowserMainParts::~AlloyBrowserMainParts() {
}
void AlloyBrowserMainParts::ToolkitInitialized() {
SetConstrainedWindowViewsClient(
CreateAlloyConstrainedWindowViewsClient(nullptr));
SetConstrainedWindowViewsClient(CreateAlloyConstrainedWindowViewsClient());
#if defined(USE_AURA)
CHECK(aura::Env::GetInstance());
@@ -284,13 +283,12 @@ void AlloyBrowserMainParts::PostCreateMainMessageLoop() {
std::unique_ptr<os_crypt::Config> config =
std::make_unique<os_crypt::Config>();
// Forward to os_crypt the flag to use a specific password store.
config->store =
command_line->GetSwitchValueASCII(password_manager::kPasswordStore);
// Forward the product name
config->store = command_line->GetSwitchValueASCII(switches::kPasswordStore);
// Forward the product name (defaults to "Chromium").
config->product_name = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
// OSCrypt can be disabled in a special settings file.
config->should_use_preference =
command_line->HasSwitch(password_manager::kEnableEncryptionSelection);
command_line->HasSwitch(switches::kEnableEncryptionSelection);
base::PathService::Get(chrome::DIR_USER_DATA, &config->user_data_path);
DCHECK(!config->user_data_path.empty());
OSCrypt::SetConfig(std::move(config));

View File

@@ -6,12 +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/memory/raw_ptr.h"
#include "base/strings/string_piece.h"
#include "build/build_config.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_main_parts.h"
#include "ui/display/screen.h"
@@ -80,7 +79,7 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
#endif // BUILDFLAG(IS_WIN)
CefRefPtr<CefRequestContextImpl> global_request_context_;
raw_ptr<CefDevToolsDelegate> devtools_delegate_ = nullptr; // Deletes itself.
CefDevToolsDelegate* devtools_delegate_ = nullptr; // Deletes itself.
// Blocking task runners exposed via CefTaskRunner. For consistency with
// previous named thread behavior always execute all pending tasks before

View File

@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_browser_main.h"
#include <Objbase.h>
#include <commctrl.h>
#include <windows.h>
#include <commctrl.h>
#include "libcef/browser/alloy/alloy_browser_main.h"
#include "base/logging.h"

View File

@@ -2,12 +2,48 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include <algorithm>
#include <tuple>
#include <utility>
#include "include/cef_version.h"
#include "libcef/browser/alloy/alloy_browser_context.h"
#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/browser_context.h"
#include "libcef/browser/browser_frame.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_manager.h"
#include "libcef/browser/browser_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"
#include "libcef/browser/net/chrome_scheme_handler.h"
#include "libcef/browser/net/throttle_handler.h"
#include "libcef/browser/net_service/cookie_manager_impl.h"
#include "libcef/browser/net_service/login_delegate.h"
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
#include "libcef/browser/prefs/renderer_prefs.h"
#include "libcef/browser/speech_recognition_manager_delegate.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/x509_certificate_impl.h"
#include "libcef/common/alloy/alloy_content_client.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/command_line_impl.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/frame_util.h"
#include "libcef/common/net/scheme_registration.h"
#include "libcef/common/request_impl.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
@@ -16,41 +52,6 @@
#include "base/stl_util.h"
#include "base/threading/thread_restrictions.h"
#include "cef/grit/cef_resources.h"
#include "cef/include/cef_version.h"
#include "cef/libcef/browser/alloy/alloy_browser_context.h"
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "cef/libcef/browser/alloy/alloy_browser_main.h"
#include "cef/libcef/browser/alloy/alloy_web_contents_view_delegate.h"
#include "cef/libcef/browser/alloy/devtools/devtools_manager_delegate.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/browser_frame.h"
#include "cef/libcef/browser/browser_info.h"
#include "cef/libcef/browser/browser_info_manager.h"
#include "cef/libcef/browser/browser_manager.h"
#include "cef/libcef/browser/browser_platform_delegate.h"
#include "cef/libcef/browser/certificate_query.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/extensions/extension_system.h"
#include "cef/libcef/browser/extensions/extension_web_contents_observer.h"
#include "cef/libcef/browser/media_capture_devices_dispatcher.h"
#include "cef/libcef/browser/net/chrome_scheme_handler.h"
#include "cef/libcef/browser/net/throttle_handler.h"
#include "cef/libcef/browser/net_service/cookie_manager_impl.h"
#include "cef/libcef/browser/net_service/login_delegate.h"
#include "cef/libcef/browser/net_service/proxy_url_loader_factory.h"
#include "cef/libcef/browser/net_service/resource_request_handler_wrapper.h"
#include "cef/libcef/browser/prefs/renderer_prefs.h"
#include "cef/libcef/browser/speech_recognition_manager_delegate.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/browser/x509_certificate_impl.h"
#include "cef/libcef/common/alloy/alloy_content_client.h"
#include "cef/libcef/common/app_manager.h"
#include "cef/libcef/common/cef_switches.h"
#include "cef/libcef/common/command_line_impl.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "cef/libcef/common/frame_util.h"
#include "cef/libcef/common/net/scheme_registration.h"
#include "cef/libcef/common/request_impl.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/extensions/chrome_content_browser_client_extensions_part.h"
@@ -91,7 +92,6 @@
#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"
@@ -160,10 +160,10 @@
#include "net/ssl/client_cert_store_mac.h"
#include "services/video_capture/public/mojom/constants.mojom.h"
#elif BUILDFLAG(IS_POSIX)
#include "cef/libcef/common/crash_reporting.h"
#include "components/crash/core/app/crash_switches.h"
#include "components/crash/core/app/crashpad.h"
#include "content/public/common/content_descriptors.h"
#include "libcef/common/crash_reporting.h"
#endif
#if BUILDFLAG(IS_WIN)
@@ -384,10 +384,6 @@ AlloyContentBrowserClient::AlloyContentBrowserClient() = default;
AlloyContentBrowserClient::~AlloyContentBrowserClient() = default;
void AlloyContentBrowserClient::CleanupOnUIThread() {
browser_main_parts_ = nullptr;
}
std::unique_ptr<content::BrowserMainParts>
AlloyContentBrowserClient::CreateBrowserMainParts(
bool /* is_integration_test */) {
@@ -453,7 +449,7 @@ bool AlloyContentBrowserClient::DoesSiteRequireDedicatedProcess(
}
bool AlloyContentBrowserClient::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
std::string_view scheme,
base::StringPiece 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
@@ -474,7 +470,7 @@ bool AlloyContentBrowserClient::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
bool AlloyContentBrowserClient::
ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
std::string_view scheme,
base::StringPiece scheme,
bool is_embedded_origin_secure) {
return is_embedded_origin_secure && scheme == content::kChromeUIScheme;
}
@@ -629,6 +625,10 @@ 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 +917,10 @@ void AlloyContentBrowserClient::
},
&render_frame_host));
associated_registry.AddInterface<pdf::mojom::PdfHost>(base::BindRepeating(
associated_registry.AddInterface<pdf::mojom::PdfService>(base::BindRepeating(
[](content::RenderFrameHost* render_frame_host,
mojo::PendingAssociatedReceiver<pdf::mojom::PdfHost> receiver) {
pdf::PDFDocumentHelper::BindPdfHost(
mojo::PendingAssociatedReceiver<pdf::mojom::PdfService> receiver) {
pdf::PDFDocumentHelper::BindPdfService(
std::move(receiver), render_frame_host,
std::make_unique<ChromePDFDocumentHelperClient>());
},
@@ -1183,7 +1183,6 @@ 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,

View File

@@ -9,11 +9,11 @@
#include <string>
#include <utility>
#include "base/memory/raw_ptr.h"
#include "include/cef_request_context_handler.h"
#include "libcef/browser/request_context_impl.h"
#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "cef/include/cef_request_context_handler.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/web_contents.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -34,8 +34,6 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
AlloyContentBrowserClient();
~AlloyContentBrowserClient() override;
void CleanupOnUIThread();
// ContentBrowserClient implementation.
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
bool is_integration_test) override;
@@ -47,10 +45,10 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context,
const GURL& effective_site_url) override;
bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
std::string_view scheme,
base::StringPiece scheme,
bool is_embedded_origin_secure) override;
bool ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
std::string_view scheme,
base::StringPiece scheme,
bool is_embedded_origin_secure) override;
void OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
@@ -188,7 +186,6 @@ 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,
@@ -281,7 +278,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
const extensions::Extension* GetExtension(
content::SiteInstance* site_instance);
raw_ptr<AlloyBrowserMainParts> browser_main_parts_ = nullptr;
AlloyBrowserMainParts* browser_main_parts_ = nullptr;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_

View File

@@ -1,22 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/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);
}

View File

@@ -1,26 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
#pragma once
#include "cef/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_

View File

@@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_download_util.h"
#include "libcef/browser/alloy/alloy_download_util.h"
#include "cef/libcef/browser/alloy/alloy_browser_context.h"
#include "libcef/browser/alloy/alloy_browser_context.h"
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();
}

View File

@@ -6,8 +6,6 @@
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_UTIL_H_
#pragma once
#include "cef/libcef/features/features.h"
class DownloadPrefs;
namespace content {

View File

@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_web_contents_view_delegate.h"
#include "libcef/browser/alloy/alloy_web_contents_view_delegate.h"
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "content/public/browser/web_contents.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
AlloyWebContentsViewDelegate::AlloyWebContentsViewDelegate(
content::WebContents* web_contents)
: web_contents_(web_contents) {}

View File

@@ -6,8 +6,8 @@
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_
#pragma once
#include "base/memory/raw_ptr.h"
#include "cef/include/internal/cef_ptr.h"
#include "include/internal/cef_ptr.h"
#include "content/public/browser/web_contents_view_delegate.h"
namespace content {
@@ -27,7 +27,7 @@ class AlloyWebContentsViewDelegate : public content::WebContentsViewDelegate {
const content::ContextMenuParams& params) override;
private:
const raw_ptr<content::WebContents> web_contents_;
content::WebContents* const web_contents_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_

View File

@@ -2,66 +2,42 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/browser_platform_delegate_alloy.h"
#include "libcef/browser/alloy/browser_platform_delegate_alloy.h"
#include <memory>
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/extensions/extension_background_host.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/extensions/extension_view_host.h"
#include "libcef/browser/extensions/extension_web_contents_observer.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net/url_util.h"
#include "libcef/features/runtime_checks.h"
#include "base/logging.h"
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "cef/libcef/browser/extensions/extension_background_host.h"
#include "cef/libcef/browser/extensions/extension_system.h"
#include "cef/libcef/browser/extensions/extension_view_host.h"
#include "cef/libcef/browser/extensions/extension_web_contents_observer.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "cef/libcef/common/net/url_util.h"
#include "cef/libcef/features/features.h"
#include "chrome/browser/task_manager/web_contents_tags.h"
#include "chrome/browser/ui/tab_helpers.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "components/find_in_page/find_tab_helper.h"
#include "components/find_in_page/find_types.h"
#include "components/performance_manager/embedder/performance_manager_registry.h"
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
#include "components/permissions/permission_request_manager.h"
#include "components/zoom/zoom_controller.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/public/browser/render_view_host.h"
#include "extensions/browser/process_manager.h"
#include "pdf/pdf_features.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
#include "cef/libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h"
#include "cef/libcef/features/runtime_checks.h"
#include "chrome/browser/printing/printing_init.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
#include "components/permissions/permission_request_manager.h"
#include "components/zoom/zoom_controller.h"
#include "extensions/browser/extension_registry.h"
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
namespace {
const char kAttachedHelpersUserDataKey[] = "CefAttachedHelpers";
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
const extensions::Extension* GetExtensionForUrl(
content::BrowserContext* browser_context,
const GURL& url) {
auto* registry = extensions::ExtensionRegistry::Get(browser_context);
if (!registry) {
return nullptr;
}
std::string extension_id = url.host();
return registry->enabled_extensions().GetByID(extension_id);
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
} // 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) {
@@ -74,13 +50,13 @@ content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
CHECK(browser_context);
scoped_refptr<content::SiteInstance> site_instance;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
if (extensions::ExtensionsEnabled() && !create_params.url.empty()) {
GURL gurl = url_util::MakeGURL(create_params.url, /*fixup=*/true);
if (!create_params.extension) {
// We might be loading an extension app view where the extension URL is
// provided by the client.
create_params.extension = GetExtensionForUrl(browser_context, gurl);
create_params.extension =
extensions::GetExtensionForUrl(browser_context, gurl);
}
if (create_params.extension) {
if (create_params.extension_host_type ==
@@ -101,7 +77,6 @@ content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
DCHECK(site_instance);
}
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
content::WebContents::CreateParams wc_create_params(browser_context,
site_instance);
@@ -125,7 +100,7 @@ void CefBrowserPlatformDelegateAlloy::WebContentsCreated(
CefBrowserPlatformDelegate::WebContentsCreated(web_contents, owned);
if (primary_) {
AttachHelpers(web_contents);
find_in_page::FindTabHelper::CreateForWebContents(web_contents);
if (owned) {
SetOwnedWebContents(web_contents);
@@ -143,6 +118,7 @@ void CefBrowserPlatformDelegateAlloy::AddNewContents(
const blink::mojom::WindowFeatures& window_features,
bool user_gesture,
bool* was_blocked) {
REQUIRE_ALLOY_RUNTIME();
DCHECK(primary_);
CefRefPtr<AlloyBrowserHostImpl> owner =
@@ -155,16 +131,13 @@ void CefBrowserPlatformDelegateAlloy::AddNewContents(
return;
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
if (extension_host_) {
extension_host_->AddNewContents(source, std::move(new_contents), target_url,
disposition, window_features, user_gesture,
was_blocked);
}
#endif
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool CefBrowserPlatformDelegateAlloy::
ShouldAllowRendererInitiatedCrossProcessNavigation(
bool is_main_frame_navigation) {
@@ -174,7 +147,6 @@ bool CefBrowserPlatformDelegateAlloy::
}
return true;
}
#endif
void CefBrowserPlatformDelegateAlloy::RenderViewReady() {
ConfigureAutoResize();
@@ -190,17 +162,22 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
}
DCHECK(!web_contents_->GetDelegate());
web_contents_->SetDelegate(
AlloyBrowserHostImpl::FromBaseChecked(browser).get());
web_contents_->SetDelegate(static_cast<AlloyBrowserHostImpl*>(browser));
AttachHelpers(web_contents_);
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_));
// Used for print preview and JavaScript dialogs.
web_contents_dialog_helper_ =
std::make_unique<AlloyWebContentsDialogHelper>(web_contents_, this);
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
const extensions::Extension* extension,
const GURL& url,
@@ -213,12 +190,12 @@ void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
DCHECK(browser_);
DCHECK(!extension_host_);
auto alloy_browser = AlloyBrowserHostImpl::FromBaseChecked(browser_.get());
auto alloy_browser = static_cast<AlloyBrowserHostImpl*>(browser_);
if (host_type == extensions::mojom::ViewType::kExtensionPopup) {
// Create an extension host that we own.
extension_host_ = new extensions::CefExtensionViewHost(
alloy_browser.get(), extension, web_contents_, url, host_type);
alloy_browser, extension, web_contents_, url, host_type);
// Trigger load of the extension URL.
extension_host_->CreateRendererSoon();
} else if (host_type ==
@@ -227,7 +204,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.get(),
alloy_browser,
base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted,
weak_ptr_factory_.GetWeakPtr()),
extension, web_contents_, url, host_type);
@@ -241,14 +218,11 @@ extensions::ExtensionHost* CefBrowserPlatformDelegateAlloy::GetExtensionHost()
const {
return extension_host_;
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CefBrowserPlatformDelegateAlloy::BrowserDestroyed(
CefBrowserHostBase* browser) {
if (primary_) {
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
DestroyExtensionHost();
#endif
owned_web_contents_.reset();
}
@@ -290,7 +264,6 @@ void CefBrowserPlatformDelegateAlloy::NotifyMoveOrResizeStarted() {
}
#endif
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool CefBrowserPlatformDelegateAlloy::PreHandleGestureEvent(
content::WebContents* source,
const blink::WebGestureEvent& event) {
@@ -307,7 +280,6 @@ bool CefBrowserPlatformDelegateAlloy::IsNeverComposited(
}
return false;
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CefBrowserPlatformDelegateAlloy::SetAutoResizeEnabled(
bool enabled,
@@ -340,6 +312,19 @@ 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,
@@ -404,7 +389,6 @@ void CefBrowserPlatformDelegateAlloy::SetOwnedWebContents(
owned_web_contents_.reset(owned_contents);
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CefBrowserPlatformDelegateAlloy::DestroyExtensionHost() {
if (!extension_host_) {
return;
@@ -430,51 +414,3 @@ void CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted() {
DCHECK(extension_host_);
extension_host_ = nullptr;
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
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>());
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
// 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
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
{
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);
}
}

View File

@@ -6,10 +6,10 @@
#ifndef CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
#define CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
#include "base/memory/raw_ptr.h"
#include "libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "base/memory/weak_ptr.h"
#include "cef/libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.h"
#include "cef/libcef/browser/browser_platform_delegate.h"
#include "components/find_in_page/find_notification_details.h"
#include "content/public/browser/web_contents.h"
#include "ui/gfx/geometry/size.h"
@@ -33,18 +33,14 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
const blink::mojom::WindowFeatures& window_features,
bool user_gesture,
bool* was_blocked) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
bool is_main_frame_navigation) override;
#endif
void RenderViewReady() override;
void BrowserCreated(CefBrowserHostBase* browser) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type) override;
extensions::ExtensionHost* GetExtensionHost() const override;
#endif
void BrowserDestroyed(CefBrowserHostBase* browser) override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
const override;
@@ -52,15 +48,13 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC))
void NotifyMoveOrResizeStarted() override;
#endif
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) override;
bool IsNeverComposited(content::WebContents* web_contents) override;
#endif
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,
@@ -89,17 +83,11 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
private:
void SetOwnedWebContents(content::WebContents* owned_contents);
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void DestroyExtensionHost();
void OnExtensionHostDeleted();
#endif
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
@@ -113,11 +101,9 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
// matches, the find selection rectangle, etc.
find_in_page::FindNotificationDetails last_search_result_;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
// Used when the browser is hosting an extension.
raw_ptr<extensions::ExtensionHost> extension_host_ = nullptr;
extensions::ExtensionHost* extension_host_ = nullptr;
bool is_background_host_ = false;
#endif
// Used with auto-resize.
bool auto_resize_enabled_ = false;

View File

@@ -3,21 +3,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/chrome_browser_process_alloy.h"
#include "libcef/browser/alloy/chrome_browser_process_alloy.h"
#include <memory>
#include "libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/context.h"
#include "libcef/browser/extensions/extensions_browser_client.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_client.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/command_line.h"
#include "base/path_service.h"
#include "cef/libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/extensions/extensions_browser_client.h"
#include "cef/libcef/browser/prefs/browser_prefs.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/cef_switches.h"
#include "cef/libcef/common/extensions/extensions_client.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/component_updater/chrome_component_updater_configurator.h"
#include "chrome/browser/net/system_network_context_manager.h"
@@ -154,7 +155,6 @@ void ChromeBrowserProcessAlloy::CleanupOnUIThread() {
}
}
os_crypt_async_.reset();
local_state_.reset();
browser_policy_connector_.reset();
background_printing_manager_.reset();
@@ -370,12 +370,6 @@ 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;
@@ -445,12 +439,6 @@ os_crypt_async::OSCryptAsync* ChromeBrowserProcessAlloy::os_crypt_async() {
return os_crypt_async_.get();
}
void ChromeBrowserProcessAlloy::set_additional_os_crypt_async_provider_for_test(
size_t precedence,
std::unique_ptr<os_crypt_async::KeyProvider> provider) {
DCHECK(false);
}
BuildState* ChromeBrowserProcessAlloy::GetBuildState() {
DCHECK(false);
return nullptr;

View File

@@ -92,8 +92,6 @@ 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)
@@ -109,9 +107,6 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
resource_coordinator::ResourceCoordinatorParts* resource_coordinator_parts()
override;
os_crypt_async::OSCryptAsync* os_crypt_async() override;
void set_additional_os_crypt_async_provider_for_test(
size_t precedence,
std::unique_ptr<os_crypt_async::KeyProvider> provider) override;
BuildState* GetBuildState() override;
SerialPolicyAllowedPorts* serial_policy_allowed_ports() override;
HidSystemTrayIcon* hid_system_tray_icon() override;

View File

@@ -3,9 +3,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/chrome_profile_alloy.h"
#include "libcef/browser/alloy/chrome_profile_alloy.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "components/profile_metrics/browser_profile_type.h"
#include "components/variations/variations_client.h"
@@ -32,7 +31,7 @@ class CefVariationsClient : public variations::VariationsClient {
}
private:
raw_ptr<content::BrowserContext> browser_context_;
content::BrowserContext* browser_context_;
};
} // namespace

View File

@@ -3,11 +3,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "cef/libcef/common/app_manager.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/common/app_manager.h"
namespace {

View File

@@ -1,46 +0,0 @@
// 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 "cef/libcef/browser/alloy/devtools/alloy_devtools_window_runner.h"
#include "cef/libcef/browser/alloy/devtools/devtools_frontend.h"
#include "cef/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;
}

View File

@@ -1,40 +0,0 @@
// 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 "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "cef/libcef/browser/devtools/devtools_window_runner.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.
raw_ptr<CefDevToolsFrontend> devtools_frontend_ = nullptr;
base::WeakPtrFactory<AlloyDevToolsWindowRunner> weak_ptr_factory_{this};
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_

View File

@@ -3,10 +3,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
#include "libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
#include "libcef/browser/browser_host_base.h"
#include "base/notreached.h"
#include "cef/libcef/browser/browser_host_base.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
namespace {
@@ -14,10 +15,7 @@ namespace {
class AlloyConstrainedWindowViewsClient
: public constrained_window::ConstrainedWindowViewsClient {
public:
explicit AlloyConstrainedWindowViewsClient(
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
chrome_client)
: chrome_client_(std::move(chrome_client)) {}
AlloyConstrainedWindowViewsClient() = default;
AlloyConstrainedWindowViewsClient(const AlloyConstrainedWindowViewsClient&) =
delete;
@@ -28,12 +26,6 @@ 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();
}
@@ -42,12 +34,6 @@ 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();
}
@@ -80,17 +66,11 @@ class AlloyConstrainedWindowViewsClient
return browser;
}
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
chrome_client_;
};
} // namespace
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
CreateAlloyConstrainedWindowViewsClient(
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
chrome_client) {
return std::make_unique<AlloyConstrainedWindowViewsClient>(
std::move(chrome_client));
CreateAlloyConstrainedWindowViewsClient() {
return std::make_unique<AlloyConstrainedWindowViewsClient>();
}

View File

@@ -12,8 +12,6 @@
// Creates a ConstrainedWindowViewsClient for the Chrome environment.
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
CreateAlloyConstrainedWindowViewsClient(
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
chrome_client);
CreateAlloyConstrainedWindowViewsClient();
#endif // CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_CONSTRAINED_WINDOW_VIEWS_CLIENT_H_
#endif // CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_CONSTRAINED_WINDOW_VIEWS_CLIENT_H_

View File

@@ -3,10 +3,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h"
#include "libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h"
#include "libcef/browser/browser_host_base.h"
#include "base/logging.h"
#include "cef/libcef/browser/browser_host_base.h"
namespace {

View File

@@ -15,4 +15,4 @@ std::unique_ptr<JavaScriptTabModalDialogManagerDelegateDesktop>
CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(
content::WebContents* web_contents);
#endif // CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_JAVASCRIPT_DIALOG_MANAGER_DELEGATE_H_
#endif // CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_JAVASCRIPT_DIALOG_MANAGER_DELEGATE_H_

View File

@@ -2,10 +2,11 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "cef/libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.h"
#include "libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "base/notreached.h"
#include "cef/libcef/browser/browser_platform_delegate.h"
#include "chrome/browser/platform_util.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "ui/views/widget/widget.h"
@@ -43,20 +44,14 @@ AlloyWebContentsDialogHelper::GetWebContentsModalDialogHost() {
gfx::NativeView AlloyWebContentsDialogHelper::GetHostView() const {
// Windowless rendering uses GetAcceleratedWidget() instead.
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 (browser_delegate_->IsWindowless()) {
return gfx::NativeView();
}
NOTIMPLEMENTED();
if (auto widget = browser_delegate_->GetWindowWidget()) {
return widget->GetNativeView();
}
DCHECK(false);
return gfx::NativeView();
}
@@ -64,13 +59,15 @@ gfx::AcceleratedWidget AlloyWebContentsDialogHelper::GetAcceleratedWidget()
const {
#if defined(USE_AURA)
// Windowed rendering uses GetHostView() instead.
if (browser_delegate_->IsWindowless()) {
if (auto parent_widget = browser_delegate_->GetHostWindowHandle()) {
return parent_widget;
}
if (!browser_delegate_->IsWindowless()) {
return gfx::kNullAcceleratedWidget;
}
if (auto parent_widget = browser_delegate_->GetHostWindowHandle()) {
return parent_widget;
}
#endif // defined(USE_AURA)
NOTIMPLEMENTED();
DCHECK(false);
return gfx::kNullAcceleratedWidget;
}

View File

@@ -7,7 +7,6 @@
#pragma once
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "components/web_modal/modal_dialog_host.h"
@@ -41,7 +40,7 @@ class AlloyWebContentsDialogHelper
private:
void OnBoundsChanged();
const raw_ptr<CefBrowserPlatformDelegate> browser_delegate_;
CefBrowserPlatformDelegate* const browser_delegate_;
// Used to notify WebContentsModalDialog.
base::ObserverList<web_modal::ModalDialogHostObserver>::Unchecked

View File

@@ -3,10 +3,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/audio_capturer.h"
#include "libcef/browser/audio_capturer.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/audio_loopback_stream_creator.h"
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "cef/libcef/browser/audio_loopback_stream_creator.h"
#include "components/mirroring/service/captured_audio_input.h"
#include "media/audio/audio_input_device.h"

View File

@@ -7,8 +7,9 @@
#define CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_
#pragma once
#include "cef/include/internal/cef_ptr.h"
#include "cef/include/internal/cef_types_wrappers.h"
#include "include/internal/cef_ptr.h"
#include "include/internal/cef_types_wrappers.h"
#include "media/base/audio_capturer_source.h"
namespace media {

View File

@@ -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 "cef/libcef/browser/audio_loopback_stream_creator.h"
#include "libcef/browser/audio_loopback_stream_creator.h"
#include <memory>
#include <utility>

View File

@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/browser_contents_delegate.h"
#include "libcef/browser/browser_contents_delegate.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/browser_util.h"
#include "libcef/browser/native/cursor_util.h"
#include "libcef/common/frame_util.h"
#include "base/memory/raw_ptr.h"
#include "cef/libcef/browser/browser_host_base.h"
#include "cef/libcef/browser/browser_platform_delegate.h"
#include "cef/libcef/browser/browser_util.h"
#include "cef/libcef/browser/native/cursor_util.h"
#include "cef/libcef/common/frame_util.h"
#include "chrome/browser/ui/views/sad_tab_view.h"
#include "chrome/common/chrome_result_codes.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
@@ -25,7 +25,6 @@
#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)
@@ -74,8 +73,8 @@ class CefWidgetHostInterceptor
private:
CefRefPtr<CefBrowser> const browser_;
const raw_ptr<content::RenderWidgetHost> render_widget_host_;
const raw_ptr<blink::mojom::WidgetHost> impl_;
content::RenderWidgetHost* const render_widget_host_;
blink::mojom::WidgetHost* const impl_;
};
} // namespace
@@ -94,7 +93,8 @@ 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());
browser_info_->MaybeCreateFrame(new_contents->GetPrimaryMainFrame(),
false /* is_guest_view */);
// Make sure RenderWidgetCreated is called at least one time. This Observer
// is registered too late to catch the initial creation.
@@ -112,11 +112,9 @@ 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::OpenURLFromTabEx(
content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>&
navigation_handle_callback) {
const content::OpenURLParams& params) {
bool cancel = false;
if (auto c = client()) {
@@ -135,13 +133,8 @@ content::WebContents* CefBrowserContentsDelegate::OpenURLFromTabEx(
}
}
if (!cancel) {
// TODO: Do something with |navigation_handle_callback|.
return web_contents();
}
// Returning nullptr will cancel the navigation.
return nullptr;
return cancel ? nullptr : web_contents();
}
void CefBrowserContentsDelegate::LoadingStateChanged(
@@ -235,9 +228,11 @@ void CefBrowserContentsDelegate::CanDownload(
base::OnceCallback<void(bool)> callback) {
bool allow = true;
if (auto c = client()) {
if (auto handler = c->GetDownloadHandler()) {
allow = handler->CanDownload(browser(), url.spec(), request_method);
if (auto delegate = platform_delegate()) {
if (auto c = client()) {
if (auto handler = c->GetDownloadHandler()) {
allow = handler->CanDownload(browser(), url.spec(), request_method);
}
}
}
@@ -299,26 +294,9 @@ 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);
browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */);
if (render_frame_host->GetParent() == nullptr) {
auto render_view_host = render_frame_host->GetRenderViewHost();
auto base_background_color = platform_delegate()->GetBackgroundColor();
@@ -341,7 +319,7 @@ void CefBrowserContentsDelegate::RenderFrameCreated(
void CefBrowserContentsDelegate::RenderFrameHostChanged(
content::RenderFrameHost* old_host,
content::RenderFrameHost* new_host) {
// Update tracking for the RFH.
// Just in case RenderFrameCreated wasn't called for some reason.
RenderFrameCreated(new_host);
}
@@ -494,11 +472,6 @@ void CefBrowserContentsDelegate::DidFinishNavigation(
return;
}
if (browser_info_->IsClosing()) {
// Ignore notifications when the browser is closing.
return;
}
if (navigation_handle->IsInPrimaryMainFrame() &&
navigation_handle->HasCommitted()) {
// A primary main frame navigation has occured.
@@ -511,15 +484,21 @@ void CefBrowserContentsDelegate::DidFinishNavigation(
const GURL& url =
(error_code == net::OK ? navigation_handle->GetURL() : GURL());
auto browser_info = browser_info_;
if (!browser_info->browser()) {
// Ignore notifications when the browser is closing.
return;
}
// May return NULL when starting a new navigation if the previous navigation
// caused the renderer process to crash during load.
CefRefPtr<CefFrameHostImpl> frame =
browser_info_->GetFrameForGlobalId(global_id);
browser_info->GetFrameForGlobalId(global_id);
if (!frame) {
if (is_main_frame) {
frame = browser_info_->GetMainFrame();
frame = browser_info->GetMainFrame();
} else {
frame = browser_info_->CreateTempSubFrame(frame_util::InvalidGlobalId());
frame = browser_info->CreateTempSubFrame(frame_util::InvalidGlobalId());
}
}
frame->RefreshAttributes();
@@ -567,10 +546,6 @@ 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;

View File

@@ -8,9 +8,10 @@
#include <memory>
#include "libcef/browser/frame_host_impl.h"
#include "base/callback_list.h"
#include "base/observer_list.h"
#include "cef/libcef/browser/frame_host_impl.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
@@ -79,15 +80,10 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
// 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,
base::OnceCallback<void(content::NavigationHandle&)>&
navigation_handle_callback);
// WebContentsDelegate methods:
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;
@@ -109,9 +105,6 @@ 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;

View File

@@ -2,24 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/browser_context.h"
#include "libcef/browser/browser_context.h"
#include <map>
#include <memory>
#include <utility>
#include "libcef/browser/context.h"
#include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/request_context_impl.h"
#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"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/media_router/media_router_manager.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/cef_switches.h"
#include "cef/libcef/common/frame_util.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
@@ -132,7 +134,7 @@ class ImplManager {
return all_.end();
}
using PathMap = std::map<base::FilePath, raw_ptr<CefBrowserContext>>;
using PathMap = std::map<base::FilePath, CefBrowserContext*>;
PathMap map_;
Vector all_;
@@ -282,7 +284,8 @@ std::vector<CefBrowserContext*> CefBrowserContext::GetAll() {
void CefBrowserContext::OnRenderFrameCreated(
CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame) {
bool is_main_frame,
bool is_guest_view) {
CEF_REQUIRE_UIT();
DCHECK(frame_util::IsValidGlobalId(global_id));
@@ -300,7 +303,8 @@ void CefBrowserContext::OnRenderFrameCreated(
void CefBrowserContext::OnRenderFrameDeleted(
CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame) {
bool is_main_frame,
bool is_guest_view) {
CEF_REQUIRE_UIT();
DCHECK(frame_util::IsValidGlobalId(global_id));
@@ -365,7 +369,6 @@ void CefBrowserContext::ClearSchemeHandlerFactories() {
iothread_state_));
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CefBrowserContext::LoadExtension(
const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
@@ -392,7 +395,10 @@ bool CefBrowserContext::UnloadExtension(const CefString& extension_id) {
NOTIMPLEMENTED();
return false;
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool CefBrowserContext::IsPrintPreviewSupported() const {
return true;
}
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
CEF_REQUIRE_UIT();
@@ -419,12 +425,12 @@ CefRefPtr<CefRequestContextImpl> CefBrowserContext::GetAnyRequestContext(
if (prefer_no_handler) {
for (const auto& request_context : request_context_set_) {
if (!request_context->GetHandler()) {
return request_context.get();
return request_context;
}
}
}
return request_context_set_.begin()->get();
return *request_context_set_.begin();
}
CefBrowserContext::CookieableSchemes CefBrowserContext::GetCookieableSchemes()

View File

@@ -10,17 +10,16 @@
#include <set>
#include <vector>
#include "include/cef_request_context_handler.h"
#include "libcef/browser/iothread_state.h"
#include "libcef/browser/request_context_handler_map.h"
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/task/sequenced_task_runner_helpers.h"
#include "cef/include/cef_request_context_handler.h"
#include "cef/libcef/browser/iothread_state.h"
#include "cef/libcef/browser/request_context_handler_map.h"
#include "cef/libcef/features/features.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"
/*
@@ -132,12 +131,14 @@ class CefBrowserContext {
// Called from CefRequestContextImpl::OnRenderFrameCreated.
void OnRenderFrameCreated(CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame);
bool is_main_frame,
bool is_guest_view);
// Called from CefRequestContextImpl::OnRenderFrameDeleted.
void OnRenderFrameDeleted(CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame);
bool is_main_frame,
bool is_guest_view);
// Returns the handler that matches the specified IDs. Pass -1 for unknown
// values. If |require_frame_match| is true only exact matches will be
@@ -160,8 +161,7 @@ class CefBrowserContext {
const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory);
void ClearSchemeHandlerFactories();
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
// TODO(chrome-runtime): Make these extension methods pure virtual.
virtual void LoadExtension(const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler,
@@ -171,13 +171,9 @@ class CefBrowserContext {
// Called from CefExtensionImpl::Unload().
virtual bool UnloadExtension(const CefString& extension_id);
#endif
// 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;
// Returns true if this context supports print preview.
virtual bool IsPrintPreviewSupported() const;
network::mojom::NetworkContext* GetNetworkContext();
@@ -235,7 +231,7 @@ class CefBrowserContext {
std::unique_ptr<CefMediaRouterManager> media_router_manager_;
// CefRequestContextImpl objects referencing this object.
std::set<raw_ptr<CefRequestContextImpl>> request_context_set_;
std::set<CefRequestContextImpl*> request_context_set_;
// Map IDs to CefRequestContextHandler objects.
CefRequestContextHandlerMap handler_map_;

View File

@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
#include "cef/libcef/browser/browser_context_keyed_service_factories.h"
#include "libcef/browser/browser_context_keyed_service_factories.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/feature_list.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/first_party_sets/first_party_sets_policy_service_factory.h"
#include "chrome/browser/media/router/chrome_media_router_factory.h"

View File

@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/browser_frame.h"
#include "libcef/browser/browser_frame.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/thread_util.h"
#include "cef/libcef/browser/browser_host_base.h"
#include "cef/libcef/browser/browser_info_manager.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/frame_util.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
@@ -58,31 +57,26 @@ void CefBrowserFrame::FrameAttached(
bool reattached) {
// Always send to the newly created RFH, which may be speculative when
// navigating cross-origin.
bool is_excluded;
if (auto host = GetFrameHost(/*prefer_speculative=*/true, &is_excluded)) {
if (auto host = GetFrameHost(/*prefer_speculative=*/true)) {
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(/*prefer_speculative=*/false)) {
if (auto host = GetFrameHost()) {
host->UpdateDraggableRegions(std::move(regions));
}
}
CefRefPtr<CefFrameHostImpl> CefBrowserFrame::GetFrameHost(
bool prefer_speculative,
bool* is_excluded) const {
return CefBrowserInfoManager::GetFrameHost(
render_frame_host(), prefer_speculative,
/*browser_info=*/nullptr, is_excluded);
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;
}

View File

@@ -6,8 +6,9 @@
#define CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_
#pragma once
#include "cef/libcef/browser/frame_host_impl.h"
#include "cef/libcef/browser/frame_service_base.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/frame_service_base.h"
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "mojo/public/cpp/bindings/binder_map.h"
@@ -47,8 +48,8 @@ class CefBrowserFrame
// FrameServiceBase methods:
bool ShouldCloseOnFinishNavigation() const override { return false; }
CefRefPtr<CefFrameHostImpl> GetFrameHost(bool prefer_speculative,
bool* is_excluded = nullptr) const;
CefRefPtr<CefFrameHostImpl> GetFrameHost(
bool prefer_speculative = false) const;
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_

View File

@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/browser_host_base.h"
#include "libcef/browser/browser_host_base.h"
#include <tuple>
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
#include "libcef/browser/hang_monitor.h"
#include "libcef/browser/image_impl.h"
#include "libcef/browser/navigation_entry_impl.h"
#include "libcef/browser/printing/print_util.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/frame_util.h"
#include "libcef/common/net/url_util.h"
#include "base/logging.h"
#include "cef/libcef/browser/browser_info_manager.h"
#include "cef/libcef/browser/browser_platform_delegate.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/extensions/browser_extensions_util.h"
#include "cef/libcef/browser/hang_monitor.h"
#include "cef/libcef/browser/image_impl.h"
#include "cef/libcef/browser/navigation_entry_impl.h"
#include "cef/libcef/browser/printing/print_util.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/frame_util.h"
#include "cef/libcef/common/net/url_util.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
@@ -83,12 +83,6 @@ 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) {
@@ -121,18 +115,7 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForContents(
const content::WebContents* contents) {
DCHECK(contents);
CEF_REQUIRE_UIT();
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;
return WebContentsUserDataAdapter::Get(contents);
}
// static
@@ -152,8 +135,10 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalId(
return GetBrowserForHost(render_frame_host);
} else {
// Use the thread-safe approach.
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(global_id);
if (info) {
bool is_guest_view = false;
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(
global_id, &is_guest_view);
if (info && !is_guest_view) {
auto browser = info->browser();
if (!browser) {
LOG(WARNING) << "Found browser id " << info->browser_id()
@@ -183,9 +168,10 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalToken(
return GetBrowserForHost(render_frame_host);
} else {
// Use the thread-safe approach.
auto info =
CefBrowserInfoManager::GetInstance()->GetBrowserInfo(global_token);
if (info) {
bool is_guest_view = false;
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(
global_token, &is_guest_view);
if (info && !is_guest_view) {
auto browser = info->browser();
if (!browser) {
LOG(WARNING) << "Found browser id " << info->browser_id()
@@ -262,51 +248,16 @@ void CefBrowserHostBase::InitializeBrowser() {
WebContentsUserDataAdapter::Register(this);
}
void CefBrowserHostBase::DestroyWebContents(
content::WebContents* web_contents) {
CEF_REQUIRE_UIT();
// GetWebContents() should return nullptr at this point.
DCHECK(!GetWebContents());
// Notify that this browser has been destroyed. These must be delivered in
// the expected order.
// 1. Notify the platform delegate. With Views this will result in a call to
// CefBrowserViewDelegate::OnBrowserDestroyed().
platform_delegate_->NotifyBrowserDestroyed();
// 2. Notify the browser's LifeSpanHandler. This must always be the last
// notification for this browser.
OnBeforeClose();
// Notify any observers that may have state associated with this browser.
OnBrowserDestroyed();
// Free objects that may have references to the WebContents.
devtools_protocol_manager_.reset();
devtools_window_runner_.reset();
context_menu_observer_ = nullptr;
if (javascript_dialog_manager_) {
javascript_dialog_manager_->Destroy();
javascript_dialog_manager_.reset();
}
browser_info_->WebContentsDestroyed();
platform_delegate_->WebContentsDestroyed(web_contents);
}
void CefBrowserHostBase::DestroyBrowser() {
CEF_REQUIRE_UIT();
// The WebContents should no longer be observed.
DCHECK(!contents_delegate_->web_contents());
devtools_manager_.reset();
media_stream_registrar_.reset();
platform_delegate_.reset();
contents_delegate_->RemoveObserver(this);
contents_delegate_->ObserveWebContents(nullptr);
if (unresponsive_process_callback_) {
hang_monitor::Detach(unresponsive_process_callback_);
@@ -314,7 +265,7 @@ void CefBrowserHostBase::DestroyBrowser() {
}
CefBrowserInfoManager::GetInstance()->RemoveBrowserInfo(browser_info_);
browser_info_->BrowserDestroyed();
browser_info_->SetBrowser(nullptr);
}
CefRefPtr<CefBrowser> CefBrowserHostBase::GetBrowser() {
@@ -611,30 +562,6 @@ 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) {
@@ -653,10 +580,10 @@ bool CefBrowserHostBase::SendDevToolsMessage(const void* message,
return false;
}
if (!EnsureDevToolsProtocolManager()) {
if (!EnsureDevToolsManager()) {
return false;
}
return devtools_protocol_manager_->SendDevToolsMessage(message, message_size);
return devtools_manager_->SendDevToolsMessage(message, message_size);
}
int CefBrowserHostBase::ExecuteDevToolsMethod(
@@ -671,11 +598,10 @@ int CefBrowserHostBase::ExecuteDevToolsMethod(
return 0;
}
if (!EnsureDevToolsProtocolManager()) {
if (!EnsureDevToolsManager()) {
return 0;
}
return devtools_protocol_manager_->ExecuteDevToolsMethod(message_id, method,
params);
return devtools_manager_->ExecuteDevToolsMethod(message_id, method, params);
}
CefRefPtr<CefRegistration> CefBrowserHostBase::AddDevToolsMessageObserver(
@@ -683,7 +609,7 @@ CefRefPtr<CefRegistration> CefBrowserHostBase::AddDevToolsMessageObserver(
if (!observer) {
return nullptr;
}
auto registration = CefDevToolsProtocolManager::CreateRegistration(observer);
auto registration = CefDevToolsManager::CreateRegistration(observer);
InitializeDevToolsRegistrationOnUIThread(registration);
return registration.get();
}
@@ -764,15 +690,6 @@ void CefBrowserHostBase::NotifyMoveOrResizeStarted() {
#endif
}
CefRefPtr<CefExtension> CefBrowserHostBase::GetExtension() {
NOTIMPLEMENTED();
return nullptr;
}
bool CefBrowserHostBase::IsBackgroundHost() {
return false;
}
bool CefBrowserHostBase::IsFullscreen() {
if (!CEF_CURRENTLY_ON_UIT()) {
DCHECK(false) << "called on invalid thread";
@@ -814,10 +731,6 @@ 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(
@@ -923,7 +836,7 @@ void CefBrowserHostBase::SendMouseWheelEvent(const CefMouseEvent& event,
}
bool CefBrowserHostBase::IsValid() {
return browser_info_->IsValid();
return browser_info_->browser() == this;
}
CefRefPtr<CefBrowserHost> CefBrowserHostBase::GetHost() {
@@ -1035,8 +948,8 @@ int CefBrowserHostBase::GetIdentifier() {
}
bool CefBrowserHostBase::IsSame(CefRefPtr<CefBrowser> that) {
auto impl = FromBrowser(that);
return (impl.get() == this);
auto impl = static_cast<CefBrowserHostBase*>(that.get());
return (impl == this);
}
bool CefBrowserHostBase::HasDocument() {
@@ -1173,12 +1086,12 @@ CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForHost(
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalId(
const content::GlobalRenderFrameHostId& global_id) {
return browser_info_->GetFrameForGlobalId(global_id);
return browser_info_->GetFrameForGlobalId(global_id, nullptr);
}
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token) {
return browser_info_->GetFrameForGlobalToken(global_token);
return browser_info_->GetFrameForGlobalToken(global_token, nullptr);
}
void CefBrowserHostBase::AddObserver(Observer* observer) {
@@ -1230,12 +1143,6 @@ 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,
@@ -1287,17 +1194,9 @@ void CefBrowserHostBase::SelectFileListenerDestroyed(
}
}
content::JavaScriptDialogManager*
CefBrowserHostBase::GetJavaScriptDialogManager() {
if (!javascript_dialog_manager_) {
javascript_dialog_manager_ =
std::make_unique<CefJavaScriptDialogManager>(this);
}
return javascript_dialog_manager_.get();
}
bool CefBrowserHostBase::MaybeAllowNavigation(
content::RenderFrameHost* opener,
bool is_guest_view,
const content::OpenURLParams& params) {
return true;
}
@@ -1345,6 +1244,10 @@ 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();
@@ -1367,13 +1270,6 @@ 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_) {
@@ -1425,15 +1321,14 @@ bool CefBrowserHostBase::IsVisible() const {
return false;
}
bool CefBrowserHostBase::EnsureDevToolsProtocolManager() {
bool CefBrowserHostBase::EnsureDevToolsManager() {
CEF_REQUIRE_UIT();
if (!contents_delegate_->web_contents()) {
return false;
}
if (!devtools_protocol_manager_) {
devtools_protocol_manager_ =
std::make_unique<CefDevToolsProtocolManager>(this);
if (!devtools_manager_) {
devtools_manager_ = std::make_unique<CefDevToolsManager>(this);
}
return true;
}
@@ -1449,10 +1344,10 @@ void CefBrowserHostBase::InitializeDevToolsRegistrationOnUIThread(
return;
}
if (!EnsureDevToolsProtocolManager()) {
if (!EnsureDevToolsManager()) {
return;
}
devtools_protocol_manager_->InitializeRegistrationOnUIThread(registration);
devtools_manager_->InitializeRegistrationOnUIThread(registration);
}
bool CefBrowserHostBase::EnsureFileDialogManager() {

View File

@@ -6,46 +6,36 @@
#define CEF_LIBCEF_BROWSER_BROWSER_HOST_BASE_H_
#pragma once
#include "base/memory/raw_ptr.h"
#include "include/cef_browser.h"
#include "include/cef_client.h"
#include "include/cef_unresponsive_process_callback.h"
#include "include/views/cef_browser_view.h"
#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/file_dialog_manager.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/media_stream_registrar.h"
#include "libcef/browser/request_context_impl.h"
#include "base/observer_list.h"
#include "base/synchronization/lock.h"
#include "cef/include/cef_browser.h"
#include "cef/include/cef_client.h"
#include "cef/include/cef_unresponsive_process_callback.h"
#include "cef/include/views/cef_browser_view.h"
#include "cef/libcef/browser/browser_contents_delegate.h"
#include "cef/libcef/browser/browser_info.h"
#include "cef/libcef/browser/browser_platform_delegate.h"
#include "cef/libcef/browser/devtools/devtools_protocol_manager.h"
#include "cef/libcef/browser/devtools/devtools_window_runner.h"
#include "cef/libcef/browser/file_dialog_manager.h"
#include "cef/libcef/browser/frame_host_impl.h"
#include "cef/libcef/browser/javascript_dialog_manager.h"
#include "cef/libcef/browser/media_stream_registrar.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "cef/libcef/features/features.h"
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
#include "extensions/common/mojom/view_type.mojom.h"
#endif
namespace extensions {
class Extension;
}
class RenderViewContextMenuObserver;
// Parameters that are passed to the runtime-specific Create methods.
struct CefBrowserCreateParams {
CefBrowserCreateParams() = default;
// Copy constructor used with Chrome style only.
// Copy constructor used with the chrome runtime 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;
@@ -53,29 +43,14 @@ struct CefBrowserCreateParams {
request_context = that.request_context;
extra_info = that.extra_info;
if (that.window_info) {
MaybeSetWindowInfo(*that.window_info, /*allow_alloy_style=*/false,
/*allow_chrome_style=*/true);
MaybeSetWindowInfo(*that.window_info);
}
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,
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;
void MaybeSetWindowInfo(const CefWindowInfo& window_info);
// Platform-specific window creation info. Will be nullptr for Views-hosted
// browsers except when using the Chrome runtime with a native parent handle.
@@ -90,10 +65,6 @@ 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;
@@ -104,11 +75,9 @@ struct CefBrowserCreateParams {
// Browser settings.
CefBrowserSettings settings;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
// Other browser that opened this DevTools browser. Will be nullptr for non-
// DevTools browsers. Currently used with the alloy runtime only.
CefRefPtr<CefBrowserHostBase> devtools_opener;
#endif
// Request context to use when creating the browser. If nullptr the global
// request context will be used.
@@ -118,14 +87,29 @@ struct CefBrowserCreateParams {
// CefRenderProcessHandler::OnBrowserCreated.
CefRefPtr<CefDictionaryValue> extra_info;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
// Used when explicitly creating the browser as an extension host via
// ProcessManager::CreateBackgroundHost. Currently used with the alloy
// runtime only.
raw_ptr<const extensions::Extension> extension = nullptr;
const extensions::Extension* extension = nullptr;
extensions::mojom::ViewType extension_host_type =
extensions::mojom::ViewType::kInvalid;
#endif
};
// 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
@@ -152,11 +136,6 @@ 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);
@@ -202,32 +181,9 @@ class CefBrowserHostBase : public CefBrowserHost,
// the UI thread only.
virtual bool WillBeDestroyed() const = 0;
// Called on the UI thread to complete WebContents tear-down. In most cases
// this will be called via WebContentsObserver::WebContentsDestroyed. Any
// remaining objects that reference the WebContents (including RFH, etc)
// should be cleared in this callback.
virtual void DestroyWebContents(content::WebContents* web_contents);
// Called on the UI thread to complete CefBrowserHost tear-down.
//
// With Chrome style the WebContents is owned by the Browser's TabStripModel
// and will usually be destroyed first: CloseBrowser -> (async) DoCloseBrowser
// -> [TabStripModel deletes the WebContents] -> OnWebContentsDestroyed ->
// DestroyWebContents -> (async) DestroyBrowser.
//
// With Alloy style the WebContents is owned by the
// CefBrowserPlatformDelegateAlloy and will usually be destroyed at the same
// time: CloseBrowser -> [OS/platform logic] -> (async) DestroyBrowser ->
// [CefBrowserPlatformDelegateAlloy deletes the WebContents]
// -> WebContentsDestroyed -> DestoyWebContents.
//
// There are a few exceptions to the above rules:
// 1. If the CefBrowserHost still exists at CefShutdown, in which case
// DestroyBrowser will be called first via
// CefBrowserInfoManager::DestroyAllBrowsers.
// 2. If a popup WebContents is still pending when the parent WebContents is
// destroyed, in which case WebContentsDestroyed will be called first via
// the parent WebContents destructor.
// Called on the UI thread after the associated WebContents is destroyed.
// Also called from CefBrowserInfoManager::DestroyAllBrowsers if the browser
// was not properly shut down.
virtual void DestroyBrowser();
// CefBrowserHost methods:
@@ -260,8 +216,6 @@ 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;
@@ -283,12 +237,9 @@ class CefBrowserHostBase : public CefBrowserHost,
bool current_only) override;
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
void NotifyMoveOrResizeStarted() override;
CefRefPtr<CefExtension> GetExtension() override;
bool IsBackgroundHost() override;
bool IsFullscreen() override;
void ExitFullscreen(bool will_cause_resize) override;
bool IsRenderProcessUnresponsive() override;
cef_runtime_style_t GetRuntimeStyle() override;
// CefBrowser methods:
bool IsValid() override;
@@ -319,8 +270,7 @@ class CefBrowserHostBase : public CefBrowserHost,
void OnStateChanged(CefBrowserContentsState state_changed) override;
void OnWebContentsDestroyed(content::WebContents* web_contents) override;
// Returns the frame object matching the specified |host| or nullptr if no
// match is found. Must be called on the UI thread.
// Returns the frame associated with the specified RenderFrameHost.
CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host);
// Returns the frame associated with the specified global ID/token. See
@@ -358,12 +308,9 @@ class CefBrowserHostBase : public CefBrowserHost,
void* params);
void SelectFileListenerDestroyed(ui::SelectFileDialog::Listener* listener);
// Called from AlloyBrowserHostImpl::GetJavaScriptDialogManager and
// ChromeBrowserDelegate::GetJavaScriptDialogManager.
content::JavaScriptDialogManager* GetJavaScriptDialogManager();
// 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.
@@ -383,11 +330,7 @@ class CefBrowserHostBase : public CefBrowserHost,
SkColor GetBackgroundColor() const;
// Returns true if windowless rendering is enabled.
virtual bool IsWindowless() const = 0;
// Returns the runtime style of this browser.
virtual bool IsAlloyStyle() const = 0;
bool IsChromeStyle() const { return !IsAlloyStyle(); }
virtual bool IsWindowless() const;
// Accessors that must be called on the UI thread.
content::WebContents* GetWebContents() const;
@@ -399,7 +342,6 @@ class CefBrowserHostBase : public CefBrowserHost,
return contents_delegate_.get();
}
CefMediaStreamRegistrar* GetMediaStreamRegistrar();
CefDevToolsWindowRunner* GetDevToolsWindowRunner();
CefRefPtr<CefUnresponsiveProcessCallback> unresponsive_process_callback()
const {
@@ -410,13 +352,6 @@ 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;
@@ -443,7 +378,7 @@ class CefBrowserHostBase : public CefBrowserHost,
virtual bool IsVisible() const;
protected:
bool EnsureDevToolsProtocolManager();
bool EnsureDevToolsManager();
void InitializeDevToolsRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration);
@@ -451,7 +386,8 @@ class CefBrowserHostBase : public CefBrowserHost,
virtual bool Navigate(const content::OpenURLParams& params);
// Called from ShowDevTools to perform the actual show.
void ShowDevToolsOnUIThread(std::unique_ptr<CefShowDevToolsParams> params);
virtual void ShowDevToolsOnUIThread(
std::unique_ptr<CefShowDevToolsParams> params) = 0;
// Create the CefFileDialogManager if it doesn't already exist.
bool EnsureFileDialogManager();
@@ -467,7 +403,6 @@ class CefBrowserHostBase : public CefBrowserHost,
// Only accessed on the UI thread.
std::unique_ptr<CefBrowserContentsDelegate> contents_delegate_;
CefRefPtr<CefUnresponsiveProcessCallback> unresponsive_process_callback_;
raw_ptr<RenderViewContextMenuObserver> context_menu_observer_ = nullptr;
// Observers that want to be notified of changes to this object.
// Only accessed on the UI thread.
@@ -476,9 +411,6 @@ class CefBrowserHostBase : public CefBrowserHost,
// Used for creating and managing file dialogs.
std::unique_ptr<CefFileDialogManager> file_dialog_manager_;
// Used for creating and managing JavaScript dialogs.
std::unique_ptr<CefJavaScriptDialogManager> javascript_dialog_manager_;
// Volatile state accessed from multiple threads. All access must be protected
// by |state_lock_|.
base::Lock state_lock_;
@@ -489,11 +421,8 @@ class CefBrowserHostBase : public CefBrowserHost,
bool is_fullscreen_ = false;
CefRefPtr<CefFrameHostImpl> focused_frame_;
// 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_;
// Used for creating and managing DevTools instances.
std::unique_ptr<CefDevToolsManager> devtools_manager_;
std::unique_ptr<CefMediaStreamRegistrar> media_stream_registrar_;

View File

@@ -3,13 +3,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/include/cef_browser.h"
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "cef/libcef/browser/chrome/chrome_browser_host_impl.h"
#include "cef/libcef/browser/chrome/views/chrome_child_window.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/features/runtime.h"
#include "include/cef_browser.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
#include "libcef/browser/chrome/views/chrome_child_window.h"
#include "libcef/browser/context.h"
#include "libcef/browser/thread_util.h"
#include "libcef/features/runtime.h"
namespace {
@@ -65,9 +65,8 @@ bool CefBrowserHost::CreateBrowser(
// Verify windowless rendering requirements.
if (windowInfo.windowless_rendering_enabled &&
(!client || !client->GetRenderHandler().get())) {
LOG(ERROR)
<< "Windowless rendering requires a CefRenderHandler implementation";
!client->GetRenderHandler().get()) {
DCHECK(false) << "CefRenderHandler implementation is required";
return false;
}
@@ -134,15 +133,13 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
// Verify windowless rendering requirements.
if (windowInfo.windowless_rendering_enabled &&
(!client || !client->GetRenderHandler().get())) {
LOG(ERROR)
<< "Windowless rendering requires a CefRenderHandler implementation";
!client->GetRenderHandler().get()) {
DCHECK(false) << "CefRenderHandler implementation is required";
return nullptr;
}
CefBrowserCreateParams create_params;
create_params.MaybeSetWindowInfo(windowInfo, /*allow_alloy_style=*/true,
/*allow_chrome_style=*/true);
create_params.MaybeSetWindowInfo(windowInfo);
create_params.client = client;
create_params.url = url;
create_params.settings = settings;
@@ -152,135 +149,18 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
return CefBrowserHostBase::Create(create_params);
}
// static
bool CefBrowserCreateParams::IsChromeStyle(const CefWindowInfo* window_info) {
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
if (!cef::IsChromeRuntimeEnabled()) {
return false;
}
#endif
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 BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
if (!cef::IsChromeRuntimeEnabled()) {
return false;
}
#endif
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 (
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
cef::IsChromeRuntimeEnabled() &&
#endif
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,
bool allow_alloy_style,
bool allow_chrome_style) {
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
if (!cef::IsChromeRuntimeEnabled()) {
// Chrome style is not supported wih the Alloy bootstrap.
allow_chrome_style = false;
}
#endif
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 ||
const CefWindowInfo& new_window_info) {
if (!cef::IsChromeRuntimeEnabled() ||
chrome_child_window::HasParentHandle(new_window_info)) {
window_info = std::make_unique<CefWindowInfo>(new_window_info);
if (
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
cef::IsChromeRuntimeEnabled() &&
#endif
!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 (create_params.IsChromeStyle()) {
if (cef::IsChromeRuntimeEnabled()) {
if (auto browser =
chrome_child_window::MaybeCreateChildBrowser(create_params)) {
return browser.get();

View File

@@ -2,16 +2,16 @@
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "cef/libcef/browser/browser_info.h"
#include "libcef/browser/browser_info.h"
#include <memory>
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/frame_util.h"
#include "libcef/common/values_impl.h"
#include "base/logging.h"
#include "cef/libcef/browser/browser_host_base.h"
#include "cef/libcef/browser/browser_info_manager.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/frame_util.h"
#include "cef/libcef/common/values_impl.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/public/browser/render_process_host.h"
@@ -29,12 +29,10 @@ 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);
@@ -55,82 +53,49 @@ CefBrowserInfo::~CefBrowserInfo() {
CefRefPtr<CefBrowserHostBase> CefBrowserInfo::browser() const {
base::AutoLock lock_scope(lock_);
return browser_;
}
bool CefBrowserInfo::IsValid() const {
base::AutoLock lock_scope(lock_);
return browser_ && !is_closing_;
}
bool CefBrowserInfo::IsClosing() const {
base::AutoLock lock_scope(lock_);
return is_closing_;
if (!is_closing_) {
return browser_;
}
return nullptr;
}
void CefBrowserInfo::SetBrowser(CefRefPtr<CefBrowserHostBase> browser) {
base::AutoLock lock_scope(lock_);
DCHECK(browser);
DCHECK(!browser_);
NotificationStateLock lock_scope(this);
if (browser) {
DCHECK(!browser_);
// Cache the associated frame handler.
if (auto client = browser->GetClient()) {
frame_handler_ = client->GetFrameHandler();
}
} else {
DCHECK(browser_);
}
auto old_browser = browser_;
browser_ = browser;
// Cache the associated frame handler.
if (auto client = browser->GetClient()) {
frame_handler_ = client->GetFrameHandler();
if (!browser_) {
RemoveAllFrames(old_browser);
// Any future calls to MaybeExecuteFrameNotification will now fail.
// NotificationStateLock already took a reference for the delivery of any
// notifications that are currently queued due to RemoveAllFrames.
frame_handler_ = nullptr;
}
}
void CefBrowserInfo::SetClosing() {
base::AutoLock lock_scope(lock_);
// In most cases WebContentsDestroyed will be called first, except if the
// browser still exits at CefShitdown.
if (!is_closing_) {
is_closing_ = true;
}
DCHECK(!is_closing_);
is_closing_ = true;
}
void CefBrowserInfo::WebContentsDestroyed() {
NotificationStateLock lock_scope(this);
// Always called before BrowserDestroyed.
DCHECK(browser_);
// We want GetMainFrame() to return nullptr at this point, but browser()
// should still be valid so as not to interfere with the net_service
// DestructionObserver.
if (!is_closing_) {
is_closing_ = true;
}
RemoveAllFrames(browser_);
// Any future calls to MaybeExecuteFrameNotification will now fail.
// NotificationStateLock already took a reference for the delivery of any
// notifications that are currently queued due to RemoveAllFrames.
frame_handler_ = nullptr;
}
void CefBrowserInfo::BrowserDestroyed() {
base::AutoLock lock_scope(lock_);
// Always called after SetClosing and WebContentsDestroyed.
DCHECK(is_closing_);
DCHECK(frame_info_set_.empty());
DCHECK(browser_);
browser_ = nullptr;
}
void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host) {
void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
bool is_guest_view) {
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);
@@ -156,13 +121,11 @@ 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
// Update the associated RFH, which may have changed.
info->frame_->MaybeReAttach(this, host, /*require_detached=*/false);
if (info->is_speculative_ && !is_speculative) {
if (!info->is_guest_view_ && info->is_speculative_ && !is_speculative) {
// Upgrade the frame info from speculative to non-speculative.
if (info->is_main_frame_) {
// Set the main frame object.
@@ -174,24 +137,30 @@ 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;
// 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_);
}
// 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());
// 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);
browser_->request_context()->OnRenderFrameCreated(global_id, is_main_frame,
is_guest_view);
// Populate the lookup maps.
frame_id_map_.insert(std::make_pair(global_id, frame_info));
@@ -214,7 +183,7 @@ void CefBrowserInfo::FrameHostStateChanged(
new_state == content::RenderFrameHost::LifecycleState::kActive) {
if (auto frame = GetFrameForHost(host)) {
// Update the associated RFH, which may have changed.
frame->MaybeReAttach(this, host, /*require_detached=*/true);
frame->MaybeReAttach(this, host);
if (frame->IsMain()) {
// Update the main frame object.
@@ -241,11 +210,10 @@ void CefBrowserInfo::FrameHostStateChanged(
base::AutoLock lock_scope(lock_);
auto it = frame_id_map_.find(host->GetGlobalId());
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;
}
DCHECK(it != frame_id_map_.end());
DCHECK((!it->second->is_in_bfcache_ && added_to_bfcache) ||
(it->second->is_in_bfcache_ && removed_from_bfcache));
it->second->is_in_bfcache_ = added_to_bfcache;
}
void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
@@ -255,14 +223,12 @@ void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
const auto global_id = host->GetGlobalId();
auto it = frame_id_map_.find(global_id);
if (it == frame_id_map_.end()) {
return;
}
DCHECK(it != frame_id_map_.end());
auto frame_info = it->second;
browser_->request_context()->OnRenderFrameDeleted(global_id,
frame_info->is_main_frame_);
browser_->request_context()->OnRenderFrameDeleted(
global_id, frame_info->is_main_frame_, frame_info->is_guest_view_);
// Remove from the lookup maps.
frame_id_map_.erase(it);
@@ -313,19 +279,29 @@ 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(),
const_cast<content::RenderFrameHost*>(host)->GetGlobalId(), is_guest_view,
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;
}
@@ -336,6 +312,13 @@ 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.
@@ -355,7 +338,12 @@ 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;
}
@@ -371,7 +359,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalToken(
global_id = it->second;
}
return GetFrameForGlobalId(global_id, prefer_speculative);
return GetFrameForGlobalId(global_id, is_guest_view, prefer_speculative);
}
CefBrowserInfo::FrameHostList CefBrowserInfo::GetAllFrames() const {
@@ -550,7 +538,8 @@ void CefBrowserInfo::RemoveAllFrames(
// Make sure any callbacks will see the correct state (e.g. like
// CefBrowser::GetMainFrame returning nullptr and CefBrowser::IsValid
// returning false).
DCHECK(is_closing_);
DCHECK(!browser_);
DCHECK(old_browser);
// Clear the lookup maps.
frame_id_map_.clear();

View File

@@ -10,15 +10,15 @@
#include <set>
#include <unordered_map>
#include "include/internal/cef_ptr.h"
#include "libcef/common/values_impl.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
#include "base/values.h"
#include "cef/include/internal/cef_ptr.h"
#include "cef/libcef/common/values_impl.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/render_frame_host.h"
@@ -37,7 +37,6 @@ 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;
@@ -46,38 +45,30 @@ 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 nullptr if the browser has not yet been created (before
// SetBrowser) or if the browser has been destroyed (after BrowserDestroyed).
// May return NULL if the browser has not yet been created or if the browser
// has been destroyed.
CefRefPtr<CefBrowserHostBase> browser() const;
// Returns true if the browser has been created (after SetBrowser) and is not
// yet closing (before SetClosing or WebContentsDestroyed).
bool IsValid() const;
// Returns true if the browser is closing (after SetClosing or
// WebContentsDestroyed).
bool IsClosing() const;
// Called from CefBrowserHostBase constructor.
// Set or clear the browser. Called from CefBrowserHostBase InitializeBrowser
// (to set) and DestroyBrowser (to clear).
void SetBrowser(CefRefPtr<CefBrowserHostBase> browser);
// Called from CefBrowserHostBase::OnBeforeClose.
// Called after OnBeforeClose and before SetBrowser(nullptr). This will cause
// browser() and GetMainFrame() to return nullptr as expected by
// CefFrameHandler callbacks. Note that this differs from calling
// SetBrowser(nullptr) because the WebContents has not yet been destroyed and
// further frame-related callbacks are expected.
void SetClosing();
// Called from CefBrowserHostBase::DestroyWebContents.
void WebContentsDestroyed();
// Called from CefBrowserHostBase::DestroyBrowser.
void BrowserDestroyed();
// 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.
void MaybeCreateFrame(content::RenderFrameHost* host);
// Called from CefBrowserContentsDelegate::RenderFrameCreated (is_guest_view =
// false) or CefMimeHandlerViewGuestDelegate::OnGuestAttached (is_guest_view =
// true).
void MaybeCreateFrame(content::RenderFrameHost* host, bool is_guest_view);
// Used to track state changes such as entering/exiting the BackForwardCache.
// Called from CefBrowserContentsDelegate::RenderFrameHostStateChanged.
@@ -109,22 +100,32 @@ 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. Must be called on the UI thread.
// 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.
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. Safe to call from any thread.
// 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.
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. Safe to
// call from any thread.
// 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.
using FrameHostList = std::set<CefRefPtr<CefFrameHostImpl>>;
FrameHostList GetAllFrames() const;
@@ -179,7 +180,9 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
return frame_ && is_main_frame_ && !is_speculative_ && !is_in_bfcache_;
}
content::RenderFrameHost* host_;
content::GlobalRenderFrameHostId global_id_;
bool is_guest_view_;
bool is_main_frame_;
bool is_speculative_;
bool is_in_bfcache_ = false;
@@ -198,10 +201,9 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
void RemoveAllFrames(CefRefPtr<CefBrowserHostBase> old_browser);
const int browser_id_;
const bool is_popup_;
const bool is_windowless_;
const bool print_preview_enabled_;
int browser_id_;
bool is_popup_;
bool is_windowless_;
CefRefPtr<CefDictionaryValue> extra_info_;
// Navigation will be blocked while |navigation_lock_| exists.
@@ -219,7 +221,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
protected:
friend class CefBrowserInfo;
const raw_ptr<CefBrowserInfo> browser_info_;
CefBrowserInfo* const browser_info_;
CefRefPtr<CefFrameHandler> frame_handler_;
std::unique_ptr<base::AutoLock> browser_info_lock_scope_;
std::queue<FrameNotifyOnceAction> queue_;
@@ -228,7 +230,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
mutable base::Lock notification_lock_;
// These members must be protected by |notification_lock_|.
raw_ptr<NotificationStateLock> notification_state_lock_ = nullptr;
NotificationStateLock* notification_state_lock_ = nullptr;
CefRefPtr<CefFrameHandler> frame_handler_;
mutable base::Lock lock_;

View File

@@ -2,22 +2,23 @@
// Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "cef/libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_info_manager.h"
#include <utility>
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#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 "base/command_line.h"
#include "base/logging.h"
#include "base/task/sequenced_task_runner.h"
#include "cef/libcef/browser/browser_host_base.h"
#include "cef/libcef/browser/browser_platform_delegate.h"
#include "cef/libcef/browser/extensions/browser_extensions_util.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/cef_switches.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "cef/libcef/common/frame_util.h"
#include "cef/libcef/common/values_impl.h"
#include "cef/libcef/features/runtime.h"
#include "content/public/browser/child_process_host.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
@@ -65,13 +66,11 @@ 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,
print_preview_enabled, extra_info);
scoped_refptr<CefBrowserInfo> browser_info = new CefBrowserInfo(
++next_browser_id_, is_popup, is_windowless, extra_info);
browser_info_list_.push_back(browser_info);
return browser_info;
@@ -80,23 +79,24 @@ 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) {
CEF_REQUIRE_UIT();
base::AutoLock lock_scope(browser_info_lock_);
auto frame_host = new_contents->GetPrimaryMainFrame();
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);
}
scoped_refptr<CefBrowserInfo> browser_info =
new CefBrowserInfo(++next_browser_id_, true, is_windowless, extra_info);
browser_info_list_.push_back(browser_info);
// Continue any pending NewBrowserInfo request.
ContinueNewBrowserInfo(frame_host->GetGlobalFrameToken(), browser_info,
/*is_excluded=*/false);
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);
}
return browser_info;
}
@@ -129,7 +129,10 @@ bool CefBrowserInfoManager::CanCreateWindow(
bool handled = false;
CefWindowInfo window_info;
CefBrowserCreateParams::InitWindowInfo(&window_info, browser.get());
#if BUILDFLAG(IS_WIN)
window_info.SetAsPopup(nullptr, CefString());
#endif
auto pending_popup = std::make_unique<CefBrowserInfoManager::PendingPopup>();
pending_popup->step = PendingPopup::CAN_CREATE_WINDOW;
@@ -182,12 +185,10 @@ bool CefBrowserInfoManager::CanCreateWindow(
if (allow) {
CefBrowserCreateParams create_params;
create_params.MaybeSetWindowInfo(window_info, /*allow_alloy_style=*/true,
/*allow_chrome_style=*/true);
create_params.MaybeSetWindowInfo(window_info);
if (!handled) {
// Use default Browser creation with Chrome style if OnBeforePopup was
// unhandled.
// Use default Browser creation if OnBeforePopup was unhandled.
// TODO(chrome): Expose a mechanism for the client to choose default
// creation.
pending_popup->use_default_browser_creation = true;
@@ -195,10 +196,6 @@ 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;
@@ -207,11 +204,6 @@ 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:"
@@ -231,9 +223,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());
@@ -257,10 +249,13 @@ void CefBrowserInfoManager::WebContentsCreated(
content::WebContents* new_contents) {
CEF_REQUIRE_UIT();
// 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);
// 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);
DCHECK(pending_popup.get());
DCHECK(pending_popup->platform_delegate.get());
@@ -269,8 +264,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 Chrome style.
if (!pending_popup->alloy_style) {
// AddWebContents (the next step) is only used with the Chrome runtime.
if (cef::IsChromeRuntimeEnabled()) {
pending_popup->step = PendingPopup::WEB_CONTENTS_CREATED;
pending_popup->new_contents = new_contents;
PushPendingPopup(std::move(pending_popup));
@@ -279,18 +274,14 @@ void CefBrowserInfoManager::WebContentsCreated(
bool CefBrowserInfoManager::AddWebContents(content::WebContents* new_contents) {
CEF_REQUIRE_UIT();
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
DCHECK(cef::IsChromeRuntimeEnabled());
#endif
// Pending popup information may be missing in cases where
// chrome::AddWebContents is called directly from the Chrome UI (profile
// settings, etc).
auto pending_popup =
PopPendingPopup(PendingPopup::WEB_CONTENTS_CREATED,
PendingPopup::WEB_CONTENTS_CREATED, new_contents);
PopPendingPopup(PendingPopup::WEB_CONTENTS_CREATED, new_contents);
if (pending_popup) {
DCHECK(!pending_popup->alloy_style);
return !pending_popup->use_default_browser_creation;
}
@@ -308,13 +299,15 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
base::AutoLock lock_scope(browser_info_lock_);
bool is_guest_view = false;
scoped_refptr<CefBrowserInfo> browser_info =
GetBrowserInfoInternal(global_token);
GetBrowserInfoInternal(global_token, &is_guest_view);
if (browser_info) {
// Send the response immediately.
SendNewBrowserInfoResponse(browser_info, /*is_excluded=*/false,
std::move(callback), callback_runner);
SendNewBrowserInfoResponse(browser_info, is_guest_view, std::move(callback),
callback_runner);
return;
}
@@ -345,54 +338,6 @@ 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(
@@ -441,15 +386,17 @@ void CefBrowserInfoManager::DestroyAllBrowsers() {
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
const content::GlobalRenderFrameHostId& global_id) {
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view) {
base::AutoLock lock_scope(browser_info_lock_);
return GetBrowserInfoInternal(global_id);
return GetBrowserInfoInternal(global_id, is_guest_view);
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token) {
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view) {
base::AutoLock lock_scope(browser_info_lock_);
return GetBrowserInfoInternal(global_token);
return GetBrowserInfoInternal(global_token, is_guest_view);
}
bool CefBrowserInfoManager::MaybeAllowNavigation(
@@ -458,14 +405,15 @@ bool CefBrowserInfoManager::MaybeAllowNavigation(
CefRefPtr<CefBrowserHostBase>& browser_out) const {
CEF_REQUIRE_UIT();
auto browser = CefBrowserHostBase::GetBrowserForHost(opener);
bool is_guest_view = false;
auto browser = extensions::GetOwnerBrowserForHost(opener, &is_guest_view);
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, params)) {
if (!browser->MaybeAllowNavigation(opener, is_guest_view, params)) {
return false;
}
@@ -486,83 +434,6 @@ 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_);
@@ -619,21 +490,16 @@ void CefBrowserInfoManager::PushPendingPopup(
std::unique_ptr<CefBrowserInfoManager::PendingPopup>
CefBrowserInfoManager::PopPendingPopup(
PendingPopup::Step previous_step_alloy,
PendingPopup::Step previous_step_chrome,
PendingPopup::Step previous_step,
const content::GlobalRenderFrameHostId& opener_global_id,
const GURL& target_url) {
CEF_REQUIRE_UIT();
DCHECK(frame_util::IsValidGlobalId(opener_global_id));
DCHECK_LE(previous_step_alloy, PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW);
DCHECK_LE(previous_step_chrome, PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW);
DCHECK_LE(previous_step, 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) {
@@ -648,19 +514,14 @@ CefBrowserInfoManager::PopPendingPopup(
}
std::unique_ptr<CefBrowserInfoManager::PendingPopup>
CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step previous_step_alloy,
PendingPopup::Step previous_step_chrome,
CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step previous_step,
content::WebContents* new_contents) {
CEF_REQUIRE_UIT();
DCHECK_GE(previous_step_alloy, PendingPopup::WEB_CONTENTS_CREATED);
DCHECK_GE(previous_step_chrome, PendingPopup::WEB_CONTENTS_CREATED);
DCHECK_GE(previous_step, 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();
@@ -673,16 +534,26 @@ CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step previous_step_alloy,
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
const content::GlobalRenderFrameHostId& global_id) {
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view) {
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_) {
auto frame = browser_info->GetFrameForGlobalId(global_id);
if (frame) {
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;
}
return browser_info;
}
}
@@ -691,16 +562,26 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
const content::GlobalRenderFrameHostToken& global_token) {
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view) {
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_) {
auto frame = browser_info->GetFrameForGlobalToken(global_token);
if (frame) {
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;
}
return browser_info;
}
}
@@ -711,26 +592,25 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
// static
void CefBrowserInfoManager::SendNewBrowserInfoResponse(
scoped_refptr<CefBrowserInfo> browser_info,
bool is_excluded,
bool is_guest_view,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_runner) {
if (!callback_runner->RunsTasksInCurrentSequence()) {
callback_runner->PostTask(
FROM_HERE,
base::BindOnce(&CefBrowserInfoManager::SendNewBrowserInfoResponse,
browser_info, is_excluded, std::move(callback),
browser_info, is_guest_view, std::move(callback),
callback_runner));
return;
}
auto params = cef::mojom::NewBrowserInfo::New();
params->is_excluded = is_excluded;
params->is_guest_view = is_guest_view;
if (browser_info) {
params->browser_id = browser_info->browser_id();
params->is_windowless = browser_info->is_windowless();
params->is_popup = browser_info->is_popup();
params->print_preview_enabled = browser_info->print_preview_enabled();
auto extra_info = browser_info->extra_info();
if (extra_info) {
@@ -750,7 +630,7 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
// static
void CefBrowserInfoManager::CancelNewBrowserInfoResponse(
PendingNewBrowserInfo* pending_info) {
SendNewBrowserInfoResponse(/*browser_info=*/nullptr, /*is_excluded=*/false,
SendNewBrowserInfoResponse(/*browser_info=*/nullptr, /*is_guest_view=*/false,
std::move(pending_info->callback),
pending_info->callback_runner);
}
@@ -775,21 +655,15 @@ void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse(
return;
}
// 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);
#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
LOG(ERROR) << "Timeout of new browser info response for frame "
<< frame_util::GetFrameDebugString(global_token)
<< " (has_rfh=" << has_rfh << ")";
<< frame_util::GetFrameDebugString(global_token);
CancelNewBrowserInfoResponse(pending_info.get());
g_info_manager->pending_new_browser_info_map_.erase(it);

View File

@@ -6,16 +6,17 @@
#define CEF_LIBCEF_BROWSER_BROWSER_INFO_MANAGER_H_
#pragma once
#include "include/cef_client.h"
#include <list>
#include <map>
#include <memory>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "libcef/browser/browser_info.h"
#include "base/synchronization/lock.h"
#include "base/task/sequenced_task_runner.h"
#include "cef/include/cef_client.h"
#include "cef/libcef/browser/browser_info.h"
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/render_process_host_observer.h"
@@ -57,7 +58,6 @@ 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,7 +67,6 @@ 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
@@ -109,9 +108,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. It may sometimes already exist for
// traditional popup browsers depending on timing. See comments on
// PendingPopup for more information.
// exist for explicitly created browsers and guest views. It may sometimes
// already exist for traditional popup browsers depending on timing. See
// comments on PendingPopup for more information.
void OnGetNewBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback);
@@ -125,11 +124,16 @@ 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() instead.
// 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.
scoped_refptr<CefBrowserInfo> GetBrowserInfo(
const content::GlobalRenderFrameHostId& global_id);
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view = nullptr);
scoped_refptr<CefBrowserInfo> GetBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token);
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view = nullptr);
// Returns all existing CefBrowserInfo objects.
using BrowserInfoList = std::list<scoped_refptr<CefBrowserInfo>>;
@@ -145,18 +149,6 @@ 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;
@@ -165,7 +157,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 (PDF viewer) then the popup is canceled and
// an extension guest view 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:
@@ -187,9 +179,6 @@ 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();
@@ -206,11 +195,11 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate;
// True if default Browser or tab creation should proceed from
// AddWebContents (Chrome style only).
// AddWebContents (chrome runtime only).
bool use_default_browser_creation = false;
// The newly created WebContents (set in WebContentsCreated).
raw_ptr<content::WebContents> new_contents = nullptr;
content::WebContents* new_contents = nullptr;
};
// Manage pending popups. Only called on the UI thread.
@@ -218,36 +207,27 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Used after CanCreateWindow is called.
std::unique_ptr<PendingPopup> PopPendingPopup(
PendingPopup::Step previous_step_alloy,
PendingPopup::Step previous_step_chrome,
PendingPopup::Step previous_step,
const content::GlobalRenderFrameHostId& opener_global_id,
const GURL& target_url);
// Used after WebContentsCreated is called.
std::unique_ptr<PendingPopup> PopPendingPopup(
PendingPopup::Step previous_step_alloy,
PendingPopup::Step previous_step_chrome,
PendingPopup::Step previous_step,
content::WebContents* new_contents);
// Retrieves the BrowserInfo matching the specified ID/token.
scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal(
const content::GlobalRenderFrameHostId& global_id);
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view);
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,
scoped_refptr<CefBrowserInfo> browser_info,
bool is_excluded);
bool* is_guest_view);
// Send the response for a pending OnGetNewBrowserInfo request.
static void SendNewBrowserInfoResponse(
scoped_refptr<CefBrowserInfo> browser_info,
bool is_excluded,
bool is_guest_view,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_runner);

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