Compare commits

...

24 Commits
6778 ... 6367

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

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

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

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

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

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

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

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

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

View File

@@ -774,6 +774,8 @@ source_set("libcef_static") {
"libcef/browser/views/browser_view_view.h",
"libcef/browser/views/button_impl.h",
"libcef/browser/views/button_view.h",
"libcef/browser/views/color_provider_tracker.cc",
"libcef/browser/views/color_provider_tracker.h",
"libcef/browser/views/display_impl.cc",
"libcef/browser/views/display_impl.h",
"libcef/browser/views/fill_layout_impl.cc",
@@ -809,7 +811,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",
@@ -1123,22 +1129,23 @@ 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" ]
}
}
@@ -1478,6 +1485,20 @@ action("make_config_header") {
args = rebase_path(outputs + [ "$root_out_dir/args.gn" ], root_build_dir)
}
# Generate cef_color_ids.h.
action("make_colorids_header") {
script = "tools/make_colorids_header.py"
inputs = [
"//ui/color/color_id.h",
"//components/color/color_id.h",
"//chrome/browser/ui/color/chrome_color_id.h",
]
outputs = [ "$root_out_dir/includes/include/cef_color_ids.h" ]
args = rebase_path(outputs + inputs, root_build_dir)
}
# Generate pack files and associated CEF header files.
group("cef_make_headers") {
deps = [
@@ -1486,6 +1507,7 @@ group("cef_make_headers") {
":make_pack_header_command_ids",
":make_api_hash_header",
":make_config_header",
":make_colorids_header",
]
}
@@ -1964,6 +1986,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/124.0.6367.0'
'chromium_checkout': 'refs/tags/124.0.6367.207',
'depot_tools_checkout': '19199514e8'
}

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',
@@ -53,6 +54,7 @@
'include/internal/cef_time.h',
'include/internal/cef_trace_event_internal.h',
'include/internal/cef_types.h',
'include/internal/cef_types_color.h',
'include/internal/cef_types_content_settings.h',
'include/internal/cef_types_geometry.h',
],
@@ -315,6 +317,7 @@
'tests/cefclient/resources/binary_transfer.html',
'tests/cefclient/resources/binding.html',
'tests/cefclient/resources/dialogs.html',
'tests/cefclient/resources/draggable.html',
'tests/cefclient/resources/hang.html',
'tests/cefclient/resources/ipc_performance.html',
'tests/cefclient/resources/localstorage.html',

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.

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=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=7df03921b2ee743fb059f13e545ccf89904eb060$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@@ -368,6 +368,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=0ea5c2c5c1a8e8349f199a46642631be0c1bfb6b$
// $hash=08f13de764f30261616372dfffb7f97c57957f73$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_
@@ -339,18 +339,29 @@ typedef struct _cef_view_t {
///
/// Sets the background color for this View. The background color will be
/// automatically reset if the current theme changes. See
/// cef_view_delegate_t::OnThemeChanged for related documentation.
/// automatically reset when cef_view_delegate_t::OnThemeChanged is called.
///
void(CEF_CALLBACK* set_background_color)(struct _cef_view_t* self,
cef_color_t color);
///
/// Returns the background color for this View. If the background color has
/// not been explicitly set then the current theme color will be returned.
/// Returns the background color for this View. If the background color is
/// unset then the current `GetThemeColor(CEF_ColorPrimaryBackground)` value
/// will be returned. If this View belongs to an overlay (created with
/// cef_window_t::AddOverlayView), and the background color is unset, then a
/// value of transparent (0) will be returned.
///
cef_color_t(CEF_CALLBACK* get_background_color)(struct _cef_view_t* self);
///
/// Returns the current theme color associated with |color_id|, or the
/// placeholder color (red) if unset. See cef_color_ids.h for standard ID
/// values. Standard colors can be overridden and custom colors can be added
/// using cef_window_t::SetThemeColor.
///
cef_color_t(CEF_CALLBACK* get_theme_color)(struct _cef_view_t* self,
int color_id);
///
/// Convert |point| from this View's coordinate system to DIP screen
/// coordinates. This View must belong to a Window when calling this function.

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=d3624baa94bb722c48880b4319f5d5e8035eaa46$
// $hash=0f562c026f64ca19a32834dcc1e1cd3a98be2f1f$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_
@@ -143,11 +143,22 @@ typedef struct _cef_view_delegate_t {
///
/// Called when the theme for |view| has changed, after the new theme colors
/// have already been applied. This will be called at least one time when
/// |view| is added to a parent View. Further theme changes can be disabled by
/// passing the `--force-dark-mode` or `--force-light-mode` command-line flag.
/// Optionally use this callback to override the new theme colors by calling
/// the appropriate cef_view_t functions (SetBackgroundColor, etc).
/// have already been applied. Views are notified via the component hierarchy
/// in depth-first reverse order (children before parents).
///
/// This will be called in the following cases:
///
/// 1. When |view|, or a parent of |view|, is added to a Window. 2. When the
/// native/OS or Chrome theme changes for the Window that contains
/// |view|. See CefWindowDelegate::OnThemeColorsChanged documentation.
/// 3. When the client explicitly calls cef_window_t::ThemeChanged on the
/// Window
/// that contains |view|.
///
/// Optionally use this callback to override the new per-View theme colors by
/// calling cef_view_t::SetBackgroundColor or the appropriate component-
/// specific function. See cef_window_t::SetThemeColor documentation for how
/// to customize additional Window theme colors.
///
void(CEF_CALLBACK* on_theme_changed)(struct _cef_view_delegate_t* self,
struct _cef_view_t* view);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=dbe89dfdd14eb114e3f2d16fbfc55624bb91e7ce$
// $hash=2abb3759a22a95ffc0207f0538c645a74a5030c6$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_
@@ -364,6 +364,43 @@ 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);
} 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=e6bbc33db1b5ed3832982f8799e14557204f4028$
//
#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,43 @@ 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);
} 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 "a741045ff32b6feeaedf4e767ee0a18ed1c68007"
#define CEF_API_HASH_UNIVERSAL "35035b76d79ba0c7144aedb63d72b7988d372706"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "1180df9630b71b08a4c4874aa66484c3ca391327"
#define CEF_API_HASH_PLATFORM "9227cf2e0abf4f378e31e6095d503a91b2da59af"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "eaed012692fa480863cb78189e21ddf738fb8d5d"
#define CEF_API_HASH_PLATFORM "fe0bdc49d209ee3cf108bdb72faec21316f9d0e0"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "e17a9dca9ce61905920a734e71333729578da10e"
#define CEF_API_HASH_PLATFORM "df471096e6600c025ac0655b5eaa9818f075b8ba"
#endif
#ifdef __cplusplus

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

@@ -381,6 +381,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

@@ -2925,21 +2925,6 @@ typedef enum {
RESPONSE_FILTER_ERROR
} cef_response_filter_status_t;
///
/// Describes how to interpret the components of a pixel.
///
typedef enum {
///
/// RGBA with 8 bits per pixel (32bits total).
///
CEF_COLOR_TYPE_RGBA_8888,
///
/// BGRA with 8 bits per pixel (32bits total).
///
CEF_COLOR_TYPE_BGRA_8888,
} cef_color_type_t;
///
/// Describes how to interpret the alpha component of a pixel.
///
@@ -3854,6 +3839,20 @@ typedef enum {
CEF_ZOOM_COMMAND_IN,
} cef_zoom_command_t;
///
/// Specifies the color variants supported by
/// CefRequestContext::SetChromeThemeColor.
///
typedef enum {
CEF_COLOR_VARIANT_SYSTEM,
CEF_COLOR_VARIANT_LIGHT,
CEF_COLOR_VARIANT_DARK,
CEF_COLOR_VARIANT_TONAL_SPOT,
CEF_COLOR_VARIANT_NEUTRAL,
CEF_COLOR_VARIANT_VIBRANT,
CEF_COLOR_VARIANT_EXPRESSIVE,
} cef_color_variant_t;
#ifdef __cplusplus
}
#endif

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

@@ -43,6 +43,7 @@ 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"
// Handle types.
@@ -137,6 +138,56 @@ typedef struct _cef_window_info_t {
cef_window_handle_t window;
} 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,6 +35,7 @@
#if defined(OS_MAC)
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_color.h"
#include "include/internal/cef_types_geometry.h"
// Handle types.
@@ -44,6 +45,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
@@ -136,6 +139,23 @@ typedef struct _cef_window_info_t {
cef_window_handle_t view;
} 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

@@ -37,12 +37,14 @@
#include <windows.h>
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_color.h"
#include "include/internal/cef_types_geometry.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
@@ -104,6 +106,24 @@ typedef struct _cef_window_info_t {
cef_window_handle_t window;
} 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

@@ -750,4 +750,14 @@ struct CefMediaSinkDeviceInfoTraits {
///
using CefMediaSinkDeviceInfo = CefStructBase<CefMediaSinkDeviceInfoTraits>;
///
/// Class representing accelerated paint info.
///
class CefAcceleratedPaintInfo : public cef_accelerated_paint_info_t {
public:
CefAcceleratedPaintInfo() : cef_accelerated_paint_info_t{} {}
CefAcceleratedPaintInfo(const cef_accelerated_paint_info_t& r)
: cef_accelerated_paint_info_t(r) {}
};
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_

View File

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

View File

@@ -134,11 +134,21 @@ class CefViewDelegate : public virtual CefBaseRefCounted {
///
/// Called when the theme for |view| has changed, after the new theme colors
/// have already been applied. This will be called at least one time when
/// |view| is added to a parent View. Further theme changes can be disabled by
/// passing the `--force-dark-mode` or `--force-light-mode` command-line flag.
/// Optionally use this callback to override the new theme colors by calling
/// the appropriate CefView methods (SetBackgroundColor, etc).
/// have already been applied. Views are notified via the component hierarchy
/// in depth-first reverse order (children before parents).
///
/// This will be called in the following cases:
///
/// 1. When |view|, or a parent of |view|, is added to a Window.
/// 2. When the native/OS or Chrome theme changes for the Window that contains
/// |view|. See CefWindowDelegate::OnThemeColorsChanged documentation.
/// 3. When the client explicitly calls CefWindow::ThemeChanged on the Window
/// that contains |view|.
///
/// Optionally use this callback to override the new per-View theme colors by
/// calling CefView::SetBackgroundColor or the appropriate component-specific
/// method. See CefWindow::SetThemeColor documentation for how to customize
/// additional Window theme colors.
///
/*--cef()--*/
virtual void OnThemeChanged(CefRefPtr<CefView> view) {}

View File

@@ -377,6 +377,43 @@ 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;
};
#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,41 @@ 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) {}
};
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_

View File

