Compare commits

...

21 Commits
5563 ... 5359

Author SHA1 Message Date
Marshall Greenblatt
a98cd4cdc0 Update to Chromium version 108.0.5359.125 2022-12-14 17:26:26 +00:00
Marshall Greenblatt
2e23cedb41 Update to Chromium version 108.0.5359.71 2022-12-01 20:30:09 +00:00
Marshall Greenblatt
9e367620cb Update to Chromium version 108.0.5359.62 2022-11-29 20:14:09 +00:00
Marshall Greenblatt
8d6f4e38bc mac: Fix harfbuzz sprintf compile error with macOS 14 SDK. 2022-11-17 12:12:00 -05:00
Marshall Greenblatt
6f1563868d Update to Chromium version 108.0.5359.48 2022-11-17 16:44:54 +00:00
Marshall Greenblatt
b950336a00 linux: Set use_allocator=none by default (see issue #3095) 2022-11-16 13:48:03 -05:00
Marshall Greenblatt
ca0a1134ea mac: Fix bug in GetNSBoundsInDisplay (see issue #3359) 2022-11-16 13:48:03 -05:00
Marshall Greenblatt
e874c768d7 tests: Fix CorsTest.Iframe failures (see issue #3348)
Run test initialization after the server has started.
2022-11-16 13:48:03 -05:00
Marshall Greenblatt
496c871d1e Update to Chromium version 108.0.5359.40 2022-11-10 16:36:30 +00:00
Marshall Greenblatt
414dbb1674 win: Fix 1px gap with maximized frameless windows on Win11 (fixes issue #3414) 2022-11-09 13:09:50 -05:00
Rye Mutt
9ea9e58074 win: tools: Add VS2022 to msvs_env.bat 2022-11-08 17:24:05 -05:00
Marshall Greenblatt
518ad36ac8 cefclient: mac: Support window state restore (see issue #3359)
The cefclient sample app on macOS will persist window state across application
restart if run with cache_path and persist_user_references enabled.

To test:
1. Run `cefclient --cache-path=/path/to/cache --persist-user-preferences`
2. Move or resize the window, maximize, minimize, etc.
3. Exit cefclient.
4. Run cefclient again with the same arguments. The previous window state will
   be restored.
2022-11-08 16:47:26 -05:00
Marshall Greenblatt
a614475a0e Update to Chromium version 108.0.5359.30 2022-11-07 22:10:00 +00:00
Marshall Greenblatt
117413e2a3 cefclient: win: Support window state restore (see issue #3359)
The cefclient sample app on Windows will persist window state across application
restart if run with cache_path and persist_user_references enabled.

To test:
1. Run `cefclient --cache-path=/path/to/cache --persist-user-preferences`
2. Move or resize the window, maximize, minimize, etc.
3. Exit cefclient.
4. Run cefclient again with the same arguments. The previous window state will
   be restored.
2022-11-07 15:26:21 -05:00
Marshall Greenblatt
8bc83a973d cefclient: views: Support window state restore (see issue #3359)
The cefclient sample app will persist window state across application restart
if run with views, cache_path and persist_user_references enabled.

To test:
1. Run `cefclient --use-views --cache-path=/path/to/cache --persist-user-preferences`
2. Move or resize the window, maximize, minimize, etc.
3. Exit cefclient.
4. Run cefclient again with the same arguments. The previous window state will
   be restored.
2022-11-07 11:29:59 -05:00
Marshall Greenblatt
fba80ef0f9 Support registration of custom preferences.
Custom global and request context preferences can now be registered via
CefBrowserProcessHandler::OnRegisterCustomPreferences. CefRequestContext
now extends CefPreferenceManager and global preferences can be accessed
via CefPreferenceManager::GetGlobalPreferenceManager.
2022-11-07 11:29:47 -05:00
Marshall Greenblatt
7bc9b87d5e windows: Fix size/placement with multi-DPI screen setup (fixes issue #3359)
Use ScreenWin functions to correctly compute DIP/pixel conversions for
CEF-created top-level windows.

Fix incorrect DIPToScreenRect usage in DesktopWindowTreeHostWin when
|has_external_parent_| is true.
2022-11-07 11:29:38 -05:00
Marshall Greenblatt
85c53029bf windows: Configure stack size for executables (fixes issue #3250)
Change the default stack size to 8 MiB for 64-bit and 0.5 MiB for 32-bit.

CEF's main thread needs at least a 1.5 MiB stack size in order to avoid
stack overflow crashes. However, if this is set in the PE file then other
threads get this size as well, leading to address-space exhaustion in 32-bit
CEF. A new CefRunWinMainWithPreferredStackSize function uses fibers to switch
the main thread to a 4 MiB stack (roughly the same effective size as the
64-bit build's 8 MiB stack) before running any other code.

This change additionally moves the existing Windows-only functions
CefSetOSModalLoop and CefEnableHighDPISupport from cef_app.h to cef_win.h.
2022-11-07 11:29:27 -05:00
Marshall Greenblatt
5050c3f0af Remove obsolete call to _set_FMA3_enable(0)
This call was longer required after the switch to VS2015 (see
https://crbug.com/586618).
2022-11-07 11:29:15 -05:00
Marshall Greenblatt
7add4a33d4 alloy: Fix renderer crashes related to BadgeService (fixes issue #3005) 2022-10-20 12:50:55 -04:00
Marshall Greenblatt
e8fe3cfeaf Update to Chromium version 108.0.5359.10 2022-10-19 16:08:43 -04:00
115 changed files with 4005 additions and 1098 deletions

View File

@@ -611,6 +611,8 @@ source_set("libcef_static") {
"libcef/browser/frame_host_impl.cc",
"libcef/browser/frame_host_impl.h",
"libcef/browser/frame_service_base.h",
"libcef/browser/global_preference_manager_impl.cc",
"libcef/browser/global_preference_manager_impl.h",
"libcef/browser/image_impl.cc",
"libcef/browser/image_impl.h",
"libcef/browser/iothread_state.cc",
@@ -709,6 +711,10 @@ source_set("libcef_static") {
"libcef/browser/permission_prompt.h",
"libcef/browser/prefs/browser_prefs.cc",
"libcef/browser/prefs/browser_prefs.h",
"libcef/browser/prefs/pref_helper.cc",
"libcef/browser/prefs/pref_helper.h",
"libcef/browser/prefs/pref_registrar.cc",
"libcef/browser/prefs/pref_registrar.h",
"libcef/browser/prefs/pref_store.cc",
"libcef/browser/prefs/pref_store.h",
"libcef/browser/prefs/renderer_prefs.cc",
@@ -1210,6 +1216,21 @@ config("libcef_dll_wrapper_config") {
]
configs = [ ":libcef_autogen_config" ]
if (is_win) {
if (current_cpu == "x86") {
# Set the initial stack size to 0.5MiB, instead of the 1.5MiB minimum
# needed by CEF's main thread. This saves significant memory on threads
# (like those in the Windows thread pool, and others) whose stack size we
# can only control through this setting. The main thread (in 32-bit builds
# only) uses fibers to switch to a 4MiB stack at runtime via
# CefRunWinMainWithPreferredStackSize().
ldflags = [ "/STACK:0x80000" ]
} else {
# Increase the initial stack size to 8MiB from the default 1MiB.
ldflags = [ "/STACK:0x800000" ]
}
}
}
# libcef_dll_wrapper target.

View File

@@ -7,5 +7,6 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/108.0.5359.0'
'chromium_checkout': 'refs/tags/108.0.5359.125',
'depot_tools_checkout': '64b6175557'
}

View File

@@ -2375,7 +2375,8 @@ PREDEFINED = USING_CEF_SHARED \
OS_WIN \
OS_LINUX \
CEF_X11 \
OS_MAC
OS_MAC \
ARCH_CPU_32_BITS
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=ffc0502a0275b74228f1fd642566d3f020e538a0$
# $hash=0373d7e3fc02d16a128a5891aac70af56fb9ddc1$
#
{
@@ -56,6 +56,7 @@
'include/cef_parser.h',
'include/cef_path_util.h',
'include/cef_permission_handler.h',
'include/cef_preference.h',
'include/cef_print_handler.h',
'include/cef_print_settings.h',
'include/cef_process_message.h',
@@ -159,6 +160,7 @@
'include/capi/cef_parser_capi.h',
'include/capi/cef_path_util_capi.h',
'include/capi/cef_permission_handler_capi.h',
'include/capi/cef_preference_capi.h',
'include/capi/cef_print_handler_capi.h',
'include/capi/cef_print_settings_capi.h',
'include/capi/cef_process_message_capi.h',
@@ -382,6 +384,10 @@
'libcef_dll/cpptoc/post_data_cpptoc.h',
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
'libcef_dll/cpptoc/post_data_element_cpptoc.h',
'libcef_dll/cpptoc/preference_manager_cpptoc.cc',
'libcef_dll/cpptoc/preference_manager_cpptoc.h',
'libcef_dll/cpptoc/preference_registrar_cpptoc.cc',
'libcef_dll/cpptoc/preference_registrar_cpptoc.h',
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.cc',
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.h',
'libcef_dll/ctocpp/print_handler_ctocpp.cc',
@@ -706,6 +712,10 @@
'libcef_dll/ctocpp/post_data_ctocpp.h',
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
'libcef_dll/ctocpp/post_data_element_ctocpp.h',
'libcef_dll/ctocpp/preference_manager_ctocpp.cc',
'libcef_dll/ctocpp/preference_manager_ctocpp.h',
'libcef_dll/ctocpp/preference_registrar_ctocpp.cc',
'libcef_dll/ctocpp/preference_registrar_ctocpp.h',
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.cc',
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.h',
'libcef_dll/cpptoc/print_handler_cpptoc.cc',

View File

@@ -79,6 +79,7 @@
'include/internal/cef_win.h',
],
'includes_win_capi': [
'include/internal/cef_app_win.h',
'include/internal/cef_types_win.h',
],
'includes_mac': [
@@ -233,6 +234,8 @@
'tests/cefclient/browser/client_handler_osr.h',
'tests/cefclient/browser/client_handler_std.cc',
'tests/cefclient/browser/client_handler_std.h',
'tests/cefclient/browser/client_prefs.cc',
'tests/cefclient/browser/client_prefs.h',
'tests/cefclient/browser/client_types.h',
'tests/cefclient/browser/dialog_test.cc',
'tests/cefclient/browser/dialog_test.h',

View File

@@ -448,6 +448,23 @@ if(OS_WINDOWS)
NDEBUG _NDEBUG # Not a debug build
)
if(PROJECT_ARCH STREQUAL "x86")
# Set the initial stack size to 0.5MiB, instead of the 1.5MiB minimum
# needed by CEF's main thread. This saves significant memory on threads
# (like those in the Windows thread pool, and others) whose stack size we
# can only control through this setting. The main thread (in 32-bit builds
# only) uses fibers to switch to a 4MiB stack at runtime via
# CefRunWinMainWithPreferredStackSize().
list(APPEND CEF_EXE_LINKER_FLAGS
/STACK:0x8000
)
else()
# Increase the initial stack size to 8MiB from the default 1MiB.
list(APPEND CEF_EXE_LINKER_FLAGS
/STACK:0x800000
)
endif()
# Standard libraries.
set(CEF_STANDARD_LIBS
comctl32.lib

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=7c6894aae3e508aaa42a376532328316d9bd509c$
// $hash=2f4bdc6adde5defdc86dbb5c998266d6372dd164$
//
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
@@ -183,19 +183,6 @@ CEF_EXPORT void cef_run_message_loop(void);
///
CEF_EXPORT void cef_quit_message_loop(void);
///
/// Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a
/// modal message loop. Set to false (0) after exiting the modal message loop.
///
CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop);
///
/// Call during process startup to enable High-DPI support on Windows 7 or
/// newer. Older versions of Windows should be left DPI-unaware because they do
/// not support DirectWrite and GDI fonts are kerned very badly.
///
CEF_EXPORT void cef_enable_highdpi_support(void);
#ifdef __cplusplus
}
#endif

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=c4ed4278e513daa2a1ccf42e50e242d61dfbb86f$
// $hash=a4d3026623111f1ba226d1579c6b03de3b924457$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
@@ -43,6 +43,7 @@
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_client_capi.h"
#include "include/capi/cef_command_line_capi.h"
#include "include/capi/cef_preference_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
@@ -60,6 +61,33 @@ typedef struct _cef_browser_process_handler_t {
///
cef_base_ref_counted_t base;
///
/// Provides an opportunity to register custom preferences prior to global and
/// request context initialization.
///
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
/// accessed via cef_preference_manager_t::GetGlobalPreferences after
/// OnContextInitialized is called. Global preferences are registered a single
/// time at application startup. See related cef_settings_t.cache_path and
/// cef_settings_t.persist_user_preferences configuration.
///
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
/// accessed via the cef_request_context_t after
/// cef_request_context_handler_t::OnRequestContextInitialized is called.
/// Request context preferences are registered each time a new
/// cef_request_context_t is created. It is intended but not required that all
/// request contexts have the same registered preferences. See related
/// cef_request_context_settings_t.cache_path and
/// cef_request_context_settings_t.persist_user_preferences configuration.
///
/// Do not keep a reference to the |registrar| object. This function is called
/// on the browser process UI thread.
///
void(CEF_CALLBACK* on_register_custom_preferences)(
struct _cef_browser_process_handler_t* self,
cef_preferences_type_t type,
struct _cef_preference_registrar_t* registrar);
///
/// Called on the browser process UI thread immediately after the CEF context
/// has been initialized.

View File

@@ -0,0 +1,148 @@
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=eac0782793e7b9c64668f2a22a859357257140ea$
//
#ifndef CEF_INCLUDE_CAPI_CEF_PREFERENCE_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_PREFERENCE_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
/// Structure that manages custom preference registrations.
///
typedef struct _cef_preference_registrar_t {
///
/// Base structure.
///
cef_base_scoped_t base;
///
/// Register a preference with the specified |name| and |default_value|. To
/// avoid conflicts with built-in preferences the |name| value should contain
/// an application-specific prefix followed by a period (e.g. "myapp.value").
/// The contents of |default_value| will be copied. The data type for the
/// preference will be inferred from |default_value|'s type and cannot be
/// changed after registration. Returns true (1) on success. Returns false (0)
/// if |name| is already registered or if |default_value| has an invalid type.
/// This function must be called from within the scope of the
/// cef_browser_process_handler_t::OnRegisterCustomPreferences callback.
///
int(CEF_CALLBACK* add_preference)(struct _cef_preference_registrar_t* self,
const cef_string_t* name,
struct _cef_value_t* default_value);
} cef_preference_registrar_t;
///
/// Manage access to preferences. Many built-in preferences are registered by
/// Chromium. Custom preferences can be registered in
/// cef_browser_process_handler_t::OnRegisterCustomPreferences.
///
typedef struct _cef_preference_manager_t {
///
/// Base structure.
///
cef_base_ref_counted_t base;
///
/// Returns true (1) if a preference with the specified |name| exists. This
/// function must be called on the browser process UI thread.
///
int(CEF_CALLBACK* has_preference)(struct _cef_preference_manager_t* self,
const cef_string_t* name);
///
/// Returns the value for the preference with the specified |name|. Returns
/// NULL if the preference does not exist. The returned object contains a copy
/// of the underlying preference value and modifications to the returned
/// object will not modify the underlying preference value. This function must
/// be called on the browser process UI thread.
///
struct _cef_value_t*(CEF_CALLBACK* get_preference)(
struct _cef_preference_manager_t* self,
const cef_string_t* name);
///
/// Returns all preferences as a dictionary. If |include_defaults| is true (1)
/// then preferences currently at their default value will be included. The
/// returned object contains a copy of the underlying preference values and
/// modifications to the returned object will not modify the underlying
/// preference values. This function must be called on the browser process UI
/// thread.
///
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)(
struct _cef_preference_manager_t* self,
int include_defaults);
///
/// Returns true (1) if the preference with the specified |name| can be
/// modified using SetPreference. As one example preferences set via the
/// command-line usually cannot be modified. This function must be called on
/// the browser process UI thread.
///
int(CEF_CALLBACK* can_set_preference)(struct _cef_preference_manager_t* self,
const cef_string_t* name);
///
/// Set the |value| associated with preference |name|. Returns true (1) if the
/// value is set successfully and false (0) otherwise. If |value| is NULL the
/// preference will be restored to its default value. If setting the
/// preference fails then |error| will be populated with a detailed
/// description of the problem. This function must be called on the browser
/// process UI thread.
///
int(CEF_CALLBACK* set_preference)(struct _cef_preference_manager_t* self,
const cef_string_t* name,
struct _cef_value_t* value,
cef_string_t* error);
} cef_preference_manager_t;
///
/// Returns the global preference manager object.
///
CEF_EXPORT cef_preference_manager_t* cef_preference_manager_get_global(void);
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_PREFERENCE_CAPI_H_

View File

@@ -0,0 +1,116 @@
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=1f5dd49cfc5aeb4b673c10750de01768f5cd2694$
//
#ifndef CEF_INCLUDE_CAPI_CEF_PREFERENCE_MANAGER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_PREFERENCE_MANAGER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
/// Manage access to preferences.
///
typedef struct _cef_preference_manager_t {
///
/// Base structure.
///
cef_base_ref_counted_t base;
///
/// Returns true (1) if a preference with the specified |name| exists. This
/// function must be called on the browser process UI thread.
///
int(CEF_CALLBACK* has_preference)(struct _cef_preference_manager_t* self,
const cef_string_t* name);
///
/// Returns the value for the preference with the specified |name|. Returns
/// NULL if the preference does not exist. The returned object contains a copy
/// of the underlying preference value and modifications to the returned
/// object will not modify the underlying preference value. This function must
/// be called on the browser process UI thread.
///
struct _cef_value_t*(CEF_CALLBACK* get_preference)(
struct _cef_preference_manager_t* self,
const cef_string_t* name);
///
/// Returns all preferences as a dictionary. If |include_defaults| is true (1)
/// then preferences currently at their default value will be included. The
/// returned object contains a copy of the underlying preference values and
/// modifications to the returned object will not modify the underlying
/// preference values. This function must be called on the browser process UI
/// thread.
///
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)(
struct _cef_preference_manager_t* self,
int include_defaults);
///
/// Returns true (1) if the preference with the specified |name| can be
/// modified using SetPreference. As one example preferences set via the
/// command-line usually cannot be modified. This function must be called on
/// the browser process UI thread.
///
int(CEF_CALLBACK* can_set_preference)(struct _cef_preference_manager_t* self,
const cef_string_t* name);
///
/// Set the |value| associated with preference |name|. Returns true (1) if the
/// value is set successfully and false (0) otherwise. If |value| is NULL the
/// preference will be restored to its default value. If setting the
/// preference fails then |error| will be populated with a detailed
/// description of the problem. This function must be called on the browser
/// process UI thread.
///
int(CEF_CALLBACK* set_preference)(struct _cef_preference_manager_t* self,
const cef_string_t* name,
struct _cef_value_t* value,
cef_string_t* error);
} cef_preference_manager_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_PREFERENCE_MANAGER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=0c12192146d0ecf006c1f3f294a4c2fd4bec484b$
// $hash=62f9dd603840149334ecd1f25222dbda0682b0e6$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@@ -45,7 +45,7 @@
#include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/capi/cef_media_router_capi.h"
#include "include/capi/cef_values_capi.h"
#include "include/capi/cef_preference_capi.h"
#ifdef __cplusplus
extern "C" {
@@ -93,7 +93,7 @@ typedef struct _cef_request_context_t {
///
/// Base structure.
///
cef_base_ref_counted_t base;
cef_preference_manager_t base;
///
/// Returns true (1) if this object is pointing to the same context as |that|
@@ -165,58 +165,6 @@ typedef struct _cef_request_context_t {
int(CEF_CALLBACK* clear_scheme_handler_factories)(
struct _cef_request_context_t* self);
///
/// Returns true (1) if a preference with the specified |name| exists. This
/// function must be called on the browser process UI thread.
///
int(CEF_CALLBACK* has_preference)(struct _cef_request_context_t* self,
const cef_string_t* name);
///
/// Returns the value for the preference with the specified |name|. Returns
/// NULL if the preference does not exist. The returned object contains a copy
/// of the underlying preference value and modifications to the returned
/// object will not modify the underlying preference value. This function must
/// be called on the browser process UI thread.
///
struct _cef_value_t*(CEF_CALLBACK* get_preference)(
struct _cef_request_context_t* self,
const cef_string_t* name);
///
/// Returns all preferences as a dictionary. If |include_defaults| is true (1)
/// then preferences currently at their default value will be included. The
/// returned object contains a copy of the underlying preference values and
/// modifications to the returned object will not modify the underlying
/// preference values. This function must be called on the browser process UI
/// thread.
///
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)(
struct _cef_request_context_t* self,
int include_defaults);
///
/// Returns true (1) if the preference with the specified |name| can be
/// modified using SetPreference. As one example preferences set via the
/// command-line usually cannot be modified. This function must be called on
/// the browser process UI thread.
///
int(CEF_CALLBACK* can_set_preference)(struct _cef_request_context_t* self,
const cef_string_t* name);
///
/// Set the |value| associated with preference |name|. Returns true (1) if the
/// value is set successfully and false (0) otherwise. If |value| is NULL the
/// preference will be restored to its default value. If setting the
/// preference fails then |error| will be populated with a detailed
/// description of the problem. This function must be called on the browser
/// process UI thread.
///
int(CEF_CALLBACK* set_preference)(struct _cef_request_context_t* self,
const cef_string_t* name,
struct _cef_value_t* value,
cef_string_t* error);
///
/// Clears all certificate exceptions that were added as part of handling
/// cef_request_handler_t::on_certificate_error(). If you call this it is

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=e2a1abf4d73bb90fb077cc5642d7b95ac5c11c14$
// $hash=c25acf0c0dde9bbd8b9b3526e161aaa9e00445c8$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_HANDLER_CAPI_H_
@@ -43,6 +43,7 @@
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#include "include/capi/cef_frame_capi.h"
#include "include/capi/cef_preference_capi.h"
#include "include/capi/cef_request_capi.h"
#include "include/capi/cef_resource_request_handler_capi.h"

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=6eed21d200bad5e898dfbe2701ad327cc1e4cc5c$
// $hash=912c23bc842c87aeca79780746c31e3fe848013a$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_DISPLAY_CAPI_H_
@@ -154,6 +154,20 @@ cef_display_convert_screen_point_to_pixels(const cef_point_t* point);
CEF_EXPORT cef_point_t
cef_display_convert_screen_point_from_pixels(const cef_point_t* point);
///
/// Convert |rect| from DIP screen coordinates to pixel screen coordinates. This
/// function is only used on Windows.
///
CEF_EXPORT cef_rect_t
cef_display_convert_screen_rect_to_pixels(const cef_rect_t* rect);
///
/// Convert |rect| from pixel screen coordinates to DIP screen coordinates. This
/// function is only used on Windows.
///
CEF_EXPORT cef_rect_t
cef_display_convert_screen_rect_from_pixels(const cef_rect_t* rect);
#ifdef __cplusplus
}
#endif

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=ea84b76b6965d1419e416581d87e82f74680bd07$
// $hash=e1657ed68132b846ad638dc87bc5ee9b9c10f014$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
@@ -65,6 +65,12 @@ typedef struct _cef_window_delegate_t {
void(CEF_CALLBACK* on_window_created)(struct _cef_window_delegate_t* self,
struct _cef_window_t* window);
///
/// Called when |window| is closing.
///
void(CEF_CALLBACK* on_window_closing)(struct _cef_window_delegate_t* self,
struct _cef_window_t* window);
///
/// Called when |window| is destroyed. Release all references to |window| and
/// do not attempt to execute any functions on |window| after this callback
@@ -81,6 +87,15 @@ typedef struct _cef_window_delegate_t {
struct _cef_window_t* window,
int active);
///
/// Called when |window| bounds have changed. |new_bounds| will be in DIP
/// screen coordinates.
///
void(CEF_CALLBACK* on_window_bounds_changed)(
struct _cef_window_delegate_t* self,
struct _cef_window_t* window,
const cef_rect_t* new_bounds);
///
/// Return the parent for |window| or NULL if the |window| does not have a
/// parent. Windows with parents will not get a taskbar button. Set |is_menu|

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 "b52718166004e2be9d225454b9999445e1a5d131"
#define CEF_API_HASH_UNIVERSAL "e92cde673e73851d8841e2f3c4f38bcd0f6ed2bb"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "f327210f819821b0f53a9071281622e16c8515bd"
#define CEF_API_HASH_PLATFORM "162bfdae56cbfd7f76fd4178be019f0dba512c40"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "41b7d845bec3d93f820e6e940583085351fda410"
#define CEF_API_HASH_PLATFORM "31c5680dbc8d80fffc14214dd1ce4126a08e38d3"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "fd19a4db781e699f7b2492f9fc2c63544934a6e4"
#define CEF_API_HASH_PLATFORM "9682b2251f9973ee9eee0940eb9c773e522c2975"
#endif
#ifdef __cplusplus

View File

@@ -123,21 +123,6 @@ void CefRunMessageLoop();
/*--cef()--*/
void CefQuitMessageLoop();
///
/// Set to true before calling Windows APIs like TrackPopupMenu that enter a
/// modal message loop. Set to false after exiting the modal message loop.
///
/*--cef()--*/
void CefSetOSModalLoop(bool osModalLoop);
///
/// Call during process startup to enable High-DPI support on Windows 7 or
/// newer. Older versions of Windows should be left DPI-unaware because they do
/// not support DirectWrite and GDI fonts are kerned very badly.
///
/*--cef(capi_name=cef_enable_highdpi_support)--*/
void CefEnableHighDPISupport();
///
/// Implement this interface to provide handler implementations. Methods will be
/// called by the process and/or thread indicated.

View File

@@ -41,6 +41,7 @@
#include "include/cef_base.h"
#include "include/cef_client.h"
#include "include/cef_command_line.h"
#include "include/cef_preference.h"
#include "include/cef_values.h"
///
@@ -51,6 +52,33 @@
/*--cef(source=client,no_debugct_check)--*/
class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
public:
///
/// Provides an opportunity to register custom preferences prior to
/// global and request context initialization.
///
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
/// accessed via CefPreferenceManager::GetGlobalPreferences after
/// OnContextInitialized is called. Global preferences are registered a single
/// time at application startup. See related cef_settings_t.cache_path and
/// cef_settings_t.persist_user_preferences configuration.
///
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
/// accessed via the CefRequestContext after
/// CefRequestContextHandler::OnRequestContextInitialized is called. Request
/// context preferences are registered each time a new CefRequestContext is
/// created. It is intended but not required that all request contexts have
/// the same registered preferences. See related
/// cef_request_context_settings_t.cache_path and
/// cef_request_context_settings_t.persist_user_preferences configuration.
///
/// Do not keep a reference to the |registrar| object. This method is called
/// on the browser process UI thread.
///
/*--cef()--*/
virtual void OnRegisterCustomPreferences(
cef_preferences_type_t type,
CefRawPtr<CefPreferenceRegistrar> registrar) {}
///
/// Called on the browser process UI thread immediately after the CEF context
/// has been initialized.

134
include/cef_preference.h Normal file
View File

@@ -0,0 +1,134 @@
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_PREFERENCE_H_
#define CEF_INCLUDE_CEF_PREFERENCE_H_
#pragma once
#include <vector>
#include "include/cef_base.h"
#include "include/cef_values.h"
///
/// Class that manages custom preference registrations.
///
/*--cef(source=library)--*/
class CefPreferenceRegistrar : public CefBaseScoped {
public:
///
/// Register a preference with the specified |name| and |default_value|. To
/// avoid conflicts with built-in preferences the |name| value should contain
/// an application-specific prefix followed by a period (e.g. "myapp.value").
/// The contents of |default_value| will be copied. The data type for the
/// preference will be inferred from |default_value|'s type and cannot be
/// changed after registration. Returns true on success. Returns false if
/// |name| is already registered or if |default_value| has an invalid type.
/// This method must be called from within the scope of the
/// CefBrowserProcessHandler::OnRegisterCustomPreferences callback.
///
/*--cef()--*/
virtual bool AddPreference(const CefString& name,
CefRefPtr<CefValue> default_value) = 0;
};
///
/// Manage access to preferences. Many built-in preferences are registered by
/// Chromium. Custom preferences can be registered in
/// CefBrowserProcessHandler::OnRegisterCustomPreferences.
///
/*--cef(source=library,no_debugct_check)--*/
class CefPreferenceManager : public virtual CefBaseRefCounted {
public:
///
/// Returns the global preference manager object.
///
/*--cef()--*/
static CefRefPtr<CefPreferenceManager> GetGlobalPreferenceManager();
///
/// Returns true if a preference with the specified |name| exists. This method
/// must be called on the browser process UI thread.
///
/*--cef()--*/
virtual bool HasPreference(const CefString& name) = 0;
///
/// Returns the value for the preference with the specified |name|. Returns
/// NULL if the preference does not exist. The returned object contains a copy
/// of the underlying preference value and modifications to the returned
/// object will not modify the underlying preference value. This method must
/// be called on the browser process UI thread.
///
/*--cef()--*/
virtual CefRefPtr<CefValue> GetPreference(const CefString& name) = 0;
///
/// Returns all preferences as a dictionary. If |include_defaults| is true
/// then preferences currently at their default value will be included. The
/// returned object contains a copy of the underlying preference values and
/// modifications to the returned object will not modify the underlying
/// preference values. This method must be called on the browser process UI
/// thread.
///
/*--cef()--*/
virtual CefRefPtr<CefDictionaryValue> GetAllPreferences(
bool include_defaults) = 0;
///
/// Returns true if the preference with the specified |name| can be modified
/// using SetPreference. As one example preferences set via the command-line
/// usually cannot be modified. This method must be called on the browser
/// process UI thread.
///
/*--cef()--*/
virtual bool CanSetPreference(const CefString& name) = 0;
///
/// Set the |value| associated with preference |name|. Returns true if the
/// value is set successfully and false otherwise. If |value| is NULL the
/// preference will be restored to its default value. If setting the
/// preference fails then |error| will be populated with a detailed
/// description of the problem. This method must be called on the browser
/// process UI thread.
///
/*--cef(optional_param=value)--*/
virtual bool SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) = 0;
};
#endif // CEF_INCLUDE_CEF_PREFERENCE_H_

View File

@@ -45,7 +45,7 @@
#include "include/cef_extension.h"
#include "include/cef_extension_handler.h"
#include "include/cef_media_router.h"
#include "include/cef_values.h"
#include "include/cef_preference.h"
class CefRequestContextHandler;
class CefSchemeHandlerFactory;
@@ -84,7 +84,7 @@ class CefResolveCallback : public virtual CefBaseRefCounted {
/// all other request context objects will be ignored.
///
/*--cef(source=library,no_debugct_check)--*/
class CefRequestContext : public virtual CefBaseRefCounted {
class CefRequestContext : public CefPreferenceManager {
public:
///
/// Returns the global context object.
@@ -179,57 +179,6 @@ class CefRequestContext : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual bool ClearSchemeHandlerFactories() = 0;
///
/// Returns true if a preference with the specified |name| exists. This method
/// must be called on the browser process UI thread.
///
/*--cef()--*/
virtual bool HasPreference(const CefString& name) = 0;
///
/// Returns the value for the preference with the specified |name|. Returns
/// NULL if the preference does not exist. The returned object contains a copy
/// of the underlying preference value and modifications to the returned
/// object will not modify the underlying preference value. This method must
/// be called on the browser process UI thread.
///
/*--cef()--*/
virtual CefRefPtr<CefValue> GetPreference(const CefString& name) = 0;
///
/// Returns all preferences as a dictionary. If |include_defaults| is true
/// then preferences currently at their default value will be included. The
/// returned object contains a copy of the underlying preference values and
/// modifications to the returned object will not modify the underlying
/// preference values. This method must be called on the browser process UI
/// thread.
///
/*--cef()--*/
virtual CefRefPtr<CefDictionaryValue> GetAllPreferences(
bool include_defaults) = 0;
///
/// Returns true if the preference with the specified |name| can be modified
/// using SetPreference. As one example preferences set via the command-line
/// usually cannot be modified. This method must be called on the browser
/// process UI thread.
///
/*--cef()--*/
virtual bool CanSetPreference(const CefString& name) = 0;
///
/// Set the |value| associated with preference |name|. Returns true if the
/// value is set successfully and false otherwise. If |value| is NULL the
/// preference will be restored to its default value. If setting the
/// preference fails then |error| will be populated with a detailed
/// description of the problem. This method must be called on the browser
/// process UI thread.
///
/*--cef(optional_param=value)--*/
virtual bool SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) = 0;
///
/// Clears all certificate exceptions that were added as part of handling
/// CefRequestHandler::OnCertificateError(). If you call this it is

View File

@@ -41,6 +41,7 @@
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "include/cef_frame.h"
#include "include/cef_preference.h"
#include "include/cef_request.h"
#include "include/cef_resource_request_handler.h"

View File

@@ -0,0 +1,107 @@
// Copyright (c) 2022 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_APP_WIN_H_
#define CEF_INCLUDE_INTERNAL_CEF_APP_WIN_H_
#pragma once
#include "include/base/cef_build.h"
#if defined(OS_WIN)
#if defined(ARCH_CPU_32_BITS)
#include <windows.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined(ARCH_CPU_32_BITS)
typedef int(APIENTRY* wWinMainPtr)(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nCmdShow);
typedef int (*mainPtr)(int argc, char* argv[]);
///
/// Run the main thread on 32-bit Windows using a fiber with the preferred 4MiB
/// stack size. This function must be called at the top of the executable entry
/// point function (`main()` or `wWinMain()`). It is used in combination with
/// the initial stack size of 0.5MiB configured via the `/STACK:0x80000` linker
/// flag on executable targets. This saves significant memory on threads (like
/// those in the Windows thread pool, and others) whose stack size can only be
/// controlled via the linker flag.
///
/// CEF's main thread needs at least a 1.5 MiB stack size in order to avoid
/// stack overflow crashes. However, if this is set in the PE file then other
/// threads get this size as well, leading to address-space exhaustion in 32-bit
/// CEF. This function uses fibers to switch the main thread to a 4 MiB stack
/// (roughly the same effective size as the 64-bit build's 8 MiB stack) before
/// running any other code.
///
/// Choose the function variant that matches the entry point function type used
/// by the executable. Reusing the entry point minimizes confusion when
/// examining call stacks in crash reports.
///
/// If this function is already running on the fiber it will return -1
/// immediately, meaning that execution should proceed with the remainder of the
/// entry point function. Otherwise, this function will block until the entry
/// point function has completed execution on the fiber and then return a result
/// >= 0, meaning that the entry point function should return the result
/// immediately without proceeding with execution.
///
CEF_EXPORT int cef_run_winmain_with_preferred_stack_size(wWinMainPtr wWinMain,
HINSTANCE hInstance,
LPWSTR lpCmdLine,
int nCmdShow);
CEF_EXPORT int cef_run_main_with_preferred_stack_size(mainPtr main,
int argc,
char* argv[]);
#endif // defined(ARCH_CPU_32_BITS)
///
/// Call during process startup to enable High-DPI support on Windows 7 or
/// newer. Older versions of Windows should be left DPI-unaware because they do
/// not support DirectWrite and GDI fonts are kerned very badly.
///
CEF_EXPORT void cef_enable_highdpi_support(void);
///
/// Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a
/// modal message loop. Set to false (0) after exiting the modal message loop.
///
CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop);
#ifdef __cplusplus
}
#endif
#endif // defined(OS_WIN)
#endif // CEF_INCLUDE_INTERNAL_CEF_APP_WIN_H_

View File

@@ -3431,6 +3431,19 @@ typedef enum {
CEF_TEST_CERT_EXPIRED,
} cef_test_cert_type_t;
///
/// Preferences type passed to
/// CefBrowserProcessHandler::OnRegisterCustomPreferences.
///
typedef enum {
/// Global preferences registered a single time at application startup.
CEF_PREFERENCES_TYPE_GLOBAL,
/// Request context preferences registered each time a new CefRequestContext
/// is created.
CEF_PREFERENCES_TYPE_REQUEST_CONTEXT,
} cef_preferences_type_t;
#ifdef __cplusplus
}
#endif

View File

@@ -31,6 +31,7 @@
#define CEF_INCLUDE_INTERNAL_CEF_WIN_H_
#pragma once
#include "include/internal/cef_app_win.h"
#include "include/internal/cef_types_win.h"
#include "include/internal/cef_types_wrappers.h"
@@ -132,4 +133,52 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
}
};
#if defined(ARCH_CPU_32_BITS)
///
/// Run the main thread on 32-bit Windows using a fiber with the preferred 4MiB
/// stack size. This function must be called at the top of the executable entry
/// point function (`main()` or `wWinMain()`). It is used in combination with
/// the initial stack size of 0.5MiB configured via the `/STACK:0x80000` linker
/// flag on executable targets. This saves significant memory on threads (like
/// those in the Windows thread pool, and others) whose stack size can only be
/// controlled via the linker flag.
///
/// CEF's main thread needs at least a 1.5 MiB stack size in order to avoid
/// stack overflow crashes. However, if this is set in the PE file then other
/// threads get this size as well, leading to address-space exhaustion in 32-bit
/// CEF. This function uses fibers to switch the main thread to a 4 MiB stack
/// (roughly the same effective size as the 64-bit build's 8 MiB stack) before
/// running any other code.
///
/// Choose the function variant that matches the entry point function type used
/// by the executable. Reusing the entry point minimizes confusion when
/// examining call stacks in crash reports.
///
/// If this function is already running on the fiber it will return -1
/// immediately, meaning that execution should proceed with the remainder of the
/// entry point function. Otherwise, this function will block until the entry
/// point function has completed execution on the fiber and then return a result
/// >= 0, meaning that the entry point function should return the result
/// immediately without proceeding with execution.
///
int CefRunWinMainWithPreferredStackSize(wWinMainPtr wWinMain,
HINSTANCE hInstance,
LPWSTR lpCmdLine,
int nCmdShow);
int CefRunMainWithPreferredStackSize(mainPtr main, int argc, char* argv[]);
#endif // defined(ARCH_CPU_32_BITS)
///
/// Call during process startup to enable High-DPI support on Windows 7 or
/// newer. Older versions of Windows should be left DPI-unaware because they do
/// not support DirectWrite and GDI fonts are kerned very badly.
///
void CefEnableHighDPISupport();
///
/// Set to true before calling Windows APIs like TrackPopupMenu that enter a
/// modal message loop. Set to false after exiting the modal message loop.
///
void CefSetOSModalLoop(bool osModalLoop);
#endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_

View File

@@ -105,6 +105,20 @@ class CefDisplay : public CefBaseRefCounted {
/*--cef()--*/
static CefPoint ConvertScreenPointFromPixels(const CefPoint& point);
///
/// Convert |rect| from DIP screen coordinates to pixel screen coordinates.
/// This method is only used on Windows.
///
/*--cef()--*/
static CefRect ConvertScreenRectToPixels(const CefRect& rect);
///
/// Convert |rect| from pixel screen coordinates to DIP screen coordinates.
/// This method is only used on Windows.
///
/*--cef()--*/
static CefRect ConvertScreenRectFromPixels(const CefRect& rect);
///
/// Returns the unique identifier for this Display.
///

View File

@@ -55,6 +55,12 @@ class CefWindowDelegate : public CefPanelDelegate {
/*--cef()--*/
virtual void OnWindowCreated(CefRefPtr<CefWindow> window) {}
///
/// Called when |window| is closing.
///
/*--cef()--*/
virtual void OnWindowClosing(CefRefPtr<CefWindow> window) {}
///
/// Called when |window| is destroyed. Release all references to |window| and
/// do not attempt to execute any methods on |window| after this callback
@@ -70,6 +76,14 @@ class CefWindowDelegate : public CefPanelDelegate {
virtual void OnWindowActivationChanged(CefRefPtr<CefWindow> window,
bool active) {}
///
/// Called when |window| bounds have changed. |new_bounds| will be in DIP
/// screen coordinates.
///
/*--cef()--*/
virtual void OnWindowBoundsChanged(CefRefPtr<CefWindow> window,
const CefRect& new_bounds) {}
///
/// Return the parent for |window| or NULL if the |window| does not have a
/// parent. Windows with parents will not get a taskbar button. Set |is_menu|

View File

@@ -140,6 +140,7 @@
#include "storage/browser/quota/quota_settings.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#include "third_party/blink/public/mojom/badging/badging.mojom.h"
#include "third_party/blink/public/mojom/prerender/prerender.mojom.h"
#include "third_party/blink/public/web/web_window_features.h"
#include "ui/base/l10n/l10n_util.h"
@@ -377,6 +378,14 @@ void BindPluginInfoHost(
std::move(receiver));
}
void BindBadgeService(
content::RenderFrameHost* frame_host,
mojo::PendingReceiver<blink::mojom::BadgeService> receiver) {}
void BindBadgeServiceForServiceWorker(
const content::ServiceWorkerVersionBaseInfo& info,
mojo::PendingReceiver<blink::mojom::BadgeService> receiver) {}
void BindMediaFoundationRendererNotifierHandler(
content::RenderFrameHost* frame_host,
mojo::PendingReceiver<media::mojom::MediaFoundationRendererNotifier>
@@ -1329,6 +1338,7 @@ void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
CefBrowserFrame::RegisterBrowserInterfaceBindersForFrame(render_frame_host,
map);
map->Add<blink::mojom::BadgeService>(base::BindRepeating(&BindBadgeService));
map->Add<media::mojom::MediaFoundationRendererNotifier>(
base::BindRepeating(&BindMediaFoundationRendererNotifierHandler));
map->Add<network_hints::mojom::NetworkHintsHandler>(
@@ -1358,6 +1368,15 @@ void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
extension);
}
void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForServiceWorker(
content::BrowserContext* browser_context,
const content::ServiceWorkerVersionBaseInfo& service_worker_version_info,
mojo::BinderMapWithContext<const content::ServiceWorkerVersionBaseInfo&>*
map) {
map->Add<blink::mojom::BadgeService>(
base::BindRepeating(&BindBadgeServiceForServiceWorker));
}
base::FilePath
AlloyContentBrowserClient::GetSandboxedStorageServiceDataDirectory() {
return GetRootCachePath();

View File

@@ -227,6 +227,11 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
void RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override;
void RegisterBrowserInterfaceBindersForServiceWorker(
content::BrowserContext* browser_context,
const content::ServiceWorkerVersionBaseInfo& service_worker_version_info,
mojo::BinderMapWithContext<const content::ServiceWorkerVersionBaseInfo&>*
map) override;
base::FilePath GetSandboxedStorageServiceDataDirectory() override;
std::string GetProduct() override;
std::string GetChromeProduct() override;

View File

@@ -21,9 +21,12 @@
#include "ui/base/ui_base_switches.h"
#if BUILDFLAG(IS_WIN)
#include "base/debug/alias.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/win_util.h"
#include "chrome/chrome_elf/chrome_elf_main.h"
#include "chrome/install_static/initialize_from_primary_module.h"
#include "include/internal/cef_win.h"
#endif
namespace {
@@ -39,19 +42,6 @@ class CefShutdownChecker {
#endif // DCHECK_IS_ON()
#if BUILDFLAG(IS_WIN)
#if defined(ARCH_CPU_X86_64)
// VS2013 only checks the existence of FMA3 instructions, not the enabled-ness
// of them at the OS level (this is fixed in VS2015). We force off usage of
// FMA3 instructions in the CRT to avoid using that path and hitting illegal
// instructions when running on CPUs that support FMA3, but OSs that don't.
void DisableFMA3() {
static bool disabled = false;
if (disabled)
return;
disabled = true;
_set_FMA3_enable(0);
}
#endif // defined(ARCH_CPU_X86_64)
// Transfer state from chrome_elf.dll to the libcef.dll. Accessed when
// loading chrome://system.
@@ -72,6 +62,7 @@ void InitCrashReporter() {
initialized = true;
SignalInitializeCrashReporting();
}
#endif // BUILDFLAG(IS_WIN)
bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) {
@@ -170,15 +161,116 @@ base::FilePath NormalizeCachePathAndSet(cef_string_t& path_str,
return path;
}
// Based on chrome/app/chrome_exe_main_win.cc.
// In 32-bit builds, the main thread starts with the default (small) stack size.
// The ARCH_CPU_32_BITS blocks here and below are in support of moving the main
// thread to a fiber with a larger stack size.
#if BUILDFLAG(IS_WIN) && defined(ARCH_CPU_32_BITS)
// The information needed to transfer control to the large-stack fiber and later
// pass the main routine's exit code back to the small-stack fiber prior to
// termination.
struct FiberState {
FiberState(wWinMainPtr wWinMain,
HINSTANCE hInstance,
LPWSTR lpCmdLine,
int nCmdShow) {
this->wWinMain = wWinMain;
this->hInstance = hInstance;
this->lpCmdLine = lpCmdLine;
this->nCmdShow = nCmdShow;
}
FiberState(mainPtr main, int argc, char** argv) {
this->main = main;
this->argc = argc;
this->argv = argv;
}
wWinMainPtr wWinMain = nullptr;
HINSTANCE hInstance;
LPWSTR lpCmdLine;
int nCmdShow;
mainPtr main = nullptr;
int argc;
char** argv;
LPVOID original_fiber;
int fiber_result;
};
// A PFIBER_START_ROUTINE function run on a large-stack fiber that calls the
// main routine, stores its return value, and returns control to the small-stack
// fiber. |params| must be a pointer to a FiberState struct.
void WINAPI FiberBinder(void* params) {
auto* fiber_state = static_cast<FiberState*>(params);
// Call the main routine from the fiber. Reusing the entry point minimizes
// confusion when examining call stacks in crash reports - seeing wWinMain on
// the stack is a handy hint that this is the main thread of the process.
if (fiber_state->main) {
fiber_state->fiber_result =
fiber_state->main(fiber_state->argc, fiber_state->argv);
} else {
fiber_state->fiber_result =
fiber_state->wWinMain(fiber_state->hInstance, nullptr,
fiber_state->lpCmdLine, fiber_state->nCmdShow);
}
// Switch back to the main thread to exit.
::SwitchToFiber(fiber_state->original_fiber);
}
int RunMainWithPreferredStackSize(FiberState& fiber_state) {
enum class FiberStatus { kConvertFailed, kCreateFiberFailed, kSuccess };
FiberStatus fiber_status = FiberStatus::kSuccess;
// GetLastError result if fiber conversion failed.
DWORD fiber_error = ERROR_SUCCESS;
if (!::IsThreadAFiber()) {
// Make the main thread's stack size 4 MiB so that it has roughly the same
// effective size as the 64-bit build's 8 MiB stack.
constexpr size_t kStackSize = 4 * 1024 * 1024; // 4 MiB
// Leak the fiber on exit.
LPVOID original_fiber =
::ConvertThreadToFiberEx(nullptr, FIBER_FLAG_FLOAT_SWITCH);
if (original_fiber) {
fiber_state.original_fiber = original_fiber;
// Create a fiber with a bigger stack and switch to it. Leak the fiber on
// exit.
LPVOID big_stack_fiber = ::CreateFiberEx(
0, kStackSize, FIBER_FLAG_FLOAT_SWITCH, FiberBinder, &fiber_state);
if (big_stack_fiber) {
::SwitchToFiber(big_stack_fiber);
// The fibers must be cleaned up to avoid obscure TLS-related shutdown
// crashes.
::DeleteFiber(big_stack_fiber);
::ConvertFiberToThread();
// Control returns here after CEF has finished running on FiberMain.
return fiber_state.fiber_result;
}
fiber_status = FiberStatus::kCreateFiberFailed;
} else {
fiber_status = FiberStatus::kConvertFailed;
}
// If we reach here then creating and switching to a fiber has failed. This
// probably means we are low on memory and will soon crash. Try to report
// this error once crash reporting is initialized.
fiber_error = ::GetLastError();
base::debug::Alias(&fiber_error);
}
// If we are already a fiber then continue normal execution.
// Intentionally crash if converting to a fiber failed.
CHECK_EQ(fiber_status, FiberStatus::kSuccess);
return -1;
}
#endif // BUILDFLAG(IS_WIN) && defined(ARCH_CPU_32_BITS)
} // namespace
int CefExecuteProcess(const CefMainArgs& args,
CefRefPtr<CefApp> application,
void* windows_sandbox_info) {
#if BUILDFLAG(IS_WIN)
#if defined(ARCH_CPU_X86_64)
DisableFMA3();
#endif
InitInstallDetails();
InitCrashReporter();
#endif
@@ -192,9 +284,6 @@ bool CefInitialize(const CefMainArgs& args,
CefRefPtr<CefApp> application,
void* windows_sandbox_info) {
#if BUILDFLAG(IS_WIN)
#if defined(ARCH_CPU_X86_64)
DisableFMA3();
#endif
InitInstallDetails();
InitCrashReporter();
#endif
@@ -286,8 +375,30 @@ void CefQuitMessageLoop() {
g_context->QuitMessageLoop();
}
void CefSetOSModalLoop(bool osModalLoop) {
#if BUILDFLAG(IS_WIN)
#if defined(ARCH_CPU_32_BITS)
int CefRunWinMainWithPreferredStackSize(wWinMainPtr wWinMain,
HINSTANCE hInstance,
LPWSTR lpCmdLine,
int nCmdShow) {
CHECK(wWinMain && hInstance);
FiberState fiber_state(wWinMain, hInstance, lpCmdLine, nCmdShow);
return RunMainWithPreferredStackSize(fiber_state);
}
int CefRunMainWithPreferredStackSize(mainPtr main, int argc, char* argv[]) {
CHECK(main);
FiberState fiber_state(main, argc, argv);
return RunMainWithPreferredStackSize(fiber_state);
}
#endif // defined(ARCH_CPU_32_BITS)
void CefEnableHighDPISupport() {
base::win::EnableHighDPISupport();
}
void CefSetOSModalLoop(bool osModalLoop) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
@@ -300,9 +411,10 @@ void CefSetOSModalLoop(bool osModalLoop) {
}
base::CurrentThread::Get()->set_os_modal_loop(osModalLoop);
#endif // BUILDFLAG(IS_WIN)
}
#endif // BUILDFLAG(IS_WIN)
// CefContext
CefContext::CefContext()

View File

@@ -0,0 +1,54 @@
// Copyright (c) 2022 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/global_preference_manager_impl.h"
#include "libcef/browser/context.h"
#include "libcef/browser/prefs/pref_helper.h"
#include "libcef/browser/thread_util.h"
#include "chrome/browser/browser_process.h"
bool CefGlobalPreferenceManagerImpl::HasPreference(const CefString& name) {
CEF_REQUIRE_UIT_RETURN(false);
return pref_helper::HasPreference(g_browser_process->local_state(), name);
}
CefRefPtr<CefValue> CefGlobalPreferenceManagerImpl::GetPreference(
const CefString& name) {
CEF_REQUIRE_UIT_RETURN(nullptr);
return pref_helper::GetPreference(g_browser_process->local_state(), name);
}
CefRefPtr<CefDictionaryValue> CefGlobalPreferenceManagerImpl::GetAllPreferences(
bool include_defaults) {
CEF_REQUIRE_UIT_RETURN(nullptr);
return pref_helper::GetAllPreferences(g_browser_process->local_state(),
include_defaults);
}
bool CefGlobalPreferenceManagerImpl::CanSetPreference(const CefString& name) {
CEF_REQUIRE_UIT_RETURN(false);
return pref_helper::CanSetPreference(g_browser_process->local_state(), name);
}
bool CefGlobalPreferenceManagerImpl::SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) {
CEF_REQUIRE_UIT_RETURN(false);
return pref_helper::SetPreference(g_browser_process->local_state(), name,
value, error);
}
// static
CefRefPtr<CefPreferenceManager>
CefPreferenceManager::GetGlobalPreferenceManager() {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return nullptr;
}
return new CefGlobalPreferenceManagerImpl();
}

View File

@@ -0,0 +1,35 @@
// Copyright (c) 2022 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_GLOBAL_PREFERENCE_MANAGER_IMPL_H_
#define CEF_LIBCEF_BROWSER_GLOBAL_PREFERENCE_MANAGER_IMPL_H_
#pragma once
#include "include/cef_preference.h"
// Implementation of the CefPreferenceManager interface for global preferences.
class CefGlobalPreferenceManagerImpl : public CefPreferenceManager {
public:
CefGlobalPreferenceManagerImpl() = default;
CefGlobalPreferenceManagerImpl(const CefGlobalPreferenceManagerImpl&) =
delete;
CefGlobalPreferenceManagerImpl& operator=(
const CefGlobalPreferenceManagerImpl&) = delete;
// CefPreferenceManager methods.
bool HasPreference(const CefString& name) override;
CefRefPtr<CefValue> GetPreference(const CefString& name) override;
CefRefPtr<CefDictionaryValue> GetAllPreferences(
bool include_defaults) override;
bool CanSetPreference(const CefString& name) override;
bool SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) override;
private:
IMPLEMENT_REFCOUNTING(CefGlobalPreferenceManagerImpl);
};
#endif // CEF_LIBCEF_BROWSER_GLOBAL_PREFERENCE_MANAGER_IMPL_H_

View File

@@ -25,6 +25,7 @@
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
#import "ui/base/cocoa/cocoa_base_utils.h"
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
#include "ui/display/screen.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/keycodes/keyboard_codes_posix.h"
#include "ui/gfx/geometry/rect.h"
@@ -144,8 +145,90 @@ constexpr int kDefaultHeight = 750;
constexpr int kDefaultWidth = 750;
constexpr NSWindowStyleMask kDefaultStyleMask =
NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable |
NSWindowStyleMaskUnifiedTitleAndToolbar;
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
// Keep the frame bounds inside the display work area.
NSRect ClampNSBoundsToWorkArea(const NSRect& frame_bounds,
const gfx::Rect& display_bounds,
const gfx::Rect& work_area) {
NSRect bounds = frame_bounds;
// Convert from DIP coordinates (top-left origin) to macOS coordinates
// (bottom-left origin).
const int work_area_y =
display_bounds.height() - work_area.height() - work_area.y();
if (bounds.size.width > work_area.width()) {
bounds.size.width = work_area.width();
}
if (bounds.size.height > work_area.height()) {
bounds.size.height = work_area.height();
}
if (bounds.origin.x < work_area.x()) {
bounds.origin.x = work_area.x();
} else if (bounds.origin.x + bounds.size.width >=
work_area.x() + work_area.width()) {
bounds.origin.x = work_area.x() + work_area.width() - bounds.size.width;
}
if (bounds.origin.y < work_area_y) {
bounds.origin.y = work_area_y;
} else if (bounds.origin.y + bounds.size.height >=
work_area_y + work_area.height()) {
bounds.origin.y = work_area_y + work_area.height() - bounds.size.height;
}
return bounds;
}
// Get frame and content area rects matching the input DIP screen bounds. The
// resulting window frame will be kept inside the closest display work area. If
// |input_content_bounds| is true the input size is used for the content area
// and the input origin is used for the frame. Otherwise, both input size and
// origin are used for the frame.
void GetNSBoundsInDisplay(const gfx::Rect& dip_bounds,
bool input_content_bounds,
NSWindowStyleMask style_mask,
NSRect& frame_rect,
NSRect& content_rect) {
// Identify the closest display.
const auto display =
display::Screen::GetScreen()->GetDisplayMatching(dip_bounds);
const auto& display_bounds = display.bounds();
const auto& display_work_area = display.work_area();
// Convert from DIP coordinates (top-left origin) to macOS coordinates
// (bottom-left origin).
NSRect requested_rect = NSMakeRect(dip_bounds.x(), dip_bounds.y(),
dip_bounds.width(), dip_bounds.height());
requested_rect.origin.y = display_bounds.height() -
requested_rect.size.height -
requested_rect.origin.y;
// Calculate the equivalent frame and content bounds.
if (input_content_bounds) {
// Compute frame rect from content rect. Keep the requested origin.
content_rect = requested_rect;
frame_rect = [NSWindow frameRectForContentRect:content_rect
styleMask:style_mask];
frame_rect.origin = requested_rect.origin;
} else {
// Compute content rect from frame rect.
frame_rect = requested_rect;
content_rect = [NSWindow contentRectForFrameRect:frame_rect
styleMask:style_mask];
}
// Keep the frame inside the display work area.
const NSRect new_frame_rect =
ClampNSBoundsToWorkArea(frame_rect, display_bounds, display_work_area);
if (!NSEqualRects(frame_rect, new_frame_rect)) {
frame_rect = new_frame_rect;
content_rect = [NSWindow contentRectForFrameRect:frame_rect
styleMask:style_mask];
}
}
} // namespace
@@ -168,48 +251,52 @@ void CefBrowserPlatformDelegateNativeMac::BrowserDestroyed(
bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
base::mac::ScopedNSAutoreleasePool autorelease_pool;
NSWindow* newWnd = nil;
NSWindow* new_window = nil;
NSView* parentView =
NSView* parent_view =
CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(window_info_.parent_view);
NSRect browser_view_rect =
NSMakeRect(window_info_.bounds.x, window_info_.bounds.y,
window_info_.bounds.width, window_info_.bounds.height);
const CGFloat x = static_cast<CGFloat>(window_info_.bounds.x);
const CGFloat y = static_cast<CGFloat>(window_info_.bounds.y);
const CGFloat width = static_cast<CGFloat>(window_info_.bounds.width);
const CGFloat height = static_cast<CGFloat>(window_info_.bounds.height);
if (parent_view == nil) {
// TODO(port): If no x,y position is specified the window will always appear
// in the upper-left corner. Maybe there's a better default place to put it?
const gfx::Rect dip_bounds(
window_info_.bounds.x, window_info_.bounds.y,
window_info_.bounds.width <= 0 ? kDefaultWidth
: window_info_.bounds.width,
window_info_.bounds.height <= 0 ? kDefaultHeight
: window_info_.bounds.height);
// Calculate the equivalent frame and content area bounds.
NSRect frame_rect, content_rect;
GetNSBoundsInDisplay(dip_bounds, /*input_content_bounds=*/true,
kDefaultStyleMask, frame_rect, content_rect);
NSRect content_rect = {{x, y}, {width, height}};
if (parentView == nil) {
// Create a new window.
NSRect window_rect = {{x, y}, {width, height}};
if (window_rect.size.width == 0)
window_rect.size.width = kDefaultWidth;
if (window_rect.size.height == 0)
window_rect.size.height = kDefaultHeight;
content_rect = {{0, 0}, {window_rect.size.width, window_rect.size.height}};
newWnd = [[UnderlayOpenGLHostingWindow alloc]
initWithContentRect:window_rect
new_window = [[UnderlayOpenGLHostingWindow alloc]
initWithContentRect:content_rect
styleMask:kDefaultStyleMask
backing:NSBackingStoreBuffered
defer:NO];
// Create the delegate for control and browser window events.
[[CefWindowDelegate alloc] initWithWindow:newWnd andBrowser:browser_];
[[CefWindowDelegate alloc] initWithWindow:new_window andBrowser:browser_];
parentView = [newWnd contentView];
window_info_.parent_view = parentView;
parent_view = [new_window contentView];
browser_view_rect = [parent_view bounds];
window_info_.parent_view = parent_view;
// Make the content view for the window have a layer. This will make all
// sub-views have layers. This is necessary to ensure correct layer
// ordering of all child views and their layers.
[parentView setWantsLayer:YES];
[parent_view setWantsLayer:YES];
// Transform input Y coodinate into the MacOS coordinate.
NSRect primary_screen_rect = [[[NSScreen screens] firstObject] frame];
const CGFloat transformed_y = NSMaxY(primary_screen_rect) - y;
[newWnd setFrameTopLeftPoint:NSMakePoint(x, transformed_y)];
// Place the window at the target point. This is required for proper
// placement if the point is on a secondary display.
[new_window setFrameOrigin:frame_rect.origin];
}
host_window_created_ = true;
@@ -219,14 +306,14 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
// Create the browser view.
CefBrowserHostView* browser_view =
[[CefBrowserHostView alloc] initWithFrame:content_rect];
[[CefBrowserHostView alloc] initWithFrame:browser_view_rect];
browser_view.browser = browser_;
[parentView addSubview:browser_view];
[parent_view addSubview:browser_view];
[browser_view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[browser_view setNeedsDisplay:YES];
[browser_view release];
// Parent the TabContents to the browser view.
// Parent the WebContents to the browser view.
const NSRect bounds = [browser_view bounds];
NSView* native_view = web_contents_->GetNativeView().GetNativeNSView();
[browser_view addSubview:native_view];
@@ -236,9 +323,9 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
window_info_.view = browser_view;
if (newWnd != nil && !window_info_.hidden) {
if (new_window != nil && !window_info_.hidden) {
// Show the window.
[newWnd makeKeyAndOrderFront:nil];
[new_window makeKeyAndOrderFront:nil];
}
return true;

View File

@@ -28,6 +28,7 @@
#include "ui/base/win/shell.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/display/win/screen_win.h"
#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion_win.h"
@@ -122,84 +123,65 @@ void ExecuteExternalProtocol(const GURL& url) {
}
}
// DPI value for 1x scale factor.
#define DPI_1X 96.0f
float GetWindowScaleFactor(HWND hwnd) {
DCHECK(hwnd);
if (base::win::IsProcessPerMonitorDpiAware()) {
// Let Windows tell us the correct DPI.
static auto get_dpi_for_window_func = []() {
return reinterpret_cast<decltype(::GetDpiForWindow)*>(
GetProcAddress(GetModuleHandle(L"user32.dll"), "GetDpiForWindow"));
}();
if (get_dpi_for_window_func)
return static_cast<float>(get_dpi_for_window_func(hwnd)) / DPI_1X;
}
// Fallback to the monitor that contains the window center point.
RECT cr;
GetWindowRect(hwnd, &cr);
return display::Screen::GetScreen()
->GetDisplayNearestPoint(
gfx::Point((cr.right - cr.left) / 2, (cr.bottom - cr.top) / 2))
.device_scale_factor();
}
struct ScreenInfo {
float scale_factor;
CefRect rect;
};
ScreenInfo GetScreenInfo(int x, int y) {
gfx::Rect GetDisplayWorkAreaNearestPoint(gfx::Point dip_point) {
const auto display =
display::Screen::GetScreen()->GetDisplayNearestPoint(gfx::Point(x, y));
const auto rect = display.work_area();
return ScreenInfo{display.device_scale_factor(),
CefRect(rect.x(), rect.y(), rect.width(), rect.height())};
display::Screen::GetScreen()->GetDisplayNearestPoint(dip_point);
// Work area in DIP.
return display.work_area();
}
CefRect GetFrameRectFromLogicalContentRect(CefRect content,
DWORD style,
DWORD ex_style,
bool has_menu,
float scale) {
const auto scaled_rect = gfx::ScaleToRoundedRect(
gfx::Rect(content.x, content.y, content.width, content.height), scale);
CefRect GetScreenFrameRectFromDIPContentRect(HWND window,
gfx::Rect dip_rect,
DWORD style,
DWORD ex_style,
bool has_menu) {
// Convert from DIP using a method that can handle multiple displays with
// different DPI. If |window| is nullptr the closest display will be used.
const auto screen_rect =
display::win::ScreenWin::DIPToScreenRect(window, dip_rect);
RECT rect = {0, 0, scaled_rect.width(), scaled_rect.height()};
RECT rect = {screen_rect.x(), screen_rect.y(),
screen_rect.x() + screen_rect.width(),
screen_rect.y() + screen_rect.height()};
AdjustWindowRectEx(&rect, style, has_menu, ex_style);
return CefRect(scaled_rect.x(), scaled_rect.y(), rect.right - rect.left,
// Keep the original origin while potentially increasing the size to include
// the frame non-client area.
return CefRect(screen_rect.x(), screen_rect.y(), rect.right - rect.left,
rect.bottom - rect.top);
}
CefRect GetAdjustedWindowRect(CefRect content,
DWORD style,
DWORD ex_style,
bool has_menu) {
// If height or width is not provided, let OS determine position and size,
// similarly to Chromium behavior
if (content.width == CW_USEDEFAULT || content.height == CW_USEDEFAULT) {
CefRect GetAdjustedScreenFrameRect(CefRect screen_rect,
DWORD style,
DWORD ex_style,
bool has_menu) {
// If height or width is not provided let the OS determine the position and
// size similar to Chromium behavior. Note that |CW_USEDEFAULT| cannot be
// stored in a gfx::Rect due to clamping.
if (screen_rect.width == CW_USEDEFAULT ||
screen_rect.height == CW_USEDEFAULT) {
return CefRect(CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT);
}
if (content.x == CW_USEDEFAULT) {
content.x = 0;
if (screen_rect.x == CW_USEDEFAULT) {
screen_rect.x = 0;
}
if (content.y == CW_USEDEFAULT) {
content.y = 0;
if (screen_rect.y == CW_USEDEFAULT) {
screen_rect.y = 0;
}
const ScreenInfo screen = GetScreenInfo(content.x, content.y);
const CefRect rect = MakeVisibleOnScreenRect(content, screen.rect);
// Convert to DIP using a method that can handle multiple displays with
// different DPI.
const auto dip_rect = display::win::ScreenWin::ScreenToDIPRect(
nullptr, gfx::Rect(screen_rect.x, screen_rect.y, screen_rect.width,
screen_rect.height));
const auto visible_dip_rect = MakeVisibleOnScreenRect(
dip_rect, GetDisplayWorkAreaNearestPoint(dip_rect.origin()));
return GetFrameRectFromLogicalContentRect(rect, style, ex_style, has_menu,
screen.scale_factor);
return GetScreenFrameRectFromDIPContentRect(
/*window=*/nullptr, visible_dip_rect, style, ex_style, has_menu);
}
} // namespace
@@ -245,8 +227,8 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
if (!window_info_.parent_window) {
const bool has_menu =
!(window_info_.style & WS_CHILD) && (window_info_.menu != NULL);
window_rect = GetAdjustedWindowRect(window_rect, window_info_.style,
window_info_.ex_style, has_menu);
window_rect = GetAdjustedScreenFrameRect(window_rect, window_info_.style,
window_info_.ex_style, has_menu);
}
// Create the new browser window.
@@ -283,13 +265,13 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
DCHECK(!window_widget_);
// Convert from device coordinates to logical coordinates.
RECT cr;
GetClientRect(window_info_.window, &cr);
gfx::Point point = gfx::Point(cr.right, cr.bottom);
const float scale = GetWindowScaleFactor(window_info_.window);
point =
gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(point), 1.0f / scale));
// Convert to DIP using a method that can handle multiple displays with
// different DPI. Client coordinates always have origin (0,0).
const gfx::Rect dip_rect = display::win::ScreenWin::ScreenToDIPRect(
window_info_.window, gfx::Rect(0, 0, cr.right, cr.bottom));
// Stay on top if top-most window hosting the web view is topmost.
HWND top_level_window = GetAncestor(window_info_.window, GA_ROOT);
@@ -301,7 +283,7 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
CefWindowDelegateView* delegate_view = new CefWindowDelegateView(
GetBackgroundColor(), always_on_top, GetBoundsChangedCallback());
delegate_view->Init(window_info_.window, web_contents_,
gfx::Rect(0, 0, point.x(), point.y()));
gfx::Rect(0, 0, dip_rect.width(), dip_rect.height()));
window_widget_ = delegate_view->GetWidget();
@@ -440,11 +422,9 @@ void CefBrowserPlatformDelegateNativeWin::SizeTo(int width, int height) {
const DWORD style = GetWindowLong(window, GWL_STYLE);
const DWORD ex_style = GetWindowLong(window, GWL_EXSTYLE);
const bool has_menu = !(style & WS_CHILD) && (GetMenu(window) != NULL);
const float scale = GetWindowScaleFactor(window);
const CefRect content_rect(0, 0, width, height);
const CefRect frame_rect = GetFrameRectFromLogicalContentRect(
content_rect, style, ex_style, has_menu, scale);
const auto frame_rect = GetScreenFrameRectFromDIPContentRect(
window, gfx::Rect(0, 0, width, height), style, ex_style, has_menu);
// Size the window. The left/top values may be negative.
SetWindowPos(window, NULL, 0, 0, frame_rect.width, frame_rect.height,

View File

@@ -8,6 +8,7 @@
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/context.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/prefs/pref_registrar.h"
#include "libcef/browser/prefs/pref_store.h"
#include "libcef/browser/prefs/renderer_prefs.h"
#include "libcef/common/cef_switches.h"
@@ -118,18 +119,13 @@ std::string GetAcceptLanguageListSetting(CefBrowserContext* browser_context,
const char kUserPrefsFileName[] = "UserPrefs.json";
const char kLocalPrefsFileName[] = "LocalPrefs.json";
void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
pref_registrar::RegisterCustomPrefs(CEF_PREFERENCES_TYPE_GLOBAL, registry);
}
void RegisterProfilePrefs(PrefRegistrySimple* registry) {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnablePreferenceTesting)) {
// Preferences used with unit tests.
registry->RegisterBooleanPref("test.bool", true);
registry->RegisterIntegerPref("test.int", 2);
registry->RegisterDoublePref("test.double", 5.0);
registry->RegisterStringPref("test.string", "default");
registry->RegisterListPref("test.list");
registry->RegisterDictionaryPref("test.dict");
}
pref_registrar::RegisterCustomPrefs(CEF_PREFERENCES_TYPE_REQUEST_CONTEXT,
registry);
}
std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
@@ -276,7 +272,6 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
privacy_sandbox::RegisterProfilePrefs(registry.get());
ProfileNetworkContextService::RegisterProfilePrefs(registry.get());
safe_browsing::RegisterProfilePrefs(registry.get());
RegisterProfilePrefs(registry.get());
const std::string& locale =
command_line->GetSwitchValueASCII(switches::kLang);
@@ -339,6 +334,12 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
base::Value(accept_language_list));
}
registry->RegisterListPref(prefs::kWebRtcLocalIpsAllowedUrls);
// Always do this after all other profile prefs.
RegisterProfilePrefs(registry.get());
} else {
// Always do this after all other local state prefs.
RegisterLocalStatePrefs(registry.get());
}
// Build the PrefService that manages the PrefRegistry and PrefStores.

View File

@@ -23,10 +23,12 @@ namespace browser_prefs {
extern const char kUserPrefsFileName[];
// Register preferences specific to CEF.
void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
void RegisterProfilePrefs(PrefRegistrySimple* registry);
// Create the PrefService used to manage pref registration and storage.
// |profile| will be nullptr for the system-level PrefService.
// |profile| will be nullptr for the system-level PrefService. Used with the
// Alloy runtime only.
std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
const base::FilePath& cache_path,
bool persist_user_preferences);

View File

@@ -0,0 +1,120 @@
// Copyright (c) 2022 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/prefs/pref_helper.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/values_impl.h"
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "components/prefs/pref_service.h"
namespace pref_helper {
namespace {
const char* GetTypeString(base::Value::Type type) {
switch (type) {
case base::Value::Type::NONE:
return "NULL";
case base::Value::Type::BOOLEAN:
return "BOOLEAN";
case base::Value::Type::INTEGER:
return "INTEGER";
case base::Value::Type::DOUBLE:
return "DOUBLE";
case base::Value::Type::STRING:
return "STRING";
case base::Value::Type::BINARY:
return "BINARY";
case base::Value::Type::DICTIONARY:
return "DICTIONARY";
case base::Value::Type::LIST:
return "LIST";
}
NOTREACHED();
return "UNKNOWN";
}
} // namespace
bool HasPreference(PrefService* pref_service, const CefString& name) {
return (pref_service->FindPreference(name) != nullptr);
}
CefRefPtr<CefValue> GetPreference(PrefService* pref_service,
const CefString& name) {
const PrefService::Preference* pref = pref_service->FindPreference(name);
if (!pref)
return nullptr;
return new CefValueImpl(pref->GetValue()->CreateDeepCopy().release());
}
CefRefPtr<CefDictionaryValue> GetAllPreferences(PrefService* pref_service,
bool include_defaults) {
base::Value values = pref_service->GetPreferenceValues(
include_defaults ? PrefService::INCLUDE_DEFAULTS
: PrefService::EXCLUDE_DEFAULTS);
// CefDictionaryValueImpl takes ownership of |values|.
return new CefDictionaryValueImpl(
base::DictionaryValue::From(
base::Value::ToUniquePtrValue(std::move(values)))
.release(),
true, false);
}
bool CanSetPreference(PrefService* pref_service, const CefString& name) {
const PrefService::Preference* pref = pref_service->FindPreference(name);
return (pref && pref->IsUserModifiable());
}
bool SetPreference(PrefService* pref_service,
const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) {
// The below validation logic should match PrefService::SetUserPrefValue.
const PrefService::Preference* pref = pref_service->FindPreference(name);
if (!pref) {
error = "Trying to modify an unregistered preference";
return false;
}
if (!pref->IsUserModifiable()) {
error = "Trying to modify a preference that is not user modifiable";
return false;
}
if (!value.get()) {
// Reset the preference to its default value.
pref_service->ClearPref(name);
return true;
}
if (!value->IsValid()) {
error = "A valid value is required";
return false;
}
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
CefValueImpl::ScopedLockedValue scoped_locked_value(impl);
base::Value* impl_value = impl->GetValueUnsafe();
if (pref->GetType() != impl_value->type()) {
error = base::StringPrintf(
"Trying to set a preference of type %s to value of type %s",
GetTypeString(pref->GetType()), GetTypeString(impl_value->type()));
return false;
}
// PrefService will make a DeepCopy of |impl_value|.
pref_service->Set(name, *impl_value);
return true;
}
} // namespace pref_helper

View File

@@ -0,0 +1,33 @@
// Copyright (c) 2022 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_PREFS_PREF_HELPER_H_
#define CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_
#include "include/cef_values.h"
class PrefService;
namespace pref_helper {
// Function names and arguments match the CefPreferenceManager interface.
bool HasPreference(PrefService* pref_service, const CefString& name);
CefRefPtr<CefValue> GetPreference(PrefService* pref_service,
const CefString& name);
CefRefPtr<CefDictionaryValue> GetAllPreferences(PrefService* pref_service,
bool include_defaults);
bool CanSetPreference(PrefService* pref_service, const CefString& name);
bool SetPreference(PrefService* pref_service,
const CefString& name,
CefRefPtr<CefValue> value,
CefString& error);
} // namespace pref_helper
#endif // CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_

View File

@@ -0,0 +1,99 @@
// Copyright (c) 2022 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/prefs/pref_registrar.h"
#include "include/cef_app.h"
#include "include/cef_browser_process_handler.h"
#include "include/cef_preference.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/values_impl.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_store.h"
namespace pref_registrar {
namespace {
class CefPreferenceRegistrarImpl : public CefPreferenceRegistrar {
public:
explicit CefPreferenceRegistrarImpl(PrefRegistrySimple* registry)
: registry_(registry) {}
CefPreferenceRegistrarImpl(const CefPreferenceRegistrarImpl&) = delete;
CefPreferenceRegistrarImpl& operator=(const CefPreferenceRegistrarImpl&) =
delete;
// CefPreferenceRegistrar methods.
bool AddPreference(const CefString& name,
CefRefPtr<CefValue> default_value) override {
const std::string nameStr = name;
if (registry_->defaults()->GetValue(nameStr, nullptr)) {
LOG(ERROR) << "Trying to register a previously registered preference: "
<< nameStr;
return false;
}
switch (default_value->GetType()) {
case VTYPE_INVALID:
case VTYPE_NULL:
case VTYPE_BINARY:
break;
case VTYPE_BOOL:
registry_->RegisterBooleanPref(nameStr, default_value->GetBool());
return true;
case VTYPE_INT:
registry_->RegisterIntegerPref(nameStr, default_value->GetInt());
return true;
case VTYPE_DOUBLE:
registry_->RegisterDoublePref(nameStr, default_value->GetDouble());
return true;
case VTYPE_STRING:
registry_->RegisterStringPref(nameStr, default_value->GetString());
return true;
case VTYPE_DICTIONARY:
case VTYPE_LIST:
RegisterComplexPref(nameStr, default_value);
return true;
};
LOG(ERROR) << "Invalid value type for preference: " << nameStr;
return false;
}
private:
void RegisterComplexPref(const std::string& name,
CefRefPtr<CefValue> default_value) {
CefValueImpl* impl = static_cast<CefValueImpl*>(default_value.get());
CefValueImpl::ScopedLockedValue scoped_locked_value(impl);
base::Value* impl_value = impl->GetValueUnsafe();
// Will make a deep copy of |impl_value|.
if (impl_value->type() == base::Value::Type::DICT) {
registry_->RegisterDictionaryPref(name, impl_value->Clone());
} else if (impl_value->type() == base::Value::Type::LIST) {
registry_->RegisterListPref(name, impl_value->Clone());
} else {
NOTREACHED();
}
}
PrefRegistrySimple* const registry_;
};
} // namespace
void RegisterCustomPrefs(cef_preferences_type_t type,
PrefRegistrySimple* registry) {
if (auto app = CefAppManager::Get()->GetApplication()) {
if (auto handler = app->GetBrowserProcessHandler()) {
CefPreferenceRegistrarImpl registrar(registry);
handler->OnRegisterCustomPreferences(type, &registrar);
}
}
}
} // namespace pref_registrar

View File

@@ -0,0 +1,19 @@
// Copyright (c) 2022 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_PREFS_PREF_REGISTRAR_H_
#define CEF_LIBCEF_BROWSER_PREFS_PREF_REGISTRAR_H_
#include "include/internal/cef_types.h"
class PrefRegistrySimple;
namespace pref_registrar {
void RegisterCustomPrefs(cef_preferences_type_t type,
PrefRegistrySimple* registry);
} // namespace pref_registrar
#endif // CEF_LIBCEF_BROWSER_PREFS_PREF_REGISTRAR_H_

View File

@@ -5,10 +5,10 @@
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/context.h"
#include "libcef/browser/prefs/pref_helper.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/task_runner_impl.h"
#include "libcef/common/values_impl.h"
#include "base/atomic_sequence_num.h"
#include "base/logging.h"
@@ -30,30 +30,6 @@ namespace {
base::AtomicSequenceNumber g_next_id;
const char* GetTypeString(base::Value::Type type) {
switch (type) {
case base::Value::Type::NONE:
return "NULL";
case base::Value::Type::BOOLEAN:
return "BOOLEAN";
case base::Value::Type::INTEGER:
return "INTEGER";
case base::Value::Type::DOUBLE:
return "DOUBLE";
case base::Value::Type::STRING:
return "STRING";
case base::Value::Type::BINARY:
return "BINARY";
case base::Value::Type::DICTIONARY:
return "DICTIONARY";
case base::Value::Type::LIST:
return "LIST";
}
NOTREACHED();
return "UNKNOWN";
}
class ResolveHostHelper : public network::ResolveHostClientBase {
public:
explicit ResolveHostHelper(CefRefPtr<CefResolveCallback> callback)
@@ -380,7 +356,7 @@ bool CefRequestContextImpl::HasPreference(const CefString& name) {
return false;
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
return (pref_service->FindPreference(name) != nullptr);
return pref_helper::HasPreference(pref_service, name);
}
CefRefPtr<CefValue> CefRequestContextImpl::GetPreference(
@@ -389,10 +365,7 @@ CefRefPtr<CefValue> CefRequestContextImpl::GetPreference(
return nullptr;
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
const PrefService::Preference* pref = pref_service->FindPreference(name);
if (!pref)
return nullptr;
return new CefValueImpl(pref->GetValue()->CreateDeepCopy().release());
return pref_helper::GetPreference(pref_service, name);
}
CefRefPtr<CefDictionaryValue> CefRequestContextImpl::GetAllPreferences(
@@ -401,17 +374,7 @@ CefRefPtr<CefDictionaryValue> CefRequestContextImpl::GetAllPreferences(
return nullptr;
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
base::Value values = pref_service->GetPreferenceValues(
include_defaults ? PrefService::INCLUDE_DEFAULTS
: PrefService::EXCLUDE_DEFAULTS);
// CefDictionaryValueImpl takes ownership of |values|.
return new CefDictionaryValueImpl(
base::DictionaryValue::From(
base::Value::ToUniquePtrValue(std::move(values)))
.release(),
true, false);
return pref_helper::GetAllPreferences(pref_service, include_defaults);
}
bool CefRequestContextImpl::CanSetPreference(const CefString& name) {
@@ -419,8 +382,7 @@ bool CefRequestContextImpl::CanSetPreference(const CefString& name) {
return false;
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
const PrefService::Preference* pref = pref_service->FindPreference(name);
return (pref && pref->IsUserModifiable());
return pref_helper::CanSetPreference(pref_service, name);
}
bool CefRequestContextImpl::SetPreference(const CefString& name,
@@ -430,46 +392,7 @@ bool CefRequestContextImpl::SetPreference(const CefString& name,
return false;
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
// The below validation logic should match PrefService::SetUserPrefValue.
const PrefService::Preference* pref = pref_service->FindPreference(name);
if (!pref) {
error = "Trying to modify an unregistered preference";
return false;
}
if (!pref->IsUserModifiable()) {
error = "Trying to modify a preference that is not user modifiable";
return false;
}
if (!value.get()) {
// Reset the preference to its default value.
pref_service->ClearPref(name);
return true;
}
if (!value->IsValid()) {
error = "A valid value is required";
return false;
}
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
CefValueImpl::ScopedLockedValue scoped_locked_value(impl);
base::Value* impl_value = impl->GetValueUnsafe();
if (pref->GetType() != impl_value->type()) {
error = base::StringPrintf(
"Trying to set a preference of type %s to value of type %s",
GetTypeString(pref->GetType()), GetTypeString(impl_value->type()));
return false;
}
// PrefService will make a DeepCopy of |impl_value|.
pref_service->Set(name, *impl_value);
return true;
return pref_helper::SetPreference(pref_service, name, value, error);
}
void CefRequestContextImpl::ClearCertificateExceptions(

View File

@@ -2,8 +2,8 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
#define CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
#ifndef CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_IMPL_H_
#define CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_IMPL_H_
#pragma once
#include "include/cef_request_context.h"
@@ -176,4 +176,4 @@ class CefRequestContextImpl : public CefRequestContext {
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefRequestContextImpl);
};
#endif // CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
#endif // CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_IMPL_H_

View File

@@ -6,6 +6,8 @@
#include <algorithm>
#include "ui/gfx/geometry/rect.h"
namespace {
constexpr int kMinWidth = 0;
@@ -25,15 +27,17 @@ int clamp_segment_start(int start, int len, int min, int max) {
} // namespace
CefRect MakeVisibleOnScreenRect(const CefRect& rect, const CefRect& screen) {
const int width = std::clamp(rect.width, kMinWidth, screen.width);
const int height = std::clamp(rect.height, kMinHeight, screen.height);
gfx::Rect MakeVisibleOnScreenRect(const gfx::Rect& rect,
const gfx::Rect& screen) {
const int width = std::clamp(rect.width(), kMinWidth, screen.width());
const int height = std::clamp(rect.height(), kMinHeight, screen.height());
const int right_border = screen.x + screen.width;
const int x = clamp_segment_start(rect.x, width, screen.x, right_border);
const int right_border = screen.x() + screen.width();
const int x = clamp_segment_start(rect.x(), width, screen.x(), right_border);
const int bottom_border = screen.y + screen.height;
const int y = clamp_segment_start(rect.y, height, screen.y, bottom_border);
const int bottom_border = screen.y() + screen.height();
const int y =
clamp_segment_start(rect.y(), height, screen.y(), bottom_border);
return CefRect(x, y, width, height);
return gfx::Rect(x, y, width, height);
}

View File

@@ -6,12 +6,15 @@
#define CEF_LIBCEF_BROWSER_SCREEN_UTIL_H_
#pragma once
#include "include/internal/cef_types_wrappers.h"
namespace gfx {
class Rect;
}
// Create a new rectangle from the input |rect| rectangle that is fully visible
// on provided |screen_rect| screen. The width and height of the resulting
// rectangle are clamped to the screen width and height respectively if they
// would overflow.
CefRect MakeVisibleOnScreenRect(const CefRect& rect, const CefRect& screen);
gfx::Rect MakeVisibleOnScreenRect(const gfx::Rect& rect,
const gfx::Rect& screen);
#endif // CEF_LIBCEF_BROWSER_SCREEN_UTIL_H_

View File

@@ -5,77 +5,79 @@
#include "cef/libcef/browser/screen_util.h"
#include "tests/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect.h"
namespace {
constexpr int kScreenWidth = 1024;
constexpr int kScreenHeight = 768;
const CefRect kMainScreen(0, 0, kScreenWidth, kScreenHeight);
const CefRect kLeftScreen(-1024, 0, kScreenWidth, kScreenHeight);
const gfx::Rect kMainScreen(0, 0, kScreenWidth, kScreenHeight);
const gfx::Rect kLeftScreen(-1024, 0, kScreenWidth, kScreenHeight);
} // namespace
TEST(MakeVisibleOnScreenRect, RectSizeIsBiggerThanScreen) {
const CefRect rect{400, 500, 1500, 800};
const gfx::Rect rect{400, 500, 1500, 800};
auto result = MakeVisibleOnScreenRect(rect, kMainScreen);
EXPECT_EQ(result.x, 0);
EXPECT_EQ(result.width, kMainScreen.width);
EXPECT_EQ(result.y, 0);
EXPECT_EQ(result.height, kMainScreen.height);
EXPECT_EQ(result.x(), 0);
EXPECT_EQ(result.width(), kMainScreen.width());
EXPECT_EQ(result.y(), 0);
EXPECT_EQ(result.height(), kMainScreen.height());
}
TEST(MakeVisibleOnScreenRect, RightBorderIsOutsideTheScreen) {
const CefRect rect{600, 400, 500, 300};
const gfx::Rect rect{600, 400, 500, 300};
auto result = MakeVisibleOnScreenRect(rect, kMainScreen);
EXPECT_EQ(result.x, 524);
EXPECT_EQ(result.width, rect.width);
EXPECT_EQ(result.y, rect.y);
EXPECT_EQ(result.height, rect.height);
EXPECT_EQ(result.x(), 524);
EXPECT_EQ(result.width(), rect.width());
EXPECT_EQ(result.y(), rect.y());
EXPECT_EQ(result.height(), rect.height());
}
TEST(MakeVisibleOnScreenRect, LeftBorderIsOutsideTheScreen) {
const CefRect rect{-400, 400, 500, 300};
const gfx::Rect rect{-400, 400, 500, 300};
auto result = MakeVisibleOnScreenRect(rect, kMainScreen);
EXPECT_EQ(result.x, 0);
EXPECT_EQ(result.width, rect.width);
EXPECT_EQ(result.y, rect.y);
EXPECT_EQ(result.height, rect.height);
EXPECT_EQ(result.x(), 0);
EXPECT_EQ(result.width(), rect.width());
EXPECT_EQ(result.y(), rect.y());
EXPECT_EQ(result.height(), rect.height());
}
TEST(MakeVisibleOnScreenRect, BottomBorderIsOutsideTheScreen) {
const CefRect rect{600, 500, 300, 300};
const gfx::Rect rect{600, 500, 300, 300};
auto result = MakeVisibleOnScreenRect(rect, kMainScreen);
EXPECT_EQ(result.x, 600);
EXPECT_EQ(result.width, rect.width);
EXPECT_EQ(result.y, 468);
EXPECT_EQ(result.height, rect.height);
EXPECT_EQ(result.x(), 600);
EXPECT_EQ(result.width(), rect.width());
EXPECT_EQ(result.y(), 468);
EXPECT_EQ(result.height(), rect.height());
}
TEST(MakeVisibleOnScreenRect, RectIsVisibleOnTheLeftScreen) {
const CefRect rect{-500, 300, 300, 300};
const gfx::Rect rect{-500, 300, 300, 300};
auto result = MakeVisibleOnScreenRect(rect, kLeftScreen);
EXPECT_EQ(result.x, rect.x);
EXPECT_EQ(result.width, rect.width);
EXPECT_EQ(result.y, rect.y);
EXPECT_EQ(result.height, rect.height);
EXPECT_EQ(result.x(), rect.x());
EXPECT_EQ(result.width(), rect.width());
EXPECT_EQ(result.y(), rect.y());
EXPECT_EQ(result.height(), rect.height());
}
TEST(MakeVisibleOnScreenRect, RectSizeIsBiggerThanLeftScreen) {
const CefRect rect{-500, 300, 3000, 3000};
const gfx::Rect rect{-500, 300, 3000, 3000};
auto result = MakeVisibleOnScreenRect(rect, kLeftScreen);
EXPECT_EQ(result.x, kLeftScreen.x);
EXPECT_EQ(result.width, kLeftScreen.width);
EXPECT_EQ(result.y, kLeftScreen.y);
EXPECT_EQ(result.height, kLeftScreen.height);
EXPECT_EQ(result.x(), kLeftScreen.x());
EXPECT_EQ(result.width(), kLeftScreen.width());
EXPECT_EQ(result.y(), kLeftScreen.y());
EXPECT_EQ(result.height(), kLeftScreen.height());
}

View File

@@ -75,6 +75,32 @@ CefPoint CefDisplay::ConvertScreenPointFromPixels(const CefPoint& point) {
#endif
}
// static
CefRect CefDisplay::ConvertScreenRectToPixels(const CefRect& rect) {
CEF_REQUIRE_UIT_RETURN(CefRect());
#if BUILDFLAG(IS_WIN)
const gfx::Rect pix_rect = view_util::ConvertRectToPixels(
gfx::Rect(rect.x, rect.y, rect.width, rect.height));
return CefRect(pix_rect.x(), pix_rect.y(), pix_rect.width(),
pix_rect.height());
#else
return rect;
#endif
}
// static
CefRect CefDisplay::ConvertScreenRectFromPixels(const CefRect& rect) {
CEF_REQUIRE_UIT_RETURN(CefRect());
#if BUILDFLAG(IS_WIN)
const gfx::Rect dip_rect = view_util::ConvertRectFromPixels(
gfx::Rect(rect.x, rect.y, rect.width, rect.height));
return CefRect(dip_rect.x(), dip_rect.y(), dip_rect.width(),
dip_rect.height());
#else
return rect;
#endif
}
CefDisplayImpl::CefDisplayImpl(const display::Display& display)
: display_(display) {
CEF_REQUIRE_UIT();

View File

@@ -236,6 +236,14 @@ gfx::Point ConvertPointFromPixels(const gfx::Point& point) {
gfx::Point ConvertPointToPixels(const gfx::Point& point) {
return display::win::ScreenWin::DIPToScreenPoint(point);
}
gfx::Rect ConvertRectFromPixels(const gfx::Rect& rect) {
return display::win::ScreenWin::ScreenToDIPRect(nullptr, rect);
}
gfx::Rect ConvertRectToPixels(const gfx::Rect& rect) {
return display::win::ScreenWin::DIPToScreenRect(nullptr, rect);
}
#endif // BUILDFLAG(IS_WIN)
bool ConvertPointToScreen(views::View* view,

View File

@@ -97,6 +97,12 @@ gfx::Point ConvertPointFromPixels(const gfx::Point& point);
// Convert |point| from DIP screen coordinates to pixel screen coordinates.
gfx::Point ConvertPointToPixels(const gfx::Point& point);
// Convert |rect| from pixel screen coordinates to DIP screen coordinates.
gfx::Rect ConvertRectFromPixels(const gfx::Rect& rect);
// Convert |rect| from DIP screen coordinates to pixel screen coordinates.
gfx::Rect ConvertRectToPixels(const gfx::Rect& rect);
#endif // BUILDFLAG(IS_WIN)
// Convert |point| from |view| to screen coordinates. If |output_pixel_coords|

View File

@@ -391,6 +391,9 @@ void CefWindowImpl::OnWindowClosing() {
#if defined(USE_AURA)
unhandled_key_event_handler_.reset();
#endif
if (delegate())
delegate()->OnWindowClosing(this);
}
void CefWindowImpl::OnWindowViewDeleted() {

View File

@@ -535,6 +535,12 @@ void CefWindowView::OnWidgetActivationChanged(views::Widget* widget,
void CefWindowView::OnWidgetBoundsChanged(views::Widget* widget,
const gfx::Rect& new_bounds) {
MoveOverlaysIfNecessary();
if (cef_delegate()) {
cef_delegate()->OnWindowBoundsChanged(
GetCefWindow(), {new_bounds.x(), new_bounds.y(), new_bounds.width(),
new_bounds.height()});
}
}
display::Display CefWindowView::GetDisplay() const {

View File

@@ -12,10 +12,6 @@
#include "base/threading/platform_thread.h"
#include "base/trace_event/trace_event.h"
#if BUILDFLAG(IS_WIN)
#include "base/win/win_util.h"
#endif
namespace {
constexpr const char kCategory[] = "cef.client";
@@ -334,9 +330,3 @@ cef_get_current_platform_thread_handle() {
return base::PlatformThread::CurrentHandle().platform_handle();
#endif
}
void CefEnableHighDPISupport() {
#if BUILDFLAG(IS_WIN)
base::win::EnableHighDPISupport();
#endif
}

View File

@@ -91,9 +91,6 @@ const char kDisableScrollBounce[] = "disable-scroll-bounce";
// Disable the PDF extension.
const char kDisablePdfExtension[] = "disable-pdf-extension";
// Expose preferences used only by unit tests.
const char kEnablePreferenceTesting[] = "enable-preference-testing";
// Enable print preview.
const char kEnablePrintPreview[] = "enable-print-preview";

View File

@@ -43,7 +43,6 @@ extern const char kEnableSpellingService[];
extern const char kOverrideSpellCheckLang[];
extern const char kDisableScrollBounce[];
extern const char kDisablePdfExtension[];
extern const char kEnablePreferenceTesting[];
extern const char kEnablePrintPreview[];
extern const char kDisableNewBrowserInfoTimeout[];
extern const char kDevToolsProtocolLogFile[];

View File

@@ -9,17 +9,41 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=452f119327aff2ec0aaed162adf85bbd239b9033$
// $hash=984f4b764ebd914b5f5e585479866bd7a36c0429$
//
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
#include "libcef_dll/cpptoc/client_cpptoc.h"
#include "libcef_dll/ctocpp/command_line_ctocpp.h"
#include "libcef_dll/ctocpp/preference_registrar_ctocpp.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK browser_process_handler_on_register_custom_preferences(
struct _cef_browser_process_handler_t* self,
cef_preferences_type_t type,
struct _cef_preference_registrar_t* registrar) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: registrar; type: rawptr_diff
DCHECK(registrar);
if (!registrar)
return;
// Translate param: registrar; type: rawptr_diff
CefOwnPtr<CefPreferenceRegistrar> registrarPtr(
CefPreferenceRegistrarCToCpp::Wrap(registrar));
// Execute
CefBrowserProcessHandlerCppToC::Get(self)->OnRegisterCustomPreferences(
type, registrarPtr.get());
}
void CEF_CALLBACK browser_process_handler_on_context_initialized(
struct _cef_browser_process_handler_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@@ -85,6 +109,8 @@ struct _cef_client_t* CEF_CALLBACK browser_process_handler_get_default_client(
// CONSTRUCTOR - Do not edit by hand.
CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC() {
GetStruct()->on_register_custom_preferences =
browser_process_handler_on_register_custom_preferences;
GetStruct()->on_context_initialized =
browser_process_handler_on_context_initialized;
GetStruct()->on_before_child_process_launch =

View File

@@ -0,0 +1,183 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=6958fb584fde290169bdcf0fa3f1c94a2c9d77ea$
//
#include "libcef_dll/cpptoc/preference_manager_cpptoc.h"
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
#include "libcef_dll/cpptoc/value_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_preference_manager_t* cef_preference_manager_get_global() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
CefRefPtr<CefPreferenceManager> _retval =
CefPreferenceManager::GetGlobalPreferenceManager();
// Return type: refptr_same
return CefPreferenceManagerCppToC::Wrap(_retval);
}
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK
preference_manager_has_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval =
CefPreferenceManagerCppToC::Get(self)->HasPreference(CefString(name));
// Return type: bool
return _retval;
}
struct _cef_value_t* CEF_CALLBACK
preference_manager_get_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return NULL;
// Execute
CefRefPtr<CefValue> _retval =
CefPreferenceManagerCppToC::Get(self)->GetPreference(CefString(name));
// Return type: refptr_same
return CefValueCppToC::Wrap(_retval);
}
struct _cef_dictionary_value_t* CEF_CALLBACK
preference_manager_get_all_preferences(struct _cef_preference_manager_t* self,
int include_defaults) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefDictionaryValue> _retval =
CefPreferenceManagerCppToC::Get(self)->GetAllPreferences(
include_defaults ? true : false);
// Return type: refptr_same
return CefDictionaryValueCppToC::Wrap(_retval);
}
int CEF_CALLBACK
preference_manager_can_set_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval =
CefPreferenceManagerCppToC::Get(self)->CanSetPreference(CefString(name));
// Return type: bool
return _retval;
}
int CEF_CALLBACK
preference_manager_set_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name,
struct _cef_value_t* value,
cef_string_t* error) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Verify param: error; type: string_byref
DCHECK(error);
if (!error)
return 0;
// Unverified params: value
// Translate param: error; type: string_byref
CefString errorStr(error);
// Execute
bool _retval = CefPreferenceManagerCppToC::Get(self)->SetPreference(
CefString(name), CefValueCppToC::Unwrap(value), errorStr);
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefPreferenceManagerCppToC::CefPreferenceManagerCppToC() {
GetStruct()->has_preference = preference_manager_has_preference;
GetStruct()->get_preference = preference_manager_get_preference;
GetStruct()->get_all_preferences = preference_manager_get_all_preferences;
GetStruct()->can_set_preference = preference_manager_can_set_preference;
GetStruct()->set_preference = preference_manager_set_preference;
}
// DESTRUCTOR - Do not edit by hand.
CefPreferenceManagerCppToC::~CefPreferenceManagerCppToC() {}
template <>
CefRefPtr<CefPreferenceManager> CefCppToCRefCounted<
CefPreferenceManagerCppToC,
CefPreferenceManager,
cef_preference_manager_t>::UnwrapDerived(CefWrapperType type,
cef_preference_manager_t* s) {
if (type == WT_REQUEST_CONTEXT) {
return CefRequestContextCppToC::Unwrap(
reinterpret_cast<cef_request_context_t*>(s));
}
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCppToCRefCounted<CefPreferenceManagerCppToC,
CefPreferenceManager,
cef_preference_manager_t>::kWrapperType =
WT_PREFERENCE_MANAGER;

View File

@@ -0,0 +1,38 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=d8fe527c202b0c4438c542174f61c553faf851f5$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_MANAGER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_MANAGER_CPPTOC_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_preference_capi.h"
#include "include/cef_preference.h"
#include "libcef_dll/cpptoc/cpptoc_ref_counted.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefPreferenceManagerCppToC
: public CefCppToCRefCounted<CefPreferenceManagerCppToC,
CefPreferenceManager,
cef_preference_manager_t> {
public:
CefPreferenceManagerCppToC();
virtual ~CefPreferenceManagerCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_MANAGER_CPPTOC_H_

View File

@@ -0,0 +1,82 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=c20ff60ecd65930e687921444e6c46e90e7cc230$
//
#include "libcef_dll/cpptoc/preference_registrar_cpptoc.h"
#include "libcef_dll/cpptoc/value_cpptoc.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK
preference_registrar_add_preference(struct _cef_preference_registrar_t* self,
const cef_string_t* name,
struct _cef_value_t* default_value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Verify param: default_value; type: refptr_same
DCHECK(default_value);
if (!default_value)
return 0;
// Execute
bool _retval = CefPreferenceRegistrarCppToC::Get(self)->AddPreference(
CefString(name), CefValueCppToC::Unwrap(default_value));
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefPreferenceRegistrarCppToC::CefPreferenceRegistrarCppToC() {
GetStruct()->add_preference = preference_registrar_add_preference;
}
// DESTRUCTOR - Do not edit by hand.
CefPreferenceRegistrarCppToC::~CefPreferenceRegistrarCppToC() {}
template <>
CefOwnPtr<CefPreferenceRegistrar> CefCppToCScoped<CefPreferenceRegistrarCppToC,
CefPreferenceRegistrar,
cef_preference_registrar_t>::
UnwrapDerivedOwn(CefWrapperType type, cef_preference_registrar_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return CefOwnPtr<CefPreferenceRegistrar>();
}
template <>
CefRawPtr<CefPreferenceRegistrar> CefCppToCScoped<CefPreferenceRegistrarCppToC,
CefPreferenceRegistrar,
cef_preference_registrar_t>::
UnwrapDerivedRaw(CefWrapperType type, cef_preference_registrar_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCppToCScoped<CefPreferenceRegistrarCppToC,
CefPreferenceRegistrar,
cef_preference_registrar_t>::kWrapperType =
WT_PREFERENCE_REGISTRAR;

View File

@@ -0,0 +1,38 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=79809d65530b8405f3fed4adf7c55f8d28f515e0$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_REGISTRAR_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_REGISTRAR_CPPTOC_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_preference_capi.h"
#include "include/cef_preference.h"
#include "libcef_dll/cpptoc/cpptoc_scoped.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefPreferenceRegistrarCppToC
: public CefCppToCScoped<CefPreferenceRegistrarCppToC,
CefPreferenceRegistrar,
cef_preference_registrar_t> {
public:
CefPreferenceRegistrarCppToC();
virtual ~CefPreferenceRegistrarCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_REGISTRAR_CPPTOC_H_

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=ab7b829bdc8e583b08496227e5e9bebc2b166025$
// $hash=e4711889504d06c942d937a1e61fa48cee26b912$
//
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
@@ -238,118 +238,6 @@ int CEF_CALLBACK request_context_clear_scheme_handler_factories(
return _retval;
}
int CEF_CALLBACK
request_context_has_preference(struct _cef_request_context_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval =
CefRequestContextCppToC::Get(self)->HasPreference(CefString(name));
// Return type: bool
return _retval;
}
struct _cef_value_t* CEF_CALLBACK
request_context_get_preference(struct _cef_request_context_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return NULL;
// Execute
CefRefPtr<CefValue> _retval =
CefRequestContextCppToC::Get(self)->GetPreference(CefString(name));
// Return type: refptr_same
return CefValueCppToC::Wrap(_retval);
}
struct _cef_dictionary_value_t* CEF_CALLBACK
request_context_get_all_preferences(struct _cef_request_context_t* self,
int include_defaults) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefDictionaryValue> _retval =
CefRequestContextCppToC::Get(self)->GetAllPreferences(
include_defaults ? true : false);
// Return type: refptr_same
return CefDictionaryValueCppToC::Wrap(_retval);
}
int CEF_CALLBACK
request_context_can_set_preference(struct _cef_request_context_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval =
CefRequestContextCppToC::Get(self)->CanSetPreference(CefString(name));
// Return type: bool
return _retval;
}
int CEF_CALLBACK
request_context_set_preference(struct _cef_request_context_t* self,
const cef_string_t* name,
struct _cef_value_t* value,
cef_string_t* error) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Verify param: error; type: string_byref
DCHECK(error);
if (!error)
return 0;
// Unverified params: value
// Translate param: error; type: string_byref
CefString errorStr(error);
// Execute
bool _retval = CefRequestContextCppToC::Get(self)->SetPreference(
CefString(name), CefValueCppToC::Unwrap(value), errorStr);
// Return type: bool
return _retval;
}
void CEF_CALLBACK request_context_clear_certificate_exceptions(
struct _cef_request_context_t* self,
cef_completion_callback_t* callback) {
@@ -551,6 +439,125 @@ request_context_get_media_router(struct _cef_request_context_t* self,
return CefMediaRouterCppToC::Wrap(_retval);
}
int CEF_CALLBACK
request_context_has_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval = CefRequestContextCppToC::Get(
reinterpret_cast<cef_request_context_t*>(self))
->HasPreference(CefString(name));
// Return type: bool
return _retval;
}
struct _cef_value_t* CEF_CALLBACK
request_context_get_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return NULL;
// Execute
CefRefPtr<CefValue> _retval =
CefRequestContextCppToC::Get(
reinterpret_cast<cef_request_context_t*>(self))
->GetPreference(CefString(name));
// Return type: refptr_same
return CefValueCppToC::Wrap(_retval);
}
struct _cef_dictionary_value_t* CEF_CALLBACK
request_context_get_all_preferences(struct _cef_preference_manager_t* self,
int include_defaults) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefDictionaryValue> _retval =
CefRequestContextCppToC::Get(
reinterpret_cast<cef_request_context_t*>(self))
->GetAllPreferences(include_defaults ? true : false);
// Return type: refptr_same
return CefDictionaryValueCppToC::Wrap(_retval);
}
int CEF_CALLBACK
request_context_can_set_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval = CefRequestContextCppToC::Get(
reinterpret_cast<cef_request_context_t*>(self))
->CanSetPreference(CefString(name));
// Return type: bool
return _retval;
}
int CEF_CALLBACK
request_context_set_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name,
struct _cef_value_t* value,
cef_string_t* error) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Verify param: error; type: string_byref
DCHECK(error);
if (!error)
return 0;
// Unverified params: value
// Translate param: error; type: string_byref
CefString errorStr(error);
// Execute
bool _retval = CefRequestContextCppToC::Get(
reinterpret_cast<cef_request_context_t*>(self))
->SetPreference(CefString(name),
CefValueCppToC::Unwrap(value), errorStr);
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
@@ -566,11 +573,6 @@ CefRequestContextCppToC::CefRequestContextCppToC() {
request_context_register_scheme_handler_factory;
GetStruct()->clear_scheme_handler_factories =
request_context_clear_scheme_handler_factories;
GetStruct()->has_preference = request_context_has_preference;
GetStruct()->get_preference = request_context_get_preference;
GetStruct()->get_all_preferences = request_context_get_all_preferences;
GetStruct()->can_set_preference = request_context_can_set_preference;
GetStruct()->set_preference = request_context_set_preference;
GetStruct()->clear_certificate_exceptions =
request_context_clear_certificate_exceptions;
GetStruct()->clear_http_auth_credentials =
@@ -583,6 +585,11 @@ CefRequestContextCppToC::CefRequestContextCppToC() {
GetStruct()->get_extensions = request_context_get_extensions;
GetStruct()->get_extension = request_context_get_extension;
GetStruct()->get_media_router = request_context_get_media_router;
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;
GetStruct()->base.can_set_preference = request_context_can_set_preference;
GetStruct()->base.set_preference = request_context_set_preference;
}
// DESTRUCTOR - Do not edit by hand.

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=5e68fdaae42fe008a95bcf2672debe3cf04fa2ff$
// $hash=d2f3054a54f514ce650101e293bf085eeba48ee7$
//
#include "libcef_dll/cpptoc/views/display_cpptoc.h"
@@ -163,6 +163,48 @@ cef_display_convert_screen_point_from_pixels(const cef_point_t* point) {
return _retval;
}
CEF_EXPORT cef_rect_t
cef_display_convert_screen_rect_to_pixels(const cef_rect_t* rect) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: rect; type: simple_byref_const
DCHECK(rect);
if (!rect)
return CefRect();
// Translate param: rect; type: simple_byref_const
CefRect rectVal = rect ? *rect : CefRect();
// Execute
cef_rect_t _retval = CefDisplay::ConvertScreenRectToPixels(rectVal);
// Return type: simple
return _retval;
}
CEF_EXPORT cef_rect_t
cef_display_convert_screen_rect_from_pixels(const cef_rect_t* rect) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: rect; type: simple_byref_const
DCHECK(rect);
if (!rect)
return CefRect();
// Translate param: rect; type: simple_byref_const
CefRect rectVal = rect ? *rect : CefRect();
// Execute
cef_rect_t _retval = CefDisplay::ConvertScreenRectFromPixels(rectVal);
// Return type: simple
return _retval;
}
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=2ecdf3e890e54e962286430f350c5b49249a9a9e$
// $hash=9657432e6ca2ba72aeeb1ced5c8cf5ee71cf7221$
//
#include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h"
@@ -41,6 +41,26 @@ window_delegate_on_window_created(struct _cef_window_delegate_t* self,
CefWindowCToCpp::Wrap(window));
}
void CEF_CALLBACK
window_delegate_on_window_closing(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;
// Verify param: window; type: refptr_diff
DCHECK(window);
if (!window)
return;
// Execute
CefWindowDelegateCppToC::Get(self)->OnWindowClosing(
CefWindowCToCpp::Wrap(window));
}
void CEF_CALLBACK
window_delegate_on_window_destroyed(struct _cef_window_delegate_t* self,
cef_window_t* window) {
@@ -82,6 +102,34 @@ void CEF_CALLBACK window_delegate_on_window_activation_changed(
CefWindowCToCpp::Wrap(window), active ? true : false);
}
void CEF_CALLBACK
window_delegate_on_window_bounds_changed(struct _cef_window_delegate_t* self,
cef_window_t* window,
const cef_rect_t* new_bounds) {
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;
// Verify param: new_bounds; type: simple_byref_const
DCHECK(new_bounds);
if (!new_bounds)
return;
// Translate param: new_bounds; type: simple_byref_const
CefRect new_boundsVal = new_bounds ? *new_bounds : CefRect();
// Execute
CefWindowDelegateCppToC::Get(self)->OnWindowBoundsChanged(
CefWindowCToCpp::Wrap(window), new_boundsVal);
}
cef_window_t* CEF_CALLBACK
window_delegate_get_parent_window(struct _cef_window_delegate_t* self,
cef_window_t* window,
@@ -588,9 +636,12 @@ void CEF_CALLBACK window_delegate_on_blur(struct _cef_view_delegate_t* self,
CefWindowDelegateCppToC::CefWindowDelegateCppToC() {
GetStruct()->on_window_created = window_delegate_on_window_created;
GetStruct()->on_window_closing = window_delegate_on_window_closing;
GetStruct()->on_window_destroyed = window_delegate_on_window_destroyed;
GetStruct()->on_window_activation_changed =
window_delegate_on_window_activation_changed;
GetStruct()->on_window_bounds_changed =
window_delegate_on_window_bounds_changed;
GetStruct()->get_parent_window = window_delegate_get_parent_window;
GetStruct()->get_initial_bounds = window_delegate_get_initial_bounds;
GetStruct()->get_initial_show_state = window_delegate_get_initial_show_state;

View File

@@ -9,15 +9,40 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=3302f28c60da03b9f5ba5fa110523b353765d1a3$
// $hash=c6ad132e54265eb08e748bb22d2c90784ed098b0$
//
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
#include "libcef_dll/cpptoc/preference_registrar_cpptoc.h"
#include "libcef_dll/ctocpp/client_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
void CefBrowserProcessHandlerCToCpp::OnRegisterCustomPreferences(
cef_preferences_type_t type,
CefRawPtr<CefPreferenceRegistrar> registrar) {
cef_browser_process_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_register_custom_preferences))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: registrar; type: rawptr_diff
DCHECK(registrar);
if (!registrar)
return;
// Translate param: registrar; type: rawptr_diff
CefOwnPtr<CefPreferenceRegistrarCppToC> registrarPtr(
CefPreferenceRegistrarCppToC::WrapRaw(registrar));
// Execute
_struct->on_register_custom_preferences(_struct, type,
registrarPtr->GetStruct());
}
NO_SANITIZE("cfi-icall")
void CefBrowserProcessHandlerCToCpp::OnContextInitialized() {
cef_browser_process_handler_t* _struct = GetStruct();

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=7a13d15a99d1c92a757b776bb00d932296012054$
// $hash=dc8b4fabed723f33f4a5a7e668233a48913da2b4$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_
@@ -35,6 +35,9 @@ class CefBrowserProcessHandlerCToCpp
virtual ~CefBrowserProcessHandlerCToCpp();
// CefBrowserProcessHandler methods.
void OnRegisterCustomPreferences(
cef_preferences_type_t type,
CefRawPtr<CefPreferenceRegistrar> registrar) override;
void OnContextInitialized() override;
void OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line) override;

View File

@@ -0,0 +1,166 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=52f3ca6608adcc88d2fb8faf80f53255946880fc$
//
#include "libcef_dll/ctocpp/preference_manager_ctocpp.h"
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
#include "libcef_dll/ctocpp/value_ctocpp.h"
// STATIC METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
CefRefPtr<CefPreferenceManager>
CefPreferenceManager::GetGlobalPreferenceManager() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_preference_manager_t* _retval = cef_preference_manager_get_global();
// Return type: refptr_same
return CefPreferenceManagerCToCpp::Wrap(_retval);
}
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
bool CefPreferenceManagerCToCpp::HasPreference(const CefString& name) {
cef_preference_manager_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, has_preference))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return false;
// Execute
int _retval = _struct->has_preference(_struct, name.GetStruct());
// Return type: bool
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefValue> CefPreferenceManagerCToCpp::GetPreference(
const CefString& name) {
cef_preference_manager_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_preference))
return nullptr;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return nullptr;
// Execute
cef_value_t* _retval = _struct->get_preference(_struct, name.GetStruct());
// Return type: refptr_same
return CefValueCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefDictionaryValue> CefPreferenceManagerCToCpp::GetAllPreferences(
bool include_defaults) {
cef_preference_manager_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_all_preferences))
return nullptr;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_dictionary_value_t* _retval =
_struct->get_all_preferences(_struct, include_defaults);
// Return type: refptr_same
return CefDictionaryValueCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
bool CefPreferenceManagerCToCpp::CanSetPreference(const CefString& name) {
cef_preference_manager_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, can_set_preference))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return false;
// Execute
int _retval = _struct->can_set_preference(_struct, name.GetStruct());
// Return type: bool
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
bool CefPreferenceManagerCToCpp::SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) {
cef_preference_manager_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, set_preference))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return false;
// Unverified params: value
// Execute
int _retval = _struct->set_preference(_struct, name.GetStruct(),
CefValueCToCpp::Unwrap(value),
error.GetWritableStruct());
// Return type: bool
return _retval ? true : false;
}
// CONSTRUCTOR - Do not edit by hand.
CefPreferenceManagerCToCpp::CefPreferenceManagerCToCpp() {}
// DESTRUCTOR - Do not edit by hand.
CefPreferenceManagerCToCpp::~CefPreferenceManagerCToCpp() {}
template <>
cef_preference_manager_t* CefCToCppRefCounted<
CefPreferenceManagerCToCpp,
CefPreferenceManager,
cef_preference_manager_t>::UnwrapDerived(CefWrapperType type,
CefPreferenceManager* c) {
if (type == WT_REQUEST_CONTEXT) {
return reinterpret_cast<cef_preference_manager_t*>(
CefRequestContextCToCpp::Unwrap(
reinterpret_cast<CefRequestContext*>(c)));
}
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCToCppRefCounted<CefPreferenceManagerCToCpp,
CefPreferenceManager,
cef_preference_manager_t>::kWrapperType =
WT_PREFERENCE_MANAGER;

View File

@@ -0,0 +1,48 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=ec2addea82a8ad9018bd3f8e8dee80c998c7229b$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_MANAGER_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_MANAGER_CTOCPP_H_
#pragma once
#if !defined(WRAPPING_CEF_SHARED)
#error This file can be included wrapper-side only
#endif
#include "include/capi/cef_preference_capi.h"
#include "include/cef_preference.h"
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefPreferenceManagerCToCpp
: public CefCToCppRefCounted<CefPreferenceManagerCToCpp,
CefPreferenceManager,
cef_preference_manager_t> {
public:
CefPreferenceManagerCToCpp();
virtual ~CefPreferenceManagerCToCpp();
// CefPreferenceManager methods.
bool HasPreference(const CefString& name) override;
CefRefPtr<CefValue> GetPreference(const CefString& name) override;
CefRefPtr<CefDictionaryValue> GetAllPreferences(
bool include_defaults) override;
bool CanSetPreference(const CefString& name) override;
bool SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) override;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_MANAGER_CTOCPP_H_

View File

@@ -0,0 +1,77 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=c2a2edb07cc7aa06a63a71b626898213712a840a$
//
#include "libcef_dll/ctocpp/preference_registrar_ctocpp.h"
#include "libcef_dll/ctocpp/value_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
bool CefPreferenceRegistrarCToCpp::AddPreference(
const CefString& name,
CefRefPtr<CefValue> default_value) {
cef_preference_registrar_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, add_preference))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return false;
// Verify param: default_value; type: refptr_same
DCHECK(default_value.get());
if (!default_value.get())
return false;
// Execute
int _retval = _struct->add_preference(_struct, name.GetStruct(),
CefValueCToCpp::Unwrap(default_value));
// Return type: bool
return _retval ? true : false;
}
// CONSTRUCTOR - Do not edit by hand.
CefPreferenceRegistrarCToCpp::CefPreferenceRegistrarCToCpp() {}
// DESTRUCTOR - Do not edit by hand.
CefPreferenceRegistrarCToCpp::~CefPreferenceRegistrarCToCpp() {}
template <>
cef_preference_registrar_t* CefCToCppScoped<CefPreferenceRegistrarCToCpp,
CefPreferenceRegistrar,
cef_preference_registrar_t>::
UnwrapDerivedOwn(CefWrapperType type, CefOwnPtr<CefPreferenceRegistrar> c) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
cef_preference_registrar_t* CefCToCppScoped<CefPreferenceRegistrarCToCpp,
CefPreferenceRegistrar,
cef_preference_registrar_t>::
UnwrapDerivedRaw(CefWrapperType type, CefRawPtr<CefPreferenceRegistrar> c) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCToCppScoped<CefPreferenceRegistrarCToCpp,
CefPreferenceRegistrar,
cef_preference_registrar_t>::kWrapperType =
WT_PREFERENCE_REGISTRAR;

View File

@@ -0,0 +1,42 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=ca84e9c8992668fc127f6aed0136687f0d5ce0a3$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_REGISTRAR_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_REGISTRAR_CTOCPP_H_
#pragma once
#if !defined(WRAPPING_CEF_SHARED)
#error This file can be included wrapper-side only
#endif
#include "include/capi/cef_preference_capi.h"
#include "include/cef_preference.h"
#include "libcef_dll/ctocpp/ctocpp_scoped.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefPreferenceRegistrarCToCpp
: public CefCToCppScoped<CefPreferenceRegistrarCToCpp,
CefPreferenceRegistrar,
cef_preference_registrar_t> {
public:
CefPreferenceRegistrarCToCpp();
virtual ~CefPreferenceRegistrarCToCpp();
// CefPreferenceRegistrar methods.
bool AddPreference(const CefString& name,
CefRefPtr<CefValue> default_value) override;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_REGISTRAR_CTOCPP_H_

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=34a53ca8c93eb3dd0999d9e34d3f86307995e82d$
// $hash=8abfb084742cdd3ed31754a33281f0eacfc5fceb$
//
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
@@ -225,109 +225,6 @@ bool CefRequestContextCToCpp::ClearSchemeHandlerFactories() {
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
bool CefRequestContextCToCpp::HasPreference(const CefString& name) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, has_preference))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return false;
// Execute
int _retval = _struct->has_preference(_struct, name.GetStruct());
// Return type: bool
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefValue> CefRequestContextCToCpp::GetPreference(
const CefString& name) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_preference))
return nullptr;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return nullptr;
// Execute
cef_value_t* _retval = _struct->get_preference(_struct, name.GetStruct());
// Return type: refptr_same
return CefValueCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefDictionaryValue> CefRequestContextCToCpp::GetAllPreferences(
bool include_defaults) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_all_preferences))
return nullptr;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_dictionary_value_t* _retval =
_struct->get_all_preferences(_struct, include_defaults);
// Return type: refptr_same
return CefDictionaryValueCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
bool CefRequestContextCToCpp::CanSetPreference(const CefString& name) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, can_set_preference))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return false;
// Execute
int _retval = _struct->can_set_preference(_struct, name.GetStruct());
// Return type: bool
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
bool CefRequestContextCToCpp::SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, set_preference))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return false;
// Unverified params: value
// Execute
int _retval = _struct->set_preference(_struct, name.GetStruct(),
CefValueCToCpp::Unwrap(value),
error.GetWritableStruct());
// Return type: bool
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
void CefRequestContextCToCpp::ClearCertificateExceptions(
CefRefPtr<CefCompletionCallback> callback) {
@@ -533,6 +430,114 @@ CefRefPtr<CefMediaRouter> CefRequestContextCToCpp::GetMediaRouter(
return CefMediaRouterCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
bool CefRequestContextCToCpp::HasPreference(const CefString& name) {
cef_preference_manager_t* _struct =
reinterpret_cast<cef_preference_manager_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, has_preference))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return false;
// Execute
int _retval = _struct->has_preference(_struct, name.GetStruct());
// Return type: bool
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefValue> CefRequestContextCToCpp::GetPreference(
const CefString& name) {
cef_preference_manager_t* _struct =
reinterpret_cast<cef_preference_manager_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, get_preference))
return nullptr;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return nullptr;
// Execute
cef_value_t* _retval = _struct->get_preference(_struct, name.GetStruct());
// Return type: refptr_same
return CefValueCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefDictionaryValue> CefRequestContextCToCpp::GetAllPreferences(
bool include_defaults) {
cef_preference_manager_t* _struct =
reinterpret_cast<cef_preference_manager_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, get_all_preferences))
return nullptr;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_dictionary_value_t* _retval =
_struct->get_all_preferences(_struct, include_defaults);
// Return type: refptr_same
return CefDictionaryValueCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
bool CefRequestContextCToCpp::CanSetPreference(const CefString& name) {
cef_preference_manager_t* _struct =
reinterpret_cast<cef_preference_manager_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, can_set_preference))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return false;
// Execute
int _retval = _struct->can_set_preference(_struct, name.GetStruct());
// Return type: bool
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
bool CefRequestContextCToCpp::SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) {
cef_preference_manager_t* _struct =
reinterpret_cast<cef_preference_manager_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, set_preference))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: name; type: string_byref_const
DCHECK(!name.empty());
if (name.empty())
return false;
// Unverified params: value
// Execute
int _retval = _struct->set_preference(_struct, name.GetStruct(),
CefValueCToCpp::Unwrap(value),
error.GetWritableStruct());
// Return type: bool
return _retval ? true : false;
}
// CONSTRUCTOR - Do not edit by hand.
CefRequestContextCToCpp::CefRequestContextCToCpp() {}

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=693f5845874072abc324f643981531ed08d17b37$
// $hash=92f03524a854cd701e24fadc9680585ef875a8c8$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_CTOCPP_H_
@@ -52,14 +52,6 @@ class CefRequestContextCToCpp
const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory) override;
bool ClearSchemeHandlerFactories() override;
bool HasPreference(const CefString& name) override;
CefRefPtr<CefValue> GetPreference(const CefString& name) override;
CefRefPtr<CefDictionaryValue> GetAllPreferences(
bool include_defaults) override;
bool CanSetPreference(const CefString& name) override;
bool SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) override;
void ClearCertificateExceptions(
CefRefPtr<CefCompletionCallback> callback) override;
void ClearHttpAuthCredentials(
@@ -76,6 +68,16 @@ class CefRequestContextCToCpp
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
CefRefPtr<CefMediaRouter> GetMediaRouter(
CefRefPtr<CefCompletionCallback> callback) override;
// CefPreferenceManager methods.
bool HasPreference(const CefString& name) override;
CefRefPtr<CefValue> GetPreference(const CefString& name) override;
CefRefPtr<CefDictionaryValue> GetAllPreferences(
bool include_defaults) override;
bool CanSetPreference(const CefString& name) override;
bool SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) override;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_CTOCPP_H_

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=afef323719b977c74bb86d015ad1b0f5c253c3ba$
// $hash=d171aff72ef24ed2b85182e98b2b8d609ae25ddd$
//
#include "libcef_dll/ctocpp/views/display_ctocpp.h"
@@ -136,6 +136,32 @@ CefPoint CefDisplay::ConvertScreenPointFromPixels(const CefPoint& point) {
return _retval;
}
NO_SANITIZE("cfi-icall")
CefRect CefDisplay::ConvertScreenRectToPixels(const CefRect& rect) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_rect_t _retval = cef_display_convert_screen_rect_to_pixels(&rect);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
CefRect CefDisplay::ConvertScreenRectFromPixels(const CefRect& rect) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_rect_t _retval = cef_display_convert_screen_rect_from_pixels(&rect);
// Return type: simple
return _retval;
}
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall") int64 CefDisplayCToCpp::GetID() {

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=423d12cda6148d99e5afb0cc4aa11818e0740e1e$
// $hash=07d3613588fb17a2d07d817a4b1390db3b6cffe7$
//
#include "libcef_dll/ctocpp/views/window_delegate_ctocpp.h"
@@ -38,6 +38,25 @@ void CefWindowDelegateCToCpp::OnWindowCreated(CefRefPtr<CefWindow> window) {
_struct->on_window_created(_struct, CefWindowCppToC::Wrap(window));
}
NO_SANITIZE("cfi-icall")
void CefWindowDelegateCToCpp::OnWindowClosing(CefRefPtr<CefWindow> window) {
shutdown_checker::AssertNotShutdown();
cef_window_delegate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_window_closing))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: window; type: refptr_diff
DCHECK(window.get());
if (!window.get())
return;
// Execute
_struct->on_window_closing(_struct, CefWindowCppToC::Wrap(window));
}
NO_SANITIZE("cfi-icall")
void CefWindowDelegateCToCpp::OnWindowDestroyed(CefRefPtr<CefWindow> window) {
shutdown_checker::AssertNotShutdown();
@@ -79,6 +98,27 @@ void CefWindowDelegateCToCpp::OnWindowActivationChanged(
active);
}
NO_SANITIZE("cfi-icall")
void CefWindowDelegateCToCpp::OnWindowBoundsChanged(CefRefPtr<CefWindow> window,
const CefRect& new_bounds) {
shutdown_checker::AssertNotShutdown();
cef_window_delegate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_window_bounds_changed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: window; type: refptr_diff
DCHECK(window.get());
if (!window.get())
return;
// Execute
_struct->on_window_bounds_changed(_struct, CefWindowCppToC::Wrap(window),
&new_bounds);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefWindow> CefWindowDelegateCToCpp::GetParentWindow(
CefRefPtr<CefWindow> window,

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=4041b496f1e9ed673f99211be26b8fa98967fece$
// $hash=a7d0db45a4032026a7235d653b3cfed9929ad519$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_
@@ -38,9 +38,12 @@ class CefWindowDelegateCToCpp
// CefWindowDelegate methods.
void OnWindowCreated(CefRefPtr<CefWindow> window) override;
void OnWindowClosing(CefRefPtr<CefWindow> window) override;
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override;
void OnWindowActivationChanged(CefRefPtr<CefWindow> window,
bool active) override;
void OnWindowBoundsChanged(CefRefPtr<CefWindow> window,
const CefRect& new_bounds) override;
CefRefPtr<CefWindow> GetParentWindow(CefRefPtr<CefWindow> window,
bool* is_menu,
bool* can_activate_menu) override;

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=a3be9b3f96ebf8c8840856a6f454729d77459a22$
// $hash=6bc0085b04e78068511eb7198a3f9bda103adc85$
//
#include "include/capi/cef_app_capi.h"
@@ -146,20 +146,6 @@ CEF_EXPORT void cef_quit_message_loop() {
CefQuitMessageLoop();
}
CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
CefSetOSModalLoop(osModalLoop ? true : false);
}
CEF_EXPORT void cef_enable_highdpi_support() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
CefEnableHighDPISupport();
}
CEF_EXPORT int cef_crash_reporting_enabled() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

