Compare commits

...

72 Commits
6261 ... 6422

Author SHA1 Message Date
Marshall Greenblatt
1701b8e6d5 Pin depot_tools version for out-of-support branch 2024-06-13 13:53:48 -04:00
Marshall Greenblatt
c410c950de alloy: Move warning after logging init (fixes #3713) 2024-06-10 11:02:09 -04:00
Marshall Greenblatt
c8b1a8cb23 Update to Chromium version 125.0.6422.142 2024-06-05 16:07:43 +00:00
Marshall Greenblatt
74eca7268f Remove pinned depot_tools version (see #3709) 2024-06-03 12:52:03 -04:00
Marshall Greenblatt
3d8f1c9064 Update to Chromium version 125.0.6422.112 2024-05-27 13:57:38 +00:00
pkv
e997249d53 alloy: Fix audio capturer crash on exit (fixes #3689) 2024-05-21 14:00:37 -04:00
Marshall Greenblatt
3ccd305f6d cefclient: Use default window for DevTools non-Views popup (see #3681)
Chrome runtime only supports creation of a Views-hosted DevTools
popup in ChromeBrowserDelegate::CreateDevToolsBrowser if the parent
is also Views-hosted.

To test:
- Run `cefclient --use-native`
- Right click, select "Show DevTools"
- Close both windows and the app should exit
2024-05-20 18:47:34 -04:00
Marshall Greenblatt
99c85e32ac osr: Support DevTools windows with Chrome runtime Alloy style (see #3681) 2024-05-20 18:44:01 -04:00
Marshall Greenblatt
6da73a3d31 Update to Chromium version 125.0.6422.41 2024-05-10 14:43:46 +00:00
Marshall Greenblatt
44f7b57e79 cefsimple: Enable Chrome runtime by default (see #3685)
Run with `--disable-chrome-runtime` to use the Alloy runtime.
2024-05-09 12:18:59 -04:00
Marshall Greenblatt
331f668eee Update depot_tools to fix race when downloading gsutil
See https://issues.chromium.org/issues/338040708
2024-05-09 10:23:27 -04:00
Marshall Greenblatt
14bd14567f cefclient: Enable Chrome runtime by default (see #3685)
Run with `--disable-chrome-runtime` to use the Alloy runtime.
2024-05-09 10:21:15 -04:00
Marshall Greenblatt
69ce47ae4c Revert unretained dangling ptr detector crash by default (fixes #3693) 2024-05-06 16:53:09 -04:00
Marshall Greenblatt
0580f93839 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:17:22 -04:00
Marshall Greenblatt
3c3e543b44 alloy: Add missing geolocation pref registration (fixes #3694) 2024-05-06 12:06:04 -04:00
Marshall Greenblatt
fae4a6f0bd views: Support themes for Alloy BrowserView in Chrome Window (see #3681)
To test:
- Run `cefclient --enable-chrome-runtime --use-alloy-style
                 --use-chrome-style-window [--background-color=green]`
- OS and Chrome theme changes behave as expected.
2024-05-03 17:27:28 -04:00
Marshall Greenblatt
91ba12468b chrome: Support CefResourceBundleHandler (see #3685) 2024-05-03 13:29:24 -04:00
Marshall Greenblatt
739021e4a8 chrome: Support CefSettings logging config (see #3685)
Also enables logging by default for Release builds (previously
required the `--enable-logging` flag). Logging can still be
disabled by passing the `--disable-logging` flag.
2024-05-03 13:22:19 -04:00
Marshall Greenblatt
853ea8846a chrome: Support CefSettings path config (see #3685) 2024-05-03 13:22:02 -04:00
Marshall Greenblatt
9f45038464 Add Alloy bootstrap deprecation warnings (see #3685)
Alloy bootstrap is deprecated and will be removed in ~M127.
2024-05-03 13:02:20 -04:00
Marshall Greenblatt
39993d8c0c Update to Chromium version 125.0.6422.26 2024-05-03 13:53:32 +00:00
reito
0f68a0d7a3 win: osr: Fix GPU mutex logic (see #2575) 2024-04-29 14:59:06 +00:00
Marshall Greenblatt
a0566e64d8 Update to Chromium version 125.0.6422.14 2024-04-27 17:12:11 -04:00
Marshall Greenblatt
fe5b0dd668 chrome: osr: Fix performance manager init (see #3681) 2024-04-27 15:36:59 -04:00
Marshall Greenblatt
c0e7854782 cefclient: osr: Fix compile errors with binary distribution (see #2575) 2024-04-27 15:36:58 -04:00
Marshall Greenblatt
be6642df3f chrome: Add CefDownloadHandler support (see #3681)
Behaves the same as Alloy runtime except that CanDownload is not
called for invalid protocol schemes.
2024-04-27 15:36:58 -04:00
Marshall Greenblatt
ed079792b6 chrome: Add extension support for Alloy style browsers (see #3681)
This change adds minimal tabs API support for Alloy style browsers.
Clicking links in PDF documents now navigate as expected.
2024-04-27 15:36:58 -04:00
Marshall Greenblatt
0783b4c57d win: Fix generated binaries crashing with exit code 3221225477
See https://issues.chromium.org/issues/336007395
2024-04-26 13:46:45 -04:00
Marshall Greenblatt
b537fc929b mac: Disable dangling pointer detector (see #3239)
This is enabled by default on Mac in M125 but we can't use it until
raw_ptr<> is supported by libcef. For background see
https://chromium.googlesource.com/chromium/src/+/main/docs/dangling_ptr.md
2024-04-26 10:31:40 -04:00
Marshall Greenblatt
708d90a6ff chrome: osr: Create CefWebContentsViewOSR for guest views (see #3681)
Match the logic in Alloy's CefMimeHandlerViewGuestDelegate.
2024-04-26 10:31:40 -04:00
Marshall Greenblatt
5065aba1b4 Remove explicit tracking of guest view frames
This is no longer required now that we have implicit exclusion
of certain frame types including guest view frames.

Rename GuestView to ExcludedView in the renderer process.
2024-04-26 10:31:40 -04:00
Marshall Greenblatt
65234a6830 Ignore load of excluded PDF renderer frames
Starting with M125 we get WebContentsObserver callbacks for speculative
PDF renderer frames. These callbacks should be ignored.
2024-04-26 10:31:40 -04:00
Marshall Greenblatt
b67cbc47e3 Update to Chromium version 125.0.6422.0 (#1287751) 2024-04-25 18:43:05 -04:00
Marshall Greenblatt
4fe529e2dc mac: Enable allocator shim to fix builds (see #3061)
This is a workaround for https://crbug.com/326898585
2024-04-25 18:43:04 -04:00
reito
260dd0ca24 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-23 13:03:56 -04:00
Marshall Greenblatt
dca0435d2f chrome: Add support for Alloy style browsers and windows (see #3681)
Split the Alloy runtime into bootstrap and style components. Support
creation of Alloy style browsers and windows with the Chrome runtime.
Chrome runtime (`--enable-chrome-runtime`) + Alloy style
(`--use-alloy-style`) supports Views (`--use-views`), native parent
(`--use-native`) and windowless rendering
(`--off-screen-rendering-enabled`).

Print preview is supported in all cases except with windowless rendering
on all platforms and native parent on MacOS. It is disabled by default
with Alloy style for legacy compatibility. Where supported it can be
enabled or disabled globally using `--[enable|disable]-print-preview` or
configured on a per-RequestContext basis using the
`printing.print_preview_disabled` preference. It also behaves as
expected when triggered via the PDF viewer print button.

Chrome runtime + Alloy style behavior differs from Alloy runtime in the
following significant ways:

- Supports Chrome error pages by default.
- DevTools popups are Chrome style only (cannot be windowless).
- The Alloy extension API will not supported.

Chrome runtime + Alloy style passes all expected Alloy ceftests except
the following:

- `DisplayTest.AutoResize` (Alloy extension API not supported)
- `DownloadTest.*` (Download API not yet supported)
- `ExtensionTest.*` (Alloy extension API not supported)

This change also adds Chrome runtime support for
CefContextMenuHandler::RunContextMenu (see #3293).

This change also explicitly blocks (and doesn't retry) FrameAttached
requests from PDF viewer and print preview excluded frames (see #3664).

Known issues specific to Chrome runtime + Alloy style:
- DevTools popup with windowless rendering doesn't load successfully.
  Use windowed rendering or remote debugging as a workaround.
- Chrome style Window with Alloy style BrowserView (`--use-alloy-style
  --use-chrome-style-window`) does not show Chrome theme changes.

To test:
- Run `ceftests --enable-chrome-runtime --use-alloy-style
       [--use-chrome-style-window] [--use-views|--use-native]
       --gtest_filter=...`
- Run `cefclient --enable-chrome-runtime --use-alloy-style
       [--use-chrome-style-window]
       [--use-views|--use-native|--off-screen-rendering-enabled]`
- Run `cefsimple --enable-chrome-runtime --use-alloy-style [--use-views]`
2024-04-22 14:57:37 -04:00
Marshall Greenblatt
62c93f01f4 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:43:44 -04:00
Jacobo Aragunde Pérez
81a0648ee1 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 15:53:51 +00:00
Nik Pavlov
744a194a6e mac: views: Add customization point for acceptsFirstMouse (fixes #3680) 2024-04-12 15:49:31 +00:00
Nik Pavlov
96dc172980 Fix how CefV8ValueImpl differentiates INT and UINT types (fixes #3657) 2024-04-12 15:37:33 +00:00
Marshall Greenblatt
f1effba336 views: Fix destruction issues with CefOverlayViewHost 2024-04-11 15:51:42 -04:00
Marshall Greenblatt
d10cc16236 distrib: Add missing cef_color_id_macros.inc (see #3671) 2024-04-11 11:35:55 -04:00
Marshall Greenblatt
da1c3179a9 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:29:51 -04:00
Marshall Greenblatt
2e33954032 cefclient: Add missing draggable.html resource reference 2024-04-11 11:24:26 -04:00
Marshall Greenblatt
f60476b848 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:19:35 -04:00
Marshall Greenblatt
29c21f58e8 views: Generate cef_color_ids.h header (see #3671) 2024-04-03 12:09:22 -04:00
Marshall Greenblatt
54a9c26b92 Disable thin archives with cef_sandbox builds (fixes #3674) 2024-03-28 11:35:37 -04:00
Marshall Greenblatt
6253e69b70 views: cefclient: Fix initial toolbar button state 2024-03-28 11:35:37 -04:00
Marshall Greenblatt
8ba22e9e11 views: Update textfield colors when enabled state changes 2024-03-28 11:35:37 -04:00
Marshall Greenblatt
19ba8b2b8d views: Use default theme background color for all controls (see #3671)
Add new CefViewDelegate::OnThemeChanged callback for optionally overriding
default theme colors when the current theme changes.
2024-03-28 11:35:37 -04:00
Marshall Greenblatt
a13b6dc7f6 chrome: Use square corners for Chrome toolbar when Views-hosted
Chrome design changed to rounded top corners by default with
Chrome Refresh 2023. Square corners look better when the toolbar
is part of a custom Views-hosted layout, like in cefclient.
2024-03-22 14:50:14 -04:00
Marshall Greenblatt
52dac91167 Update to Chromium version 124.0.6367.0 (#1274542) 2024-03-22 13:46:28 -04:00
Marshall Greenblatt
526e934a12 ceftests: Check CefInitialize return value (see #3609) 2024-03-18 18:33:38 -04:00
Marshall Greenblatt
b8f91c5431 Add callbacks for unresponsive render process (fixes #3661)
The client can optionally wait or terminate the render process.

Expose process exit codes via OnRenderProcessTerminated and
CefGetExitCode (fixes #2126).

cefclient: Add a new https://tests/hang page for testing hang behavior.

cefclient: Move message and resource handling to a new BaseClientHandler
class to support loading of test pages in default Chrome UI windows.
2024-03-18 17:45:31 -04:00
Marshall Greenblatt
5e616b2df0 Improve crash reporting of frame connection retry failures (see #3664)
Introduce different call stacks for different types of disconnects,
and log additional state information in the FATAL message.
2024-03-08 14:24:32 -05:00
qqqqqqqqq
9b06b028dc Replace non-standard memory.h with cstring (fixes #3665)
cef_string_wrappers.h uses a non-standard header memory.h, which breaks
the build on UCRT environments. Replace <memory.h> include with <cstring>,
which is guaranteed to contain strlen.
2024-03-08 17:18:15 +00:00
Marshall Greenblatt
d4cf19db29 Update to Chromium version 123.0.6312.0 (#1262506)
- MacOS ARM64 Official builds are currently failing due to
  https://issues.chromium.org/issues/326898585
2024-02-26 12:08:55 -05:00
Marshall Greenblatt
2c5dd120c7 mac: Add fallback for unsupported --lang values (fixes #3653) 2024-02-20 13:15:25 -05:00
Nik Pavlov
ffea0d9c4a chrome: Add SetAccessibilityState support (fixes #3649) 2024-02-20 16:27:48 +00:00
Marshall Greenblatt
8db08e657d win: distrib: Add DirectX compiler binaries for WebGPU (fixes #3646) 2024-02-15 17:00:30 -05:00
Marshall Greenblatt
706193f3d9 Reland "alloy: Allow --remote-debugging-port=0 (fixes #3619)"
This relands commit 70471059cf
with necessary changes.
2024-02-15 16:12:47 -05:00
Marshall Greenblatt
bfed26c5fc alloy: Fix crash on JS dialog from PDF viewer (fixes #3644) 2024-02-15 15:35:11 -05:00
Marshall Greenblatt
71c8b4b2bb chrome: win: Disable taskbar decoration for PiP and DevTools windows (fixes #3645) 2024-02-15 14:17:59 -05:00
Marshall Greenblatt
ec122a9148 chrome: win: Fix crash on ShowProfileErrorDialog (fixes #3648) 2024-02-15 12:22:52 -05:00
Marshall Greenblatt
90775f149f Revert "alloy: Allow --remote-debugging-port=0 (fixes #3619)"
Reason for the revert: Incorrectly enables DevTools remote debugging
by default.

This reverts commit 70471059cf.
2024-02-14 20:02:20 -05:00
Marshall Greenblatt
f071a4a988 alloy: Fix crash when accessing FirstPartySets (fixes #3643)
Initialize FirstPartySets without PrivacySandbox or IdentityManager
dependencies.
2024-02-14 18:51:32 -05:00
Marshall Greenblatt
cc3d77eec5 chrome: Enforce matching context for new user and incognito profiles
Selecting a new user or incognito profile via Chrome UI may result in
the creation of a new Profile object. If that occurs, we should find
or create a matching CefBrowserContext and CefRequestContext instead
of reusing an existing mismatched context (e.g. using the original
context for an incognito window would be a mismatch). If a new
CefRequestContext will be created the client can now implement
CefBrowserProcessHandler::GetDefaultRequestContextHandler() to
provide the handler for that context.

To test with a new user profile:
1. Click "Profile" icon, select "Add". Now you have 2+ profiles.
2. Click "Profile" icon, select the other user name to create a new
   window using the other user profile.
3. The new window should launch successfully.

To test with a new incognito profile:
1. Select "New Incognito window" from the 3-dot menu.
2. The new window should launch successfully.

To test DevTools window creation for the new profile:
1. Right-click in the new window, select Inspect.
2. The DevTools window should launch successfully.
2024-02-14 18:51:32 -05:00
Marshall Greenblatt
a79981bf7f chrome: cefclient: Add support for --request-context-per-browser
Wait for the OnRequestContextInitialized callback before using a
non-global CefRequestContext.

Use default handling of --load-extension for Chrome runtime (fixes #3529).
2024-02-14 18:51:32 -05:00
Vladimir Kharitonov
70471059cf alloy: Allow --remote-debugging-port=0 (fixes #3619) 2024-02-07 18:42:06 +00:00
Marshall Greenblatt
5dc3cc13e7 chrome: win: Fix taskbar grouping of PiP and DevTools windows (fixes #3641) 2024-02-06 13:55:01 -05:00
Marshall Greenblatt
da3899d142 views: win: Fix occlusion tracking of initially-minimized windows (fixes #3638)
Chromium considers initially-minimized windows to be visible at
creation time in the Aura layer. This confuses the native occlusion
detector which knows that the OS window is initially hidden due to
IsIconic returning true. Start occlusion tracking with consistent
state by delaying enablement until the initially-minimized window is
restored for the first time.
2024-02-05 16:24:51 -05:00
Shezan Baig
69fd43f789 Always assign |is_guest_view| in CefBrowserInfo::GetFrameForGlobalToken 2024-02-05 16:31:04 +00:00
588 changed files with 15338 additions and 5406 deletions

View File

@@ -465,12 +465,22 @@ source_set("libcef_static") {
"libcef/browser/alloy/alloy_browser_main.h",
"libcef/browser/alloy/alloy_content_browser_client.cc",
"libcef/browser/alloy/alloy_content_browser_client.h",
"libcef/browser/alloy/alloy_download_manager_delegate.cc",
"libcef/browser/alloy/alloy_download_manager_delegate.h",
"libcef/browser/alloy/alloy_download_util.cc",
"libcef/browser/alloy/alloy_download_util.h",
"libcef/browser/alloy/alloy_web_contents_view_delegate.cc",
"libcef/browser/alloy/alloy_web_contents_view_delegate.h",
"libcef/browser/alloy/browser_platform_delegate_alloy.cc",
"libcef/browser/alloy/browser_platform_delegate_alloy.h",
"libcef/browser/alloy/devtools/alloy_devtools_window_runner.cc",
"libcef/browser/alloy/devtools/alloy_devtools_window_runner.h",
"libcef/browser/alloy/devtools/devtools_file_manager.cc",
"libcef/browser/alloy/devtools/devtools_file_manager.h",
"libcef/browser/alloy/devtools/devtools_frontend.cc",
"libcef/browser/alloy/devtools/devtools_frontend.h",
"libcef/browser/alloy/devtools/devtools_manager_delegate.cc",
"libcef/browser/alloy/devtools/devtools_manager_delegate.h",
"libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.cc",
"libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h",
"libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.cc",
@@ -528,9 +538,14 @@ source_set("libcef_static") {
"libcef/browser/chrome/chrome_content_browser_client_cef.h",
"libcef/browser/chrome/chrome_context_menu_handler.cc",
"libcef/browser/chrome/chrome_context_menu_handler.h",
"libcef/browser/chrome/chrome_devtools_window_runner.cc",
"libcef/browser/chrome/chrome_devtools_window_runner.h",
"libcef/browser/chrome/chrome_startup_browser_creator.cc",
"libcef/browser/chrome/chrome_startup_browser_creator.h",
"libcef/browser/chrome/chrome_web_contents_view_delegate_cef.h",
"libcef/browser/chrome_crash_reporter_client_stub.cc",
"libcef/browser/chrome/extensions/chrome_extension_util.cc",
"libcef/browser/chrome/extensions/chrome_extension_util.h",
"libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.cc",
"libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.h",
"libcef/browser/chrome/views/browser_platform_delegate_chrome_child_window.cc",
@@ -555,18 +570,16 @@ source_set("libcef_static") {
"libcef/browser/context_menu_params_impl.h",
"libcef/browser/devtools/devtools_controller.cc",
"libcef/browser/devtools/devtools_controller.h",
"libcef/browser/devtools/devtools_file_manager.cc",
"libcef/browser/devtools/devtools_file_manager.h",
"libcef/browser/devtools/devtools_frontend.cc",
"libcef/browser/devtools/devtools_frontend.h",
"libcef/browser/devtools/devtools_manager.cc",
"libcef/browser/devtools/devtools_manager.h",
"libcef/browser/devtools/devtools_manager_delegate.cc",
"libcef/browser/devtools/devtools_manager_delegate.h",
"libcef/browser/devtools/devtools_protocol_manager.cc",
"libcef/browser/devtools/devtools_protocol_manager.h",
"libcef/browser/devtools/devtools_window_runner.h",
"libcef/browser/devtools/devtools_window_runner_create.cc",
"libcef/browser/download_item_impl.cc",
"libcef/browser/download_item_impl.h",
"libcef/browser/download_manager_delegate.cc",
"libcef/browser/download_manager_delegate.h",
"libcef/browser/download_manager_delegate_impl.cc",
"libcef/browser/download_manager_delegate_impl.h",
"libcef/browser/extension_impl.cc",
"libcef/browser/extension_impl.h",
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.cc",
@@ -620,6 +633,8 @@ source_set("libcef_static") {
"libcef/browser/frame_service_base.h",
"libcef/browser/global_preference_manager_impl.cc",
"libcef/browser/global_preference_manager_impl.h",
"libcef/browser/hang_monitor.cc",
"libcef/browser/hang_monitor.h",
"libcef/browser/image_impl.cc",
"libcef/browser/image_impl.h",
"libcef/browser/iothread_state.cc",
@@ -772,6 +787,8 @@ source_set("libcef_static") {
"libcef/browser/views/browser_view_view.h",
"libcef/browser/views/button_impl.h",
"libcef/browser/views/button_view.h",
"libcef/browser/views/color_provider_tracker.cc",
"libcef/browser/views/color_provider_tracker.h",
"libcef/browser/views/display_impl.cc",
"libcef/browser/views/display_impl.h",
"libcef/browser/views/fill_layout_impl.cc",
@@ -807,7 +824,11 @@ source_set("libcef_static") {
"libcef/browser/views/view_util.cc",
"libcef/browser/views/view_util.h",
"libcef/browser/views/view_view.h",
"libcef/browser/views/widget.cc",
"libcef/browser/views/widget.h",
"libcef/browser/views/widget_destruction_observer.h",
"libcef/browser/views/widget_impl.cc",
"libcef/browser/views/widget_impl.h",
"libcef/browser/views/window_impl.cc",
"libcef/browser/views/window_impl.h",
"libcef/browser/views/window_view.cc",
@@ -915,6 +936,8 @@ source_set("libcef_static") {
"libcef/features/runtime_checks.h",
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
"libcef/renderer/alloy/alloy_content_renderer_client.h",
"libcef/renderer/alloy/alloy_render_frame_observer.cc",
"libcef/renderer/alloy/alloy_render_frame_observer.h",
"libcef/renderer/alloy/alloy_render_thread_observer.cc",
"libcef/renderer/alloy/alloy_render_thread_observer.h",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.cc",
@@ -927,12 +950,10 @@ source_set("libcef_static") {
"libcef/renderer/dom_document_impl.h",
"libcef/renderer/dom_node_impl.cc",
"libcef/renderer/dom_node_impl.h",
"libcef/renderer/extensions/extensions_dispatcher_delegate.cc",
"libcef/renderer/extensions/extensions_dispatcher_delegate.h",
"libcef/renderer/extensions/extensions_renderer_api_provider.cc",
"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",
@@ -1121,27 +1142,30 @@ source_set("libcef_static") {
"libcef/common/util_linux.cc",
]
if (ozone_platform_x11) {
sources += [
"libcef/browser/native/window_x11.cc",
"libcef/browser/native/window_x11.h",
]
}
deps += [
"//build/config/freetype",
"//third_party/fontconfig",
]
if (is_linux && !ozone_platform_x11) {
deps += [
"//third_party/angle:libEGL",
if (ozone_platform_x11) {
sources += [
"libcef/browser/native/window_x11.cc",
"libcef/browser/native/window_x11.h",
]
} else {
deps += [ "//third_party/angle:libEGL" ]
}
if (use_dbus) {
deps += [ "//dbus" ]
defines = [ "USE_DBUS" ]
}
}
if (is_mac) {
sources += includes_mac + [
"libcef/browser/chrome/chrome_content_browser_client_cef_mac.mm",
"libcef/browser/chrome/chrome_web_contents_view_delegate_cef_mac.mm",
"libcef/browser/native/browser_platform_delegate_native_mac.h",
"libcef/browser/native/browser_platform_delegate_native_mac.mm",
"libcef/browser/native/cursor_util_mac.mm",
@@ -1163,6 +1187,10 @@ source_set("libcef_static") {
"//chrome/app/chrome_main_mac.h",
"//chrome/app/chrome_main_mac.mm",
]
} else {
sources += [
"libcef/browser/chrome/chrome_web_contents_view_delegate_cef.cc",
]
}
if (ozone_platform_x11) {
@@ -1476,6 +1504,20 @@ action("make_config_header") {
args = rebase_path(outputs + [ "$root_out_dir/args.gn" ], root_build_dir)
}
# Generate cef_color_ids.h.
action("make_colorids_header") {
script = "tools/make_colorids_header.py"
inputs = [
"//ui/color/color_id.h",
"//components/color/color_id.h",
"//chrome/browser/ui/color/chrome_color_id.h",
]
outputs = [ "$root_out_dir/includes/include/cef_color_ids.h" ]
args = rebase_path(outputs + inputs, root_build_dir)
}
# Generate pack files and associated CEF header files.
group("cef_make_headers") {
deps = [
@@ -1484,6 +1526,7 @@ group("cef_make_headers") {
":make_pack_header_command_ids",
":make_api_hash_header",
":make_config_header",
":make_colorids_header",
]
}
@@ -1962,6 +2005,7 @@ if (is_mac) {
]
frameworks = [
"AppKit.framework",
"IOSurface.framework",
"OpenGL.framework",
]
defines = [

View File

@@ -7,5 +7,6 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/122.0.6261.0'
'chromium_checkout': 'refs/tags/125.0.6422.142',
'depot_tools_checkout': '3e4ab13934'
}

View File

@@ -39,6 +39,7 @@
'chrome/renderer/chrome_content_renderer_client.*',
'chrome/renderer/extensions/chrome_extensions_renderer_client.*',
'components/content_settings/core/common/content_settings_types.mojom',
'components/permissions/request_type.h',
'content/browser/renderer_host/render_widget_host_view_base.*',
'content/public/browser/content_browser_client.*',
'content/public/browser/render_widget_host_view.h',

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=25599539f43226aac01bfcb74f19ac74217aee9a$
# $hash=3b28f3236c16d2b776a44674ae3bae0a070e9f27$
#
{
@@ -85,6 +85,7 @@
'include/cef_task.h',
'include/cef_thread.h',
'include/cef_trace.h',
'include/cef_unresponsive_process_callback.h',
'include/cef_urlrequest.h',
'include/cef_v8.h',
'include/cef_values.h',
@@ -189,6 +190,7 @@
'include/capi/cef_task_capi.h',
'include/capi/cef_thread_capi.h',
'include/capi/cef_trace_capi.h',
'include/capi/cef_unresponsive_process_callback_capi.h',
'include/capi/cef_urlrequest_capi.h',
'include/capi/cef_v8_capi.h',
'include/capi/cef_values_capi.h',
@@ -508,6 +510,8 @@
'libcef_dll/cpptoc/urlrequest_cpptoc.h',
'libcef_dll/ctocpp/urlrequest_client_ctocpp.cc',
'libcef_dll/ctocpp/urlrequest_client_ctocpp.h',
'libcef_dll/cpptoc/unresponsive_process_callback_cpptoc.cc',
'libcef_dll/cpptoc/unresponsive_process_callback_cpptoc.h',
'libcef_dll/ctocpp/v8accessor_ctocpp.cc',
'libcef_dll/ctocpp/v8accessor_ctocpp.h',
'libcef_dll/ctocpp/v8array_buffer_release_callback_ctocpp.cc',
@@ -836,6 +840,8 @@
'libcef_dll/ctocpp/urlrequest_ctocpp.h',
'libcef_dll/cpptoc/urlrequest_client_cpptoc.cc',
'libcef_dll/cpptoc/urlrequest_client_cpptoc.h',
'libcef_dll/ctocpp/unresponsive_process_callback_ctocpp.cc',
'libcef_dll/ctocpp/unresponsive_process_callback_ctocpp.h',
'libcef_dll/cpptoc/v8accessor_cpptoc.cc',
'libcef_dll/cpptoc/v8accessor_cpptoc.h',
'libcef_dll/cpptoc/v8array_buffer_release_callback_cpptoc.cc',

View File

@@ -29,6 +29,7 @@
'include/base/cef_weak_ptr.h',
'include/base/internal/cef_bind_internal.h',
'include/base/internal/cef_callback_internal.h',
'include/base/internal/cef_color_id_macros.inc',
'include/base/internal/cef_lock_impl.h',
'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h',
'include/base/internal/cef_scoped_policy.h',
@@ -55,6 +56,8 @@
'include/internal/cef_types.h',
'include/internal/cef_types_content_settings.h',
'include/internal/cef_types_geometry.h',
'include/internal/cef_types_runtime.h',
'include/internal/cef_types_color.h',
],
'includes_capi': [
'include/capi/cef_base_capi.h',
@@ -220,6 +223,8 @@
'tests/shared/browser/util_win.h',
],
'cefclient_sources_browser': [
'tests/cefclient/browser/base_client_handler.cc',
'tests/cefclient/browser/base_client_handler.h',
'tests/cefclient/browser/binary_transfer_test.cc',
'tests/cefclient/browser/binary_transfer_test.h',
'tests/cefclient/browser/binding_test.cc',
@@ -240,10 +245,11 @@
'tests/cefclient/browser/client_prefs.cc',
'tests/cefclient/browser/client_prefs.h',
'tests/cefclient/browser/client_types.h',
'tests/cefclient/browser/default_client_handler.cc',
'tests/cefclient/browser/default_client_handler.h',
'tests/cefclient/browser/dialog_test.cc',
'tests/cefclient/browser/dialog_test.h',
'tests/cefclient/browser/hang_test.cc',
'tests/cefclient/browser/hang_test.h',
'tests/cefclient/browser/image_cache.cc',
'tests/cefclient/browser/image_cache.h',
'tests/cefclient/browser/main_context.cc',
@@ -309,11 +315,12 @@
'tests/cefclient/renderer/performance_test_tests.cc',
],
'cefclient_sources_resources': [
'tests/cefclient/resources/binary_transfer.html',
'tests/cefclient/resources/binding.html',
'tests/cefclient/resources/dialogs.html',
'tests/cefclient/resources/draggable.html',
'tests/cefclient/resources/hang.html',
'tests/cefclient/resources/ipc_performance.html',
'tests/cefclient/resources/binary_transfer.html',
'tests/cefclient/resources/localstorage.html',
'tests/cefclient/resources/logo.png',
'tests/cefclient/resources/media_router.html',

View File

@@ -304,8 +304,9 @@ if(OS_MAC)
# Standard libraries.
set(CEF_STANDARD_LIBS
-lpthread
"-framework Cocoa"
"-framework AppKit"
"-framework Cocoa"
"-framework IOSurface"
)
# Find the newest available base SDK.
@@ -554,6 +555,13 @@ if(OS_WINDOWS)
vulkan-1.dll
)
if(PROJECT_ARCH STREQUAL "x86_64")
list(APPEND CEF_BINARY_FILES
dxil.dll
dxcompiler.dll
)
endif()
# List of CEF resource files.
set(CEF_RESOURCE_FILES
chrome_100_percent.pak

View File

@@ -0,0 +1,50 @@
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The following macros are used to declare both the color id enumerations and
// the stringized names of the enumeration elements for use in dump_colors. To
// stringize the element names, define STRINGIZE_COLOR_IDS prior to including
// this file. This file is intended to be included just before and just after
// the enumeration or string array declarations.
#if !defined(COLOR_ID_MACROS_DEFINED)
#define COLOR_ID_MACROS_DEFINED
#if defined(STRINGIZE_COLOR_IDS)
// Convert first token to string, throw away the rest.
#define D1(enum_name) #enum_name
#define D2(enum_name, enum_value) #enum_name
#else // defined(STRINGIZE_COLOR_IDS)
// Declare enum with optional assigned value.
#define D1(enum_name) enum_name
#define D2(enum_name, enum_value) enum_name = enum_value
#endif // defined(STRINGIZE_COLOR_IDS)
// Select which token in the declaration is the assigned value.
// Use first and optional third token, ignore optional second.
#define E1(enum_name) D1(enum_name)
#define E2(enum_name, old_enum_name) D1(enum_name)
#define E3(enum_name, old_enum_name, enum_value) D2(enum_name, enum_value)
#define GET_E(_1, _2, _3, macro_name, ...) macro_name
#if defined(COMPILER_MSVC)
// Workaround for MSVC not properly expanding __VA_ARGS__.
#define EXPAND(x) x
#define E_CPONLY(...) EXPAND(E(__VA_ARGS__))
#define E(...) EXPAND(GET_E(__VA_ARGS__, E3, E2, E1)(__VA_ARGS__)),
#else // !defined(COMPILER_MSVC)
#define E_CPONLY(...) E(__VA_ARGS__)
#define E(...) GET_E(__VA_ARGS__, E3, E2, E1)(__VA_ARGS__),
#endif // !defined(COMPILER_MSVC)
#else // !defined(COLOR_ID_MACROS_DEFINED)
#undef D1
#undef D2
#undef E1
#undef E2
#undef E3
#if defined(COMPILER_MSVC)
#undef EXPAND
#endif
#undef E_CPONLY
#undef GET_E
#undef E
#undef COLOR_ID_MACROS_DEFINED
#endif // !defined(COLOR_ID_MACROS_DEFINED)

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=b9a2bad4a30bcb99384197c9f7409116dc5b376e$
// $hash=dfa0d4d2da319b2fd5e92324fd14301b500ceb5c$
//
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
@@ -137,15 +137,26 @@ CEF_EXPORT int cef_execute_process(const cef_main_args_t* args,
/// true (1) if initialization succeeds. Returns false (0) if initialization
/// fails or if early exit is desired (for example, due to process singleton
/// relaunch behavior). If this function returns false (0) then the application
/// should exit immediately without calling any other CEF functions. The
/// |windows_sandbox_info| parameter is only used on Windows and may be NULL
/// (see cef_sandbox_win.h for details).
/// should exit immediately without calling any other CEF functions except,
/// optionally, CefGetErrorCode. The |windows_sandbox_info| parameter is only
/// used on Windows and may be NULL (see cef_sandbox_win.h for details).
///
CEF_EXPORT int cef_initialize(const cef_main_args_t* args,
const struct _cef_settings_t* settings,
cef_app_t* application,
void* windows_sandbox_info);
///
/// This function can optionally be called on the main application thread after
/// CefInitialize to retrieve the initialization exit code. When CefInitialize
/// returns true (1) the exit code will be 0 (CEF_RESULT_CODE_NORMAL_EXIT).
/// Otherwise, see cef_resultcode_t for possible exit code values including
/// browser process initialization errors and normal early exit conditions (such
/// as CEF_RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED for process singleton
/// relaunch behavior).
///
CEF_EXPORT int cef_get_exit_code(void);
///
/// This function should be called on the main application thread to shut down
/// the CEF browser process before the application exits. Do not call any other

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=e7f9480661f77931890085d6c5bf23d9842212e2$
// $hash=6ee74f31d37a1b5ab3c9c5ccbe2dce9841329b38$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
@@ -911,6 +911,8 @@ typedef struct _cef_browser_host_t {
/// Returns the extension hosted in this browser or NULL if no extension is
/// hosted. See cef_request_context_t::LoadExtension for details.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
struct _cef_browser_host_t* self);
@@ -919,6 +921,8 @@ typedef struct _cef_browser_host_t {
/// script. Background hosts do not have a window and are not displayable. See
/// cef_request_context_t::LoadExtension for details.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
int(CEF_CALLBACK* is_background_host)(struct _cef_browser_host_t* self);
///
@@ -974,6 +978,24 @@ typedef struct _cef_browser_host_t {
struct _cef_browser_host_t* self,
int command_id,
cef_window_open_disposition_t disposition);
///
/// Returns true (1) if the render process associated with this browser is
/// currently unresponsive as indicated by a lack of input event processing
/// for at least 15 seconds. To receive associated state change notifications
/// and optionally handle an unresponsive render process implement
/// cef_request_handler_t::OnRenderProcessUnresponsive. This function can only
/// be called on the UI thread.
///
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=f844d2a1e39d822129d0733f33c14d27481c36b7$
// $hash=d958d5bed7f909f6313facef3440fb8ba07a5c01$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
@@ -44,6 +44,7 @@
#include "include/capi/cef_client_capi.h"
#include "include/capi/cef_command_line_capi.h"
#include "include/capi/cef_preference_capi.h"
#include "include/capi/cef_request_context_handler_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
@@ -147,14 +148,26 @@ typedef struct _cef_browser_process_handler_t {
int64_t delay_ms);
///
/// Return the default client for use with a newly created browser window. If
/// null is returned the browser will be unmanaged (no callbacks will be
/// executed for that browser) and application shutdown will be blocked until
/// the browser window is closed manually. This function is currently only
/// used with the chrome runtime.
/// Return the default client for use with a newly created browser window
/// (cef_browser_t object). If null is returned the cef_browser_t will be
/// unmanaged (no callbacks will be executed for that cef_browser_t) and
/// application shutdown will be blocked until the browser window is closed
/// manually. This function is currently only used with the Chrome runtime
/// when creating new browser windows via Chrome UI.
///
struct _cef_client_t*(CEF_CALLBACK* get_default_client)(
struct _cef_browser_process_handler_t* self);
///
/// Return the default handler for use with a new user or incognito profile
/// (cef_request_context_t object). If null is returned the
/// cef_request_context_t will be unmanaged (no callbacks will be executed for
/// that cef_request_context_t). This function is currently only used with the
/// Chrome runtime when creating new browser windows via Chrome UI.
///
struct _cef_request_context_handler_t*(
CEF_CALLBACK* get_default_request_context_handler)(
struct _cef_browser_process_handler_t* self);
} cef_browser_process_handler_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=60a08a60be70e8fe5df17f18f8e5758e1830d5e1$
// $hash=7ecfb07a95315ff81937e9f68d419122fc88f1b7$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
@@ -117,12 +117,13 @@ typedef struct _cef_download_handler_t {
///
/// Called before a download begins. |suggested_name| is the suggested name
/// for the download file. By default the download will be canceled. Execute
/// |callback| either asynchronously or in this function to continue the
/// download if desired. Do not keep a reference to |download_item| outside of
/// this function.
/// for the download file. Return true (1) and execute |callback| either
/// asynchronously or in this function to continue or cancel the download.
/// Return false (0) to proceed with default handling (cancel with Alloy
/// style, download shelf with Chrome style). Do not keep a reference to
/// |download_item| outside of this function.
///
void(CEF_CALLBACK* on_before_download)(
int(CEF_CALLBACK* on_before_download)(
struct _cef_download_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_download_item_t* download_item,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=0ca2b788f70f8c9f5b2706d691d8e063be00ed19$
// $hash=634054ad25154c30fb4ec630fe7fb79b0cf1f9b3$
//
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
@@ -54,6 +54,8 @@ struct _cef_request_context_t;
/// Object representing an extension. Methods may be called on any thread unless
/// otherwise indicated.
///
/// WARNING: This API is deprecated and will be removed in ~M127.
///
typedef struct _cef_extension_t {
///
/// Base structure.

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=5cfff4465a586d2b2ea7b54a9549096faec415f6$
// $hash=ebac34c9b85de780ce7524211c5dd61a80d4576c$
//
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
@@ -80,6 +80,8 @@ typedef struct _cef_get_extension_resource_callback_t {
/// cef_request_context_t::LoadExtension for information about extension
/// loading.
///
/// WARNING: This API is deprecated and will be removed in ~M127.
///
typedef struct _cef_extension_handler_t {
///
/// Base structure.

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=5309b2f6da62526ed92c928c0918bc27898cf03b$
// $hash=5151b6ea3c06e46a75f2cd7679044a2891063d29$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_
@@ -149,17 +149,27 @@ typedef struct _cef_render_handler_t {
/// Called when an element has been rendered to the shared texture handle.
/// |type| indicates whether the element is the view or the popup widget.
/// |dirtyRects| contains the set of rectangles in pixel coordinates that need
/// to be repainted. |shared_handle| is the handle for a D3D11 Texture2D that
/// can be accessed via ID3D11Device using the OpenSharedResource function.
/// This function is only called when cef_window_tInfo::shared_texture_enabled
/// is set to true (1), and is currently only supported on Windows.
/// to be repainted. |info| contains the shared handle; on Windows it is a
/// HANDLE to a texture that can be opened with D3D11 OpenSharedResource, on
/// macOS it is an IOSurface pointer that can be opened with Metal or OpenGL,
/// and on Linux it contains several planes, each with an fd to the underlying
/// system native buffer.
///
void(CEF_CALLBACK* on_accelerated_paint)(struct _cef_render_handler_t* self,
struct _cef_browser_t* browser,
cef_paint_element_type_t type,
size_t dirtyRectsCount,
cef_rect_t const* dirtyRects,
void* shared_handle);
/// The underlying implementation uses a pool to deliver frames. As a result,
/// the handle may differ every frame depending on how many frames are in-
/// progress. The handle's resource cannot be cached and cannot be accessed
/// outside of this callback. It should be reopened each time this callback is
/// executed and the contents should be copied to a texture owned by the
/// client application. The contents of |info| will be released back to the
/// pool after this callback returns.
///
void(CEF_CALLBACK* on_accelerated_paint)(
struct _cef_render_handler_t* self,
struct _cef_browser_t* browser,
cef_paint_element_type_t type,
size_t dirtyRectsCount,
cef_rect_t const* dirtyRects,
const cef_accelerated_paint_info_t* info);
///
/// Called to retrieve the size of the touch handle for the specified

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=23302ef6e4458aa3e7065aeaca3421a6f0b58361$
// $hash=2c496139ca9a59303b1493ee93d2c3ae96a956c0$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@@ -253,6 +253,8 @@ typedef struct _cef_request_context_t {
/// See https://developer.chrome.com/extensions for extension implementation
/// and usage documentation.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
void(CEF_CALLBACK* load_extension)(struct _cef_request_context_t* self,
const cef_string_t* root_directory,
struct _cef_dictionary_value_t* manifest,
@@ -264,6 +266,8 @@ typedef struct _cef_request_context_t {
/// access to the extension (see HasExtension). This function must be called
/// on the browser process UI thread.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
int(CEF_CALLBACK* did_load_extension)(struct _cef_request_context_t* self,
const cef_string_t* extension_id);
@@ -273,6 +277,8 @@ typedef struct _cef_request_context_t {
/// extension (see DidLoadExtension). This function must be called on the
/// browser process UI thread.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
int(CEF_CALLBACK* has_extension)(struct _cef_request_context_t* self,
const cef_string_t* extension_id);
@@ -282,6 +288,8 @@ typedef struct _cef_request_context_t {
/// extension ID values. Returns true (1) on success. This function must be
/// called on the browser process UI thread.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
int(CEF_CALLBACK* get_extensions)(struct _cef_request_context_t* self,
cef_string_list_t extension_ids);
@@ -290,6 +298,8 @@ typedef struct _cef_request_context_t {
/// extension is accessible in this context (see HasExtension). This function
/// must be called on the browser process UI thread.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
struct _cef_request_context_t* self,
const cef_string_t* extension_id);
@@ -368,6 +378,39 @@ typedef struct _cef_request_context_t {
const cef_string_t* top_level_url,
cef_content_setting_types_t content_type,
cef_content_setting_values_t value);
///
/// Sets the Chrome color scheme for all browsers that share this request
/// context. |variant| values of SYSTEM, LIGHT and DARK change the underlying
/// color mode (e.g. light vs dark). Other |variant| values determine how
/// |user_color| will be applied in the current color mode. If |user_color| is
/// transparent (0) the default color will be used.
///
void(CEF_CALLBACK* set_chrome_color_scheme)(
struct _cef_request_context_t* self,
cef_color_variant_t variant,
cef_color_t user_color);
///
/// Returns the current Chrome color scheme mode (SYSTEM, LIGHT or DARK). Must
/// be called on the browser process UI thread.
///
cef_color_variant_t(CEF_CALLBACK* get_chrome_color_scheme_mode)(
struct _cef_request_context_t* self);
///
/// Returns the current Chrome color scheme color, or transparent (0) for the
/// default color. Must be called on the browser process UI thread.
///
cef_color_t(CEF_CALLBACK* get_chrome_color_scheme_color)(
struct _cef_request_context_t* self);
///
/// Returns the current Chrome color scheme variant. Must be called on the
/// browser process UI thread.
///
cef_color_variant_t(CEF_CALLBACK* get_chrome_color_scheme_variant)(
struct _cef_request_context_t* self);
} cef_request_context_t;
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=3b59c0bc014d773dedc24649071141ee2dd2125c$
// $hash=2e8b5c5107f61e3d4c333dc02c76a9f30cd0cf83$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_
@@ -48,6 +48,7 @@
#include "include/capi/cef_request_capi.h"
#include "include/capi/cef_resource_request_handler_capi.h"
#include "include/capi/cef_ssl_info_capi.h"
#include "include/capi/cef_unresponsive_process_callback_capi.h"
#include "include/capi/cef_x509_certificate_capi.h"
#ifdef __cplusplus
@@ -222,14 +223,53 @@ typedef struct _cef_request_handler_t {
void(CEF_CALLBACK* on_render_view_ready)(struct _cef_request_handler_t* self,
struct _cef_browser_t* browser);
///
/// Called on the browser process UI thread when the render process is
/// unresponsive as indicated by a lack of input event processing for at least
/// 15 seconds. Return false (0) for the default behavior which is an
/// indefinite wait with the Alloy runtime or display of the "Page
/// unresponsive" dialog with the Chrome runtime. Return true (1) and don't
/// execute the callback for an indefinite wait without display of the Chrome
/// runtime dialog. Return true (1) and call
/// cef_unresponsive_process_callback_t::Wait either in this function or at a
/// later time to reset the wait timer, potentially triggering another call to
/// this function if the process remains unresponsive. Return true (1) and
/// call cef_unresponsive_process_callback_t:: Terminate either in this
/// function or at a later time to terminate the unresponsive process,
/// resulting in a call to OnRenderProcessTerminated.
/// OnRenderProcessResponsive will be called if the process becomes responsive
/// after this function is called. This functionality depends on the hang
/// monitor which can be disabled by passing the `--disable-hang-monitor`
/// command-line flag.
///
int(CEF_CALLBACK* on_render_process_unresponsive)(
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_unresponsive_process_callback_t* callback);
///
/// Called on the browser process UI thread when the render process becomes
/// responsive after previously being unresponsive. See documentation on
/// OnRenderProcessUnresponsive.
///
void(CEF_CALLBACK* on_render_process_responsive)(
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser);
///
/// Called on the browser process UI thread when the render process terminates
/// unexpectedly. |status| indicates how the process terminated.
/// unexpectedly. |status| indicates how the process terminated. |error_code|
/// and |error_string| represent the error that would be displayed in Chrome's
/// "Aw, Snap!" view. Possible |error_code| values include cef_resultcode_t
/// non-normal exit values and platform-specific crash values (for example, a
/// Posix signal or Windows hardware exception).
///
void(CEF_CALLBACK* on_render_process_terminated)(
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
cef_termination_status_t status);
cef_termination_status_t status,
int error_code,
const cef_string_t* error_string);
///
/// Called on the browser process UI thread when the window.document object of

View File

@@ -0,0 +1,74 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=9ad38f2709d9e3b1bd0e99c279b0497b8aa4c82a$
//
#ifndef CEF_INCLUDE_CAPI_CEF_UNRESPONSIVE_PROCESS_CALLBACK_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_UNRESPONSIVE_PROCESS_CALLBACK_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
/// Callback structure for asynchronous handling of an unresponsive process.
///
typedef struct _cef_unresponsive_process_callback_t {
///
/// Base structure.
///
cef_base_ref_counted_t base;
///
/// Reset the timeout for the unresponsive process.
///
void(CEF_CALLBACK* wait)(struct _cef_unresponsive_process_callback_t* self);
///
/// Terminate the unresponsive process.
///
void(CEF_CALLBACK* terminate)(
struct _cef_unresponsive_process_callback_t* self);
} cef_unresponsive_process_callback_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_UNRESPONSIVE_PROCESS_CALLBACK_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=2e5a3b3b1f427a7eb1e6a447fe0d31c5ace49469$
// $hash=1c2fbbffaf51e90a2d55bfa7eb3fa3a4e315f4ac$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
@@ -93,6 +93,13 @@ typedef struct _cef_browser_view_t {
///
void(CEF_CALLBACK* set_prefer_accelerators)(struct _cef_browser_view_t* self,
int prefer_accelerators);
///
/// Returns the runtime style for this BrowserView (ALLOY or CHROME). See
/// cef_runtime_style_t documentation for details.
///
cef_runtime_style_t(CEF_CALLBACK* get_runtime_style)(
struct _cef_browser_view_t* self);
} cef_browser_view_t;
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=1f2a6e206b86945386bef57167b80e2fb6067c59$
// $hash=a0a9f2bfcdf8e05d3d1114fcd8860caaa726ec98$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_
@@ -141,6 +141,13 @@ typedef struct _cef_browser_view_delegate_t {
struct _cef_browser_view_delegate_t* self,
struct _cef_browser_view_t* browser_view,
cef_gesture_command_t gesture_command);
///
/// Optionally change the runtime style for this BrowserView. See
/// cef_runtime_style_t documentation for details.
///
cef_runtime_style_t(CEF_CALLBACK* get_browser_runtime_style)(
struct _cef_browser_view_delegate_t* self);
} cef_browser_view_delegate_t;
#ifdef __cplusplus

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=48df6ccac2c68f32c7024ae68c8a6b6a5f8ed914$
// $hash=08f13de764f30261616372dfffb7f97c57957f73$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_
@@ -338,16 +338,30 @@ typedef struct _cef_view_t {
void(CEF_CALLBACK* request_focus)(struct _cef_view_t* self);
///
/// Sets the background color for this View.
/// Sets the background color for this View. The background color will be
/// automatically reset when cef_view_delegate_t::OnThemeChanged is called.
///
void(CEF_CALLBACK* set_background_color)(struct _cef_view_t* self,
cef_color_t color);
///
/// Returns the background color for this View.
/// Returns the background color for this View. If the background color is
/// unset then the current `GetThemeColor(CEF_ColorPrimaryBackground)` value
/// will be returned. If this View belongs to an overlay (created with
/// cef_window_t::AddOverlayView), and the background color is unset, then a
/// value of transparent (0) will be returned.
///
cef_color_t(CEF_CALLBACK* get_background_color)(struct _cef_view_t* self);
///
/// Returns the current theme color associated with |color_id|, or the
/// placeholder color (red) if unset. See cef_color_ids.h for standard ID
/// values. Standard colors can be overridden and custom colors can be added
/// using cef_window_t::SetThemeColor.
///
cef_color_t(CEF_CALLBACK* get_theme_color)(struct _cef_view_t* self,
int color_id);
///
/// Convert |point| from this View's coordinate system to DIP screen
/// coordinates. This View must belong to a Window when calling this function.

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=4e421d2d1e24df6e58f7a7c0c074056bc5284df4$
// $hash=0f562c026f64ca19a32834dcc1e1cd3a98be2f1f$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_
@@ -140,6 +140,28 @@ typedef struct _cef_view_delegate_t {
///
void(CEF_CALLBACK* on_blur)(struct _cef_view_delegate_t* self,
struct _cef_view_t* view);
///
/// Called when the theme for |view| has changed, after the new theme colors
/// have already been applied. Views are notified via the component hierarchy
/// in depth-first reverse order (children before parents).
///
/// This will be called in the following cases:
///
/// 1. When |view|, or a parent of |view|, is added to a Window. 2. When the
/// native/OS or Chrome theme changes for the Window that contains
/// |view|. See CefWindowDelegate::OnThemeColorsChanged documentation.
/// 3. When the client explicitly calls cef_window_t::ThemeChanged on the
/// Window
/// that contains |view|.
///
/// Optionally use this callback to override the new per-View theme colors by
/// calling cef_view_t::SetBackgroundColor or the appropriate component-
/// specific function. See cef_window_t::SetThemeColor documentation for how
/// to customize additional Window theme colors.
///
void(CEF_CALLBACK* on_theme_changed)(struct _cef_view_delegate_t* self,
struct _cef_view_t* view);
} cef_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=dbe89dfdd14eb114e3f2d16fbfc55624bb91e7ce$
// $hash=dd32b58ec9aca0e04a1d30ccf94a741995fcc094$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_
@@ -364,6 +364,50 @@ typedef struct _cef_window_t {
/// Remove all keyboard accelerators.
///
void(CEF_CALLBACK* remove_all_accelerators)(struct _cef_window_t* self);
///
/// Override a standard theme color or add a custom color associated with
/// |color_id|. See cef_color_ids.h for standard ID values. Recommended usage
/// is as follows:
///
/// 1. Customize the default native/OS theme by calling SetThemeColor before
/// showing the first Window. When done setting colors call
/// CefWindow::ThemeChanged to trigger CefViewDelegate::OnThemeChanged
/// notifications.
/// 2. Customize the current native/OS or Chrome theme after it changes by
/// calling SetThemeColor from the CefWindowDelegate::OnThemeColorsChanged
/// callback. CefViewDelegate::OnThemeChanged notifications will then be
/// triggered automatically.
///
/// The configured color will be available immediately via
/// cef_view_t::GetThemeColor and will be applied to each View in this
/// Window's component hierarchy when cef_view_delegate_t::OnThemeChanged is
/// called. See OnThemeColorsChanged documentation for additional details.
///
/// Clients wishing to add custom colors should use |color_id| values >=
/// CEF_ChromeColorsEnd.
///
void(CEF_CALLBACK* set_theme_color)(struct _cef_window_t* self,
int color_id,
cef_color_t color);
///
/// Trigger cef_view_delegate_t::OnThemeChanged callbacks for each View in
/// this Window's component hierarchy. Unlike a native/OS or Chrome theme
/// change this function does not reset theme colors to standard values and
/// does not result in a call to cef_window_delegate_t::OnThemeColorsChanged.
///
/// Do not call this function from cef_window_delegate_t::OnThemeColorsChanged
/// or cef_view_delegate_t::OnThemeChanged.
///
void(CEF_CALLBACK* theme_changed)(struct _cef_window_t* self);
///
/// Returns the runtime style for this Window (ALLOY or CHROME). See
/// cef_runtime_style_t documentation for details.
///
cef_runtime_style_t(CEF_CALLBACK* get_runtime_style)(
struct _cef_window_t* self);
} cef_window_t;
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=c1c2705cdef7d9189557b57531dc2d53e9f68d0c$
// $hash=e8c9e32caa8d317a7cb6ff2f0ad6be49cf1b7ad1$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
@@ -182,6 +182,20 @@ typedef struct _cef_window_delegate_t {
struct _cef_window_t* window,
float* titlebar_height);
///
/// Return whether the view should accept the initial mouse-down event,
/// allowing it to respond to click-through behavior. If STATE_ENABLED is
/// returned, the view will be sent a mouseDown: message for an initial mouse-
/// down event, activating the view with one click, instead of clicking first
/// to make the window active and then clicking the view.
///
/// This function is only supported on macOS. For more details, refer to the
/// documentation of acceptsFirstMouse.
///
cef_state_t(CEF_CALLBACK* accepts_first_mouse)(
struct _cef_window_delegate_t* self,
struct _cef_window_t* window);
///
/// Return true (1) if |window| can be resized.
///
@@ -224,6 +238,50 @@ typedef struct _cef_window_delegate_t {
int(CEF_CALLBACK* on_key_event)(struct _cef_window_delegate_t* self,
struct _cef_window_t* window,
const cef_key_event_t* event);
///
/// Called after the native/OS or Chrome theme for |window| has changed.
/// |chrome_theme| will be true (1) if the notification is for a Chrome theme.
///
/// Native/OS theme colors are configured globally and do not need to be
/// customized for each Window individually. An example of a native/OS theme
/// change that triggers this callback is when the user switches between dark
/// and light mode during application lifespan. Native/OS theme changes can be
/// disabled by passing the `--force-dark-mode` or `--force-light-mode`
/// command-line flag.
///
/// Chrome theme colors will be applied and this callback will be triggered
/// if/when a BrowserView is added to the Window's component hierarchy. Chrome
/// theme colors can be configured on a per-RequestContext basis using
/// cef_request_context_t::SetChromeColorScheme or (Chrome runtime only) by
/// visiting chrome://settings/manageProfile. Any theme changes using those
/// mechanisms will also trigger this callback. Chrome theme colors will be
/// persisted and restored from disk cache with the Chrome runtime, and with
/// the Alloy runtime if persist_user_preferences is set to true (1) via
/// CefSettings or cef_request_context_tSettings.
///
/// This callback is not triggered on Window creation so clients that wish to
/// customize the initial native/OS theme must call
/// cef_window_t::SetThemeColor and cef_window_t::ThemeChanged before showing
/// the first Window.
///
/// Theme colors will be reset to standard values before this callback is
/// called for the first affected Window. Call cef_window_t::SetThemeColor
/// from inside this callback to override a standard color or add a custom
/// color. cef_view_delegate_t::OnThemeChanged will be called after this
/// callback for the complete |window| component hierarchy.
///
void(CEF_CALLBACK* on_theme_colors_changed)(
struct _cef_window_delegate_t* self,
struct _cef_window_t* window,
int chrome_theme);
///
/// Optionally change the runtime style for this Window. See
/// cef_runtime_style_t documentation for details.
///
cef_runtime_style_t(CEF_CALLBACK* get_window_runtime_style)(
struct _cef_window_delegate_t* self);
} cef_window_delegate_t;
#ifdef __cplusplus

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 "60ecc3c751154b2b2b41e5d3ac0ccbeba588918d"
#define CEF_API_HASH_UNIVERSAL "73e8743408bfeba0df3b567bfd04b2eb642df11d"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "7819cee8508a9b048ccfa80acea7351a5b549c45"
#define CEF_API_HASH_PLATFORM "3a73f4c69062c6f413e00c1821f6e6df91a2a787"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "f2bb2e5a9d14dcad463fd3fc8ed4af16b6fe6196"
#define CEF_API_HASH_PLATFORM "f5fb92747082f06a9c42724b0b717accc29e3879"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "bcf76490ddea85c12ea8feeee9190ffe24dedcc6"
#define CEF_API_HASH_PLATFORM "8775d620c6b17725bddba2c1c3a21353b4d8acb1"
#endif
#ifdef __cplusplus

View File

@@ -71,9 +71,9 @@ int CefExecuteProcess(const CefMainArgs& args,
/// true if initialization succeeds. Returns false if initialization fails or if
/// early exit is desired (for example, due to process singleton relaunch
/// behavior). If this function returns false then the application should exit
/// immediately without calling any other CEF functions. The
/// |windows_sandbox_info| parameter is only used on Windows and may be NULL
/// (see cef_sandbox_win.h for details).
/// immediately without calling any other CEF functions except, optionally,
/// CefGetErrorCode. The |windows_sandbox_info| parameter is only used on
/// Windows and may be NULL (see cef_sandbox_win.h for details).
///
/*--cef(api_hash_check,optional_param=application,
optional_param=windows_sandbox_info)--*/
@@ -82,6 +82,18 @@ bool CefInitialize(const CefMainArgs& args,
CefRefPtr<CefApp> application,
void* windows_sandbox_info);
///
/// This function can optionally be called on the main application thread after
/// CefInitialize to retrieve the initialization exit code. When CefInitialize
/// returns true the exit code will be 0 (CEF_RESULT_CODE_NORMAL_EXIT).
/// Otherwise, see cef_resultcode_t for possible exit code values including
/// browser process initialization errors and normal early exit conditions (such
/// as CEF_RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED for process singleton
/// relaunch behavior).
///
/*--cef()--*/
int CefGetExitCode();
///
/// This function should be called on the main application thread to shut down
/// the CEF browser process before the application exits. Do not call any

View File

@@ -942,6 +942,8 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
/// Returns the extension hosted in this browser or NULL if no extension is
/// hosted. See CefRequestContext::LoadExtension for details.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual CefRefPtr<CefExtension> GetExtension() = 0;
@@ -950,6 +952,8 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
/// Background hosts do not have a window and are not displayable. See
/// CefRequestContext::LoadExtension for details.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual bool IsBackgroundHost() = 0;
@@ -1007,6 +1011,24 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
virtual void ExecuteChromeCommand(
int command_id,
cef_window_open_disposition_t disposition) = 0;
///
/// Returns true if the render process associated with this browser is
/// currently unresponsive as indicated by a lack of input event processing
/// for at least 15 seconds. To receive associated state change notifications
/// and optionally handle an unresponsive render process implement
/// CefRequestHandler::OnRenderProcessUnresponsive. This method can only be
/// called on the UI thread.
///
/*--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

@@ -42,6 +42,7 @@
#include "include/cef_client.h"
#include "include/cef_command_line.h"
#include "include/cef_preference.h"
#include "include/cef_request_context_handler.h"
#include "include/cef_values.h"
///
@@ -139,14 +140,28 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
virtual void OnScheduleMessagePumpWork(int64_t delay_ms) {}
///
/// Return the default client for use with a newly created browser window. If
/// null is returned the browser will be unmanaged (no callbacks will be
/// executed for that browser) and application shutdown will be blocked until
/// the browser window is closed manually. This method is currently only used
/// with the chrome runtime.
/// Return the default client for use with a newly created browser window
/// (CefBrowser object). If null is returned the CefBrowser will be unmanaged
/// (no callbacks will be executed for that CefBrowser) and application
/// shutdown will be blocked until the browser window is closed manually. This
/// method is currently only used with the Chrome runtime when creating new
/// browser windows via Chrome UI.
///
/*--cef()--*/
virtual CefRefPtr<CefClient> GetDefaultClient() { return nullptr; }
///
/// Return the default handler for use with a new user or incognito profile
/// (CefRequestContext object). If null is returned the CefRequestContext will
/// be unmanaged (no callbacks will be executed for that CefRequestContext).
/// This method is currently only used with the Chrome runtime when creating
/// new browser windows via Chrome UI.
///
/*--cef()--*/
virtual CefRefPtr<CefRequestContextHandler>
GetDefaultRequestContextHandler() {
return nullptr;
}
};
#endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_

View File

@@ -106,17 +106,19 @@ class CefDownloadHandler : public virtual CefBaseRefCounted {
///
/// Called before a download begins. |suggested_name| is the suggested name
/// for the download file. By default the download will be canceled. Execute
/// |callback| either asynchronously or in this method to continue the
/// download if desired. Do not keep a reference to |download_item| outside of
/// this method.
/// for the download file. Return true and execute |callback| either
/// asynchronously or in this method to continue or cancel the download.
/// Return false to proceed with default handling (cancel with Alloy style,
/// download shelf with Chrome style). Do not keep a reference to
/// |download_item| outside of this method.
///
/*--cef()--*/
virtual void OnBeforeDownload(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback> callback) = 0;
virtual bool OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback> callback) {
return false;
}
///
/// Called when a download's status or progress information has been updated.

View File

@@ -48,6 +48,8 @@ class CefRequestContext;
/// Object representing an extension. Methods may be called on any thread unless
/// otherwise indicated.
///
/// WARNING: This API is deprecated and will be removed in ~M127.
///
/*--cef(source=library)--*/
class CefExtension : public CefBaseRefCounted {
public:

View File

@@ -70,6 +70,8 @@ class CefGetExtensionResourceCallback : public CefBaseRefCounted {
/// The methods of this class will be called on the UI thread. See
/// CefRequestContext::LoadExtension for information about extension loading.
///
/// WARNING: This API is deprecated and will be removed in ~M127.
///
/*--cef(source=client)--*/
class CefExtensionHandler : public virtual CefBaseRefCounted {
public:

View File

@@ -152,16 +152,25 @@ class CefRenderHandler : public virtual CefBaseRefCounted {
/// Called when an element has been rendered to the shared texture handle.
/// |type| indicates whether the element is the view or the popup widget.
/// |dirtyRects| contains the set of rectangles in pixel coordinates that need
/// to be repainted. |shared_handle| is the handle for a D3D11 Texture2D that
/// can be accessed via ID3D11Device using the OpenSharedResource method. This
/// method is only called when CefWindowInfo::shared_texture_enabled is set to
/// true, and is currently only supported on Windows.
/// to be repainted. |info| contains the shared handle; on Windows it is a
/// HANDLE to a texture that can be opened with D3D11 OpenSharedResource, on
/// macOS it is an IOSurface pointer that can be opened with Metal or OpenGL,
/// and on Linux it contains several planes, each with an fd to the underlying
/// system native buffer.
///
/// The underlying implementation uses a pool to deliver frames. As a result,
/// the handle may differ every frame depending on how many frames are
/// in-progress. The handle's resource cannot be cached and cannot be accessed
/// outside of this callback. It should be reopened each time this callback is
/// executed and the contents should be copied to a texture owned by the
/// client application. The contents of |info| will be released back to the
/// pool after this callback returns.
///
/*--cef()--*/
virtual void OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
void* shared_handle) {}
const CefAcceleratedPaintInfo& info) {}
///
/// Called to retrieve the size of the touch handle for the specified

View File

@@ -266,6 +266,8 @@ class CefRequestContext : public CefPreferenceManager {
/// See https://developer.chrome.com/extensions for extension implementation
/// and usage documentation.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef(optional_param=manifest,optional_param=handler)--*/
virtual void LoadExtension(const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
@@ -277,6 +279,8 @@ class CefRequestContext : public CefPreferenceManager {
/// access to the extension (see HasExtension). This method must be called on
/// the browser process UI thread.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual bool DidLoadExtension(const CefString& extension_id) = 0;
@@ -286,6 +290,8 @@ class CefRequestContext : public CefPreferenceManager {
/// extension (see DidLoadExtension). This method must be called on the
/// browser process UI thread.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual bool HasExtension(const CefString& extension_id) = 0;
@@ -295,6 +301,8 @@ class CefRequestContext : public CefPreferenceManager {
/// extension ID values. Returns true on success. This method must be called
/// on the browser process UI thread.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual bool GetExtensions(std::vector<CefString>& extension_ids) = 0;
@@ -303,6 +311,8 @@ class CefRequestContext : public CefPreferenceManager {
/// extension is accessible in this context (see HasExtension). This method
/// must be called on the browser process UI thread.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual CefRefPtr<CefExtension> GetExtension(
const CefString& extension_id) = 0;
@@ -381,6 +391,38 @@ class CefRequestContext : public CefPreferenceManager {
const CefString& top_level_url,
cef_content_setting_types_t content_type,
cef_content_setting_values_t value) = 0;
///
/// Sets the Chrome color scheme for all browsers that share this request
/// context. |variant| values of SYSTEM, LIGHT and DARK change the underlying
/// color mode (e.g. light vs dark). Other |variant| values determine how
/// |user_color| will be applied in the current color mode. If |user_color| is
/// transparent (0) the default color will be used.
///
/*--cef()--*/
virtual void SetChromeColorScheme(cef_color_variant_t variant,
cef_color_t user_color) = 0;
///
/// Returns the current Chrome color scheme mode (SYSTEM, LIGHT or DARK). Must
/// be called on the browser process UI thread.
///
/*--cef(default_retval=CEF_COLOR_VARIANT_SYSTEM)--*/
virtual cef_color_variant_t GetChromeColorSchemeMode() = 0;
///
/// Returns the current Chrome color scheme color, or transparent (0) for the
/// default color. Must be called on the browser process UI thread.
///
/*--cef(default_retval=0)--*/
virtual cef_color_t GetChromeColorSchemeColor() = 0;
///
/// Returns the current Chrome color scheme variant. Must be called on the
/// browser process UI thread.
///
/*--cef(default_retval=CEF_COLOR_VARIANT_SYSTEM)--*/
virtual cef_color_variant_t GetChromeColorSchemeVariant() = 0;
};
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_

View File

@@ -48,6 +48,7 @@
#include "include/cef_request.h"
#include "include/cef_resource_request_handler.h"
#include "include/cef_ssl_info.h"
#include "include/cef_unresponsive_process_callback.h"
#include "include/cef_x509_certificate.h"
///
@@ -221,14 +222,52 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual void OnRenderViewReady(CefRefPtr<CefBrowser> browser) {}
///
/// Called on the browser process UI thread when the render process is
/// unresponsive as indicated by a lack of input event processing for at
/// least 15 seconds. Return false for the default behavior which is an
/// indefinite wait with the Alloy runtime or display of the "Page
/// unresponsive" dialog with the Chrome runtime. Return true and don't
/// execute the callback for an indefinite wait without display of the Chrome
/// runtime dialog. Return true and call CefUnresponsiveProcessCallback::Wait
/// either in this method or at a later time to reset the wait timer,
/// potentially triggering another call to this method if the process remains
/// unresponsive. Return true and call CefUnresponsiveProcessCallback::
/// Terminate either in this method or at a later time to terminate the
/// unresponsive process, resulting in a call to OnRenderProcessTerminated.
/// OnRenderProcessResponsive will be called if the process becomes responsive
/// after this method is called. This functionality depends on the hang
/// monitor which can be disabled by passing the `--disable-hang-monitor`
/// command-line flag.
///
/*--cef()--*/
virtual bool OnRenderProcessUnresponsive(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefUnresponsiveProcessCallback> callback) {
return false;
}
///
/// Called on the browser process UI thread when the render process becomes
/// responsive after previously being unresponsive. See documentation on
/// OnRenderProcessUnresponsive.
///
/*--cef()--*/
virtual void OnRenderProcessResponsive(CefRefPtr<CefBrowser> browser) {}
///
/// Called on the browser process UI thread when the render process
/// terminates unexpectedly. |status| indicates how the process
/// terminated.
/// terminates unexpectedly. |status| indicates how the process terminated.
/// |error_code| and |error_string| represent the error that would be
/// displayed in Chrome's "Aw, Snap!" view. Possible |error_code| values
/// include cef_resultcode_t non-normal exit values and platform-specific
/// crash values (for example, a Posix signal or Windows hardware exception).
///
/*--cef()--*/
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
TerminationStatus status) {}
TerminationStatus status,
int error_code,
const CefString& error_string) {}
///
/// Called on the browser process UI thread when the window.document object of

View File

@@ -0,0 +1,62 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_UNRESPONSIVE_PROCESS_CALLBACK_H_
#define CEF_INCLUDE_CEF_UNRESPONSIVE_PROCESS_CALLBACK_H_
#pragma once
#include "include/cef_base.h"
///
/// Callback interface for asynchronous handling of an unresponsive process.
///
/*--cef(source=library)--*/
class CefUnresponsiveProcessCallback : public virtual CefBaseRefCounted {
public:
///
/// Reset the timeout for the unresponsive process.
///
/*--cef()--*/
virtual void Wait() = 0;
///
/// Terminate the unresponsive process.
///
/*--cef()--*/
virtual void Terminate() = 0;
};
#endif // CEF_INCLUDE_CEF_UNRESPONSIVE_PROCESS_CALLBACK_H_

View File

@@ -70,6 +70,7 @@ struct CefWindowInfoTraits {
target->shared_texture_enabled = src->shared_texture_enabled;
target->external_begin_frame_enabled = src->external_begin_frame_enabled;
target->window = src->window;
target->runtime_style = src->runtime_style;
}
};
@@ -110,6 +111,7 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
void SetAsWindowless(CefWindowHandle parent) {
windowless_rendering_enabled = true;
parent_window = parent;
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
}
};

View File

@@ -71,6 +71,7 @@ struct CefWindowInfoTraits {
target->shared_texture_enabled = src->shared_texture_enabled;
target->external_begin_frame_enabled = src->external_begin_frame_enabled;
target->view = src->view;
target->runtime_style = src->runtime_style;
}
};
@@ -112,6 +113,7 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
void SetAsWindowless(CefWindowHandle parent) {
windowless_rendering_enabled = true;
parent_view = parent;
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
}
};

View File

@@ -31,7 +31,7 @@
#define CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_
#pragma once
#include <memory.h>
#include <cstring>
#include <string>
#include "include/internal/cef_string_types.h"

View File

@@ -433,10 +433,14 @@ typedef struct _cef_settings_t {
///
/// Set to a value between 1024 and 65535 to enable remote debugging on the
/// specified port. Also configurable using the "remote-debugging-port"
/// command-line switch. Remote debugging can be accessed by loading the
/// chrome://inspect page in Google Chrome. Port numbers 9222 and 9229 are
/// discoverable by default. Other port numbers may need to be configured via
/// "Discover network targets" on the Devices tab.
/// command-line switch. Specifying 0 via the command-line switch will result
/// in the selection of an ephemeral port and the port number will be printed
/// as part of the WebSocket endpoint URL to stderr. If a cache directory path
/// is provided the port will also be written to the
/// <cache-dir>/DevToolsActivePort file. Remote debugging can be accessed by
/// loading the chrome://inspect page in Google Chrome. Port numbers 9222 and
/// 9229 are discoverable by default. Other port numbers may need to be
/// configured via "Discover network targets" on the Devices tab.
///
int remote_debugging_port;
@@ -913,6 +917,16 @@ typedef enum {
/// Out of memory. Some platforms may use TS_PROCESS_CRASHED instead.
///
TS_PROCESS_OOM,
///
/// Child process never launched.
///
TS_LAUNCH_FAILED,
///
/// On Windows, the OS terminated the process due to code integrity failure.
///
TS_INTEGRITY_FAILURE,
} cef_termination_status_t;
///
@@ -1023,6 +1037,100 @@ typedef enum {
CERT_STATUS_CT_COMPLIANCE_FAILED = 1 << 20,
} cef_cert_status_t;
///
/// Process result codes. This is not a comprehensive list, as result codes
/// might also include platform-specific crash values (Posix signal or Windows
/// hardware exception), or internal-only implementation values.
///
typedef enum {
// The following values should be kept in sync with Chromium's
// content::ResultCode type.
CEF_RESULT_CODE_NORMAL_EXIT,
/// Process was killed by user or system.
CEF_RESULT_CODE_KILLED,
/// Process hung.
CEF_RESULT_CODE_HUNG,
/// A bad message caused the process termination.
CEF_RESULT_CODE_KILLED_BAD_MESSAGE,
/// The GPU process exited because initialization failed.
CEF_RESULT_CODE_GPU_DEAD_ON_ARRIVAL,
// The following values should be kept in sync with Chromium's
// chrome::ResultCode type. Unused chrome values are excluded.
CEF_RESULT_CODE_CHROME_FIRST,
/// A critical chrome file is missing.
CEF_RESULT_CODE_MISSING_DATA = 7,
/// Command line parameter is not supported.
CEF_RESULT_CODE_UNSUPPORTED_PARAM = 13,
/// The profile was in use on another host.
CEF_RESULT_CODE_PROFILE_IN_USE = 21,
/// Failed to pack an extension via the command line.
CEF_RESULT_CODE_PACK_EXTENSION_ERROR = 22,
/// The browser process exited early by passing the command line to another
/// running browser.
CEF_RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED = 24,
/// A browser process was sandboxed. This should never happen.
CEF_RESULT_CODE_INVALID_SANDBOX_STATE = 31,
/// Cloud policy enrollment failed or was given up by user.
CEF_RESULT_CODE_CLOUD_POLICY_ENROLLMENT_FAILED = 32,
/// The GPU process was terminated due to context lost.
CEF_RESULT_CODE_GPU_EXIT_ON_CONTEXT_LOST = 34,
/// An early startup command was executed and the browser must exit.
CEF_RESULT_CODE_NORMAL_EXIT_PACK_EXTENSION_SUCCESS = 36,
/// The browser process exited because system resources are exhausted. The
/// system state can't be recovered and will be unstable.
CEF_RESULT_CODE_SYSTEM_RESOURCE_EXHAUSTED = 37,
CEF_RESULT_CODE_CHROME_LAST = 39,
// The following values should be kept in sync with Chromium's
// sandbox::TerminationCodes type.
CEF_RESULT_CODE_SANDBOX_FATAL_FIRST = 7006,
/// Windows sandbox could not set the integrity level.
CEF_RESULT_CODE_SANDBOX_FATAL_INTEGRITY = CEF_RESULT_CODE_SANDBOX_FATAL_FIRST,
/// Windows sandbox could not lower the token.
CEF_RESULT_CODE_SANDBOX_FATAL_DROPTOKEN,
/// Windows sandbox failed to flush registry handles.
CEF_RESULT_CODE_SANDBOX_FATAL_FLUSHANDLES,
/// Windows sandbox failed to forbid HCKU caching.
CEF_RESULT_CODE_SANDBOX_FATAL_CACHEDISABLE,
/// Windows sandbox failed to close pending handles.
CEF_RESULT_CODE_SANDBOX_FATAL_CLOSEHANDLES,
/// Windows sandbox could not set the mitigation policy.
CEF_RESULT_CODE_SANDBOX_FATAL_MITIGATION,
/// Windows sandbox exceeded the job memory limit.
CEF_RESULT_CODE_SANDBOX_FATAL_MEMORY_EXCEEDED,
/// Windows sandbox failed to warmup.
CEF_RESULT_CODE_SANDBOX_FATAL_WARMUP,
CEF_RESULT_CODE_SANDBOX_FATAL_LAST,
} cef_resultcode_t;
///
/// The manner in which a link click should be opened. These constants match
/// their equivalents in Chromium's window_open_disposition.h and should not be
@@ -2332,6 +2440,7 @@ typedef enum {
DOM_FORM_CONTROL_TYPE_BUTTON_SUBMIT,
DOM_FORM_CONTROL_TYPE_BUTTON_RESET,
DOM_FORM_CONTROL_TYPE_BUTTON_SELECT_LIST,
DOM_FORM_CONTROL_TYPE_BUTTON_POPOVER,
DOM_FORM_CONTROL_TYPE_FIELDSET,
DOM_FORM_CONTROL_TYPE_INPUT_BUTTON,
DOM_FORM_CONTROL_TYPE_INPUT_CHECKBOX,
@@ -2816,21 +2925,6 @@ typedef enum {
RESPONSE_FILTER_ERROR
} cef_response_filter_status_t;
///
/// Describes how to interpret the components of a pixel.
///
typedef enum {
///
/// RGBA with 8 bits per pixel (32bits total).
///
CEF_COLOR_TYPE_RGBA_8888,
///
/// BGRA with 8 bits per pixel (32bits total).
///
CEF_COLOR_TYPE_BGRA_8888,
} cef_color_type_t;
///
/// Describes how to interpret the alpha component of a pixel.
///
@@ -2863,51 +2957,22 @@ typedef enum {
} cef_text_style_t;
///
/// Specifies where along the main axis the CefBoxLayout child views should be
/// laid out.
/// Specifies where along the axis the CefBoxLayout child views should be laid
/// out. Should be kept in sync with Chromium's views::LayoutAlignment type.
///
typedef enum {
///
/// Child views will be left-aligned.
///
CEF_MAIN_AXIS_ALIGNMENT_START,
/// Child views will be left/top-aligned.
CEF_AXIS_ALIGNMENT_START,
///
/// Child views will be center-aligned.
///
CEF_MAIN_AXIS_ALIGNMENT_CENTER,
CEF_AXIS_ALIGNMENT_CENTER,
///
/// Child views will be right-aligned.
///
CEF_MAIN_AXIS_ALIGNMENT_END,
} cef_main_axis_alignment_t;
/// Child views will be right/bottom-aligned.
CEF_AXIS_ALIGNMENT_END,
///
/// Specifies where along the cross axis the CefBoxLayout child views should be
/// laid out.
///
typedef enum {
///
/// Child views will be stretched to fit.
///
CEF_CROSS_AXIS_ALIGNMENT_STRETCH,
///
/// Child views will be left-aligned.
///
CEF_CROSS_AXIS_ALIGNMENT_START,
///
/// Child views will be center-aligned.
///
CEF_CROSS_AXIS_ALIGNMENT_CENTER,
///
/// Child views will be right-aligned.
///
CEF_CROSS_AXIS_ALIGNMENT_END,
} cef_cross_axis_alignment_t;
CEF_AXIS_ALIGNMENT_STRETCH,
} cef_axis_alignment_t;
///
/// Settings used when initializing a CefBoxLayout.
@@ -2944,12 +3009,12 @@ typedef struct _cef_box_layout_settings_t {
///
/// Specifies where along the main axis the child views should be laid out.
///
cef_main_axis_alignment_t main_axis_alignment;
cef_axis_alignment_t main_axis_alignment;
///
/// Specifies where along the cross axis the child views should be laid out.
///
cef_cross_axis_alignment_t cross_axis_alignment;
cef_axis_alignment_t cross_axis_alignment;
///
/// Minimum cross axis size.
@@ -3218,64 +3283,65 @@ typedef enum {
/// Front L, Front R, Front C, LFE, Back L, Back R
CEF_CHANNEL_LAYOUT_5_1_BACK = 12,
/// Front L, Front R, Front C, Side L, Side R, Back L, Back R
/// Front L, Front R, Front C, Back L, Back R, Side L, Side R
CEF_CHANNEL_LAYOUT_7_0 = 13,
/// Front L, Front R, Front C, LFE, Side L, Side R, Back L, Back R
/// Front L, Front R, Front C, LFE, Back L, Back R, Side L, Side R
CEF_CHANNEL_LAYOUT_7_1 = 14,
/// Front L, Front R, Front C, LFE, Side L, Side R, Front LofC, Front RofC
/// Front L, Front R, Front C, LFE, Front LofC, Front RofC, Side L, Side R
CEF_CHANNEL_LAYOUT_7_1_WIDE = 15,
/// Stereo L, Stereo R
/// Front L, Front R
CEF_CHANNEL_LAYOUT_STEREO_DOWNMIX = 16,
/// Stereo L, Stereo R, LFE
/// Front L, Front R, LFE
CEF_CHANNEL_LAYOUT_2POINT1 = 17,
/// Stereo L, Stereo R, Front C, LFE
/// Front L, Front R, Front C, LFE
CEF_CHANNEL_LAYOUT_3_1 = 18,
/// Stereo L, Stereo R, Front C, Rear C, LFE
/// Front L, Front R, Front C, LFE, Back C
CEF_CHANNEL_LAYOUT_4_1 = 19,
/// Stereo L, Stereo R, Front C, Side L, Side R, Back C
/// Front L, Front R, Front C, Back C, Side L, Side R
CEF_CHANNEL_LAYOUT_6_0 = 20,
/// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC
/// Front L, Front R, Front LofC, Front RofC, Side L, Side R
CEF_CHANNEL_LAYOUT_6_0_FRONT = 21,
/// Stereo L, Stereo R, Front C, Rear L, Rear R, Rear C
/// Front L, Front R, Front C, Back L, Back R, Back C
CEF_CHANNEL_LAYOUT_HEXAGONAL = 22,
/// Stereo L, Stereo R, Front C, LFE, Side L, Side R, Rear Center
/// Front L, Front R, Front C, LFE, Back C, Side L, Side R
CEF_CHANNEL_LAYOUT_6_1 = 23,
/// Stereo L, Stereo R, Front C, LFE, Back L, Back R, Rear Center
/// Front L, Front R, Front C, LFE, Back L, Back R, Back C
CEF_CHANNEL_LAYOUT_6_1_BACK = 24,
/// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE
/// Front L, Front R, LFE, Front LofC, Front RofC, Side L, Side R
CEF_CHANNEL_LAYOUT_6_1_FRONT = 25,
/// Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC
/// Front L, Front R, Front C, Front LofC, Front RofC, Side L, Side R
CEF_CHANNEL_LAYOUT_7_0_FRONT = 26,
/// Front L, Front R, Front C, LFE, Back L, Back R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_7_1_WIDE_BACK = 27,
/// Front L, Front R, Front C, Side L, Side R, Rear L, Back R, Back C.
/// Front L, Front R, Front C, Back L, Back R, Back C, Side L, Side R
CEF_CHANNEL_LAYOUT_OCTAGONAL = 28,
/// Channels are not explicitly mapped to speakers.
CEF_CHANNEL_LAYOUT_DISCRETE = 29,
/// Deprecated, but keeping the enum value for UMA consistency.
/// Front L, Front R, Front C. Front C contains the keyboard mic audio. This
/// layout is only intended for input for WebRTC. The Front C channel
/// is stripped away in the WebRTC audio input pipeline and never seen outside
/// of that.
CEF_CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC = 30,
/// Front L, Front R, Side L, Side R, LFE
/// Front L, Front R, LFE, Side L, Side R
CEF_CHANNEL_LAYOUT_4_1_QUAD_SIDE = 31,
/// Actual channel layout is specified in the bitstream and the actual channel
@@ -3289,8 +3355,14 @@ typedef enum {
/// kMaxConcurrentChannels
CEF_CHANNEL_LAYOUT_5_1_4_DOWNMIX = 33,
/// Front C, LFE
CEF_CHANNEL_LAYOUT_1_1 = 34,
/// Front L, Front R, LFE, Back C
CEF_CHANNEL_LAYOUT_3_1_BACK = 35,
/// Max value, must always equal the largest entry ever logged.
CEF_CHANNEL_LAYOUT_MAX = CEF_CHANNEL_LAYOUT_5_1_4_DOWNMIX
CEF_CHANNEL_LAYOUT_MAX = CEF_CHANNEL_LAYOUT_3_1_BACK
} cef_channel_layout_t;
///
@@ -3562,9 +3634,9 @@ typedef enum {
CEF_PERMISSION_TYPE_DISK_QUOTA = 1 << 7,
CEF_PERMISSION_TYPE_LOCAL_FONTS = 1 << 8,
CEF_PERMISSION_TYPE_GEOLOCATION = 1 << 9,
CEF_PERMISSION_TYPE_IDLE_DETECTION = 1 << 10,
CEF_PERMISSION_TYPE_MIC_STREAM = 1 << 11,
CEF_PERMISSION_TYPE_MIDI = 1 << 12,
CEF_PERMISSION_TYPE_IDENTITY_PROVIDER = 1 << 10,
CEF_PERMISSION_TYPE_IDLE_DETECTION = 1 << 11,
CEF_PERMISSION_TYPE_MIC_STREAM = 1 << 12,
CEF_PERMISSION_TYPE_MIDI_SYSEX = 1 << 13,
CEF_PERMISSION_TYPE_MULTIPLE_DOWNLOADS = 1 << 14,
CEF_PERMISSION_TYPE_NOTIFICATIONS = 1 << 15,
@@ -3767,6 +3839,20 @@ typedef enum {
CEF_ZOOM_COMMAND_IN,
} cef_zoom_command_t;
///
/// Specifies the color variants supported by
/// CefRequestContext::SetChromeThemeColor.
///
typedef enum {
CEF_COLOR_VARIANT_SYSTEM,
CEF_COLOR_VARIANT_LIGHT,
CEF_COLOR_VARIANT_DARK,
CEF_COLOR_VARIANT_TONAL_SPOT,
CEF_COLOR_VARIANT_NEUTRAL,
CEF_COLOR_VARIANT_VIBRANT,
CEF_COLOR_VARIANT_EXPRESSIVE,
} cef_color_variant_t;
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,57 @@
// Copyright (c) 2024 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_COLOR_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_COLOR_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
///
/// Describes how to interpret the components of a pixel.
///
typedef enum {
///
/// RGBA with 8 bits per pixel (32bits total).
///
CEF_COLOR_TYPE_RGBA_8888,
///
/// BGRA with 8 bits per pixel (32bits total).
///
CEF_COLOR_TYPE_BGRA_8888,
} cef_color_type_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_COLOR_H_

View File

@@ -380,6 +380,13 @@ typedef enum {
/// a requesting-origin/top-level-site combination and persistent.
CEF_CONTENT_SETTING_TYPE_TOP_LEVEL_TPCD_TRIAL,
/// Content Setting for a first-party origin trial that allows websites to
/// enable third-party cookie deprecation.
/// ALLOW (default): no effect (e.g. third-party cookies allowed, if not
/// blocked otherwise).
/// BLOCK: third-party cookies blocked, but 3PCD mitigations enabled.
CEF_CONTENT_SETTING_TOP_LEVEL_TPCD_ORIGIN_TRIAL,
/// Content setting used to indicate whether entering picture-in-picture
/// automatically should be enabled.
CEF_CONTENT_SETTING_TYPE_AUTO_PICTURE_IN_PICTURE,
@@ -407,7 +414,36 @@ typedef enum {
/// Content settings for access to printers for the Web Printing API.
CEF_CONTENT_SETTING_TYPE_WEB_PRINTING,
CEF_CONTENT_SETTING_TYPE_NUM_TYPES,
/// Content setting used to indicate whether entering HTML Fullscreen
/// automatically (i.e. without transient activation) should be enabled.
CEF_CONTENT_SETTING_TYPE_AUTOMATIC_FULLSCREEN,
/// Content settings used to indicate that a web app is allowed to prompt the
/// user for the installation of sub apps.
CEF_CONTENT_SETTING_TYPE_SUB_APP_INSTALLATION_PROMPTS,
/// Whether an application can enumerate audio output device.
CEF_CONTENT_SETTING_TYPE_SPEAKER_SELECTION,
/// Content settings for access to the Direct Sockets API.
CEF_CONTENT_SETTING_TYPE_DIRECT_SOCKETS,
/// Keyboard Lock API allows a site to capture keyboard inputs that would
/// otherwise be handled by the OS or the browser.
CEF_CONTENT_SETTING_TYPE_KEYBOARD_LOCK,
/// 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

@@ -43,7 +43,9 @@ typedef struct _XDisplay XDisplay;
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_color.h"
#include "include/internal/cef_types_geometry.h"
#include "include/internal/cef_types_runtime.h"
// Handle types.
#if defined(CEF_X11)
@@ -135,8 +137,65 @@ typedef struct _cef_window_info_t {
/// Pointer for the new browser window. Only used with windowed rendering.
///
cef_window_handle_t window;
///
/// Optionally change the runtime style. Alloy style will always be used if
/// |windowless_rendering_enabled| is true. See cef_runtime_style_t
/// documentation for details.
///
cef_runtime_style_t runtime_style;
} cef_window_info_t;
///
/// Structure containing the plane information of the shared texture.
/// Sync with native_pixmap_handle.h
///
typedef struct _cef_accelerated_paint_native_pixmap_plane_info_t {
///
/// The strides and offsets in bytes to be used when accessing the buffers via
/// a memory mapping. One per plane per entry. Size in bytes of the plane is
/// necessary to map the buffers.
///
uint32_t stride;
uint64_t offset;
uint64_t size;
///
/// File descriptor for the underlying memory object (usually dmabuf).
///
int fd;
} cef_accelerated_paint_native_pixmap_plane_t;
#define kAcceleratedPaintMaxPlanes 4
///
/// Structure containing shared texture information for the OnAcceleratedPaint
/// callback. Resources will be released to the underlying pool for reuse when
/// the callback returns from client code.
///
typedef struct _cef_accelerated_paint_info_t {
///
/// Planes of the shared texture, usually file descriptors of dmabufs.
///
cef_accelerated_paint_native_pixmap_plane_t
planes[kAcceleratedPaintMaxPlanes];
///
/// Plane count.
///
int plane_count;
///
/// Modifier could be used with EGL driver.
///
uint64_t modifier;
///
/// The pixel format of the texture.
///
cef_color_type_t format;
} cef_accelerated_paint_info_t;
#ifdef __cplusplus
}
#endif

View File

@@ -35,7 +35,9 @@
#if defined(OS_MAC)
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_color.h"
#include "include/internal/cef_types_geometry.h"
#include "include/internal/cef_types_runtime.h"
// Handle types.
// Actually NSCursor*
@@ -44,6 +46,8 @@
#define cef_event_handle_t void*
// Actually NSView*
#define cef_window_handle_t void*
// Actually IOSurface*
#define cef_shared_texture_handle_t void*
#define kNullCursorHandle NULL
#define kNullEventHandle NULL
@@ -134,8 +138,32 @@ typedef struct _cef_window_info_t {
/// rendering.
///
cef_window_handle_t view;
///
/// Optionally change the runtime style. Alloy style will always be used if
/// |windowless_rendering_enabled| is true or if |parent_view| is provided.
/// See cef_runtime_style_t documentation for details.
///
cef_runtime_style_t runtime_style;
} cef_window_info_t;
///
/// Structure containing shared texture information for the OnAcceleratedPaint
/// callback. Resources will be released to the underlying pool for reuse when
/// the callback returns from client code.
///
typedef struct _cef_accelerated_paint_info_t {
///
/// Handle for the shared texture IOSurface.
///
cef_shared_texture_handle_t shared_texture_io_surface;
///
/// The pixel format of the texture.
///
cef_color_type_t format;
} cef_accelerated_paint_info_t;
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,88 @@
// Copyright (c) 2024 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_RUNTIME_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_RUNTIME_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
///
/// CEF supports both a Chrome runtime (based on the Chrome UI layer) and an
/// Alloy runtime (based on the Chromium content layer). The Chrome runtime
/// provides the full Chrome UI and browser functionality whereas the Alloy
/// runtime provides less default browser functionality but adds additional
/// client callbacks and support for windowless (off-screen) rendering. For
/// additional comparative details on runtime types see
/// https://bitbucket.org/chromiumembedded/cef/wiki/Architecture.md#markdown-header-cef3
///
/// Each runtime is composed of a bootstrap component and a style component. The
/// bootstrap component is configured via CefSettings.chrome_runtime and cannot
/// be changed after CefInitialize. The style component is individually
/// configured for each window/browser at creation time and, in combination with
/// the Chrome bootstrap, different styles can be mixed during runtime.
///
/// Windowless rendering will always use Alloy style. Windowed rendering with a
/// default window or client-provided parent window can configure the style via
/// CefWindowInfo.runtime_style. Windowed rendering with the Views framework can
/// configure the style via CefWindowDelegate::GetWindowRuntimeStyle and
/// CefBrowserViewDelegate::GetBrowserRuntimeStyle. Alloy style Windows with the
/// Views framework can host only Alloy style BrowserViews but Chrome style
/// Windows can host both style BrowserViews. Additionally, a Chrome style
/// Window can host at most one Chrome style BrowserView but potentially
/// multiple Alloy style BrowserViews. See CefWindowInfo.runtime_style
/// documentation for any additional platform-specific limitations.
///
typedef enum {
///
/// Use the default runtime style. The default style will match the
/// CefSettings.chrome_runtime value in most cases. See above documentation
/// for exceptions.
///
CEF_RUNTIME_STYLE_DEFAULT,
///
/// Use the Chrome runtime style. Only supported with the Chrome runtime.
///
CEF_RUNTIME_STYLE_CHROME,
///
/// Use the Alloy runtime style. Supported with both the Alloy and Chrome
/// runtime.
///
CEF_RUNTIME_STYLE_ALLOY,
} cef_runtime_style_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_RUNTIME_H_

View File

@@ -37,12 +37,15 @@
#include <windows.h>
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_color.h"
#include "include/internal/cef_types_geometry.h"
#include "include/internal/cef_types_runtime.h"
// Handle types.
#define cef_cursor_handle_t HCURSOR
#define cef_event_handle_t MSG*
#define cef_window_handle_t HWND
#define cef_shared_texture_handle_t HANDLE
#define kNullCursorHandle NULL
#define kNullEventHandle NULL
@@ -102,8 +105,33 @@ typedef struct _cef_window_info_t {
/// Handle for the new browser window. Only used with windowed rendering.
///
cef_window_handle_t window;
///
/// Optionally change the runtime style. Alloy style will always be used if
/// |windowless_rendering_enabled| is true. See cef_runtime_style_t
/// documentation for details.
///
cef_runtime_style_t runtime_style;
} cef_window_info_t;
///
/// Structure containing shared texture information for the OnAcceleratedPaint
/// callback. Resources will be released to the underlying pool for reuse when
/// the callback returns from client code.
///
typedef struct _cef_accelerated_paint_info_t {
///
/// Handle for the shared texture. The shared texture is instantiated
/// without a keyed mutex.
///
cef_shared_texture_handle_t shared_texture_handle;
///
/// The pixel format of the texture.
///
cef_color_type_t format;
} cef_accelerated_paint_info_t;
#ifdef __cplusplus
}
#endif

View File

@@ -697,7 +697,9 @@ using CefPdfPrintSettings = CefStructBase<CefPdfPrintSettingsTraits>;
///
class CefBoxLayoutSettings : public cef_box_layout_settings_t {
public:
CefBoxLayoutSettings() : cef_box_layout_settings_t{} {}
CefBoxLayoutSettings() : cef_box_layout_settings_t{} {
cross_axis_alignment = CEF_AXIS_ALIGNMENT_STRETCH;
}
CefBoxLayoutSettings(const cef_box_layout_settings_t& r)
: cef_box_layout_settings_t(r) {}
};
@@ -748,4 +750,14 @@ struct CefMediaSinkDeviceInfoTraits {
///
using CefMediaSinkDeviceInfo = CefStructBase<CefMediaSinkDeviceInfoTraits>;
///
/// Class representing accelerated paint info.
///
class CefAcceleratedPaintInfo : public cef_accelerated_paint_info_t {
public:
CefAcceleratedPaintInfo() : cef_accelerated_paint_info_t{} {}
CefAcceleratedPaintInfo(const cef_accelerated_paint_info_t& r)
: cef_accelerated_paint_info_t(r) {}
};
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_

View File

@@ -73,6 +73,7 @@ struct CefWindowInfoTraits {
target->shared_texture_enabled = src->shared_texture_enabled;
target->external_begin_frame_enabled = src->external_begin_frame_enabled;
target->window = src->window;
target->runtime_style = src->runtime_style;
}
};
@@ -130,6 +131,7 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
void SetAsWindowless(CefWindowHandle parent) {
windowless_rendering_enabled = TRUE;
parent_window = parent;
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
}
};

View File

@@ -107,6 +107,13 @@ class CefBrowserView : public CefView {
///
/*--cef()--*/
virtual void SetPreferAccelerators(bool prefer_accelerators) = 0;
///
/// Returns the runtime style for this BrowserView (ALLOY or CHROME). See
/// cef_runtime_style_t documentation for details.
///
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
virtual cef_runtime_style_t GetRuntimeStyle() = 0;
};
#endif // CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_H_

View File

@@ -140,6 +140,15 @@ class CefBrowserViewDelegate : public CefViewDelegate {
cef_gesture_command_t gesture_command) {
return false;
}
///
/// Optionally change the runtime style for this BrowserView. See
/// cef_runtime_style_t documentation for details.
///
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
virtual cef_runtime_style_t GetBrowserRuntimeStyle() {
return CEF_RUNTIME_STYLE_DEFAULT;
}
};
#endif // CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_DELEGATE_H_

View File

@@ -357,17 +357,31 @@ class CefView : public CefBaseRefCounted {
virtual void RequestFocus() = 0;
///
/// Sets the background color for this View.
/// Sets the background color for this View. The background color will be
/// automatically reset when CefViewDelegate::OnThemeChanged is called.
///
/*--cef()--*/
virtual void SetBackgroundColor(cef_color_t color) = 0;
///
/// Returns the background color for this View.
/// Returns the background color for this View. If the background color is
/// unset then the current `GetThemeColor(CEF_ColorPrimaryBackground)` value
/// will be returned. If this View belongs to an overlay (created with
/// CefWindow::AddOverlayView), and the background color is unset, then a
/// value of transparent (0) will be returned.
///
/*--cef()--*/
virtual cef_color_t GetBackgroundColor() = 0;
///
/// Returns the current theme color associated with |color_id|, or the
/// placeholder color (red) if unset. See cef_color_ids.h for standard ID
/// values. Standard colors can be overridden and custom colors can be added
/// using CefWindow::SetThemeColor.
///
/*--cef()--*/
virtual cef_color_t GetThemeColor(int color_id) = 0;
///
/// Convert |point| from this View's coordinate system to DIP screen
/// coordinates. This View must belong to a Window when calling this method.

View File

@@ -131,6 +131,27 @@ class CefViewDelegate : public virtual CefBaseRefCounted {
///
/*--cef()--*/
virtual void OnBlur(CefRefPtr<CefView> view) {}
///
/// Called when the theme for |view| has changed, after the new theme colors
/// have already been applied. Views are notified via the component hierarchy
/// in depth-first reverse order (children before parents).
///
/// This will be called in the following cases:
///
/// 1. When |view|, or a parent of |view|, is added to a Window.
/// 2. When the native/OS or Chrome theme changes for the Window that contains
/// |view|. See CefWindowDelegate::OnThemeColorsChanged documentation.
/// 3. When the client explicitly calls CefWindow::ThemeChanged on the Window
/// that contains |view|.
///
/// Optionally use this callback to override the new per-View theme colors by
/// calling CefView::SetBackgroundColor or the appropriate component-specific
/// method. See CefWindow::SetThemeColor documentation for how to customize
/// additional Window theme colors.
///
/*--cef()--*/
virtual void OnThemeChanged(CefRefPtr<CefView> view) {}
};
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_

View File

@@ -377,6 +377,50 @@ class CefWindow : public CefPanel {
///
/*--cef()--*/
virtual void RemoveAllAccelerators() = 0;
///
/// Override a standard theme color or add a custom color associated with
/// |color_id|. See cef_color_ids.h for standard ID values. Recommended usage
/// is as follows:
///
/// 1. Customize the default native/OS theme by calling SetThemeColor before
/// showing the first Window. When done setting colors call
/// CefWindow::ThemeChanged to trigger CefViewDelegate::OnThemeChanged
/// notifications.
/// 2. Customize the current native/OS or Chrome theme after it changes by
/// calling SetThemeColor from the CefWindowDelegate::OnThemeColorsChanged
/// callback. CefViewDelegate::OnThemeChanged notifications will then be
/// triggered automatically.
///
/// The configured color will be available immediately via
/// CefView::GetThemeColor and will be applied to each View in this Window's
/// component hierarchy when CefViewDelegate::OnThemeChanged is called. See
/// OnThemeColorsChanged documentation for additional details.
///
/// Clients wishing to add custom colors should use |color_id| values >=
/// CEF_ChromeColorsEnd.
///
/*--cef()--*/
virtual void SetThemeColor(int color_id, cef_color_t color) = 0;
///
/// Trigger CefViewDelegate::OnThemeChanged callbacks for each View in this
/// Window's component hierarchy. Unlike a native/OS or Chrome theme change
/// this method does not reset theme colors to standard values and does not
/// result in a call to CefWindowDelegate::OnThemeColorsChanged.
///
/// Do not call this method from CefWindowDelegate::OnThemeColorsChanged or
/// CefViewDelegate::OnThemeChanged.
///
/*--cef()--*/
virtual void ThemeChanged() = 0;
///
/// Returns the runtime style for this Window (ALLOY or CHROME). See
/// cef_runtime_style_t documentation for details.
///
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
virtual cef_runtime_style_t GetRuntimeStyle() = 0;
};
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_H_

View File

@@ -164,12 +164,11 @@ class CefWindowDelegate : public CefPanelDelegate {
}
///
/// Return whether the titlebar height should be overridden,
/// and sets the height of the titlebar in |titlebar_height|.
/// On macOS, it can also be used to adjust the vertical position
/// of the traffic light buttons in frameless windows.
/// The buttons will be positioned halfway down the titlebar
/// at a height of |titlebar_height| / 2.
/// Return whether the titlebar height should be overridden, and sets the
/// height of the titlebar in |titlebar_height|. On macOS, it can also be used
/// to adjust the vertical position of the traffic light buttons in frameless
/// windows. The buttons will be positioned halfway down the titlebar at a
/// height of |titlebar_height| / 2.
///
/*--cef()--*/
virtual bool GetTitlebarHeight(CefRefPtr<CefWindow> window,
@@ -177,6 +176,21 @@ class CefWindowDelegate : public CefPanelDelegate {
return false;
}
///
/// Return whether the view should accept the initial mouse-down event,
/// allowing it to respond to click-through behavior. If STATE_ENABLED is
/// returned, the view will be sent a mouseDown: message for an initial
/// mouse-down event, activating the view with one click, instead of clicking
/// first to make the window active and then clicking the view.
///
/// This method is only supported on macOS. For more details, refer to the
/// documentation of acceptsFirstMouse.
///
/*--cef(default_retval=STATE_DEFAULT)--*/
virtual cef_state_t AcceptsFirstMouse(CefRefPtr<CefWindow> window) {
return STATE_DEFAULT;
}
///
/// Return true if |window| can be resized.
///
@@ -222,6 +236,50 @@ class CefWindowDelegate : public CefPanelDelegate {
const CefKeyEvent& event) {
return false;
}
///
/// Called after the native/OS or Chrome theme for |window| has changed.
/// |chrome_theme| will be true if the notification is for a Chrome theme.
///
/// Native/OS theme colors are configured globally and do not need to be
/// customized for each Window individually. An example of a native/OS theme
/// change that triggers this callback is when the user switches between dark
/// and light mode during application lifespan. Native/OS theme changes can be
/// disabled by passing the `--force-dark-mode` or `--force-light-mode`
/// command-line flag.
///
/// Chrome theme colors will be applied and this callback will be triggered
/// if/when a BrowserView is added to the Window's component hierarchy. Chrome
/// theme colors can be configured on a per-RequestContext basis using
/// CefRequestContext::SetChromeColorScheme or (Chrome runtime only) by
/// visiting chrome://settings/manageProfile. Any theme changes using those
/// mechanisms will also trigger this callback. Chrome theme colors will be
/// persisted and restored from disk cache with the Chrome runtime, and with
/// the Alloy runtime if persist_user_preferences is set to true via
/// CefSettings or CefRequestContextSettings.
///
/// This callback is not triggered on Window creation so clients that wish to
/// customize the initial native/OS theme must call CefWindow::SetThemeColor
/// and CefWindow::ThemeChanged before showing the first Window.
///
/// Theme colors will be reset to standard values before this callback is
/// called for the first affected Window. Call CefWindow::SetThemeColor from
/// inside this callback to override a standard color or add a custom color.
/// CefViewDelegate::OnThemeChanged will be called after this callback for the
/// complete |window| component hierarchy.
///
/*--cef()--*/
virtual void OnThemeColorsChanged(CefRefPtr<CefWindow> window,
bool chrome_theme) {}
///
/// Optionally change the runtime style for this Window. See
/// cef_runtime_style_t documentation for details.
///
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
virtual cef_runtime_style_t GetWindowRuntimeStyle() {
return CEF_RUNTIME_STYLE_DEFAULT;
}
};
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_

View File

@@ -8,7 +8,7 @@
#include <memory>
#include <utility>
#include "libcef/browser/download_manager_delegate.h"
#include "libcef/browser/alloy/alloy_download_manager_delegate.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/ssl_host_state_delegate.h"
@@ -297,15 +297,6 @@ bool AlloyBrowserContext::UnloadExtension(const CefString& extension_id) {
return extension_system()->UnloadExtension(extension_id);
}
bool AlloyBrowserContext::IsPrintPreviewSupported() const {
CEF_REQUIRE_UIT();
if (!extensions::PrintPreviewEnabled()) {
return false;
}
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
}
content::ClientHintsControllerDelegate*
AlloyBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;
@@ -345,7 +336,7 @@ content::DownloadManagerDelegate*
AlloyBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_) {
download_manager_delegate_ =
std::make_unique<CefDownloadManagerDelegate>(GetDownloadManager());
std::make_unique<AlloyDownloadManagerDelegate>(GetDownloadManager());
}
return download_manager_delegate_.get();
}
@@ -461,6 +452,12 @@ void AlloyBrowserContext::RebuildTable(
enumerator->OnComplete(true);
}
void AlloyBrowserContext::BuildVisitedLinkTable(
const scoped_refptr<VisitedLinkEnumerator>& enumerator) {
// Called when visited links will not or cannot be loaded from disk.
enumerator->OnVisitedLinkComplete(true);
}
DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() {
CEF_REQUIRE_UIT();
if (!download_prefs_) {
@@ -469,6 +466,13 @@ DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() {
return download_prefs_.get();
}
void AlloyBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
visitedlink_master_->AddURLs(urls);
void AlloyBrowserContext::AddVisitedURLs(
const GURL& url,
const std::vector<GURL>& redirect_chain,
ui::PageTransition /*transition*/) {
if (!redirect_chain.empty()) {
visitedlink_master_->AddURLs(redirect_chain);
} else {
visitedlink_master_->AddURL(url);
}
}

View File

@@ -15,7 +15,7 @@
#include "components/proxy_config/pref_proxy_config_tracker.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
class CefDownloadManagerDelegate;
class AlloyDownloadManagerDelegate;
class CefSSLHostStateDelegate;
class CefVisitedLinkListener;
class PrefService;
@@ -56,7 +56,9 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
bool GetExtensions(std::vector<CefString>& extension_ids) override;
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
bool UnloadExtension(const CefString& extension_id) override;
bool IsPrintPreviewSupported() const override;
void AddVisitedURLs(const GURL& url,
const std::vector<GURL>& redirect_chain,
ui::PageTransition transition) override;
// content::BrowserContext overrides.
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
@@ -108,17 +110,16 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
// visitedlink::VisitedLinkDelegate methods.
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
void BuildVisitedLinkTable(
const scoped_refptr<VisitedLinkEnumerator>& enumerator) override;
// Manages extensions.
extensions::CefExtensionSystem* extension_system() const {
return extension_system_;
}
// Called from AlloyBrowserHostImpl::DidFinishNavigation to update the table
// of visited links.
void AddVisitedURLs(const std::vector<GURL>& urls);
// Called from DownloadPrefs::FromBrowserContext.
// Called from DownloadPrefs::FromBrowserContext via
// alloy::GetDownloadPrefsFromBrowserContext.
DownloadPrefs* GetDownloadPrefs();
private:
@@ -127,7 +128,7 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
std::unique_ptr<PrefService> pref_service_;
std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<AlloyDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_master_;
// |visitedlink_listener_| is owned by visitedlink_master_.

View File

@@ -9,7 +9,6 @@
#include <string>
#include <utility>
#include "libcef/browser/alloy/alloy_browser_context.h"
#include "libcef/browser/alloy/browser_platform_delegate_alloy.h"
#include "libcef/browser/audio_capturer.h"
#include "libcef/browser/browser_context.h"
@@ -17,7 +16,8 @@
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools/devtools_manager.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/hang_monitor.h"
#include "libcef/browser/media_access_query.h"
#include "libcef/browser/osr/osr_util.h"
#include "libcef/browser/request_context_impl.h"
@@ -28,7 +28,7 @@
#include "libcef/common/net/url_util.h"
#include "libcef/common/request_impl.h"
#include "libcef/common/values_impl.h"
#include "libcef/features/runtime_checks.h"
#include "libcef/features/runtime.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
@@ -72,11 +72,15 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
CefBrowserPlatformDelegate::Create(create_params);
CHECK(platform_delegate);
// Expect runtime style to match.
CHECK(platform_delegate->IsAlloyStyle());
const bool is_devtools_popup = !!create_params.devtools_opener;
scoped_refptr<CefBrowserInfo> info =
CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
is_devtools_popup, platform_delegate->IsWindowless(),
platform_delegate->IsPrintPreviewSupported(),
create_params.extra_info);
bool own_web_contents = false;
@@ -100,8 +104,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
CefRefPtr<AlloyBrowserHostImpl> browser = CreateInternal(
create_params.settings, create_params.client, web_contents,
own_web_contents, info,
static_cast<AlloyBrowserHostImpl*>(create_params.devtools_opener.get()),
own_web_contents, info, FromBaseChecked(create_params.devtools_opener),
is_devtools_popup, request_context_impl, std::move(platform_delegate),
cef_extension);
if (!browser) {
@@ -180,8 +183,8 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
// 1. Notify the opener browser's platform delegate. With Views this will
// result in a call to CefBrowserViewDelegate::OnPopupBrowserViewCreated().
// Do this first for consistency with the Chrome runtime.
opener->platform_delegate_->PopupBrowserCreated(browser.get(),
is_devtools_popup);
opener->platform_delegate_->PopupBrowserCreated(
browser->platform_delegate(), browser.get(), is_devtools_popup);
}
// 2. Notify the browser's LifeSpanHandler. This must always be the first
@@ -199,36 +202,38 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
return browser;
}
// static
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::FromBaseChecked(
CefRefPtr<CefBrowserHostBase> host_base) {
if (!host_base) {
return nullptr;
}
CHECK(host_base->IsAlloyStyle());
return static_cast<AlloyBrowserHostImpl*>(host_base.get());
}
// static
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForHost(
const content::RenderViewHost* host) {
REQUIRE_ALLOY_RUNTIME();
auto browser = CefBrowserHostBase::GetBrowserForHost(host);
return static_cast<AlloyBrowserHostImpl*>(browser.get());
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
}
// static
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForHost(
const content::RenderFrameHost* host) {
REQUIRE_ALLOY_RUNTIME();
auto browser = CefBrowserHostBase::GetBrowserForHost(host);
return static_cast<AlloyBrowserHostImpl*>(browser.get());
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
}
// static
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForContents(
const content::WebContents* contents) {
REQUIRE_ALLOY_RUNTIME();
auto browser = CefBrowserHostBase::GetBrowserForContents(contents);
return static_cast<AlloyBrowserHostImpl*>(browser.get());
return FromBaseChecked(CefBrowserHostBase::GetBrowserForContents(contents));
}
// static
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::GetBrowserForGlobalId(
const content::GlobalRenderFrameHostId& global_id) {
REQUIRE_ALLOY_RUNTIME();
auto browser = CefBrowserHostBase::GetBrowserForGlobalId(global_id);
return static_cast<AlloyBrowserHostImpl*>(browser.get());
return FromBaseChecked(CefBrowserHostBase::GetBrowserForGlobalId(global_id));
}
// AlloyBrowserHostImpl methods.
@@ -332,56 +337,6 @@ void AlloyBrowserHostImpl::StopFinding(bool clearSelection) {
}
}
void AlloyBrowserHostImpl::ShowDevToolsOnUIThread(
std::unique_ptr<CefShowDevToolsParams> params) {
CEF_REQUIRE_UIT();
if (!EnsureDevToolsManager()) {
return;
}
devtools_manager_->ShowDevTools(params->window_info_, params->client_,
params->settings_,
params->inspect_element_at_);
}
void AlloyBrowserHostImpl::CloseDevTools() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&AlloyBrowserHostImpl::CloseDevTools, this));
return;
}
if (!devtools_manager_) {
return;
}
devtools_manager_->CloseDevTools();
}
bool AlloyBrowserHostImpl::HasDevTools() {
if (!CEF_CURRENTLY_ON_UIT()) {
DCHECK(false) << "called on invalid thread";
return false;
}
if (!devtools_manager_) {
return false;
}
return devtools_manager_->HasDevTools();
}
void AlloyBrowserHostImpl::SetAccessibilityState(
cef_state_t accessibility_state) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&AlloyBrowserHostImpl::SetAccessibilityState,
this, accessibility_state));
return;
}
if (platform_delegate_) {
platform_delegate_->SetAccessibilityState(accessibility_state);
}
}
void AlloyBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) {
@@ -649,8 +604,9 @@ void AlloyBrowserHostImpl::CancelContextMenu() {
bool AlloyBrowserHostImpl::MaybeAllowNavigation(
content::RenderFrameHost* opener,
bool is_guest_view,
const content::OpenURLParams& params) {
const bool is_guest_view = extensions::IsBrowserPluginGuest(
content::WebContents::FromRenderFrameHost(opener));
if (is_guest_view && !params.is_pdf &&
!params.url.SchemeIs(extensions::kExtensionScheme) &&
!params.url.SchemeIs(content::kChromeUIScheme)) {
@@ -662,7 +618,7 @@ bool AlloyBrowserHostImpl::MaybeAllowNavigation(
CEF_POST_TASK(CEF_UIT,
base::BindOnce(
base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
this, nullptr, params));
this, nullptr, params, base::NullCallback()));
return false;
}
@@ -970,8 +926,11 @@ bool AlloyBrowserHostImpl::IsAudioMuted() {
content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) {
auto target_contents = contents_delegate_->OpenURLFromTab(source, params);
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>
navigation_handle_callback) {
auto target_contents = contents_delegate_->OpenURLFromTabEx(
source, params, navigation_handle_callback);
if (target_contents) {
// Start a navigation in the current browser that will result in the
// creation of a new render process.
@@ -1188,7 +1147,8 @@ void AlloyBrowserHostImpl::WebContentsCreated(
scoped_refptr<CefBrowserInfo> info =
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
new_contents, platform_delegate->IsWindowless(), extra_info);
new_contents, platform_delegate->IsWindowless(),
platform_delegate->IsPrintPreviewSupported(), extra_info);
CHECK(info.get());
CHECK(info->is_popup());
@@ -1210,6 +1170,20 @@ void AlloyBrowserHostImpl::WebContentsCreated(
std::move(platform_delegate), /*extension=*/nullptr);
}
void AlloyBrowserHostImpl::RendererUnresponsive(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host,
base::RepeatingClosure hang_monitor_restarter) {
hang_monitor::RendererUnresponsive(this, render_widget_host,
hang_monitor_restarter);
}
void AlloyBrowserHostImpl::RendererResponsive(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host) {
hang_monitor::RendererResponsive(this, render_widget_host);
}
content::JavaScriptDialogManager*
AlloyBrowserHostImpl::GetJavaScriptDialogManager(content::WebContents* source) {
if (!javascript_dialog_manager_) {
@@ -1302,8 +1276,8 @@ void AlloyBrowserHostImpl::ExitPictureInPicture() {
}
bool AlloyBrowserHostImpl::IsBackForwardCacheSupported() {
// Disabled due to issue #3237.
return false;
// Disabled with Alloy bootstrap due to issue #3237.
return cef::IsChromeRuntimeEnabled();
}
content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
@@ -1311,17 +1285,24 @@ content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
return content::PreloadingEligibility::kEligible;
}
void AlloyBrowserHostImpl::DraggableRegionsChanged(
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
content::WebContents* contents) {
contents_delegate_->DraggableRegionsChanged(regions, contents);
}
// content::WebContentsObserver methods.
// -----------------------------------------------------------------------------
void AlloyBrowserHostImpl::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
if (web_contents()) {
auto cef_browser_context =
static_cast<AlloyBrowserContext*>(web_contents()->GetBrowserContext());
auto cef_browser_context = CefBrowserContext::FromBrowserContext(
web_contents()->GetBrowserContext());
if (cef_browser_context) {
cef_browser_context->AddVisitedURLs(
navigation_handle->GetRedirectChain());
navigation_handle->GetURL(), navigation_handle->GetRedirectChain(),
navigation_handle->GetPageTransition());
}
}
}

View File

@@ -62,6 +62,11 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
static CefRefPtr<AlloyBrowserHostImpl> Create(
CefBrowserCreateParams& create_params);
// Safe (checked) conversion from CefBrowserHostBase to AlloyBrowserHostImpl.
// Use this method instead of static_cast.
static CefRefPtr<AlloyBrowserHostImpl> FromBaseChecked(
CefRefPtr<CefBrowserHostBase> host_base);
// Returns the browser associated with the specified RenderViewHost.
static CefRefPtr<AlloyBrowserHostImpl> GetBrowserForHost(
const content::RenderViewHost* host);
@@ -85,8 +90,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
bool matchCase,
bool findNext) override;
void StopFinding(bool clearSelection) override;
void CloseDevTools() override;
bool HasDevTools() override;
bool IsWindowRenderingDisabled() override;
void WasResized() override;
void WasHidden(bool hidden) override;
@@ -117,7 +120,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
void SetAudioMuted(bool mute) override;
bool IsAudioMuted() override;
void SetAccessibilityState(cef_state_t accessibility_state) override;
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;
@@ -127,9 +129,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void ExecuteChromeCommand(int command_id,
cef_window_open_disposition_t disposition) override;
// Returns true if windowless rendering is enabled.
// CefBrowserHostBase methods:
bool IsWindowless() const override;
bool IsAlloyStyle() const override { return true; }
bool IsVisible() const override;
// Returns true if this browser supports picture-in-picture.
@@ -148,7 +150,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void CancelContextMenu();
bool MaybeAllowNavigation(content::RenderFrameHost* opener,
bool is_guest_view,
const content::OpenURLParams& params) override;
// Convert from view DIP coordinates to screen coordinates. If
@@ -183,7 +184,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
// content::WebContentsDelegate methods.
content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) override;
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>
navigation_handle_callback) override;
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
bool is_main_frame_navigation) override;
void AddNewContents(content::WebContents* source,
@@ -234,6 +237,13 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) override;
void RendererUnresponsive(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host,
base::RepeatingClosure hang_monitor_restarter) override;
void RendererResponsive(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host) override;
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
content::WebContents* source) override;
void RunFileChooser(content::RenderFrameHost* render_frame_host,
@@ -271,6 +281,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
bool IsBackForwardCacheSupported() override;
content::PreloadingEligibility IsPrerender2Supported(
content::WebContents& web_contents) override;
void DraggableRegionsChanged(
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
content::WebContents* contents) override;
// content::WebContentsObserver methods.
using content::WebContentsObserver::BeforeUnloadFired;
@@ -284,10 +297,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
override;
void WebContentsDestroyed() override;
protected:
void ShowDevToolsOnUIThread(
std::unique_ptr<CefShowDevToolsParams> params) override;
private:
friend class CefBrowserPlatformDelegateAlloy;

View File

@@ -9,11 +9,11 @@
#include <memory>
#include <string>
#include "libcef/browser/alloy/devtools/devtools_manager_delegate.h"
#include "libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_context_keyed_service_factories.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/extensions/extension_system_factory.h"
#include "libcef/browser/file_dialog_runner.h"
#include "libcef/browser/net/chrome_scheme_handler.h"
@@ -37,6 +37,7 @@
#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "components/color/color_mixers.h"
#include "components/constrained_window/constrained_window_views.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/network_service_instance.h"
@@ -54,6 +55,9 @@
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
#include "ui/events/devices/x11/touch_factory_x11.h"
#endif
#if defined(USE_DBUS)
#include "chrome/browser/ui/views/dark_mode_manager_linux.h"
#endif
#endif
#if defined(USE_AURA)
@@ -126,26 +130,10 @@ class LinuxUiGetterImpl : public ui::LinuxUiGetter {
}
};
ui::LinuxUi* GetLinuxUI() {
// We can't use GtkUi in combination with multi-threaded-message-loop because
// Chromium's GTK implementation doesn't use GDK threads.
if (!!CefContext::Get()->settings().multi_threaded_message_loop) {
return nullptr;
}
// If the ozone backend hasn't provided a LinuxUiDelegate, don't try to create
// a LinuxUi instance as this may result in a crash in toolkit initialization.
if (!ui::LinuxUiDelegate::GetInstance()) {
return nullptr;
}
return ui::GetDefaultLinuxUi();
}
#endif // BUILDFLAG(IS_LINUX)
void ProcessSingletonNotificationCallbackImpl(
const base::CommandLine& command_line,
base::CommandLine command_line,
const base::FilePath& current_directory) {
// Drop the request if the browser process is already shutting down.
if (!CONTEXT_STATE_VALID()) {
@@ -172,7 +160,7 @@ void ProcessSingletonNotificationCallbackImpl(
// Based on ChromeBrowserMainParts::ProcessSingletonNotificationCallback.
bool ProcessSingletonNotificationCallback(
const base::CommandLine& command_line,
base::CommandLine command_line,
const base::FilePath& current_directory) {
// Drop the request if the browser process is already shutting down.
// Note that we're going to post an async task below. Even if the browser
@@ -191,7 +179,7 @@ bool ProcessSingletonNotificationCallback(
// So, we post a task to asynchronously finish the command line processing.
return base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
FROM_HERE, base::BindOnce(&ProcessSingletonNotificationCallbackImpl,
command_line, current_directory));
std::move(command_line), current_directory));
}
} // namespace
@@ -203,7 +191,8 @@ AlloyBrowserMainParts::~AlloyBrowserMainParts() {
}
void AlloyBrowserMainParts::ToolkitInitialized() {
SetConstrainedWindowViewsClient(CreateAlloyConstrainedWindowViewsClient());
SetConstrainedWindowViewsClient(
CreateAlloyConstrainedWindowViewsClient(nullptr));
#if defined(USE_AURA)
CHECK(aura::Env::GetInstance());
@@ -219,7 +208,9 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
#if BUILDFLAG(IS_LINUX)
// Based on chrome_browser_main_extra_parts_views_linux.cc
if (auto linux_ui = GetLinuxUI()) {
// |linux_ui| will be nullptr with multi-threaded-message-loop. See
// CefUiThread::InitializeBrowserRunner.
if (auto linux_ui = ui::GetDefaultLinuxUi()) {
linux_ui_getter_ = std::make_unique<LinuxUiGetterImpl>();
ui::LinuxUi::SetInstance(linux_ui);
@@ -228,6 +219,13 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
ui::CursorFactory::GetInstance()->ObserveThemeChanges();
}
#if defined(USE_DBUS)
if (!ui::NativeTheme::IsForcedDarkMode() &&
!ui::NativeTheme::IsForcedLightMode()) {
dark_mode_manager_ = std::make_unique<ui::DarkModeManagerLinux>();
}
#endif
auto printing_delegate = new CefPrintingContextLinuxDelegate();
auto default_delegate =
ui::PrintingContextLinuxDelegate::SetInstance(printing_delegate);
@@ -246,6 +244,8 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
// On GTK that builds the native theme that, in turn, adds the GTK core color
// mixer; core mixers should all be added before we add chrome mixers.
ui::ColorProviderManager::Get().AppendColorProviderInitializer(
base::BindRepeating(color::AddComponentsColorMixers));
ui::ColorProviderManager::Get().AppendColorProviderInitializer(
base::BindRepeating(AddChromeColorMixers));
}

View File

@@ -6,10 +6,11 @@
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
#pragma once
#include <string_view>
#include "libcef/browser/request_context_impl.h"
#include "base/command_line.h"
#include "base/strings/string_piece.h"
#include "build/build_config.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_main_parts.h"
@@ -31,7 +32,10 @@ class LayoutProvider;
#if BUILDFLAG(IS_LINUX)
namespace ui {
class LinuxUiGetter;
}
#if defined(USE_DBUS)
class DarkModeManagerLinux;
#endif
} // namespace ui
#endif
class CefDevToolsDelegate;
@@ -99,6 +103,9 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
#if BUILDFLAG(IS_LINUX)
std::unique_ptr<ui::LinuxUiGetter> linux_ui_getter_;
#if defined(USE_DBUS)
std::unique_ptr<ui::DarkModeManagerLinux> dark_mode_manager_;
#endif
#endif
};

View File

@@ -13,6 +13,7 @@
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/alloy/alloy_browser_main.h"
#include "libcef/browser/alloy/alloy_web_contents_view_delegate.h"
#include "libcef/browser/alloy/devtools/devtools_manager_delegate.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_frame.h"
#include "libcef/browser/browser_info.h"
@@ -21,7 +22,6 @@
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/certificate_query.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/extensions/extension_web_contents_observer.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
@@ -91,7 +91,8 @@
#include "components/pdf/browser/pdf_document_helper.h"
#include "components/pdf/browser/pdf_navigation_throttle.h"
#include "components/pdf/browser/pdf_url_loader_request_interceptor.h"
#include "components/pdf/common/internal_plugin_helpers.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"
@@ -118,7 +119,6 @@
#include "extensions/browser/api/automation_internal/automation_event_router.h"
#include "extensions/browser/api/mime_handler_private/mime_handler_private.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_message_filter.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_web_contents_observer.h"
@@ -397,13 +397,6 @@ void AlloyContentBrowserClient::RenderProcessWillLaunch(
content::RenderProcessHost* host) {
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
#if BUILDFLAG(ENABLE_EXTENSIONS_LEGACY_IPC)
if (extensions::ExtensionsEnabled()) {
host->AddFilter(
new extensions::ExtensionMessageFilter(host->GetID(), profile));
}
#endif
// If the renderer process crashes then the host may already have
// CefBrowserInfoManager as an observer. Try to remove it first before adding
// to avoid DCHECKs.
@@ -457,7 +450,7 @@ bool AlloyContentBrowserClient::DoesSiteRequireDedicatedProcess(
}
bool AlloyContentBrowserClient::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
base::StringPiece scheme,
std::string_view scheme,
bool is_embedded_origin_secure) {
// This is needed to bypass the normal SameSite rules for any chrome:// page
// embedding a secure origin, regardless of the registrable domains of any
@@ -478,7 +471,7 @@ bool AlloyContentBrowserClient::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
bool AlloyContentBrowserClient::
ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
base::StringPiece scheme,
std::string_view scheme,
bool is_embedded_origin_secure) {
return is_embedded_origin_secure && scheme == content::kChromeUIScheme;
}
@@ -633,10 +626,6 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
process ? CefBrowserContext::FromBrowserContext(browser_context)
: nullptr;
if (cef_browser_context) {
if (cef_browser_context->IsPrintPreviewSupported()) {
command_line->AppendSwitch(switches::kEnablePrintPreview);
}
// Based on ChromeContentBrowserClientExtensionsPart::
// AppendExtraRendererCommandLineSwitches
if (extensions::ProcessMap::Get(browser_context)
@@ -881,19 +870,6 @@ void AlloyContentBrowserClient::ExposeInterfacesToRenderer(
associated_registry->AddInterface<extensions::mojom::RendererHost>(
base::BindRepeating(&extensions::RendererStartupHelper::BindForRenderer,
render_process_host->GetID()));
#if BUILDFLAG(ENABLE_EXTENSIONS_LEGACY_IPC)
associated_registry->AddInterface<extensions::mojom::EventRouter>(
base::BindRepeating(&extensions::EventRouter::BindForRenderer,
host->GetID()));
associated_registry->AddInterface<extensions::mojom::ServiceWorkerHost>(
base::BindRepeating(&extensions::ServiceWorkerHost::BindReceiver,
host->GetID()));
associated_registry
->AddInterface<extensions::mojom::RendererAutomationRegistry>(
base::BindRepeating(
&extensions::AutomationEventRouter::BindForRenderer,
host->GetID()));
#endif
}
}
@@ -910,7 +886,6 @@ void AlloyContentBrowserClient::
associated_registry.AddInterface<extensions::mojom::RendererHost>(
base::BindRepeating(&extensions::RendererStartupHelper::BindForRenderer,
service_worker_version_info.process_id));
#if !BUILDFLAG(ENABLE_EXTENSIONS_LEGACY_IPC)
associated_registry.AddInterface<extensions::mojom::ServiceWorkerHost>(
base::BindRepeating(&extensions::ServiceWorkerHost::BindReceiver,
service_worker_version_info.process_id));
@@ -922,7 +897,6 @@ void AlloyContentBrowserClient::
associated_registry.AddInterface<extensions::mojom::EventRouter>(
base::BindRepeating(&extensions::EventRouter::BindForRenderer,
service_worker_version_info.process_id));
#endif
}
}
@@ -940,10 +914,10 @@ void AlloyContentBrowserClient::
},
&render_frame_host));
associated_registry.AddInterface<pdf::mojom::PdfService>(base::BindRepeating(
associated_registry.AddInterface<pdf::mojom::PdfHost>(base::BindRepeating(
[](content::RenderFrameHost* render_frame_host,
mojo::PendingAssociatedReceiver<pdf::mojom::PdfService> receiver) {
pdf::PDFDocumentHelper::BindPdfService(
mojo::PendingAssociatedReceiver<pdf::mojom::PdfHost> receiver) {
pdf::PDFDocumentHelper::BindPdfHost(
std::move(receiver), render_frame_host,
std::make_unique<ChromePDFDocumentHelperClient>());
},
@@ -1003,11 +977,8 @@ AlloyContentBrowserClient::CreateThrottlesForNavigation(
throttles.push_back(std::move(pdf_iframe_throttle));
}
auto pdf_throttle = pdf::PdfNavigationThrottle::MaybeCreateThrottleFor(
navigation_handle, std::make_unique<ChromePdfStreamDelegate>());
if (pdf_throttle) {
throttles.push_back(std::move(pdf_throttle));
}
throttles.push_back(std::make_unique<pdf::PdfNavigationThrottle>(
navigation_handle, std::make_unique<ChromePdfStreamDelegate>()));
}
throttle::CreateThrottlesForNavigation(navigation_handle, throttles);
@@ -1022,7 +993,7 @@ AlloyContentBrowserClient::CreateURLLoaderThrottles(
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id,
absl::optional<int64_t> navigation_id) {
std::optional<int64_t> navigation_id) {
std::vector<std::unique_ptr<blink::URLLoaderThrottle>> result;
// Used to substitute View ID for PDF contents when using the PDF plugin.
@@ -1123,20 +1094,27 @@ AlloyContentBrowserClient::CreateLoginDelegate(
std::move(auth_required_callback));
}
void AlloyContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
int frame_tree_node_id,
NonNetworkURLLoaderFactoryMap* factories) {
mojo::PendingRemote<network::mojom::URLLoaderFactory>
AlloyContentBrowserClient::CreateNonNetworkNavigationURLLoaderFactory(
const std::string& scheme,
int frame_tree_node_id) {
if (!extensions::ExtensionsEnabled()) {
return;
return {};
}
content::WebContents* web_contents =
content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);
factories->emplace(
extensions::kExtensionScheme,
extensions::CreateExtensionNavigationURLLoaderFactory(
web_contents->GetBrowserContext(),
!!extensions::WebViewGuest::FromWebContents(web_contents)));
content::BrowserContext* browser_context = web_contents->GetBrowserContext();
if (scheme == extensions::kExtensionScheme &&
!extensions::ChromeContentBrowserClientExtensionsPart::
AreExtensionsDisabledForProfile(browser_context)) {
return extensions::CreateExtensionNavigationURLLoaderFactory(
browser_context,
!!extensions::WebViewGuest::FromWebContents(web_contents));
}
return {};
}
void AlloyContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
@@ -1196,15 +1174,16 @@ void AlloyContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
}
}
bool AlloyContentBrowserClient::WillCreateURLLoaderFactory(
void AlloyContentBrowserClient::WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,
content::RenderFrameHost* frame,
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,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
network::URLLoaderFactoryBuilder& factory_builder,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
header_client,
bool* bypass_redirect_checks,
@@ -1217,9 +1196,8 @@ bool AlloyContentBrowserClient::WillCreateURLLoaderFactory(
type == URLLoaderFactoryType::kDownload, request_initiator);
net_service::ProxyURLLoaderFactory::CreateProxy(
browser_context, factory_receiver, header_client,
browser_context, factory_builder, header_client,
std::move(request_handler));
return true;
}
void AlloyContentBrowserClient::OnNetworkServiceCreated(

View File

@@ -15,6 +15,7 @@
#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/web_contents.h"
#include "third_party/skia/include/core/SkColor.h"
class AlloyBrowserMainParts;
@@ -44,10 +45,10 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context,
const GURL& effective_site_url) override;
bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
base::StringPiece scheme,
std::string_view scheme,
bool is_embedded_origin_secure) override;
bool ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
base::StringPiece scheme,
std::string_view scheme,
bool is_embedded_origin_secure) override;
void OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
@@ -137,7 +138,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id,
absl::optional<int64_t> navigation_id) override;
std::optional<int64_t> navigation_id) override;
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
CreateURLLoaderThrottlesForKeepAlive(
const network::ResourceRequest& request,
@@ -171,23 +172,24 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback) override;
void RegisterNonNetworkNavigationURLLoaderFactories(
int frame_tree_node_id,
NonNetworkURLLoaderFactoryMap* factories) override;
mojo::PendingRemote<network::mojom::URLLoaderFactory>
CreateNonNetworkNavigationURLLoaderFactory(const std::string& scheme,
int frame_tree_node_id) override;
void RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
int render_frame_id,
const std::optional<url::Origin>& request_initiator_origin,
NonNetworkURLLoaderFactoryMap* factories) override;
bool WillCreateURLLoaderFactory(
void WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,
content::RenderFrameHost* frame,
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,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
network::URLLoaderFactoryBuilder& factory_builder,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
header_client,
bool* bypass_redirect_checks,

View File

@@ -0,0 +1,22 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/alloy_download_manager_delegate.h"
#include "chrome/common/chrome_constants.h"
#include "components/download/public/common/download_item.h"
AlloyDownloadManagerDelegate::AlloyDownloadManagerDelegate(
content::DownloadManager* manager)
: CefDownloadManagerDelegateImpl(manager, /*alloy_bootstrap=*/true) {}
void AlloyDownloadManagerDelegate::GetNextId(
content::DownloadIdCallback callback) {
static uint32_t next_id = download::DownloadItem::kInvalidId + 1;
std::move(callback).Run(next_id++);
}
std::string AlloyDownloadManagerDelegate::ApplicationClientIdForFileScanning() {
return std::string(chrome::kApplicationClientIDStringForAVScanning);
}

View File

@@ -0,0 +1,26 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
#pragma once
#include "libcef/browser/download_manager_delegate_impl.h"
// Specialization for the Alloy bootstrap.
class AlloyDownloadManagerDelegate : public CefDownloadManagerDelegateImpl {
public:
explicit AlloyDownloadManagerDelegate(content::DownloadManager* manager);
AlloyDownloadManagerDelegate(const AlloyDownloadManagerDelegate&) = delete;
AlloyDownloadManagerDelegate& operator=(const AlloyDownloadManagerDelegate&) =
delete;
private:
// DownloadManagerDelegate methods.
void GetNextId(content::DownloadIdCallback callback) override;
std::string ApplicationClientIdForFileScanning() override;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_

View File

@@ -10,6 +10,8 @@ namespace alloy {
DownloadPrefs* GetDownloadPrefsFromBrowserContext(
content::BrowserContext* context) {
// This function is only called with Alloy bootstrap, so the static_cast is
// safe.
return static_cast<AlloyBrowserContext*>(context)->GetDownloadPrefs();
}

View File

@@ -18,27 +18,34 @@
#include "libcef/features/runtime_checks.h"
#include "base/logging.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/printing/printing_init.h"
#include "chrome/browser/task_manager/web_contents_tags.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "chrome/browser/ui/tab_helpers.h"
#include "components/find_in_page/find_tab_helper.h"
#include "components/find_in_page/find_types.h"
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
#include "components/performance_manager/embedder/performance_manager_registry.h"
#include "components/permissions/permission_request_manager.h"
#include "components/zoom/zoom_controller.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_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"
namespace {
const char kAttachedHelpersUserDataKey[] = "CefAttachedHelpers";
} // namespace
CefBrowserPlatformDelegateAlloy::CefBrowserPlatformDelegateAlloy()
: weak_ptr_factory_(this) {}
content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
CefBrowserCreateParams& create_params,
bool& own_web_contents) {
REQUIRE_ALLOY_RUNTIME();
DCHECK(primary_);
if (!create_params.request_context) {
@@ -101,7 +108,7 @@ void CefBrowserPlatformDelegateAlloy::WebContentsCreated(
CefBrowserPlatformDelegate::WebContentsCreated(web_contents, owned);
if (primary_) {
find_in_page::FindTabHelper::CreateForWebContents(web_contents);
AttachHelpers(web_contents);
if (owned) {
SetOwnedWebContents(web_contents);
@@ -119,7 +126,6 @@ void CefBrowserPlatformDelegateAlloy::AddNewContents(
const blink::mojom::WindowFeatures& window_features,
bool user_gesture,
bool* was_blocked) {
REQUIRE_ALLOY_RUNTIME();
DCHECK(primary_);
CefRefPtr<AlloyBrowserHostImpl> owner =
@@ -163,16 +169,10 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
}
DCHECK(!web_contents_->GetDelegate());
web_contents_->SetDelegate(static_cast<AlloyBrowserHostImpl*>(browser));
web_contents_->SetDelegate(
AlloyBrowserHostImpl::FromBaseChecked(browser).get());
permissions::PermissionRequestManager::CreateForWebContents(web_contents_);
PrefsTabHelper::CreateForWebContents(web_contents_);
printing::PrintViewManager::CreateForWebContents(web_contents_);
zoom::ZoomController::CreateForWebContents(web_contents_);
javascript_dialogs::TabModalDialogManager::CreateForWebContents(
web_contents_,
CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(web_contents_));
AttachHelpers(web_contents_);
// Used for print preview and JavaScript dialogs.
web_contents_dialog_helper_ =
@@ -191,12 +191,12 @@ void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
DCHECK(browser_);
DCHECK(!extension_host_);
auto alloy_browser = static_cast<AlloyBrowserHostImpl*>(browser_);
auto alloy_browser = AlloyBrowserHostImpl::FromBaseChecked(browser_);
if (host_type == extensions::mojom::ViewType::kExtensionPopup) {
// Create an extension host that we own.
extension_host_ = new extensions::CefExtensionViewHost(
alloy_browser, extension, web_contents_, url, host_type);
alloy_browser.get(), extension, web_contents_, url, host_type);
// Trigger load of the extension URL.
extension_host_->CreateRendererSoon();
} else if (host_type ==
@@ -205,7 +205,7 @@ void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
alloy_browser->is_background_host_ = true;
// Create an extension host that will be owned by ProcessManager.
extension_host_ = new extensions::CefExtensionBackgroundHost(
alloy_browser,
alloy_browser.get(),
base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted,
weak_ptr_factory_.GetWeakPtr()),
extension, web_contents_, url, host_type);
@@ -313,44 +313,6 @@ void CefBrowserPlatformDelegateAlloy::ConfigureAutoResize() {
}
}
void CefBrowserPlatformDelegateAlloy::SetAccessibilityState(
cef_state_t accessibility_state) {
// Do nothing if state is set to default. It'll be disabled by default and
// controlled by the commmand-line flags "force-renderer-accessibility" and
// "disable-renderer-accessibility".
if (accessibility_state == STATE_DEFAULT) {
return;
}
content::WebContentsImpl* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
if (!web_contents_impl) {
return;
}
ui::AXMode accMode;
// In windowless mode set accessibility to TreeOnly mode. Else native
// accessibility APIs, specific to each platform, are also created.
if (accessibility_state == STATE_ENABLED) {
accMode = IsWindowless() ? ui::kAXModeWebContentsOnly : ui::kAXModeComplete;
}
web_contents_impl->SetAccessibilityMode(accMode);
}
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,
@@ -440,3 +402,47 @@ void CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted() {
DCHECK(extension_host_);
extension_host_ = nullptr;
}
void CefBrowserPlatformDelegateAlloy::AttachHelpers(
content::WebContents* web_contents) {
// If already attached, nothing to be done.
base::SupportsUserData::Data* attached_tag =
web_contents->GetUserData(&kAttachedHelpersUserDataKey);
if (attached_tag) {
return;
}
// Mark as attached.
web_contents->SetUserData(&kAttachedHelpersUserDataKey,
std::make_unique<base::SupportsUserData::Data>());
// Create all the helpers.
if (cef::IsAlloyRuntimeEnabled()) {
find_in_page::FindTabHelper::CreateForWebContents(web_contents);
permissions::PermissionRequestManager::CreateForWebContents(web_contents);
PrefsTabHelper::CreateForWebContents(web_contents);
printing::InitializePrintingForWebContents(web_contents);
zoom::ZoomController::CreateForWebContents(web_contents);
javascript_dialogs::TabModalDialogManager::CreateForWebContents(
web_contents, CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(
web_contents));
} else {
if (IsWindowless()) {
// Logic from ChromeContentBrowserClientCef::GetWebContentsViewDelegate
// which is not called for windowless browsers. Needs to be done before
// calling AttachTabHelpers.
if (auto* registry =
performance_manager::PerformanceManagerRegistry::GetInstance()) {
registry->MaybeCreatePageNodeForWebContents(web_contents);
}
}
// Adopt the WebContents now, so all observers are in place, as the network
// requests for its initial navigation will start immediately
TabHelpers::AttachTabHelpers(web_contents);
// Make the tab show up in the task manager.
task_manager::WebContentsTags::CreateForTabContents(web_contents);
}
}

View File

@@ -51,11 +51,10 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) override;
bool IsNeverComposited(content::WebContents* web_contents) override;
bool IsAlloyStyle() const override { return true; }
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;
void SetAccessibilityState(cef_state_t accessibility_state) override;
bool IsPrintPreviewSupported() const override;
void Find(const CefString& searchText,
bool forward,
bool matchCase,
@@ -89,6 +88,10 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
void ConfigureAutoResize();
// Attach all the associated helpers that are needed for the WebContents. It
// is safe to call this on a WebContents that was already attached.
void AttachHelpers(content::WebContents* web_contents);
// Non-nullptr if this object owns the WebContents. Will be nullptr for popup
// browsers between the calls to WebContentsCreated() and AddNewContents(),
// and may never be set if the parent browser is destroyed during popup

View File

@@ -370,6 +370,12 @@ ChromeBrowserProcessAlloy::subresource_filter_ruleset_service() {
return nullptr;
}
subresource_filter::RulesetService*
ChromeBrowserProcessAlloy::fingerprinting_protection_ruleset_service() {
DCHECK(false);
return nullptr;
}
StartupData* ChromeBrowserProcessAlloy::startup_data() {
DCHECK(false);
return nullptr;

View File

@@ -92,6 +92,8 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
safe_browsing::SafeBrowsingService* safe_browsing_service() override;
subresource_filter::RulesetService* subresource_filter_ruleset_service()
override;
subresource_filter::RulesetService*
fingerprinting_protection_ruleset_service() override;
StartupData* startup_data() override;
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)

View File

@@ -0,0 +1,46 @@
// Copyright 2024 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/devtools/alloy_devtools_window_runner.h"
#include "libcef/browser/alloy/devtools/devtools_frontend.h"
#include "libcef/browser/thread_util.h"
void AlloyDevToolsWindowRunner::ShowDevTools(
CefBrowserHostBase* opener,
std::unique_ptr<CefShowDevToolsParams> params) {
CEF_REQUIRE_UIT();
if (devtools_frontend_) {
if (!params->inspect_element_at_.IsEmpty()) {
devtools_frontend_->InspectElementAt(params->inspect_element_at_.x,
params->inspect_element_at_.y);
}
devtools_frontend_->Focus();
return;
}
auto alloy_browser = AlloyBrowserHostImpl::FromBaseChecked(opener);
devtools_frontend_ = CefDevToolsFrontend::Show(
alloy_browser.get(), params->window_info_, params->client_,
params->settings_, params->inspect_element_at_,
base::BindOnce(&AlloyDevToolsWindowRunner::OnFrontEndDestroyed,
weak_ptr_factory_.GetWeakPtr()));
}
void AlloyDevToolsWindowRunner::CloseDevTools() {
CEF_REQUIRE_UIT();
if (devtools_frontend_) {
devtools_frontend_->Close();
}
}
bool AlloyDevToolsWindowRunner::HasDevTools() {
CEF_REQUIRE_UIT();
return !!devtools_frontend_;
}
void AlloyDevToolsWindowRunner::OnFrontEndDestroyed() {
CEF_REQUIRE_UIT();
devtools_frontend_ = nullptr;
}

View File

@@ -0,0 +1,40 @@
// Copyright 2024 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_
#pragma once
#include "libcef/browser/devtools/devtools_window_runner.h"
#include "base/memory/weak_ptr.h"
class CefDevToolsFrontend;
// Creates and runs a DevTools window instance. Only accessed on the UI thread.
class AlloyDevToolsWindowRunner : public CefDevToolsWindowRunner {
public:
AlloyDevToolsWindowRunner() = default;
AlloyDevToolsWindowRunner(const AlloyDevToolsWindowRunner&) = delete;
AlloyDevToolsWindowRunner& operator=(const AlloyDevToolsWindowRunner&) =
delete;
// CefDevToolsWindowRunner methods:
void ShowDevTools(CefBrowserHostBase* opener,
std::unique_ptr<CefShowDevToolsParams> params) override;
void CloseDevTools() override;
bool HasDevTools() override;
private:
void OnFrontEndDestroyed();
// CefDevToolsFrontend will delete itself when the frontend WebContents is
// destroyed.
CefDevToolsFrontend* devtools_frontend_ = nullptr;
base::WeakPtrFactory<AlloyDevToolsWindowRunner> weak_ptr_factory_{this};
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_

View File

@@ -2,7 +2,7 @@
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "libcef/browser/devtools/devtools_file_manager.h"
#include "libcef/browser/alloy/devtools/devtools_file_manager.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
@@ -35,7 +35,7 @@ void WriteToFile(const base::FilePath& path, const std::string& content) {
void AppendToFile(const base::FilePath& path, const std::string& content) {
DCHECK(!path.empty());
base::AppendToFile(path, base::StringPiece(content));
base::AppendToFile(path, std::string_view(content));
}
} // namespace
@@ -82,7 +82,7 @@ void CefDevToolsFileManager::Save(const std::string& url,
base::FilePath initial_path;
if (const base::Value* path_value = file_map.Find(base::MD5String(url))) {
absl::optional<base::FilePath> path = base::ValueToFilePath(*path_value);
std::optional<base::FilePath> path = base::ValueToFilePath(*path_value);
if (path) {
initial_path = std::move(*path);
}

View File

@@ -2,8 +2,8 @@
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
#include "base/functional/callback_forward.h"
#include "base/memory/weak_ptr.h"
@@ -79,4 +79,4 @@ class CefDevToolsFileManager {
base::WeakPtrFactory<CefDevToolsFileManager> weak_factory_;
};
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_

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 "libcef/browser/devtools/devtools_frontend.h"
#include "libcef/browser/alloy/devtools/devtools_frontend.h"
#include <stddef.h>
@@ -10,12 +10,13 @@
#include <memory>
#include <utility>
#include "libcef/browser/alloy/devtools/devtools_manager_delegate.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/net/devtools_scheme_handler.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/task_runner_manager.h"
#include "libcef/features/runtime_checks.h"
#include "base/base64.h"
#include "base/command_line.h"
@@ -165,7 +166,7 @@ void LogProtocolMessage(const base::FilePath& log_file,
WriteTimestamp(stream);
stream << ": " << type_label << ": " << to_log << "\n";
const std::string& str = stream.str();
if (!base::AppendToFile(log_file, base::StringPiece(str))) {
if (!base::AppendToFile(log_file, std::string_view(str))) {
LOG(ERROR) << "Failed to write file " << log_file.value();
log_error = true;
}
@@ -199,15 +200,13 @@ class CefDevToolsFrontend::NetworkResourceLoader
response_headers_ = response_head.headers;
}
void OnDataReceived(base::StringPiece chunk,
void OnDataReceived(std::string_view chunk,
base::OnceClosure resume) override {
base::Value chunkValue;
bool encoded = !base::IsStringUTF8(chunk);
if (encoded) {
std::string encoded_string;
base::Base64Encode(chunk, &encoded_string);
chunkValue = base::Value(std::move(encoded_string));
chunkValue = base::Value(base::Base64Encode(chunk));
} else {
chunkValue = base::Value(chunk);
}
@@ -245,6 +244,8 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at,
base::OnceClosure frontend_destroyed_callback) {
REQUIRE_ALLOY_RUNTIME();
CefBrowserSettings new_settings = settings;
if (!windowInfo.windowless_rendering_enabled &&
CefColorGetA(new_settings.background_color) != SK_AlphaOPAQUE) {
@@ -254,11 +255,14 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
}
CefBrowserCreateParams create_params;
create_params.MaybeSetWindowInfo(windowInfo, /*allow_alloy_style=*/true,
/*allow_chrome_style=*/false);
if (inspected_browser->is_views_hosted()) {
create_params.popup_with_views_hosted_opener = true;
} else {
create_params.window_info = std::make_unique<CefWindowInfo>(windowInfo);
}
create_params.popup_with_alloy_style_opener = true;
create_params.client = client;
create_params.settings = new_settings;
create_params.devtools_opener = inspected_browser;
@@ -273,8 +277,7 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
// CefDevToolsFrontend will delete itself when the frontend WebContents is
// destroyed.
CefDevToolsFrontend* devtools_frontend = new CefDevToolsFrontend(
static_cast<AlloyBrowserHostImpl*>(frontend_browser.get()),
inspected_contents, inspect_element_at,
frontend_browser.get(), inspected_contents, inspect_element_at,
std::move(frontend_destroyed_callback));
// Need to load the URL after creating the DevTools objects.
@@ -416,7 +419,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
// TODO(pfeldman): handle some of the embedder messages in content.
const std::string* url = params[0].GetIfString();
const std::string* headers = params[1].GetIfString();
absl::optional<const int> stream_id = params[2].GetIfInt();
std::optional<const int> stream_id = params[2].GetIfInt();
if (!url || !headers || !stream_id.has_value()) {
return;
}
@@ -542,7 +545,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
}
const std::string* url = params[0].GetIfString();
const std::string* content = params[1].GetIfString();
absl::optional<bool> save_as = params[2].GetIfBool();
std::optional<bool> save_as = params[2].GetIfBool();
if (!url || !content || !save_as.has_value()) {
return;
}
@@ -574,8 +577,8 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
return;
}
base::StringPiece str_message(reinterpret_cast<const char*>(message.data()),
message.size());
std::string_view str_message(reinterpret_cast<const char*>(message.data()),
message.size());
if (ProtocolLoggingEnabled()) {
// Quick check to avoid parsing the JSON object. Events begin with a
// "method" value whereas method results begin with an "id" value.
@@ -592,7 +595,7 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
size_t total_size = str_message.length();
for (size_t pos = 0; pos < str_message.length();
pos += kMaxMessageChunkSize) {
base::StringPiece str_message_chunk =
std::string_view str_message_chunk =
str_message.substr(pos, kMaxMessageChunkSize);
CallClientFunction(
@@ -640,7 +643,7 @@ bool CefDevToolsFrontend::ProtocolLoggingEnabled() const {
}
void CefDevToolsFrontend::LogProtocolMessage(ProtocolMessageType type,
const base::StringPiece& message) {
const std::string_view& message) {
DCHECK(ProtocolLoggingEnabled());
std::string to_log(message.substr(0, kMaxLogLineLength));

View File

@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FRONTEND_H_
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FRONTEND_H_
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_
#include <memory>
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/devtools/devtools_file_manager.h"
#include "libcef/browser/alloy/devtools/devtools_file_manager.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
@@ -87,7 +87,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
bool ProtocolLoggingEnabled() const;
void LogProtocolMessage(ProtocolMessageType type,
const base::StringPiece& message);
const std::string_view& message);
PrefService* GetPrefs() const;
@@ -111,4 +111,4 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
base::WeakPtrFactory<CefDevToolsFrontend> weak_factory_;
};
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FRONTEND_H_
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_

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 "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/alloy/devtools/devtools_manager_delegate.h"
#include <stdint.h>
@@ -70,28 +70,29 @@ class TCPServerSocketFactory : public content::DevToolsSocketFactory {
std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
// See if the user specified a port on the command line. Specifying 0 would
// result in the selection of an ephemeral port but that doesn't make sense
// for CEF where the URL is otherwise undiscoverable. Also, don't allow
// binding of ports between 0 and 1024 exclusive because they're normally
// restricted to root on Posix-based systems.
uint16_t port = 0;
// See if the user specified a port on the command line. Specifying 0 will
// result in the selection of an ephemeral port and the port number will be
// printed as part of the WebSocket endpoint URL to stderr. If a cache
// directory path is provided the port will also be written to the
// <cache-dir>/DevToolsActivePort file.
//
// It's not allowed to bind ports between 0 and 1024 exclusive because
// they're normally restricted to root on Posix-based systems.
if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
int temp_port;
int port = 0;
std::string port_str =
command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);
if (base::StringToInt(port_str, &temp_port) && temp_port >= 1024 &&
temp_port < 65535) {
port = static_cast<uint16_t>(temp_port);
if (base::StringToInt(port_str, &port) &&
(0 == port || (port >= 1024 && port < 65535))) {
return std::unique_ptr<content::DevToolsSocketFactory>(
new TCPServerSocketFactory("127.0.0.1", port));
} else {
DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
DLOG(WARNING) << "Invalid http debugger port number '" << port_str << "'";
}
}
if (port == 0) {
return nullptr;
}
return std::unique_ptr<content::DevToolsSocketFactory>(
new TCPServerSocketFactory("127.0.0.1", port));
return nullptr;
}
} // namespace

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
#include "content/public/browser/devtools_manager_delegate.h"
@@ -32,4 +32,4 @@ class CefDevToolsManagerDelegate : public content::DevToolsManagerDelegate {
bool HasBundledFrontendResources() override;
};
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_

View File

@@ -15,7 +15,10 @@ namespace {
class AlloyConstrainedWindowViewsClient
: public constrained_window::ConstrainedWindowViewsClient {
public:
AlloyConstrainedWindowViewsClient() = default;
explicit AlloyConstrainedWindowViewsClient(
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
chrome_client)
: chrome_client_(std::move(chrome_client)) {}
AlloyConstrainedWindowViewsClient(const AlloyConstrainedWindowViewsClient&) =
delete;
@@ -26,6 +29,12 @@ class AlloyConstrainedWindowViewsClient
// ConstrainedWindowViewsClient methods:
web_modal::ModalDialogHost* GetModalDialogHost(
gfx::NativeWindow parent) override {
if (chrome_client_) {
if (auto dialog_host = chrome_client_->GetModalDialogHost(parent)) {
return dialog_host;
}
}
if (auto browser = GetPreferredBrowser(parent)) {
return browser->platform_delegate()->GetWebContentsModalDialogHost();
}
@@ -34,6 +43,12 @@ class AlloyConstrainedWindowViewsClient
}
gfx::NativeView GetDialogHostView(gfx::NativeWindow parent) override {
if (chrome_client_) {
if (auto host_view = chrome_client_->GetDialogHostView(parent)) {
return host_view;
}
}
if (auto dialog_host = GetModalDialogHost(parent)) {
return dialog_host->GetHostView();
}
@@ -66,11 +81,17 @@ class AlloyConstrainedWindowViewsClient
return browser;
}
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
chrome_client_;
};
} // namespace
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
CreateAlloyConstrainedWindowViewsClient() {
return std::make_unique<AlloyConstrainedWindowViewsClient>();
CreateAlloyConstrainedWindowViewsClient(
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
chrome_client) {
return std::make_unique<AlloyConstrainedWindowViewsClient>(
std::move(chrome_client));
}

View File

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

View File

@@ -44,14 +44,20 @@ AlloyWebContentsDialogHelper::GetWebContentsModalDialogHost() {
gfx::NativeView AlloyWebContentsDialogHelper::GetHostView() const {
// Windowless rendering uses GetAcceleratedWidget() instead.
if (browser_delegate_->IsWindowless()) {
return gfx::NativeView();
if (!browser_delegate_->IsWindowless()) {
#if BUILDFLAG(IS_MAC)
// This is supported with all configurations except MacOS with external
// parent because we can't provide a gfx::NativeView or a
// gfx::AcceleratedWidget on that platform (it's an arbitrary internal
// Chromium type). This code should not be reached in that case because
// print preview is disabled.
DCHECK(!browser_delegate_->HasExternalParent());
#endif
if (auto widget = browser_delegate_->GetWindowWidget()) {
return widget->GetNativeView();
}
}
if (auto widget = browser_delegate_->GetWindowWidget()) {
return widget->GetNativeView();
}
DCHECK(false);
NOTIMPLEMENTED();
return gfx::NativeView();
}
@@ -59,15 +65,13 @@ gfx::AcceleratedWidget AlloyWebContentsDialogHelper::GetAcceleratedWidget()
const {
#if defined(USE_AURA)
// Windowed rendering uses GetHostView() instead.
if (!browser_delegate_->IsWindowless()) {
return gfx::kNullAcceleratedWidget;
}
if (auto parent_widget = browser_delegate_->GetHostWindowHandle()) {
return parent_widget;
if (browser_delegate_->IsWindowless()) {
if (auto parent_widget = browser_delegate_->GetHostWindowHandle()) {
return parent_widget;
}
}
#endif // defined(USE_AURA)
DCHECK(false);
NOTIMPLEMENTED();
return gfx::kNullAcceleratedWidget;
}

View File

@@ -98,6 +98,7 @@ void CefAudioCapturer::OnCaptureStarted() {
void CefAudioCapturer::Capture(const media::AudioBus* source,
base::TimeTicks audio_capture_time,
const media::AudioGlitchInfo& /*glitch_info*/,
double /*volume*/,
bool /*key_pressed*/) {
const int channels = source->channels();
@@ -116,7 +117,10 @@ void CefAudioCapturer::OnCaptureError(
media::AudioCapturerSource::ErrorCode code,
const std::string& message) {
audio_handler_->OnAudioStreamError(browser_, message);
StopStream();
if (code != media::AudioCapturerSource::ErrorCode::kSocketError) {
StopStream();
}
}
void CefAudioCapturer::StopStream() {
@@ -129,4 +133,4 @@ void CefAudioCapturer::StopStream() {
audio_input_device_ = nullptr;
capturing_ = false;
}
}

View File

@@ -31,6 +31,7 @@ class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback {
void OnCaptureStarted() override;
void Capture(const media::AudioBus* audio_source,
base::TimeTicks audio_capture_time,
const media::AudioGlitchInfo& glitch_info,
double volume,
bool key_pressed) override;
void OnCaptureError(media::AudioCapturerSource::ErrorCode code,
@@ -48,4 +49,4 @@ class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback {
int channels_ = 0;
};
#endif // CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_
#endif // CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_

View File

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

View File

@@ -10,6 +10,8 @@
#include "libcef/browser/native/cursor_util.h"
#include "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"
#include "content/public/browser/focused_node_details.h"
#include "content/public/browser/keyboard_event_processing_result.h"
@@ -23,8 +25,13 @@
#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)
#include "sandbox/win/src/sandbox_types.h"
#endif
using content::KeyboardEventProcessingResult;
namespace {
@@ -87,8 +94,7 @@ void CefBrowserContentsDelegate::ObserveWebContents(
// Make sure MaybeCreateFrame is called at least one time.
// Create the frame representation before OnAfterCreated is called for a new
// browser.
browser_info_->MaybeCreateFrame(new_contents->GetPrimaryMainFrame(),
false /* is_guest_view */);
browser_info_->MaybeCreateFrame(new_contents->GetPrimaryMainFrame());
// Make sure RenderWidgetCreated is called at least one time. This Observer
// is registered too late to catch the initial creation.
@@ -106,9 +112,11 @@ void CefBrowserContentsDelegate::RemoveObserver(Observer* observer) {
// |source| may be NULL for navigations in the current tab, or if the
// navigation originates from a guest view via MaybeAllowNavigation.
content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
content::WebContents* CefBrowserContentsDelegate::OpenURLFromTabEx(
content::WebContents* source,
const content::OpenURLParams& params) {
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>&
navigation_handle_callback) {
bool cancel = false;
if (auto c = client()) {
@@ -127,8 +135,13 @@ content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
}
}
if (!cancel) {
// TODO: Do something with |navigation_handle_callback|.
return web_contents();
}
// Returning nullptr will cancel the navigation.
return cancel ? nullptr : web_contents();
return nullptr;
}
void CefBrowserContentsDelegate::LoadingStateChanged(
@@ -222,11 +235,9 @@ void CefBrowserContentsDelegate::CanDownload(
base::OnceCallback<void(bool)> callback) {
bool allow = true;
if (auto delegate = platform_delegate()) {
if (auto c = client()) {
if (auto handler = c->GetDownloadHandler()) {
allow = handler->CanDownload(browser(), url.spec(), request_method);
}
if (auto c = client()) {
if (auto handler = c->GetDownloadHandler()) {
allow = handler->CanDownload(browser(), url.spec(), request_method);
}
}
@@ -288,9 +299,26 @@ bool CefBrowserContentsDelegate::HandleKeyboardEvent(
return false;
}
void CefBrowserContentsDelegate::DraggableRegionsChanged(
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
content::WebContents* contents) {
// Already converted to window bounds in WebViewImpl::DraggableRegionsChanged.
std::vector<cef::mojom::DraggableRegionEntryPtr> cef_regions;
if (!regions.empty()) {
cef_regions.reserve(regions.size());
for (const auto& region : regions) {
auto cef_region = cef::mojom::DraggableRegionEntry::New(
region->bounds, region->draggable);
cef_regions.emplace_back(std::move(cef_region));
}
}
browser_info_->GetMainFrame()->UpdateDraggableRegions(std::move(cef_regions));
}
void CefBrowserContentsDelegate::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) {
browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */);
browser_info_->MaybeCreateFrame(render_frame_host);
if (render_frame_host->GetParent() == nullptr) {
auto render_view_host = render_frame_host->GetRenderViewHost();
auto base_background_color = platform_delegate()->GetBackgroundColor();
@@ -351,6 +379,22 @@ void CefBrowserContentsDelegate::RenderViewReady() {
void CefBrowserContentsDelegate::PrimaryMainFrameRenderProcessGone(
base::TerminationStatus status) {
static_assert(static_cast<int>(CEF_RESULT_CODE_CHROME_FIRST) ==
static_cast<int>(chrome::RESULT_CODE_CHROME_START),
"enum mismatch");
static_assert(static_cast<int>(CEF_RESULT_CODE_CHROME_LAST) ==
static_cast<int>(chrome::RESULT_CODE_CHROME_LAST_CODE),
"enum mismatch");
#if defined(OS_WIN)
static_assert(static_cast<int>(CEF_RESULT_CODE_SANDBOX_FATAL_FIRST) ==
static_cast<int>(sandbox::SBOX_FATAL_INTEGRITY),
"enum mismatch");
static_assert(static_cast<int>(CEF_RESULT_CODE_SANDBOX_FATAL_LAST) ==
static_cast<int>(sandbox::SBOX_FATAL_LAST),
"enum mismatch");
#endif
cef_termination_status_t ts = TS_ABNORMAL_TERMINATION;
if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
ts = TS_PROCESS_WAS_KILLED;
@@ -358,14 +402,22 @@ void CefBrowserContentsDelegate::PrimaryMainFrameRenderProcessGone(
ts = TS_PROCESS_CRASHED;
} else if (status == base::TERMINATION_STATUS_OOM) {
ts = TS_PROCESS_OOM;
} else if (status == base::TERMINATION_STATUS_LAUNCH_FAILED) {
ts = TS_LAUNCH_FAILED;
#if BUILDFLAG(IS_WIN)
} else if (status == base::TERMINATION_STATUS_INTEGRITY_FAILURE) {
ts = TS_INTEGRITY_FAILURE;
#endif
} else if (status != base::TERMINATION_STATUS_ABNORMAL_TERMINATION) {
return;
}
if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) {
int error_code = web_contents()->GetCrashedErrorCode();
auto navigation_lock = browser_info_->CreateNavigationLock();
handler->OnRenderProcessTerminated(browser(), ts);
handler->OnRenderProcessTerminated(browser(), ts, error_code,
SadTabView::ErrorToString(error_code));
}
}
}
@@ -516,6 +568,10 @@ void CefBrowserContentsDelegate::DidFinishLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url) {
auto frame = browser_info_->GetFrameForHost(render_frame_host);
if (!frame) {
return;
}
frame->RefreshAttributes();
int http_status_code = 0;

View File

@@ -80,10 +80,15 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
// WebContentsDelegate methods:
content::WebContents* OpenURLFromTab(
// Same as OpenURLFromTab but only taking |navigation_handle_callback|
// if the return value is non-nullptr.
content::WebContents* OpenURLFromTabEx(
content::WebContents* source,
const content::OpenURLParams& params) override;
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>&
navigation_handle_callback);
// WebContentsDelegate methods:
void LoadingStateChanged(content::WebContents* source,
bool should_show_loading_ui) override;
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
@@ -105,6 +110,9 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
bool HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
void DraggableRegionsChanged(
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
content::WebContents* contents) override;
// WebContentsObserver methods:
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;

View File

@@ -14,7 +14,6 @@
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/frame_util.h"
#include "libcef/features/runtime.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
@@ -158,7 +157,7 @@ CefBrowserContext::CookieableSchemes MakeSupportedSchemes(
bool include_defaults) {
if (schemes_list.empty() && include_defaults) {
// No explicit registration of schemes.
return absl::nullopt;
return std::nullopt;
}
std::vector<std::string> all_schemes;
@@ -177,7 +176,7 @@ CefBrowserContext::CookieableSchemes MakeSupportedSchemes(
all_schemes.push_back("wss");
}
return absl::make_optional(all_schemes);
return std::make_optional(all_schemes);
}
template <typename T>
@@ -273,22 +272,7 @@ CefBrowserContext* CefBrowserContext::FromBrowserContext(
// static
CefBrowserContext* CefBrowserContext::FromProfile(const Profile* profile) {
auto* cef_context = FromBrowserContext(profile);
if (cef_context) {
return cef_context;
}
if (cef::IsChromeRuntimeEnabled()) {
auto* original_profile = profile->GetOriginalProfile();
if (original_profile != profile) {
// With the Chrome runtime if the user launches an incognito window via
// the UI we might be associated with the original Profile instead of the
// (current) incognito profile.
return FromBrowserContext(original_profile);
}
}
return nullptr;
return FromBrowserContext(profile);
}
// static
@@ -299,8 +283,7 @@ std::vector<CefBrowserContext*> CefBrowserContext::GetAll() {
void CefBrowserContext::OnRenderFrameCreated(
CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame,
bool is_guest_view) {
bool is_main_frame) {
CEF_REQUIRE_UIT();
DCHECK(frame_util::IsValidGlobalId(global_id));
@@ -318,8 +301,7 @@ void CefBrowserContext::OnRenderFrameCreated(
void CefBrowserContext::OnRenderFrameDeleted(
CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame,
bool is_guest_view) {
bool is_main_frame) {
CEF_REQUIRE_UIT();
DCHECK(frame_util::IsValidGlobalId(global_id));
@@ -411,10 +393,6 @@ bool CefBrowserContext::UnloadExtension(const CefString& extension_id) {
return false;
}
bool CefBrowserContext::IsPrintPreviewSupported() const {
return true;
}
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
CEF_REQUIRE_UIT();
auto browser_context = AsBrowserContext();
@@ -430,6 +408,24 @@ CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
return media_router_manager_.get();
}
CefRefPtr<CefRequestContextImpl> CefBrowserContext::GetAnyRequestContext(
bool prefer_no_handler) const {
CEF_REQUIRE_UIT();
if (request_context_set_.empty()) {
return nullptr;
}
if (prefer_no_handler) {
for (const auto& request_context : request_context_set_) {
if (!request_context->GetHandler()) {
return request_context;
}
}
}
return *request_context_set_.begin();
}
CefBrowserContext::CookieableSchemes CefBrowserContext::GetCookieableSchemes()
const {
CEF_REQUIRE_UIT();

View File

@@ -6,6 +6,7 @@
#define CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_IMPL_H_
#pragma once
#include <optional>
#include <set>
#include <vector>
@@ -19,7 +20,7 @@
#include "base/task/sequenced_task_runner_helpers.h"
#include "chrome/common/plugin.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/page_transition_types.h"
#include "url/origin.h"
/*
@@ -104,7 +105,7 @@ class CefBrowserContext {
const content::GlobalRenderFrameHostId& global_id,
bool require_frame_match);
// Returns the underlying CefBrowserContext if any.
// Returns the underlying CefBrowserContext, if any.
static CefBrowserContext* FromBrowserContext(
const content::BrowserContext* context);
static CefBrowserContext* FromProfile(const Profile* profile);
@@ -131,14 +132,12 @@ class CefBrowserContext {
// Called from CefRequestContextImpl::OnRenderFrameCreated.
void OnRenderFrameCreated(CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame,
bool is_guest_view);
bool is_main_frame);
// Called from CefRequestContextImpl::OnRenderFrameDeleted.
void OnRenderFrameDeleted(CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame,
bool is_guest_view);
bool is_main_frame);
// Returns the handler that matches the specified IDs. Pass -1 for unknown
// values. If |require_frame_match| is true only exact matches will be
@@ -172,14 +171,25 @@ class CefBrowserContext {
// Called from CefExtensionImpl::Unload().
virtual bool UnloadExtension(const CefString& extension_id);
// Returns true if this context supports print preview.
virtual bool IsPrintPreviewSupported() const;
// Called from AlloyBrowserHostImpl::DidFinishNavigation to update the table
// of visited links.
virtual void AddVisitedURLs(const GURL& url,
const std::vector<GURL>& redirect_chain,
ui::PageTransition transition) = 0;
network::mojom::NetworkContext* GetNetworkContext();
CefMediaRouterManager* GetMediaRouterManager();
using CookieableSchemes = absl::optional<std::vector<std::string>>;
// Returns any CefRequestContext associated with this object, or nullptr if
// none exist. If |prefer_no_handler| is true this method will try to return a
// context without an associated CefRequestContextHandler. Use
// CefRequestContextImpl::GetOrCreateForBrowserContext() instead of calling
// this method directly.
CefRefPtr<CefRequestContextImpl> GetAnyRequestContext(
bool prefer_no_handler) const;
using CookieableSchemes = std::optional<std::vector<std::string>>;
// Returns the schemes associated with this context specifically, or the
// global configuration if unset.

View File

@@ -7,6 +7,7 @@
#include "base/feature_list.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"
#include "chrome/browser/media/webrtc/media_device_salt_service_factory.h"
#include "chrome/browser/plugins/plugin_prefs_factory.h"
@@ -25,6 +26,7 @@ namespace cef {
void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
CookieSettingsFactory::GetInstance();
first_party_sets::FirstPartySetsPolicyServiceFactory::GetInstance();
MediaDeviceSaltServiceFactory::GetInstance();
media_router::ChromeMediaRouterFactory::GetInstance();
PluginPrefsFactory::GetInstance();

View File

@@ -5,7 +5,9 @@
#include "libcef/browser/browser_frame.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/frame_util.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
@@ -57,26 +59,31 @@ void CefBrowserFrame::FrameAttached(
bool reattached) {
// Always send to the newly created RFH, which may be speculative when
// navigating cross-origin.
if (auto host = GetFrameHost(/*prefer_speculative=*/true)) {
bool is_excluded;
if (auto host = GetFrameHost(/*prefer_speculative=*/true, &is_excluded)) {
host->FrameAttached(std::move(render_frame), reattached);
} else if (is_excluded) {
VLOG(1) << "frame "
<< frame_util::GetFrameDebugString(
render_frame_host()->GetGlobalFrameToken())
<< " attach denied";
mojo::Remote<cef::mojom::RenderFrame> render_frame_remote;
render_frame_remote.Bind(std::move(render_frame));
render_frame_remote->FrameAttachedAck(/*allow=*/false);
}
}
void CefBrowserFrame::UpdateDraggableRegions(
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) {
if (auto host = GetFrameHost()) {
std::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) {
if (auto host = GetFrameHost(/*prefer_speculative=*/false)) {
host->UpdateDraggableRegions(std::move(regions));
}
}
CefRefPtr<CefFrameHostImpl> CefBrowserFrame::GetFrameHost(
bool prefer_speculative) const {
CEF_REQUIRE_UIT();
auto rfh = render_frame_host();
if (auto browser = CefBrowserHostBase::GetBrowserForHost(rfh)) {
return browser->browser_info()->GetFrameForHost(rfh, nullptr,
prefer_speculative);
}
DCHECK(false);
return nullptr;
bool prefer_speculative,
bool* is_excluded) const {
return CefBrowserInfoManager::GetFrameHost(
render_frame_host(), prefer_speculative,
/*browser_info=*/nullptr, is_excluded);
}

View File

@@ -42,14 +42,14 @@ class CefBrowserFrame
void FrameAttached(mojo::PendingRemote<cef::mojom::RenderFrame> render_frame,
bool reattached) override;
void UpdateDraggableRegions(
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions)
std::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions)
override;
// FrameServiceBase methods:
bool ShouldCloseOnFinishNavigation() const override { return false; }
CefRefPtr<CefFrameHostImpl> GetFrameHost(
bool prefer_speculative = false) const;
CefRefPtr<CefFrameHostImpl> GetFrameHost(bool prefer_speculative,
bool* is_excluded = nullptr) const;
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_

View File

@@ -9,6 +9,8 @@
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/hang_monitor.h"
#include "libcef/browser/image_impl.h"
#include "libcef/browser/navigation_entry_impl.h"
#include "libcef/browser/printing/print_util.h"
@@ -31,6 +33,8 @@
#include "content/public/browser/download_request_utils.h"
#include "content/public/browser/file_select_listener.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "ui/base/resource/resource_scale_factor.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/shell_dialogs/select_file_policy.h"
@@ -80,6 +84,12 @@ class WebContentsUserDataAdapter : public base::SupportsUserData::Data {
} // namespace
// static
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::FromBrowser(
CefRefPtr<CefBrowser> browser) {
return static_cast<CefBrowserHostBase*>(browser.get());
}
// static
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForHost(
const content::RenderViewHost* host) {
@@ -112,7 +122,18 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForContents(
const content::WebContents* contents) {
DCHECK(contents);
CEF_REQUIRE_UIT();
return WebContentsUserDataAdapter::Get(contents);
if (auto browser = WebContentsUserDataAdapter::Get(contents)) {
return browser;
}
// Try the owner WebContents if |contents| originates from an excluded view
// such as the PDF viewer or Print Preview. This is safe to call even if Alloy
// extensions are disabled.
if (auto* owner_contents = extensions::GetOwnerForGuestContents(contents)) {
return WebContentsUserDataAdapter::Get(owner_contents);
}
return nullptr;
}
// static
@@ -132,10 +153,8 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalId(
return GetBrowserForHost(render_frame_host);
} else {
// Use the thread-safe approach.
bool is_guest_view = false;
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(
global_id, &is_guest_view);
if (info && !is_guest_view) {
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(global_id);
if (info) {
auto browser = info->browser();
if (!browser) {
LOG(WARNING) << "Found browser id " << info->browser_id()
@@ -165,10 +184,9 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalToken(
return GetBrowserForHost(render_frame_host);
} else {
// Use the thread-safe approach.
bool is_guest_view = false;
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(
global_token, &is_guest_view);
if (info && !is_guest_view) {
auto info =
CefBrowserInfoManager::GetInstance()->GetBrowserInfo(global_token);
if (info) {
auto browser = info->browser();
if (!browser) {
LOG(WARNING) << "Found browser id " << info->browser_id()
@@ -248,7 +266,8 @@ void CefBrowserHostBase::InitializeBrowser() {
void CefBrowserHostBase::DestroyBrowser() {
CEF_REQUIRE_UIT();
devtools_manager_.reset();
devtools_protocol_manager_.reset();
devtools_window_runner_.reset();
media_stream_registrar_.reset();
platform_delegate_.reset();
@@ -256,6 +275,11 @@ void CefBrowserHostBase::DestroyBrowser() {
contents_delegate_->RemoveObserver(this);
contents_delegate_->ObserveWebContents(nullptr);
if (unresponsive_process_callback_) {
hang_monitor::Detach(unresponsive_process_callback_);
unresponsive_process_callback_.reset();
}
CefBrowserInfoManager::GetInstance()->RemoveBrowserInfo(browser_info_);
browser_info_->SetBrowser(nullptr);
}
@@ -554,6 +578,30 @@ void CefBrowserHostBase::ShowDevTools(const CefWindowInfo& windowInfo,
}
}
void CefBrowserHostBase::CloseDevTools() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefBrowserHostBase::CloseDevTools, this));
return;
}
if (devtools_window_runner_) {
devtools_window_runner_->CloseDevTools();
}
}
bool CefBrowserHostBase::HasDevTools() {
if (!CEF_CURRENTLY_ON_UIT()) {
DCHECK(false) << "called on invalid thread";
return false;
}
if (devtools_window_runner_) {
return devtools_window_runner_->HasDevTools();
}
return false;
}
bool CefBrowserHostBase::SendDevToolsMessage(const void* message,
size_t message_size) {
if (!message || message_size == 0) {
@@ -572,10 +620,10 @@ bool CefBrowserHostBase::SendDevToolsMessage(const void* message,
return false;
}
if (!EnsureDevToolsManager()) {
if (!EnsureDevToolsProtocolManager()) {
return false;
}
return devtools_manager_->SendDevToolsMessage(message, message_size);
return devtools_protocol_manager_->SendDevToolsMessage(message, message_size);
}
int CefBrowserHostBase::ExecuteDevToolsMethod(
@@ -590,10 +638,11 @@ int CefBrowserHostBase::ExecuteDevToolsMethod(
return 0;
}
if (!EnsureDevToolsManager()) {
if (!EnsureDevToolsProtocolManager()) {
return 0;
}
return devtools_manager_->ExecuteDevToolsMethod(message_id, method, params);
return devtools_protocol_manager_->ExecuteDevToolsMethod(message_id, method,
params);
}
CefRefPtr<CefRegistration> CefBrowserHostBase::AddDevToolsMessageObserver(
@@ -601,7 +650,7 @@ CefRefPtr<CefRegistration> CefBrowserHostBase::AddDevToolsMessageObserver(
if (!observer) {
return nullptr;
}
auto registration = CefDevToolsManager::CreateRegistration(observer);
auto registration = CefDevToolsProtocolManager::CreateRegistration(observer);
InitializeDevToolsRegistrationOnUIThread(registration);
return registration.get();
}
@@ -707,6 +756,26 @@ void CefBrowserHostBase::ExitFullscreen(bool will_cause_resize) {
}
}
bool CefBrowserHostBase::IsRenderProcessUnresponsive() {
if (!CEF_CURRENTLY_ON_UIT()) {
DCHECK(false) << "called on invalid thread";
return false;
}
if (auto* web_contents = GetWebContents()) {
if (auto* rvh = web_contents->GetRenderViewHost()) {
if (auto* rwh = rvh->GetWidget()) {
return rwh->IsCurrentlyUnresponsive();
}
}
}
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(
@@ -924,8 +993,8 @@ int CefBrowserHostBase::GetIdentifier() {
}
bool CefBrowserHostBase::IsSame(CefRefPtr<CefBrowser> that) {
auto impl = static_cast<CefBrowserHostBase*>(that.get());
return (impl == this);
auto impl = FromBrowser(that);
return (impl.get() == this);
}
bool CefBrowserHostBase::HasDocument() {
@@ -1009,6 +1078,20 @@ void CefBrowserHostBase::GetFrameNames(std::vector<CefString>& names) {
}
}
void CefBrowserHostBase::SetAccessibilityState(
cef_state_t accessibility_state) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefBrowserHostBase::SetAccessibilityState,
this, accessibility_state));
return;
}
if (platform_delegate_) {
platform_delegate_->SetAccessibilityState(accessibility_state);
}
}
void CefBrowserHostBase::OnStateChanged(CefBrowserContentsState state_changed) {
// Make sure that CefBrowser state is consistent before the associated
// CefClient callback is executed.
@@ -1048,12 +1131,12 @@ CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForHost(
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalId(
const content::GlobalRenderFrameHostId& global_id) {
return browser_info_->GetFrameForGlobalId(global_id, nullptr);
return browser_info_->GetFrameForGlobalId(global_id);
}
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token) {
return browser_info_->GetFrameForGlobalToken(global_token, nullptr);
return browser_info_->GetFrameForGlobalToken(global_token);
}
void CefBrowserHostBase::AddObserver(Observer* observer) {
@@ -1105,6 +1188,12 @@ bool CefBrowserHostBase::Navigate(const content::OpenURLParams& params) {
return false;
}
void CefBrowserHostBase::ShowDevToolsOnUIThread(
std::unique_ptr<CefShowDevToolsParams> params) {
CEF_REQUIRE_UIT();
GetDevToolsWindowRunner()->ShowDevTools(this, std::move(params));
}
void CefBrowserHostBase::ViewText(const std::string& text) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
@@ -1158,7 +1247,6 @@ void CefBrowserHostBase::SelectFileListenerDestroyed(
bool CefBrowserHostBase::MaybeAllowNavigation(
content::RenderFrameHost* opener,
bool is_guest_view,
const content::OpenURLParams& params) {
return true;
}
@@ -1206,10 +1294,6 @@ SkColor CefBrowserHostBase::GetBackgroundColor() const {
&settings_, IsWindowless() ? STATE_ENABLED : STATE_DISABLED);
}
bool CefBrowserHostBase::IsWindowless() const {
return false;
}
content::WebContents* CefBrowserHostBase::GetWebContents() const {
CEF_REQUIRE_UIT();
return contents_delegate_->web_contents();
@@ -1232,6 +1316,13 @@ CefMediaStreamRegistrar* CefBrowserHostBase::GetMediaStreamRegistrar() {
return media_stream_registrar_.get();
}
CefDevToolsWindowRunner* CefBrowserHostBase::GetDevToolsWindowRunner() {
if (!devtools_window_runner_) {
devtools_window_runner_ = CefDevToolsWindowRunner::Create();
}
return devtools_window_runner_.get();
}
views::Widget* CefBrowserHostBase::GetWindowWidget() const {
CEF_REQUIRE_UIT();
if (!platform_delegate_) {
@@ -1283,14 +1374,15 @@ bool CefBrowserHostBase::IsVisible() const {
return false;
}
bool CefBrowserHostBase::EnsureDevToolsManager() {
bool CefBrowserHostBase::EnsureDevToolsProtocolManager() {
CEF_REQUIRE_UIT();
if (!contents_delegate_->web_contents()) {
return false;
}
if (!devtools_manager_) {
devtools_manager_ = std::make_unique<CefDevToolsManager>(this);
if (!devtools_protocol_manager_) {
devtools_protocol_manager_ =
std::make_unique<CefDevToolsProtocolManager>(this);
}
return true;
}
@@ -1306,10 +1398,10 @@ void CefBrowserHostBase::InitializeDevToolsRegistrationOnUIThread(
return;
}
if (!EnsureDevToolsManager()) {
if (!EnsureDevToolsProtocolManager()) {
return;
}
devtools_manager_->InitializeRegistrationOnUIThread(registration);
devtools_protocol_manager_->InitializeRegistrationOnUIThread(registration);
}
bool CefBrowserHostBase::EnsureFileDialogManager() {

View File

@@ -8,11 +8,13 @@
#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/devtools/devtools_protocol_manager.h"
#include "libcef/browser/devtools/devtools_window_runner.h"
#include "libcef/browser/file_dialog_manager.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/media_stream_registrar.h"
@@ -26,15 +28,19 @@ namespace extensions {
class Extension;
}
class RenderViewContextMenuObserver;
// Parameters that are passed to the runtime-specific Create methods.
struct CefBrowserCreateParams {
CefBrowserCreateParams() = default;
// Copy constructor used with the chrome runtime only.
// Copy constructor used with Chrome style only.
CefBrowserCreateParams(const CefBrowserCreateParams& that) {
operator=(that);
}
CefBrowserCreateParams& operator=(const CefBrowserCreateParams& that) {
DCHECK(that.IsChromeStyle());
// Not all parameters can be copied.
client = that.client;
url = that.url;
@@ -42,14 +48,29 @@ struct CefBrowserCreateParams {
request_context = that.request_context;
extra_info = that.extra_info;
if (that.window_info) {
MaybeSetWindowInfo(*that.window_info);
MaybeSetWindowInfo(*that.window_info, /*allow_alloy_style=*/false,
/*allow_chrome_style=*/true);
}
browser_view = that.browser_view;
return *this;
}
// Initialize |window_info| with expected defaults before passing to a client
// callback. |opener| will be non-nullptr for popups, DevTools windows, etc.
static void InitWindowInfo(CefWindowInfo* window_info,
CefBrowserHostBase* opener);
// Set |window_info| if appropriate (see below).
void MaybeSetWindowInfo(const CefWindowInfo& window_info);
void MaybeSetWindowInfo(const CefWindowInfo& window_info,
bool allow_alloy_style,
bool allow_chrome_style);
// Returns true if |window_info| indicates creation of a Chrome style window.
static bool IsChromeStyle(const CefWindowInfo* window_info);
bool IsChromeStyle() const;
// Returns true if parameters indicate windowless (off-screen) rendering.
bool IsWindowless() const;
// Platform-specific window creation info. Will be nullptr for Views-hosted
// browsers except when using the Chrome runtime with a native parent handle.
@@ -64,6 +85,10 @@ struct CefBrowserCreateParams {
// PopupWebContentsCreated).
bool popup_with_views_hosted_opener = false;
// True if this browser is a popup and has an Alloy style opener. Only used
// with the Chrome runtime.
bool popup_with_alloy_style_opener = false;
// Client implementation. May be nullptr.
CefRefPtr<CefClient> client;
@@ -94,23 +119,6 @@ struct CefBrowserCreateParams {
extensions::mojom::ViewType::kInvalid;
};
// Parameters passed to ShowDevToolsOnUIThread().
struct CefShowDevToolsParams {
CefShowDevToolsParams(const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at)
: window_info_(windowInfo),
client_(client),
settings_(settings),
inspect_element_at_(inspect_element_at) {}
CefWindowInfo window_info_;
CefRefPtr<CefClient> client_;
CefBrowserSettings settings_;
CefPoint inspect_element_at_;
};
// Base class for CefBrowserHost implementations. Includes functionality that is
// shared by the alloy and chrome runtimes. All methods are thread-safe unless
// otherwise indicated.
@@ -135,6 +143,11 @@ class CefBrowserHostBase : public CefBrowserHost,
static CefRefPtr<CefBrowserHostBase> Create(
CefBrowserCreateParams& create_params);
// Safe conversion from CefBrowserHostBase to CefBrowserHostBase.
// Use this method instead of static_cast.
static CefRefPtr<CefBrowserHostBase> FromBrowser(
CefRefPtr<CefBrowser> browser);
// Returns the browser associated with the specified RenderViewHost.
static CefRefPtr<CefBrowserHostBase> GetBrowserForHost(
const content::RenderViewHost* host);
@@ -215,6 +228,8 @@ class CefBrowserHostBase : public CefBrowserHost,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at) override;
void CloseDevTools() override;
bool HasDevTools() override;
void ReplaceMisspelling(const CefString& word) override;
void AddWordToDictionary(const CefString& word) override;
void SendKeyEvent(const CefKeyEvent& event) override;
@@ -238,6 +253,8 @@ class CefBrowserHostBase : public CefBrowserHost,
void NotifyMoveOrResizeStarted() 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;
@@ -262,12 +279,14 @@ class CefBrowserHostBase : public CefBrowserHost,
size_t GetFrameCount() override;
void GetFrameIdentifiers(std::vector<CefString>& identifiers) override;
void GetFrameNames(std::vector<CefString>& names) override;
void SetAccessibilityState(cef_state_t accessibility_state) override;
// CefBrowserContentsDelegate::Observer methods:
void OnStateChanged(CefBrowserContentsState state_changed) override;
void OnWebContentsDestroyed(content::WebContents* web_contents) override;
// Returns the frame associated with the specified RenderFrameHost.
// Returns the frame object matching the specified |host| or nullptr if no
// match is found. Must be called on the UI thread.
CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host);
// Returns the frame associated with the specified global ID/token. See
@@ -307,7 +326,6 @@ class CefBrowserHostBase : public CefBrowserHost,
// Called from CefBrowserInfoManager::MaybeAllowNavigation.
virtual bool MaybeAllowNavigation(content::RenderFrameHost* opener,
bool is_guest_view,
const content::OpenURLParams& params);
// Helpers for executing client callbacks. Must be called on the UI thread.
@@ -327,7 +345,11 @@ class CefBrowserHostBase : public CefBrowserHost,
SkColor GetBackgroundColor() const;
// Returns true if windowless rendering is enabled.
virtual bool IsWindowless() const;
virtual bool IsWindowless() const = 0;
// Returns the runtime style of this browser.
virtual bool IsAlloyStyle() const = 0;
bool IsChromeStyle() const { return !IsAlloyStyle(); }
// Accessors that must be called on the UI thread.
content::WebContents* GetWebContents() const;
@@ -339,6 +361,23 @@ class CefBrowserHostBase : public CefBrowserHost,
return contents_delegate_.get();
}
CefMediaStreamRegistrar* GetMediaStreamRegistrar();
CefDevToolsWindowRunner* GetDevToolsWindowRunner();
CefRefPtr<CefUnresponsiveProcessCallback> unresponsive_process_callback()
const {
return unresponsive_process_callback_;
}
void set_unresponsive_process_callback(
CefRefPtr<CefUnresponsiveProcessCallback> callback) {
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.
@@ -366,7 +405,7 @@ class CefBrowserHostBase : public CefBrowserHost,
virtual bool IsVisible() const;
protected:
bool EnsureDevToolsManager();
bool EnsureDevToolsProtocolManager();
void InitializeDevToolsRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration);
@@ -374,8 +413,7 @@ class CefBrowserHostBase : public CefBrowserHost,
virtual bool Navigate(const content::OpenURLParams& params);
// Called from ShowDevTools to perform the actual show.
virtual void ShowDevToolsOnUIThread(
std::unique_ptr<CefShowDevToolsParams> params) = 0;
void ShowDevToolsOnUIThread(std::unique_ptr<CefShowDevToolsParams> params);
// Create the CefFileDialogManager if it doesn't already exist.
bool EnsureFileDialogManager();
@@ -390,6 +428,8 @@ class CefBrowserHostBase : public CefBrowserHost,
// Only accessed on the UI thread.
std::unique_ptr<CefBrowserContentsDelegate> contents_delegate_;
CefRefPtr<CefUnresponsiveProcessCallback> unresponsive_process_callback_;
RenderViewContextMenuObserver* context_menu_observer_ = nullptr;
// Observers that want to be notified of changes to this object.
// Only accessed on the UI thread.
@@ -408,8 +448,11 @@ class CefBrowserHostBase : public CefBrowserHost,
bool is_fullscreen_ = false;
CefRefPtr<CefFrameHostImpl> focused_frame_;
// Used for creating and managing DevTools instances.
std::unique_ptr<CefDevToolsManager> devtools_manager_;
// Used for managing DevTools instances without a frontend.
std::unique_ptr<CefDevToolsProtocolManager> devtools_protocol_manager_;
// Used for creating and running the DevTools window frontend.
std::unique_ptr<CefDevToolsWindowRunner> devtools_window_runner_;
std::unique_ptr<CefMediaStreamRegistrar> media_stream_registrar_;

View File

@@ -65,8 +65,9 @@ bool CefBrowserHost::CreateBrowser(
// Verify windowless rendering requirements.
if (windowInfo.windowless_rendering_enabled &&
!client->GetRenderHandler().get()) {
DCHECK(false) << "CefRenderHandler implementation is required";
(!client || !client->GetRenderHandler().get())) {
LOG(ERROR)
<< "Windowless rendering requires a CefRenderHandler implementation";
return false;
}
@@ -133,13 +134,15 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
// Verify windowless rendering requirements.
if (windowInfo.windowless_rendering_enabled &&
!client->GetRenderHandler().get()) {
DCHECK(false) << "CefRenderHandler implementation is required";
(!client || !client->GetRenderHandler().get())) {
LOG(ERROR)
<< "Windowless rendering requires a CefRenderHandler implementation";
return nullptr;
}
CefBrowserCreateParams create_params;
create_params.MaybeSetWindowInfo(windowInfo);
create_params.MaybeSetWindowInfo(windowInfo, /*allow_alloy_style=*/true,
/*allow_chrome_style=*/true);
create_params.client = client;
create_params.url = url;
create_params.settings = settings;
@@ -149,18 +152,121 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
return CefBrowserHostBase::Create(create_params);
}
// static
bool CefBrowserCreateParams::IsChromeStyle(const CefWindowInfo* window_info) {
if (!cef::IsChromeRuntimeEnabled()) {
return false;
}
if (!window_info) {
return true;
}
// Both CHROME and DEFAULT indicate Chrome style with Chrome bootstrap.
return window_info->runtime_style == CEF_RUNTIME_STYLE_CHROME ||
window_info->runtime_style == CEF_RUNTIME_STYLE_DEFAULT;
}
bool CefBrowserCreateParams::IsChromeStyle() const {
if (!cef::IsChromeRuntimeEnabled()) {
return false;
}
const bool chrome_style_via_window_info = IsChromeStyle(window_info.get());
if (popup_with_alloy_style_opener) {
// Creating a popup where the opener is Alloy style.
if (chrome_style_via_window_info &&
window_info->runtime_style == CEF_RUNTIME_STYLE_CHROME) {
// Only use Chrome style for the popup if the client explicitly sets
// CHROME (and not DEFAULT) via CefWindowInfo.runtime_style.
return true;
}
return false;
}
if (browser_view) {
// Must match the BrowserView style. GetRuntimeStyle() will not return
// DEFAULT.
return browser_view->GetRuntimeStyle() == CEF_RUNTIME_STYLE_CHROME;
}
// Chrome style does not support windowless rendering.
return chrome_style_via_window_info && !IsWindowless();
}
bool CefBrowserCreateParams::IsWindowless() const {
return window_info && window_info->windowless_rendering_enabled && client &&
client->GetRenderHandler().get();
}
// static
void CefBrowserCreateParams::InitWindowInfo(CefWindowInfo* window_info,
CefBrowserHostBase* opener) {
#if BUILDFLAG(IS_WIN)
window_info->SetAsPopup(nullptr, CefString());
#endif
if (cef::IsChromeRuntimeEnabled() && opener->IsAlloyStyle()) {
// Give the popup the same runtime style as the opener.
window_info->runtime_style = CEF_RUNTIME_STYLE_ALLOY;
}
}
void CefBrowserCreateParams::MaybeSetWindowInfo(
const CefWindowInfo& new_window_info) {
if (!cef::IsChromeRuntimeEnabled() ||
const CefWindowInfo& new_window_info,
bool allow_alloy_style,
bool allow_chrome_style) {
if (!cef::IsChromeRuntimeEnabled()) {
// Chrome style is not supported wih the Alloy bootstrap.
allow_chrome_style = false;
}
if (allow_chrome_style && new_window_info.windowless_rendering_enabled) {
// Chrome style is not supported with windowles rendering.
allow_chrome_style = false;
}
#if BUILDFLAG(IS_MAC)
if (allow_chrome_style &&
chrome_child_window::HasParentHandle(new_window_info)) {
// Chrome style is not supported with native parent on MacOS. See issue
// #3294.
allow_chrome_style = false;
}
#endif
DCHECK(allow_alloy_style || allow_chrome_style);
bool reset_style = false;
if (new_window_info.runtime_style == CEF_RUNTIME_STYLE_ALLOY &&
!allow_alloy_style) {
LOG(ERROR) << "Alloy style is not supported for this browser";
reset_style = true;
} else if (new_window_info.runtime_style == CEF_RUNTIME_STYLE_CHROME &&
!allow_chrome_style) {
LOG(ERROR) << "Chrome style is not supported for this browser";
reset_style = true;
}
const bool is_chrome_style =
allow_chrome_style && IsChromeStyle(&new_window_info);
if (!is_chrome_style ||
chrome_child_window::HasParentHandle(new_window_info)) {
window_info = std::make_unique<CefWindowInfo>(new_window_info);
if (cef::IsChromeRuntimeEnabled() && !allow_chrome_style) {
// Only Alloy style is allowed.
window_info->runtime_style = CEF_RUNTIME_STYLE_ALLOY;
} else if (reset_style) {
// Use the default style.
window_info->runtime_style = CEF_RUNTIME_STYLE_DEFAULT;
}
}
}
// static
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::Create(
CefBrowserCreateParams& create_params) {
if (cef::IsChromeRuntimeEnabled()) {
if (create_params.IsChromeStyle()) {
if (auto browser =
chrome_child_window::MaybeCreateChildBrowser(create_params)) {
return browser.get();

View File

@@ -7,6 +7,7 @@
#include <memory>
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/frame_util.h"
#include "libcef/common/values_impl.h"
@@ -29,10 +30,12 @@ CefBrowserInfo::FrameInfo::~FrameInfo() {
CefBrowserInfo::CefBrowserInfo(int browser_id,
bool is_popup,
bool is_windowless,
bool print_preview_enabled,
CefRefPtr<CefDictionaryValue> extra_info)
: browser_id_(browser_id),
is_popup_(is_popup),
is_windowless_(is_windowless),
print_preview_enabled_(print_preview_enabled),
extra_info_(extra_info) {
DCHECK_GT(browser_id, 0);
@@ -92,10 +95,14 @@ void CefBrowserInfo::SetClosing() {
is_closing_ = true;
}
void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
bool is_guest_view) {
void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host) {
CEF_REQUIRE_UIT();
if (CefBrowserInfoManager::IsExcludedFrameHost(host)) {
// Don't create a FrameHost for an excluded type.
return;
}
const auto global_id = host->GetGlobalId();
const bool is_main_frame = (host->GetParent() == nullptr);
@@ -121,11 +128,10 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
#if DCHECK_IS_ON()
// Check that the frame info hasn't changed unexpectedly.
DCHECK_EQ(info->global_id_, global_id);
DCHECK_EQ(info->is_guest_view_, is_guest_view);
DCHECK_EQ(info->is_main_frame_, is_main_frame);
#endif
if (!info->is_guest_view_ && info->is_speculative_ && !is_speculative) {
if (info->is_speculative_ && !is_speculative) {
// Upgrade the frame info from speculative to non-speculative.
if (info->is_main_frame_) {
// Set the main frame object.
@@ -139,28 +145,23 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
auto frame_info = new FrameInfo;
frame_info->host_ = host;
frame_info->global_id_ = global_id;
frame_info->is_guest_view_ = is_guest_view;
frame_info->is_main_frame_ = is_main_frame;
frame_info->is_speculative_ = is_speculative;
// Guest views don't get their own CefBrowser or CefFrame objects.
if (!is_guest_view) {
// Create a new frame object.
frame_info->frame_ = new CefFrameHostImpl(this, host);
MaybeNotifyFrameCreated(frame_info->frame_);
if (is_main_frame && !is_speculative) {
SetMainFrame(browser_, frame_info->frame_);
}
#if DCHECK_IS_ON()
// Check that the frame info hasn't changed unexpectedly.
DCHECK(host->GetGlobalFrameToken() == *frame_info->frame_->frame_token());
DCHECK_EQ(frame_info->is_main_frame_, frame_info->frame_->IsMain());
#endif
// Create a new frame object.
frame_info->frame_ = new CefFrameHostImpl(this, host);
MaybeNotifyFrameCreated(frame_info->frame_);
if (is_main_frame && !is_speculative) {
SetMainFrame(browser_, frame_info->frame_);
}
browser_->request_context()->OnRenderFrameCreated(global_id, is_main_frame,
is_guest_view);
#if DCHECK_IS_ON()
// Check that the frame info hasn't changed unexpectedly.
DCHECK(host->GetGlobalFrameToken() == *frame_info->frame_->frame_token());
DCHECK_EQ(frame_info->is_main_frame_, frame_info->frame_->IsMain());
#endif
browser_->request_context()->OnRenderFrameCreated(global_id, is_main_frame);
// Populate the lookup maps.
frame_id_map_.insert(std::make_pair(global_id, frame_info));
@@ -210,10 +211,11 @@ void CefBrowserInfo::FrameHostStateChanged(
base::AutoLock lock_scope(lock_);
auto it = frame_id_map_.find(host->GetGlobalId());
DCHECK(it != frame_id_map_.end());
DCHECK((!it->second->is_in_bfcache_ && added_to_bfcache) ||
(it->second->is_in_bfcache_ && removed_from_bfcache));
it->second->is_in_bfcache_ = added_to_bfcache;
if (it != frame_id_map_.end()) {
DCHECK((!it->second->is_in_bfcache_ && added_to_bfcache) ||
(it->second->is_in_bfcache_ && removed_from_bfcache));
it->second->is_in_bfcache_ = added_to_bfcache;
}
}
void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
@@ -223,12 +225,14 @@ void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
const auto global_id = host->GetGlobalId();
auto it = frame_id_map_.find(global_id);
DCHECK(it != frame_id_map_.end());
if (it == frame_id_map_.end()) {
return;
}
auto frame_info = it->second;
browser_->request_context()->OnRenderFrameDeleted(
global_id, frame_info->is_main_frame_, frame_info->is_guest_view_);
browser_->request_context()->OnRenderFrameDeleted(global_id,
frame_info->is_main_frame_);
// Remove from the lookup maps.
frame_id_map_.erase(it);
@@ -279,29 +283,19 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::CreateTempSubFrame(
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForHost(
const content::RenderFrameHost* host,
bool* is_guest_view,
bool prefer_speculative) const {
if (is_guest_view) {
*is_guest_view = false;
}
if (!host) {
return nullptr;
}
return GetFrameForGlobalId(
const_cast<content::RenderFrameHost*>(host)->GetGlobalId(), is_guest_view,
const_cast<content::RenderFrameHost*>(host)->GetGlobalId(),
prefer_speculative);
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId(
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view,
bool prefer_speculative) const {
if (is_guest_view) {
*is_guest_view = false;
}
if (!frame_util::IsValidGlobalId(global_id)) {
return nullptr;
}
@@ -312,13 +306,6 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId(
if (it != frame_id_map_.end()) {
const auto info = it->second;
if (info->is_guest_view_) {
if (is_guest_view) {
*is_guest_view = true;
}
return nullptr;
}
if (info->is_speculative_ && !prefer_speculative) {
if (info->is_main_frame_ && main_frame_) {
// Always prefer the non-speculative main frame.
@@ -338,7 +325,6 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId(
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view,
bool prefer_speculative) const {
if (!frame_util::IsValidGlobalToken(global_token)) {
return nullptr;
@@ -355,7 +341,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalToken(
global_id = it->second;
}
return GetFrameForGlobalId(global_id, is_guest_view, prefer_speculative);
return GetFrameForGlobalId(global_id, prefer_speculative);
}
CefBrowserInfo::FrameHostList CefBrowserInfo::GetAllFrames() const {

View File

@@ -37,6 +37,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
CefBrowserInfo(int browser_id,
bool is_popup,
bool is_windowless,
bool print_preview_enabled,
CefRefPtr<CefDictionaryValue> extra_info);
CefBrowserInfo(const CefBrowserInfo&) = delete;
@@ -45,6 +46,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
int browser_id() const { return browser_id_; }
bool is_popup() const { return is_popup_; }
bool is_windowless() const { return is_windowless_; }
bool print_preview_enabled() const { return print_preview_enabled_; }
CefRefPtr<CefDictionaryValue> extra_info() const { return extra_info_; }
// May return NULL if the browser has not yet been created or if the browser
@@ -65,10 +67,8 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// Ensure that a frame record exists for |host|. Called for the main frame
// when the RenderView is created, or for a sub-frame when the associated
// RenderFrame is created in the renderer process.
// Called from CefBrowserContentsDelegate::RenderFrameCreated (is_guest_view =
// false) or CefMimeHandlerViewGuestDelegate::OnGuestAttached (is_guest_view =
// true).
void MaybeCreateFrame(content::RenderFrameHost* host, bool is_guest_view);
// Called from CefBrowserContentsDelegate::RenderFrameCreated.
void MaybeCreateFrame(content::RenderFrameHost* host);
// Used to track state changes such as entering/exiting the BackForwardCache.
// Called from CefBrowserContentsDelegate::RenderFrameHostStateChanged.
@@ -100,32 +100,22 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
const content::GlobalRenderFrameHostId& parent_global_id);
// Returns the frame object matching the specified host or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
// because we don't create frame objects for guest views. If |is_guest_view|
// is non-nullptr it will be set to true in this case. Must be called on the
// UI thread.
// is found. Must be called on the UI thread.
CefRefPtr<CefFrameHostImpl> GetFrameForHost(
const content::RenderFrameHost* host,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
// Returns the frame object matching the specified ID/token or nullptr if no
// match is found. Nullptr will also be returned if a guest view match is
// found because we don't create frame objects for guest views. If
// |is_guest_view| is non-nullptr it will be set to true in this case. Safe to
// call from any thread.
// match is found. Safe to call from any thread.
CefRefPtr<CefFrameHostImpl> GetFrameForGlobalId(
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
CefRefPtr<CefFrameHostImpl> GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const;
// Returns all non-speculative frame objects that currently exist. Guest views
// will be excluded because they don't have a frame object. Safe to call from
// any thread.
// Returns all non-speculative frame objects that currently exist. Safe to
// call from any thread.
using FrameHostList = std::set<CefRefPtr<CefFrameHostImpl>>;
FrameHostList GetAllFrames() const;
@@ -182,7 +172,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
content::RenderFrameHost* host_;
content::GlobalRenderFrameHostId global_id_;
bool is_guest_view_;
bool is_main_frame_;
bool is_speculative_;
bool is_in_bfcache_ = false;
@@ -201,9 +190,10 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
void RemoveAllFrames(CefRefPtr<CefBrowserHostBase> old_browser);
int browser_id_;
bool is_popup_;
bool is_windowless_;
const int browser_id_;
const bool is_popup_;
const bool is_windowless_;
const bool print_preview_enabled_;
CefRefPtr<CefDictionaryValue> extra_info_;
// Navigation will be blocked while |navigation_lock_| exists.

View File

@@ -14,7 +14,7 @@
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/frame_util.h"
#include "libcef/common/values_impl.h"
#include "libcef/features/runtime_checks.h"
#include "libcef/features/runtime.h"
#include "base/command_line.h"
#include "base/logging.h"
@@ -66,11 +66,13 @@ CefBrowserInfoManager* CefBrowserInfoManager::GetInstance() {
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreateBrowserInfo(
bool is_popup,
bool is_windowless,
bool print_preview_enabled,
CefRefPtr<CefDictionaryValue> extra_info) {
base::AutoLock lock_scope(browser_info_lock_);
scoped_refptr<CefBrowserInfo> browser_info = new CefBrowserInfo(
++next_browser_id_, is_popup, is_windowless, extra_info);
scoped_refptr<CefBrowserInfo> browser_info =
new CefBrowserInfo(++next_browser_id_, is_popup, is_windowless,
print_preview_enabled, extra_info);
browser_info_list_.push_back(browser_info);
return browser_info;
@@ -79,24 +81,23 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreateBrowserInfo(
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
content::WebContents* new_contents,
bool is_windowless,
bool print_preview_enabled,
CefRefPtr<CefDictionaryValue> extra_info) {
base::AutoLock lock_scope(browser_info_lock_);
CEF_REQUIRE_UIT();
auto frame_host = new_contents->GetPrimaryMainFrame();
scoped_refptr<CefBrowserInfo> browser_info =
new CefBrowserInfo(++next_browser_id_, true, is_windowless, extra_info);
browser_info_list_.push_back(browser_info);
scoped_refptr<CefBrowserInfo> browser_info;
{
base::AutoLock lock_scope(browser_info_lock_);
browser_info = new CefBrowserInfo(++next_browser_id_, true, is_windowless,
print_preview_enabled, extra_info);
browser_info_list_.push_back(browser_info);
}
// Continue any pending NewBrowserInfo request.
auto it =
pending_new_browser_info_map_.find(frame_host->GetGlobalFrameToken());
if (it != pending_new_browser_info_map_.end()) {
SendNewBrowserInfoResponse(browser_info, /*is_guest_view=*/false,
std::move(it->second->callback),
it->second->callback_runner);
pending_new_browser_info_map_.erase(it);
}
ContinueNewBrowserInfo(frame_host->GetGlobalFrameToken(), browser_info,
/*is_excluded=*/false);
return browser_info;
}
@@ -129,10 +130,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
bool handled = false;
CefWindowInfo window_info;
#if BUILDFLAG(IS_WIN)
window_info.SetAsPopup(nullptr, CefString());
#endif
CefBrowserCreateParams::InitWindowInfo(&window_info, browser.get());
auto pending_popup = std::make_unique<CefBrowserInfoManager::PendingPopup>();
pending_popup->step = PendingPopup::CAN_CREATE_WINDOW;
@@ -185,10 +183,12 @@ bool CefBrowserInfoManager::CanCreateWindow(
if (allow) {
CefBrowserCreateParams create_params;
create_params.MaybeSetWindowInfo(window_info);
create_params.MaybeSetWindowInfo(window_info, /*allow_alloy_style=*/true,
/*allow_chrome_style=*/true);
if (!handled) {
// Use default Browser creation if OnBeforePopup was unhandled.
// Use default Browser creation with Chrome style if OnBeforePopup was
// unhandled.
// TODO(chrome): Expose a mechanism for the client to choose default
// creation.
pending_popup->use_default_browser_creation = true;
@@ -196,6 +196,10 @@ bool CefBrowserInfoManager::CanCreateWindow(
create_params.popup_with_views_hosted_opener = ShouldCreateViewsHostedPopup(
browser, pending_popup->use_default_browser_creation);
// Potentially use Alloy style with the Chrome runtime.
create_params.popup_with_alloy_style_opener = browser->IsAlloyStyle();
create_params.settings = pending_popup->settings;
create_params.client = pending_popup->client;
create_params.extra_info = pending_popup->extra_info;
@@ -204,6 +208,11 @@ bool CefBrowserInfoManager::CanCreateWindow(
CefBrowserPlatformDelegate::Create(create_params);
CHECK(pending_popup->platform_delegate.get());
// Expect runtime style to match.
pending_popup->alloy_style = !create_params.IsChromeStyle();
CHECK_EQ(pending_popup->alloy_style,
pending_popup->platform_delegate->IsAlloyStyle());
// Between the calls to CanCreateWindow and GetCustomWebContentsView
// RenderViewHostImpl::CreateNewWindow() will call
// RenderProcessHostImpl::FilterURL() which, in the case of "javascript:"
@@ -223,9 +232,9 @@ void CefBrowserInfoManager::GetCustomWebContentsView(
content::WebContentsView** view,
content::RenderViewHostDelegateView** delegate_view) {
CEF_REQUIRE_UIT();
REQUIRE_ALLOY_RUNTIME();
auto pending_popup = PopPendingPopup(PendingPopup::CAN_CREATE_WINDOW,
PendingPopup::CAN_CREATE_WINDOW,
opener_global_id, target_url);
DCHECK(pending_popup.get());
DCHECK(pending_popup->platform_delegate.get());
@@ -249,13 +258,10 @@ void CefBrowserInfoManager::WebContentsCreated(
content::WebContents* new_contents) {
CEF_REQUIRE_UIT();
// GET_CUSTOM_WEB_CONTENTS_VIEW is only used with the alloy runtime.
const auto previous_step = cef::IsAlloyRuntimeEnabled()
? PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW
: PendingPopup::CAN_CREATE_WINDOW;
auto pending_popup =
PopPendingPopup(previous_step, opener_global_id, target_url);
// GET_CUSTOM_WEB_CONTENTS_VIEW is only used with Alloy style.
auto pending_popup = PopPendingPopup(
PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW,
PendingPopup::CAN_CREATE_WINDOW, opener_global_id, target_url);
DCHECK(pending_popup.get());
DCHECK(pending_popup->platform_delegate.get());
@@ -264,8 +270,8 @@ void CefBrowserInfoManager::WebContentsCreated(
platform_delegate = std::move(pending_popup->platform_delegate);
extra_info = pending_popup->extra_info;
// AddWebContents (the next step) is only used with the Chrome runtime.
if (cef::IsChromeRuntimeEnabled()) {
// AddWebContents (the next step) is only used with Chrome style.
if (!pending_popup->alloy_style) {
pending_popup->step = PendingPopup::WEB_CONTENTS_CREATED;
pending_popup->new_contents = new_contents;
PushPendingPopup(std::move(pending_popup));
@@ -280,8 +286,10 @@ bool CefBrowserInfoManager::AddWebContents(content::WebContents* new_contents) {
// chrome::AddWebContents is called directly from the Chrome UI (profile
// settings, etc).
auto pending_popup =
PopPendingPopup(PendingPopup::WEB_CONTENTS_CREATED, new_contents);
PopPendingPopup(PendingPopup::WEB_CONTENTS_CREATED,
PendingPopup::WEB_CONTENTS_CREATED, new_contents);
if (pending_popup) {
DCHECK(!pending_popup->alloy_style);
return !pending_popup->use_default_browser_creation;
}
@@ -299,15 +307,13 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
base::AutoLock lock_scope(browser_info_lock_);
bool is_guest_view = false;
scoped_refptr<CefBrowserInfo> browser_info =
GetBrowserInfoInternal(global_token, &is_guest_view);
GetBrowserInfoInternal(global_token);
if (browser_info) {
// Send the response immediately.
SendNewBrowserInfoResponse(browser_info, is_guest_view, std::move(callback),
callback_runner);
SendNewBrowserInfoResponse(browser_info, /*is_excluded=*/false,
std::move(callback), callback_runner);
return;
}
@@ -338,6 +344,54 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
global_token, timeout_id),
kNewBrowserInfoResponseTimeoutMs);
}
// Check for excluded content (PDF viewer or print preview).
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
&CefBrowserInfoManager::CheckExcludedNewBrowserInfoOnUIThread,
global_token));
}
// static
void CefBrowserInfoManager::CheckExcludedNewBrowserInfoOnUIThread(
const content::GlobalRenderFrameHostToken& global_token) {
CEF_REQUIRE_UIT();
if (!g_info_manager) {
return;
}
// May return nullptr for PDF renderer process.
auto* rfh = content::RenderFrameHost::FromFrameToken(global_token);
if (!rfh) {
return;
}
// PDF viewer and print preview create multiple renderer processes. These
// excluded processes are not tracked by CefBrowserInfo.
CefBrowserInfo* browser_info;
bool is_excluded;
GetFrameHost(rfh, /*prefer_speculative=*/true, &browser_info, &is_excluded);
if (browser_info && is_excluded) {
g_info_manager->ContinueNewBrowserInfo(global_token, browser_info,
/*is_excluded=*/true);
}
}
void CefBrowserInfoManager::ContinueNewBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token,
scoped_refptr<CefBrowserInfo> browser_info,
bool is_excluded) {
base::AutoLock lock_scope(browser_info_lock_);
// Continue any pending NewBrowserInfo request.
auto it = pending_new_browser_info_map_.find(global_token);
if (it != pending_new_browser_info_map_.end()) {
SendNewBrowserInfoResponse(browser_info, is_excluded,
std::move(it->second->callback),
it->second->callback_runner);
pending_new_browser_info_map_.erase(it);
}
}
void CefBrowserInfoManager::RemoveBrowserInfo(
@@ -386,17 +440,15 @@ void CefBrowserInfoManager::DestroyAllBrowsers() {
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view) {
const content::GlobalRenderFrameHostId& global_id) {
base::AutoLock lock_scope(browser_info_lock_);
return GetBrowserInfoInternal(global_id, is_guest_view);
return GetBrowserInfoInternal(global_id);
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view) {
const content::GlobalRenderFrameHostToken& global_token) {
base::AutoLock lock_scope(browser_info_lock_);
return GetBrowserInfoInternal(global_token, is_guest_view);
return GetBrowserInfoInternal(global_token);
}
bool CefBrowserInfoManager::MaybeAllowNavigation(
@@ -405,15 +457,14 @@ bool CefBrowserInfoManager::MaybeAllowNavigation(
CefRefPtr<CefBrowserHostBase>& browser_out) const {
CEF_REQUIRE_UIT();
bool is_guest_view = false;
auto browser = extensions::GetOwnerBrowserForHost(opener, &is_guest_view);
auto browser = CefBrowserHostBase::GetBrowserForHost(opener);
if (!browser) {
// Print preview uses a modal dialog where we don't own the WebContents.
// Allow that navigation to proceed.
return true;
}
if (!browser->MaybeAllowNavigation(opener, is_guest_view, params)) {
if (!browser->MaybeAllowNavigation(opener, params)) {
return false;
}
@@ -434,6 +485,83 @@ bool CefBrowserInfoManager::ShouldCreateViewsHostedPopup(
!use_default_browser_creation;
}
// static
CefRefPtr<CefFrameHostImpl> CefBrowserInfoManager::GetFrameHost(
content::RenderFrameHost* rfh,
bool prefer_speculative,
CefBrowserInfo** browser_info,
bool* is_excluded) {
CEF_REQUIRE_UIT();
DCHECK(rfh);
const bool is_pdf_process = rfh->GetProcess()->IsPdf();
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
const bool is_browser_process_guest =
extensions::IsBrowserPluginGuest(web_contents);
const bool is_print_preview_dialog =
extensions::IsPrintPreviewDialog(web_contents);
bool excluded =
is_pdf_process || is_browser_process_guest || is_print_preview_dialog;
CefRefPtr<CefFrameHostImpl> frame;
// A BrowserHost may match an excluded RFH type. Some associations are
// registered directly via CefBrowserInfo::MaybeCreateFrame and some are
// discovered indirectly via extensions::GetOwnerForGuestContents.
auto browser = CefBrowserHostBase::GetBrowserForHost(rfh);
if (browser && !excluded) {
frame = browser->browser_info()->GetFrameForHost(rfh, prefer_speculative);
}
if (browser_info) {
*browser_info = browser ? browser->browser_info().get() : nullptr;
}
if (is_excluded) {
*is_excluded = excluded;
}
if (VLOG_IS_ON(1)) {
const std::string& debug_string =
frame_util::GetFrameDebugString(rfh->GetGlobalFrameToken());
const bool is_main = rfh->GetParent() == nullptr;
VLOG(1) << "frame " << debug_string << ", pdf_process=" << is_pdf_process
<< ", browser_process_guest=" << is_browser_process_guest
<< ", print_preview_dialog=" << is_print_preview_dialog
<< ", main=" << is_main << (browser ? "" : ", has no BrowserHost")
<< (frame ? "" : ", has no FrameHost");
}
return frame;
}
// static
bool CefBrowserInfoManager::IsExcludedFrameHost(content::RenderFrameHost* rfh) {
CEF_REQUIRE_UIT();
DCHECK(rfh);
const bool is_pdf_process = rfh->GetProcess()->IsPdf();
if (is_pdf_process) {
return true;
}
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
const bool is_browser_process_guest =
extensions::IsBrowserPluginGuest(web_contents);
if (is_browser_process_guest) {
return true;
}
const bool is_print_preview_dialog =
extensions::IsPrintPreviewDialog(web_contents);
if (is_print_preview_dialog) {
return true;
}
return false;
}
CefBrowserInfoManager::BrowserInfoList
CefBrowserInfoManager::GetBrowserInfoList() {
base::AutoLock lock_scope(browser_info_lock_);
@@ -490,16 +618,21 @@ void CefBrowserInfoManager::PushPendingPopup(
std::unique_ptr<CefBrowserInfoManager::PendingPopup>
CefBrowserInfoManager::PopPendingPopup(
PendingPopup::Step previous_step,
PendingPopup::Step previous_step_alloy,
PendingPopup::Step previous_step_chrome,
const content::GlobalRenderFrameHostId& opener_global_id,
const GURL& target_url) {
CEF_REQUIRE_UIT();
DCHECK(frame_util::IsValidGlobalId(opener_global_id));
DCHECK_LE(previous_step, PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW);
DCHECK_LE(previous_step_alloy, PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW);
DCHECK_LE(previous_step_chrome, PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW);
PendingPopupList::iterator it = pending_popup_list_.begin();
for (; it != pending_popup_list_.end(); ++it) {
PendingPopup* popup = it->get();
const auto previous_step =
popup->alloy_style ? previous_step_alloy : previous_step_chrome;
if (popup->step == previous_step &&
popup->opener_global_id == opener_global_id &&
popup->target_url == target_url) {
@@ -514,14 +647,19 @@ CefBrowserInfoManager::PopPendingPopup(
}
std::unique_ptr<CefBrowserInfoManager::PendingPopup>
CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step previous_step,
CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step previous_step_alloy,
PendingPopup::Step previous_step_chrome,
content::WebContents* new_contents) {
CEF_REQUIRE_UIT();
DCHECK_GE(previous_step, PendingPopup::WEB_CONTENTS_CREATED);
DCHECK_GE(previous_step_alloy, PendingPopup::WEB_CONTENTS_CREATED);
DCHECK_GE(previous_step_chrome, PendingPopup::WEB_CONTENTS_CREATED);
PendingPopupList::iterator it = pending_popup_list_.begin();
for (; it != pending_popup_list_.end(); ++it) {
PendingPopup* popup = it->get();
const auto previous_step =
popup->alloy_style ? previous_step_alloy : previous_step_chrome;
if (popup->step == previous_step && popup->new_contents == new_contents) {
// Transfer ownership of the pointer.
it->release();
@@ -534,26 +672,16 @@ CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step previous_step,
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view) {
const content::GlobalRenderFrameHostId& global_id) {
browser_info_lock_.AssertAcquired();
if (is_guest_view) {
*is_guest_view = false;
}
if (!frame_util::IsValidGlobalId(global_id)) {
return nullptr;
}
for (const auto& browser_info : browser_info_list_) {
bool is_guest_view_tmp;
auto frame =
browser_info->GetFrameForGlobalId(global_id, &is_guest_view_tmp);
if (frame || is_guest_view_tmp) {
if (is_guest_view) {
*is_guest_view = is_guest_view_tmp;
}
auto frame = browser_info->GetFrameForGlobalId(global_id);
if (frame) {
return browser_info;
}
}
@@ -562,26 +690,16 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view) {
const content::GlobalRenderFrameHostToken& global_token) {
browser_info_lock_.AssertAcquired();
if (is_guest_view) {
*is_guest_view = false;
}
if (!frame_util::IsValidGlobalToken(global_token)) {
return nullptr;
}
for (const auto& browser_info : browser_info_list_) {
bool is_guest_view_tmp;
auto frame =
browser_info->GetFrameForGlobalToken(global_token, &is_guest_view_tmp);
if (frame || is_guest_view_tmp) {
if (is_guest_view) {
*is_guest_view = is_guest_view_tmp;
}
auto frame = browser_info->GetFrameForGlobalToken(global_token);
if (frame) {
return browser_info;
}
}
@@ -592,25 +710,26 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
// static
void CefBrowserInfoManager::SendNewBrowserInfoResponse(
scoped_refptr<CefBrowserInfo> browser_info,
bool is_guest_view,
bool is_excluded,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_runner) {
if (!callback_runner->RunsTasksInCurrentSequence()) {
callback_runner->PostTask(
FROM_HERE,
base::BindOnce(&CefBrowserInfoManager::SendNewBrowserInfoResponse,
browser_info, is_guest_view, std::move(callback),
browser_info, is_excluded, std::move(callback),
callback_runner));
return;
}
auto params = cef::mojom::NewBrowserInfo::New();
params->is_guest_view = is_guest_view;
params->is_excluded = is_excluded;
if (browser_info) {
params->browser_id = browser_info->browser_id();
params->is_windowless = browser_info->is_windowless();
params->is_popup = browser_info->is_popup();
params->print_preview_enabled = browser_info->print_preview_enabled();
auto extra_info = browser_info->extra_info();
if (extra_info) {
@@ -630,7 +749,7 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
// static
void CefBrowserInfoManager::CancelNewBrowserInfoResponse(
PendingNewBrowserInfo* pending_info) {
SendNewBrowserInfoResponse(/*browser_info=*/nullptr, /*is_guest_view=*/false,
SendNewBrowserInfoResponse(/*browser_info=*/nullptr, /*is_excluded=*/false,
std::move(pending_info->callback),
pending_info->callback_runner);
}
@@ -655,15 +774,21 @@ void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse(
return;
}
#if DCHECK_IS_ON()
// This method should never be called for a PDF renderer.
content::RenderProcessHost* process =
content::RenderProcessHost::FromID(global_token.child_id);
DCHECK(!process || !process->IsPdf());
#endif
// Cases where we expect to time out are:
// - With the Chrome runtime when chrome::AddWebContents or
// WebContents::Create are called directly from the Chrome UI (profile
// settings, etc). A RFH will exist without a matching CefBrowserHost.
// - When the PDF renderer is loaded in the print preview dialog. There will
// be no RFH in this case.
// Any additional cases should be debugged and, if possible,
// extensions::GetOwnerForGuestContents should be improved to find the
// associated CefBrowserHost.
const bool has_rfh =
!!content::RenderFrameHost::FromFrameToken(global_token);
LOG(ERROR) << "Timeout of new browser info response for frame "
<< frame_util::GetFrameDebugString(global_token);
<< frame_util::GetFrameDebugString(global_token)
<< " (has_rfh=" << has_rfh << ")";
CancelNewBrowserInfoResponse(pending_info.get());
g_info_manager->pending_new_browser_info_map_.erase(it);

View File

@@ -58,6 +58,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(
bool is_popup,
bool is_windowless,
bool print_preview_enabled,
CefRefPtr<CefDictionaryValue> extra_info);
// Called from WebContentsDelegate::WebContentsCreated when a new browser is
@@ -67,6 +68,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
scoped_refptr<CefBrowserInfo> CreatePopupBrowserInfo(
content::WebContents* new_contents,
bool is_windowless,
bool print_preview_enabled,
CefRefPtr<CefDictionaryValue> extra_info);
// Called from ContentBrowserClient::CanCreateWindow. See comments on
@@ -108,9 +110,9 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// browser info to the renderer process. If the browser info already exists
// the response will be sent immediately. Otherwise, the response will be sent
// when CreatePopupBrowserInfo creates the browser info. The info will already
// exist for explicitly created browsers and guest views. It may sometimes
// already exist for traditional popup browsers depending on timing. See
// comments on PendingPopup for more information.
// exist for explicitly created browsers. It may sometimes already exist for
// traditional popup browsers depending on timing. See comments on
// PendingPopup for more information.
void OnGetNewBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback);
@@ -124,16 +126,11 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Returns the CefBrowserInfo matching the specified ID/token or nullptr if no
// match is found. It is allowed to add new callers of this method but
// consider using CefBrowserHostBase::GetBrowserForGlobalId/Token() or
// extensions::GetOwnerBrowserForGlobalId() instead. If |is_guest_view| is
// non-nullptr it will be set to true if the ID/token matches a guest view
// associated with the returned browser info instead of the browser itself.
// consider using CefBrowserHostBase::GetBrowserForGlobalId/Token() instead.
scoped_refptr<CefBrowserInfo> GetBrowserInfo(
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view = nullptr);
const content::GlobalRenderFrameHostId& global_id);
scoped_refptr<CefBrowserInfo> GetBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view = nullptr);
const content::GlobalRenderFrameHostToken& global_token);
// Returns all existing CefBrowserInfo objects.
using BrowserInfoList = std::list<scoped_refptr<CefBrowserInfo>>;
@@ -149,6 +146,18 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
static bool ShouldCreateViewsHostedPopup(CefRefPtr<CefBrowserHostBase> opener,
bool use_default_browser_creation);
// Returns the FrameHost associated with |rfh|, if any. |browser_info| and
// |is_excluded| will be populated if non-nullptr. An excluded type will not
// have a FrameHost but |browser_info| may still be populated if the
// association is known.
static CefRefPtr<CefFrameHostImpl> GetFrameHost(content::RenderFrameHost* rfh,
bool prefer_speculative,
CefBrowserInfo** browser_info,
bool* is_excluded);
// Returns true if |rfh| should be excluded (no FrameHost created).
static bool IsExcludedFrameHost(content::RenderFrameHost* rfh);
private:
// RenderProcessHostObserver methods:
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
@@ -157,7 +166,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// - CanCreateWindow (UIT):
// Provides an opportunity to cancel the popup (calls OnBeforePopup) and
// creates the new platform delegate for the popup. If the popup owner is
// an extension guest view then the popup is canceled and
// an extension guest view (PDF viewer) then the popup is canceled and
// WebContentsDelegate::OpenURLFromTab is called via the
// CefBrowserHostBase::MaybeAllowNavigation implementation.
// And then the following calls may occur at the same time:
@@ -179,6 +188,9 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
WEB_CONTENTS_CREATED,
} step;
// True if this popup is Alloy style, otherwise Chrome style.
bool alloy_style;
// Initial state from ViewHostMsg_CreateWindow.
// |target_url| will be empty if a popup is created via window.open() and
// never navigated. For example: javascript:window.open();
@@ -195,7 +207,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate;
// True if default Browser or tab creation should proceed from
// AddWebContents (chrome runtime only).
// AddWebContents (Chrome style only).
bool use_default_browser_creation = false;
// The newly created WebContents (set in WebContentsCreated).
@@ -207,27 +219,36 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Used after CanCreateWindow is called.
std::unique_ptr<PendingPopup> PopPendingPopup(
PendingPopup::Step previous_step,
PendingPopup::Step previous_step_alloy,
PendingPopup::Step previous_step_chrome,
const content::GlobalRenderFrameHostId& opener_global_id,
const GURL& target_url);
// Used after WebContentsCreated is called.
std::unique_ptr<PendingPopup> PopPendingPopup(
PendingPopup::Step previous_step,
PendingPopup::Step previous_step_alloy,
PendingPopup::Step previous_step_chrome,
content::WebContents* new_contents);
// Retrieves the BrowserInfo matching the specified ID/token.
scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal(
const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view);
const content::GlobalRenderFrameHostId& global_id);
scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal(
const content::GlobalRenderFrameHostToken& global_token);
// Check for excluded frames that can be responded to immediately.
static void CheckExcludedNewBrowserInfoOnUIThread(
const content::GlobalRenderFrameHostToken& global_token);
void ContinueNewBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view);
scoped_refptr<CefBrowserInfo> browser_info,
bool is_excluded);
// Send the response for a pending OnGetNewBrowserInfo request.
static void SendNewBrowserInfoResponse(
scoped_refptr<CefBrowserInfo> browser_info,
bool is_guest_view,
bool is_excluded,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_runner);

View File

@@ -4,12 +4,22 @@
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "include/views/cef_window.h"
#include "include/views/cef_window_delegate.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/views/browser_view_impl.h"
#include "libcef/common/cef_switches.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
@@ -27,6 +37,39 @@ void ExecuteExternalProtocol(const GURL& url) {
CEF_POST_TASK(TID_UI, base::BindOnce(&platform_util::OpenExternal, url));
}
// Default popup window delegate implementation.
class PopupWindowDelegate : public CefWindowDelegate {
public:
explicit PopupWindowDelegate(CefRefPtr<CefBrowserView> browser_view)
: browser_view_(browser_view) {}
PopupWindowDelegate(const PopupWindowDelegate&) = delete;
PopupWindowDelegate& operator=(const PopupWindowDelegate&) = delete;
void OnWindowCreated(CefRefPtr<CefWindow> window) override {
window->AddChildView(browser_view_);
window->Show();
browser_view_->RequestFocus();
}
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override {
browser_view_ = nullptr;
}
bool CanClose(CefRefPtr<CefWindow> window) override {
CefRefPtr<CefBrowser> browser = browser_view_->GetBrowser();
if (browser) {
return browser->GetHost()->TryCloseBrowser();
}
return true;
}
private:
CefRefPtr<CefBrowserView> browser_view_;
IMPLEMENT_REFCOUNTING(PopupWindowDelegate);
};
} // namespace
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() = default;
@@ -146,10 +189,14 @@ views::Widget* CefBrowserPlatformDelegate::GetWindowWidget() const {
}
CefRefPtr<CefBrowserView> CefBrowserPlatformDelegate::GetBrowserView() const {
DCHECK(false);
return nullptr;
}
void CefBrowserPlatformDelegate::SetBrowserView(
CefRefPtr<CefBrowserView> browser_view) {
DCHECK(false);
}
web_modal::WebContentsModalDialogHost*
CefBrowserPlatformDelegate::GetWebContentsModalDialogHost() const {
DCHECK(false);
@@ -161,11 +208,79 @@ void CefBrowserPlatformDelegate::PopupWebContentsCreated(
CefRefPtr<CefClient> client,
content::WebContents* new_web_contents,
CefBrowserPlatformDelegate* new_platform_delegate,
bool is_devtools) {}
bool is_devtools) {
// Default popup handling may not be Views-hosted.
if (!new_platform_delegate->IsViewsHosted()) {
return;
}
CefRefPtr<CefBrowserViewDelegate> new_delegate;
CefRefPtr<CefBrowserViewDelegate> opener_delegate;
auto browser_view = GetBrowserView();
if (browser_view) {
// When |this| (the popup opener) is Views-hosted use the current delegate.
opener_delegate =
static_cast<CefBrowserViewImpl*>(browser_view.get())->delegate();
}
if (!opener_delegate) {
opener_delegate =
new_platform_delegate->GetDefaultBrowserViewDelegateForPopupOpener();
}
if (opener_delegate) {
new_delegate = opener_delegate->GetDelegateForPopupBrowserView(
browser_view, settings, client, is_devtools);
}
// Create a new BrowserView for the popup.
CefRefPtr<CefBrowserViewImpl> new_browser_view =
CefBrowserViewImpl::CreateForPopup(settings, new_delegate, is_devtools);
// Associate the PlatformDelegate with the new BrowserView.
new_platform_delegate->SetBrowserView(new_browser_view);
}
void CefBrowserPlatformDelegate::PopupBrowserCreated(
CefBrowserPlatformDelegate* new_platform_delegate,
CefBrowserHostBase* new_browser,
bool is_devtools) {}
bool is_devtools) {
// Default popup handling may not be Views-hosted.
if (!new_platform_delegate->IsViewsHosted()) {
return;
}
CefRefPtr<CefBrowserView> new_browser_view =
CefBrowserView::GetForBrowser(new_browser);
CHECK(new_browser_view);
bool popup_handled = false;
CefRefPtr<CefBrowserViewDelegate> opener_delegate;
auto browser_view = GetBrowserView();
if (browser_view) {
// When |this| (the popup opener) is Views-hosted use the current delegate.
opener_delegate =
static_cast<CefBrowserViewImpl*>(browser_view.get())->delegate();
}
if (!opener_delegate) {
opener_delegate =
new_platform_delegate->GetDefaultBrowserViewDelegateForPopupOpener();
}
if (opener_delegate) {
popup_handled = opener_delegate->OnPopupBrowserViewCreated(
browser_view, new_browser_view.get(), is_devtools);
}
if (!popup_handled) {
CefWindow::CreateTopLevelWindow(
new PopupWindowDelegate(new_browser_view.get()));
}
}
CefRefPtr<CefBrowserViewDelegate>
CefBrowserPlatformDelegate::GetDefaultBrowserViewDelegateForPopupOpener() {
return nullptr;
}
SkColor CefBrowserPlatformDelegate::GetBackgroundColor() const {
DCHECK(false);
@@ -409,10 +524,58 @@ void CefBrowserPlatformDelegate::SetAutoResizeEnabled(bool enabled,
void CefBrowserPlatformDelegate::SetAccessibilityState(
cef_state_t accessibility_state) {
NOTIMPLEMENTED();
// Do nothing if state is set to default. It'll be disabled by default and
// controlled by the command-line flags "force-renderer-accessibility" and
// "disable-renderer-accessibility".
if (accessibility_state == STATE_DEFAULT) {
return;
}
content::WebContentsImpl* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
if (!web_contents_impl) {
return;
}
ui::AXMode accMode;
// In windowless mode set accessibility to TreeOnly mode. Else native
// accessibility APIs, specific to each platform, are also created.
if (accessibility_state == STATE_ENABLED) {
accMode = IsWindowless() ? ui::kAXModeWebContentsOnly : ui::kAXModeComplete;
}
web_contents_impl->SetAccessibilityMode(accMode);
}
bool CefBrowserPlatformDelegate::IsPrintPreviewSupported() const {
if (IsWindowless()) {
// Not supported with windowless rendering.
return false;
}
if (web_contents_) {
auto cef_browser_context = CefBrowserContext::FromBrowserContext(
web_contents_->GetBrowserContext());
if (cef_browser_context->AsProfile()->GetPrefs()->GetBoolean(
prefs::kPrintPreviewDisabled)) {
// Disabled on the Profile.
return false;
}
}
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kDisablePrintPreview)) {
// Disabled explicitly via the command-line.
return false;
}
const bool default_disabled = IsAlloyStyle();
if (default_disabled &&
!command_line->HasSwitch(switches::kEnablePrintPreview)) {
// Default disabled and not enabled explicitly via the command-line.
return false;
}
return true;
}

View File

@@ -88,7 +88,7 @@ class CefBrowserPlatformDelegate {
static std::unique_ptr<CefBrowserPlatformDelegate> Create(
const CefBrowserCreateParams& create_params);
// Called from AlloyBrowserHostImpl::Create.
// Called from BrowserHost::Create.
// Wait for the call to WebContentsCreated(owned=true) before taking ownership
// of the resulting WebContents object.
virtual content::WebContents* CreateWebContents(
@@ -136,12 +136,12 @@ class CefBrowserPlatformDelegate {
// See WebContentsObserver documentation.
virtual void RenderViewReady();
// Called after the owning AlloyBrowserHostImpl is created. Will only be
// Called after the owning BrowserHost is created. Will only be
// called a single time per instance. Do not send any client notifications
// from this method.
virtual void BrowserCreated(CefBrowserHostBase* browser);
// Called from AlloyBrowserHostImpl::Create.
// Called from BrowserHost::Create.
virtual void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type);
@@ -157,9 +157,9 @@ class CefBrowserPlatformDelegate {
// BrowserDestroyed().
virtual void NotifyBrowserDestroyed();
// Called before the owning AlloyBrowserHostImpl is destroyed. Will only be
// Called before the owning BrowserHost is destroyed. Will only be
// called a single time per instance. All references to the
// AlloyBrowserHostImpl and WebContents should be cleared when this method is
// BrowserHost and WebContents should be cleared when this method is
// called. Do not send any client notifications from this method.
virtual void BrowserDestroyed(CefBrowserHostBase* browser);
@@ -182,35 +182,48 @@ class CefBrowserPlatformDelegate {
// rendering.
virtual views::Widget* GetWindowWidget() const;
// Returns the BrowserView associated with this browser. Only used with views-
// Returns the BrowserView associated with this browser. Only used with Views-
// based browsers.
virtual CefRefPtr<CefBrowserView> GetBrowserView() const;
// Sets the BrowserView associated with this browser. Only used with
// Views-based browsers.
virtual void SetBrowserView(CefRefPtr<CefBrowserView> browser_view);
// Returns the WebContentsModalDialogHost associated with this browser.
virtual web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
const;
// Called after the WebContents have been created for a new popup browser
// parented to this browser but before the AlloyBrowserHostImpl is created for
// the popup. |is_devtools| will be true if the popup will host DevTools. This
// parented to this browser but before the BrowserHost is created for the
// popup. |is_devtools| will be true if the popup will host DevTools. This
// method will be called before WebContentsCreated() is called on
// |new_platform_delegate|. Do not make the new browser visible in this
// |new_platform_delegate|. Does not make the new browser visible in this
// callback.
virtual void PopupWebContentsCreated(
void PopupWebContentsCreated(
const CefBrowserSettings& settings,
CefRefPtr<CefClient> client,
content::WebContents* new_web_contents,
CefBrowserPlatformDelegate* new_platform_delegate,
bool is_devtools);
// Called after the AlloyBrowserHostImpl is created for a new popup browser
// parented to this browser. |is_devtools| will be true if the popup will host
// DevTools. This method will be called immediately after
// Called after the BrowserHost is created for a new popup browser parented to
// this browser. |is_devtools| will be true if the popup will host DevTools.
// This method will be called immediately after
// CefLifeSpanHandler::OnAfterCreated() for the popup browser. It is safe to
// make the new browser visible in this callback (for example, add the browser
// to a window and show it).
virtual void PopupBrowserCreated(CefBrowserHostBase* new_browser,
bool is_devtools);
void PopupBrowserCreated(CefBrowserPlatformDelegate* new_platform_delegate,
CefBrowserHostBase* new_browser,
bool is_devtools);
// Called from PopupWebContentsCreated/PopupBrowserCreated to retrieve the
// default BrowserViewDelegate in cases where this is a new Views-based popup
// and the opener is either not Views-based or doesn't implement the
// BrowserViewDelegate. Only implemented for specific configurations where
// special handling of new popups is required for proper functioning.
virtual CefRefPtr<CefBrowserViewDelegate>
GetDefaultBrowserViewDelegateForPopupOpener();
// Returns the background color for the browser. The alpha component will be
// either SK_AlphaTRANSPARENT or SK_AlphaOPAQUE (e.g. fully transparent or
@@ -294,6 +307,11 @@ class CefBrowserPlatformDelegate {
// be called on multiple threads.
virtual bool IsViewsHosted() const;
// Returns the runtime style implemented by this delegate. May be called on
// multiple threads.
virtual bool IsAlloyStyle() const = 0;
bool IsChromeStyle() const { return !IsAlloyStyle(); }
// Returns true if this delegate implements a browser with external
// (client-provided) parent window. May be called on multiple threads.
virtual bool HasExternalParent() const;

View File

@@ -18,7 +18,6 @@
#include "libcef/browser/chrome/views/chrome_child_window.h"
#include "libcef/browser/extensions/browser_platform_delegate_background.h"
#include "libcef/browser/views/browser_platform_delegate_views.h"
#include "libcef/features/runtime_checks.h"
#if BUILDFLAG(IS_WIN)
#include "libcef/browser/native/browser_platform_delegate_native_win.h"
@@ -59,10 +58,10 @@ std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
std::move(native_delegate), use_shared_texture, use_external_begin_frame);
#elif BUILDFLAG(IS_MAC)
return std::make_unique<CefBrowserPlatformDelegateOsrMac>(
std::move(native_delegate));
std::move(native_delegate), use_shared_texture, use_external_begin_frame);
#elif BUILDFLAG(IS_LINUX)
return std::make_unique<CefBrowserPlatformDelegateOsrLinux>(
std::move(native_delegate), use_external_begin_frame);
std::move(native_delegate), use_shared_texture, use_external_begin_frame);
#endif
}
@@ -71,14 +70,11 @@ std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
// static
std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
const CefBrowserCreateParams& create_params) {
const bool is_windowless =
create_params.window_info &&
create_params.window_info->windowless_rendering_enabled &&
create_params.client && create_params.client->GetRenderHandler().get();
const bool is_windowless = create_params.IsWindowless();
const SkColor background_color = CefContext::Get()->GetBackgroundColor(
&create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED);
if (cef::IsChromeRuntimeEnabled()) {
if (create_params.IsChromeStyle()) {
CefWindowInfo window_info;
if (create_params.window_info) {
window_info = *create_params.window_info;
@@ -124,8 +120,6 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(*create_params.window_info, background_color);
if (is_windowless) {
REQUIRE_ALLOY_RUNTIME();
const bool use_shared_texture =
create_params.window_info->shared_texture_enabled;

View File

@@ -12,12 +12,17 @@
#include "base/memory/scoped_refptr.h"
#include "chrome/browser/ui/page_action/page_action_icon_type.h"
#include "content/public/browser/web_contents_delegate.h"
#include "third_party/blink/public/mojom/page/draggable_region.mojom-forward.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/base/window_open_disposition.h"
class Browser;
class Profile;
namespace content {
class NavigationHandle;
}
namespace cef {
// Delegate for the chrome Browser object. Lifespan is controlled by the Browser
@@ -39,15 +44,16 @@ class BrowserDelegate : public content::WebContentsDelegate {
scoped_refptr<CreateParams> cef_params,
const Browser* opener);
~BrowserDelegate() override = default;
// Optionally override Browser creation in
// DevToolsWindow::CreateDevToolsBrowser. The returned Browser, if any, will
// take ownership of |devtools_contents|.
virtual Browser* CreateDevToolsBrowser(
static Browser* CreateDevToolsBrowser(
Profile* profile,
Browser* opener,
std::unique_ptr<content::WebContents>& devtools_contents) = 0;
content::WebContents* inspected_web_contents,
std::unique_ptr<content::WebContents>& devtools_contents);
~BrowserDelegate() override = default;
// Optionally override chrome::AddWebContents behavior. This is most often
// called via Browser::AddNewContents for new popup browsers and provides an
@@ -119,6 +125,21 @@ class BrowserDelegate : public content::WebContentsDelegate {
return callback;
}
// Same as RendererUnresponsive but returning false if unhandled.
virtual bool RendererUnresponsiveEx(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host,
base::RepeatingClosure hang_monitor_restarter) {
return false;
}
// Same as RendererResponsive but returning false if unhandled.
virtual bool RendererResponsiveEx(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host) {
return false;
}
// Optionally override support for the specified window feature of type
// Browser::WindowFeature.
virtual std::optional<bool> SupportsWindowFeature(int feature) const {
@@ -135,12 +156,22 @@ class BrowserDelegate : public content::WebContentsDelegate {
return std::nullopt;
}
// Set the draggable region relative to web contents.
// Called from DraggableRegionsHostImpl::UpdateDraggableRegions.
virtual void UpdateDraggableRegion(const SkRegion& region) {}
// Called at the end of a fullscreen transition.
virtual void WindowFullscreenStateChanged() {}
// Returns true if this browser has a Views-hosted opener. Only
// applicable for Browsers of type picture_in_picture and devtools.
virtual bool HasViewsHostedOpener() const { return false; }
// Same as OpenURLFromTab but only taking |navigation_handle_callback|
// if the return value is non-nullptr.
virtual content::WebContents* OpenURLFromTabEx(
content::WebContents* source,
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>&
navigation_handle_callback) {
return nullptr;
}
};
} // namespace cef

View File

@@ -119,11 +119,6 @@ CefEventHandle CefBrowserPlatformDelegateChrome::GetEventHandle(
return native_delegate_->GetEventHandle(event);
}
bool CefBrowserPlatformDelegateChrome::IsPrintPreviewSupported() const {
return chrome_browser_ && !chrome_browser_->profile()->GetPrefs()->GetBoolean(
prefs::kPrintPreviewDisabled);
}
CefWindowHandle CefBrowserPlatformDelegateChrome::GetParentWindowHandle()
const {
return GetHostWindowHandle();
@@ -143,6 +138,9 @@ gfx::NativeWindow CefBrowserPlatformDelegateChrome::GetNativeWindow() const {
if (chrome_browser_ && chrome_browser_->window()) {
return chrome_browser_->window()->GetNativeWindow();
}
DCHECK(false);
if (web_contents_) {
return web_contents_->GetTopLevelNativeWindow();
}
NOTIMPLEMENTED();
return gfx::NativeWindow();
}

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