@@ -55,6 +55,9 @@
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
#include "ui/events/devices/x11/touch_factory_x11.h"
#endif
#if defined(USE_DBUS)
#include "chrome/browser/ui/views/dark_mode_manager_linux.h"
#endif
#endif
#if defined(USE_AURA)
@@ -127,22 +130,6 @@ class LinuxUiGetterImpl : public ui::LinuxUiGetter {
}
};
ui::LinuxUi* GetLinuxUI() {
// We can't use GtkUi in combination with multi-threaded-message-loop because
// Chromium's GTK implementation doesn't use GDK threads.
if (!!CefContext::Get()->settings().multi_threaded_message_loop) {
return nullptr;
}
// If the ozone backend hasn't provided a LinuxUiDelegate, don't try to create
// a LinuxUi instance as this may result in a crash in toolkit initialization.
if (!ui::LinuxUiDelegate::GetInstance()) {
return nullptr;
}
return ui::GetDefaultLinuxUi();
}
#endif // BUILDFLAG(IS_LINUX)
void ProcessSingletonNotificationCallbackImpl(
@@ -220,7 +207,9 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
#if BUILDFLAG(IS_LINUX)
// Based on chrome_browser_main_extra_parts_views_linux.cc
if (auto linux_ui = GetLinuxUI()) {
// |linux_ui| will be nullptr with multi-threaded-message-loop. See
// CefUiThread::InitializeBrowserRunner.
if (auto linux_ui = ui::GetDefaultLinuxUi()) {
linux_ui_getter_ = std::make_unique<LinuxUiGetterImpl>();
ui::LinuxUi::SetInstance(linux_ui);
@@ -229,6 +218,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);

View File

@@ -31,7 +31,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 +102,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

@@ -117,7 +117,10 @@ void CefAudioCapturer::OnCaptureError(
media::AudioCapturerSource::ErrorCode code,
const std::string& message) {
audio_handler_->OnAudioStreamError(browser_, message);
StopStream();
if (code != media::AudioCapturerSource::ErrorCode::kSocketError) {
StopStream();
}
}
void CefAudioCapturer::StopStream() {

View File

@@ -59,10 +59,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
}

View File

@@ -72,6 +72,12 @@ void CefBrowserPlatformDelegateChromeViews::WebContentsCreated(
browser_view_->WebContentsCreated(web_contents);
}
void CefBrowserPlatformDelegateChromeViews::WebContentsDestroyed(
content::WebContents* web_contents) {
CefBrowserPlatformDelegateChrome::WebContentsDestroyed(web_contents);
browser_view_->WebContentsDestroyed(web_contents);
}
void CefBrowserPlatformDelegateChromeViews::BrowserCreated(
CefBrowserHostBase* browser) {
CefBrowserPlatformDelegateChrome::BrowserCreated(browser);

View File

@@ -21,6 +21,7 @@ class CefBrowserPlatformDelegateChromeViews
// CefBrowserPlatformDelegate overrides.
void WebContentsCreated(content::WebContents* web_contents,
bool owned) override;
void WebContentsDestroyed(content::WebContents* web_contents) override;
void BrowserCreated(CefBrowserHostBase* browser) override;
void NotifyBrowserCreated() override;
void NotifyBrowserDestroyed() override;

View File

@@ -5,6 +5,8 @@
#include "libcef/browser/chrome/views/chrome_browser_frame.h"
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/views/window_view.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/browser.h"
@@ -17,6 +19,9 @@
#include "ui/views/widget/native_widget_private.h"
#endif
ChromeBrowserFrame::ChromeBrowserFrame(CefWindowView* window_view)
: window_view_(window_view) {}
void ChromeBrowserFrame::Init(BrowserView* browser_view,
std::unique_ptr<Browser> browser) {
DCHECK(browser_view);
@@ -45,8 +50,51 @@ void ChromeBrowserFrame::Init(BrowserView* browser_view,
#endif // BUILDFLAG(IS_MAC)
}
void ChromeBrowserFrame::ToggleFullscreenMode() {
chrome::ToggleFullscreenMode(browser_view_->browser());
void ChromeBrowserFrame::Initialized() {
initialized_ = true;
// Based on BrowserFrame::InitBrowserFrame.
// This is the first call that will trigger theme-related client callbacks.
#if BUILDFLAG(IS_LINUX)
// Calls ThemeChanged() or OnNativeThemeUpdated().
SelectNativeTheme();
#else
// Calls ThemeChanged().
SetNativeTheme(ui::NativeTheme::GetInstanceForNativeUi());
#endif
}
void ChromeBrowserFrame::AddAssociatedProfile(Profile* /*profile*/) {
// Calls ThemeChanged().
UserChangedTheme(BrowserThemeChangeType::kBrowserTheme);
}
void ChromeBrowserFrame::RemoveAssociatedProfile(Profile* /*profile*/) {}
Profile* ChromeBrowserFrame::GetThemeProfile() const {
if (browser_view_) {
return browser_view_->GetProfile();
}
return nullptr;
}
bool ChromeBrowserFrame::ToggleFullscreenMode() {
if (browser_view_) {
// Toggle fullscreen mode via the Chrome command for consistent behavior.
chrome::ToggleFullscreenMode(browser_view_->browser());
return true;
}
return false;
}
void ChromeBrowserFrame::UserChangedTheme(
BrowserThemeChangeType theme_change_type) {
// Callback from Browser::OnThemeChanged() and OnNativeThemeUpdated().
// Calls ThemeChanged() and possibly SelectNativeTheme().
BrowserFrame::UserChangedTheme(theme_change_type);
NotifyThemeColorsChanged(/*chrome_theme=*/!native_theme_change_);
}
views::internal::RootView* ChromeBrowserFrame::CreateRootView() {
@@ -80,3 +128,41 @@ void ChromeBrowserFrame::Activate() {
// Proceed with default handling.
BrowserFrame::Activate();
}
void ChromeBrowserFrame::OnNativeWidgetDestroyed() {
window_view_ = nullptr;
BrowserFrame::OnNativeWidgetDestroyed();
}
void ChromeBrowserFrame::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
// TODO: Reduce the frequency of this callback on Windows/Linux.
// See https://issues.chromium.org/issues/40280130#comment7
color_provider_tracker_.OnNativeThemeUpdated();
native_theme_change_ = true;
// Calls UserChangedTheme().
BrowserFrame::OnNativeThemeUpdated(observed_theme);
native_theme_change_ = false;
}
void ChromeBrowserFrame::OnColorProviderCacheResetMissed() {
// Ignore calls during Widget::Init().
if (!initialized_) {
return;
}
NotifyThemeColorsChanged(/*chrome_theme=*/false);
}
void ChromeBrowserFrame::NotifyThemeColorsChanged(bool chrome_theme) {
if (window_view_) {
window_view_->OnThemeColorsChanged(chrome_theme);
// Call ThemeChanged() asynchronously to avoid possible reentrancy.
CEF_POST_TASK(TID_UI, base::BindOnce(&ChromeBrowserFrame::ThemeChanged,
weak_ptr_factory_.GetWeakPtr()));
}
}

View File

@@ -6,6 +6,10 @@
#define CEF_LIBCEF_BROWSER_CHROME_VIEWS_CHROME_BROWSER_FRAME_H_
#pragma once
#include "libcef/browser/views/color_provider_tracker.h"
#include "libcef/browser/views/widget.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
@@ -86,18 +90,34 @@
// modifications.
class BrowserView;
class CefWindowView;
// Widget for a Views-hosted Chrome browser. Created in
// CefWindowView::CreateWidget() when the Chrome runtime is enabled.
class ChromeBrowserFrame : public BrowserFrame {
class ChromeBrowserFrame : public BrowserFrame,
public CefWidget,
public CefColorProviderTracker::Observer {
public:
ChromeBrowserFrame() = default;
explicit ChromeBrowserFrame(CefWindowView* window_view);
ChromeBrowserFrame(const ChromeBrowserFrame&) = delete;
ChromeBrowserFrame& operator=(const ChromeBrowserFrame&) = delete;
// Called from ChromeBrowserView::InitBrowser after |browser| creation.
void Init(BrowserView* browser_view, std::unique_ptr<Browser> browser);
void ToggleFullscreenMode();
// CefWidget methods:
views::Widget* GetWidget() override { return this; }
const views::Widget* GetWidget() const override { return this; }
void Initialized() override;
bool IsInitialized() const override { return initialized_; }
void AddAssociatedProfile(Profile* profile) override;
void RemoveAssociatedProfile(Profile* profile) override;
Profile* GetThemeProfile() const override;
bool ToggleFullscreenMode() override;
// BrowserFrame methods:
void UserChangedTheme(BrowserThemeChangeType theme_change_type) override;
// views::Widget methods:
views::internal::RootView* CreateRootView() override;
@@ -105,10 +125,29 @@ class ChromeBrowserFrame : public BrowserFrame {
override;
void Activate() override;
// NativeWidgetDelegate methods:
void OnNativeWidgetDestroyed() override;
// ui::NativeThemeObserver methods:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
BrowserView* browser_view() const { return browser_view_; }
private:
// CefColorProviderTracker::Observer methods:
void OnColorProviderCacheResetMissed() override;
void NotifyThemeColorsChanged(bool chrome_theme);
CefWindowView* window_view_;
BrowserView* browser_view_ = nullptr;
bool initialized_ = false;
bool native_theme_change_ = false;
CefColorProviderTracker color_provider_tracker_{this};
base::WeakPtrFactory<ChromeBrowserFrame> weak_ptr_factory_{this};
};
#endif // CEF_LIBCEF_BROWSER_CHROME_VIEWS_CHROME_BROWSER_FRAME_H_

View File

@@ -52,8 +52,17 @@ void ChromeBrowserView::ViewHierarchyChanged(
}
void ChromeBrowserView::AddedToWidget() {
// Create the Browser and ChromeBrowserHostImpl.
// Results in a call to InitBrowser which calls ParentClass::AddedToWidget.
cef_browser_view_->OnBrowserViewAdded();
// Call after ChromeBrowserHostImpl creation.
cef_browser_view_->AddedToWidget();
}
void ChromeBrowserView::RemovedFromWidget() {
ParentClass::RemovedFromWidget();
cef_browser_view_->RemovedFromWidget();
}
void ChromeBrowserView::OnBoundsChanged(const gfx::Rect& previous_bounds) {

View File

@@ -42,6 +42,7 @@ class ChromeBrowserView
void ViewHierarchyChanged(
const views::ViewHierarchyChangedDetails& details) override;
void AddedToWidget() override;
void RemovedFromWidget() override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
void OnGestureEvent(ui::GestureEvent* event) override;

View File

@@ -31,6 +31,13 @@
#include "content/public/common/content_switches.h"
#include "third_party/crashpad/crashpad/handler/handler_main.h"
#if BUILDFLAG(IS_LINUX)
#include "ui/base/ozone_buildflags.h"
#if BUILDFLAG(IS_OZONE_X11)
#include "ui/ozone/platform/x11/ozone_platform_x11.h"
#endif
#endif
#if BUILDFLAG(IS_WIN)
#include <Objbase.h>
#include <windows.h>
@@ -155,6 +162,17 @@ class CefUIThread : public base::PlatformThread::Delegate {
void InitializeBrowserRunner(
content::MainFunctionParams main_function_params) {
#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_OZONE_X11)
// Disable creation of GtkUi (interface to GTK desktop features) and cause
// ui::GetDefaultLinuxUi() (and related functions) to return nullptr. We
// can't use GtkUi in combination with multi-threaded-message-loop because
// Chromium's GTK implementation doesn't use GDK threads. Light/dark theme
// changes will still be detected via DarkModeManagerLinux.
ui::SetMultiThreadedMessageLoopX11();
#endif
#endif
// Use our own browser process runner.
browser_runner_ = content::BrowserMainRunner::Create();

View File

@@ -359,6 +359,7 @@ class InterceptedRequest : public network::mojom::URLLoader,
GURL redirect_url_;
GURL header_client_redirect_url_;
const net::MutableNetworkTrafficAnnotationTag traffic_annotation_;
std::optional<network::mojom::CredentialsMode> original_crendentials_mode_;
mojo::Receiver<network::mojom::URLLoader> proxied_loader_receiver_;
mojo::Remote<network::mojom::URLLoaderClient> target_client_;
@@ -507,6 +508,7 @@ void InterceptedRequest::Restart() {
// Match logic in CorsURLLoader::StartNetworkRequest.
const auto response_tainting = CalculateResponseTainting(
should_check_cors, request_.mode, tainted_origin);
original_crendentials_mode_ = request_.credentials_mode;
request_.credentials_mode =
network::cors::CalculateCredentialsFlag(request_.credentials_mode,
response_tainting)
@@ -875,6 +877,14 @@ void InterceptedRequest::ContinueAfterIntercept() {
target_loader_.BindNewPipeAndPassReceiver(), id_, options, request_,
proxied_client_receiver_.BindNewPipeAndPassRemote(),
traffic_annotation_);
if (original_crendentials_mode_) {
// Restore the original |credentials_mode| value after calling
// CreateLoaderAndStart. This matches the logic in CorsURLLoader::
// StartNetworkRequest and allows InterceptedRequest::Restart to compute
// the correct |credentials_mode| during a fetch request redirect.
request_.credentials_mode = *original_crendentials_mode_;
original_crendentials_mode_.reset();
}
}
}

View File

@@ -8,9 +8,10 @@
CefBrowserPlatformDelegateOsrLinux::CefBrowserPlatformDelegateOsrLinux(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate,
bool use_shared_texture,
bool use_external_begin_frame)
: CefBrowserPlatformDelegateOsr(std::move(native_delegate),
/*use_shared_texture=*/false,
use_shared_texture,
use_external_begin_frame) {}
CefWindowHandle CefBrowserPlatformDelegateOsrLinux::GetHostWindowHandle()

View File

@@ -13,6 +13,7 @@ class CefBrowserPlatformDelegateOsrLinux
public:
CefBrowserPlatformDelegateOsrLinux(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate,
bool use_shared_texture,
bool use_external_begin_frame);
// CefBrowserPlatformDelegate methods:

View File

@@ -11,7 +11,9 @@
class CefBrowserPlatformDelegateOsrMac : public CefBrowserPlatformDelegateOsr {
public:
explicit CefBrowserPlatformDelegateOsrMac(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate);
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate,
bool use_shared_texture,
bool use_external_begin_frame);
// CefBrowserPlatformDelegate methods:
CefWindowHandle GetHostWindowHandle() const override;

View File

@@ -7,10 +7,12 @@
#include <utility>
CefBrowserPlatformDelegateOsrMac::CefBrowserPlatformDelegateOsrMac(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate)
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate,
bool use_shared_texture,
bool use_external_begin_frame)
: CefBrowserPlatformDelegateOsr(std::move(native_delegate),
/*use_shared_texture=*/false,
/*use_external_begin_frame=*/false) {}
use_shared_texture,
use_external_begin_frame) {}
CefWindowHandle CefBrowserPlatformDelegateOsrMac::GetHostWindowHandle() const {
return native_delegate_->window_info().parent_view;

View File

@@ -202,6 +202,7 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
CefRenderWidgetHostViewOSR* parent_host_view)
: content::RenderWidgetHostViewBase(widget),
background_color_(background_color),
use_shared_texture_(use_shared_texture),
render_widget_host_(content::RenderWidgetHostImpl::From(widget)),
has_parent_(parent_host_view != nullptr),
parent_host_view_(parent_host_view),
@@ -397,7 +398,8 @@ void CefRenderWidgetHostViewOSR::ShowWithVisibility(
if (!content::GpuDataManagerImpl::GetInstance()->IsGpuCompositingDisabled()) {
// Start generating frames when we're visible and at the correct size.
if (!video_consumer_) {
video_consumer_ = std::make_unique<CefVideoConsumerOSR>(this);
video_consumer_ =
std::make_unique<CefVideoConsumerOSR>(this, use_shared_texture_);
UpdateFrameRate();
} else {
video_consumer_->SetActive(true);
@@ -1560,7 +1562,7 @@ void CefRenderWidgetHostViewOSR::OnPaint(const gfx::Rect& damage_rect,
const void* pixels) {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::OnPaint");
// Workaround for https://github.com/chromiumembedded/cef/issues/2817
// Workaround for issue #2817.
if (!is_showing_) {
return;
}
@@ -1594,6 +1596,43 @@ void CefRenderWidgetHostViewOSR::OnPaint(const gfx::Rect& damage_rect,
}
}
void CefRenderWidgetHostViewOSR::OnAcceleratedPaint(
const gfx::Rect& damage_rect,
const gfx::Size& pixel_size,
const CefAcceleratedPaintInfo& info) {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::OnAcceleratedPaint");
// Workaround for https://github.com/chromiumembedded/cef/issues/2817
if (!is_showing_) {
return;
}
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
CHECK(handler);
gfx::Rect rect_in_pixels(0, 0, pixel_size.width(), pixel_size.height());
rect_in_pixels.Intersect(damage_rect);
CefRenderHandler::RectList rcList;
rcList.emplace_back(rect_in_pixels.x(), rect_in_pixels.y(),
rect_in_pixels.width(), rect_in_pixels.height());
handler->OnAcceleratedPaint(browser_impl_.get(),
IsPopupWidget() ? PET_POPUP : PET_VIEW, rcList,
info);
// Release the resize hold when we reach the desired size.
if (hold_resize_) {
DCHECK_GT(cached_scale_factor_, 0);
gfx::Size expected_size =
gfx::ScaleToCeiledSize(GetViewBounds().size(), cached_scale_factor_);
if (pixel_size == expected_size) {
ReleaseResizeHold();
}
}
}
ui::Layer* CefRenderWidgetHostViewOSR::GetRootLayer() const {
return root_layer_.get();
}

View File

@@ -254,6 +254,9 @@ class CefRenderWidgetHostViewOSR
void OnPaint(const gfx::Rect& damage_rect,
const gfx::Size& pixel_size,
const void* pixels);
void OnAcceleratedPaint(const gfx::Rect& damage_rect,
const gfx::Size& pixel_size,
const CefAcceleratedPaintInfo& info);
void OnBeginFame(base::TimeTicks frame_time);
@@ -401,6 +404,7 @@ class CefRenderWidgetHostViewOSR
uint64_t begin_frame_number_ = viz::BeginFrameArgs::kStartingFrameNumber;
bool begin_frame_pending_ = false;
bool use_shared_texture_ = false;
bool sync_frame_rate_ = false;
bool external_begin_frame_enabled_ = false;
bool needs_external_begin_frames_ = false;

View File

@@ -11,6 +11,12 @@
#include "media/capture/mojom/video_capture_types.mojom.h"
#include "ui/gfx/skbitmap_operations.h"
#if BUILDFLAG(IS_WIN)
#include "ipc/service/gpu_memory_buffer_factory_dxgi.h"
#elif BUILDFLAG(IS_APPLE)
#include "ipc/service/gpu_memory_buffer_factory_io_surface.h"
#endif
namespace {
// Helper to always call Done() at the end of OnFrameCaptured().
@@ -28,8 +34,11 @@ class ScopedVideoFrameDone {
} // namespace
CefVideoConsumerOSR::CefVideoConsumerOSR(CefRenderWidgetHostViewOSR* view)
: view_(view), video_capturer_(view->CreateVideoCapturer()) {
CefVideoConsumerOSR::CefVideoConsumerOSR(CefRenderWidgetHostViewOSR* view,
bool use_shared_texture)
: use_shared_texture_(use_shared_texture),
view_(view),
video_capturer_(view->CreateVideoCapturer()) {
video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB);
// Always use the highest resolution within constraints that doesn't exceed
@@ -45,7 +54,10 @@ CefVideoConsumerOSR::~CefVideoConsumerOSR() = default;
void CefVideoConsumerOSR::SetActive(bool active) {
if (active) {
video_capturer_->Start(this, viz::mojom::BufferFormatPreference::kDefault);
video_capturer_->Start(
this, use_shared_texture_
? viz::mojom::BufferFormatPreference::kPreferGpuMemoryBuffer
: viz::mojom::BufferFormatPreference::kDefault);
} else {
video_capturer_->Stop();
}
@@ -88,6 +100,55 @@ void CefVideoConsumerOSR::OnFrameCaptured(
callbacks) {
ScopedVideoFrameDone scoped_done(std::move(callbacks));
// If it is GPU Texture OSR.
if (use_shared_texture_) {
CHECK(data->is_gpu_memory_buffer_handle() &&
(info->pixel_format == media::PIXEL_FORMAT_ARGB ||
info->pixel_format == media::PIXEL_FORMAT_ABGR));
// The info->pixel_format will tell if the texture is RGBA or BGRA
// On Linux, X11 lacks support for RGBA_8888 so it might be BGRA.
// On Windows and macOS, it should always be RGBA.
auto pixel_format = info->pixel_format == media::PIXEL_FORMAT_ABGR
? CEF_COLOR_TYPE_RGBA_8888
: CEF_COLOR_TYPE_BGRA_8888;
#if BUILDFLAG(IS_WIN)
auto& gmb_handle = data->get_gpu_memory_buffer_handle();
cef_accelerated_paint_info_t paint_info;
paint_info.shared_texture_handle = gmb_handle.dxgi_handle.Get();
paint_info.format = pixel_format;
view_->OnAcceleratedPaint(content_rect, info->coded_size, paint_info);
#elif BUILDFLAG(IS_APPLE)
auto& gmb_handle = data->get_gpu_memory_buffer_handle();
cef_accelerated_paint_info_t paint_info;
paint_info.shared_texture_io_surface = gmb_handle.io_surface.get();
paint_info.format = pixel_format;
view_->OnAcceleratedPaint(content_rect, info->coded_size, paint_info);
#elif BUILDFLAG(IS_LINUX)
auto& gmb_handle = data->get_gpu_memory_buffer_handle();
auto& native_pixmap = gmb_handle.native_pixmap_handle;
CHECK(native_pixmap.planes.size() <= kAcceleratedPaintMaxPlanes);
cef_accelerated_paint_info_t paint_info;
paint_info.plane_count = native_pixmap.planes.size();
paint_info.modifier = native_pixmap.modifier;
paint_info.format = pixel_format;
auto cef_plain_index = 0;
for (const auto& plane : native_pixmap.planes) {
cef_accelerated_paint_native_pixmap_plane_t cef_plane;
cef_plane.stride = plane.stride;
cef_plane.offset = plane.offset;
cef_plane.size = plane.size;
cef_plane.fd = plane.fd.get();
paint_info.planes[cef_plain_index++] = cef_plane;
}
view_->OnAcceleratedPaint(content_rect, info->coded_size, paint_info);
#endif
return;
}
if (info->pixel_format != media::PIXEL_FORMAT_ARGB) {
DLOG(ERROR) << "Unsupported pixel format " << info->pixel_format;
return;

View File

@@ -11,7 +11,8 @@ class CefRenderWidgetHostViewOSR;
class CefVideoConsumerOSR : public viz::mojom::FrameSinkVideoConsumer {
public:
explicit CefVideoConsumerOSR(CefRenderWidgetHostViewOSR* view);
CefVideoConsumerOSR(CefRenderWidgetHostViewOSR* view,
bool use_shared_texture);
CefVideoConsumerOSR(const CefVideoConsumerOSR&) = delete;
CefVideoConsumerOSR& operator=(const CefVideoConsumerOSR&) = delete;
@@ -37,6 +38,8 @@ class CefVideoConsumerOSR : public viz::mojom::FrameSinkVideoConsumer {
void OnNewSubCaptureTargetVersion(
uint32_t sub_capture_target_version) override {}
const bool use_shared_texture_;
CefRenderWidgetHostViewOSR* const view_;
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;

View File

@@ -24,12 +24,14 @@
#include "chrome/browser/media/webrtc/permission_bubble_media_access_handler.h"
#include "chrome/browser/net/profile_network_context_service.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/permissions/quiet_notification_permission_ui_state.h"
#include "chrome/browser/prefs/chrome_command_line_pref_store.h"
#include "chrome/browser/preloading/preloading_prefs.h"
#include "chrome/browser/printing/print_preview_sticky_settings.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ssl/ssl_config_service_manager.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/browser_view_prefs.h"
#include "chrome/browser/ui/webui/accessibility/accessibility_ui.h"
#include "chrome/browser/ui/webui/print_preview/policy_settings.h"
#include "chrome/common/buildflags.h"
@@ -271,6 +273,8 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
prefetch::RegisterPredictionOptionsProfilePrefs(registry.get());
privacy_sandbox::RegisterProfilePrefs(registry.get());
ProfileNetworkContextService::RegisterProfilePrefs(registry.get());
QuietNotificationPermissionUiState::RegisterProfilePrefs(registry.get());
RegisterBrowserViewProfilePrefs(registry.get());
safe_browsing::RegisterProfilePrefs(registry.get());
unified_consent::UnifiedConsentService::RegisterPrefs(registry.get());

View File

@@ -22,6 +22,8 @@
#include "chrome/browser/extensions/extension_webkit_preferences.h"
#include "chrome/browser/font_family_cache.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
@@ -211,9 +213,25 @@ bool UpdatePreferredColorScheme(blink::web_pref::WebPreferences* web_prefs,
const ui::NativeTheme* native_theme) {
auto old_preferred_color_scheme = web_prefs->preferred_color_scheme;
auto preferred_color_scheme = native_theme->GetPreferredColorScheme();
// Based on https://issues.chromium.org/issues/332328864#comment3
auto* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
const auto* theme_service = ThemeServiceFactory::GetForProfile(profile);
const auto browser_color_scheme = theme_service->GetBrowserColorScheme();
if (browser_color_scheme != ThemeService::BrowserColorScheme::kSystem) {
// Override the native theme.
preferred_color_scheme =
browser_color_scheme == ThemeService::BrowserColorScheme::kLight
? ui::NativeTheme::PreferredColorScheme::kLight
: ui::NativeTheme::PreferredColorScheme::kDark;
}
// Update based on native theme scheme.
web_prefs->preferred_color_scheme =
ToBlinkPreferredColorScheme(native_theme->GetPreferredColorScheme());
ToBlinkPreferredColorScheme(preferred_color_scheme);
if (url.SchemeIs(content::kChromeUIScheme)) {
// WebUI should track the color mode of the ColorProvider associated with

View File

@@ -10,12 +10,15 @@
#include "libcef/common/app_manager.h"
#include "libcef/common/task_runner_impl.h"
#include "libcef/common/values_impl.h"
#include "libcef/features/runtime.h"
#include "base/atomic_sequence_num.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_task_traits.h"
@@ -27,6 +30,7 @@
#include "services/network/public/cpp/resolve_host_client_base.h"
#include "services/network/public/mojom/clear_data_filter.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "ui/base/ui_base_features.h"
using content::BrowserThread;
@@ -631,6 +635,72 @@ void CefRequestContextImpl::SetContentSetting(
requesting_url, top_level_url, content_type, value));
}
void CefRequestContextImpl::SetChromeColorScheme(cef_color_variant_t variant,
cef_color_t user_color) {
GetBrowserContext(
content::GetUIThreadTaskRunner({}),
base::BindOnce(&CefRequestContextImpl::SetChromeColorSchemeInternal, this,
variant, user_color));
}
cef_color_variant_t CefRequestContextImpl::GetChromeColorSchemeMode() {
if (!VerifyBrowserContext()) {
return CEF_COLOR_VARIANT_SYSTEM;
}
const auto* theme_service =
ThemeServiceFactory::GetForProfile(browser_context()->AsProfile());
switch (theme_service->GetBrowserColorScheme()) {
case ThemeService::BrowserColorScheme::kSystem:
return CEF_COLOR_VARIANT_SYSTEM;
case ThemeService::BrowserColorScheme::kLight:
return CEF_COLOR_VARIANT_LIGHT;
case ThemeService::BrowserColorScheme::kDark:
return CEF_COLOR_VARIANT_DARK;
}
DCHECK(false); // Not reached.
return CEF_COLOR_VARIANT_SYSTEM;
}
cef_color_t CefRequestContextImpl::GetChromeColorSchemeColor() {
if (!VerifyBrowserContext()) {
return 0;
}
const auto* theme_service =
ThemeServiceFactory::GetForProfile(browser_context()->AsProfile());
if (const auto& user_color = theme_service->GetUserColor()) {
return *user_color;
}
return 0;
}
cef_color_variant_t CefRequestContextImpl::GetChromeColorSchemeVariant() {
if (!VerifyBrowserContext()) {
return CEF_COLOR_VARIANT_SYSTEM;
}
const auto* theme_service =
ThemeServiceFactory::GetForProfile(browser_context()->AsProfile());
switch (theme_service->GetBrowserColorVariant()) {
case ui::mojom::BrowserColorVariant::kSystem:
return CEF_COLOR_VARIANT_SYSTEM;
case ui::mojom::BrowserColorVariant::kTonalSpot:
return CEF_COLOR_VARIANT_TONAL_SPOT;
case ui::mojom::BrowserColorVariant::kNeutral:
return CEF_COLOR_VARIANT_NEUTRAL;
case ui::mojom::BrowserColorVariant::kVibrant:
return CEF_COLOR_VARIANT_VIBRANT;
case ui::mojom::BrowserColorVariant::kExpressive:
return CEF_COLOR_VARIANT_EXPRESSIVE;
}
DCHECK(false); // Not reached.
return CEF_COLOR_VARIANT_SYSTEM;
}
void CefRequestContextImpl::OnRenderFrameCreated(
const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame,
@@ -898,6 +968,90 @@ void CefRequestContextImpl::SetContentSettingInternal(
}
}
void CefRequestContextImpl::SetChromeColorSchemeInternal(
cef_color_variant_t variant,
cef_color_t user_color,
CefBrowserContext::Getter browser_context_getter) {
auto* browser_context = browser_context_getter.Run();
if (!browser_context) {
return;
}
auto* theme_service =
ThemeServiceFactory::GetForProfile(browser_context->AsProfile());
// Possibly set the color scheme.
std::optional<ThemeService::BrowserColorScheme> color_scheme;
switch (variant) {
case CEF_COLOR_VARIANT_SYSTEM:
color_scheme = ThemeService::BrowserColorScheme::kSystem;
break;
case CEF_COLOR_VARIANT_LIGHT:
color_scheme = ThemeService::BrowserColorScheme::kLight;
break;
case CEF_COLOR_VARIANT_DARK:
color_scheme = ThemeService::BrowserColorScheme::kDark;
break;
default:
break;
}
if (color_scheme && *color_scheme != theme_service->GetBrowserColorScheme()) {
// Color scheme has changed.
// Based on CustomizeColorSchemeModeHandler::SetColorSchemeMode.
theme_service->SetBrowserColorScheme(*color_scheme);
}
// Returns nullopt if the current color is SK_ColorTRANSPARENT.
const auto& current_color = theme_service->GetUserColor();
// Possibly set the user color.
if (user_color == 0) {
if (current_color) {
// User color is not currently transparent.
// Based on ThemeColorPickerHandler::SetDefaultColor.
if (features::IsChromeWebuiRefresh2023()) {
theme_service->SetUserColor(SK_ColorTRANSPARENT);
theme_service->UseDeviceTheme(false);
} else {
theme_service->UseDefaultTheme();
}
}
} else {
ui::mojom::BrowserColorVariant ui_variant;
switch (variant) {
case CEF_COLOR_VARIANT_NEUTRAL:
ui_variant = ui::mojom::BrowserColorVariant::kNeutral;
break;
case CEF_COLOR_VARIANT_VIBRANT:
ui_variant = ui::mojom::BrowserColorVariant::kVibrant;
break;
case CEF_COLOR_VARIANT_EXPRESSIVE:
ui_variant = ui::mojom::BrowserColorVariant::kExpressive;
break;
case CEF_COLOR_VARIANT_SYSTEM:
ui_variant = ui::mojom::BrowserColorVariant::kSystem;
break;
default:
ui_variant = ui::mojom::BrowserColorVariant::kTonalSpot;
break;
}
if (!current_color || *current_color != user_color ||
ui_variant != theme_service->GetBrowserColorVariant()) {
// User color and/or variant has changed.
// Based on ThemeColorPickerHandler::SetSeedColor.
if (features::IsChromeWebuiRefresh2023()) {
theme_service->SetUserColorAndBrowserColorVariant(user_color,
ui_variant);
theme_service->UseDeviceTheme(false);
} else {
theme_service->BuildAutogeneratedThemeFromColor(user_color);
}
}
}
}
void CefRequestContextImpl::InitializeCookieManagerInternal(
CefRefPtr<CefCookieManagerImpl> cookie_manager,
CefRefPtr<CefCompletionCallback> callback) {

View File

@@ -131,6 +131,11 @@ class CefRequestContextImpl : public CefRequestContext {
const CefString& top_level_url,
cef_content_setting_types_t content_type,
cef_content_setting_values_t value) override;
void SetChromeColorScheme(cef_color_variant_t variant,
cef_color_t user_color) override;
cef_color_variant_t GetChromeColorSchemeMode() override;
cef_color_t GetChromeColorSchemeColor() override;
cef_color_variant_t GetChromeColorSchemeVariant() override;
const CefRequestContextSettings& settings() const { return config_.settings; }
@@ -205,6 +210,10 @@ class CefRequestContextImpl : public CefRequestContext {
cef_content_setting_types_t content_type,
cef_content_setting_values_t value,
CefBrowserContext::Getter browser_context_getter);
void SetChromeColorSchemeInternal(
cef_color_variant_t variant,
cef_color_t user_color,
CefBrowserContext::Getter browser_context_getter);
void InitializeCookieManagerInternal(
CefRefPtr<CefCookieManagerImpl> cookie_manager,

View File

@@ -80,6 +80,7 @@ void CefBrowserPlatformDelegateViews::WebContentsCreated(
void CefBrowserPlatformDelegateViews::WebContentsDestroyed(
content::WebContents* web_contents) {
CefBrowserPlatformDelegateAlloy::WebContentsDestroyed(web_contents);
browser_view_->WebContentsCreated(web_contents);
native_delegate_->WebContentsDestroyed(web_contents);
}

View File

@@ -13,8 +13,10 @@
#include "libcef/browser/context.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/views/widget.h"
#include "libcef/browser/views/window_impl.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/common/input/native_web_keyboard_event.h"
#include "ui/content_accelerators/accelerator_util.h"
@@ -111,6 +113,16 @@ void CefBrowserViewImpl::WebContentsCreated(
}
}
void CefBrowserViewImpl::WebContentsDestroyed(
content::WebContents* web_contents) {
// This will always be called before BrowserDestroyed().
DisassociateFromWidget();
if (web_view()) {
web_view()->SetWebContents(nullptr);
}
}
void CefBrowserViewImpl::BrowserCreated(
CefBrowserHostBase* browser,
base::RepeatingClosure on_bounds_changed) {
@@ -122,9 +134,9 @@ void CefBrowserViewImpl::BrowserDestroyed(CefBrowserHostBase* browser) {
DCHECK_EQ(browser, browser_);
browser_ = nullptr;
if (web_view()) {
web_view()->SetWebContents(nullptr);
}
// If this BrowserView belonged to a Widget then we expect to have received a
// call to DisassociateFromWidget().
DCHECK(!cef_widget_);
}
bool CefBrowserViewImpl::HandleKeyboardEvent(
@@ -230,6 +242,28 @@ void CefBrowserViewImpl::OnBrowserViewAdded() {
}
}
void CefBrowserViewImpl::AddedToWidget() {
DCHECK(!cef_widget_);
DCHECK(browser_);
views::Widget* widget = root_view()->GetWidget();
DCHECK(widget);
cef_widget_ = CefWidget::GetForWidget(widget);
DCHECK(cef_widget_);
profile_ = Profile::FromBrowserContext(browser_->GetBrowserContext());
DCHECK(profile_);
// May call Widget::ThemeChanged().
cef_widget_->AddAssociatedProfile(profile_);
}
void CefBrowserViewImpl::RemovedFromWidget() {
// With Chrome runtime this may be called after BrowserDestroyed(), in which
// case the following call will be a no-op.
DisassociateFromWidget();
}
void CefBrowserViewImpl::OnBoundsChanged() {
if (!on_bounds_changed_.is_null()) {
on_bounds_changed_.Run();
@@ -369,3 +403,14 @@ bool CefBrowserViewImpl::HandleAccelerator(
void CefBrowserViewImpl::RequestFocusInternal() {
ParentClass::RequestFocus();
}
void CefBrowserViewImpl::DisassociateFromWidget() {
if (!cef_widget_) {
return;
}
// May call Widget::ThemeChanged().
cef_widget_->RemoveAssociatedProfile(profile_);
cef_widget_ = nullptr;
profile_ = nullptr;
}

View File

@@ -18,8 +18,10 @@
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
class CefBrowserHostBase;
class CefWidget;
class CefWindowImpl;
class ChromeBrowserView;
class Profile;
class CefBrowserViewImpl
: public CefViewImpl<views::View, CefBrowserView, CefBrowserViewDelegate>,
@@ -48,8 +50,9 @@ class CefBrowserViewImpl
const CefBrowserSettings& settings,
CefRefPtr<CefBrowserViewDelegate> delegate);
// Called from CefBrowserPlatformDelegateViews.
// Called from CefBrowserPlatformDelegate[Chrome]Views.
void WebContentsCreated(content::WebContents* web_contents);
void WebContentsDestroyed(content::WebContents* web_contents);
void BrowserCreated(CefBrowserHostBase* browser,
base::RepeatingClosure on_bounds_changed);
void BrowserDestroyed(CefBrowserHostBase* browser);
@@ -75,6 +78,8 @@ class CefBrowserViewImpl
// CefBrowserViewView::Delegate methods:
void OnBrowserViewAdded() override;
void AddedToWidget() override;
void RemovedFromWidget() override;
void OnBoundsChanged() override;
bool OnGestureEvent(ui::GestureEvent* event) override;
@@ -115,6 +120,8 @@ class CefBrowserViewImpl
void RequestFocusInternal();
void DisassociateFromWidget();
std::unique_ptr<CefBrowserCreateParams> pending_browser_create_params_;
CefRefPtr<CefBrowserHostBase> browser_;
@@ -124,6 +131,9 @@ class CefBrowserViewImpl
base::RepeatingClosure on_bounds_changed_;
CefWidget* cef_widget_ = nullptr;
Profile* profile_ = nullptr;
base::WeakPtrFactory<CefBrowserViewImpl> weak_ptr_factory_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefBrowserViewImpl);

View File

@@ -45,3 +45,13 @@ void CefBrowserViewView::OnGestureEvent(ui::GestureEvent* event) {
}
ParentClass::OnGestureEvent(event);
}
void CefBrowserViewView::AddedToWidget() {
ParentClass::AddedToWidget();
browser_view_delegate_->AddedToWidget();
}
void CefBrowserViewView::RemovedFromWidget() {
ParentClass::RemovedFromWidget();
browser_view_delegate_->RemovedFromWidget();
}

View File

@@ -38,6 +38,10 @@ class CefBrowserViewView
// Called when the BrowserView has been added to a parent view.
virtual void OnBrowserViewAdded() = 0;
// Called when the BrowserView is added or removed from a Widget.
virtual void AddedToWidget() = 0;
virtual void RemovedFromWidget() = 0;
// Called when the BrowserView bounds have changed.
virtual void OnBoundsChanged() = 0;
@@ -59,6 +63,8 @@ class CefBrowserViewView
const views::ViewHierarchyChangedDetails& details) override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
void OnGestureEvent(ui::GestureEvent* event) override;
void AddedToWidget() override;
void RemovedFromWidget() override;
private:
// Not owned by this object.

View File

@@ -79,13 +79,14 @@ CEF_BUTTON_IMPL_T cef_button_state_t CEF_BUTTON_IMPL_D::GetState() {
CEF_BUTTON_IMPL_T void CEF_BUTTON_IMPL_D::SetInkDropEnabled(bool enabled) {
CEF_REQUIRE_VALID_RETURN_VOID();
views::InkDrop::Get(ParentClass::root_view())
->SetMode(enabled ? views::InkDropHost::InkDropMode::ON
: views::InkDropHost::InkDropMode::OFF);
auto* inkdrop = views::InkDrop::Get(ParentClass::root_view());
inkdrop->SetMode(enabled ? views::InkDropHost::InkDropMode::ON
: views::InkDropHost::InkDropMode::OFF);
if (enabled) {
views::InkDrop::Get(ParentClass::root_view())
->SetBaseColor(color_utils::BlendTowardMaxContrast(
ParentClass::GetBackgroundColor(), 0x61));
// Never returns an empty value.
const auto& color = view_util::GetBackgroundColor(
ParentClass::root_view(), /*allow_transparent=*/false);
inkdrop->SetBaseColor(color_utils::BlendTowardMaxContrast(*color, 0x61));
}
}

View File

@@ -12,6 +12,7 @@
#include "libcef/browser/views/view_view.h"
#include "base/logging.h"
#include "ui/gfx/color_utils.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/controls/button/button.h"
@@ -41,6 +42,9 @@ CEF_BUTTON_VIEW_T class CefButtonView : public CEF_VIEW_VIEW_D {
return button;
}
// views::View methods:
void OnThemeChanged() override;
// views::Button methods:
void StateChanged(views::Button::ButtonState old_state) override;
@@ -48,6 +52,18 @@ CEF_BUTTON_VIEW_T class CefButtonView : public CEF_VIEW_VIEW_D {
void ButtonPressed(const ui::Event& event) override;
};
CEF_BUTTON_VIEW_T void CEF_BUTTON_VIEW_D::OnThemeChanged() {
ParentClass::OnThemeChanged();
auto* inkdrop = views::InkDrop::Get(this);
if (inkdrop->ink_drop_mode() != views::InkDropHost::InkDropMode::OFF) {
// Never returns an empty value.
const auto& color =
view_util::GetBackgroundColor(this, /*allow_transparent=*/false);
inkdrop->SetBaseColor(color_utils::BlendTowardMaxContrast(*color, 0x61));
}
}
CEF_BUTTON_VIEW_T void CEF_BUTTON_VIEW_D::StateChanged(
views::Button::ButtonState old_state) {
ParentClass::StateChanged(old_state);

View File

@@ -0,0 +1,28 @@
// 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/views/color_provider_tracker.h"
#include "base/check.h"
CefColorProviderTracker::CefColorProviderTracker(Observer* observer)
: observer_(observer) {
DCHECK(observer_);
color_provider_observation_.Observe(&ui::ColorProviderManager::Get());
}
void CefColorProviderTracker::OnNativeThemeUpdated() {
got_theme_updated_ = true;
}
void CefColorProviderTracker::OnColorProviderCacheReset() {
// May be followed by a call to OnNativeThemeUpdated.
got_theme_updated_ = false;
}
void CefColorProviderTracker::OnAfterNativeThemeUpdated() {
if (!got_theme_updated_) {
observer_->OnColorProviderCacheResetMissed();
}
}

View File

@@ -0,0 +1,63 @@
// 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_VIEWS_COLOR_PROVIDER_TRACKER_H_
#define CEF_LIBCEF_BROWSER_VIEWS_COLOR_PROVIDER_TRACKER_H_
#pragma once
#include "base/scoped_observation.h"
#include "ui/color/color_provider_manager.h"
// Color registrations are managed by the global ColorProviderManager object.
// When the system theme changes (e.g. NativeThemeWin::UpdateDarkModeStatus or
// NativeThemeWin::OnSysColorChange is called) all existing platform NativeTheme
// objects (NativeTheme[Win|Mac|Gtk]) are notified. They then call
// NativeTheme::NotifyOnNativeThemeUpdated which calls
// ColorProviderManager::ResetColorProviderCache, followed by
// OnNativeThemeUpdated for each registered Widget, followed by
// ColorProviderManager::AfterNativeThemeUpdated. The problem is that Chromium
// creates multiple NativeTheme objects but each Widget only registers as an
// Observer for the one returned via Widget::GetNativeTheme. If a different
// NativeTheme is the last caller of ResetColorProviderCache then we don't get
// an opportunity to reapply global color overrides in the Widget's
// OnNativeThemeChanged callback. To work around this problem each Widget owns a
// Tracker object. The Tracker explicitly registers as an Observer on the
// ColorProviderManager to get callbacks from ResetColorProviderCache and
// AfterNativeThemeUpdated. If OnNativeThemeUpdated is not called for the Widget
// (which otherwise forwards the call to the Tracker) then the Tracker will call
// OnColorProviderCacheResetMissed from OnAfterNativeThemeUpdated.
class CefColorProviderTracker : public ui::ColorProviderManagerObserver {
public:
class Observer {
public:
// Called when the color provider cache is reset without a follow-up call to
// OnNativeThemeUpdated.
virtual void OnColorProviderCacheResetMissed() {}
protected:
virtual ~Observer() = default;
};
explicit CefColorProviderTracker(Observer* observer);
CefColorProviderTracker(const CefColorProviderTracker&) = delete;
CefColorProviderTracker& operator=(const CefColorProviderTracker&) = delete;
// Notify us when OnNativeThemeUpdated is called.
void OnNativeThemeUpdated();
private:
// ui::ColorProviderManagerObserver methods:
void OnColorProviderCacheReset() override;
void OnAfterNativeThemeUpdated() override;
Observer* const observer_;
bool got_theme_updated_ = false;
base::ScopedObservation<ui::ColorProviderManager,
ui::ColorProviderManagerObserver>
color_provider_observation_{this};
};
#endif // CEF_LIBCEF_BROWSER_VIEWS_COLOR_PROVIDER_TRACKER_H_

View File

@@ -87,10 +87,12 @@ NativeWidgetMacNSWindow* CefNativeWidgetMac::CreateNSWindow(
NSWindowStyleMaskClosable | NSWindowStyleMaskResizable |
NSWindowStyleMaskTexturedBackground;
bool is_frameless = window_delegate_->IsFrameless(window_);
const bool is_frameless = window_delegate_->IsFrameless(window_);
const auto accepts_first_mouse = window_delegate_->AcceptsFirstMouse(window_);
auto window = [[CefNSWindow alloc] initWithStyle:style_mask
isFrameless:is_frameless];
isFrameless:is_frameless
acceptsFirstMouse:accepts_first_mouse];
if (is_frameless) {
[window setTitlebarAppearsTransparent:YES];

View File

@@ -6,15 +6,22 @@
#define CEF_LIBCEF_BROWSER_VIEWS_NS_WINDOW_H_
#pragma once
#include "include/internal/cef_types.h"
#include "components/remote_cocoa/app_shim/native_widget_mac_nswindow.h"
@interface CefNSWindow : NativeWidgetMacNSWindow {
@private
bool is_frameless_;
cef_state_t accepts_first_mouse_;
}
- (id)initWithStyle:(NSUInteger)style_mask isFrameless:(bool)is_frameless;
- (id)initWithStyle:(NSUInteger)style_mask
isFrameless:(bool)is_frameless
acceptsFirstMouse:(cef_state_t)accepts_first_mouse;
- (BOOL)shouldCenterTrafficLights;
- (int)acceptsFirstMouse;
@end
#endif // CEF_LIBCEF_BROWSER_VIEWS_NS_WINDOW_H_

View File

@@ -64,12 +64,15 @@
@implementation CefNSWindow
- (id)initWithStyle:(NSUInteger)style_mask isFrameless:(bool)is_frameless {
- (id)initWithStyle:(NSUInteger)style_mask
isFrameless:(bool)is_frameless
acceptsFirstMouse:(cef_state_t)accepts_first_mouse {
if ((self = [super initWithContentRect:ui::kWindowSizeDeterminedLater
styleMask:style_mask
backing:NSBackingStoreBuffered
defer:NO])) {
is_frameless_ = is_frameless;
accepts_first_mouse_ = accepts_first_mouse;
}
return self;
}
@@ -102,4 +105,8 @@
return [super frameViewClassForStyleMask:windowStyle];
}
- (int)acceptsFirstMouse {
return accepts_first_mouse_;
}
@end

View File

@@ -31,7 +31,8 @@ class CefOverlayControllerImpl : public CefOverlayController {
}
bool IsSame(CefRefPtr<CefOverlayController> that) override {
return that && that->GetContentsView()->IsSame(view_);
return IsValid() && that && that->IsValid() &&
that->GetContentsView()->IsSame(view_);
}
CefRefPtr<CefView> GetContentsView() override { return view_; }
@@ -52,11 +53,17 @@ class CefOverlayControllerImpl : public CefOverlayController {
void Destroy() override {
if (IsValid()) {
host_->Destroy();
view_ = nullptr;
// Results in a call to Destroyed().
host_->Close();
host_ = nullptr;
}
}
void Destroyed() {
DCHECK(view_);
view_ = nullptr;
}
void SetBounds(const CefRect& bounds) override {
if (IsValid() && host_->docking_mode() == CEF_DOCKING_MODE_CUSTOM) {
host_->SetOverlayBounds(
@@ -155,7 +162,7 @@ class CefOverlayControllerImpl : public CefOverlayController {
bool IsDrawn() override { return IsVisible(); }
private:
CefOverlayViewHost* const host_;
CefOverlayViewHost* host_;
CefRefPtr<CefView> view_;
IMPLEMENT_REFCOUNTING(CefOverlayControllerImpl);
@@ -180,7 +187,8 @@ void CefOverlayViewHost::Init(views::View* host_view,
cef_controller_ = new CefOverlayControllerImpl(this, view);
// Initialize the Widget.
// Initialize the Widget. |widget_| will be deleted by the NativeWidget or
// when WidgetDelegate::DeleteDelegate() deletes |this|.
widget_ = std::make_unique<ThemeCopyingWidget>(window_view_->GetWidget());
views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
params.delegate = this;
@@ -193,13 +201,23 @@ void CefOverlayViewHost::Init(views::View* host_view,
: views::Widget::InitParams::Activatable::kNo;
widget_->Init(std::move(params));
// |widget_| should now be associated with |this|.
DCHECK_EQ(widget_.get(), GetWidget());
// Make the Widget background transparent. The View might still be opaque.
if (widget_->GetCompositor()) {
widget_->GetCompositor()->SetBackgroundColor(SK_ColorTRANSPARENT);
}
host_view_ = host_view;
view_util::SetHostView(widget_.get(), host_view);
// Cause WidgetDelegate::DeleteDelegate() to delete |this| after executing the
// registered DeleteDelegate callback.
SetOwnedByWidget(true);
RegisterDeleteDelegateCallback(
base::BindOnce(&CefOverlayViewHost::Cleanup, base::Unretained(this)));
if (cef::IsChromeRuntimeEnabled()) {
// Some attributes associated with a Chrome toolbar are located via the
// Widget. See matching logic in BrowserView::AddedToWidget.
@@ -239,15 +257,12 @@ void CefOverlayViewHost::Init(views::View* host_view,
widget_->Hide();
}
void CefOverlayViewHost::Destroy() {
void CefOverlayViewHost::Close() {
if (widget_ && !widget_->IsClosed()) {
// Remove the child View immediately. It may be reused by the client.
auto view = view_util::GetFor(view_, /*find_known_parent=*/false);
widget_->GetContentsView()->RemoveChildView(view_);
if (view) {
view_util::ResumeOwnership(view);
}
// Remove all references ASAP, before the Widget is destroyed.
Cleanup();
// Eventually calls DeleteDelegate().
widget_->Close();
}
}
@@ -333,3 +348,37 @@ gfx::Rect CefOverlayViewHost::ComputeBounds() const {
return gfx::Rect(x, y, prefsize.width(), prefsize.height());
}
void CefOverlayViewHost::Cleanup() {
// This method may be called multiple times. For example, explicitly after the
// client calls CefOverlayController::Destroy or implicitly when the host
// Widget is being closed or destroyed. In most implicit cases
// CefWindowView::WindowClosing will call this before the host Widget is
// destroyed, allowing the client to optionally reuse the child View. However,
// if CefWindowView::WindowClosing is not called, DeleteDelegate will call
// this after the host Widget and all associated Widgets/Views have been
// destroyed. In the DeleteDelegate case |widget_| will return nullptr.
if (view_ && widget_) {
// Remove the child View immediately. It may be reused by the client.
auto view = view_util::GetFor(view_, /*find_known_parent=*/false);
widget_->GetContentsView()->RemoveChildView(view_);
if (view) {
view_util::ResumeOwnership(view);
}
view_->RemoveObserver(this);
view_ = nullptr;
}
if (cef_controller_) {
CefOverlayControllerImpl* controller_impl =
static_cast<CefOverlayControllerImpl*>(cef_controller_.get());
controller_impl->Destroyed();
cef_controller_ = nullptr;
}
if (window_view_) {
window_view_->RemoveOverlayView(this, host_view_);
window_view_ = nullptr;
host_view_ = nullptr;
}
}

View File

@@ -12,6 +12,7 @@
#include "include/views/cef_view.h"
#include "ui/views/view_observer.h"
#include "ui/views/widget/unique_widget_ptr.h"
#include "ui/views/widget/widget_delegate.h"
class CefWindowView;
@@ -34,7 +35,7 @@ class CefOverlayViewHost : public views::WidgetDelegate,
// relative to views with layers and views with associated NativeViews.
void Init(views::View* host_view, CefRefPtr<CefView> view, bool can_activate);
void Destroy();
void Close();
void MoveIfNecessary();
@@ -55,17 +56,22 @@ class CefOverlayViewHost : public views::WidgetDelegate,
private:
gfx::Rect ComputeBounds() const;
void Cleanup();
// The CefWindowView that created us.
CefWindowView* const window_view_;
CefWindowView* window_view_;
const cef_docking_mode_t docking_mode_;
// The host view that the overlay is positioned relative to.
views::View* host_view_ = nullptr;
// Our view, which is responsible for drawing the UI.
views::View* view_ = nullptr;
// The Widget implementation that is created and maintained by the overlay.
// It contains |view_|.
std::unique_ptr<views::Widget> widget_;
views::UniqueWidgetPtr widget_;
CefRefPtr<CefOverlayController> cef_controller_;

View File

@@ -298,6 +298,7 @@
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/values.h"
#include "ui/gfx/color_palette.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/view.h"
@@ -403,6 +404,7 @@ CEF_VIEW_IMPL_T class CefViewImpl : public CefViewAdapter, public CefViewClass {
void RequestFocus() override;
void SetBackgroundColor(cef_color_t color) override;
cef_color_t GetBackgroundColor() override;
cef_color_t GetThemeColor(int color_id) override;
bool ConvertPointToScreen(CefPoint& point) override;
bool ConvertPointFromScreen(CefPoint& point) override;
bool ConvertPointToWindow(CefPoint& point) override;
@@ -679,11 +681,19 @@ CEF_VIEW_IMPL_T void CEF_VIEW_IMPL_D::SetBackgroundColor(cef_color_t color) {
}
CEF_VIEW_IMPL_T cef_color_t CEF_VIEW_IMPL_D::GetBackgroundColor() {
CEF_REQUIRE_VALID_RETURN(0U);
if (root_view()->background()) {
return root_view()->background()->get_color();
CEF_REQUIRE_VALID_RETURN(gfx::kPlaceholderColor);
// May return an empty value.
const auto& color =
view_util::GetBackgroundColor(root_view(), /*allow_transparency=*/true);
if (color) {
return *color;
}
return view_util::GetColor(root_view(), ui::kColorPrimaryBackground);
return SK_ColorTRANSPARENT;
}
CEF_VIEW_IMPL_T cef_color_t CEF_VIEW_IMPL_D::GetThemeColor(int color_id) {
CEF_REQUIRE_VALID_RETURN(gfx::kPlaceholderColor);
return view_util::GetColor(root_view(), color_id);
}
CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointToScreen(CefPoint& point) {

View File

@@ -6,8 +6,13 @@
#include <utility>
#include "include/cef_color_ids.h"
#include "libcef/browser/views/view_adapter.h"
#include "libcef/browser/views/widget.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "ui/color/color_provider.h"
#include "ui/color/color_provider_manager.h"
#include "ui/display/display.h"
@@ -15,6 +20,7 @@
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/background.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/window/non_client_view.h"
@@ -341,14 +347,72 @@ bool ConvertPointFromWindow(views::View* view, gfx::Point* point) {
return true;
}
SkColor GetColor(views::View* view, ui::ColorId id) {
SkColor GetColor(const views::View* view, ui::ColorId id) {
// Verify that our enum matches Chromium's values.
static_assert(static_cast<int>(CEF_ChromeColorsEnd) ==
static_cast<int>(kChromeColorsEnd),
"enum mismatch");
// |color_provider| will be nullptr if |view| has not yet been added to a
// Widget.
if (auto color_provider = view->GetColorProvider()) {
if (const auto* color_provider = view->GetColorProvider()) {
return color_provider->GetColor(id);
}
return GetDefaultColorProvider()->GetColor(id);
}
void SetColor(views::View* view, ui::ColorId id, SkColor color) {
auto* color_provider = view->GetColorProvider();
if (!color_provider) {
color_provider = GetDefaultColorProvider();
}
if (color_provider) {
color_provider->SetColorForTesting(id, color);
}
}
std::optional<SkColor> GetBackgroundColor(const views::View* view,
bool allow_transparent) {
// Return the configured background color, if any.
if (view->background()) {
return view->background()->get_color();
}
// If the containing Widget is an overlay then it has a transparent background
// by default.
if (allow_transparent) {
const bool is_overlay_hosted =
view->GetWidget() && GetHostView(view->GetWidget()) != nullptr;
if (is_overlay_hosted) {
return std::nullopt;
}
}
// Return the default background color.
return GetColor(view, ui::kColorPrimaryBackground);
}
bool ShouldUseDarkTheme(views::Widget* widget) {
DCHECK(widget);
Profile* profile = nullptr;
if (auto* cef_widget = CefWidget::GetForWidget(widget)) {
profile = cef_widget->GetThemeProfile();
}
if (profile) {
const auto* theme_service = ThemeServiceFactory::GetForProfile(profile);
const auto browser_color_scheme = theme_service->GetBrowserColorScheme();
if (browser_color_scheme != ThemeService::BrowserColorScheme::kSystem) {
// Override the native theme value.
return browser_color_scheme == ThemeService::BrowserColorScheme::kDark;
}
}
// Use the native theme value.
return widget->GetNativeTheme()->ShouldUseDarkColors();
}
} // namespace view_util

View File

@@ -6,6 +6,8 @@
#define CEF_LIBCEF_BROWSER_VIEWS_VIEW_UTIL_H_
#pragma once
#include <optional>
#include "include/views/cef_view.h"
#include "include/views/cef_window.h"
@@ -159,16 +161,33 @@ views::NativeWidget* CreateNativeWidget(
// whose position in the view hierarchy determines the z-order of the widget
// relative to views with layers and views with associated NativeViews.
void SetHostView(views::Widget* widget, views::View* host_view);
views::View* GetHostView(views::Widget* widget);
views::View* GetHostView(const views::Widget* widget);
#if BUILDFLAG(IS_MAC)
float GetNSWindowTitleBarHeight(views::Widget* widget);
#endif
// Returns the mixer color for |id|. If |view| has been added to a Widget it
// will use the Widget's ColorProvider, otherwise it will use the default theme
// will use the Widget's ColorProvider, otherwise it will use the global theme
// ColorProvider. Returns gfx::kPlaceholderColor if |id| cannot be constructed.
SkColor GetColor(views::View* view, ui::ColorId id);
SkColor GetColor(const views::View* view, ui::ColorId id);
// Sets the color associated with |id|. If |view| has been added to a Widget it
// will use the Widget's ColorProvider, otherwise it will use the global theme
// ColorProvider.
void SetColor(views::View* view, ui::ColorId id, SkColor color);
// Returns the currently configured background color for |view|. If
// |allow_transparent| is true then it may return an empty value to indicate
// transparency.
std::optional<SkColor> GetBackgroundColor(const views::View* view,
bool allow_transparent);
// Returns true if dark theme should be used for |widget|.
bool ShouldUseDarkTheme(views::Widget* widget);
// Updates the titlebar light/dark theme for |widget|.
void UpdateTitlebarTheme(views::Widget* widget);
} // namespace view_util

View File

@@ -11,6 +11,13 @@
#include "ui/views/widget/native_widget_delegate.h"
#include "ui/views/widget/widget.h"
#if BUILDFLAG(IS_WIN)
#include <dwmapi.h>
#include "base/win/windows_version.h"
#include "ui/views/win/hwnd_util.h"
#endif
namespace view_util {
gfx::NativeWindow GetNativeWindow(views::Widget* widget) {
@@ -54,8 +61,79 @@ void SetHostView(views::Widget* widget, views::View* host_view) {
widget->GetNativeView()->SetProperty(views::kHostViewKey, host_view);
}
views::View* GetHostView(views::Widget* widget) {
views::View* GetHostView(const views::Widget* widget) {
return widget->GetNativeView()->GetProperty(views::kHostViewKey);
}
void UpdateTitlebarTheme(views::Widget* widget) {
#if BUILDFLAG(IS_WIN)
// Value was 19 prior to Windows 10 20H1, according to
// https://stackoverflow.com/a/70693198
const DWORD dwAttribute =
base::win::GetVersion() >= base::win::Version::WIN10_20H1
? DWMWA_USE_IMMERSIVE_DARK_MODE
: 19;
const HWND widget_hwnd = views::HWNDForWidget(widget);
BOOL has_dark_titlebar = FALSE;
DwmGetWindowAttribute(widget_hwnd, dwAttribute, &has_dark_titlebar,
sizeof(has_dark_titlebar));
const BOOL dark_titlebar_enabled = ShouldUseDarkTheme(widget);
if (has_dark_titlebar == dark_titlebar_enabled) {
// No change required.
return;
}
// From BrowserFrameViewWin::SetSystemMicaTitlebarAttributes.
DwmSetWindowAttribute(widget_hwnd, dwAttribute, &dark_titlebar_enabled,
sizeof(dark_titlebar_enabled));
// Repaint the titlebar if the Widget is visible. None of the usual NC
// repaint techniques work with DwmSetWindowAttribute so use a workaround
// that nudges the window width.
// See https://stackoverflow.com/a/78269906/23991994
if (IsWindowVisible(widget_hwnd) && !IsIconic(widget_hwnd)) {
RECT rect = {};
::GetWindowRect(widget_hwnd, &rect);
if (IsZoomed(widget_hwnd)) {
// Window is currently maximized. Restore and then re-maximize the
// window. The restore position is changed temporarily to make the
// update less noticeable.
WINDOWPLACEMENT placement = {};
GetWindowPlacement(widget_hwnd, &placement);
const RECT oldrect = placement.rcNormalPosition;
placement.rcNormalPosition = rect;
placement.rcNormalPosition.right -= 1;
SetWindowPlacement(widget_hwnd, &placement);
LockWindowUpdate(widget_hwnd);
ShowWindow(widget_hwnd, SW_SHOWNORMAL);
ShowWindow(widget_hwnd, SW_SHOWMAXIMIZED);
LockWindowUpdate(nullptr);
placement.rcNormalPosition = oldrect;
SetWindowPlacement(widget_hwnd, &placement);
} else {
// Window is currently normal. Change and then restore the window width.
// Use Defer functions to make the update less noticeable.
HDWP defer = BeginDeferWindowPos(2);
DeferWindowPos(defer, widget_hwnd, NULL, 0, 0, rect.right - rect.left - 1,
rect.bottom - rect.top,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
DeferWindowPos(defer, widget_hwnd, NULL, 0, 0, rect.right - rect.left,
rect.bottom - rect.top,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
LockWindowUpdate(widget_hwnd);
EndDeferWindowPos(defer);
LockWindowUpdate(nullptr);
}
}
#endif // BUILDFLAG(IS_WIN)
}
} // namespace view_util

View File

@@ -20,6 +20,13 @@ constexpr char kNativeHostViewKey[] = "CefNativeHostViewKey";
// For Venura 13.3.1.
constexpr float kDefaultTitleBarHeight = 30;
NSWindow* GetNSWindow(views::Widget* widget) {
if (const auto& window = GetNativeWindow(widget)) {
return window.GetNativeNSWindow();
}
return nil;
}
} // namespace
gfx::NativeWindow GetNativeWindow(views::Widget* widget) {
@@ -65,18 +72,33 @@ void SetHostView(views::Widget* widget, views::View* host_view) {
widget->SetNativeWindowProperty(kNativeHostViewKey, host_view);
}
views::View* GetHostView(views::Widget* widget) {
views::View* GetHostView(const views::Widget* widget) {
return static_cast<views::View*>(
widget->GetNativeWindowProperty(kNativeHostViewKey));
}
float GetNSWindowTitleBarHeight(views::Widget* widget) {
if (auto window = GetNativeWindow(widget)) {
NSWindow* nswindow = window.GetNativeNSWindow();
return nswindow.frame.size.height -
[nswindow contentRectForFrameRect:nswindow.frame].size.height;
if (NSWindow* window = GetNSWindow(widget)) {
return window.frame.size.height -
[window contentRectForFrameRect:window.frame].size.height;
}
return kDefaultTitleBarHeight;
}
void UpdateTitlebarTheme(views::Widget* widget) {
NSWindow* window = GetNSWindow(widget);
if (!window) {
return;
}
auto* light = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
auto* dark = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
const bool should_use_dark = ShouldUseDarkTheme(widget);
auto* desired = should_use_dark ? dark : light;
if (window.appearance != desired) {
window.appearance = desired;
}
}
} // namespace view_util

View File

@@ -225,17 +225,13 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::OnThemeChanged() {
cef_delegate()->OnThemeChanged(GetCefView());
}
// If the background is still unset, and the containing Widget is not an
// overlay (which has transparent background), then set the background based
// on the current theme.
// If the background is still unset then possibly set it to the desired value.
if (!ParentClass::background()) {
const bool is_overlay_hosted =
ParentClass::GetWidget() &&
view_util::GetHostView(ParentClass::GetWidget()) != nullptr;
if (!is_overlay_hosted) {
const SkColor color =
view_util::GetColor(this, ui::kColorPrimaryBackground);
ParentClass::SetBackground(views::CreateSolidBackground(color));
// May return an empty value.
const auto& color =
view_util::GetBackgroundColor(this, /*allow_transparent=*/true);
if (color) {
ParentClass::SetBackground(views::CreateSolidBackground(*color));
}
}
}

View File

@@ -0,0 +1,24 @@
// 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/views/widget.h"
#include "libcef/browser/chrome/views/chrome_browser_frame.h"
#include "libcef/browser/views/widget_impl.h"
// static
CefWidget* CefWidget::Create(CefWindowView* window_view) {
if (cef::IsChromeRuntimeEnabled()) {
return new ChromeBrowserFrame(window_view);
}
return new CefWidgetImpl(window_view);
}
// static
CefWidget* CefWidget::GetForWidget(views::Widget* widget) {
if (cef::IsChromeRuntimeEnabled()) {
return static_cast<ChromeBrowserFrame*>(widget);
}
return static_cast<CefWidgetImpl*>(widget);
}

View File

@@ -0,0 +1,60 @@
// 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_VIEWS_WIDGET_H_
#define CEF_LIBCEF_BROWSER_VIEWS_WIDGET_H_
#pragma once
class CefWindowView;
class Profile;
namespace views {
class Widget;
}
// Interface that provides access to common CEF-specific Widget functionality.
// Alloy and Chrome runtimes use different views::Widget inheritance so we can't
// cast types directly. Implemented by CefWidgetImpl for the Alloy runtime and
// ChromeBrowserFrame for the Chrome runtime.
class CefWidget {
public:
// Called from CefWindowView::CreateWidget.
static CefWidget* Create(CefWindowView* window_view);
// Returns the CefWidget for |widget|, which must be Views-hosted.
static CefWidget* GetForWidget(views::Widget* widget);
// Returns the Widget associated with this object.
virtual views::Widget* GetWidget() = 0;
virtual const views::Widget* GetWidget() const = 0;
// Called from CefWindowView::CreateWidget after Widget::Init. There will be
// no theme-related callbacks prior to this method being called.
virtual void Initialized() = 0;
// Returns true if Initialize() has been called.
virtual bool IsInitialized() const = 0;
// Track all Profiles associated with this Widget. Called from
// CefBrowserViewImpl::AddedToWidget and DisassociateFromWidget.
// |profile| is only used with the Alloy runtime.
virtual void AddAssociatedProfile(Profile* profile) = 0;
virtual void RemoveAssociatedProfile(Profile* profile) = 0;
// Returns the Profile that will be used for Chrome theme purposes. Chrome
// runtime supports a single BrowserView in a single Widget. Alloy runtime
// supports multiple BrowserViews in a single Widget, and those BrowserViews
// may have different Profiles. If there are multiple Profiles we return an
// arbitrary one. The returned Profile will remain consistent until the set of
// associated Profiles changes.
virtual Profile* GetThemeProfile() const = 0;
// Optional special handling to toggle full-screen mode.
virtual bool ToggleFullscreenMode() { return false; }
protected:
virtual ~CefWidget() = default;
};
#endif // CEF_LIBCEF_BROWSER_VIEWS_WIDGET_H_

View File

@@ -0,0 +1,264 @@
// 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/views/widget_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/views/window_view.h"
#include "libcef/features/runtime.h"
#include "chrome/browser/themes/custom_theme_supplier.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#if BUILDFLAG(IS_LINUX)
#include "ui/linux/linux_ui.h"
#endif
namespace {
ui::ColorProviderKey::SchemeVariant GetSchemeVariant(
ui::mojom::BrowserColorVariant color_variant) {
using BCV = ui::mojom::BrowserColorVariant;
using SV = ui::ColorProviderKey::SchemeVariant;
static constexpr auto kSchemeVariantMap = base::MakeFixedFlatMap<BCV, SV>({
{BCV::kTonalSpot, SV::kTonalSpot},
{BCV::kNeutral, SV::kNeutral},
{BCV::kVibrant, SV::kVibrant},
{BCV::kExpressive, SV::kExpressive},
});
return kSchemeVariantMap.at(color_variant);
}
} // namespace
CefWidgetImpl::CefWidgetImpl(CefWindowView* window_view)
: window_view_(window_view) {}
CefWidgetImpl::~CefWidgetImpl() {
DCHECK(associated_profiles_.empty());
}
void CefWidgetImpl::Initialized() {
initialized_ = true;
// Based on BrowserFrame::InitBrowserFrame.
// This is the first call that will trigger theme-related client callbacks.
#if BUILDFLAG(IS_LINUX)
// Calls ThemeChanged() or OnNativeThemeUpdated().
SelectNativeTheme();
#else
// Calls ThemeChanged().
SetNativeTheme(ui::NativeTheme::GetInstanceForNativeUi());
#endif
}
void CefWidgetImpl::AddAssociatedProfile(Profile* profile) {
DCHECK(profile);
ProfileMap::iterator it = associated_profiles_.find(profile);
if (it != associated_profiles_.end()) {
// Another instance of a known Profile.
(it->second)++;
return;
}
auto* current_profile = GetThemeProfile();
associated_profiles_.insert(std::make_pair(profile, 1));
if (auto* theme_service = ThemeServiceFactory::GetForProfile(profile)) {
theme_service->AddObserver(this);
}
auto* new_profile = GetThemeProfile();
if (new_profile != current_profile) {
// Switching to a different theme.
NotifyThemeColorsChanged(/*chrome_theme=*/!!new_profile,
/*call_theme_changed=*/true);
}
}
void CefWidgetImpl::RemoveAssociatedProfile(Profile* profile) {
DCHECK(profile);
ProfileMap::iterator it = associated_profiles_.find(profile);
if (it == associated_profiles_.end()) {
DCHECK(false); // Not reached.
return;
}
if (--(it->second) > 0) {
// More instances of the Profile exist.
return;
}
auto* current_profile = GetThemeProfile();
associated_profiles_.erase(it);
if (auto* theme_service = ThemeServiceFactory::GetForProfile(profile)) {
theme_service->RemoveObserver(this);
}
auto* new_profile = GetThemeProfile();
if (new_profile != current_profile) {
// Switching to a different theme.
NotifyThemeColorsChanged(/*chrome_theme=*/!!new_profile,
/*call_theme_changed=*/true);
}
}
Profile* CefWidgetImpl::GetThemeProfile() const {
if (!associated_profiles_.empty()) {
return associated_profiles_.begin()->first;
}
return nullptr;
}
const ui::ThemeProvider* CefWidgetImpl::GetThemeProvider() const {
auto* profile = GetThemeProfile();
if (!profile) {
return Widget::GetThemeProvider();
}
// Based on BrowserFrame::GetThemeProvider.
return &ThemeService::GetThemeProviderForProfile(profile);
}
ui::ColorProviderKey::ThemeInitializerSupplier* CefWidgetImpl::GetCustomTheme()
const {
auto* profile = GetThemeProfile();
if (!profile) {
return Widget::GetCustomTheme();
}
// Based on BrowserFrame::GetCustomTheme.
auto* theme_service = ThemeServiceFactory::GetForProfile(profile);
return theme_service->UsingDeviceTheme() ? nullptr
: theme_service->GetThemeSupplier();
}
void CefWidgetImpl::OnNativeWidgetDestroyed() {
window_view_ = nullptr;
views::Widget::OnNativeWidgetDestroyed();
}
void CefWidgetImpl::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
// TODO: Reduce the frequency of this callback on Windows/Linux.
// See https://issues.chromium.org/issues/40280130#comment7
color_provider_tracker_.OnNativeThemeUpdated();
// Native/OS theme changed.
NotifyThemeColorsChanged(/*chrome_theme=*/false,
/*call_theme_changed=*/false);
// Calls ThemeChanged().
Widget::OnNativeThemeUpdated(observed_theme);
}
ui::ColorProviderKey CefWidgetImpl::GetColorProviderKey() const {
auto* profile = GetThemeProfile();
if (!profile) {
return Widget::GetColorProviderKey();
}
// Based on BrowserFrame::GetColorProviderKey.
auto key = Widget::GetColorProviderKey();
const auto* theme_service = ThemeServiceFactory::GetForProfile(profile);
CHECK(theme_service);
// color_mode.
[&key, theme_service]() {
const auto browser_color_scheme = theme_service->GetBrowserColorScheme();
if (browser_color_scheme != ThemeService::BrowserColorScheme::kSystem) {
key.color_mode =
browser_color_scheme == ThemeService::BrowserColorScheme::kLight
? ui::ColorProviderKey::ColorMode::kLight
: ui::ColorProviderKey::ColorMode::kDark;
}
}();
// user_color.
// Device theme retains the user_color from `Widget`.
if (!theme_service->UsingDeviceTheme()) {
if (theme_service->UsingAutogeneratedTheme()) {
key.user_color = theme_service->GetAutogeneratedThemeColor();
} else if (auto user_color = theme_service->GetUserColor()) {
key.user_color = user_color;
}
}
// user_color_source.
if (theme_service->UsingDeviceTheme()) {
key.user_color_source = ui::ColorProviderKey::UserColorSource::kAccent;
} else if (theme_service->GetIsGrayscale()) {
key.user_color_source = ui::ColorProviderKey::UserColorSource::kGrayscale;
} else if (theme_service->GetIsBaseline()) {
key.user_color_source = ui::ColorProviderKey::UserColorSource::kBaseline;
} else {
CHECK(key.user_color.has_value());
key.user_color_source = ui::ColorProviderKey::UserColorSource::kAccent;
}
// scheme_variant.
ui::mojom::BrowserColorVariant color_variant =
theme_service->GetBrowserColorVariant();
if (!theme_service->UsingDeviceTheme() &&
color_variant != ui::mojom::BrowserColorVariant::kSystem) {
key.scheme_variant = GetSchemeVariant(color_variant);
}
// frame_type.
key.frame_type = ui::ColorProviderKey::FrameType::kNative;
return key;
}
void CefWidgetImpl::OnThemeChanged() {
// When the Chrome theme changes, the NativeTheme may also change.
SelectNativeTheme();
NotifyThemeColorsChanged(/*chrome_theme=*/true, /*call_theme_changed=*/true);
}
void CefWidgetImpl::NotifyThemeColorsChanged(bool chrome_theme,
bool call_theme_changed) {
if (window_view_) {
window_view_->OnThemeColorsChanged(chrome_theme);
if (call_theme_changed) {
// Call ThemeChanged() asynchronously to avoid possible reentrancy.
CEF_POST_TASK(TID_UI, base::BindOnce(&CefWidgetImpl::ThemeChanged,
weak_ptr_factory_.GetWeakPtr()));
}
}
}
void CefWidgetImpl::SelectNativeTheme() {
// Based on BrowserFrame::SelectNativeTheme.
#if BUILDFLAG(IS_LINUX)
ui::NativeTheme* native_theme = ui::NativeTheme::GetInstanceForNativeUi();
// Always use the NativeTheme for forced color modes.
if (ui::NativeTheme::IsForcedDarkMode() ||
ui::NativeTheme::IsForcedLightMode()) {
SetNativeTheme(native_theme);
return;
}
const auto* linux_ui_theme =
ui::LinuxUiTheme::GetForWindow(GetNativeWindow());
SetNativeTheme(linux_ui_theme ? linux_ui_theme->GetNativeTheme()
: native_theme);
#endif
}
void CefWidgetImpl::OnColorProviderCacheResetMissed() {
// Ignore calls during Widget::Init().
if (!initialized_) {
return;
}
NotifyThemeColorsChanged(/*chrome_theme=*/false,
/*call_theme_changed=*/true);
}

View File

@@ -0,0 +1,99 @@
// 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_VIEWS_WIDGET_IMPL_H_
#define CEF_LIBCEF_BROWSER_VIEWS_WIDGET_IMPL_H_
#pragma once
#include <map>
#include "libcef/browser/views/color_provider_tracker.h"
#include "libcef/browser/views/widget.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/themes/theme_service_observer.h"
#include "ui/views/widget/widget.h"
class CefWindowView;
class Profile;
// Widget specialization to implement theme support for the Alloy runtime. The
// global NativeTheme (native/OS theme) will be used unless this Widget contains
// a BrowserView, in which case a Chrome theme associated with the BrowserView's
// Profile will be used.
//
// Theme support works as follows:
// - OnNativeThemeUpdated is called when the NativeTheme associated with this
// Widget changes. For example, when switching the OS appearance between light
// and dark mode.
// - OnColorProviderCacheResetMissed is called if some other NativeTheme not
// associated with this Widget changes and we need to reapply global color
// overrides (see CefColorProviderTracker for details).
// - OnThemeChanged is called when the client changes the Chrome theme
// explicitly by calling CefRequestContext::SetChromeColorScheme.
// - GetThemeProvider, GetCustomTheme and GetColorProviderKey return objects
// that are used internally to apply the current theme.
//
// Callers should use view_util methods (e.g. GetColor, ShouldUseDarkTheme, etc)
// instead of calling theme-related Widget methods directly.
class CefWidgetImpl : public views::Widget,
public CefWidget,
public CefColorProviderTracker::Observer,
public ThemeServiceObserver {
public:
explicit CefWidgetImpl(CefWindowView* window_view);
~CefWidgetImpl() override;
CefWidgetImpl(const CefWidgetImpl&) = delete;
CefWidgetImpl& operator=(const CefWidgetImpl&) = delete;
// CefWidget methods:
views::Widget* GetWidget() override { return this; }
const views::Widget* GetWidget() const override { return this; }
void Initialized() override;
bool IsInitialized() const override { return initialized_; }
void AddAssociatedProfile(Profile* profile) override;
void RemoveAssociatedProfile(Profile* profile) override;
Profile* GetThemeProfile() const override;
// views::Widget methods:
const ui::ThemeProvider* GetThemeProvider() const override;
ui::ColorProviderKey::ThemeInitializerSupplier* GetCustomTheme()
const override;
// NativeWidgetDelegate methods:
void OnNativeWidgetDestroyed() override;
// ui::NativeThemeObserver methods:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
ui::ColorProviderKey GetColorProviderKey() const override;
// ThemeServiceObserver methods:
void OnThemeChanged() override;
private:
void NotifyThemeColorsChanged(bool chrome_theme, bool call_theme_changed);
// Select a native theme that is appropriate for the current context. This is
// currently only needed for Linux to switch between the regular NativeTheme
// and the GTK NativeTheme instance.
void SelectNativeTheme();
// CefColorProviderTracker::Observer methods:
void OnColorProviderCacheResetMissed() override;
CefWindowView* window_view_;
bool initialized_ = false;
// Map of Profile* to count.
using ProfileMap = std::map<Profile*, size_t>;
ProfileMap associated_profiles_;
CefColorProviderTracker color_provider_tracker_{this};
base::WeakPtrFactory<CefWidgetImpl> weak_ptr_factory_{this};
};
#endif // CEF_LIBCEF_BROWSER_VIEWS_WIDGET_IMPL_H_

View File

@@ -7,15 +7,14 @@
#include <memory>
#include "libcef/browser/browser_util.h"
#include "libcef/browser/chrome/views/chrome_browser_frame.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/views/browser_view_impl.h"
#include "libcef/browser/views/display_impl.h"
#include "libcef/browser/views/fill_layout_impl.h"
#include "libcef/browser/views/layout_util.h"
#include "libcef/browser/views/view_util.h"
#include "libcef/browser/views/widget.h"
#include "libcef/browser/views/window_view.h"
#include "libcef/features/runtime.h"
#include "base/i18n/rtl.h"
#include "components/constrained_window/constrained_window_views.h"
@@ -254,14 +253,9 @@ void CefWindowImpl::Restore() {
void CefWindowImpl::SetFullscreen(bool fullscreen) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_ && fullscreen != widget_->IsFullscreen()) {
if (cef::IsChromeRuntimeEnabled()) {
// If a BrowserView exists, toggle fullscreen mode via the Chrome command
// for consistent behavior.
auto* browser_frame = static_cast<ChromeBrowserFrame*>(widget_);
if (browser_frame->browser_view()) {
browser_frame->ToggleFullscreenMode();
return;
}
if (CefWidget::GetForWidget(widget_)->ToggleFullscreenMode()) {
// Received special handling.
return;
}
// Call the Widget method directly with Alloy runtime, or Chrome runtime
@@ -741,6 +735,20 @@ void CefWindowImpl::RemoveAllAccelerators() {
focus_manager->UnregisterAccelerators(this);
}
void CefWindowImpl::SetThemeColor(int color_id, cef_color_t color) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (root_view()) {
view_util::SetColor(root_view(), color_id, color);
}
}
void CefWindowImpl::ThemeChanged() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_) {
widget_->ThemeChanged();
}
}
CefWindowView* CefWindowImpl::cef_window_view() const {
return static_cast<CefWindowView*>(root_view());
}

View File

@@ -91,6 +91,8 @@ class CefWindowImpl
bool high_priority) override;
void RemoveAccelerator(int command_id) override;
void RemoveAllAccelerators() override;
void SetThemeColor(int color_id, cef_color_t color) override;
void ThemeChanged() override;
// CefViewAdapter methods:
void Detach() override;

View File

@@ -14,12 +14,12 @@
#endif
#endif
#include "libcef/browser/chrome/views/chrome_browser_frame.h"
#include "libcef/browser/geometry_util.h"
#include "libcef/browser/image_impl.h"
#include "libcef/browser/views/widget.h"
#include "libcef/browser/views/window_impl.h"
#include "libcef/features/runtime.h"
#include "base/ranges/algorithm.h"
#include "ui/base/hit_test.h"
#include "ui/display/screen.h"
#include "ui/views/widget/widget.h"
@@ -37,9 +37,6 @@
#endif
#if BUILDFLAG(IS_WIN)
#include <dwmapi.h>
#include "base/win/windows_version.h"
#include "ui/display/win/screen_win.h"
#include "ui/views/win/hwnd_util.h"
#endif
@@ -147,24 +144,10 @@ class NativeFrameViewEx : public views::NativeFrameView {
return views::NativeFrameView::NonClientHitTest(point);
}
#if BUILDFLAG(IS_WIN)
void OnThemeChanged() override {
views::NativeFrameView::OnThemeChanged();
// Value was 19 prior to Windows 10 20H1, according to
// https://stackoverflow.com/a/70693198
const DWORD dwAttribute =
base::win::GetVersion() >= base::win::Version::WIN10_20H1
? DWMWA_USE_IMMERSIVE_DARK_MODE
: 19;
// From BrowserFrameViewWin::SetSystemMicaTitlebarAttributes:
const BOOL dark_titlebar_enabled = GetNativeTheme()->ShouldUseDarkColors();
DwmSetWindowAttribute(views::HWNDForWidget(widget_), dwAttribute,
&dark_titlebar_enabled,
sizeof(dark_titlebar_enabled));
view_util::UpdateTitlebarTheme(widget_);
}
#endif
private:
// Not owned by this object.
@@ -384,8 +367,8 @@ void CefWindowView::CreateWidget(gfx::AcceleratedWidget parent_widget) {
// |widget| is owned by the NativeWidget and will be destroyed in response to
// a native destruction message.
views::Widget* widget = cef::IsChromeRuntimeEnabled() ? new ChromeBrowserFrame
: new views::Widget;
CefWidget* cef_widget = CefWidget::Create(this);
views::Widget* widget = cef_widget->GetWidget();
views::Widget::InitParams params;
params.delegate = this;
@@ -415,8 +398,8 @@ void CefWindowView::CreateWidget(gfx::AcceleratedWidget parent_widget) {
params.type = views::Widget::InitParams::TYPE_WINDOW;
}
// WidgetDelegate::DeleteDelegate() will delete |this| after executing the
// registered callback.
// Cause WidgetDelegate::DeleteDelegate() to delete |this| after executing the
// registered DeleteDelegate callback.
SetOwnedByWidget(true);
RegisterDeleteDelegateCallback(
base::BindOnce(&CefWindowView::DeleteDelegate, base::Unretained(this)));
@@ -542,6 +525,8 @@ void CefWindowView::CreateWidget(gfx::AcceleratedWidget parent_widget) {
DCHECK(widget->widget_delegate()->CanActivate());
}
cef_widget->Initialized();
#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_OZONE_X11)
auto x11window = static_cast<x11::Window>(view_util::GetWindowHandle(widget));
@@ -602,6 +587,9 @@ CefRefPtr<CefWindow> CefWindowView::GetCefWindow() const {
}
void CefWindowView::DeleteDelegate() {
// Any overlays should already be removed.
DCHECK(overlay_hosts_.empty());
// Remove all child Views before deleting the Window so that notifications
// resolve correctly.
RemoveAllChildViews();
@@ -648,6 +636,14 @@ ui::ImageModel CefWindowView::GetWindowAppIcon() {
}
void CefWindowView::WindowClosing() {
// Close any overlays now, before the Widget is destroyed.
// Use a copy of the array because the original may be modified while
// iterating.
std::vector<CefOverlayViewHost*> overlay_hosts = overlay_hosts_;
for (auto* overlay_host : overlay_hosts) {
overlay_host->Close();
}
#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_OZONE_X11)
if (host_widget()) {
@@ -663,6 +659,8 @@ void CefWindowView::WindowClosing() {
#endif
window_delegate_->OnWindowClosing();
views::WidgetDelegateView::WindowClosing();
}
views::View* CefWindowView::GetContentsView() {
@@ -747,6 +745,20 @@ void CefWindowView::ViewHierarchyChanged(
ParentClass::ViewHierarchyChanged(details);
}
void CefWindowView::OnThemeChanged() {
bool initialized = false;
if (auto* cef_widget = CefWidget::GetForWidget(GetWidget())) {
initialized = cef_widget->IsInitialized();
}
if (!initialized) {
// Skip the CefViewView logic.
views::WidgetDelegateView::OnThemeChanged();
} else {
ParentClass::OnThemeChanged();
}
}
void CefWindowView::OnWidgetActivationChanged(views::Widget* widget,
bool active) {
if (cef_delegate()) {
@@ -756,7 +768,11 @@ void CefWindowView::OnWidgetActivationChanged(views::Widget* widget,
void CefWindowView::OnWidgetBoundsChanged(views::Widget* widget,
const gfx::Rect& new_bounds) {
MoveOverlaysIfNecessary();
// Size is set to zero when the host Widget is hidden. We don't need to move
// overlays in that case.
if (!new_bounds.IsEmpty()) {
MoveOverlaysIfNecessary();
}
if (cef_delegate()) {
cef_delegate()->OnWindowBoundsChanged(
@@ -818,10 +834,10 @@ CefRefPtr<CefOverlayController> CefWindowView::AddOverlayView(
// Owned by the View hierarchy. Acts as a z-order reference for the overlay.
auto overlay_host_view = AddChildView(std::make_unique<views::View>());
overlay_hosts_.push_back(
std::make_unique<CefOverlayViewHost>(this, docking_mode));
// Owned by the resulting Widget, after calling Init().
auto* overlay_host = new CefOverlayViewHost(this, docking_mode);
overlay_hosts_.push_back(overlay_host);
auto& overlay_host = overlay_hosts_.back();
overlay_host->Init(overlay_host_view, view, can_activate);
return overlay_host->controller();
@@ -830,6 +846,18 @@ CefRefPtr<CefOverlayController> CefWindowView::AddOverlayView(
return nullptr;
}
void CefWindowView::RemoveOverlayView(CefOverlayViewHost* host,
views::View* host_view) {
DCHECK_EQ(host_view->parent(), this);
RemoveChildView(host_view);
const auto it = base::ranges::find_if(
overlay_hosts_,
[host](CefOverlayViewHost* current) { return current == host; });
DCHECK(it != overlay_hosts_.end());
overlay_hosts_.erase(it);
}
void CefWindowView::MoveOverlaysIfNecessary() {
if (overlay_hosts_.empty()) {
return;
@@ -986,3 +1014,9 @@ std::optional<float> CefWindowView::GetTitlebarHeight(bool required) const {
return std::nullopt;
}
void CefWindowView::OnThemeColorsChanged(bool chrome_theme) {
if (cef_delegate()) {
cef_delegate()->OnThemeColorsChanged(GetCefWindow(), chrome_theme);
}
}

View File

@@ -79,6 +79,7 @@ class CefWindowView
// views::View methods:
void ViewHierarchyChanged(
const views::ViewHierarchyChangedDetails& details) override;
void OnThemeChanged() override;
// views::WidgetObserver methods:
void OnWidgetActivationChanged(views::Widget* widget, bool active) override;
@@ -109,6 +110,9 @@ class CefWindowView
cef_docking_mode_t docking_mode,
bool can_activate);
// Called from CefOverlayViewHost::Cleanup().
void RemoveOverlayView(CefOverlayViewHost* host, views::View* host_view);
// Set/get the draggable regions.
void SetDraggableRegions(const std::vector<CefDraggableRegion>& regions);
SkRegion* draggable_region() const { return draggable_region_.get(); }
@@ -128,12 +132,15 @@ class CefWindowView
std::optional<float> GetTitlebarHeight(bool required) const;
bool IsFrameless() const { return is_frameless_; }
// Called before ThemeChanged() for native or Chrome theme changes.
void OnThemeColorsChanged(bool chrome_theme);
// The Widget that hosts us, if we're a modal dialog. May return nullptr
// during initialization and destruction.
views::Widget* host_widget() const;
private:
// Called when removed from the Widget and before |this| is deleted.
// Called after Widget teardown starts, before |this| is deleted.
void DeleteDelegate();
void MoveOverlaysIfNecessary();
@@ -161,7 +168,7 @@ class CefWindowView
std::unique_ptr<WidgetDestructionObserver> host_widget_destruction_observer_;
// Hosts for overlay widgets.
std::vector<std::unique_ptr<CefOverlayViewHost>> overlay_hosts_;
std::vector<CefOverlayViewHost*> overlay_hosts_;
};
#endif // CEF_LIBCEF_BROWSER_VIEWS_WINDOW_VIEW_H_

View File

@@ -6,6 +6,7 @@
// Otherwise there will be compile errors in wtf/MathExtras.h.
#define _USE_MATH_DEFINES
#include <limits>
#include <map>
#include <memory>
#include <string>
@@ -49,6 +50,8 @@
namespace {
static const char kCefTrackObject[] = "Cef::TrackObject";
constexpr int32_t kMaxInt32 = std::numeric_limits<int32_t>::max();
constexpr uint32_t kMaxInt32AsUint32 = static_cast<uint32_t>(kMaxInt32);
void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
v8::Handle<v8::Value> data);
@@ -1693,12 +1696,13 @@ bool CefV8ValueImpl::IsBool() {
bool CefV8ValueImpl::IsInt() {
CEF_V8_REQUIRE_ISOLATE_RETURN(false);
return (type_ == TYPE_INT || type_ == TYPE_UINT);
return type_ == TYPE_INT ||
(type_ == TYPE_UINT && uint_value_ <= kMaxInt32AsUint32);
}
bool CefV8ValueImpl::IsUInt() {
CEF_V8_REQUIRE_ISOLATE_RETURN(false);
return (type_ == TYPE_INT || type_ == TYPE_UINT);
return type_ == TYPE_UINT || (type_ == TYPE_INT && int_value_ >= 0);
}
bool CefV8ValueImpl::IsDouble() {
@@ -1807,17 +1811,23 @@ bool CefV8ValueImpl::GetBoolValue() {
int32_t CefV8ValueImpl::GetIntValue() {
CEF_V8_REQUIRE_ISOLATE_RETURN(0);
if (type_ == TYPE_INT || type_ == TYPE_UINT) {
if (type_ == TYPE_INT) {
return int_value_;
}
if (type_ == TYPE_UINT && uint_value_ <= kMaxInt32AsUint32) {
return static_cast<int32_t>(uint_value_);
}
return 0;
}
uint32_t CefV8ValueImpl::GetUIntValue() {
CEF_V8_REQUIRE_ISOLATE_RETURN(0);
if (type_ == TYPE_INT || type_ == TYPE_UINT) {
if (type_ == TYPE_UINT) {
return uint_value_;
}
if (type_ == TYPE_INT && int_value_ >= 0) {
return static_cast<uint32_t>(int_value_);
}
return 0;
}

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=0b4a5f175a85d506a4ba6da1bbdb6bad2306d898$
// $hash=fb10148445f36dc1712cf760b9754911bbbcdf13$
//
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
@@ -315,7 +315,7 @@ render_handler_on_accelerated_paint(struct _cef_render_handler_t* self,
cef_paint_element_type_t type,
size_t dirtyRectsCount,
cef_rect_t const* dirtyRects,
void* shared_handle) {
const cef_accelerated_paint_info_t* info) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@@ -334,9 +334,9 @@ render_handler_on_accelerated_paint(struct _cef_render_handler_t* self,
if (dirtyRectsCount > 0 && !dirtyRects) {
return;
}
// Verify param: shared_handle; type: simple_byaddr
DCHECK(shared_handle);
if (!shared_handle) {
// Verify param: info; type: simple_byref_const
DCHECK(info);
if (!info) {
return;
}
@@ -348,10 +348,12 @@ render_handler_on_accelerated_paint(struct _cef_render_handler_t* self,
dirtyRectsList.push_back(dirtyRectsVal);
}
}
// Translate param: info; type: simple_byref_const
CefAcceleratedPaintInfo infoVal = info ? *info : CefAcceleratedPaintInfo();
// Execute
CefRenderHandlerCppToC::Get(self)->OnAcceleratedPaint(
CefBrowserCToCpp::Wrap(browser), type, dirtyRectsList, shared_handle);
CefBrowserCToCpp::Wrap(browser), type, dirtyRectsList, infoVal);
}
void CEF_CALLBACK

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=713287303ab9bbb6db24d8aabb340766f5e69461$
// $hash=48bce7be945d4e74682ffa41e8b45eb46a4f7589$
//
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
@@ -553,6 +553,73 @@ request_context_set_content_setting(struct _cef_request_context_t* self,
CefString(requesting_url), CefString(top_level_url), content_type, value);
}
void CEF_CALLBACK
request_context_set_chrome_color_scheme(struct _cef_request_context_t* self,
cef_color_variant_t variant,
cef_color_t user_color) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return;
}
// Execute
CefRequestContextCppToC::Get(self)->SetChromeColorScheme(variant, user_color);
}
cef_color_variant_t CEF_CALLBACK request_context_get_chrome_color_scheme_mode(
struct _cef_request_context_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return CEF_COLOR_VARIANT_SYSTEM;
}
// Execute
cef_color_variant_t _retval =
CefRequestContextCppToC::Get(self)->GetChromeColorSchemeMode();
// Return type: simple
return _retval;
}
cef_color_t CEF_CALLBACK request_context_get_chrome_color_scheme_color(
struct _cef_request_context_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return 0;
}
// Execute
cef_color_t _retval =
CefRequestContextCppToC::Get(self)->GetChromeColorSchemeColor();
// Return type: simple
return _retval;
}
cef_color_variant_t CEF_CALLBACK
request_context_get_chrome_color_scheme_variant(
struct _cef_request_context_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return CEF_COLOR_VARIANT_SYSTEM;
}
// Execute
cef_color_variant_t _retval =
CefRequestContextCppToC::Get(self)->GetChromeColorSchemeVariant();
// Return type: simple
return _retval;
}
int CEF_CALLBACK
request_context_has_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
@@ -713,6 +780,14 @@ CefRequestContextCppToC::CefRequestContextCppToC() {
GetStruct()->set_website_setting = request_context_set_website_setting;
GetStruct()->get_content_setting = request_context_get_content_setting;
GetStruct()->set_content_setting = request_context_set_content_setting;
GetStruct()->set_chrome_color_scheme =
request_context_set_chrome_color_scheme;
GetStruct()->get_chrome_color_scheme_mode =
request_context_get_chrome_color_scheme_mode;
GetStruct()->get_chrome_color_scheme_color =
request_context_get_chrome_color_scheme_color;
GetStruct()->get_chrome_color_scheme_variant =
request_context_get_chrome_color_scheme_variant;
GetStruct()->base.has_preference = request_context_has_preference;
GetStruct()->base.get_preference = request_context_get_preference;
GetStruct()->base.get_all_preferences = request_context_get_all_preferences;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=f0759e132185f8e6f0ee9e947f7e5ece3dddd5e7$
// $hash=07903b210017d0e545a381bb700088c689187b0e$
//
#include "libcef_dll/cpptoc/views/browser_view_cpptoc.h"
@@ -995,6 +995,26 @@ browser_view_get_background_color(struct _cef_view_t* self) {
return _retval;
}
cef_color_t CEF_CALLBACK browser_view_get_theme_color(struct _cef_view_t* self,
int color_id) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return 0;
}
// Execute
cef_color_t _retval =
CefBrowserViewCppToC::Get(reinterpret_cast<cef_browser_view_t*>(self))
->GetThemeColor(color_id);
// Return type: simple
return _retval;
}
int CEF_CALLBACK browser_view_convert_point_to_screen(struct _cef_view_t* self,
cef_point_t* point) {
shutdown_checker::AssertNotShutdown();
@@ -1261,6 +1281,7 @@ CefBrowserViewCppToC::CefBrowserViewCppToC() {
GetStruct()->base.request_focus = browser_view_request_focus;
GetStruct()->base.set_background_color = browser_view_set_background_color;
GetStruct()->base.get_background_color = browser_view_get_background_color;
GetStruct()->base.get_theme_color = browser_view_get_theme_color;
GetStruct()->base.convert_point_to_screen =
browser_view_convert_point_to_screen;
GetStruct()->base.convert_point_from_screen =

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=3c4cb278397e9a07c8e5754650fe6944dd2a20ed$
// $hash=4e2f75d68d804ad2414eb34b9f273b8f558c3dab$
//
#include "libcef_dll/cpptoc/views/button_cpptoc.h"
@@ -950,6 +950,26 @@ cef_color_t CEF_CALLBACK button_get_background_color(struct _cef_view_t* self) {
return _retval;
}
cef_color_t CEF_CALLBACK button_get_theme_color(struct _cef_view_t* self,
int color_id) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return 0;
}
// Execute
cef_color_t _retval =
CefButtonCppToC::Get(reinterpret_cast<cef_button_t*>(self))
->GetThemeColor(color_id);
// Return type: simple
return _retval;
}
int CEF_CALLBACK button_convert_point_to_screen(struct _cef_view_t* self,
cef_point_t* point) {
shutdown_checker::AssertNotShutdown();
@@ -1212,6 +1232,7 @@ CefButtonCppToC::CefButtonCppToC() {
GetStruct()->base.request_focus = button_request_focus;
GetStruct()->base.set_background_color = button_set_background_color;
GetStruct()->base.get_background_color = button_get_background_color;
GetStruct()->base.get_theme_color = button_get_theme_color;
GetStruct()->base.convert_point_to_screen = button_convert_point_to_screen;
GetStruct()->base.convert_point_from_screen =
button_convert_point_from_screen;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=cc05a9116adf2a98d4b6169a86052a14e299cfeb$
// $hash=51a06f8ad654129497df44179105e8523e1234af$
//
#include "libcef_dll/cpptoc/views/label_button_cpptoc.h"
@@ -1228,6 +1228,26 @@ label_button_get_background_color(struct _cef_view_t* self) {
return _retval;
}
cef_color_t CEF_CALLBACK label_button_get_theme_color(struct _cef_view_t* self,
int color_id) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return 0;
}
// Execute
cef_color_t _retval =
CefLabelButtonCppToC::Get(reinterpret_cast<cef_label_button_t*>(self))
->GetThemeColor(color_id);
// Return type: simple
return _retval;
}
int CEF_CALLBACK label_button_convert_point_to_screen(struct _cef_view_t* self,
cef_point_t* point) {
shutdown_checker::AssertNotShutdown();
@@ -1512,6 +1532,7 @@ CefLabelButtonCppToC::CefLabelButtonCppToC() {
label_button_set_background_color;
GetStruct()->base.base.get_background_color =
label_button_get_background_color;
GetStruct()->base.base.get_theme_color = label_button_get_theme_color;
GetStruct()->base.base.convert_point_to_screen =
label_button_convert_point_to_screen;
GetStruct()->base.base.convert_point_from_screen =

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=82aaa681d0ed57446e54a2c04a62adf18c284677$
// $hash=02040c0851514ead9307d3901c117d94d4fffb41$
//
#include "libcef_dll/cpptoc/views/menu_button_cpptoc.h"
@@ -1281,6 +1281,26 @@ menu_button_get_background_color(struct _cef_view_t* self) {
return _retval;
}
cef_color_t CEF_CALLBACK menu_button_get_theme_color(struct _cef_view_t* self,
int color_id) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return 0;
}
// Execute
cef_color_t _retval =
CefMenuButtonCppToC::Get(reinterpret_cast<cef_menu_button_t*>(self))
->GetThemeColor(color_id);
// Return type: simple
return _retval;
}
int CEF_CALLBACK menu_button_convert_point_to_screen(struct _cef_view_t* self,
cef_point_t* point) {
shutdown_checker::AssertNotShutdown();
@@ -1569,6 +1589,7 @@ CefMenuButtonCppToC::CefMenuButtonCppToC() {
menu_button_set_background_color;
GetStruct()->base.base.base.get_background_color =
menu_button_get_background_color;
GetStruct()->base.base.base.get_theme_color = menu_button_get_theme_color;
GetStruct()->base.base.base.convert_point_to_screen =
menu_button_convert_point_to_screen;
GetStruct()->base.base.base.convert_point_from_screen =

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=9ec8f43a509317ec1eead47556f83ce953f041b8$
// $hash=4c768c4065540d40bfcc8da63dfa1916ca09f6f7$
//
#include "libcef_dll/cpptoc/views/panel_cpptoc.h"
@@ -1088,6 +1088,26 @@ cef_color_t CEF_CALLBACK panel_get_background_color(struct _cef_view_t* self) {
return _retval;
}
cef_color_t CEF_CALLBACK panel_get_theme_color(struct _cef_view_t* self,
int color_id) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return 0;
}
// Execute
cef_color_t _retval =
CefPanelCppToC::Get(reinterpret_cast<cef_panel_t*>(self))
->GetThemeColor(color_id);
// Return type: simple
return _retval;
}
int CEF_CALLBACK panel_convert_point_to_screen(struct _cef_view_t* self,
cef_point_t* point) {
shutdown_checker::AssertNotShutdown();
@@ -1356,6 +1376,7 @@ CefPanelCppToC::CefPanelCppToC() {
GetStruct()->base.request_focus = panel_request_focus;
GetStruct()->base.set_background_color = panel_set_background_color;
GetStruct()->base.get_background_color = panel_get_background_color;
GetStruct()->base.get_theme_color = panel_get_theme_color;
GetStruct()->base.convert_point_to_screen = panel_convert_point_to_screen;
GetStruct()->base.convert_point_from_screen = panel_convert_point_from_screen;
GetStruct()->base.convert_point_to_window = panel_convert_point_to_window;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=2ac2ff6e231398755ea6f2748985d21c0b4b1510$
// $hash=9c4a2548745464359046f080fa2a07d1438c208b$
//
#include "libcef_dll/cpptoc/views/scroll_view_cpptoc.h"
@@ -1017,6 +1017,26 @@ scroll_view_get_background_color(struct _cef_view_t* self) {
return _retval;
}
cef_color_t CEF_CALLBACK scroll_view_get_theme_color(struct _cef_view_t* self,
int color_id) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return 0;
}
// Execute
cef_color_t _retval =
CefScrollViewCppToC::Get(reinterpret_cast<cef_scroll_view_t*>(self))
->GetThemeColor(color_id);
// Return type: simple
return _retval;
}
int CEF_CALLBACK scroll_view_convert_point_to_screen(struct _cef_view_t* self,
cef_point_t* point) {
shutdown_checker::AssertNotShutdown();
@@ -1286,6 +1306,7 @@ CefScrollViewCppToC::CefScrollViewCppToC() {
GetStruct()->base.request_focus = scroll_view_request_focus;
GetStruct()->base.set_background_color = scroll_view_set_background_color;
GetStruct()->base.get_background_color = scroll_view_get_background_color;
GetStruct()->base.get_theme_color = scroll_view_get_theme_color;
GetStruct()->base.convert_point_to_screen =
scroll_view_convert_point_to_screen;
GetStruct()->base.convert_point_from_screen =

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=f8d63e2a2ba174b0f7ffb1ae66052288c28b6c43$
// $hash=5407c7f442b7787de087a85d5613fffb384288c8$
//
#include "libcef_dll/cpptoc/views/textfield_cpptoc.h"
@@ -1447,6 +1447,26 @@ textfield_get_background_color(struct _cef_view_t* self) {
return _retval;
}
cef_color_t CEF_CALLBACK textfield_get_theme_color(struct _cef_view_t* self,
int color_id) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return 0;
}
// Execute
cef_color_t _retval =
CefTextfieldCppToC::Get(reinterpret_cast<cef_textfield_t*>(self))
->GetThemeColor(color_id);
// Return type: simple
return _retval;
}
int CEF_CALLBACK textfield_convert_point_to_screen(struct _cef_view_t* self,
cef_point_t* point) {
shutdown_checker::AssertNotShutdown();
@@ -1741,6 +1761,7 @@ CefTextfieldCppToC::CefTextfieldCppToC() {
GetStruct()->base.request_focus = textfield_request_focus;
GetStruct()->base.set_background_color = textfield_set_background_color;
GetStruct()->base.get_background_color = textfield_get_background_color;
GetStruct()->base.get_theme_color = textfield_get_theme_color;
GetStruct()->base.convert_point_to_screen = textfield_convert_point_to_screen;
GetStruct()->base.convert_point_from_screen =
textfield_convert_point_from_screen;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=a543a7ac4053e15e97e84a87f4275c23e9a35477$
// $hash=ae22b240b761b1bd2e9f168de2859ae0085191f6$
//
#include "libcef_dll/cpptoc/views/view_cpptoc.h"
@@ -788,6 +788,24 @@ cef_color_t CEF_CALLBACK view_get_background_color(struct _cef_view_t* self) {
return _retval;
}
cef_color_t CEF_CALLBACK view_get_theme_color(struct _cef_view_t* self,
int color_id) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return 0;
}
// Execute
cef_color_t _retval = CefViewCppToC::Get(self)->GetThemeColor(color_id);
// Return type: simple
return _retval;
}
int CEF_CALLBACK view_convert_point_to_screen(struct _cef_view_t* self,
cef_point_t* point) {
shutdown_checker::AssertNotShutdown();
@@ -1037,6 +1055,7 @@ CefViewCppToC::CefViewCppToC() {
GetStruct()->request_focus = view_request_focus;
GetStruct()->set_background_color = view_set_background_color;
GetStruct()->get_background_color = view_get_background_color;
GetStruct()->get_theme_color = view_get_theme_color;
GetStruct()->convert_point_to_screen = view_convert_point_to_screen;
GetStruct()->convert_point_from_screen = view_convert_point_from_screen;
GetStruct()->convert_point_to_window = view_convert_point_to_window;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=a5f9a7de12728e82f8dee6d8dde3b9275a3e4ee4$
// $hash=b9df5830c3e1b042aeced2a2b5fd97d00e702869$
//
#include "libcef_dll/cpptoc/views/window_cpptoc.h"
@@ -721,6 +721,36 @@ void CEF_CALLBACK window_remove_all_accelerators(struct _cef_window_t* self) {
CefWindowCppToC::Get(self)->RemoveAllAccelerators();
}
void CEF_CALLBACK window_set_theme_color(struct _cef_window_t* self,
int color_id,
cef_color_t color) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return;
}
// Execute
CefWindowCppToC::Get(self)->SetThemeColor(color_id, color);
}
void CEF_CALLBACK window_theme_changed(struct _cef_window_t* self) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return;
}
// Execute
CefWindowCppToC::Get(self)->ThemeChanged();
}
struct _cef_window_t* CEF_CALLBACK window_as_window(struct _cef_panel_t* self) {
shutdown_checker::AssertNotShutdown();
@@ -1784,6 +1814,26 @@ cef_color_t CEF_CALLBACK window_get_background_color(struct _cef_view_t* self) {
return _retval;
}
cef_color_t CEF_CALLBACK window_get_theme_color(struct _cef_view_t* self,
int color_id) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return 0;
}
// Execute
cef_color_t _retval =
CefWindowCppToC::Get(reinterpret_cast<cef_window_t*>(self))
->GetThemeColor(color_id);
// Return type: simple
return _retval;
}
int CEF_CALLBACK window_convert_point_to_screen(struct _cef_view_t* self,
cef_point_t* point) {
shutdown_checker::AssertNotShutdown();
@@ -2035,6 +2085,8 @@ CefWindowCppToC::CefWindowCppToC() {
GetStruct()->set_accelerator = window_set_accelerator;
GetStruct()->remove_accelerator = window_remove_accelerator;
GetStruct()->remove_all_accelerators = window_remove_all_accelerators;
GetStruct()->set_theme_color = window_set_theme_color;
GetStruct()->theme_changed = window_theme_changed;
GetStruct()->base.as_window = window_as_window;
GetStruct()->base.set_to_fill_layout = window_set_to_fill_layout;
GetStruct()->base.set_to_box_layout = window_set_to_box_layout;
@@ -2092,6 +2144,7 @@ CefWindowCppToC::CefWindowCppToC() {
GetStruct()->base.base.request_focus = window_request_focus;
GetStruct()->base.base.set_background_color = window_set_background_color;
GetStruct()->base.base.get_background_color = window_get_background_color;
GetStruct()->base.base.get_theme_color = window_get_theme_color;
GetStruct()->base.base.convert_point_to_screen =
window_convert_point_to_screen;
GetStruct()->base.base.convert_point_from_screen =

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=1829e6ed7282ca9a0b34e825a11c229ddd48590d$
// $hash=4d171663d78dd204b321d77248f44ed7f0d752b8$
//
#include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h"
@@ -374,6 +374,31 @@ window_delegate_get_titlebar_height(struct _cef_window_delegate_t* self,
return _retval;
}
cef_state_t CEF_CALLBACK
window_delegate_accepts_first_mouse(struct _cef_window_delegate_t* self,
cef_window_t* window) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return STATE_DEFAULT;
}
// Verify param: window; type: refptr_diff
DCHECK(window);
if (!window) {
return STATE_DEFAULT;
}
// Execute
cef_state_t _retval = CefWindowDelegateCppToC::Get(self)->AcceptsFirstMouse(
CefWindowCToCpp::Wrap(window));
// Return type: simple
return _retval;
}
int CEF_CALLBACK window_delegate_can_resize(struct _cef_window_delegate_t* self,
cef_window_t* window) {
shutdown_checker::AssertNotShutdown();
@@ -532,6 +557,29 @@ window_delegate_on_key_event(struct _cef_window_delegate_t* self,
return _retval;
}
void CEF_CALLBACK
window_delegate_on_theme_colors_changed(struct _cef_window_delegate_t* self,
cef_window_t* window,
int chrome_theme) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return;
}
// Verify param: window; type: refptr_diff
DCHECK(window);
if (!window) {
return;
}
// Execute
CefWindowDelegateCppToC::Get(self)->OnThemeColorsChanged(
CefWindowCToCpp::Wrap(window), chrome_theme ? true : false);
}
cef_size_t CEF_CALLBACK
window_delegate_get_preferred_size(struct _cef_view_delegate_t* self,
cef_view_t* view) {
@@ -837,12 +885,15 @@ CefWindowDelegateCppToC::CefWindowDelegateCppToC() {
GetStruct()->with_standard_window_buttons =
window_delegate_with_standard_window_buttons;
GetStruct()->get_titlebar_height = window_delegate_get_titlebar_height;
GetStruct()->accepts_first_mouse = window_delegate_accepts_first_mouse;
GetStruct()->can_resize = window_delegate_can_resize;
GetStruct()->can_maximize = window_delegate_can_maximize;
GetStruct()->can_minimize = window_delegate_can_minimize;
GetStruct()->can_close = window_delegate_can_close;
GetStruct()->on_accelerator = window_delegate_on_accelerator;
GetStruct()->on_key_event = window_delegate_on_key_event;
GetStruct()->on_theme_colors_changed =
window_delegate_on_theme_colors_changed;
GetStruct()->base.base.get_preferred_size =
window_delegate_get_preferred_size;
GetStruct()->base.base.get_minimum_size = window_delegate_get_minimum_size;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=0a40603ce9d3cb6ee7758c4d8ebad8c2299256cf$
// $hash=2ef28289570e9eba45c5e2bb87c94e7e8e51ed0e$
//
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
@@ -239,10 +239,11 @@ void CefRenderHandlerCToCpp::OnPaint(CefRefPtr<CefBrowser> browser,
}
NO_SANITIZE("cfi-icall")
void CefRenderHandlerCToCpp::OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
void* shared_handle) {
void CefRenderHandlerCToCpp::OnAcceleratedPaint(
CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
const CefAcceleratedPaintInfo& info) {
shutdown_checker::AssertNotShutdown();
cef_render_handler_t* _struct = GetStruct();
@@ -257,11 +258,6 @@ void CefRenderHandlerCToCpp::OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
if (!browser.get()) {
return;
}
// Verify param: shared_handle; type: simple_byaddr
DCHECK(shared_handle);
if (!shared_handle) {
return;
}
// Translate param: dirtyRects; type: simple_vec_byref_const
const size_t dirtyRectsCount = dirtyRects.size();
@@ -278,7 +274,7 @@ void CefRenderHandlerCToCpp::OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
// Execute
_struct->on_accelerated_paint(_struct, CefBrowserCppToC::Wrap(browser), type,
dirtyRectsCount, dirtyRectsList, shared_handle);
dirtyRectsCount, dirtyRectsList, &info);
// Restore param:dirtyRects; type: simple_vec_byref_const
if (dirtyRectsList) {

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=b1028055c90d484e6548009d8bb6e69e06ac1d17$
// $hash=ae20df54c0accee56380672fa4c7e501a0037348$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_
@@ -56,7 +56,7 @@ class CefRenderHandlerCToCpp
void OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
void* shared_handle) override;
const CefAcceleratedPaintInfo& info) override;
void GetTouchHandleSize(CefRefPtr<CefBrowser> browser,
cef_horizontal_alignment_t orientation,
CefSize& size) override;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=64a3528952ccef311d43064975e3447e7806ec25$
// $hash=fadeb722e5e853c5747bb18b1508e4e0221c7019$
//
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
@@ -546,6 +546,69 @@ void CefRequestContextCToCpp::SetContentSetting(
top_level_url.GetStruct(), content_type, value);
}
NO_SANITIZE("cfi-icall")
void CefRequestContextCToCpp::SetChromeColorScheme(cef_color_variant_t variant,
cef_color_t user_color) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, set_chrome_color_scheme)) {
return;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
_struct->set_chrome_color_scheme(_struct, variant, user_color);
}
NO_SANITIZE("cfi-icall")
cef_color_variant_t CefRequestContextCToCpp::GetChromeColorSchemeMode() {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_chrome_color_scheme_mode)) {
return CEF_COLOR_VARIANT_SYSTEM;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_color_variant_t _retval = _struct->get_chrome_color_scheme_mode(_struct);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
cef_color_t CefRequestContextCToCpp::GetChromeColorSchemeColor() {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_chrome_color_scheme_color)) {
return 0;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_color_t _retval = _struct->get_chrome_color_scheme_color(_struct);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
cef_color_variant_t CefRequestContextCToCpp::GetChromeColorSchemeVariant() {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_chrome_color_scheme_variant)) {
return CEF_COLOR_VARIANT_SYSTEM;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_color_variant_t _retval =
_struct->get_chrome_color_scheme_variant(_struct);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
bool CefRequestContextCToCpp::HasPreference(const CefString& name) {
cef_preference_manager_t* _struct =

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=34b4d674c378da826baafd00b0ed352441d17482$
// $hash=daa5d7e0fa0e6b882ca98d9b4be5e6f5c81ddbde$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_CTOCPP_H_
@@ -84,6 +84,11 @@ class CefRequestContextCToCpp
const CefString& top_level_url,
cef_content_setting_types_t content_type,
cef_content_setting_values_t value) override;
void SetChromeColorScheme(cef_color_variant_t variant,
cef_color_t user_color) override;
cef_color_variant_t GetChromeColorSchemeMode() override;
cef_color_t GetChromeColorSchemeColor() override;
cef_color_variant_t GetChromeColorSchemeVariant() override;
// CefPreferenceManager methods.
bool HasPreference(const CefString& name) override;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=f5c482db02b530d627e487b8ba71019577910637$
// $hash=fce37150f543768b0e9df8c5b8163d0ac4829a52$
//
#include "libcef_dll/ctocpp/views/browser_view_ctocpp.h"
@@ -864,6 +864,24 @@ cef_color_t CefBrowserViewCToCpp::GetBackgroundColor() {
return _retval;
}
NO_SANITIZE("cfi-icall")
cef_color_t CefBrowserViewCToCpp::GetThemeColor(int color_id) {
shutdown_checker::AssertNotShutdown();
cef_view_t* _struct = reinterpret_cast<cef_view_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, get_theme_color)) {
return 0;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_color_t _retval = _struct->get_theme_color(_struct, color_id);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
bool CefBrowserViewCToCpp::ConvertPointToScreen(CefPoint& point) {
shutdown_checker::AssertNotShutdown();

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=47b5f2dd231632b2ed2ca843ff1925cabac6d2a8$
// $hash=d407851a21f82fc67289bd6314f31f46e07870df$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BROWSER_VIEW_CTOCPP_H_
@@ -83,6 +83,7 @@ class CefBrowserViewCToCpp : public CefCToCppRefCounted<CefBrowserViewCToCpp,
void RequestFocus() override;
void SetBackgroundColor(cef_color_t color) override;
cef_color_t GetBackgroundColor() override;
cef_color_t GetThemeColor(int color_id) override;
bool ConvertPointToScreen(CefPoint& point) override;
bool ConvertPointFromScreen(CefPoint& point) override;
bool ConvertPointToWindow(CefPoint& point) override;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=ff414aa670f0c92cb67f6f18fbe8c7a25034635b$
// $hash=f71e4f87086a3fb6d20a922af417bc47c81dbc7c$
//
#include "libcef_dll/ctocpp/views/button_ctocpp.h"
@@ -861,6 +861,24 @@ NO_SANITIZE("cfi-icall") cef_color_t CefButtonCToCpp::GetBackgroundColor() {
return _retval;
}
NO_SANITIZE("cfi-icall")
cef_color_t CefButtonCToCpp::GetThemeColor(int color_id) {
shutdown_checker::AssertNotShutdown();
cef_view_t* _struct = reinterpret_cast<cef_view_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, get_theme_color)) {
return 0;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_color_t _retval = _struct->get_theme_color(_struct, color_id);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
bool CefButtonCToCpp::ConvertPointToScreen(CefPoint& point) {
shutdown_checker::AssertNotShutdown();

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=fc28306db14011294cbb7e7ef277ddd35d5667f0$
// $hash=c8c1e03aa10a0ea469774ccd59640fcec2487513$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BUTTON_CTOCPP_H_
@@ -87,6 +87,7 @@ class CefButtonCToCpp
void RequestFocus() override;
void SetBackgroundColor(cef_color_t color) override;
cef_color_t GetBackgroundColor() override;
cef_color_t GetThemeColor(int color_id) override;
bool ConvertPointToScreen(CefPoint& point) override;
bool ConvertPointFromScreen(CefPoint& point) override;
bool ConvertPointToWindow(CefPoint& point) override;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=e4d98e5ef3ec602b76f42fa4c4d4f5436a8ff53a$
// $hash=771ab2674e580450d8a0478435305bccc2440cae$
//
#include "libcef_dll/ctocpp/views/label_button_ctocpp.h"
@@ -1089,6 +1089,24 @@ cef_color_t CefLabelButtonCToCpp::GetBackgroundColor() {
return _retval;
}
NO_SANITIZE("cfi-icall")
cef_color_t CefLabelButtonCToCpp::GetThemeColor(int color_id) {
shutdown_checker::AssertNotShutdown();
cef_view_t* _struct = reinterpret_cast<cef_view_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, get_theme_color)) {
return 0;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_color_t _retval = _struct->get_theme_color(_struct, color_id);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
bool CefLabelButtonCToCpp::ConvertPointToScreen(CefPoint& point) {
shutdown_checker::AssertNotShutdown();

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=a22e6b723998dcbfc9c9ff8fd52dd1dfdd3ce772$
// $hash=3ba705772b9bd57b5abac5f7128bc5afe148c83a$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_LABEL_BUTTON_CTOCPP_H_
@@ -102,6 +102,7 @@ class CefLabelButtonCToCpp : public CefCToCppRefCounted<CefLabelButtonCToCpp,
void RequestFocus() override;
void SetBackgroundColor(cef_color_t color) override;
cef_color_t GetBackgroundColor() override;
cef_color_t GetThemeColor(int color_id) override;
bool ConvertPointToScreen(CefPoint& point) override;
bool ConvertPointFromScreen(CefPoint& point) override;
bool ConvertPointToWindow(CefPoint& point) override;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=da5ea80e7619690e181a8d1aade3baab524994af$
// $hash=510f6e414ccd2152a39fdcd12447071794b649c2$
//
#include "libcef_dll/ctocpp/views/menu_button_ctocpp.h"
@@ -1136,6 +1136,24 @@ NO_SANITIZE("cfi-icall") cef_color_t CefMenuButtonCToCpp::GetBackgroundColor() {
return _retval;
}
NO_SANITIZE("cfi-icall")
cef_color_t CefMenuButtonCToCpp::GetThemeColor(int color_id) {
shutdown_checker::AssertNotShutdown();
cef_view_t* _struct = reinterpret_cast<cef_view_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, get_theme_color)) {
return 0;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_color_t _retval = _struct->get_theme_color(_struct, color_id);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
bool CefMenuButtonCToCpp::ConvertPointToScreen(CefPoint& point) {
shutdown_checker::AssertNotShutdown();

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