View File

@@ -4,9 +4,15 @@
//
#include <cstddef>
#include "include/base/cef_build.h"
#include "include/cef_api_hash.h"
#include "include/cef_version.h"
#if defined(OS_WIN)
#include "include/internal/cef_win.h"
#endif
CEF_EXPORT int cef_version_info(int entry) {
switch (entry) {
case 0:
@@ -42,3 +48,31 @@ CEF_EXPORT const char* cef_api_hash(int entry) {
return NULL;
}
}
#if defined(OS_WIN)
#if defined(ARCH_CPU_32_BITS)
CEF_EXPORT int cef_run_winmain_with_preferred_stack_size(wWinMainPtr wWinMain,
HINSTANCE hInstance,
LPWSTR lpCmdLine,
int nCmdShow) {
return CefRunWinMainWithPreferredStackSize(wWinMain, hInstance, lpCmdLine,
nCmdShow);
}
CEF_EXPORT int cef_run_main_with_preferred_stack_size(mainPtr main,
int argc,
char* argv[]) {
return CefRunMainWithPreferredStackSize(main, argc, argv);
}
#endif // defined(ARCH_CPU_32_BITS)
CEF_EXPORT void cef_enable_highdpi_support() {
CefEnableHighDPISupport();
}
CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop) {
CefSetOSModalLoop(osModalLoop ? true : false);
}
#endif // defined(OS_WIN)

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=bb6f61b0d69253de7bcc5506fd04562e46fa797c$
// $hash=aa091bc741fcefee760906fce4c8f86937dd74ca$
//
#include <dlfcn.h>
@@ -30,6 +30,7 @@
#include "include/capi/cef_origin_whitelist_capi.h"
#include "include/capi/cef_parser_capi.h"
#include "include/capi/cef_path_util_capi.h"
#include "include/capi/cef_preference_capi.h"
#include "include/capi/cef_print_settings_capi.h"
#include "include/capi/cef_process_message_capi.h"
#include "include/capi/cef_process_util_capi.h"
@@ -95,8 +96,6 @@ struct libcef_pointers {
decltype(&cef_do_message_loop_work) cef_do_message_loop_work;
decltype(&cef_run_message_loop) cef_run_message_loop;
decltype(&cef_quit_message_loop) cef_quit_message_loop;
decltype(&cef_set_osmodal_loop) cef_set_osmodal_loop;
decltype(&cef_enable_highdpi_support) cef_enable_highdpi_support;
decltype(&cef_crash_reporting_enabled) cef_crash_reporting_enabled;
decltype(&cef_set_crash_key_value) cef_set_crash_key_value;
decltype(&cef_create_directory) cef_create_directory;
@@ -157,6 +156,8 @@ struct libcef_pointers {
decltype(&cef_image_create) cef_image_create;
decltype(&cef_media_router_get_global) cef_media_router_get_global;
decltype(&cef_menu_model_create) cef_menu_model_create;
decltype(&cef_preference_manager_get_global)
cef_preference_manager_get_global;
decltype(&cef_print_settings_create) cef_print_settings_create;
decltype(&cef_process_message_create) cef_process_message_create;
decltype(&cef_request_create) cef_request_create;
@@ -238,6 +239,10 @@ struct libcef_pointers {
cef_display_convert_screen_point_to_pixels;
decltype(&cef_display_convert_screen_point_from_pixels)
cef_display_convert_screen_point_from_pixels;
decltype(&cef_display_convert_screen_rect_to_pixels)
cef_display_convert_screen_rect_to_pixels;
decltype(&cef_display_convert_screen_rect_from_pixels)
cef_display_convert_screen_rect_from_pixels;
decltype(&cef_label_button_create) cef_label_button_create;
decltype(&cef_menu_button_create) cef_menu_button_create;
decltype(&cef_panel_create) cef_panel_create;
@@ -336,8 +341,6 @@ int libcef_init_pointers(const char* path) {
INIT_ENTRY(cef_do_message_loop_work);
INIT_ENTRY(cef_run_message_loop);
INIT_ENTRY(cef_quit_message_loop);
INIT_ENTRY(cef_set_osmodal_loop);
INIT_ENTRY(cef_enable_highdpi_support);
INIT_ENTRY(cef_crash_reporting_enabled);
INIT_ENTRY(cef_set_crash_key_value);
INIT_ENTRY(cef_create_directory);
@@ -389,6 +392,7 @@ int libcef_init_pointers(const char* path) {
INIT_ENTRY(cef_image_create);
INIT_ENTRY(cef_media_router_get_global);
INIT_ENTRY(cef_menu_model_create);
INIT_ENTRY(cef_preference_manager_get_global);
INIT_ENTRY(cef_print_settings_create);
INIT_ENTRY(cef_process_message_create);
INIT_ENTRY(cef_request_create);
@@ -451,6 +455,8 @@ int libcef_init_pointers(const char* path) {
INIT_ENTRY(cef_display_get_alls);
INIT_ENTRY(cef_display_convert_screen_point_to_pixels);
INIT_ENTRY(cef_display_convert_screen_point_from_pixels);
INIT_ENTRY(cef_display_convert_screen_rect_to_pixels);
INIT_ENTRY(cef_display_convert_screen_rect_from_pixels);
INIT_ENTRY(cef_label_button_create);
INIT_ENTRY(cef_menu_button_create);
INIT_ENTRY(cef_panel_create);
@@ -599,14 +605,6 @@ NO_SANITIZE("cfi-icall") void cef_quit_message_loop() {
g_libcef_pointers.cef_quit_message_loop();
}
NO_SANITIZE("cfi-icall") void cef_set_osmodal_loop(int osModalLoop) {
g_libcef_pointers.cef_set_osmodal_loop(osModalLoop);
}
NO_SANITIZE("cfi-icall") void cef_enable_highdpi_support() {
g_libcef_pointers.cef_enable_highdpi_support();
}
NO_SANITIZE("cfi-icall") int cef_crash_reporting_enabled() {
return g_libcef_pointers.cef_crash_reporting_enabled();
}
@@ -912,6 +910,11 @@ struct _cef_menu_model_t* cef_menu_model_create(
return g_libcef_pointers.cef_menu_model_create(delegate);
}
NO_SANITIZE("cfi-icall")
struct _cef_preference_manager_t* cef_preference_manager_get_global() {
return g_libcef_pointers.cef_preference_manager_get_global();
}
NO_SANITIZE("cfi-icall")
struct _cef_print_settings_t* cef_print_settings_create() {
return g_libcef_pointers.cef_print_settings_create();
@@ -1291,6 +1294,16 @@ cef_point_t cef_display_convert_screen_point_from_pixels(
return g_libcef_pointers.cef_display_convert_screen_point_from_pixels(point);
}
NO_SANITIZE("cfi-icall")
cef_rect_t cef_display_convert_screen_rect_to_pixels(const cef_rect_t* rect) {
return g_libcef_pointers.cef_display_convert_screen_rect_to_pixels(rect);
}
NO_SANITIZE("cfi-icall")
cef_rect_t cef_display_convert_screen_rect_from_pixels(const cef_rect_t* rect) {
return g_libcef_pointers.cef_display_convert_screen_rect_from_pixels(rect);
}
NO_SANITIZE("cfi-icall")
struct _cef_label_button_t* cef_label_button_create(
struct _cef_button_delegate_t* delegate,

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=f1ec7f73b35927e943a058141d73d449dd31e43c$
// $hash=24d0396cbcb6e2af587c1126c899277d4ac0b4d2$
//
#include "include/capi/cef_app_capi.h"
@@ -138,20 +138,6 @@ NO_SANITIZE("cfi-icall") CEF_GLOBAL void CefQuitMessageLoop() {
cef_quit_message_loop();
}
NO_SANITIZE("cfi-icall") CEF_GLOBAL void CefSetOSModalLoop(bool osModalLoop) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_set_osmodal_loop(osModalLoop);
}
NO_SANITIZE("cfi-icall") CEF_GLOBAL void CefEnableHighDPISupport() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_enable_highdpi_support();
}
NO_SANITIZE("cfi-icall") CEF_GLOBAL bool CefCrashReportingEnabled() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

View File

@@ -1,3 +1,62 @@
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2022 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 "include/base/cef_build.h"
#if defined(OS_WIN)
#include "include/base/cef_compiler_specific.h"
#include "include/base/cef_logging.h"
#include "include/cef_api_hash.h"
#include "include/internal/cef_win.h"
#if defined(ARCH_CPU_32_BITS)
NO_SANITIZE("cfi-icall")
int CefRunWinMainWithPreferredStackSize(wWinMainPtr wWinMain,
HINSTANCE hInstance,
LPWSTR lpCmdLine,
int nCmdShow) {
CHECK(wWinMain && hInstance);
const char* api_hash = cef_api_hash(0);
if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) {
// The libcef API hash does not match the current header API hash.
NOTREACHED();
return 0;
}
return cef_run_winmain_with_preferred_stack_size(wWinMain, hInstance,
lpCmdLine, nCmdShow);
}
int CefRunMainWithPreferredStackSize(mainPtr main, int argc, char* argv[]) {
CHECK(main);
const char* api_hash = cef_api_hash(0);
if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) {
// The libcef API hash does not match the current header API hash.
NOTREACHED();
return 0;
}
return cef_run_main_with_preferred_stack_size(main, argc, argv);
}
#endif // defined(ARCH_CPU_32_BITS)
NO_SANITIZE("cfi-icall") void CefEnableHighDPISupport() {
const char* api_hash = cef_api_hash(0);
if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) {
// The libcef API hash does not match the current header API hash.
NOTREACHED();
return;
}
cef_enable_highdpi_support();
}
NO_SANITIZE("cfi-icall") void CefSetOSModalLoop(bool osModalLoop) {
cef_set_osmodal_loop(osModalLoop);
}
#endif // defined(OS_WIN)

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=15d99837c9ebf79df1d1ec2bab84900260410046$
// $hash=e8bf5997bf7a4e77f39247068da48b539ef838b0$
//
#ifndef CEF_LIBCEF_DLL_WRAPPER_TYPES_H_
@@ -100,6 +100,8 @@ enum CefWrapperType {
WT_PERMISSION_PROMPT_CALLBACK,
WT_POST_DATA,
WT_POST_DATA_ELEMENT,
WT_PREFERENCE_MANAGER,
WT_PREFERENCE_REGISTRAR,
WT_PRINT_DIALOG_CALLBACK,
WT_PRINT_HANDLER,
WT_PRINT_JOB_CALLBACK,

View File

@@ -118,6 +118,13 @@ patches = [
# Allow override of RWHVBase::GetNewScreenInfosForUpdate() which is now
# required due to https://crrev.com/96938eb36e in order to use
# RWHVBase::UpdateScreenInfo() with OSR.
#
# Windows: Fix incorrect DIPToScreenRect usage in DesktopWindowTreeHostWin
# when |has_external_parent_| is true.
# https://bitbucket.org/chromiumembedded/cef/issues/3359
#
# Windows: Fix 1px gap with maximized frameless windows on Win11.
# https://bitbucket.org/chromiumembedded/cef/issues/3414
'name': 'views_widget',
},
{
@@ -600,5 +607,11 @@ patches = [
# use_sysroot=false on Ubuntu 18.04.
# https://chromium-review.googlesource.com/c/chromium/src/+/3960017
'name': 'linux_glib_deprecated_volatile'
},
{
# mac: Fix sprintf compile error with macOS 14 SDK.
# https://github.com/harfbuzz/harfbuzz/pull/3495#issuecomment-1299107964
'name': 'mac_harfbuzz_3495',
'path': 'third_party/harfbuzz-ng/src'
}
]

View File

@@ -20,10 +20,10 @@ index 18c138c21a853..554e22458da45 100644
// TODO(wjmaclean): We should update the ProcessLock comparison API
diff --git content/browser/renderer_host/navigation_request.cc content/browser/renderer_host/navigation_request.cc
index 14dfb45da60c0..7e3ebfa6fb431 100644
index 28605cda32c8a..ed83d689e3574 100644
--- content/browser/renderer_host/navigation_request.cc
+++ content/browser/renderer_host/navigation_request.cc
@@ -6669,6 +6669,14 @@ std::pair<url::Origin, std::string> NavigationRequest::
@@ -6677,6 +6677,14 @@ std::pair<url::Origin, std::string> NavigationRequest::
origin_and_debug_info.second += ", error";
}
@@ -38,7 +38,7 @@ index 14dfb45da60c0..7e3ebfa6fb431 100644
if (use_opaque_origin) {
origin_and_debug_info =
std::make_pair(origin_and_debug_info.first.DeriveNewOpaqueOrigin(),
@@ -6696,6 +6704,15 @@ std::pair<url::Origin, std::string> NavigationRequest::
@@ -6704,6 +6712,15 @@ std::pair<url::Origin, std::string> NavigationRequest::
GetOriginForURLLoaderFactoryWithoutFinalFrameHostWithDebugInfo(
SandboxFlagsToCommit());

View File

@@ -1,8 +1,8 @@
diff --git build/config/compiler/BUILD.gn build/config/compiler/BUILD.gn
index cd9b186a1252f..2d0d9310485fe 100644
index 531b326c498d0..ee31a8d2feee5 100644
--- build/config/compiler/BUILD.gn
+++ build/config/compiler/BUILD.gn
@@ -1862,8 +1862,6 @@ config("thin_archive") {
@@ -1866,8 +1866,6 @@ config("thin_archive") {
# confuses lldb.
if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
arflags = [ "-T" ]

View File

@@ -1,5 +1,5 @@
diff --git chrome/browser/BUILD.gn chrome/browser/BUILD.gn
index 68415e75360ce..7a144a035b0a7 100644
index 6af6b725815f6..0cfb285477821 100644
--- chrome/browser/BUILD.gn
+++ chrome/browser/BUILD.gn
@@ -11,6 +11,7 @@ import("//build/config/compiler/pgo/pgo.gni")
@@ -10,7 +10,7 @@ index 68415e75360ce..7a144a035b0a7 100644
import("//chrome/browser/buildflags.gni")
import("//chrome/browser/downgrade/buildflags.gni")
import("//chrome/common/features.gni")
@@ -1986,6 +1987,7 @@ static_library("browser") {
@@ -1988,6 +1989,7 @@ static_library("browser") {
"//build/config/chromebox_for_meetings:buildflags",
"//build/config/compiler:compiler_buildflags",
"//cc",
@@ -18,7 +18,7 @@ index 68415e75360ce..7a144a035b0a7 100644
"//chrome:extra_resources",
"//chrome:resources",
"//chrome:strings",
@@ -2537,6 +2539,10 @@ static_library("browser") {
@@ -2539,6 +2541,10 @@ static_library("browser") {
]
}
@@ -29,7 +29,7 @@ index 68415e75360ce..7a144a035b0a7 100644
if (is_android) {
sources += [
"after_startup_task_utils_android.cc",
@@ -6394,8 +6400,6 @@ static_library("browser") {
@@ -6398,8 +6404,6 @@ static_library("browser") {
sources += [
"enterprise/chrome_browser_main_extra_parts_enterprise.cc",
"enterprise/chrome_browser_main_extra_parts_enterprise.h",

View File

@@ -13,7 +13,7 @@ index af62c19be9db6..d58f033cffecc 100644
return false;
}
diff --git chrome/browser/ui/BUILD.gn chrome/browser/ui/BUILD.gn
index f335c3dd28a5f..0798e05a47e10 100644
index 847e3c7baf8f4..bed6981df11e7 100644
--- chrome/browser/ui/BUILD.gn
+++ chrome/browser/ui/BUILD.gn
@@ -9,6 +9,7 @@ import("//build/config/compiler/compiler.gni")
@@ -43,7 +43,7 @@ index f335c3dd28a5f..0798e05a47e10 100644
"//chrome:extra_resources",
"//chrome:resources",
"//chrome:strings",
@@ -5713,6 +5719,7 @@ static_library("ui") {
@@ -5711,6 +5717,7 @@ static_library("ui") {
if (enable_basic_printing) {
deps += [
"//components/printing/browser",

View File

@@ -1,5 +1,5 @@
diff --git chrome/browser/renderer_context_menu/render_view_context_menu.cc chrome/browser/renderer_context_menu/render_view_context_menu.cc
index a4c41a8be6b23..0724b0e6e4ccf 100644
index cced71a37ce11..2bb623d2bdb60 100644
--- chrome/browser/renderer_context_menu/render_view_context_menu.cc
+++ chrome/browser/renderer_context_menu/render_view_context_menu.cc
@@ -309,6 +309,13 @@ base::OnceCallback<void(RenderViewContextMenu*)>* GetMenuShownCallback() {
@@ -42,7 +42,7 @@ index a4c41a8be6b23..0724b0e6e4ccf 100644
}
RenderViewContextMenu::~RenderViewContextMenu() = default;
@@ -1160,6 +1179,12 @@ void RenderViewContextMenu::InitMenu() {
@@ -1157,6 +1176,12 @@ void RenderViewContextMenu::InitMenu() {
// menu, meaning that each menu item added/removed in this function will cause
// it to visibly jump on the screen (see b/173569669).
AppendQuickAnswersItems();
@@ -55,7 +55,7 @@ index a4c41a8be6b23..0724b0e6e4ccf 100644
}
Profile* RenderViewContextMenu::GetProfile() const {
@@ -3031,6 +3056,12 @@ void RenderViewContextMenu::RegisterExecutePluginActionCallbackForTesting(
@@ -3022,6 +3047,12 @@ void RenderViewContextMenu::RegisterExecutePluginActionCallbackForTesting(
execute_plugin_action_callback_ = std::move(cb);
}
@@ -69,7 +69,7 @@ index a4c41a8be6b23..0724b0e6e4ccf 100644
RenderViewContextMenu::GetHandlersForLinkUrl() {
custom_handlers::ProtocolHandlerRegistry::ProtocolHandlerList handlers =
diff --git chrome/browser/renderer_context_menu/render_view_context_menu.h chrome/browser/renderer_context_menu/render_view_context_menu.h
index a6df6ba30d454..9bbd84c9c8820 100644
index 0e609102a42c0..73c38ed952d4a 100644
--- chrome/browser/renderer_context_menu/render_view_context_menu.h
+++ chrome/browser/renderer_context_menu/render_view_context_menu.h
@@ -134,6 +134,12 @@ class RenderViewContextMenu
@@ -85,7 +85,7 @@ index a6df6ba30d454..9bbd84c9c8820 100644
protected:
Profile* GetProfile() const;
@@ -381,6 +387,9 @@ class RenderViewContextMenu
@@ -386,6 +392,9 @@ class RenderViewContextMenu
// built.
bool is_protocol_submenu_valid_ = false;

View File

@@ -44,7 +44,7 @@ index 40d27e69a17ce..a7e18b475dd18 100644
base::FeatureList::IsEnabled(
features::kPeriodicSyncPermissionForDefaultSearchEngine) &&
diff --git chrome/browser/permissions/chrome_permissions_client.cc chrome/browser/permissions/chrome_permissions_client.cc
index 77faa54c6e8dc..d986538d36c2e 100644
index 6d3f766751ebf..85de2088cd972 100644
--- chrome/browser/permissions/chrome_permissions_client.cc
+++ chrome/browser/permissions/chrome_permissions_client.cc
@@ -13,6 +13,7 @@
@@ -55,7 +55,7 @@ index 77faa54c6e8dc..d986538d36c2e 100644
#include "chrome/browser/bluetooth/bluetooth_chooser_context_factory.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
@@ -211,6 +212,9 @@ ChromePermissionsClient::GetPermissionDecisionAutoBlocker(
@@ -219,6 +220,9 @@ ChromePermissionsClient::GetPermissionDecisionAutoBlocker(
double ChromePermissionsClient::GetSiteEngagementScore(
content::BrowserContext* browser_context,
const GURL& origin) {
@@ -65,7 +65,7 @@ index 77faa54c6e8dc..d986538d36c2e 100644
return site_engagement::SiteEngagementService::Get(
Profile::FromBrowserContext(browser_context))
->GetScore(origin);
@@ -295,8 +299,10 @@ ChromePermissionsClient::CreatePermissionUiSelectors(
@@ -303,8 +307,10 @@ ChromePermissionsClient::CreatePermissionUiSelectors(
std::make_unique<ContextualNotificationPermissionUiSelector>());
selectors.emplace_back(std::make_unique<PrefNotificationPermissionUiSelector>(
Profile::FromBrowserContext(browser_context)));

View File

@@ -14,7 +14,7 @@ index 8f94c350756b4..a243dbaadbc2b 100644
}
diff --git chrome/browser/profiles/profile.cc chrome/browser/profiles/profile.cc
index bd0f46ee1edce..f8efd6222175d 100644
index a82af67cd3afb..c9dbd798dbeda 100644
--- chrome/browser/profiles/profile.cc
+++ chrome/browser/profiles/profile.cc
@@ -83,6 +83,7 @@ base::LazyInstance<std::set<content::BrowserContext*>>::Leaky
@@ -52,7 +52,7 @@ index bd0f46ee1edce..f8efd6222175d 100644
Profile::OTRProfileID Profile::OTRProfileID::CreateUniqueForDevTools() {
return CreateUnique(kDevToolsOTRProfileIDPrefix);
diff --git chrome/browser/profiles/profile.h chrome/browser/profiles/profile.h
index eb5172ba4789c..147c9d828708b 100644
index bb7826c38d7ed..c99b96ee82fd5 100644
--- chrome/browser/profiles/profile.h
+++ chrome/browser/profiles/profile.h
@@ -99,6 +99,10 @@ class Profile : public content::BrowserContext {

View File

@@ -1,5 +1,5 @@
diff --git chrome/app/chrome_main_delegate.cc chrome/app/chrome_main_delegate.cc
index 87c1c47fc868a..42d7929172abc 100644
index dcd6659915114..b83f110bfe921 100644
--- chrome/app/chrome_main_delegate.cc
+++ chrome/app/chrome_main_delegate.cc
@@ -40,6 +40,7 @@
@@ -40,7 +40,7 @@ index 87c1c47fc868a..42d7929172abc 100644
base::sequence_manager::internal::ThreadControllerPowerMonitor::
InitializeOnMainThread();
base::InitializePlatformThreadFeatures();
@@ -1221,6 +1230,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1225,6 +1234,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
@@ -48,7 +48,7 @@ index 87c1c47fc868a..42d7929172abc 100644
crash_reporter::InitializeCrashKeys();
#if BUILDFLAG(IS_POSIX)
@@ -1231,6 +1241,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1235,6 +1245,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
InitMacCrashReporter(command_line, process_type);
SetUpInstallerPreferences(command_line);
#endif
@@ -56,7 +56,7 @@ index 87c1c47fc868a..42d7929172abc 100644
#if BUILDFLAG(IS_WIN)
child_process_logging::Init();
@@ -1433,6 +1444,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1437,6 +1448,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale;
}
@@ -64,7 +64,7 @@ index 87c1c47fc868a..42d7929172abc 100644
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
// Zygote needs to call InitCrashReporter() in RunZygote().
if (process_type != switches::kZygoteProcess) {
@@ -1476,6 +1488,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1480,6 +1492,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
// After all the platform Breakpads have been initialized, store the command
// line for crash reporting.
crash_keys::SetCrashKeysFromCommandLine(command_line);
@@ -72,7 +72,7 @@ index 87c1c47fc868a..42d7929172abc 100644
#if BUILDFLAG(ENABLE_PDF)
MaybePatchGdiGetFontData();
@@ -1574,6 +1587,7 @@ void ChromeMainDelegate::ZygoteForked() {
@@ -1578,6 +1591,7 @@ void ChromeMainDelegate::ZygoteForked() {
SetUpProfilingShutdownHandler();
}
@@ -80,7 +80,7 @@ index 87c1c47fc868a..42d7929172abc 100644
// Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets
// this up for the browser process in a different manner.
const base::CommandLine* command_line =
@@ -1596,6 +1610,7 @@ void ChromeMainDelegate::ZygoteForked() {
@@ -1600,6 +1614,7 @@ void ChromeMainDelegate::ZygoteForked() {
// Reset the command line for the newly spawned process.
crash_keys::SetCrashKeysFromCommandLine(*command_line);
@@ -198,7 +198,7 @@ index 70f6abda15030..d7a6dcc541464 100644
+#endif
}
diff --git chrome/browser/chrome_content_browser_client.cc chrome/browser/chrome_content_browser_client.cc
index 3038bbd2f7ada..73c55394367fa 100644
index 96b42e4e7ffe3..b3bbb9a78fdd0 100644
--- chrome/browser/chrome_content_browser_client.cc
+++ chrome/browser/chrome_content_browser_client.cc
@@ -32,6 +32,7 @@
@@ -209,7 +209,7 @@ index 3038bbd2f7ada..73c55394367fa 100644
#include "chrome/browser/accessibility/accessibility_labels_service.h"
#include "chrome/browser/accessibility/accessibility_labels_service_factory.h"
#include "chrome/browser/after_startup_task_utils.h"
@@ -1403,6 +1404,8 @@ bool DoesGaiaOriginRequireDedicatedProcess() {
@@ -1405,6 +1406,8 @@ bool DoesGaiaOriginRequireDedicatedProcess() {
} // namespace
ChromeContentBrowserClient::ChromeContentBrowserClient() {
@@ -218,7 +218,7 @@ index 3038bbd2f7ada..73c55394367fa 100644
#if BUILDFLAG(ENABLE_PLUGINS)
extra_parts_.push_back(new ChromeContentBrowserClientPluginsPart);
#endif
@@ -1428,6 +1431,11 @@ ChromeContentBrowserClient::~ChromeContentBrowserClient() {
@@ -1430,6 +1433,11 @@ ChromeContentBrowserClient::~ChromeContentBrowserClient() {
extra_parts_.clear();
}
@@ -230,7 +230,7 @@ index 3038bbd2f7ada..73c55394367fa 100644
// static
void ChromeContentBrowserClient::RegisterLocalStatePrefs(
PrefRegistrySimple* registry) {
@@ -4035,9 +4043,11 @@ void ChromeContentBrowserClient::BrowserURLHandlerCreated(
@@ -4037,9 +4045,11 @@ void ChromeContentBrowserClient::BrowserURLHandlerCreated(
&search::HandleNewTabURLReverseRewrite);
#endif // BUILDFLAG(IS_ANDROID)
@@ -242,7 +242,7 @@ index 3038bbd2f7ada..73c55394367fa 100644
}
base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
@@ -5771,7 +5781,7 @@ void ChromeContentBrowserClient::OnNetworkServiceCreated(
@@ -5782,7 +5792,7 @@ void ChromeContentBrowserClient::OnNetworkServiceCreated(
network_service);
}
@@ -251,7 +251,7 @@ index 3038bbd2f7ada..73c55394367fa 100644
content::BrowserContext* context,
bool in_memory,
const base::FilePath& relative_partition_path,
@@ -5789,6 +5799,8 @@ void ChromeContentBrowserClient::ConfigureNetworkContextParams(
@@ -5800,6 +5810,8 @@ void ChromeContentBrowserClient::ConfigureNetworkContextParams(
network_context_params->user_agent = GetUserAgentBasedOnPolicy(context);
network_context_params->accept_language = GetApplicationLocale();
}
@@ -260,7 +260,7 @@ index 3038bbd2f7ada..73c55394367fa 100644
}
std::vector<base::FilePath>
@@ -6656,10 +6668,10 @@ void ChromeContentBrowserClient::OnKeepaliveRequestStarted(
@@ -6667,10 +6679,10 @@ void ChromeContentBrowserClient::OnKeepaliveRequestStarted(
const auto now = base::TimeTicks::Now();
const auto timeout = GetKeepaliveTimerTimeout(context);
keepalive_deadline_ = std::max(keepalive_deadline_, now + timeout);
@@ -273,7 +273,7 @@ index 3038bbd2f7ada..73c55394367fa 100644
FROM_HERE, keepalive_deadline_ - now,
base::BindOnce(
&ChromeContentBrowserClient::OnKeepaliveTimerFired,
@@ -6678,7 +6690,8 @@ void ChromeContentBrowserClient::OnKeepaliveRequestFinished() {
@@ -6689,7 +6701,8 @@ void ChromeContentBrowserClient::OnKeepaliveRequestFinished() {
--num_keepalive_requests_;
if (num_keepalive_requests_ == 0) {
DVLOG(1) << "Stopping the keepalive timer";
@@ -283,7 +283,7 @@ index 3038bbd2f7ada..73c55394367fa 100644
// This deletes the keep alive handle attached to the timer function and
// unblock the shutdown sequence.
}
@@ -6810,7 +6823,7 @@ void ChromeContentBrowserClient::OnKeepaliveTimerFired(
@@ -6821,7 +6834,7 @@ void ChromeContentBrowserClient::OnKeepaliveTimerFired(
const auto now = base::TimeTicks::Now();
const auto then = keepalive_deadline_;
if (now < then) {
@@ -324,7 +324,7 @@ index 10b5cf030a944..49b773042ad24 100644
#endif
diff --git chrome/browser/prefs/browser_prefs.cc chrome/browser/prefs/browser_prefs.cc
index 621b03d86a86a..9123aa34187d1 100644
index 3eff9bc639bb1..49840f0f44529 100644
--- chrome/browser/prefs/browser_prefs.cc
+++ chrome/browser/prefs/browser_prefs.cc
@@ -11,6 +11,7 @@
@@ -346,14 +346,26 @@ index 621b03d86a86a..9123aa34187d1 100644
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/accessibility/animation_policy_prefs.h"
#include "chrome/browser/apps/platform_apps/shortcut_manager.h"
@@ -1321,6 +1326,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
SessionDataService::RegisterProfilePrefs(registry);
#endif
@@ -1228,6 +1233,11 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
// This is intentionally last.
RegisterLocalStatePrefsForMigration(registry);
+
+#if BUILDFLAG(ENABLE_CEF)
+ // Always call this last.
+ browser_prefs::RegisterLocalStatePrefs(registry);
+#endif
}
// Register prefs applicable to all profiles.
@@ -1602,6 +1612,10 @@ void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
const std::string& locale) {
RegisterProfilePrefs(registry, locale);
+#if BUILDFLAG(ENABLE_CEF)
+ browser_prefs::RegisterProfilePrefs(registry);
+#endif
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
ExtensionWebUI::RegisterProfilePrefs(registry);
RegisterAnimationPolicyPrefs(registry);
#if BUILDFLAG(IS_ANDROID)
::android::RegisterUserProfilePrefs(registry);
#endif

View File

@@ -475,7 +475,7 @@ index 57d5e9f7b4e3c..da7b2d14bae49 100644
}
diff --git chrome/browser/ui/views/toolbar/toolbar_view.cc chrome/browser/ui/views/toolbar/toolbar_view.cc
index 89ea1bf57ef43..22c39b3c6566d 100644
index b4d585985bf4c..6c5ac33bf3de8 100644
--- chrome/browser/ui/views/toolbar/toolbar_view.cc
+++ chrome/browser/ui/views/toolbar/toolbar_view.cc
@@ -171,12 +171,13 @@ auto& GetViewCommandMap() {

View File

@@ -105,7 +105,7 @@ index 58f891fd7af7a..3178a0aeab935 100644
}
diff --git content/app/content_main_runner_impl.cc content/app/content_main_runner_impl.cc
index 6965f862853af..d674963c89a64 100644
index 3336d4e49eb40..d4765faf7ae33 100644
--- content/app/content_main_runner_impl.cc
+++ content/app/content_main_runner_impl.cc
@@ -43,6 +43,7 @@
@@ -116,7 +116,7 @@ index 6965f862853af..d674963c89a64 100644
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
@@ -1269,6 +1270,12 @@ void ContentMainRunnerImpl::Shutdown() {
@@ -1280,6 +1281,12 @@ void ContentMainRunnerImpl::Shutdown() {
is_shutdown_ = true;
}

View File

@@ -0,0 +1,26 @@
diff --git src/OT/Layout/GSUB/Ligature.hh src/OT/Layout/GSUB/Ligature.hh
index f373d921b..cdb35f525 100644
--- src/OT/Layout/GSUB/Ligature.hh
+++ src/OT/Layout/GSUB/Ligature.hh
@@ -118,7 +118,7 @@ struct Ligature
match_positions[i] += delta;
if (i)
*p++ = ',';
- sprintf (p, "%u", match_positions[i]);
+ snprintf (p, sizeof(buf) - (p - buf), "%u", match_positions[i]);
p += strlen(p);
}
diff --git src/OT/Layout/GSUB/Sequence.hh src/OT/Layout/GSUB/Sequence.hh
index 3d84a5e6e..e2190078b 100644
--- src/OT/Layout/GSUB/Sequence.hh
+++ src/OT/Layout/GSUB/Sequence.hh
@@ -117,7 +117,7 @@ struct Sequence
{
if (buf < p)
*p++ = ',';
- sprintf (p, "%u", i);
+ snprintf (p, sizeof(buf) - (p - buf), "%u", i);
p += strlen(p);
}

View File

@@ -41,10 +41,10 @@ index afefe3cd83dee..6668463247644 100644
} // namespace content
diff --git content/browser/renderer_host/render_widget_host_impl.cc content/browser/renderer_host/render_widget_host_impl.cc
index 0133090585389..9f619e6577bbd 100644
index ff4e181fae184..5150ccf1e58b6 100644
--- content/browser/renderer_host/render_widget_host_impl.cc
+++ content/browser/renderer_host/render_widget_host_impl.cc
@@ -3175,6 +3175,11 @@ void RenderWidgetHostImpl::OnInvalidInputEventSource() {
@@ -3188,6 +3188,11 @@ void RenderWidgetHostImpl::OnInvalidInputEventSource() {
GetProcess(), bad_message::INPUT_ROUTER_INVALID_EVENT_SOURCE);
}
@@ -57,7 +57,7 @@ index 0133090585389..9f619e6577bbd 100644
const WebInputEvent& event) {
if ((base::FeatureList::IsEnabled(
diff --git content/browser/renderer_host/render_widget_host_impl.h content/browser/renderer_host/render_widget_host_impl.h
index 688c6b226d839..f4b8a63aca530 100644
index 6ea55a22496a5..c44aaee52c2c2 100644
--- content/browser/renderer_host/render_widget_host_impl.h
+++ content/browser/renderer_host/render_widget_host_impl.h
@@ -789,6 +789,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl

View File

@@ -1,5 +1,5 @@
diff --git content/browser/renderer_host/render_widget_host_view_base.cc content/browser/renderer_host/render_widget_host_view_base.cc
index b0c9044e9978f..13191e2d38387 100644
index e5d57b6136722..1d34b6256823a 100644
--- content/browser/renderer_host/render_widget_host_view_base.cc
+++ content/browser/renderer_host/render_widget_host_view_base.cc
@@ -663,6 +663,14 @@ float RenderWidgetHostViewBase::GetScaleOverrideForCapture() const {
@@ -258,10 +258,10 @@ index 774a2d23a87a6..88769ad800d22 100644
// Calculate initial bounds.
diff --git ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
index 0d5595767664e..dc9162d3c6eb3 100644
index 0d5595767664e..d36964f634683 100644
--- ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
+++ ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
@@ -183,8 +183,12 @@ void DesktopWindowTreeHostWin::Init(const Widget::InitParams& params) {
@@ -183,16 +183,28 @@ void DesktopWindowTreeHostWin::Init(const Widget::InitParams& params) {
native_widget_delegate_);
HWND parent_hwnd = nullptr;
@@ -275,7 +275,26 @@ index 0d5595767664e..dc9162d3c6eb3 100644
remove_standard_frame_ = params.remove_standard_frame;
has_non_client_view_ = Widget::RequiresNonClientView(params.type);
@@ -1033,11 +1037,15 @@ void DesktopWindowTreeHostWin::HandleFrameChanged() {
z_order_ = params.EffectiveZOrderLevel();
- // We don't have an HWND yet, so scale relative to the nearest screen.
- gfx::Rect pixel_bounds =
- display::win::ScreenWin::DIPToScreenRect(nullptr, params.bounds);
+ gfx::Rect pixel_bounds;
+ if (has_external_parent_) {
+ // Scale relative to the screen that contains the parent window.
+ // Child windows always have origin (0,0).
+ pixel_bounds.set_size(display::win::ScreenWin::DIPToScreenSize(
+ parent_hwnd, params.bounds.size()));
+ } else {
+ // We don't have an HWND yet, so scale relative to the nearest screen.
+ pixel_bounds =
+ display::win::ScreenWin::DIPToScreenRect(nullptr, params.bounds);
+ }
message_handler_->Init(parent_hwnd, pixel_bounds, params.headless_mode);
CreateCompositor(params.force_software_compositing);
OnAcceleratedWidgetAvailable();
@@ -1033,11 +1045,15 @@ void DesktopWindowTreeHostWin::HandleFrameChanged() {
}
void DesktopWindowTreeHostWin::HandleNativeFocus(HWND last_focused_window) {
@@ -293,7 +312,7 @@ index 0d5595767664e..dc9162d3c6eb3 100644
}
bool DesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) {
@@ -1045,6 +1053,12 @@ bool DesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) {
@@ -1045,6 +1061,12 @@ bool DesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) {
if (ui::PlatformEventSource::ShouldIgnoreNativePlatformEvents())
return true;
@@ -306,6 +325,24 @@ index 0d5595767664e..dc9162d3c6eb3 100644
SendEventToSink(event);
return event->handled();
}
@@ -1224,8 +1246,16 @@ void DesktopWindowTreeHostWin::SetBoundsInDIP(const gfx::Rect& bounds) {
// positions in variable-DPI situations. See https://crbug.com/1224715 for
// details.
aura::Window* root = nullptr;
- const gfx::Rect bounds_in_pixels =
+ if (has_external_parent_) {
+ // Scale relative to the screen that contains the parent window.
+ root = AsWindowTreeHost()->window();
+ }
+ gfx::Rect bounds_in_pixels =
display::Screen::GetScreen()->DIPToScreenRectInWindow(root, bounds);
+ if (has_external_parent_) {
+ // Child windows always have origin (0,0).
+ bounds_in_pixels.set_origin(gfx::Point(0, 0));
+ }
AsWindowTreeHost()->SetBoundsInPixels(bounds_in_pixels);
}
diff --git ui/views/widget/desktop_aura/desktop_window_tree_host_win.h ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
index cec35ceb25477..6eab66d5676b5 100644
--- ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
@@ -322,7 +359,7 @@ index cec35ceb25477..6eab66d5676b5 100644
// a reference.
raw_ptr<corewm::TooltipWin> tooltip_;
diff --git ui/views/widget/widget.cc ui/views/widget/widget.cc
index 8e2d4979b8a31..d7cf97b77d267 100644
index a00e37288c693..9bcd04733348d 100644
--- ui/views/widget/widget.cc
+++ ui/views/widget/widget.cc
@@ -344,7 +344,8 @@ void Widget::Init(InitParams params) {
@@ -358,7 +395,7 @@ index 8e2d4979b8a31..d7cf97b77d267 100644
}
if (base::FeatureList::IsEnabled(features::kWidgetLayering)) {
@@ -1480,10 +1489,16 @@ void Widget::OnNativeWidgetParentChanged(gfx::NativeView parent) {
@@ -1482,10 +1491,16 @@ void Widget::OnNativeWidgetParentChanged(gfx::NativeView parent) {
}
gfx::Size Widget::GetMinimumSize() const {
@@ -376,7 +413,7 @@ index 8e2d4979b8a31..d7cf97b77d267 100644
}
diff --git ui/views/widget/widget.h ui/views/widget/widget.h
index 04135ed11fa00..cfc074bad31dd 100644
index ae1aa11206097..d493ecca37893 100644
--- ui/views/widget/widget.h
+++ ui/views/widget/widget.h
@@ -345,6 +345,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
@@ -418,10 +455,21 @@ index d24c447bb8030..29215d6578169 100644
if (native_widget_delegate->IsDialogBox()) {
*style |= DS_MODALFRAME;
diff --git ui/views/win/hwnd_message_handler.cc ui/views/win/hwnd_message_handler.cc
index ec39cb0d15c80..1bafc2fd817e5 100644
index ec39cb0d15c80..27c51bfb740f4 100644
--- ui/views/win/hwnd_message_handler.cc
+++ ui/views/win/hwnd_message_handler.cc
@@ -827,7 +827,11 @@ bool HWNDMessageHandler::IsVisible() const {
@@ -626,7 +626,9 @@ void HWNDMessageHandler::SetDwmFrameExtension(DwmFrameState state) {
if (!delegate_->HasFrame() && ui::win::IsAeroGlassEnabled() &&
!is_translucent_) {
MARGINS m = {0, 0, 0, 0};
- if (state == DwmFrameState::kOn)
+ // Fix 1px gap with frameless windows on Win11 by not setting DWM margins
+ // when maximized. See CEF issue #3414.
+ if (state == DwmFrameState::kOn && !IsMaximized())
m = {0, 0, 1, 0};
DwmExtendFrameIntoClientArea(hwnd(), &m);
}
@@ -827,7 +829,11 @@ bool HWNDMessageHandler::IsVisible() const {
}
bool HWNDMessageHandler::IsActive() const {
@@ -434,7 +482,7 @@ index ec39cb0d15c80..1bafc2fd817e5 100644
}
bool HWNDMessageHandler::IsMinimized() const {
@@ -3224,10 +3228,13 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message,
@@ -3224,10 +3230,13 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message,
} else if (event.type() == ui::ET_MOUSEWHEEL) {
ui::MouseWheelEvent mouse_wheel_event(msg);
// Reroute the mouse wheel to the window under the pointer if applicable.

View File

@@ -170,7 +170,7 @@ index 4c5bf12286fbc..8067b12a373d4 100644
compositor_data.display_client->GetBoundRemote(resize_task_runner_);
mojo::AssociatedRemote<viz::mojom::ExternalBeginFrameController>
diff --git mojo/public/cpp/bindings/sync_call_restrictions.h mojo/public/cpp/bindings/sync_call_restrictions.h
index 46e283304761c..624f4030acc6a 100644
index d63ec55ae38d6..ff86831efd68b 100644
--- mojo/public/cpp/bindings/sync_call_restrictions.h
+++ mojo/public/cpp/bindings/sync_call_restrictions.h
@@ -42,6 +42,7 @@ class Compositor;
@@ -181,7 +181,7 @@ index 46e283304761c..624f4030acc6a 100644
class GpuHostImpl;
class HostFrameSinkManager;
class HostGpuMemoryBufferManager;
@@ -104,6 +105,8 @@ class COMPONENT_EXPORT(MOJO_CPP_BINDINGS) SyncCallRestrictions {
@@ -118,6 +119,8 @@ class COMPONENT_EXPORT(MOJO_CPP_BINDINGS) SyncCallRestrictions {
// For preventing frame swaps of wrong size during resize on Windows.
// (https://crbug.com/811945)
friend class ui::Compositor;

View File

@@ -1,8 +1,8 @@
diff --git content/browser/web_contents/web_contents_impl.cc content/browser/web_contents/web_contents_impl.cc
index 04bd45199b0db..f55241b38fc7b 100644
index 15b6cdaf470c1..4154329771c37 100644
--- content/browser/web_contents/web_contents_impl.cc
+++ content/browser/web_contents/web_contents_impl.cc
@@ -3082,6 +3082,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
@@ -3084,6 +3084,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
site_instance.get(), params.renderer_initiated_creation,
params.main_frame_name, GetOpener(), primary_main_frame_policy);
@@ -15,7 +15,7 @@ index 04bd45199b0db..f55241b38fc7b 100644
std::unique_ptr<WebContentsViewDelegate> delegate =
GetContentClient()->browser()->GetWebContentsViewDelegate(this);
@@ -3092,6 +3098,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
@@ -3094,6 +3100,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
view_ = CreateWebContentsView(this, std::move(delegate),
&render_view_host_delegate_view_);
}
@@ -23,7 +23,7 @@ index 04bd45199b0db..f55241b38fc7b 100644
CHECK(render_view_host_delegate_view_);
CHECK(view_.get());
@@ -3267,6 +3274,9 @@ void WebContentsImpl::RenderWidgetCreated(
@@ -3269,6 +3276,9 @@ void WebContentsImpl::RenderWidgetCreated(
OPTIONAL_TRACE_EVENT1("content", "WebContentsImpl::RenderWidgetCreated",
"render_widget_host", render_widget_host);
created_widgets_.insert(render_widget_host);
@@ -33,7 +33,7 @@ index 04bd45199b0db..f55241b38fc7b 100644
}
void WebContentsImpl::RenderWidgetDeleted(
@@ -3995,6 +4005,15 @@ FrameTree* WebContentsImpl::CreateNewWindow(
@@ -3997,6 +4007,15 @@ FrameTree* WebContentsImpl::CreateNewWindow(
params.pip_options->lock_aspect_ratio;
}
@@ -49,7 +49,7 @@ index 04bd45199b0db..f55241b38fc7b 100644
std::unique_ptr<WebContentsImpl> new_contents;
if (!is_guest) {
create_params.context = view_->GetNativeView();
@@ -7879,6 +7898,9 @@ void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node,
@@ -7893,6 +7912,9 @@ void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node,
// frames).
SetFocusedFrameTree(node->frame_tree());
}
@@ -60,7 +60,7 @@ index 04bd45199b0db..f55241b38fc7b 100644
void WebContentsImpl::DidCallFocus() {
diff --git content/public/browser/web_contents.h content/public/browser/web_contents.h
index aea5078136b95..3371a5ee23330 100644
index cc61bc1b43500..c5a387653d93a 100644
--- content/public/browser/web_contents.h
+++ content/public/browser/web_contents.h
@@ -95,10 +95,12 @@ class BrowserContext;

View File

@@ -8,6 +8,7 @@
#include "include/cef_command_line.h"
#include "include/cef_crash_util.h"
#include "include/cef_file_util.h"
#include "tests/cefclient/browser/client_prefs.h"
#include "tests/shared/common/client_switches.h"
namespace client {
@@ -19,6 +20,16 @@ class ClientBrowserDelegate : public ClientAppBrowser::Delegate {
public:
ClientBrowserDelegate() {}
void OnRegisterCustomPreferences(
CefRefPtr<client::ClientAppBrowser> app,
cef_preferences_type_t type,
CefRawPtr<CefPreferenceRegistrar> registrar) override {
if (type == CEF_PREFERENCES_TYPE_GLOBAL) {
// Register global preferences with default values.
prefs::RegisterGlobalPreferences(registrar);
}
}
void OnContextInitialized(CefRefPtr<ClientAppBrowser> app) override {
if (CefCrashReportingEnabled()) {
// Set some crash keys for testing purposes. Keys must be defined in the

View File

@@ -0,0 +1,202 @@
// Copyright (c) 2022 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 "tests/cefclient/browser/client_prefs.h"
#include <memory>
#include "include/base/cef_logging.h"
#include "include/cef_command_line.h"
#include "include/cef_preference.h"
#include "include/cef_values.h"
#include "include/views/cef_display.h"
#include "include/wrapper/cef_helpers.h"
#include "tests/shared/common/client_switches.h"
#include "tests/shared/common/string_util.h"
namespace client {
namespace prefs {
namespace {
constexpr char kPrefWindowRestore[] = "cefclient.window_restore";
constexpr char kWindowRestoreStateKey[] = "state";
constexpr char kWindowRestoreBoundsKey[] = "bounds";
constexpr char kWindowRestoreBoundsKey_X[] = "x";
constexpr char kWindowRestoreBoundsKey_Y[] = "y";
constexpr char kWindowRestoreBoundsKey_W[] = "w";
constexpr char kWindowRestoreBoundsKey_H[] = "h";
static struct {
const char* str;
cef_show_state_t state;
} const kWindowRestoreStateValueMap[] = {
{"normal", CEF_SHOW_STATE_NORMAL},
{"minimized", CEF_SHOW_STATE_MINIMIZED},
{"maximized", CEF_SHOW_STATE_MAXIMIZED},
{"fullscreen", CEF_SHOW_STATE_FULLSCREEN},
};
std::optional<cef_show_state_t> ShowStateFromString(const std::string& str) {
const auto strLower = AsciiStrToLower(str);
for (size_t i = 0; i < std::size(kWindowRestoreStateValueMap); ++i) {
if (strLower == kWindowRestoreStateValueMap[i].str) {
return kWindowRestoreStateValueMap[i].state;
}
}
return std::nullopt;
}
const char* ShowStateToString(cef_show_state_t show_state) {
for (size_t i = 0; i < std::size(kWindowRestoreStateValueMap); ++i) {
if (show_state == kWindowRestoreStateValueMap[i].state) {
return kWindowRestoreStateValueMap[i].str;
}
}
NOTREACHED();
return nullptr;
}
// Create the CefValue representation that will be stored in preferences.
CefRefPtr<CefValue> CreateWindowRestoreValue(
cef_show_state_t show_state,
std::optional<CefRect> dip_bounds) {
auto dict = CefDictionaryValue::Create();
// Show state is required.
dict->SetString(kWindowRestoreStateKey, ShowStateToString(show_state));
// Bounds is optional.
if (dip_bounds) {
auto bounds_dict = CefDictionaryValue::Create();
bounds_dict->SetInt(kWindowRestoreBoundsKey_X, dip_bounds->x);
bounds_dict->SetInt(kWindowRestoreBoundsKey_Y, dip_bounds->y);
bounds_dict->SetInt(kWindowRestoreBoundsKey_W, dip_bounds->width);
bounds_dict->SetInt(kWindowRestoreBoundsKey_H, dip_bounds->height);
dict->SetDictionary(kWindowRestoreBoundsKey, bounds_dict);
}
auto value = CefValue::Create();
value->SetDictionary(dict);
return value;
}
CefRefPtr<CefValue> CreateDefaultWindowRestoreValue() {
return CreateWindowRestoreValue(CEF_SHOW_STATE_NORMAL, std::nullopt);
}
// Parse the CefValue representation that was stored in preferences.
bool ParseWindowRestoreValue(CefRefPtr<CefValue> value,
cef_show_state_t& show_state,
std::optional<CefRect>& dip_bounds) {
if (!value || value->GetType() != VTYPE_DICTIONARY) {
return false;
}
auto dict = value->GetDictionary();
bool has_state = false;
// Show state is required.
if (dict->GetType(kWindowRestoreStateKey) == VTYPE_STRING) {
auto result = ShowStateFromString(dict->GetString(kWindowRestoreStateKey));
if (result) {
show_state = *result;
has_state = true;
}
}
// Bounds is optional.
if (has_state && dict->GetType(kWindowRestoreBoundsKey) == VTYPE_DICTIONARY) {
auto bounds_dict = dict->GetDictionary(kWindowRestoreBoundsKey);
if (bounds_dict->GetType(kWindowRestoreBoundsKey_X) == VTYPE_INT &&
bounds_dict->GetType(kWindowRestoreBoundsKey_Y) == VTYPE_INT &&
bounds_dict->GetType(kWindowRestoreBoundsKey_W) == VTYPE_INT &&
bounds_dict->GetType(kWindowRestoreBoundsKey_H) == VTYPE_INT) {
dip_bounds = CefRect(bounds_dict->GetInt(kWindowRestoreBoundsKey_X),
bounds_dict->GetInt(kWindowRestoreBoundsKey_Y),
bounds_dict->GetInt(kWindowRestoreBoundsKey_W),
bounds_dict->GetInt(kWindowRestoreBoundsKey_H));
}
}
return has_state;
}
// Keep the bounds inside the closest display work area.
CefRect ClampBoundsToDisplay(const CefRect& dip_bounds) {
auto display = CefDisplay::GetDisplayMatchingBounds(
dip_bounds, /*input_pixel_coords=*/false);
const auto work_area = display->GetWorkArea();
CefRect bounds = dip_bounds;
if (bounds.width > work_area.width)
bounds.width = work_area.width;
if (bounds.height > work_area.height)
bounds.height = work_area.height;
if (bounds.x < work_area.x)
bounds.x = work_area.x;
else if (bounds.x + bounds.width >= work_area.x + work_area.width)
bounds.x = work_area.x + work_area.width - bounds.width;
if (bounds.y < work_area.y)
bounds.y = work_area.y;
else if (bounds.y + bounds.height >= work_area.y + work_area.height)
bounds.y = work_area.y + work_area.height - bounds.height;
return bounds;
}
} // namespace
void RegisterGlobalPreferences(CefRawPtr<CefPreferenceRegistrar> registrar) {
registrar->AddPreference(kPrefWindowRestore,
CreateDefaultWindowRestoreValue());
}
bool LoadWindowRestorePreferences(cef_show_state_t& show_state,
std::optional<CefRect>& dip_bounds) {
CEF_REQUIRE_UI_THREAD();
// Check if show state was specified on the command-line.
auto command_line = CefCommandLine::GetGlobalCommandLine();
if (command_line->HasSwitch(switches::kInitialShowState)) {
auto result = ShowStateFromString(
command_line->GetSwitchValue(switches::kInitialShowState));
if (result) {
show_state = *result;
return true;
}
}
// Check if show state was saved in global preferences.
auto manager = CefPreferenceManager::GetGlobalPreferenceManager();
if (ParseWindowRestoreValue(manager->GetPreference(kPrefWindowRestore),
show_state, dip_bounds)) {
if (dip_bounds) {
// Keep the bounds inside the closest display.
dip_bounds = ClampBoundsToDisplay(*dip_bounds);
}
return true;
}
return false;
}
bool SaveWindowRestorePreferences(cef_show_state_t show_state,
std::optional<CefRect> dip_bounds) {
CEF_REQUIRE_UI_THREAD();
auto manager = CefPreferenceManager::GetGlobalPreferenceManager();
CefString error;
return manager->SetPreference(
kPrefWindowRestore, CreateWindowRestoreValue(show_state, dip_bounds),
error);
}
} // namespace prefs
} // namespace client

View File

@@ -0,0 +1,29 @@
// Copyright (c) 2022 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_TESTS_CEFCLIENT_BROWSER_CLIENT_PREFS_H_
#define CEF_TESTS_CEFCLIENT_BROWSER_CLIENT_PREFS_H_
#pragma once
#include <optional>
#include "include/cef_base.h"
#include "include/cef_preference.h"
namespace client {
namespace prefs {
// Register global preferences with default values.
void RegisterGlobalPreferences(CefRawPtr<CefPreferenceRegistrar> registrar);
// Load/save window restore info.
bool LoadWindowRestorePreferences(cef_show_state_t& show_state,
std::optional<CefRect>& dip_bounds);
bool SaveWindowRestorePreferences(cef_show_state_t show_state,
std::optional<CefRect> dip_bounds);
} // namespace prefs
} // namespace client
#endif // CEF_TESTS_CEFCLIENT_BROWSER_CLIENT_PREFS_H_

View File

@@ -11,13 +11,7 @@
namespace client {
RootWindowConfig::RootWindowConfig()
: always_on_top(false),
with_controls(true),
with_osr(false),
with_extension(false),
initially_hidden(false),
url(MainContext::Get()->GetMainURL()) {}
RootWindowConfig::RootWindowConfig() : url(MainContext::Get()->GetMainURL()) {}
RootWindow::RootWindow() : delegate_(nullptr) {}

View File

@@ -25,19 +25,19 @@ struct RootWindowConfig {
RootWindowConfig();
// If true the window will always display above other windows.
bool always_on_top;
bool always_on_top = false;
// If true the window will show controls.
bool with_controls;
bool with_controls = true;
// If true the window will use off-screen rendering.
bool with_osr;
bool with_osr = false;
// If true the window is hosting an extension app.
bool with_extension;
bool with_extension = false;
// If true the window will be created initially hidden.
bool initially_hidden;
bool initially_hidden = false;
// Requested window position. If |bounds| and |source_bounds| are empty the
// default window size and location will be used.
@@ -49,6 +49,10 @@ struct RootWindowConfig {
// based windows when |initially_hidden| is also true.
CefRect source_bounds;
// Requested window show state. Only used when |bounds| is non-empty and
// |initially_hidden| is false.
cef_show_state_t show_state = CEF_SHOW_STATE_NORMAL;
// Parent window. Only used for Views-based windows.
CefRefPtr<CefWindow> parent_window;

View File

@@ -9,8 +9,10 @@
#include "include/base/cef_callback.h"
#include "include/cef_app.h"
#include "include/cef_application_mac.h"
#include "include/views/cef_display.h"
#include "tests/cefclient/browser/browser_window_osr_mac.h"
#include "tests/cefclient/browser/browser_window_std_mac.h"
#include "tests/cefclient/browser/client_prefs.h"
#include "tests/cefclient/browser/main_context.h"
#include "tests/cefclient/browser/temp_window.h"
#include "tests/cefclient/browser/window_test_runner_mac.h"
@@ -23,10 +25,12 @@
@private
NSWindow* window_;
client::RootWindowMac* root_window_;
std::optional<CefRect> last_visible_bounds_;
bool force_close_;
}
@property(nonatomic, readonly) client::RootWindowMac* root_window;
@property(nonatomic, readwrite) std::optional<CefRect> last_visible_bounds;
@property(nonatomic, readwrite) bool force_close;
- (id)initWithWindow:(NSWindow*)window
@@ -61,10 +65,120 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
return button;
}
// Transform input Y coodinate into MacOS coordinate.
CGFloat TransformY(int y) {
NSRect primary_screen_rect = [[[NSScreen screens] firstObject] frame];
return NSMaxY(primary_screen_rect) - y;
// Returns the current DIP screen bounds for a visible window in the
// restored position, or nullopt if the window is currently minimized or
// fullscreen.
std::optional<CefRect> GetWindowBoundsInScreen(NSWindow* window) {
if ([window isMiniaturized] or [window isZoomed]) {
return std::nullopt;
}
auto screen = [window screen];
if (screen == nil)
screen = [NSScreen mainScreen];
const auto bounds = [window frame];
const auto screen_bounds = [screen frame];
if (NSEqualRects(bounds, screen_bounds)) {
// Don't include windows that are transitioning to fullscreen.
return std::nullopt;
}
CefRect dip_bounds{static_cast<int>(bounds.origin.x),
static_cast<int>(bounds.origin.y),
static_cast<int>(bounds.size.width),
static_cast<int>(bounds.size.height)};
// Convert from macOS coordinates (bottom-left origin) to DIP coordinates
// (top-left origin).
dip_bounds.y = static_cast<int>(screen_bounds.size.height) -
dip_bounds.height - dip_bounds.y;
return dip_bounds;
}
// Keep the frame bounds inside the display work area.
NSRect ClampNSBoundsToWorkArea(const NSRect& frame_bounds,
const CefRect& display_bounds,
const CefRect& work_area) {
NSRect bounds = frame_bounds;
// Convert from DIP coordinates (top-left origin) to macOS coordinates
// (bottom-left origin).
const int work_area_y =
display_bounds.height - work_area.height - work_area.y;
if (bounds.size.width > work_area.width) {
bounds.size.width = work_area.width;
}
if (bounds.size.height > work_area.height) {
bounds.size.height = work_area.height;
}
if (bounds.origin.x < work_area.x) {
bounds.origin.x = work_area.x;
} else if (bounds.origin.x + bounds.size.width >=
work_area.x + work_area.width) {
bounds.origin.x = work_area.x + work_area.width - bounds.size.width;
}
if (bounds.origin.y < work_area_y) {
bounds.origin.y = work_area_y;
} else if (bounds.origin.y + bounds.size.height >=
work_area_y + work_area.height) {
bounds.origin.y = work_area_y + work_area.height - bounds.size.height;
}
return bounds;
}
// Get frame and content area rects matching the input DIP screen bounds. The
// resulting window frame will be kept inside the closest display work area. If
// |input_content_bounds| is true the input size is used for the content area
// and the input origin is used for the frame. Otherwise, both input size and
// origin are used for the frame.
void GetNSBoundsInDisplay(const CefRect& dip_bounds,
bool input_content_bounds,
NSWindowStyleMask style_mask,
NSRect& frame_rect,
NSRect& content_rect) {
// Identify the closest display.
auto display =
CefDisplay::GetDisplayMatchingBounds(dip_bounds,
/*input_pixel_coords=*/false);
const auto display_bounds = display->GetBounds();
const auto display_work_area = display->GetWorkArea();
// Convert from DIP coordinates (top-left origin) to macOS coordinates
// (bottom-left origin).
NSRect requested_rect = NSMakeRect(dip_bounds.x, dip_bounds.y,
dip_bounds.width, dip_bounds.height);
requested_rect.origin.y = display_bounds.height - requested_rect.size.height -
requested_rect.origin.y;
// Calculate the equivalent frame and content bounds.
if (input_content_bounds) {
// Compute frame rect from content rect. Keep the requested origin.
content_rect = requested_rect;
frame_rect = [NSWindow frameRectForContentRect:content_rect
styleMask:style_mask];
frame_rect.origin = requested_rect.origin;
} else {
// Compute content rect from frame rect.
frame_rect = requested_rect;
content_rect = [NSWindow contentRectForFrameRect:frame_rect
styleMask:style_mask];
}
// Keep the frame inside the display work area.
const NSRect new_frame_rect =
ClampNSBoundsToWorkArea(frame_rect, display_bounds, display_work_area);
if (!NSEqualRects(frame_rect, new_frame_rect)) {
frame_rect = new_frame_rect;
content_rect = [NSWindow contentRectForFrameRect:frame_rect
styleMask:style_mask];
}
}
} // namespace
@@ -124,7 +238,8 @@ class RootWindowMacImpl
bool with_osr_ = false;
bool with_extension_ = false;
bool is_popup_ = false;
CefRect start_rect_;
CefRect initial_bounds_;
cef_show_state_t initial_show_state_ = CEF_SHOW_STATE_NORMAL;
std::unique_ptr<BrowserWindow> browser_window_;
bool initialized_ = false;
@@ -164,19 +279,26 @@ void RootWindowMacImpl::Init(RootWindow::Delegate* delegate,
with_controls_ = config->with_controls;
with_osr_ = config->with_osr;
with_extension_ = config->with_extension;
start_rect_ = config->bounds;
if (!config->bounds.IsEmpty()) {
// Initial state was specified via the config object.
initial_bounds_ = config->bounds;
initial_show_state_ = config->show_state;
} else {
// Initial state may be specified via the command-line or global
// preferences.
std::optional<CefRect> bounds;
if (prefs::LoadWindowRestorePreferences(initial_show_state_, bounds) &&
bounds) {
initial_bounds_ = *bounds;
}
}
CreateBrowserWindow(config->url);
initialized_ = true;
// Create the native root window on the main thread.
if (CURRENTLY_ON_MAIN_THREAD()) {
CreateRootWindow(settings, config->initially_hidden);
} else {
MAIN_POST_CLOSURE(base::BindOnce(&RootWindowMacImpl::CreateRootWindow, this,
settings, config->initially_hidden));
}
CreateRootWindow(settings, config->initially_hidden);
}
void RootWindowMacImpl::InitAsPopup(RootWindow::Delegate* delegate,
@@ -194,13 +316,13 @@ void RootWindowMacImpl::InitAsPopup(RootWindow::Delegate* delegate,
is_popup_ = true;
if (popupFeatures.xSet)
start_rect_.x = popupFeatures.x;
initial_bounds_.x = popupFeatures.x;
if (popupFeatures.ySet)
start_rect_.y = popupFeatures.y;
initial_bounds_.y = popupFeatures.y;
if (popupFeatures.widthSet)
start_rect_.width = popupFeatures.width;
initial_bounds_.width = popupFeatures.width;
if (popupFeatures.heightSet)
start_rect_.height = popupFeatures.height;
initial_bounds_.height = popupFeatures.height;
CreateBrowserWindow(std::string());
@@ -267,16 +389,13 @@ void RootWindowMacImpl::SetBounds(int x, int y, size_t width, size_t height) {
if (!window_)
return;
// Desired content rectangle.
NSRect content_rect;
content_rect.size.width = static_cast<int>(width);
content_rect.size.height =
static_cast<int>(height) + (with_controls_ ? URLBAR_HEIGHT : 0);
const CefRect dip_bounds(x, y, static_cast<int>(width),
static_cast<int>(height));
// Convert to a frame rectangle.
NSRect frame_rect = [window_ frameRectForContentRect:content_rect];
frame_rect.origin.x = x;
frame_rect.origin.y = TransformY(y) - frame_rect.size.height;
// Calculate the equivalent frame and content area bounds.
NSRect frame_rect, content_rect;
GetNSBoundsInDisplay(dip_bounds, /*input_content_bounds=*/true,
[window_ styleMask], frame_rect, content_rect);
[window_ setFrame:frame_rect display:YES];
}
@@ -356,22 +475,28 @@ void RootWindowMacImpl::CreateRootWindow(const CefBrowserSettings& settings,
// TODO(port): If no x,y position is specified the window will always appear
// in the upper-left corner. Maybe there's a better default place to put it?
const int x = start_rect_.x;
const int y = start_rect_.y;
int width, height;
if (start_rect_.IsEmpty()) {
// TODO(port): Also, maybe there's a better way to choose the default size.
width = 800;
height = 600;
} else {
width = start_rect_.width;
height = start_rect_.height;
}
const int height_with_controls =
with_controls_ ? height + URLBAR_HEIGHT : height;
CefRect dip_bounds = initial_bounds_;
// The window Y coordinate is fixed in the setFrameTopLeftPoint call below
const NSRect content_rect = NSMakeRect(x, y, width, height_with_controls);
// TODO(port): Also, maybe there's a better way to choose the default size.
if (dip_bounds.width <= 0)
dip_bounds.width = 800;
if (dip_bounds.height <= 0)
dip_bounds.height = 600;
// For popups, the requested bounds are for the content area and the requested
// origin is for the window.
if (is_popup_ && with_controls_) {
dip_bounds.height += URLBAR_HEIGHT;
}
const NSWindowStyleMask style_mask =
(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable);
// Calculate the equivalent frame and content area bounds.
NSRect frame_rect, content_rect;
GetNSBoundsInDisplay(dip_bounds, /*input_content_bounds=*/is_popup_,
style_mask, frame_rect, content_rect);
// The CEF framework library is loaded at runtime so we need to use this
// mechanism for retrieving the class.
@@ -379,14 +504,10 @@ void RootWindowMacImpl::CreateRootWindow(const CefBrowserSettings& settings,
CHECK(window_class);
// Create the main window.
window_ = [[window_class alloc]
initWithContentRect:content_rect
styleMask:(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable |
NSWindowStyleMaskResizable |
NSWindowStyleMaskUnifiedTitleAndToolbar)
backing:NSBackingStoreBuffered
defer:NO];
window_ = [[window_class alloc] initWithContentRect:content_rect
styleMask:style_mask
backing:NSBackingStoreBuffered
defer:NO];
[window_ setTitle:@"cefclient"];
// No dark mode, please
window_.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
@@ -395,6 +516,12 @@ void RootWindowMacImpl::CreateRootWindow(const CefBrowserSettings& settings,
window_delegate_ = [[RootWindowDelegate alloc] initWithWindow:window_
andRootWindow:&root_window_];
if (!initial_bounds_.IsEmpty()) {
// Remember the bounds from the previous application run in case the user
// does not move or resize the window during this application run.
window_delegate_.last_visible_bounds = initial_bounds_;
}
// Rely on the window delegate to clean us up rather than immediately
// releasing when the window gets closed. We use the delegate to do
// everything from the autorelease pool so the window isn't on the stack
@@ -426,15 +553,17 @@ void RootWindowMacImpl::CreateRootWindow(const CefBrowserSettings& settings,
}
if (with_controls_) {
// Reduce the browser height by the URL bar height.
contentBounds.size.height -= URLBAR_HEIGHT;
// Create the buttons.
NSRect button_rect = contentBounds;
button_rect.origin.y = height + (URLBAR_HEIGHT - BUTTON_HEIGHT) / 2;
button_rect.origin.y =
contentBounds.size.height + (URLBAR_HEIGHT - BUTTON_HEIGHT) / 2;
button_rect.size.height = BUTTON_HEIGHT;
button_rect.origin.x += BUTTON_MARGIN;
button_rect.size.width = BUTTON_WIDTH;
contentBounds.size.height -= URLBAR_HEIGHT;
back_button_ = MakeButton(&button_rect, @"Back", contentView);
[back_button_ setTarget:window_delegate_];
[back_button_ setAction:@selector(goBack:)];
@@ -470,14 +599,16 @@ void RootWindowMacImpl::CreateRootWindow(const CefBrowserSettings& settings,
[[url_textfield_ cell] setScrollable:YES];
}
// Fix the window Y coordinate
[window_ setFrameTopLeftPoint:NSMakePoint(x, TransformY(y))];
// Place the window at the target point. This is required for proper placement
// if the point is on a secondary display.
[window_ setFrameOrigin:frame_rect.origin];
if (!is_popup_) {
// Create the browser window.
browser_window_->CreateBrowser(
CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(contentView),
CefRect(0, 0, width, height), settings, nullptr,
CefRect(0, 0, contentBounds.size.width, contentBounds.size.height),
settings, nullptr,
root_window_.delegate_->GetRequestContext(&root_window_));
} else {
// With popups we already have a browser window. Parent the browser window
@@ -488,8 +619,15 @@ void RootWindowMacImpl::CreateRootWindow(const CefBrowserSettings& settings,
}
if (!initially_hidden) {
auto mode = RootWindow::ShowNormal;
if (initial_show_state_ == CEF_SHOW_STATE_MAXIMIZED) {
mode = RootWindow::ShowMaximized;
} else if (initial_show_state_ == CEF_SHOW_STATE_MINIMIZED) {
mode = RootWindow::ShowMinimized;
}
// Show the window.
Show(RootWindow::ShowNormal);
Show(mode);
}
}
@@ -735,6 +873,7 @@ void RootWindowMac::OnNativeWindowClosed() {
@implementation RootWindowDelegate
@synthesize root_window = root_window_;
@synthesize last_visible_bounds = last_visible_bounds_;
@synthesize force_close = force_close_;
- (id)initWithWindow:(NSWindow*)window
@@ -837,6 +976,24 @@ void RootWindowMac::OnNativeWindowClosed() {
browser_window->Show();
}
// Called when we have been resized.
- (void)windowDidResize:(NSNotification*)notification {
// Track the last visible bounds for window restore purposes.
const auto dip_bounds = client::GetWindowBoundsInScreen(window_);
if (dip_bounds) {
last_visible_bounds_ = dip_bounds;
}
}
// Called when we have been moved.
- (void)windowDidMove:(NSNotification*)notification {
// Track the last visible bounds for window restore purposes.
const auto dip_bounds = client::GetWindowBoundsInScreen(window_);
if (dip_bounds) {
last_visible_bounds_ = dip_bounds;
}
}
// Called when the application has been hidden.
- (void)applicationDidHide:(NSNotification*)notification {
// If the window is miniaturized then nothing has really changed.
@@ -877,6 +1034,23 @@ void RootWindowMac::OnNativeWindowClosed() {
}
}
// Save window restore position.
std::optional<CefRect> dip_bounds;
cef_show_state_t show_state = CEF_SHOW_STATE_NORMAL;
if ([window_ isMiniaturized]) {
show_state = CEF_SHOW_STATE_MINIMIZED;
} else if ([window_ isZoomed]) {
show_state = CEF_SHOW_STATE_MAXIMIZED;
} else {
dip_bounds = client::GetWindowBoundsInScreen(window_);
}
if (!dip_bounds) {
dip_bounds = last_visible_bounds_;
}
client::prefs::SaveWindowRestorePreferences(show_state, dip_bounds);
// Clean ourselves up after clearing the stack of anything that might have the
// window on it.
[self cleanup];

View File

@@ -11,6 +11,7 @@
#include "include/cef_app.h"
#include "include/wrapper/cef_helpers.h"
#include "tests/cefclient/browser/client_handler_std.h"
#include "tests/cefclient/browser/client_prefs.h"
namespace client {
@@ -37,19 +38,11 @@ void RootWindowViews::Init(RootWindow::Delegate* delegate,
delegate_ = delegate;
config_ = std::move(config);
if (config_->initially_hidden && !config_->source_bounds.IsEmpty()) {
// The window will be sized and positioned in OnAutoResize().
initial_bounds_ = config_->source_bounds;
position_on_resize_ = true;
} else {
initial_bounds_ = config_->bounds;
}
CreateClientHandler(config_->url);
initialized_ = true;
// Continue initialization on the UI thread.
InitOnUIThread(settings, config_->url, delegate_->GetRequestContext(this));
InitOnUIThread(settings, delegate_->GetRequestContext(this));
}
void RootWindowViews::InitAsPopup(RootWindow::Delegate* delegate,
@@ -68,7 +61,6 @@ void RootWindowViews::InitAsPopup(RootWindow::Delegate* delegate,
delegate_ = delegate;
config_ = std::make_unique<RootWindowConfig>();
config_->with_controls = with_controls;
is_popup_ = true;
if (popupFeatures.xSet)
initial_bounds_.x = popupFeatures.x;
@@ -217,11 +209,16 @@ CefRefPtr<CefWindow> RootWindowViews::GetParentWindow() {
return config_->parent_window;
}
CefRect RootWindowViews::GetWindowBounds() {
CefRect RootWindowViews::GetInitialBounds() {
CEF_REQUIRE_UI_THREAD();
return initial_bounds_;
}
cef_show_state_t RootWindowViews::GetInitialShowState() {
CEF_REQUIRE_UI_THREAD();
return initial_show_state_;
}
scoped_refptr<ImageCache> RootWindowViews::GetImageCache() {
CEF_REQUIRE_UI_THREAD();
return image_cache_;
@@ -239,6 +236,17 @@ void RootWindowViews::OnViewsWindowCreated(CefRefPtr<ViewsWindow> window) {
}
}
void RootWindowViews::OnViewsWindowClosing(CefRefPtr<ViewsWindow> window) {
CEF_REQUIRE_UI_THREAD();
DCHECK(window_);
cef_show_state_t show_state;
std::optional<CefRect> dip_bounds;
if (window_->GetWindowRestorePreferences(show_state, dip_bounds)) {
prefs::SaveWindowRestorePreferences(show_state, dip_bounds);
}
}
void RootWindowViews::OnViewsWindowDestroyed(CefRefPtr<ViewsWindow> window) {
CEF_REQUIRE_UI_THREAD();
window_ = nullptr;
@@ -472,15 +480,32 @@ void RootWindowViews::CreateClientHandler(const std::string& url) {
void RootWindowViews::InitOnUIThread(
const CefBrowserSettings& settings,
const std::string& startup_url,
CefRefPtr<CefRequestContext> request_context) {
if (!CefCurrentlyOn(TID_UI)) {
// Execute this method on the UI thread.
CefPostTask(TID_UI, base::BindOnce(&RootWindowViews::InitOnUIThread, this,
settings, startup_url, request_context));
settings, request_context));
return;
}
if (config_->initially_hidden && !config_->source_bounds.IsEmpty()) {
// The window will be sized and positioned in OnAutoResize().
initial_bounds_ = config_->source_bounds;
position_on_resize_ = true;
} else if (!config_->bounds.IsEmpty()) {
// Initial state was specified via the config object.
initial_bounds_ = config_->bounds;
initial_show_state_ = config_->show_state;
} else {
// Initial state may be specified via the command-line or global
// preferences.
std::optional<CefRect> bounds;
if (prefs::LoadWindowRestorePreferences(initial_show_state_, bounds) &&
bounds) {
initial_bounds_ = *bounds;
}
}
image_cache_ = delegate_->GetImageCache();
// Populate the default image cache.
@@ -490,12 +515,11 @@ void RootWindowViews::InitOnUIThread(
image_cache_->LoadImages(
image_set, base::BindOnce(&RootWindowViews::CreateViewsWindow, this,
settings, startup_url, request_context));
settings, request_context));
}
void RootWindowViews::CreateViewsWindow(
const CefBrowserSettings& settings,
const std::string& startup_url,
CefRefPtr<CefRequestContext> request_context,
const ImageCache::ImageSet& images) {
CEF_REQUIRE_UI_THREAD();
@@ -510,7 +534,7 @@ void RootWindowViews::CreateViewsWindow(
#endif
// Create the ViewsWindow. It will show itself after creation.
ViewsWindow::Create(this, client_handler_, startup_url, settings,
ViewsWindow::Create(this, client_handler_, config_->url, settings,
request_context);
}

View File

@@ -54,9 +54,11 @@ class RootWindowViews : public RootWindow,
bool WithExtension() override;
bool InitiallyHidden() override;
CefRefPtr<CefWindow> GetParentWindow() override;
CefRect GetWindowBounds() override;
CefRect GetInitialBounds() override;
cef_show_state_t GetInitialShowState() override;
scoped_refptr<ImageCache> GetImageCache() override;
void OnViewsWindowCreated(CefRefPtr<ViewsWindow> window) override;
void OnViewsWindowClosing(CefRefPtr<ViewsWindow> window) override;
void OnViewsWindowDestroyed(CefRefPtr<ViewsWindow> window) override;
void OnViewsWindowActivated(CefRefPtr<ViewsWindow> window) override;
ViewsWindow::Delegate* GetDelegateForPopup(
@@ -90,10 +92,8 @@ class RootWindowViews : public RootWindow,
void CreateClientHandler(const std::string& url);
void InitOnUIThread(const CefBrowserSettings& settings,
const std::string& startup_url,
CefRefPtr<CefRequestContext> request_context);
void CreateViewsWindow(const CefBrowserSettings& settings,
const std::string& startup_url,
CefRefPtr<CefRequestContext> request_context,
const ImageCache::ImageSet& images);
@@ -101,22 +101,20 @@ class RootWindowViews : public RootWindow,
void NotifyViewsWindowActivated();
void NotifyDestroyedIfDone();
// After initialization all members are only accessed on the main thread
// unless otherwise indicated.
// Members set during initialization.
// Members set during initialization. Safe to access from any thread.
std::unique_ptr<RootWindowConfig> config_;
bool is_popup_ = false;
CefRect initial_bounds_;
bool position_on_resize_ = false;
CefRefPtr<ClientHandler> client_handler_;
bool initialized_ = false;
// Only accessed on the main thread.
CefRefPtr<CefBrowser> browser_;
bool window_destroyed_ = false;
bool browser_destroyed_ = false;
CefRefPtr<CefBrowser> browser_;
// Only accessed on the browser process UI thread.
CefRect initial_bounds_;
cef_show_state_t initial_show_state_ = CEF_SHOW_STATE_NORMAL;
bool position_on_resize_ = false;
CefRefPtr<ViewsWindow> window_;
ExtensionSet pending_extensions_;
scoped_refptr<ImageCache> image_cache_;

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