Compare commits

..

83 Commits
6943 ... master

Author SHA1 Message Date
Marshall Greenblatt
c60d380f39 Fix read of crash reporting env vars 2025-06-03 16:02:44 -04:00
Marshall Greenblatt
31d14c386f Tag 13800 API version 2025-06-03 14:20:59 -04:00
Marshall Greenblatt
f8a746373e Update to Chromium version 138.0.7204.0 (#1465706)
Mac: Require Xcode 16.3 (16E140) and SDK 15.4 (24E241)
2025-06-03 14:20:59 -04:00
Marshall Greenblatt
c5e80eb44a tests: Remove unused version_info argument (see #3935) 2025-06-02 13:38:45 -04:00
Marshall Greenblatt
667e23b91c bootstrap: Support use with older API versions (see #3935) 2025-06-02 13:23:59 -04:00
Tom Crowley
2c411892e2 ceftests: Add tests for PrintToPdf 2025-05-29 16:55:50 +00:00
Pedro de Carvalho Gomes
6bd53b6093 linux: Fix parenting of select widget on Wayland (fixes #3937) 2025-05-29 16:45:12 +00:00
Marshall Greenblatt
b36cb4fe56 bootstrap: Don't explicitly call FreeLibary (see #3935)
This avoids an illegal access during shutdown.
2025-05-29 12:29:37 -04:00
Marshall Greenblatt
9ee8d2c848 bootstrap: Add missing deps for bootstrap-only build (see #3935) 2025-05-29 12:29:37 -04:00
Marshall Greenblatt
794601f128 bootstrap: Pass version to CefScopedLibraryLoader (see #3935)
Strict Chromium version checking is necessary because both sandbox
info and chrome_elf introduce Chromium version dependencies, and we
don't know which non-matching versions are compatible.
2025-05-29 12:29:37 -04:00
Marshall Greenblatt
914a6026b4 bootstrap: Depend on //sandbox directly (see #3935)
This allows us to more accurately duplicate the chrome.exe
sandbox initialization logic.
2025-05-29 12:29:37 -04:00
Marshall Greenblatt
4d65863278 bootstrap: Only show error dialogs with DCHECK_IS_ON (see #3935)
This will enable error dialogs for the Official CEF "Debug" builds.
2025-05-29 12:29:03 -04:00
Marshall Greenblatt
66457acccc bootstrap: Initialize crash reporting (see #3935)
This adds a runtime dependency on chrome_elf.dll and makes all
runtime errors LOG(FATAL) to generate a crash report. Don't wait
for libcef to load before running as the crashpad-handler process.
2025-05-29 12:21:55 -04:00
Marshall Greenblatt
1e8093a910 bootstrap: Load client DLL as untrusted for checks (see #3935) 2025-05-29 12:21:10 -04:00
Marshall Greenblatt
6606e241a1 cefclient: win: Add code signing verification (see #3935)
Move code signing verification code to libcef_dll_wrapper
and add example checks in cefclient.

Load libcef.dll with code signing checks.

Add a CefScopedLibraryLoader variant for Windows.
2025-05-29 12:20:30 -04:00
Marshall Greenblatt
77701dda21 Add cef::logging::ScopedEarlySupport (see #3935)
Supports use of logging macros prior to loading libcef.
2025-05-29 12:19:51 -04:00
Marshall Greenblatt
1244bd34bf libcef: Fix incorrect sandbox init with --no-sandbox
Match the current logic for chrome.exe.
2025-05-29 12:18:25 -04:00
Marshall Greenblatt
85b49df98b cmake: win: Fix cefclient delayload config (see #3824) 2025-05-29 12:18:04 -04:00
Marshall Greenblatt
9a115ea48f Exit early on invalid process type flag (see #3824)
This avoids crashes later during Chromium initialization.
2025-05-20 13:48:48 -04:00
Marshall Greenblatt
ce365d4987 bootstrap: Check code signing certificates (see #3824)
If either the bootstrap executable or the client dll is code signed
then both must be valid (all signatures) and signed with the same
primary certificate. This is a protection against mixing binaries
with different trust levels.
2025-05-20 13:48:48 -04:00
Marshall Greenblatt
4ceedd7f43 patch: Add CEF deps for //components patches (see #3824)
These deps were previously applied to //base via
base_sandbox_2743.patch.
2025-05-19 11:50:33 -04:00
Marshall Greenblatt
d009f6e1ee patch: Remove build.patch (see #3928)
This patch is no longer required after removing cef_sandbox
static linking on macOS.
2025-05-19 11:50:33 -04:00
Marshall Greenblatt
79955317be bazel: mac: Remove cef_sandbox.a linking (see #3928) 2025-05-19 11:50:33 -04:00
Marshall Greenblatt
880e82f45f cmake: mac: Remove cef_sandbox.a linking (see #3928) 2025-05-19 11:50:33 -04:00
Marshall Greenblatt
cfaa10a746 mac: Convert cef_sandbox to a shared library (see #3928)
Replace statically linked cef_sandbox.a with dynamically loaded
libcef_sandbox.dylib. See the SandboxSetup Wiki page for details.
2025-05-19 11:50:33 -04:00
Marshall Greenblatt
353b6fb138 build: Remove GN arg is_cef_sandbox_build (see #3824)
This argument is no longer used after removing cef_sandbox patches.
2025-05-19 11:50:33 -04:00
Marshall Greenblatt
992b9d3435 patch: Remove sandbox-related //base patches (see #3824)
The //base target is only used by cef_sandbox on Windows (not macOS).
2025-05-19 11:50:32 -04:00
Marshall Greenblatt
6a97b82ffc distrib: win: Repurpose sandbox distrib for bootstrap executables (see #3824) 2025-05-19 11:50:32 -04:00
Marshall Greenblatt
dadfe2c8dc bazel: win: Remove cef_sandbox.lib linking (see #3824)
Support for bootstrap executables will be added later.
2025-05-19 11:50:32 -04:00
Marshall Greenblatt
572c44bc2e cmake: win: Remove cef_sandbox.lib linking (see #3824)
- Repurpose USE_SANDBOX config to enable the bootstrap.
- Build appname.dll instead of appname.exe.
- Copy bootstrap[c].exe to appname.exe as a post-build step.
2025-05-19 11:50:32 -04:00
Marshall Greenblatt
c302f285c7 patch: Remove Windows-only cef_sandbox patches (see #3824) 2025-05-16 17:43:11 -04:00
Marshall Greenblatt
adcac2c37c win: Add bootstrap[c].exe for sandbox integration (see #3824)
Replace cef_sandbox.lib usage with bootstrap executables.
See the SandboxSetup Wiki page for details.
2025-05-16 17:32:34 -04:00
Marshall Greenblatt
7581264dbb tools: Don't print git errors with fix_style 2025-05-14 13:09:37 -04:00
Marshall Greenblatt
fbb54374d4 distrib: Add --no-format option for faster testing 2025-05-14 13:09:27 -04:00
Marshall Greenblatt
4060fb9c22 bazel: Remove support for angle bracket includes
Fixes the following error:

fail: attribute includes: './' resolves to the workspace root,
which would allow this rule and all of its transitive dependents
to include any file in your workspace. Please include only what
you need.

Bazel's recommendation [1] is to use double quotes instead of
angle brackets.

[1] https://bazel.build/docs/bazel-and-cpp#include-paths
2025-05-13 18:51:20 -04:00
Marshall Greenblatt
4634b6f0d5 win: Fix crash loading chrome://sandbox when sandbox is disabled 2025-05-13 18:51:10 -04:00
Marshall Greenblatt
9051920b44 osr: linux: Fix crash with default JS modal dialogs (fixes #3921) 2025-05-07 16:10:22 -04:00
Marshall Greenblatt
ad4fa9cf24 Tag 13700 API version 2025-05-07 13:25:44 -04:00
Marshall Greenblatt
8b09ea4324 vscode: Fix cwd for clicking file paths in task output 2025-05-06 17:09:21 -04:00
Marshall Greenblatt
a16513512e docs: Fix incorrect function name (fixes #3923) 2025-05-06 17:09:21 -04:00
Marshall Greenblatt
7944038baf Update to Chromium version 137.0.7151.0 (#1453031) 2025-05-06 17:09:21 -04:00
Marshall Greenblatt
faa85bf980 Support JavaScript window.moveTo/By() and resizeTo/By() (fixes #698)
Adds new CefDisplayHandler::OnContentsBoundsChange and
CefDisplayHandler::GetRootWindowScreenRect callbacks.

cefclient: Implement the above callbacks and call
CefBrowserHost::NotifyScreenInfoChanged when the root window
bounds change.

cefclient: osr: Use real screen bounds by default. Pass
`--fake-screen-bounds` for the old default behavior.

Load https://tests/window in cefclient for additional
implementation details and usage examples.
2025-05-05 11:53:33 -04:00
Marshall Greenblatt
f59112d839 Tag 13601 API version 2025-04-22 10:23:52 -04:00
Marshall Greenblatt
d5339f1f2a Fix enum value typos 2025-04-22 10:22:49 -04:00
Marshall Greenblatt
77f2451a5e Add callback to allow Document PiP moveTo/By() (fixes #3714)
Allow Document picture-in-picture moveTo/By() and resizeTo/By()
(without user gesture) if the new
CefBrowserViewDelegate::AllowMoveForPictureInPicture callback
returns true.
2025-04-22 14:05:23 +00:00
Marshall Greenblatt
d746017d7c Tag 13600 API version 2025-04-07 17:42:26 -04:00
Marshall Greenblatt
06288b535e osr: Avoid crash in WebContentsImpl::GetSize/Resize 2025-04-07 17:11:48 -04:00
Marshall Greenblatt
c0df792f3b vscode: Fix error running build tasks
Running tasks without explicit "cwd" broke in VSCode 1.99.0.
2025-04-07 15:38:21 -04:00
Marshall Greenblatt
68b0feea6d Fix dangling menu observer on browser destruction 2025-04-07 15:38:21 -04:00
Marshall Greenblatt
e7320793b6 Update to Chromium version 136.0.7103.0 (#1440670)
- Win: Update to VS 2022 17.13.4 and WinSDK 10.0.26100.3323
2025-04-07 15:38:21 -04:00
Marshall Greenblatt
ef82e430b4 alloy: Fix display of modal JS dialogs (fixes #3818) 2025-04-02 14:25:45 -04:00
Marshall Greenblatt
70ea6f589f Fix allow_os_execution=true (fixes #2715, fixes #3851, fixes #3889)
When setting allow_os_execution=true in OnProtocolExecution the
confirmation dialog should display consistently, the load should
be canceled with ERR_ABORTED, and no interstitial error page
should be displayed.
2025-04-01 18:08:25 -04:00
Marshall Greenblatt
5b18ca7d3f linux: Fix stack-related sub-process shutdown crashes (fixes #3912)
On Linux systems the stack frame reference canary will be purposely
changed when forking sub-processes (see https://crbug.com/40181003).
To avoid sub-process shutdown crashes the NO_STACK_PROTECTOR
annotation must be added to all functions in the call stack leading to
CefExecuteProcess(). Applications that cannot add this annotation must
instead pass the `--change-stack-guard-on-fork=disable` command-line
flag.
2025-03-31 14:13:24 -04:00
Marshall Greenblatt
b2f5ab6cd2 Fix crash on invalid chromeMediaSourceId (fixes #3911) 2025-03-31 12:11:33 -04:00
Marshall Greenblatt
0bf995ae26 win: alloy: Fix potential crash if browser creation is aborted (fixes #3862) 2025-03-21 14:31:02 -04:00
Marshall Greenblatt
49ac6882ec chrome: Implement CefBrowserHost::SetAudioMuted/IsAudioMuted (fixes #3893) 2025-03-21 13:17:33 -04:00
Marshall Greenblatt
8cf30843f9 chrome: Implement CefFocusHandler::OnTakeFocus callback (fixes #3897) 2025-03-21 13:03:53 -04:00
Marshall Greenblatt
e88e98f061 tools: Add VSCode setup (fixes #3906)
Add tooling to set up a Visual Studio Code development environment
for CEF. See script output for usage.

Run: python3 tools/setup_vscode.py
2025-03-20 13:53:33 -04:00
Marshall Greenblatt
8fa5244adb distrib: Include CREDITS.html with third-party licenses
This is the same content currently available via about:credits.
2025-03-19 13:57:51 -04:00
Michael Bragg
aa4734b714 alloy: win: Add spelling suggestions in context menu (fixes #3055) 2025-03-18 12:08:47 -04:00
David Cernoch
f72afb713a Make PrintToPDF path parameter optional (fixes #3879) 2025-03-18 15:44:00 +00:00
Marshall Greenblatt
8db54e92c2 Tag 13500 API version 2025-03-12 14:37:45 -04:00
Marshall Greenblatt
00b4581c9b tests: Destroy |scheme_factory_| on IO thread
This avoids a thread race between ShutdownSchemeHandler and
GetResourceHandler when running `CookieTest.AccessResource*` tests.
2025-03-12 13:40:39 -04:00
Marshall Greenblatt
ff5210f825 Update to Chromium version 135.0.7049.0 (#1427262) 2025-03-12 13:05:48 -04:00
Marshall Greenblatt
cda47aaff4 Tag 13401 API version 2025-03-10 11:53:36 -04:00
Marshall Greenblatt
549e8fe05c Add visualization for Chrome configuration changes (fixes #3892)
- Add new API to retrieve/observe configuration values.
- cefclient: Add https://tests/config to inspect configuration
  values in real time.
2025-03-10 15:50:46 +00:00
Marshall Greenblatt
ec31b2b505 Fix Chrome toolbar initialization (fixes #3898)
Change BrowserWindowFeatures initialization to consider CEF browsers
with TYPE_POPUP as normal.
2025-03-07 14:56:20 -05:00
Marshall Greenblatt
40fef43488 tools: Fix assert when all file contents are excluded (see #3836)
The full contents of a file may be excluded at certain API versions.
2025-03-07 11:59:43 -05:00
Jacobo Aragunde Pérez
e44a93551f tools: Add non-zero exit code for single patch failure (fixes #3903) 2025-03-07 15:46:05 +00:00
Marshall Greenblatt
18b65ced23 tools: Also check for CEF_NEXT in .cc files (see #3836) 2025-02-28 18:22:33 -05:00
Marshall Greenblatt
9c7b6e77a5 tools: Use short copyright for capi_versions.h headers (see #3836)
These files are not distributed and therefore don't require the
full copyright header.
2025-02-28 18:22:33 -05:00
Marshall Greenblatt
781d2b5996 tools: Fix get_all_versions for newly added class (see #3836) 2025-02-28 18:22:33 -05:00
Marshall Greenblatt
0573906f6d cefclient: Add global option to https://tests/preferences (see #3892) 2025-02-28 18:21:55 -05:00
Nik Pavlov
fdd36e8461 Support API versioning in platform-specific headers (see #3836)
- Exclude platform-specific includes (anything in < >) from the
  clang preprocessor by using `!defined(GENERATING_CEF_API_HASH)`
  in CEF header files.
- Define "target platforms" by passing platform- and architecture-
  specific ifdefs to the clang preprocessor. Grep for `defined(OS_`
  to identify headers that require target platform processing, and
  then process for each target as the platform-specific API hash
  contribution.
- Delete the univeral hash which is no longer a useful concept.
2025-02-25 12:36:00 -05:00
Marshall Greenblatt
8ddb1bffbb cmake: win: Set LPAC ACLs required for sandbox support (fixes #3791) 2025-02-19 13:38:22 -05:00
Marshall Greenblatt
bfd1110145 tools: win: Use system installed Git version
Chromium has stopped bundling Git with depot_tools on Windows.
See https://groups.google.com/a/chromium.org/g/chromium-dev/c/e4ftLlQ5GpE/m/ye0ezOLaAAAJ
2025-02-19 12:27:47 -05:00
Marshall Greenblatt
81d54830e9 Tag 13400 API version 2025-02-19 12:06:11 -05:00
Marshall Greenblatt
0c25276083 tools: win: Fix grep usage with system Git (see #3836) 2025-02-19 12:05:35 -05:00
Marshall Greenblatt
64bb2aadd5 tools: Add null check for struct ptrs in CToCpp wrapper (see #3836) 2025-02-19 11:11:51 -05:00
Marshall Greenblatt
4261816c34 views: Always remove Toolbar before BrowserView destruction 2025-02-19 11:11:51 -05:00
Marshall Greenblatt
c7c6a109c9 Update to Chromium version 134.0.6998.0 (#1415337) 2025-02-19 11:11:51 -05:00
Marshall Greenblatt
c8be96d15c Minor types cleanup for API gen (see #3836) 2025-02-19 11:11:51 -05:00
Peng Zhou
e902b1f226 mac: Add -isysroot flag to clang command (see #3836) 2025-02-14 19:57:05 +00:00
330 changed files with 11207 additions and 4468 deletions

347
BUILD.gn
View File

@@ -319,6 +319,16 @@ group("cef") {
":libcef_static_unittests",
]
if (is_win) {
deps += [
":bootstrap",
":bootstrapc",
":cefclient_dll",
":cefsimple_dll",
":ceftests_dll",
]
}
if (!is_linux || ozone_platform_x11) {
deps += [ ":cefclient" ]
}
@@ -340,7 +350,7 @@ if (is_win) {
# to maintain.
"//chrome/common/crash_keys.cc",
"//chrome/common/chrome_switches.cc",
"//components/flags_ui/flags_ui_switches.cc",
"//components/webui/flags/flags_ui_switches.cc",
"//content/public/common/content_switches.cc",
]
@@ -373,6 +383,10 @@ if (is_win) {
# Required by content_switches.cc
"//media:media_buildflags",
# Required by crash_keys.cc
"//content/public/common:buildflags",
"//tools/v8_context_snapshot:buildflags",
# Required by crash_keys.cc (from base/stl_util.h)
"//third_party/abseil-cpp:absl",
]
@@ -548,6 +562,8 @@ source_set("libcef_static") {
"libcef/browser/context.h",
"libcef/browser/context_menu_params_impl.cc",
"libcef/browser/context_menu_params_impl.h",
"libcef/browser/crashpad_runner.cc",
"libcef/browser/crashpad_runner.h",
"libcef/browser/devtools/devtools_controller.cc",
"libcef/browser/devtools/devtools_controller.h",
"libcef/browser/devtools/devtools_protocol_manager.cc",
@@ -677,6 +693,8 @@ source_set("libcef_static") {
"libcef/browser/scheme_impl.cc",
"libcef/browser/server_impl.cc",
"libcef/browser/server_impl.h",
"libcef/browser/setting_helper.cc",
"libcef/browser/setting_helper.h",
"libcef/browser/simple_menu_model_impl.cc",
"libcef/browser/simple_menu_model_impl.h",
"libcef/browser/ssl_info_impl.cc",
@@ -837,6 +855,7 @@ source_set("libcef_static") {
"libcef/common/values_impl.h",
"libcef/common/waitable_event_impl.cc",
"libcef/common/waitable_event_impl.h",
"libcef/renderer/browser_config.h",
"libcef/renderer/browser_impl.cc",
"libcef/renderer/browser_impl.h",
"libcef/renderer/chrome/chrome_content_renderer_client_cef.cc",
@@ -989,6 +1008,9 @@ source_set("libcef_static") {
"libcef/browser/native/browser_platform_delegate_native_win.h",
"libcef/browser/osr/browser_platform_delegate_osr_win.cc",
"libcef/browser/osr/browser_platform_delegate_osr_win.h",
"libcef/browser/preferred_stack_size_win.inc",
"libcef_dll/bootstrap/bootstrap_util_win.cc",
"libcef_dll/bootstrap/bootstrap_util_win.h",
]
deps += [
@@ -1153,6 +1175,9 @@ config("libcef_dll_wrapper_config") {
# Increase the initial stack size to 8MiB from the default 1MiB.
ldflags = [ "/STACK:0x800000" ]
}
# Required to support CefScopedLibraryLoader.
ldflags += [ "/DELAYLOAD:libcef.dll" ]
}
# Build using the minimum C++ version supported by the CEF binary distribution.
@@ -1188,6 +1213,14 @@ static_library("libcef_dll_wrapper") {
sources += gypi_paths2.libcef_dll_wrapper_sources_mac
}
if (is_win) {
sources += gypi_paths2.libcef_dll_wrapper_sources_win
libs = [
"crypt32.lib",
"wintrust.lib",
]
}
defines = [ "WRAPPING_CEF_SHARED" ]
configs += [ ":libcef_dll_wrapper_config" ]
@@ -1207,14 +1240,13 @@ if (is_win) {
configs += [ ":libcef_includes_config" ]
deps = [
":make_config_header",
"libcef/features:buildflags",
"//sandbox",
]
}
}
if (is_mac) {
static_library("cef_sandbox") {
shared_library("cef_sandbox") {
sources = [ "libcef_dll/sandbox/sandbox_mac.mm" ]
configs += [ ":libcef_includes_config" ]
deps = [
@@ -1225,6 +1257,97 @@ if (is_mac) {
}
}
#
# bootstrap target.
#
if (is_win) {
bootstrap_sources = includes_common +
includes_win + [
"include/wrapper/cef_certificate_util_win.h",
"include/wrapper/cef_util_win.h",
"libcef_dll/bootstrap/bootstrap_util_win.cc",
"libcef_dll/bootstrap/bootstrap_util_win.h",
"libcef_dll/bootstrap/bootstrap_win.cc",
"libcef_dll/bootstrap/win/bootstrap.rc",
"libcef_dll/bootstrap/win/resource.h",
"libcef_dll/wrapper/cef_certificate_util_win.cc",
"libcef_dll/wrapper/cef_util_win.cc",
"libcef/browser/crashpad_runner.cc",
"libcef/browser/crashpad_runner.h",
"libcef/browser/preferred_stack_size_win.inc",
"//chrome/app/delay_load_failure_hook_win.cc",
"//chrome/app/delay_load_failure_hook_win.h",
"//chrome/common/win/delay_load_failure_support.cc",
"//chrome/common/win/delay_load_failure_support.h",
"//content/app/sandbox_helper_win.cc",
"//content/public/app/sandbox_helper_win.h",
]
bootstrap_deps = [
":make_api_versions_header",
":make_config_header",
":make_version_header",
"//base",
"//build/win:default_exe_manifest",
"//chrome/install_static:secondary_module",
"//chrome/chrome_elf",
"//sandbox",
"//sandbox/policy",
"//third_party/crashpad/crashpad/handler",
]
bootstrap_libs = [
"crypt32.lib",
"wintrust.lib",
]
bootstrap_configs = [
":libcef_includes_config",
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.
"//build/config/win:delayloads",
"//build/config/win:delayloads_not_for_child_dll",
]
# Windows application that initializes the sandbox and then passes
# execution to a client-provided DLL.
executable("bootstrap") {
# Necessary because the libcef target is testonly.
testonly = true
sources = bootstrap_sources
deps = bootstrap_deps
libs = bootstrap_libs
configs += bootstrap_configs
# Set /SUBSYSTEM:WINDOWS.
configs -= [ "//build/config/win:console" ]
configs += [ "//build/config/win:windowed" ]
defines = [
"CEF_BUILD_BOOTSTRAP",
]
}
# Like "bootstrap", but as a console application.
executable("bootstrapc") {
# Necessary because the libcef target is testonly.
testonly = true
sources = bootstrap_sources
deps = bootstrap_deps
libs = bootstrap_libs
configs += bootstrap_configs
defines = [
"CEF_BUILD_BOOTSTRAP",
"CEF_BUILD_BOOTSTRAP_CONSOLE",
]
}
}
#
# Resource grit/pack targets.
#
@@ -1284,7 +1407,6 @@ make_pack_header("resources") {
"$root_gen_dir/chrome/grit/browser_resources.h",
"$root_gen_dir/chrome/grit/common_resources.h",
"$root_gen_dir/chrome/grit/component_extension_resources.h",
"$root_gen_dir/chrome/grit/dev_ui_browser_resources.h",
"$root_gen_dir/chrome/grit/pdf_resources.h",
"$root_gen_dir/chrome/grit/renderer_resources.h",
"$root_gen_dir/components/grit/components_resources.h",
@@ -1312,7 +1434,6 @@ make_pack_header("resources") {
deps = [
":cef_resources",
"//base/tracing/protos:chrome_track_event_resources",
"//chrome/browser:dev_ui_browser_resources",
"//chrome/browser:resources",
"//chrome/browser/resources:component_extension_resources",
"//chrome/browser/resources/pdf:resources",
@@ -1540,17 +1661,46 @@ if (is_mac) {
]
}
# Add the ANGLE .dylibs in the MODULE_DIR of the Framework app bundle.
bundle_data("cef_framework_angle_binaries") {
if (!use_static_angle) {
# Add the ANGLE .dylibs in the MODULE_DIR of the Framework app bundle.
bundle_data("cef_framework_angle_binaries") {
sources = [
"$root_out_dir/egl_intermediates/libEGL.dylib",
"$root_out_dir/egl_intermediates/libGLESv2.dylib",
]
outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
]
public_deps = [
"//ui/gl:angle_library_copy",
]
}
}
# We need to copy the CEF libraries so that the bundle_data dependencies have
# a "copy" target type. Otherwise for "shared_library" target types it will
# try to link things into the CEF Framework when we want to keep the libraries
# separate instead.
copy("cef_library_copy") {
sources = [
"$root_out_dir/egl_intermediates/libEGL.dylib",
"$root_out_dir/egl_intermediates/libGLESv2.dylib",
"$root_out_dir/libcef_sandbox.dylib",
]
outputs = [ "$root_out_dir/cef_intermediates/{{source_file_part}}" ]
deps = [
":cef_sandbox",
]
}
# Add the CEF .dylibs in the MODULE_DIR of the Framework app bundle.
bundle_data("cef_framework_cef_binaries") {
sources = [
"$root_out_dir/cef_intermediates/libcef_sandbox.dylib",
]
outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
]
public_deps = [
"//ui/gl:angle_library_copy",
":cef_library_copy",
]
}
@@ -1583,11 +1733,15 @@ if (is_mac) {
sources = libcef_sources_common + includes_mac
deps = libcef_deps_common + [
":cef_framework_angle_binaries",
":cef_framework_cef_binaries",
":cef_framework_resources",
":cef_framework_swiftshader_binaries",
]
if (!use_static_angle) {
deps += [ ":cef_framework_angle_binaries" ]
}
configs += [
":libcef_autogen_config",
":libcef_includes_config",
@@ -1652,7 +1806,8 @@ if (is_mac) {
]
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.
# improvements. Don't use "delayloads_not_for_child_dll" here because
# we need some DLLs loaded in child processes before sandbox lockdown.
configs += [ "//build/config/win:delayloads" ]
libs = [
@@ -1748,7 +1903,6 @@ if (is_mac) {
deps = [
":cef_make_headers",
":cef_sandbox",
":libcef_dll_wrapper",
]
if (defined(invoker.helper_deps)) {
@@ -2149,6 +2303,7 @@ if (is_mac) {
if (is_win) {
sources += includes_win +
gypi_paths2.includes_wrapper_win +
gypi_paths2.shared_sources_win +
gypi_paths2.cefclient_sources_win +
gypi_paths2.cefclient_sources_resources_win_rc
@@ -2159,7 +2314,10 @@ if (is_mac) {
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.
configs += [ "//build/config/win:delayloads" ]
configs += [
"//build/config/win:delayloads",
"//build/config/win:delayloads_not_for_child_dll",
]
defines += [
"CEF_USE_ATL",
@@ -2223,6 +2381,70 @@ if (is_mac) {
}
}
if (is_win) {
# Like the "cefclient" executable target, but building a DLL to be loaded by
# bootstrap.exe.
shared_library("cefclient_dll") {
# Necessary because the libcef target is testonly.
testonly = true
output_name = "cefclient"
sources = includes_common +
includes_win +
gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_win +
gypi_paths2.shared_sources_browser +
gypi_paths2.shared_sources_common +
gypi_paths2.shared_sources_renderer +
gypi_paths2.shared_sources_win +
gypi_paths2.cefclient_sources_browser +
gypi_paths2.cefclient_sources_common +
gypi_paths2.cefclient_sources_renderer +
gypi_paths2.cefclient_sources_win +
gypi_paths2.cefclient_sources_resources_win_rc
deps = [
":bootstrap",
":libcef",
":libcef_dll_wrapper",
]
defines = [
"CEF_USE_ATL",
"CEF_USE_BOOTSTRAP",
]
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.
configs += [
"//build/config/win:delayloads",
"//build/config/win:delayloads_not_for_child_dll",
]
libs = [
"comctl32.lib",
"d3d11.lib",
"imm32.lib",
"oleacc.lib",
"rpcrt4.lib",
"shlwapi.lib",
]
if (target_cpu != "arm64") {
libs += [
"glu32.lib",
"opengl32.lib",
]
ldflags = [
"/DELAYLOAD:glu32.dll",
"/DELAYLOAD:oleaut32.dll",
"/DELAYLOAD:opengl32.dll",
]
}
}
}
#
# cefsimple targets.
@@ -2247,6 +2469,7 @@ if (is_mac) {
if (is_win) {
sources += includes_win +
gypi_paths2.includes_wrapper_win +
gypi_paths2.cefsimple_sources_win +
gypi_paths2.cefsimple_sources_resources_win_rc
@@ -2256,7 +2479,10 @@ if (is_mac) {
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.
configs += [ "//build/config/win:delayloads" ]
configs += [
"//build/config/win:delayloads",
"//build/config/win:delayloads_not_for_child_dll",
]
deps += [
":cef_sandbox",
@@ -2287,6 +2513,48 @@ if (is_mac) {
}
}
if (is_win) {
# Like the "cefsimple" executable target, but building a DLL to be loaded by
# bootstrap.exe.
shared_library("cefsimple_dll") {
# Necessary because the libcef target is testonly.
testonly = true
output_name = "cefsimple"
sources = includes_common +
includes_win +
gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_win +
gypi_paths2.cefsimple_sources_common +
gypi_paths2.cefsimple_sources_win +
gypi_paths2.cefsimple_sources_resources_win_rc
deps = [
":bootstrap",
":libcef",
":libcef_dll_wrapper",
]
defines = [
"CEF_USE_BOOTSTRAP",
]
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.
configs += [
"//build/config/win:delayloads",
"//build/config/win:delayloads_not_for_child_dll",
]
libs = [
"comctl32.lib",
"shlwapi.lib",
"rpcrt4.lib",
]
}
}
#
# ceftests targets.
@@ -2322,13 +2590,17 @@ if (is_mac) {
]
if (is_win) {
sources += gypi_paths2.shared_sources_win +
sources += gypi_paths2.includes_wrapper_win +
gypi_paths2.shared_sources_win +
gypi_paths2.ceftests_sources_win +
gypi_paths2.ceftests_sources_resources_win_rc
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.
configs += [ "//build/config/win:delayloads" ]
configs += [
"//build/config/win:delayloads",
"//build/config/win:delayloads_not_for_child_dll",
]
deps += [
":cef_sandbox",
@@ -2360,4 +2632,45 @@ if (is_mac) {
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
}
if (is_win) {
# Like the "ceftests" executable target, but building a DLL to be loaded by
# bootstrapc.exe.
shared_library("ceftests_dll") {
testonly = true
output_name = "ceftests"
sources = includes_common +
gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_win +
gypi_paths2.shared_sources_browser +
gypi_paths2.shared_sources_common +
gypi_paths2.shared_sources_renderer +
gypi_paths2.shared_sources_win +
gypi_paths2.ceftests_sources_common +
gypi_paths2.ceftests_sources_win +
gypi_paths2.ceftests_sources_resources_win_rc
deps = [
":bootstrapc",
":libcef",
":libcef_dll_wrapper",
":gtest_teamcity",
"//testing/gtest",
]
defines = [
"CEF_USE_BOOTSTRAP",
"CEF_TESTS_IN_SRC_DIRECTORY",
]
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.
configs += [
"//build/config/win:delayloads",
"//build/config/win:delayloads_not_for_child_dll",
]
}
}
}

View File

@@ -7,6 +7,5 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/133.0.6943.142',
'depot_tools_checkout': '9dc0551d52'
'chromium_checkout': 'refs/tags/138.0.7204.0'
}

View File

@@ -43,9 +43,7 @@ def _declare_helper_app(name, info_plist, deps, helper_base_name, helper_suffix,
bundle_id = "{}.{}.helper{}".format(MACOS_BUNDLE_ID_BASE, name.lower(), bundle_id_suffix),
infoplists = [":{}_InfoPList".format(helper_base_name)],
minimum_os_version = MACOS_DEPLOYMENT_TARGET,
deps = [
"@cef//:cef_sandbox",
] + deps,
deps = deps,
**kwargs,
)

View File

@@ -47,7 +47,6 @@ def declare_exe(name, srcs, manifest_srcs, rc_file, resources_srcs, resources_de
srcs = srcs,
deps = [
"@cef//:cef_wrapper",
"@cef//:cef_sandbox",
] + deps,
linkopts = [
"$(location @cef//:cef_lib)",

View File

@@ -32,9 +32,13 @@ DLLS_X64 = [
# processes. Conversely, some DLLs must be loaded before sandbox lockdown. In
# unsandboxed processes they will load when first needed. The linker will
# automatically ignore anything which is not linked to the binary at all (it is
# harmless to have an unmatched /delayload). This list should be kept in sync
# with Chromium's "delayloads" target from the //build/config/win/BUILD.gn file.
# harmless to have an unmatched /delayload). Lists should be kept in sync with
# targets from Chromium's //build/config/win/BUILD.gn file.
DELAYLOAD_DLLS = [
# Required to support CefScopedLibraryLoader.
"libcef.dll"
# "delayloads" target.
"api-ms-win-core-winrt-error-l1-1-0.dll",
"api-ms-win-core-winrt-l1-1-0.dll",
"api-ms-win-core-winrt-string-l1-1-0.dll",
@@ -76,38 +80,36 @@ DELAYLOAD_DLLS = [
"winusb.dll",
"wsock32.dll",
"wtsapi32.dll",
# "delayloads_not_for_child_dll" target.
"crypt32.dll",
"dbghelp.dll",
"dhcpcsvc.dll",
"dwrite.dll",
"iphlpapi.dll",
"oleaut32.dll",
"secur32.dll",
"userenv.dll",
"winhttp.dll",
"winmm.dll",
"winspool.drv",
"wintrust.dll",
"ws2_32.dll",
]
# Standard link libraries.
STANDARD_LIBS = [
"comctl32.lib",
"crypt32.lib",
"delayimp.lib",
"gdi32.lib",
"rpcrt4.lib",
"shlwapi.lib",
"user32.lib",
"wintrust.lib",
"ws2_32.lib",
]
# Sandbox link libraries.
SANDBOX_LIBS = [
"Advapi32.lib",
"dbghelp.lib",
"Delayimp.lib",
"ntdll.lib",
"OleAut32.lib",
"PowrProf.lib",
"Propsys.lib",
"psapi.lib",
"SetupAPI.lib",
"Shcore.lib",
"Shell32.lib",
"Userenv.lib",
"version.lib",
"wbemuuid.lib",
"WindowsApp.lib",
"winmm.lib",
]
COMMON_LINKOPTS_DEBUG = [
]
@@ -178,18 +180,9 @@ COMMON_DEFINES = [
"WIN32_LEAN_AND_MEAN",
# Disable exceptions
"_HAS_EXCEPTIONS=0",
# Required by cef_sandbox.lib
"PSAPI_VERSION=1",
# Used by apps to test if the sandbox is enabled
"CEF_USE_SANDBOX",
]
COMMON_DEFINES_DEBUG = [
# Required by cef_sandbox.lib
# Disable iterator debugging
"HAS_ITERATOR_DEBUGGING=0",
"_ITERATOR_DEBUG_LEVEL=0",
]
COMMON_DEFINES_RELEASE = [

View File

@@ -29,8 +29,50 @@
"linux": "f1ababb4ff51ecbf77c481cee3721ef0eca9c8ca",
"mac": "98964c37b8917d83da4b173e22905503d38ad08f",
"windows": "19c014af0082aa901398e006381b6980e4f806e9"
},
"13400": {
"comment": "Added February 21, 2025.",
"linux": "ea2106b5bc012c25d735521e0c7fb719d433ea4a",
"mac": "ba5ab71db4f9447f19eb7b1943024981c88064dd",
"windows": "6ab74b90e88b7397aab9911baac5484f12466eef"
},
"13401": {
"comment": "Added March 10, 2025.",
"linux": "b14bee2c0fd250da67faea421f620b58e5dea9a2",
"mac": "b54732b528bc2669481ec0cf17c7b97b033720b9",
"windows": "751255204f006b8b883a8baf552a2da792f8aa44"
},
"13500": {
"comment": "Added March 12, 2025.",
"linux": "5b7c2284ed2542cf6212981d62ca9122fb2a4e88",
"mac": "9862177631e8059a497d6086058168dd47477ab7",
"windows": "3e78b6fe5fd31d69049499450849ada17a720a53"
},
"13600": {
"comment": "Added April 07, 2025.",
"linux": "eb353ba7b8b9bcbef890217971cd8ec41efeaa75",
"mac": "22c77d1f2305de8a6147f14e52f074b4a4e5222c",
"windows": "a8832519b4eb058567d68b65be1e1c9e80aae566"
},
"13601": {
"comment": "Added April 22, 2025.",
"linux": "40b224f295a20694241c5db49721bc90a3796f30",
"mac": "ff885fe921f9eae1a5ce6a71b30b0c37b306bf56",
"windows": "116a4153047ee1ee67f17fc938f084ee72b24e54"
},
"13700": {
"comment": "Added May 07, 2025.",
"linux": "e5ac12b1bd88b9ece6ceaa57848aaba61ab85242",
"mac": "9e84009c92c25aa80935727b5e4526b23439a575",
"windows": "65c7157dd3e8eba9bcc38db2bd7f26508c717f3e"
},
"13800": {
"comment": "Added June 02, 2025.",
"linux": "72c83a1455706c0f964505a6edcbf00c4a00575d",
"mac": "09110c1f3bbe0e8a8c26ddf6df3388d73a6593d1",
"windows": "1cde3ec27f93747ba42c0f2aa00467a5a16adfd4"
}
},
"last": "13304",
"last": "13800",
"min": "13300"
}

View File

@@ -17,6 +17,7 @@
'include/base/cef_cancelable_callback.h',
'include/base/cef_compiler_specific.h',
'include/base/cef_dump_without_crashing.h',
'include/base/cef_immediate_crash.h',
'include/base/cef_lock.h',
'include/base/cef_logging.h',
'include/base/cef_macros.h',
@@ -79,6 +80,11 @@
'includes_wrapper_mac': [
'include/wrapper/cef_library_loader.h',
],
'includes_wrapper_win': [
'include/wrapper/cef_certificate_util_win.h',
'include/wrapper/cef_library_loader.h',
'include/wrapper/cef_util_win.h',
],
'includes_win': [
'include/cef_sandbox_win.h',
'include/internal/cef_win.h',
@@ -165,9 +171,15 @@
'libcef_dll/wrapper/libcef_dll_wrapper2.cc',
],
'libcef_dll_wrapper_sources_mac': [
'libcef_dll/wrapper/cef_library_loader_mac.mm',
'libcef_dll/wrapper/cef_scoped_library_loader_mac.mm',
'libcef_dll/wrapper/cef_scoped_sandbox_context_mac.mm',
'libcef_dll/wrapper/libcef_dll_dylib.cc',
],
'libcef_dll_wrapper_sources_win': [
'libcef_dll/wrapper/cef_certificate_util_win.cc',
'libcef_dll/wrapper/cef_scoped_library_loader_win.cc',
'libcef_dll/wrapper/cef_util_win.cc',
],
'shared_sources_browser': [
'tests/shared/browser/client_app_browser.cc',
'tests/shared/browser/client_app_browser.h',
@@ -247,6 +259,8 @@
'tests/cefclient/browser/client_prefs.cc',
'tests/cefclient/browser/client_prefs.h',
'tests/cefclient/browser/client_types.h',
'tests/cefclient/browser/config_test.cc',
'tests/cefclient/browser/config_test.h',
'tests/cefclient/browser/default_client_handler.cc',
'tests/cefclient/browser/default_client_handler.h',
'tests/cefclient/browser/dialog_test.cc',
@@ -324,6 +338,7 @@
'cefclient_sources_resources': [
'tests/cefclient/resources/binary_transfer.html',
'tests/cefclient/resources/binding.html',
'tests/cefclient/resources/config.html',
'tests/cefclient/resources/dialogs.html',
'tests/cefclient/resources/draggable.html',
'tests/cefclient/resources/hang.html',
@@ -407,6 +422,8 @@
'tests/cefclient/browser/temp_window_mac.mm',
'tests/cefclient/browser/text_input_client_osr_mac.h',
'tests/cefclient/browser/text_input_client_osr_mac.mm',
'tests/cefclient/browser/util_mac.h',
'tests/cefclient/browser/util_mac.mm',
'tests/cefclient/browser/views_window_mac.mm',
'tests/cefclient/browser/window_test_runner_mac.h',
'tests/cefclient/browser/window_test_runner_mac.mm',
@@ -523,6 +540,7 @@
'tests/ceftests/permission_prompt_unittest.cc',
'tests/ceftests/preference_unittest.cc',
'tests/ceftests/print_unittest.cc',
'tests/ceftests/print_to_pdf_unittest.cc',
'tests/ceftests/process_message_unittest.cc',
'tests/ceftests/request_context_unittest.cc',
'tests/ceftests/request_handler_unittest.cc',

View File

@@ -36,11 +36,7 @@ macro(PRINT_CEF_CONFIG)
message(STATUS "CEF sandbox: ${USE_SANDBOX}")
set(_libraries ${CEF_STANDARD_LIBS})
if(OS_WINDOWS AND USE_SANDBOX)
list(APPEND _libraries ${CEF_SANDBOX_STANDARD_LIBS})
endif()
message(STATUS "Standard libraries: ${_libraries}")
message(STATUS "Standard libraries: ${CEF_STANDARD_LIBS}")
message(STATUS "Compile defines: ${CEF_COMPILER_DEFINES}")
message(STATUS "Compile defines (Debug): ${CEF_COMPILER_DEFINES_DEBUG}")

View File

@@ -326,7 +326,7 @@ if(OS_MAC)
# Find the newest available base SDK.
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
foreach(OS_VERSION 14.2 14.0 11.0)
foreach(OS_VERSION 15.4 14.2 14.0 11.0)
set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk")
if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}")
set(CMAKE_OSX_SYSROOT ${SDK})
@@ -361,14 +361,6 @@ if(OS_MAC)
list(APPEND CEF_COMPILER_DEFINES
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
)
list(APPEND CEF_STANDARD_LIBS
-lsandbox
)
# CEF sandbox library paths.
set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.a")
set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.a")
endif()
# CEF Helper app suffixes.
@@ -396,15 +388,6 @@ if(OS_WINDOWS)
set(CMAKE_CXX_FLAGS_RELEASE "")
endif()
if(USE_SANDBOX)
# Check if the current MSVC version is compatible with the cef_sandbox.lib
# static library. We require VS2015 or newer.
if(MSVC_VERSION LESS 1900)
message(WARNING "CEF sandbox is not compatible with the current MSVC version (${MSVC_VERSION})")
set(USE_SANDBOX OFF)
endif()
endif()
# Consumers who run into LNK4099 warnings can pass /Z7 instead (see issue #385).
set(CEF_DEBUG_INFO_FLAG "/Zi" CACHE STRING "Optional flag specifying specific /Z flag to use")
@@ -449,18 +432,20 @@ if(OS_WINDOWS)
list(APPEND CEF_LINKER_FLAGS_DEBUG
/DEBUG # Generate debug information
)
list(APPEND CEF_EXE_LINKER_FLAGS
/MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage)
/LARGEADDRESSAWARE # Allow 32-bit processes to access 3GB of RAM
# Delayload most libraries as the dlls are simply not required at startup (or
# at all, depending on the process type). Some dlls open handles when they are
# loaded, and we may not want them to be loaded in renderers or other sandboxed
# processes. Conversely, some dlls must be loaded before sandbox lockdown. In
# unsandboxed processes they will load when first needed. The linker will
# automatically ignore anything which is not linked to the binary at all (it is
# harmless to have an unmatched /delayload). This list should be kept in sync
# with Chromium's "delayloads" target from the //build/config/win/BUILD.gn file.
# Delayload most libraries as the dlls are simply not required at startup (or
# at all, depending on the process type). Some dlls open handles when they are
# loaded, and we may not want them to be loaded in renderers or other sandboxed
# processes. Conversely, some dlls must be loaded before sandbox lockdown. In
# unsandboxed processes they will load when first needed. The linker will
# automatically ignore anything which is not linked to the binary at all (it is
# harmless to have an unmatched /delayload). Lists should be kept in sync with
# targets from Chromium's //build/config/win/BUILD.gn file.
set(CEF_DELAYLOAD_FLAGS
# Required to support CefScopedLibraryLoader.
/DELAYLOAD:libcef.dll
# "delayloads" target.
/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll
/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll
/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll
@@ -502,6 +487,31 @@ if(OS_WINDOWS)
/DELAYLOAD:winusb.dll
/DELAYLOAD:wsock32.dll
/DELAYLOAD:wtsapi32.dll
# "delayloads_not_for_child_dll" target.
/DELAYLOAD:crypt32.dll
/DELAYLOAD:dbghelp.dll
/DELAYLOAD:dhcpcsvc.dll
/DELAYLOAD:dwrite.dll
/DELAYLOAD:iphlpapi.dll
/DELAYLOAD:oleaut32.dll
/DELAYLOAD:secur32.dll
/DELAYLOAD:userenv.dll
/DELAYLOAD:winhttp.dll
/DELAYLOAD:winmm.dll
/DELAYLOAD:winspool.drv
/DELAYLOAD:wintrust.dll
/DELAYLOAD:ws2_32.dll
)
list(APPEND CEF_EXE_LINKER_FLAGS
# For executable targets.
/MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage)
/LARGEADDRESSAWARE # Allow 32-bit processes to access 3GB of RAM
${CEF_DELAYLOAD_FLAGS}
)
list(APPEND CEF_SHARED_LINKER_FLAGS
# For shared library targets.
${CEF_DELAYLOAD_FLAGS}
)
list(APPEND CEF_COMPILER_DEFINES
WIN32 _WIN32 _WINDOWS # Windows platform
@@ -540,9 +550,12 @@ if(OS_WINDOWS)
# Standard libraries.
set(CEF_STANDARD_LIBS
comctl32.lib
crypt32.lib
delayimp.lib
gdi32.lib
rpcrt4.lib
shlwapi.lib
wintrust.lib
ws2_32.lib
)
@@ -587,36 +600,8 @@ if(OS_WINDOWS)
if(USE_SANDBOX)
list(APPEND CEF_COMPILER_DEFINES
PSAPI_VERSION=1 # Required by cef_sandbox.lib
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
CEF_USE_BOOTSTRAP # Used by apps to test if the bootstrap is enabled
)
list(APPEND CEF_COMPILER_DEFINES_DEBUG
_HAS_ITERATOR_DEBUGGING=0 # Disable iterator debugging
)
# Libraries required by cef_sandbox.lib.
set(CEF_SANDBOX_STANDARD_LIBS
Advapi32.lib
dbghelp.lib
Delayimp.lib
ntdll.lib
OleAut32.lib
PowrProf.lib
Propsys.lib
psapi.lib
SetupAPI.lib
Shell32.lib
Shcore.lib
Userenv.lib
version.lib
wbemuuid.lib
WindowsApp.lib
winmm.lib
)
# CEF sandbox library paths.
set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.lib")
set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.lib")
endif()
# Configure use of ATL.

View File

@@ -313,6 +313,30 @@
#define STACK_UNINITIALIZED
#endif
// Attribute "no_stack_protector" disables -fstack-protector for the specified
// function.
//
// "stack_protector" is enabled on most POSIX builds. The flag adds a canary
// to each stack frame, which on function return is checked against a reference
// canary. If the canaries do not match, it's likely that a stack buffer
// overflow has occurred, so immediately crashing will prevent exploitation in
// many cases.
//
// In some cases it's desirable to remove this, e.g. on hot functions, or if
// we have purposely changed the reference canary.
//
// On Linux systems the reference canary will be purposely changed when forking
// sub-processes (see https://crbug.com/40181003). To avoid sub-process shutdown
// crashes the NO_STACK_PROTECTOR annotation must be added to all functions in
// the call stack leading to CefExecuteProcess(). Applications that cannot add
// this annotation must instead pass the `--change-stack-guard-on-fork=disable`
// command-line flag.
#if defined(COMPILER_GCC) || defined(__clang__)
#define NO_STACK_PROTECTOR __attribute__((no_stack_protector))
#else
#define NO_STACK_PROTECTOR
#endif
// The ANALYZER_ASSUME_TRUE(bool arg) macro adds compiler-specific hints
// to Clang which control what code paths are statically analyzed,
// and is meant to be used in conjunction with assert & assert-like functions.

View File

@@ -47,30 +47,46 @@
#define CEF_INCLUDE_BASE_CEF_DUMP_WITHOUT_CRASHING_H_
#pragma once
#include "include/cef_api_hash.h"
constexpr long long kOneDayInMilliseconds = 86400000;
///
/// CefDumpWithoutCrashing allows for generating crash dumps with a throttling
/// This function allows for generating of crash dumps with a throttling
/// mechanism, preventing frequent dumps from being generated in a short period
/// of time from the same location. The |function_name|, |file_name|, and
/// |line_number| determine the location of the dump. The
/// of time from the same location. If should only be called after CefInitialize
/// has been successfully called. The |function_name|, |file_name|, and
/// |line_number| parameters specify the origin location of the dump. The
/// |mseconds_between_dumps| is an interval between consecutive dumps in
/// milliseconds from the same location.
///
/// Returns true if the dump was successfully generated, false otherwise.
///
/// For detailed behavior, usage instructions, and considerations, refer to the
/// documentation of DumpWithoutCrashing in base/debug/dump_without_crashing.h.
///
bool CefDumpWithoutCrashing(
long long mseconds_between_dumps = kOneDayInMilliseconds,
const char* function_name = __builtin_FUNCTION(),
const char* file_name = __builtin_FILE(),
int line_number = __builtin_LINE());
#if CEF_API_REMOVED(13500)
///
/// CefDumpWithoutCrashingUnthrottled allows for immediate crash dumping without
/// any throttling constraints.
/// This function allows for generating of crash dumps without any throttling
/// constraints. If should also only be called after CefInitialize has been
/// successfully called.
///
/// Returns true if the dump was successfully generated, false otherwise.
///
/// For detailed behavior, usage instructions, and considerations, refer to the
/// documentation of DumpWithoutCrashingUnthrottled in
/// base/debug/dump_without_crashing.h.
///
/// This function is removed in API version 13500. Use CefDumpWithoutCrashing()
/// instead.
///
bool CefDumpWithoutCrashingUnthrottled();
#endif
#endif // CEF_INCLUDE_BASE_CEF_DUMP_WITHOUT_CRASHING_H_

View File

@@ -0,0 +1,197 @@
// Copyright (c) 2025 Marshall A. Greenblatt. Portions copyright (c) 2019
// Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_BASE_CEF_IMMEDIATE_CRASH_H_
#define CEF_INCLUDE_BASE_CEF_IMMEDIATE_CRASH_H_
#pragma once
#if defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "base/immediate_crash.h"
#else // !USING_CHROMIUM_INCLUDES
// The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be
// updated to match.
#include "include/base/cef_build.h"
#if defined(OS_WIN)
#include <stdlib.h>
#endif
// Crashes in the fastest possible way with no attempt at logging.
// There are several constraints; see http://crbug.com/664209 for more context.
//
// - TRAP_SEQUENCE_() must be fatal. It should not be possible to ignore the
// resulting exception or simply hit 'continue' to skip over it in a debugger.
// - Different instances of TRAP_SEQUENCE_() must not be folded together, to
// ensure crash reports are debuggable. Unlike __builtin_trap(), asm volatile
// blocks will not be folded together.
// Note: TRAP_SEQUENCE_() previously required an instruction with a unique
// nonce since unlike clang, GCC folds together identical asm volatile
// blocks.
// - TRAP_SEQUENCE_() must produce a signal that is distinct from an invalid
// memory access.
// - TRAP_SEQUENCE_() must be treated as a set of noreturn instructions.
// __builtin_unreachable() is used to provide that hint here. clang also uses
// this as a heuristic to pack the instructions in the function epilogue to
// improve code density.
// - base::ImmediateCrash() is used in allocation hooks. To prevent recursions,
// TRAP_SEQUENCE_() must not allocate.
//
// Additional properties that are nice to have:
// - TRAP_SEQUENCE_() should be as compact as possible.
// - The first instruction of TRAP_SEQUENCE_() should not change, to avoid
// shifting crash reporting clusters. As a consequence of this, explicit
// assembly is preferred over intrinsics.
// Note: this last bullet point may no longer be true, and may be removed in
// the future.
// Note: TRAP_SEQUENCE Is currently split into two macro helpers due to the fact
// that clang emits an actual instruction for __builtin_unreachable() on certain
// platforms (see https://crbug.com/958675). In addition, the int3/bkpt/brk will
// be removed in followups, so splitting it up like this now makes it easy to
// land the followups.
#if defined(COMPILER_GCC)
#if defined(ARCH_CPU_X86_FAMILY)
// TODO(crbug.com/40625592): In theory, it should be possible to use just
// int3. However, there are a number of crashes with SIGILL as the exception
// code, so it seems likely that there's a signal handler that allows execution
// to continue after SIGTRAP.
#define TRAP_SEQUENCE1_() asm volatile("int3")
#if defined(OS_APPLE)
// Intentionally empty: __builtin_unreachable() is always part of the sequence
// (see IMMEDIATE_CRASH below) and already emits a ud2 on Mac.
#define TRAP_SEQUENCE2_() asm volatile("")
#else
#define TRAP_SEQUENCE2_() asm volatile("ud2")
#endif // defined(OS_APPLE)
#elif defined(ARCH_CPU_ARMEL)
// bkpt will generate a SIGBUS when running on armv7 and a SIGTRAP when running
// as a 32 bit userspace app on arm64. There doesn't seem to be any way to
// cause a SIGTRAP from userspace without using a syscall (which would be a
// problem for sandboxing).
// TODO(crbug.com/40625592): Remove bkpt from this sequence.
#define TRAP_SEQUENCE1_() asm volatile("bkpt #0")
#define TRAP_SEQUENCE2_() asm volatile("udf #0")
#elif defined(ARCH_CPU_ARM64)
// This will always generate a SIGTRAP on arm64.
// TODO(crbug.com/40625592): Remove brk from this sequence.
#define TRAP_SEQUENCE1_() asm volatile("brk #0")
#define TRAP_SEQUENCE2_() asm volatile("hlt #0")
#else
// Crash report accuracy will not be guaranteed on other architectures, but at
// least this will crash as expected.
#define TRAP_SEQUENCE1_() __builtin_trap()
#define TRAP_SEQUENCE2_() asm volatile("")
#endif // ARCH_CPU_*
#elif defined(COMPILER_MSVC)
#if !defined(__clang__)
// MSVC x64 doesn't support inline asm, so use the MSVC intrinsic.
#define TRAP_SEQUENCE1_() __debugbreak()
#define TRAP_SEQUENCE2_()
#elif defined(ARCH_CPU_ARM64)
// Windows ARM64 uses "BRK #F000" as its breakpoint instruction, and
// __debugbreak() generates that in both VC++ and clang.
#define TRAP_SEQUENCE1_() __debugbreak()
// Intentionally empty: __builtin_unreachable() is always part of the sequence
// (see IMMEDIATE_CRASH below) and already emits a ud2 on Win64,
// https://crbug.com/958373
#define TRAP_SEQUENCE2_() __asm volatile("")
#else
#define TRAP_SEQUENCE1_() asm volatile("int3")
#define TRAP_SEQUENCE2_() asm volatile("ud2")
#endif // __clang__
#else
#error No supported trap sequence!
#endif // COMPILER_GCC
#define TRAP_SEQUENCE_() \
do { \
TRAP_SEQUENCE1_(); \
TRAP_SEQUENCE2_(); \
} while (false)
// This version of ALWAYS_INLINE inlines even in is_debug=true.
// TODO(pbos): See if NDEBUG can be dropped from ALWAYS_INLINE as well, and if
// so merge. Otherwise document why it cannot inline in debug in
// base/compiler_specific.h.
#if defined(COMPILER_GCC)
#define IMMEDIATE_CRASH_ALWAYS_INLINE inline __attribute__((__always_inline__))
#elif defined(COMPILER_MSVC)
#define IMMEDIATE_CRASH_ALWAYS_INLINE __forceinline
#else
#define IMMEDIATE_CRASH_ALWAYS_INLINE inline
#endif
namespace base {
[[noreturn]] IMMEDIATE_CRASH_ALWAYS_INLINE void ImmediateCrash() {
#if defined(OS_WIN)
// We can't use abort() on Windows because it results in the
// abort/retry/ignore dialog which disrupts automated tests.
// TODO(crbug.com/40948553): investigate if such dialogs can
// be suppressed
TRAP_SEQUENCE_();
#if defined(__clang__) || defined(COMPILER_GCC)
__builtin_unreachable();
#endif // defined(__clang__) || defined(COMPILER_GCC)
#else // !defined(OS_WIN)
abort();
#endif // !defined(OS_WIN)
}
} // namespace base
#endif // !USING_CHROMIUM_INCLUDES
#endif // CEF_INCLUDE_BASE_CEF_LOCK_H_

View File

@@ -189,16 +189,50 @@
namespace cef {
namespace logging {
class ScopedEarlySupport;
namespace internal {
// Structure defining the baseline logging implementation used by client
// and wrapper code that links libcef_dll_wrapper.
struct Implementation {
decltype(&cef_get_min_log_level) get_min_log_level;
decltype(&cef_get_vlog_level) get_vlog_level;
decltype(&cef_log) log;
};
// Returns the currently configured logging implementation.
const Implementation* GetImplementation();
// Change the logging implementation for the lifespan of this scoped object.
// See ScopedEarlySupport for usage.
class ScopedImplementation {
public:
ScopedImplementation(const ScopedImplementation&) = delete;
ScopedImplementation& operator=(const ScopedImplementation&) = delete;
private:
friend class logging::ScopedEarlySupport;
ScopedImplementation();
~ScopedImplementation();
void Init(const Implementation* impl);
const Implementation* previous_ = nullptr;
};
} // namespace internal
// Gets the current log level.
inline int GetMinLogLevel() {
return cef_get_min_log_level();
return internal::GetImplementation()->get_min_log_level();
}
// Gets the current vlog level for the given file (usually taken from
// __FILE__). Note that |N| is the size *with* the null terminator.
template <size_t N>
int GetVlogLevel(const char (&file)[N]) {
return cef_get_vlog_level(file, N);
return internal::GetImplementation()->get_vlog_level(file, N);
}
typedef int LogSeverity;
@@ -218,6 +252,64 @@ const LogSeverity LOG_DFATAL = LOG_ERROR;
const LogSeverity LOG_DFATAL = LOG_FATAL;
#endif
///
/// Support the use of CEF logging macros during early application startup,
/// prior to loading libcef. Not for use during or after CEF initialization.
/// Support is scoped to this object's lifespan. This implementation is not
/// thread-safe and should not be used for logging from multiple threads.
///
class ScopedEarlySupport final : public internal::ScopedImplementation {
public:
///
/// Logging configuration.
///
struct Config {
///
/// Configure logging level.
///
int min_log_level = LOG_ERROR;
int vlog_level = 0;
///
/// Configure log line formatting.
///
const char* log_prefix = nullptr;
bool log_process_id = true;
bool log_thread_id = true;
bool log_timestamp = true;
bool log_tickcount = true;
///
/// Optionally override the default handling of formatted log lines. For
/// example, this callback could be used to write |log_line| to a file.
/// Return false to proceed with the default behavior of writing to stderr
/// or debugger console. FATAL errors will still intentionally crash the
/// application.
///
bool (*formatted_log_handler)(const char* /*log_line*/) = nullptr;
};
explicit ScopedEarlySupport(const Config& config);
ScopedEarlySupport(const ScopedEarlySupport&) = delete;
ScopedEarlySupport& operator=(const ScopedEarlySupport&) = delete;
private:
static const Config& GetConfig();
static int get_min_log_level();
static int get_vlog_level(const char* file_start, size_t N);
static void log(const char* file,
int line,
int severity,
const char* message);
const struct Impl {
internal::Implementation ptrs;
Config config;
} impl_;
};
// A few definitions of macros that don't generate much code. These are used
// by LOG() and LOG_IF, etc. Since these are used all over our code, it's
// better to have compact code for these operations.

View File

@@ -59,7 +59,7 @@ class CefApp;
/// |windows_sandbox_info| parameter is only used on Windows and may be NULL
/// (see cef_sandbox_win.h for details).
///
/*--cef(api_hash_check,optional_param=application,
/*--cef(api_hash_check,no_stack_protector,optional_param=application,
optional_param=windows_sandbox_info)--*/
int CefExecuteProcess(const CefMainArgs& args,
CefRefPtr<CefApp> application,
@@ -72,8 +72,8 @@ int CefExecuteProcess(const CefMainArgs& args,
/// early exit is desired (for example, due to process singleton relaunch
/// behavior). If this function returns false then the application should exit
/// immediately without calling any other CEF functions except, optionally,
/// CefGetErrorCode. The |windows_sandbox_info| parameter is only used on
/// Windows and may be NULL (see cef_sandbox_win.h for details).
/// CefGetExitCode. The |windows_sandbox_info| parameter is only used on Windows
/// and may be NULL (see cef_sandbox_win.h for details).
///
/*--cef(api_hash_check,optional_param=application,
optional_param=windows_sandbox_info)--*/

View File

@@ -249,7 +249,7 @@ class CefPdfPrintCallback : public virtual CefBaseRefCounted {
/// is the output path. |ok| will be true if the printing completed
/// successfully or false otherwise.
///
/*--cef()--*/
/*--cef(optional_param=path)--*/
virtual void OnPdfPrintFinished(const CefString& path, bool ok) = 0;
};
@@ -707,12 +707,24 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
virtual void WasHidden(bool hidden) = 0;
///
/// Send a notification to the browser that the screen info has changed. The
/// browser will then call CefRenderHandler::GetScreenInfo to update the
/// screen information with the new values. This simulates moving the webview
/// window from one display to another, or changing the properties of the
/// current display. This method is only used when window rendering is
/// disabled.
/// Notify the browser that screen information has changed. Updated
/// information will be sent to the renderer process to configure screen size
/// and position values used by CSS and JavaScript (window.deviceScaleFactor,
/// window.screenX/Y, window.outerWidth/Height, etc.). For background see
/// https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage.md#markdown-header-coordinate-systems
///
/// This method is used with (a) windowless rendering and (b) windowed
/// rendering with external (client-provided) root window.
///
/// With windowless rendering the browser will call
/// CefRenderHandler::GetScreenInfo, CefRenderHandler::GetRootScreenRect and
/// CefRenderHandler::GetViewRect. This simulates moving or resizing the root
/// window in the current display, moving the root window from one display to
/// another, or changing the properties of the current display.
///
/// With windowed rendering the browser will call
/// CefDisplayHandler::GetRootWindowScreenRect and use the associated
/// display properties.
///
/*--cef()--*/
virtual void NotifyScreenInfoChanged() = 0;

View File

@@ -38,6 +38,7 @@
#define CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_
#pragma once
#include "include/cef_api_hash.h"
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "include/cef_frame.h"
@@ -123,7 +124,7 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
///
/// Called when auto-resize is enabled via
/// CefBrowserHost::SetAutoResizeEnabled and the contents have auto-resized.
/// |new_size| will be the desired size in view coordinates. Return true if
/// |new_size| will be the desired size in DIP coordinates. Return true if
/// the resize was handled or false for default handling.
///
/*--cef()--*/
@@ -162,6 +163,46 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
virtual void OnMediaAccessChange(CefRefPtr<CefBrowser> browser,
bool has_video_access,
bool has_audio_access) {}
#if CEF_API_ADDED(13700)
///
/// Called when JavaScript is requesting new bounds via window.moveTo/By() or
/// window.resizeTo/By(). |new_bounds| are in DIP screen coordinates.
///
/// With Views-hosted browsers |new_bounds| are the desired bounds for
/// the containing CefWindow and may be passed directly to
/// CefWindow::SetBounds. With external (client-provided) parent on macOS and
/// Windows |new_bounds| are the desired frame bounds for the containing root
/// window. With other non-Views browsers |new_bounds| are the desired bounds
/// for the browser content only unless the client implements either
/// CefDisplayHandler::GetRootWindowScreenRect for windowed browsers or
/// CefRenderHandler::GetWindowScreenRect for windowless browsers. Clients may
/// expand browser content bounds to window bounds using OS-specific or
/// CefDisplay methods.
///
/// Return true if this method was handled or false for default handling.
/// Default move/resize behavior is only provided with Views-hosted Chrome
/// style browsers.
///
/*--cef(added=13700)--*/
virtual bool OnContentsBoundsChange(CefRefPtr<CefBrowser> browser,
const CefRect& new_bounds) {
return false;
}
///
/// Called to retrieve the external (client-provided) root window rectangle in
/// screen DIP coordinates. Only called for windowed browsers on Windows and
/// Linux. Return true if the rectangle was provided. Return false to use the
/// root window bounds on Windows or the browser content bounds on Linux. For
/// additional usage details see CefBrowserHost::NotifyScreenInfoChanged.
///
/*--cef(added=13700)--*/
virtual bool GetRootWindowScreenRect(CefRefPtr<CefBrowser> browser,
CefRect& rect) {
return false;
}
#endif
};
#endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_

View File

@@ -41,6 +41,7 @@
#include <vector>
#include "include/cef_base.h"
#include "include/cef_registration.h"
#include "include/cef_values.h"
///
@@ -65,6 +66,24 @@ class CefPreferenceRegistrar : public CefBaseScoped {
CefRefPtr<CefValue> default_value) = 0;
};
#if CEF_API_ADDED(13401)
///
/// Implemented by the client to observe preference changes and registered via
/// CefPreferenceManager::AddPreferenceObserver. The methods of this class will
/// be called on the browser process UI thread.
///
/*--cef(source=client,added=13401)--*/
class CefPreferenceObserver : public virtual CefBaseRefCounted {
public:
///
/// Called when a preference has changed. The new value can be retrieved using
/// CefPreferenceManager::GetPreference.
///
/*--cef()--*/
virtual void OnPreferenceChanged(const CefString& name) = 0;
};
#endif
///
/// Manage access to preferences. Many built-in preferences are registered by
/// Chromium. Custom preferences can be registered in
@@ -73,6 +92,36 @@ class CefPreferenceRegistrar : public CefBaseScoped {
/*--cef(source=library,no_debugct_check)--*/
class CefPreferenceManager : public virtual CefBaseRefCounted {
public:
#if CEF_API_ADDED(13401)
///
/// Returns the current Chrome Variations configuration (combination of field
/// trials and chrome://flags) as equivalent command-line switches
/// (`--[enable|disable]-features=XXXX`, etc). These switches can be used to
/// apply the same configuration when launching a CEF-based application. See
/// https://developer.chrome.com/docs/web-platform/chrome-variations for
/// background and details. Note that field trial tests are disabled by
/// default in Official CEF builds (via the
/// `disable_fieldtrial_testing_config=true` GN flag). This method must be
/// called on the browser process UI thread.
///
/*--cef(added=13401)--*/
static void GetChromeVariationsAsSwitches(std::vector<CefString>& switches);
///
/// Returns the current Chrome Variations configuration (combination of field
/// trials and chrome://flags) as human-readable strings. This is the
/// human-readable equivalent of the "Active Variations" section of
/// chrome://version. See
/// https://developer.chrome.com/docs/web-platform/chrome-variations for
/// background and details. Note that field trial tests are disabled by
/// default in Official CEF builds (via the
/// `disable_fieldtrial_testing_config=true` GN flag). This method must be
/// called on the browser process UI thread.
///
/*--cef(added=13401)--*/
static void GetChromeVariationsAsStrings(std::vector<CefString>& strings);
#endif
///
/// Returns the global preference manager object.
///
@@ -129,6 +178,21 @@ class CefPreferenceManager : public virtual CefBaseRefCounted {
virtual bool SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) = 0;
#if CEF_API_ADDED(13401)
///
/// Add an observer for preference changes. |name| is the name of the
/// preference to observe. If |name| is empty then all preferences will
/// be observed. Observing all preferences has performance consequences and
/// is not recommended outside of testing scenarios. The observer will remain
/// registered until the returned Registration object is destroyed. This
/// method must be called on the browser process UI thread.
///
/*--cef(optional_param=name,added=13401)--*/
virtual CefRefPtr<CefRegistration> AddPreferenceObserver(
const CefString& name,
CefRefPtr<CefPreferenceObserver> observer) = 0;
#endif
};
#endif // CEF_INCLUDE_CEF_PREFERENCE_H_

View File

@@ -44,6 +44,7 @@
#include "include/cef_cookie.h"
#include "include/cef_media_router.h"
#include "include/cef_preference.h"
#include "include/cef_registration.h"
#include "include/cef_values.h"
class CefRequestContextHandler;
@@ -66,6 +67,27 @@ class CefResolveCallback : public virtual CefBaseRefCounted {
const std::vector<CefString>& resolved_ips) = 0;
};
#if CEF_API_ADDED(13401)
///
/// Implemented by the client to observe content and website setting changes and
/// registered via CefRequestContext::AddSettingObserver. The methods of this
/// class will be called on the browser process UI thread.
///
/*--cef(source=client,added=13401)--*/
class CefSettingObserver : public virtual CefBaseRefCounted {
public:
///
/// Called when a content or website setting has changed. The new value can be
/// retrieved using CefRequestContext::GetContentSetting or
/// CefRequestContext::GetWebsiteSetting.
///
/*--cef(optional_param=requesting_url,optional_param=top_level_url)--*/
virtual void OnSettingChanged(const CefString& requesting_url,
const CefString& top_level_url,
cef_content_setting_types_t content_type) = 0;
};
#endif
///
/// A request context provides request handling for a set of related browser
/// or URL request objects. A request context can be specified when creating a
@@ -292,6 +314,17 @@ class CefRequestContext : public CefPreferenceManager {
cef_content_setting_types_t content_type,
cef_content_setting_values_t value) = 0;
#if CEF_API_ADDED(13401)
///
/// Add an observer for content and website setting changes. The observer will
/// remain registered until the returned Registration object is destroyed.
/// This method must be called on the browser process UI thread.
///
/*--cef(added=13401)--*/
virtual CefRefPtr<CefRegistration> AddSettingObserver(
CefRefPtr<CefSettingObserver> observer) = 0;
#endif
///
/// Sets the Chrome color scheme for all browsers that share this request
/// context. |variant| values of SYSTEM, LIGHT and DARK change the underlying

View File

@@ -48,14 +48,8 @@ extern "C" {
/// The sandbox is used to restrict sub-processes (renderer, GPU, etc) from
/// directly accessing system resources. This helps to protect the user from
/// untrusted and potentially malicious Web content. See
/// http://www.chromium.org/developers/design-documents/sandbox for complete
/// details.
///
/// To enable the sandbox on macOS the following requirements must be met:
/// 1. Link the helper process executable with the cef_sandbox static library.
/// 2. Call the cef_sandbox_initialize() function at the beginning of the
/// helper executable main() function and before loading the CEF framework
/// library. See include/wrapper/cef_library_loader.h for example usage.
/// https://bitbucket.org/chromiumembedded/cef/wiki/SandboxSetup.md for usage
/// details. See include/wrapper/cef_library_loader.h for example usage.
///
///
@@ -76,7 +70,7 @@ CEF_EXPORT void cef_sandbox_destroy(void* sandbox_context);
///
/// Scoped helper for managing the life span of a sandbox context handle.
///
class CEF_EXPORT CefScopedSandboxContext {
class CefScopedSandboxContext final {
public:
CefScopedSandboxContext();
~CefScopedSandboxContext();
@@ -87,7 +81,8 @@ class CEF_EXPORT CefScopedSandboxContext {
bool Initialize(int argc, char** argv);
private:
void* sandbox_context_;
void* library_handle_ = nullptr;
void* sandbox_context_ = nullptr;
};
#endif // __cplusplus

View File

@@ -37,6 +37,12 @@
#if defined(OS_WIN)
#include "include/cef_version_info.h"
#if !defined(GENERATING_CEF_API_HASH)
#include <windows.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
@@ -46,17 +52,9 @@ extern "C" {
/// The sandbox is used to restrict sub-processes (renderer, GPU, etc) from
/// directly accessing system resources. This helps to protect the user from
/// untrusted and potentially malicious Web content. See
/// http://www.chromium.org/developers/design-documents/sandbox for complete
/// https://bitbucket.org/chromiumembedded/cef/wiki/SandboxSetup.md for usage
/// details.
///
/// To enable the sandbox on Windows the following requirements must be met:
/// 1. Use the same executable for the browser process and all sub-processes.
/// 2. Link the executable with the cef_sandbox static library.
/// 3. Call the cef_sandbox_info_create() function from within the executable
/// (not from a separate DLL) and pass the resulting pointer into both the
/// CefExecuteProcess() and CefInitialize() functions via the
/// |windows_sandbox_info| parameter.
///
///
/// Create the sandbox information object for this process. It is safe to create
@@ -76,7 +74,7 @@ void cef_sandbox_info_destroy(void* sandbox_info);
///
/// Manages the life span of a sandbox information object.
///
class CefScopedSandboxInfo {
class CefScopedSandboxInfo final {
public:
CefScopedSandboxInfo() { sandbox_info_ = cef_sandbox_info_create(); }
~CefScopedSandboxInfo() { cef_sandbox_info_destroy(sandbox_info_); }
@@ -88,6 +86,39 @@ class CefScopedSandboxInfo {
};
#endif // __cplusplus
#if defined(CEF_BUILD_BOOTSTRAP)
#define CEF_BOOTSTRAP_EXPORT __declspec(dllimport)
#else
#define CEF_BOOTSTRAP_EXPORT __declspec(dllexport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
///
/// Entry point to be implemented by client DLLs using bootstrap.exe for
/// windows (/SUBSYSTEM:WINDOWS) applications.
///
CEF_BOOTSTRAP_EXPORT int RunWinMain(HINSTANCE hInstance,
LPTSTR lpCmdLine,
int nCmdShow,
void* sandbox_info,
cef_version_info_t* version_info);
///
/// Entry point to be implemented by client DLLs using bootstrapc.exe for
/// console (/SUBSYSTEM:CONSOLE) applications.
///
CEF_BOOTSTRAP_EXPORT int RunConsoleMain(int argc,
char* argv[],
void* sandbox_info,
cef_version_info_t* version_info);
#ifdef __cplusplus
}
#endif
#endif // defined(OS_WIN)
#endif // CEF_INCLUDE_CEF_SANDBOX_WIN_H_

View File

@@ -30,6 +30,9 @@
#ifndef CEF_INCLUDE_CEF_VERSION_INFO_H_
#define CEF_INCLUDE_CEF_VERSION_INFO_H_
#include <stddef.h>
#include "include/cef_api_hash.h"
#include "include/internal/cef_export.h"
#if !defined(GENERATING_CEF_API_HASH)
@@ -55,6 +58,66 @@ extern "C" {
///
CEF_EXPORT int cef_version_info(int entry);
#if CEF_API_ADDED(13800)
///
/// Structure representing all CEF version information.
///
typedef struct _cef_version_info_t {
///
/// Size of this structure.
///
size_t size;
int cef_version_major;
int cef_version_minor;
int cef_version_patch;
int cef_commit_number;
int chrome_version_major;
int chrome_version_minor;
int chrome_version_build;
int chrome_version_patch;
} cef_version_info_t;
///
/// Return all CEF version information for the libcef library.
///
CEF_EXPORT void cef_version_info_all(cef_version_info_t* info);
#elif !defined(GENERATING_CEF_API_HASH)
// Unversioned definition to support use of the bootstrap and
// CefScopedLibraryLoader with older API versions.
typedef struct _cef_version_info_t {
// Size of this structure.
size_t size;
int cef_version_major;
int cef_version_minor;
int cef_version_patch;
int cef_commit_number;
int chrome_version_major;
int chrome_version_minor;
int chrome_version_build;
int chrome_version_patch;
} cef_version_info_t;
#endif // !defined(GENERATING_CEF_API_HASH)
///
/// Populate CEF version information for the client library.
///
#define CEF_POPULATE_VERSION_INFO(info) \
(info)->size = sizeof(cef_version_info_t); \
(info)->cef_version_major = CEF_VERSION_MAJOR; \
(info)->cef_version_minor = CEF_VERSION_MINOR; \
(info)->cef_version_patch = CEF_VERSION_PATCH; \
(info)->cef_commit_number = CEF_COMMIT_NUMBER; \
(info)->chrome_version_major = CHROME_VERSION_MAJOR; \
(info)->chrome_version_minor = CHROME_VERSION_MINOR; \
(info)->chrome_version_build = CHROME_VERSION_BUILD; \
(info)->chrome_version_patch = CHROME_VERSION_PATCH
#ifdef __cplusplus
}
#endif

View File

@@ -41,6 +41,8 @@
#include <windows.h>
#endif
#include "include/internal/cef_export.h"
#ifdef __cplusplus
extern "C" {
#endif

View File

@@ -42,22 +42,37 @@ extern "C" {
// See include/base/cef_dump_without_crashing.h for intended usage.
///
/// cef_dump_without_crashing allows for capturing crash dumps in a throttled
/// manner. This function should only be called after CefInitialize has been
/// successfully called. For detailed behavior, usage instructions, and
/// considerations, refer to the documentation of DumpWithoutCrashing in
/// base/debug/dump_without_crashing.h.
/// This function allows for generating of crash dumps with a throttling
/// mechanism, preventing frequent dumps from being generated in a short period
/// of time from the same location. If should only be called after CefInitialize
/// has been successfully called. The |function_name|, |file_name|, and
/// |line_number| parameters specify the origin location of the dump. The
/// |mseconds_between_dumps| is an interval between consecutive dumps in
/// milliseconds from the same location.
///
/// Returns true (1) if the dump was successfully generated, false otherwise.
///
/// For detailed behavior, usage instructions, and considerations, refer to the
/// documentation of DumpWithoutCrashing in base/debug/dump_without_crashing.h.
///
CEF_EXPORT int cef_dump_without_crashing(long long mseconds_between_dumps,
const char* function_name,
const char* file_name,
int line_number);
///
/// cef_dump_without_crashing_unthrottled allows for capturing crash dumps
/// without any throttling constraints. This function should also only be called
/// after CefInitialize has been successfully called. For detailed behavior,
/// usage instructions, and considerations, refer to the documentation of
/// DumpWithoutCrashingUnthrottled in base/debug/dump_without_crashing.h.
/// This function allows for generating of crash dumps without any throttling
/// constraints. If should also only be called after CefInitialize has been
/// successfully called.
///
/// Returns true (1) if the dump was successfully generated, false otherwise.
///
/// For detailed behavior, usage instructions, and considerations, refer to the
/// documentation of DumpWithoutCrashingUnthrottled in
/// base/debug/dump_without_crashing.h.
///
/// This function is removed in API version 13500. Use
/// cef_dump_without_crashing() instead.
///
CEF_EXPORT int cef_dump_without_crashing_unthrottled();

View File

@@ -672,7 +672,11 @@ typedef struct _cef_browser_settings_t {
/// Controls whether databases can be used. Also configurable using the
/// "disable-databases" command-line switch.
///
#if CEF_API_ADDED(13800)
cef_state_t databases_deprecated;
#else
cef_state_t databases;
#endif
///
/// Controls whether WebGL can be used. Note that WebGL requires hardware
@@ -1061,6 +1065,11 @@ typedef enum {
CEF_RESULT_CODE_CHROME_FIRST,
#if CEF_API_ADDED(13800)
/// The process is of an unknown type.
CEF_RESULT_CODE_BAD_PROCESS_TYPE = 6,
#endif
/// A critical chrome file is missing.
CEF_RESULT_CODE_MISSING_DATA = 7,
@@ -1093,7 +1102,16 @@ typedef enum {
/// system state can't be recovered and will be unstable.
CEF_RESULT_CODE_SYSTEM_RESOURCE_EXHAUSTED = 37,
#if CEF_API_ADDED(13800)
/// The browser process exited because it was re-launched without elevation.
CEF_RESULT_CODE_NORMAL_EXIT_AUTO_DE_ELEVATED = 38,
#endif
#if CEF_API_ADDED(13800)
CEF_RESULT_CODE_CHROME_LAST = 39,
#else
CEF_RESULT_CODE_CHROME_LAST = 38,
#endif
// The following values should be kept in sync with Chromium's
// sandbox::TerminationCodes type.
@@ -1271,7 +1289,11 @@ typedef enum {
PDE_TYPE_BYTES,
PDE_TYPE_FILE,
#if CEF_API_ADDED(13601)
PDE_TYPE_NUM_VALUES,
#else
PDF_TYPE_NUM_VALUES,
#endif
} cef_postdataelement_type_t;
///
@@ -3621,6 +3643,12 @@ typedef enum {
CEF_CPAIT_OPTIMIZATION_GUIDE,
#if CEF_API_ADDED(13304)
CEF_CPAIT_COLLABORATION_MESSAGING,
#endif
#if CEF_API_ADDED(13400)
CEF_CPAIT_CHANGE_PASSWORD,
#endif
#if CEF_API_ADDED(13800)
CEF_CPAIT_LENS_OVERLAY_HOMEWORK,
#endif
CEF_CPAIT_NUM_VALUES,
} cef_chrome_page_action_icon_type_t;
@@ -3631,8 +3659,13 @@ typedef enum {
///
typedef enum {
CEF_CTBT_CAST,
#if CEF_API_REMOVED(13600)
CEF_CTBT_DOWNLOAD,
CEF_CTBT_SEND_TAB_TO_SELF,
#else
CEF_CTBT_DOWNLOAD_DEPRECATED,
CEF_CTBT_SEND_TAB_TO_SELF_DEPRECATED,
#endif
CEF_CTBT_SIDE_PANEL,
CEF_CTBT_NUM_VALUES,
} cef_chrome_toolbar_button_type_t;
@@ -3785,6 +3818,9 @@ typedef enum {
CEF_PERMISSION_TYPE_WEB_APP_INSTALLATION = 1 << 22,
CEF_PERMISSION_TYPE_WINDOW_MANAGEMENT = 1 << 23,
CEF_PERMISSION_TYPE_FILE_SYSTEM_ACCESS = 1 << 24,
#if CEF_API_ADDED(13600)
CEF_PERMISSION_TYPE_LOCAL_NETWORK_ACCESS = 1 << 25,
#endif
} cef_permission_request_types_t;
///

View File

@@ -31,6 +31,8 @@
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_CONTENT_SETTINGS_H_
#pragma once
#include "include/cef_api_hash.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -41,11 +43,12 @@ extern "C" {
/// ContentSettingsType type.
///
typedef enum {
// This setting governs whether cookies are enabled by the user in the
/// This setting governs whether cookies are enabled by the user in the
/// provided context. However, it may be overridden by other settings. This
/// enum should NOT be read directly to determine whether cookies are enabled;
/// the client should instead rely on the CookieSettings API.
CEF_CONTENT_SETTING_TYPE_COOKIES,
CEF_CONTENT_SETTING_TYPE_IMAGES,
CEF_CONTENT_SETTING_TYPE_JAVASCRIPT,
@@ -233,11 +236,15 @@ typedef enum {
/// screens. See also: https://w3c.github.io/window-placement
CEF_CONTENT_SETTING_TYPE_WINDOW_MANAGEMENT,
/// Stores whether to allow insecure websites to make private network
/// requests.
/// See also: https://wicg.github.io/cors-rfc1918
/// Set through enterprise policies only.
/// Stores whether to allow insecure websites to make private network
/// requests.
/// See also: https://wicg.github.io/cors-rfc1918
/// Set through enterprise policies only.
#if CEF_API_ADDED(13800)
CEF_CONTENT_SETTING_TYPE_INSECURE_PRIVATE_NETWORK_DEPRECATED,
#else
CEF_CONTENT_SETTING_TYPE_INSECURE_PRIVATE_NETWORK,
#endif
/// Content setting which stores whether or not a site can access low-level
/// locally installed font data using the Local Fonts Access API.
@@ -327,7 +334,7 @@ typedef enum {
/// HTTP header.
CEF_CONTENT_SETTING_TYPE_FEDERATED_IDENTITY_IDENTITY_PROVIDER_SIGNIN_STATUS,
/// Website setting which is used for UnusedSitePermissionsService to
/// Website setting which is used for RevokedPermissionsService to
/// store revoked permissions of unused sites from unused site permissions
/// feature.
CEF_CONTENT_SETTING_TYPE_REVOKED_UNUSED_SITE_PERMISSIONS,
@@ -380,12 +387,16 @@ typedef enum {
/// a requesting-origin/top-level-site combination and persistent.
CEF_CONTENT_SETTING_TYPE_TOP_LEVEL_TPCD_TRIAL,
/// Content Setting for a first-party origin trial that allows websites to
/// enable third-party cookie deprecation.
/// ALLOW (default): no effect (e.g. third-party cookies allowed, if not
/// blocked otherwise).
/// BLOCK: third-party cookies blocked, but 3PCD mitigations enabled.
/// Content Setting for a first-party origin trial that allows websites to
/// enable third-party cookie deprecation.
/// ALLOW (default): no effect (e.g. third-party cookies allowed, if not
/// blocked otherwise).
/// BLOCK: third-party cookies blocked, but 3PCD mitigations enabled.
#if CEF_API_ADDED(13601)
CEF_CONTENT_SETTING_TYPE_TOP_LEVEL_TPCD_ORIGIN_TRIAL,
#else
CEF_CONTENT_SETTING_TOP_LEVEL_TPCD_ORIGIN_TRIAL,
#endif
/// Content setting used to indicate whether entering picture-in-picture
/// automatically should be enabled.
@@ -436,7 +447,7 @@ typedef enum {
/// access to mouse inputs.
CEF_CONTENT_SETTING_TYPE_POINTER_LOCK,
/// Website setting which is used for UnusedSitePermissionsService to store
/// Website setting which is used for RevokedPermissionsService to store
/// auto-revoked notification permissions from abusive sites.
CEF_CONTENT_SETTING_TYPE_REVOKED_ABUSIVE_NOTIFICATION_PERMISSIONS,
@@ -484,6 +495,42 @@ typedef enum {
/// or legacy behavior.
CEF_CONTENT_SETTING_TYPE_LEGACY_COOKIE_SCOPE,
#if CEF_API_ADDED(13400)
/// Website setting to indicate whether the user has allowlisted suspicious
/// notifications for the origin.
CEF_CONTENT_SETTING_TYPE_ARE_SUSPICIOUS_NOTIFICATIONS_ALLOWLISTED_BY_USER,
/// Content settings for access to the Controlled Frame API.
CEF_CONTENT_SETTING_TYPE_CONTROLLED_FRAME,
#endif
#if CEF_API_ADDED(13500)
/// Website setting which is used for RevokedPermissionsService to
/// store revoked notification permissions of disruptive sites.
CEF_CONTENT_SETTING_TYPE_REVOKED_DISRUPTIVE_NOTIFICATION_PERMISSIONS,
#endif
#if CEF_API_ADDED(13600)
/// Content setting for whether the site is allowed to make local network
/// requests.
CEF_CONTENT_SETTING_TYPE_LOCAL_NETWORK_ACCESS,
#endif
#if CEF_API_ADDED(13800)
/// Stores information on-device language packs for which a site has
/// installed using the Web Speech API.
CEF_CONTENT_SETTING_TYPE_ON_DEVICE_SPEECH_RECOGNITION_LANGUAGES_DOWNLOADED,
/// Stores which Translator API language packs the site has initialized.
CEF_CONTENT_SETTING_TYPE_INITIALIZED_TRANSLATIONS,
/// Stores a list of notification ids where content detection found the
/// notification to be suspicious and a warning has already been shown for the
/// site. Used for recovering notification contents from the database if the
/// user decides they would like to see all of these notifications.
CEF_CONTENT_SETTING_TYPE_SUSPICIOUS_NOTIFICATION_IDS,
#endif
CEF_CONTENT_SETTING_TYPE_NUM_VALUES,
} cef_content_setting_types_t;

View File

@@ -567,7 +567,9 @@ struct CefBrowserSettingsTraits {
target->text_area_resize = src->text_area_resize;
target->tab_to_links = src->tab_to_links;
target->local_storage = src->local_storage;
#if !CEF_API_ADDED(13800)
target->databases = src->databases;
#endif
target->webgl = src->webgl;
target->background_color = src->background_color;

View File

@@ -38,6 +38,7 @@
#define CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_DELEGATE_H_
#pragma once
#include "include/cef_api_hash.h"
#include "include/cef_client.h"
#include "include/views/cef_view_delegate.h"
@@ -129,6 +130,18 @@ class CefBrowserViewDelegate : public CefViewDelegate {
return false;
}
#if CEF_API_ADDED(13601)
///
/// Return true to allow the use of JavaScript moveTo/By() and resizeTo/By()
/// (without user activation) with Document picture-in-picture popups.
///
/*--cef(added=13601)--*/
virtual bool AllowMoveForPictureInPicture(
CefRefPtr<CefBrowserView> browser_view) {
return false;
}
#endif
///
/// Called when |browser_view| receives a gesture command. Return true to
/// handle (or disable) a |gesture_command| or false to propagate the gesture

View File

@@ -50,6 +50,9 @@
/// indicated. Methods must be called on the browser process UI thread unless
/// otherwise indicated.
///
/// For details on coordinate systems and usage see
/// https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage#markdown-header-coordinate-systems
///
/*--cef(source=library)--*/
class CefDisplay : public CefBaseRefCounted {
public:
@@ -129,7 +132,9 @@ class CefDisplay : public CefBaseRefCounted {
/// Returns this Display's device pixel scale factor. This specifies how much
/// the UI should be scaled when the actual output has more pixels than
/// standard displays (which is around 100~120dpi). The potential return
/// values differ by platform.
/// values differ by platform. Windowed browsers with 1.0 zoom will have a
/// JavaScript `window.devicePixelRatio` value matching the associated
/// Display's GetDeviceScaleFactor() value.
///
/*--cef()--*/
virtual float GetDeviceScaleFactor() = 0;

View File

@@ -0,0 +1,151 @@
// Copyright (c) 2025 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 are only available to applications that link
// against the libcef_dll_wrapper target.
//
#ifndef CEF_INCLUDE_WRAPPER_CEF_CERTIFICATE_UTIL_WIN_H_
#define CEF_INCLUDE_WRAPPER_CEF_CERTIFICATE_UTIL_WIN_H_
#pragma once
#include <windows.h>
#include <string>
#include <vector>
namespace cef_certificate_util {
// SHA1 upper-case hex encoded = 40 characters.
inline constexpr size_t kThumbprintLength = 40U;
///
/// Structure populated by GetClientThumbprints().
///
struct ThumbprintsInfo {
///
/// True if one or more signatures exist and all are valid.
///
bool IsSignedAndValid() const {
return !valid_thumbprints.empty() && errors.empty();
}
///
/// True if unsigned, or if one or more signatures exist and all are valid.
///
bool IsUnsignedOrValid() const {
return !has_signature || IsSignedAndValid();
}
///
/// True if this and |other| have the same signature status. If
/// |allow_unsigned| is true then both may be unsigned. Otherwise, one or more
/// signatures must exist, all must be valid, and the primary fingerprint must
/// be the same for both.
///
bool IsSame(const ThumbprintsInfo& other, bool allow_unsigned) const {
if (allow_unsigned && !has_signature && !other.has_signature) {
return true;
}
return IsSignedAndValid() &&
other.HasPrimaryThumbprint(valid_thumbprints[0]);
}
///
/// True if a valid primary signature exists and it matches the specified
/// |thumbprint|.
///
bool HasPrimaryThumbprint(const std::string& thumbprint) const {
return IsSignedAndValid() && valid_thumbprints[0] == thumbprint;
}
///
/// True if a primary signature exists, irrespective of validity.
///
bool has_signature = false;
///
/// Thumbprints for signatures, if any, that passed verification.
///
std::vector<std::string> valid_thumbprints;
///
/// Thumbprints for signatures, if any, that failed verification. Will not be
/// populated if |verify_binary=true| was passed to GetClientThumbprints().
///
std::vector<std::string> invalid_thumbprints;
///
/// Errors (newline delimited) if any signatures failed verification.
///
std::wstring errors;
};
///
/// Process client signatures for the binary at the specified abolute
/// |binary_path| and populate |info|. If |verify_binary| is true and the
/// primary signature fails verification then no further signatures will be
/// processed. For a code signing example and usage details see
/// https://github.com/chromiumembedded/cef/issues/3824#issuecomment-2892139995
///
void GetClientThumbprints(const std::wstring& binary_path,
bool verify_binary,
ThumbprintsInfo& info);
///
/// Evaluate the binary at the specified absolute |binary_path| for common
/// requirements and populate |info|. If the binary is code signed then all
/// signatures must be valid. If |thumbprint| is a SHA1 hash (e.g. 40 character
/// upper-case hex-encoded value) then the primary signature must match that
/// thumbprint. If |allow_unsigned| is true and |thumbprint| is nullptr then the
/// binary may be unsigned, otherwise it must be validly signed. Returns true if
/// all requirements are met.
///
bool ValidateCodeSigning(const std::wstring& binary_path,
const char* thumbprint,
bool allow_unsigned,
ThumbprintsInfo& info);
///
/// Same as ValidateCodeSigning, but failures result in a FATAL error and
/// application termination. Optionally populate |info| is validation succeeds.
/// Usage must be protected by cef::logging::ScopedEarlySupport if called prior
/// to libcef loading.
///
void ValidateCodeSigningAssert(const std::wstring& binary_path,
const char* thumbprint,
bool allow_unsigned,
ThumbprintsInfo* info = nullptr);
} // namespace cef_certificate_util
#endif // CEF_INCLUDE_WRAPPER_CEF_CERTIFICATE_UTIL_WIN_H_

View File

@@ -33,11 +33,11 @@
#include "include/base/cef_build.h"
#ifdef __cplusplus
#include <string>
#if defined(OS_MAC)
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#endif
///
/// Load the CEF library at the specified |path|. Returns true (1) on
@@ -53,6 +53,12 @@ int cef_unload_library(void);
#ifdef __cplusplus
}
#endif
#endif // defined(OS_MAC)
#ifdef __cplusplus
#include <string>
#if defined(OS_MAC)
@@ -84,7 +90,8 @@ int cef_unload_library(void);
/// #include "include/wrapper/cef_library_loader.h"
///
/// int main(int argc, char* argv[]) {
/// // Initialize the macOS sandbox for this helper process.
/// // Dynamically load and initialize the macOS sandbox for this helper
/// // process.
/// CefScopedSandboxContext sandbox_context;
/// if (!sandbox_context.Initialize(argc, argv))
/// return 1;
@@ -98,7 +105,7 @@ int cef_unload_library(void);
/// }
/// </pre>
///
class CefScopedLibraryLoader {
class CefScopedLibraryLoader final {
public:
CefScopedLibraryLoader();
@@ -124,10 +131,101 @@ class CefScopedLibraryLoader {
private:
bool Load(bool helper);
bool loaded_;
bool loaded_ = false;
};
#endif // defined(OS_MAC)
#elif defined(OS_WIN)
#include <windows.h>
#include "include/cef_version_info.h"
///
/// Scoped helper for loading the CEF library at runtime from a specific
/// location on disk. Can optionally be used to verify code signing status and
/// Chromium version compatibility at the same time. Binaries using this helper
/// must be built with the "/DELAYLOAD:libcef.dll" linker flag.
///
/// Example usage:
///
/// <pre>
/// #include "include/wrapper/cef_library_loader.h"
///
/// int APIENTRY wWinMain(HINSTANCE hInstance,
/// HINSTANCE hPrevInstance,
/// LPTSTR lpCmdLine,
/// int nCmdShow)
/// // Version that was used to compile the CEF client app.
/// cef_version_info_t version_info = {};
/// CEF_POPULATE_VERSION_INFO(&version_info);
///
/// // Dynamically load libcef.dll from the specified location, and verify
/// // that the Chromium version is compatible. Any failures will
/// // intentionally crash the application. All CEF distribution resources
/// // (DLLs, pak, etc) must be located in the same directory.
/// CefScopedLibraryLoader library_loader;
/// if (!library_loader.LoadInSubProcessAssert(&version_info)) {
/// // Not running as a potentially sandboxed sub-process.
/// // Choose the appropriate path for loading libcef.dll...
/// const wchar_t* path = L"c:\\path\\to\\myapp\\cef\\libcef.dll";
/// if (!library_loader.LoadInMainAssert(path, nullptr, true,
/// &version_info)) {
/// // The load failed. We'll crash before reaching this line.
/// NOTREACHED();
/// return CEF_RESULT_CODE_KILLED;
/// }
/// }
///
/// // Continue with CEF initialization...
/// }
/// </pre>
///
class CefScopedLibraryLoader final {
public:
CefScopedLibraryLoader();
CefScopedLibraryLoader(const CefScopedLibraryLoader&) = delete;
CefScopedLibraryLoader& operator=(const CefScopedLibraryLoader&) = delete;
~CefScopedLibraryLoader();
///
/// Load the CEF library (libcef.dll) in the main process from the specified
/// absolute path. If libcef.dll is code signed then all signatures must be
/// valid. If |thumbprint| is a SHA1 hash (e.g. 40 character upper-case
/// hex-encoded value) then the primary signature must match that thumbprint.
/// If |allow_unsigned| is true and |thumbprint| is nullptr then libcef.dll
/// may be unsigned, otherwise it must be validly signed. Failure of code
/// signing requirements or DLL loading will result in a FATAL error and
/// application termination. If |version_info| is specified then the
/// libcef.dll version information must also match. Returns true if the load
/// succeeds. Usage must be protected by cef::logging::ScopedEarlySupport.
///
bool LoadInMainAssert(const wchar_t* dll_path,
const char* thumbprint,
bool allow_unsigned,
cef_version_info_t* version_info);
///
/// Load the CEF library (libcef.dll) in a sub-process that may be sandboxed.
/// The path will be determined based on command-line arguments for the
/// current process. Failure of DLL loading will result in a FATAL error and
/// application termination. If |version_info| is specified then the
/// libcef.dll version information must match. Returns true if the load
/// succeeds. Usage must be protected by cef::logging::ScopedEarlySupport.
///
bool LoadInSubProcessAssert(cef_version_info_t* version_info);
private:
HMODULE handle_ = nullptr;
};
namespace switches {
// Changes to this value require rebuilding libcef.dll.
inline constexpr char kLibcefPath[] = "libcef-path";
inline constexpr wchar_t kLibcefPathW[] = L"libcef-path";
} // namespace switches
#endif // defined(OS_WIN)
#endif // __cplusplus
#endif // CEF_INCLUDE_WRAPPER_CEF_LIBRARY_LOADER_H_

View File

@@ -0,0 +1,65 @@
// Copyright (c) 2025 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 are only available to applications that link
// against the libcef_dll_wrapper target.
//
#ifndef CEF_INCLUDE_WRAPPER_CEF_UTIL_WIN_H_
#define CEF_INCLUDE_WRAPPER_CEF_UTIL_WIN_H_
#pragma once
#include <windows.h>
#include <string>
#include <vector>
namespace cef_util {
// Returns the fully qualified file path for the executable module.
std::wstring GetExePath();
// Returns the fully qualified file path for |module|.
std::wstring GetModulePath(HMODULE module);
// Returns the value of GetLastError() as a string.
std::wstring GetLastErrorAsString();
// Parse command line arguments for |hInstance|.
std::vector<std::wstring> ParseCommandLineArgs(const wchar_t* str);
// Returns the value for |name| in |command_line|, if any.
std::wstring GetCommandLineValue(const std::vector<std::wstring>& command_line,
const std::wstring& name);
} // namespace cef_util
#endif // CEF_INCLUDE_WRAPPER_CEF_UTIL_WIN_H_

View File

@@ -117,8 +117,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
scoped_refptr<CefBrowserInfo> info =
CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
/*is_devtools_popup=*/false, platform_delegate->IsWindowless(),
platform_delegate->IsPrintPreviewSupported(),
/*is_devtools_popup=*/false, platform_delegate->GetBrowserConfig(),
create_params.extra_info);
bool own_web_contents = false;
@@ -132,8 +131,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
CefRefPtr<AlloyBrowserHostImpl> browser =
CreateInternal(create_params.settings, create_params.client, web_contents,
own_web_contents, info,
/*opener=*/nullptr, /*is_devtools_popup=*/false,
own_web_contents, info, /*opener=*/nullptr,
request_context_impl, std::move(platform_delegate));
if (!browser) {
return nullptr;
@@ -160,7 +158,6 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
bool own_web_contents,
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<AlloyBrowserHostImpl> opener,
bool is_devtools_popup,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate) {
CEF_REQUIRE_UIT();
@@ -185,7 +182,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
// new browser's platform delegate.
opener->platform_delegate_->PopupWebContentsCreated(
settings, client, web_contents, platform_delegate.get(),
is_devtools_popup);
/*is_devtools=*/false);
}
// Take ownership of |web_contents| if |own_web_contents| is true.
@@ -208,7 +205,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
// result in a call to CefBrowserViewDelegate::OnPopupBrowserViewCreated().
// Do this first for consistency with Chrome style.
opener->platform_delegate_->PopupBrowserCreated(
browser->platform_delegate(), browser.get(), is_devtools_popup);
browser->platform_delegate(), browser.get(), /*is_devtools=*/false);
}
// 2. Notify the browser's LifeSpanHandler. This must always be the first
@@ -419,24 +416,6 @@ void AlloyBrowserHostImpl::WasHidden(bool hidden) {
}
}
void AlloyBrowserHostImpl::NotifyScreenInfoChanged() {
if (!IsWindowless()) {
DCHECK(false) << "Window rendering is not disabled";
return;
}
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&AlloyBrowserHostImpl::NotifyScreenInfoChanged, this));
return;
}
if (platform_delegate_) {
platform_delegate_->NotifyScreenInfoChanged();
}
}
void AlloyBrowserHostImpl::Invalidate(PaintElementType type) {
if (!IsWindowless()) {
DCHECK(false) << "Window rendering is not disabled";
@@ -901,29 +880,6 @@ void AlloyBrowserHostImpl::DragSourceEndedAt(
}
}
void AlloyBrowserHostImpl::SetAudioMuted(bool mute) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SetAudioMuted,
this, mute));
return;
}
if (!web_contents()) {
return;
}
web_contents()->SetAudioMuted(mute);
}
bool AlloyBrowserHostImpl::IsAudioMuted() {
if (!CEF_CURRENTLY_ON_UIT()) {
DCHECK(false) << "called on invalid thread";
return false;
}
if (!web_contents()) {
return false;
}
return web_contents()->IsAudioMuted();
}
// content::WebContentsDelegate methods.
// -----------------------------------------------------------------------------
@@ -1024,6 +980,11 @@ void AlloyBrowserHostImpl::CloseContents(content::WebContents* source) {
}
}
void AlloyBrowserHostImpl::SetContentsBounds(content::WebContents* source,
const gfx::Rect& bounds) {
contents_delegate_.SetContentsBoundsEx(source, bounds);
}
void AlloyBrowserHostImpl::UpdateTargetURL(content::WebContents* source,
const GURL& url) {
contents_delegate_.UpdateTargetURL(source, url);
@@ -1057,14 +1018,7 @@ void AlloyBrowserHostImpl::BeforeUnloadFired(content::WebContents* source,
bool AlloyBrowserHostImpl::TakeFocus(content::WebContents* source,
bool reverse) {
if (client_.get()) {
CefRefPtr<CefFocusHandler> handler = client_->GetFocusHandler();
if (handler.get()) {
handler->OnTakeFocus(this, !reverse);
}
}
return false;
return contents_delegate_.TakeFocus(source, reverse);
}
void AlloyBrowserHostImpl::CanDownload(
@@ -1151,8 +1105,7 @@ void AlloyBrowserHostImpl::WebContentsCreated(
scoped_refptr<CefBrowserInfo> info =
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
new_contents, platform_delegate->IsWindowless(),
platform_delegate->IsPrintPreviewSupported(), extra_info);
new_contents, platform_delegate->GetBrowserConfig(), extra_info);
CHECK(info.get());
CHECK(info->is_popup());
@@ -1170,8 +1123,7 @@ void AlloyBrowserHostImpl::WebContentsCreated(
// However, we need to install observers/delegates here.
CefRefPtr<AlloyBrowserHostImpl> browser = CreateInternal(
settings, client, new_contents, /*own_web_contents=*/false, info, opener,
/*is_devtools_popup=*/false, request_context,
std::move(platform_delegate));
request_context, std::move(platform_delegate));
}
void AlloyBrowserHostImpl::RendererUnresponsive(

View File

@@ -90,7 +90,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
bool IsWindowRenderingDisabled() override;
void WasResized() override;
void WasHidden(bool hidden) override;
void NotifyScreenInfoChanged() override;
void Invalidate(PaintElementType type) override;
void SendExternalBeginFrame() override;
void SendTouchEvent(const CefTouchEvent& event) override;
@@ -115,8 +114,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void DragTargetDrop(const CefMouseEvent& event) override;
void DragSourceSystemDragEnded() override;
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
void SetAudioMuted(bool mute) override;
bool IsAudioMuted() override;
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;
@@ -195,6 +192,8 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void LoadingStateChanged(content::WebContents* source,
bool should_show_loading_ui) override;
void CloseContents(content::WebContents* source) override;
void SetContentsBounds(content::WebContents* source,
const gfx::Rect& bounds) override;
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
bool DidAddMessageToConsole(content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
@@ -300,7 +299,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
bool own_web_contents,
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<AlloyBrowserHostImpl> opener,
bool is_devtools_popup,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate);

View File

@@ -74,7 +74,7 @@ CefAudioCapturer::CefAudioCapturer(const CefAudioParameters& params,
DCHECK(browser_->web_contents());
channels_ = audio_params.channels();
audio_input_device_ = new media::AudioInputDevice(
audio_input_device_ = base::MakeRefCounted<media::AudioInputDevice>(
std::make_unique<mirroring::CapturedAudioInput>(
base::BindRepeating(&StreamCreatorHelper,
base::Unretained(browser_->web_contents()),

View File

@@ -142,6 +142,18 @@ content::WebContents* CefBrowserContentsDelegate::OpenURLFromTabEx(
return nullptr;
}
bool CefBrowserContentsDelegate::SetContentsBoundsEx(
content::WebContents* source,
const gfx::Rect& bounds) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
return handler->OnContentsBoundsChange(
browser(), {bounds.x(), bounds.y(), bounds.width(), bounds.height()});
}
}
return false;
}
void CefBrowserContentsDelegate::LoadingStateChanged(
content::WebContents* source,
bool should_show_loading_ui) {
@@ -378,11 +390,11 @@ void CefBrowserContentsDelegate::RenderViewReady() {
void CefBrowserContentsDelegate::PrimaryMainFrameRenderProcessGone(
base::TerminationStatus status) {
static_assert(static_cast<int>(CEF_RESULT_CODE_CHROME_FIRST) ==
static_cast<int>(chrome::RESULT_CODE_CHROME_START),
static_cast<int>(CHROME_RESULT_CODE_CHROME_START),
"CEF_RESULT_CODE_CHROME_FIRST must match "
"chrome::RESULT_CODE_CHROME_START");
static_assert(static_cast<int>(CEF_RESULT_CODE_CHROME_LAST) ==
static_cast<int>(chrome::RESULT_CODE_CHROME_LAST_CODE),
static_cast<int>(CHROME_RESULT_CODE_CHROME_LAST_CODE),
"CEF_RESULT_CODE_CHROME_LAST must match "
"chrome::RESULT_CODE_CHROME_LAST_CODE");
@@ -629,6 +641,17 @@ void CefBrowserContentsDelegate::OnFocusChangedInPage(
details->is_editable_node;
}
bool CefBrowserContentsDelegate::TakeFocus(content::WebContents* source,
bool reverse) {
if (auto c = client()) {
if (auto handler = c->GetFocusHandler()) {
handler->OnTakeFocus(browser(), !reverse);
}
}
return false;
}
void CefBrowserContentsDelegate::WebContentsDestroyed() {
auto wc = web_contents();
ObserveWebContents(nullptr);

View File

@@ -87,6 +87,10 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
base::OnceCallback<void(content::NavigationHandle&)>&
navigation_handle_callback);
// Same as SetContentsBounds but returning false if unhandled.
bool SetContentsBoundsEx(content::WebContents* source,
const gfx::Rect& bounds);
// WebContentsDelegate methods:
void LoadingStateChanged(content::WebContents* source,
bool should_show_loading_ui) override;
@@ -144,6 +148,7 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
void OnWebContentsFocused(
content::RenderWidgetHost* render_widget_host) override;
void OnFocusChangedInPage(content::FocusedNodeDetails* details) override;
bool TakeFocus(content::WebContents* source, bool reverse) override;
void WebContentsDestroyed() override;
// Accessors for state information. Changes will be signaled to

View File

@@ -246,7 +246,8 @@ void CefBrowserContext::RemoveCefRequestContext(
Shutdown();
// Allow the current call stack to unwind before deleting |this|.
content::BrowserThread::DeleteSoon(CEF_UIT, FROM_HERE, this);
content::BrowserThread::GetTaskRunnerForThread(CEF_UIT)->DeleteSoon(
FROM_HERE, this);
}
}

View File

@@ -783,6 +783,28 @@ CefRefPtr<CefNavigationEntry> CefBrowserHostBase::GetVisibleNavigationEntry() {
return new CefNavigationEntryImpl(entry);
}
void CefBrowserHostBase::SetAudioMuted(bool mute) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::SetAudioMuted,
this, mute));
return;
}
if (auto web_contents = GetWebContents()) {
web_contents->SetAudioMuted(mute);
}
}
bool CefBrowserHostBase::IsAudioMuted() {
if (!CEF_CURRENTLY_ON_UIT()) {
DCHECK(false) << "called on invalid thread";
return false;
}
if (auto web_contents = GetWebContents()) {
return web_contents->IsAudioMuted();
}
return false;
}
void CefBrowserHostBase::NotifyMoveOrResizeStarted() {
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC))
if (!CEF_CURRENTLY_ON_UIT()) {
@@ -795,9 +817,30 @@ void CefBrowserHostBase::NotifyMoveOrResizeStarted() {
if (platform_delegate_) {
platform_delegate_->NotifyMoveOrResizeStarted();
}
#else
LOG(WARNING)
<< "Incorrect usage of CefBrowserHost::NotifyMoveOrResizeStarted";
#endif
}
void CefBrowserHostBase::NotifyScreenInfoChanged() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefBrowserHostBase::NotifyScreenInfoChanged, this));
return;
}
if (platform_delegate_) {
if (IsWindowless() || platform_delegate_->HasExternalParent()) {
platform_delegate_->NotifyScreenInfoChanged();
} else {
LOG(WARNING)
<< "Incorrect usage of CefBrowserHost::NotifyScreenInfoChanged";
}
}
}
bool CefBrowserHostBase::IsFullscreen() {
if (!CEF_CURRENTLY_ON_UIT()) {
DCHECK(false) << "called on invalid thread";
@@ -1398,6 +1441,19 @@ CefDevToolsWindowRunner* CefBrowserHostBase::GetDevToolsWindowRunner() {
return devtools_window_runner_.get();
}
void CefBrowserHostBase::set_context_menu_observer(
RenderViewContextMenuObserver* observer) {
context_menu_observer_ = observer;
}
void CefBrowserHostBase::clear_context_menu_observer(
RenderViewContextMenuObserver* observer) {
// Don't clear if a new Observer has already been assigned.
if (context_menu_observer_ == observer) {
context_menu_observer_ = nullptr;
}
}
views::Widget* CefBrowserHostBase::GetWindowWidget() const {
CEF_REQUIRE_UIT();
if (!platform_delegate_) {

View File

@@ -262,7 +262,10 @@ class CefBrowserHostBase : public CefBrowserHost,
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
bool current_only) override;
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
void SetAudioMuted(bool mute) override;
bool IsAudioMuted() override;
void NotifyMoveOrResizeStarted() override;
void NotifyScreenInfoChanged() override;
bool IsFullscreen() override;
void ExitFullscreen(bool will_cause_resize) override;
bool IsRenderProcessUnresponsive() override;
@@ -390,9 +393,8 @@ class CefBrowserHostBase : public CefBrowserHost,
RenderViewContextMenuObserver* context_menu_observer() const {
return context_menu_observer_;
}
void set_context_menu_observer(RenderViewContextMenuObserver* observer) {
context_menu_observer_ = observer;
}
void set_context_menu_observer(RenderViewContextMenuObserver* observer);
void clear_context_menu_observer(RenderViewContextMenuObserver* observer);
// Returns the Widget owner for the browser window. Only used with windowed
// browsers.

View File

@@ -28,13 +28,11 @@ CefBrowserInfo::FrameInfo::~FrameInfo() {
CefBrowserInfo::CefBrowserInfo(int browser_id,
bool is_popup,
bool is_windowless,
bool print_preview_enabled,
const cef::BrowserConfig& config,
CefRefPtr<CefDictionaryValue> extra_info)
: browser_id_(browser_id),
is_popup_(is_popup),
is_windowless_(is_windowless),
print_preview_enabled_(print_preview_enabled),
config_(config),
extra_info_(extra_info) {
DCHECK_GT(browser_id, 0);

View File

@@ -19,6 +19,7 @@
#include "base/values.h"
#include "cef/include/internal/cef_ptr.h"
#include "cef/libcef/common/values_impl.h"
#include "cef/libcef/renderer/browser_config.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/render_frame_host.h"
@@ -36,8 +37,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
public:
CefBrowserInfo(int browser_id,
bool is_popup,
bool is_windowless,
bool print_preview_enabled,
const cef::BrowserConfig& config,
CefRefPtr<CefDictionaryValue> extra_info);
CefBrowserInfo(const CefBrowserInfo&) = delete;
@@ -45,8 +45,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
int browser_id() const { return browser_id_; }
bool is_popup() const { return is_popup_; }
bool is_windowless() const { return is_windowless_; }
bool print_preview_enabled() const { return print_preview_enabled_; }
const cef::BrowserConfig& config() const { return config_; }
CefRefPtr<CefDictionaryValue> extra_info() const { return extra_info_; }
// May return nullptr if the browser has not yet been created (before
@@ -202,8 +201,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
const int browser_id_;
const bool is_popup_;
const bool is_windowless_;
const bool print_preview_enabled_;
const cef::BrowserConfig config_;
CefRefPtr<CefDictionaryValue> extra_info_;
// Navigation will be blocked while |navigation_lock_| exists.

View File

@@ -69,15 +69,13 @@ CefBrowserInfoManager* CefBrowserInfoManager::GetInstance() {
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreateBrowserInfo(
bool is_popup,
bool is_windowless,
bool print_preview_enabled,
bool is_devtools_popup,
const cef::BrowserConfig& config,
CefRefPtr<CefDictionaryValue> extra_info) {
base::AutoLock lock_scope(browser_info_lock_);
scoped_refptr<CefBrowserInfo> browser_info =
new CefBrowserInfo(++next_browser_id_, is_popup, is_windowless,
print_preview_enabled, extra_info);
scoped_refptr<CefBrowserInfo> browser_info = new CefBrowserInfo(
++next_browser_id_, is_devtools_popup, config, extra_info);
browser_info_list_.push_back(browser_info);
return browser_info;
@@ -85,8 +83,7 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreateBrowserInfo(
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
content::WebContents* new_contents,
bool is_windowless,
bool print_preview_enabled,
const cef::BrowserConfig& config,
CefRefPtr<CefDictionaryValue> extra_info) {
CEF_REQUIRE_UIT();
@@ -95,8 +92,8 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
scoped_refptr<CefBrowserInfo> browser_info;
{
base::AutoLock lock_scope(browser_info_lock_);
browser_info = new CefBrowserInfo(++next_browser_id_, true, is_windowless,
print_preview_enabled, extra_info);
browser_info =
new CefBrowserInfo(++next_browser_id_, true, config, extra_info);
browser_info_list_.push_back(browser_info);
}
@@ -777,9 +774,14 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
if (browser_info) {
params->browser_id = browser_info->browser_id();
params->is_windowless = browser_info->is_windowless();
params->is_popup = browser_info->is_popup();
params->print_preview_enabled = browser_info->print_preview_enabled();
auto config = cef::mojom::NewBrowserConfig::New();
config->is_popup = browser_info->is_popup();
config->is_windowless = browser_info->config().is_windowless;
config->print_preview_enabled =
browser_info->config().print_preview_enabled;
config->move_pip_enabled = browser_info->config().move_pip_enabled;
params->config = std::move(config);
auto extra_info = browser_info->extra_info();
if (extra_info) {

View File

@@ -53,11 +53,10 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
static CefBrowserInfoManager* GetInstance();
// Called immediately before a new CefBrowserHost implementation is created
// directly. In this case |is_popup| will be true only for DevTools browsers.
// directly.
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(
bool is_popup,
bool is_windowless,
bool print_preview_enabled,
bool is_devtools_popup,
const cef::BrowserConfig& config,
CefRefPtr<CefDictionaryValue> extra_info);
// Called from WebContentsDelegate::WebContentsCreated when a new browser is
@@ -66,8 +65,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// response will be sent when this method is called.
scoped_refptr<CefBrowserInfo> CreatePopupBrowserInfo(
content::WebContents* new_contents,
bool is_windowless,
bool print_preview_enabled,
const cef::BrowserConfig& config,
CefRefPtr<CefDictionaryValue> extra_info);
// Called from ContentBrowserClient::CanCreateWindow. See comments on

View File

@@ -244,8 +244,7 @@ void CefBrowserPlatformDelegate::PopupBrowserCreated(
return;
}
CefRefPtr<CefBrowserView> new_browser_view =
CefBrowserView::GetForBrowser(new_browser);
auto new_browser_view = new_browser->GetBrowserView();
CHECK(new_browser_view);
bool popup_handled = false;
@@ -389,9 +388,7 @@ bool CefBrowserPlatformDelegate::IsHidden() const {
return false;
}
void CefBrowserPlatformDelegate::NotifyScreenInfoChanged() {
DCHECK(false);
}
void CefBrowserPlatformDelegate::NotifyScreenInfoChanged() {}
void CefBrowserPlatformDelegate::Invalidate(cef_paint_element_type_t type) {
DCHECK(false);
@@ -567,6 +564,15 @@ bool CefBrowserPlatformDelegate::IsPrintPreviewSupported() const {
return true;
}
bool CefBrowserPlatformDelegate::IsMovePictureInPictureEnabled() const {
return false;
}
cef::BrowserConfig CefBrowserPlatformDelegate::GetBrowserConfig() const {
return {IsWindowless(), IsPrintPreviewSupported(),
IsMovePictureInPictureEnabled()};
}
void CefBrowserPlatformDelegate::Find(const CefString& searchText,
bool forward,
bool matchCase,

View File

@@ -15,6 +15,7 @@
#include "cef/include/cef_drag_data.h"
#include "cef/include/internal/cef_types.h"
#include "cef/include/views/cef_browser_view.h"
#include "cef/libcef/renderer/browser_config.h"
#include "third_party/blink/public/common/page/drag_operation.h"
#include "third_party/blink/public/mojom/drag/drag.mojom-forward.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -305,7 +306,7 @@ class CefBrowserPlatformDelegate {
virtual bool IsHidden() const;
// Notify the browser that screen information has changed. Only used with
// windowless rendering.
// windowless rendering and external (client-provided) root window.
virtual void NotifyScreenInfoChanged();
// Invalidate the view. Only used with windowless rendering.
@@ -370,6 +371,12 @@ class CefBrowserPlatformDelegate {
bool findNext);
virtual void StopFinding(bool clearSelection);
virtual bool IsMovePictureInPictureEnabled() const;
// CefBrowser configuration determined prior to CefBrowserHost creation and
// passed to the renderer process via the GetNewBrowserInfo Mojo request.
cef::BrowserConfig GetBrowserConfig() const;
protected:
// Allow deletion via std::unique_ptr only.
friend std::default_delete<CefBrowserPlatformDelegate>;

View File

@@ -99,8 +99,8 @@ class BrowserDelegate : public content::WebContentsDelegate {
enum class ToolbarButtonType {
kCast = 0,
kDownload,
kSendTabToSelf,
kDownload_DEPRECATED,
kSendTabToSelf_DEPRECATED,
kSidePanel,
kMaxValue = kSidePanel,
};
@@ -173,6 +173,12 @@ class BrowserDelegate : public content::WebContentsDelegate {
navigation_handle_callback) {
return true;
}
// Same as SetContentsBounds but returning false if unhandled.
virtual bool SetContentsBoundsEx(content::WebContents* source,
const gfx::Rect& bounds) {
return false;
}
};
} // namespace cef

View File

@@ -260,8 +260,8 @@ void ChromeBrowserDelegate::SetAsDelegate(content::WebContents* web_contents,
CHECK(platform_delegate->IsChromeStyle());
auto browser_info = CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
is_devtools_popup, /*is_windowless=*/false,
platform_delegate->IsPrintPreviewSupported(), create_params_.extra_info);
is_devtools_popup, platform_delegate->GetBrowserConfig(),
create_params_.extra_info);
auto request_context_impl =
CefRequestContextImpl::GetOrCreateForRequestContext(
@@ -476,6 +476,14 @@ void ChromeBrowserDelegate::DraggableRegionsChanged(
}
}
bool ChromeBrowserDelegate::TakeFocus(content::WebContents* source,
bool reverse) {
if (auto delegate = GetDelegateForWebContents(source)) {
return delegate->TakeFocus(source, reverse);
}
return false;
}
void ChromeBrowserDelegate::WindowFullscreenStateChanged() {
// Use a synchronous callback for notification on Windows/Linux. MacOS gets
// notified asynchronously via CefNativeWidgetMac callbacks.
@@ -565,6 +573,14 @@ bool ChromeBrowserDelegate::OpenURLFromTabEx(
return true;
}
bool ChromeBrowserDelegate::SetContentsBoundsEx(content::WebContents* source,
const gfx::Rect& bounds) {
if (auto delegate = GetDelegateForWebContents(source)) {
return delegate->SetContentsBoundsEx(source, bounds);
}
return false;
}
void ChromeBrowserDelegate::LoadingStateChanged(content::WebContents* source,
bool should_show_loading_ui) {
if (auto delegate = GetDelegateForWebContents(source)) {
@@ -751,8 +767,7 @@ ChromeBrowserDelegate::CreateBrowserHostForPopup(
auto browser_info =
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
web_contents, /*is_windowless=*/false,
platform_delegate->IsPrintPreviewSupported(), extra_info);
web_contents, platform_delegate->GetBrowserConfig(), extra_info);
CHECK(browser_info->is_popup());
// Popups must share the same RequestContext as the parent.

View File

@@ -94,6 +94,8 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>&
navigation_handle_callback) override;
bool SetContentsBoundsEx(content::WebContents* source,
const gfx::Rect& bounds) override;
// WebContentsDelegate methods:
void WebContentsCreated(content::WebContents* source_contents,
@@ -127,6 +129,7 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
void DraggableRegionsChanged(
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
content::WebContents* contents) override;
bool TakeFocus(content::WebContents* source, bool reverse) override;
Browser* browser() const { return browser_; }

View File

@@ -250,10 +250,6 @@ void ChromeBrowserHostImpl::WasHidden(bool hidden) {
NOTIMPLEMENTED();
}
void ChromeBrowserHostImpl::NotifyScreenInfoChanged() {
NOTIMPLEMENTED();
}
void ChromeBrowserHostImpl::Invalidate(PaintElementType type) {
NOTIMPLEMENTED();
}
@@ -327,15 +323,6 @@ void ChromeBrowserHostImpl::DragSourceEndedAt(int x,
NOTIMPLEMENTED();
}
void ChromeBrowserHostImpl::SetAudioMuted(bool mute) {
NOTIMPLEMENTED();
}
bool ChromeBrowserHostImpl::IsAudioMuted() {
NOTIMPLEMENTED();
return false;
}
void ChromeBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) {
@@ -509,8 +496,7 @@ void ChromeBrowserHostImpl::Attach(content::WebContents* web_contents,
is_devtools_popup);
}
platform_delegate_->WebContentsCreated(web_contents,
/*own_web_contents=*/false);
platform_delegate_->WebContentsCreated(web_contents, /*owned=*/false);
contents_delegate_.ObserveWebContents(web_contents);
// Associate the platform delegate with this browser.

View File

@@ -84,7 +84,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
bool IsWindowRenderingDisabled() override { return false; }
void WasResized() override;
void WasHidden(bool hidden) override;
void NotifyScreenInfoChanged() override;
void Invalidate(PaintElementType type) override;
void SendExternalBeginFrame() override;
void SendTouchEvent(const CefTouchEvent& event) override;
@@ -109,8 +108,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
void DragTargetDrop(const CefMouseEvent& event) override;
void DragSourceSystemDragEnded() override;
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
void SetAudioMuted(bool mute) override;
bool IsAudioMuted() override;
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;

View File

@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/path_service.h"
#include "cef/include/wrapper/cef_library_loader.h"
#include "cef/libcef/browser/browser_frame.h"
#include "cef/libcef/browser/browser_host_base.h"
#include "cef/libcef/browser/browser_info_manager.h"
@@ -50,6 +51,10 @@
#include "cef/libcef/browser/chrome/chrome_web_contents_view_delegate_cef.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "cef/libcef_dll/bootstrap/bootstrap_util_win.h"
#endif
namespace {
class CefSelectClientCertificateCallbackImpl
@@ -132,7 +137,7 @@ void HandleExternalProtocolHelper(
ChromeContentBrowserClientCef* self,
content::WebContents::Getter web_contents_getter,
content::FrameTreeNodeId frame_tree_node_id,
content::NavigationUIData* navigation_data,
std::unique_ptr<content::NavigationUIData> navigation_data,
bool is_primary_main_frame,
bool is_in_fenced_frame_tree,
network::mojom::WebSandboxFlags sandbox_flags,
@@ -153,13 +158,25 @@ void HandleExternalProtocolHelper(
// NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
self->HandleExternalProtocol(
resource_request.url, web_contents_getter, frame_tree_node_id,
navigation_data, is_primary_main_frame, is_in_fenced_frame_tree,
navigation_data.get(), is_primary_main_frame, is_in_fenced_frame_tree,
sandbox_flags,
static_cast<ui::PageTransition>(resource_request.transition_type),
resource_request.has_user_gesture, initiating_origin, initiator_rfh,
isolation_info, nullptr);
}
#if BUILDFLAG(IS_WIN)
// Returns the module handle that contains this code (e.g. libcef.dll).
HINSTANCE GetCodeModuleHandle() {
HMODULE hModule = nullptr;
CHECK(::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCWSTR>(GetCodeModuleHandle),
&hModule));
return hModule;
}
#endif
} // namespace
ChromeContentBrowserClientCef::ChromeContentBrowserClientCef() = default;
@@ -214,6 +231,23 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames);
}
#if BUILDFLAG(IS_WIN)
{
const auto& exe_path = bootstrap_util::GetExePath();
const auto& module_value =
bootstrap_util::GetValidatedModuleValue(*browser_cmd, exe_path);
if (!module_value.empty()) {
command_line->AppendSwitchNative(bootstrap_util::switches::kModule,
module_value);
}
const auto& libcef_path =
bootstrap_util::GetModulePath(GetCodeModuleHandle());
if (libcef_path.DirName() != exe_path.DirName()) {
command_line->AppendSwitchPath(switches::kLibcefPath, libcef_path);
}
}
#endif
const std::string& process_type =
command_line->GetSwitchValueASCII(switches::kProcessType);
@@ -375,12 +409,14 @@ void ChromeContentBrowserClientCef::CreateWindowResult(
CefBrowserInfoManager::GetInstance()->CreateWindowResult(opener, success);
}
void ChromeContentBrowserClientCef::OverrideWebkitPrefs(
void ChromeContentBrowserClientCef::OverrideWebPreferences(
content::WebContents* web_contents,
content::SiteInstance& main_frame_site,
blink::web_pref::WebPreferences* prefs) {
renderer_prefs::SetDefaultPrefs(*prefs);
ChromeContentBrowserClient::OverrideWebkitPrefs(web_contents, prefs);
ChromeContentBrowserClient::OverrideWebPreferences(web_contents,
main_frame_site, prefs);
SkColor base_background_color;
auto browser = CefBrowserHostBase::GetBrowserForContents(web_contents);
@@ -542,23 +578,20 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
web_contents_getter, frame_tree_node_id, request,
base::BindRepeating(HandleExternalProtocolHelper, base::Unretained(this),
web_contents_getter, frame_tree_node_id,
navigation_data, is_primary_main_frame,
is_in_fenced_frame_tree, sandbox_flags, request,
initiating_origin, std::move(weak_initiator_document),
isolation_info));
base::Passed(navigation_data->Clone()),
is_primary_main_frame, is_in_fenced_frame_tree,
sandbox_flags, request, initiating_origin,
std::move(weak_initiator_document), isolation_info));
net_service::ProxyURLLoaderFactory::CreateProxy(
web_contents_getter, std::move(receiver), std::move(request_handler));
return true;
}
std::vector<std::unique_ptr<content::NavigationThrottle>>
ChromeContentBrowserClientCef::CreateThrottlesForNavigation(
content::NavigationHandle* navigation_handle) {
auto throttles = ChromeContentBrowserClient::CreateThrottlesForNavigation(
navigation_handle);
throttle::CreateThrottlesForNavigation(navigation_handle, throttles);
return throttles;
void ChromeContentBrowserClientCef::CreateThrottlesForNavigation(
content::NavigationThrottleRegistry& registry) {
ChromeContentBrowserClient::CreateThrottlesForNavigation(registry);
throttle::CreateThrottlesForNavigation(registry);
}
bool ChromeContentBrowserClientCef::ConfigureNetworkContextParams(
@@ -600,7 +633,7 @@ ChromeContentBrowserClientCef::CreateLoginDelegate(
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
content::GuestPageHolder* guest,
LoginAuthRequiredCallback auth_required_callback) {
content::LoginDelegate::LoginAuthRequiredCallback auth_required_callback) {
// |web_contents| is nullptr for CefURLRequests without an associated frame.
if (!web_contents || base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableChromeLoginPrompt)) {

View File

@@ -65,8 +65,9 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
bool* no_javascript_access) override;
void CreateWindowResult(content::RenderFrameHost* opener,
bool success) override;
void OverrideWebkitPrefs(content::WebContents* web_contents,
blink::web_pref::WebPreferences* prefs) override;
void OverrideWebPreferences(content::WebContents* web_contents,
content::SiteInstance& main_frame_site,
blink::web_pref::WebPreferences* prefs) override;
void WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,
content::RenderFrameHost* frame,
@@ -112,9 +113,8 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
const net::IsolationInfo& isolation_info,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
std::vector<std::unique_ptr<content::NavigationThrottle>>
CreateThrottlesForNavigation(
content::NavigationHandle* navigation_handle) override;
void CreateThrottlesForNavigation(
content::NavigationThrottleRegistry& registry) override;
bool ConfigureNetworkContextParams(
content::BrowserContext* context,
bool in_memory,
@@ -133,7 +133,8 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
content::GuestPageHolder* guest,
LoginAuthRequiredCallback auth_required_callback) override;
content::LoginDelegate::LoginAuthRequiredCallback auth_required_callback)
override;
void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,

View File

@@ -82,7 +82,8 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefContextMenuHandler> handler)
: context_menu_(context_menu), browser_(browser), handler_(handler) {
// This remains valid until the next time a context menu is created.
// Association remains valid until the next time a context menu is created,
// or this Observer is destroyed.
browser_->set_context_menu_observer(this);
}
@@ -163,6 +164,7 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
// Clear stored state because this object won't be deleted until a new
// context menu is created or the associated browser is destroyed.
browser_->clear_context_menu_observer(this);
browser_ = nullptr;
handler_ = nullptr;
params_ = nullptr;

View File

@@ -130,6 +130,16 @@ bool CefBrowserPlatformDelegateChromeViews::IsViewsHosted() const {
return true;
}
bool CefBrowserPlatformDelegateChromeViews::IsMovePictureInPictureEnabled()
const {
if (browser_view_) {
if (auto* delegate = browser_view_->delegate()) {
return delegate->AllowMoveForPictureInPicture(browser_view_.get());
}
}
return false;
}
CefWindowImpl* CefBrowserPlatformDelegateChromeViews::GetWindowImpl() const {
if (auto* widget = GetWindowWidget()) {
CefRefPtr<CefWindow> window = view_util::GetWindowFor(widget);

View File

@@ -34,6 +34,7 @@ class CefBrowserPlatformDelegateChromeViews
void SetBrowserView(CefRefPtr<CefBrowserView> browser_view) override;
void SetFocus(bool setFocus) override;
bool IsViewsHosted() const override;
bool IsMovePictureInPictureEnabled() const override;
CefBrowserViewImpl* browser_view() const { return browser_view_.get(); }

View File

@@ -14,6 +14,10 @@
#include "ui/views/win/hwnd_util.h"
#endif
#if defined(USE_AURA)
#include "cef/libcef/browser/native/browser_platform_delegate_native_aura.h"
#endif
namespace {
gfx::AcceleratedWidget GetParentWidget(const CefWindowInfo& window_info) {
@@ -61,6 +65,9 @@ class ChildWindowDelegate : public CefWindowDelegate {
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override {
browser_view_ = nullptr;
window_ = nullptr;
#if BUILDFLAG(IS_WIN)
native_delegate_ = nullptr;
#endif
}
CefRect GetInitialBounds(CefRefPtr<CefWindow> window) override {
@@ -71,22 +78,38 @@ class ChildWindowDelegate : public CefWindowDelegate {
return initial_bounds;
}
#if defined(USE_AURA)
void OnWindowBoundsChanged(CefRefPtr<CefWindow> window,
const CefRect& new_bounds) override {
if (native_delegate_) {
// Send new bounds to the renderer process and trigger the resize event.
native_delegate_->NotifyScreenInfoChanged();
}
}
#endif
private:
void ShowWindow() {
#if defined(USE_AURA)
auto browser = CefBrowserHostBase::FromBrowser(browser_view_->GetBrowser());
auto platform_delegate = browser->platform_delegate();
DCHECK(platform_delegate->IsViewsHosted());
auto chrome_delegate =
static_cast<CefBrowserPlatformDelegateChromeViews*>(platform_delegate);
native_delegate_ = static_cast<CefBrowserPlatformDelegateNativeAura*>(
chrome_delegate->native_delegate());
native_delegate_->InstallRootWindowBoundsCallback();
#if BUILDFLAG(IS_WIN)
auto widget = static_cast<CefWindowImpl*>(window_.get())->widget();
DCHECK(widget);
const HWND widget_hwnd = HWNDForWidget(widget);
DCHECK(widget_hwnd);
// The native delegate needs state to perform some actions.
auto browser = CefBrowserHostBase::FromBrowser(browser_view_->GetBrowser());
auto platform_delegate = browser->platform_delegate();
DCHECK(platform_delegate->IsViewsHosted());
auto chrome_delegate =
static_cast<CefBrowserPlatformDelegateChromeViews*>(platform_delegate);
auto native_delegate = static_cast<CefBrowserPlatformDelegateNativeWin*>(
chrome_delegate->native_delegate());
native_delegate->set_widget(widget, widget_hwnd);
// The Windows delegate needs state to perform some actions.
auto* delegate_win =
static_cast<CefBrowserPlatformDelegateNativeWin*>(native_delegate_);
delegate_win->set_widget(widget, widget_hwnd);
if (window_info_.ex_style & WS_EX_NOACTIVATE) {
const DWORD widget_ex_styles = GetWindowLongPtr(widget_hwnd, GWL_EXSTYLE);
@@ -105,6 +128,7 @@ class ChildWindowDelegate : public CefWindowDelegate {
return;
}
#endif // BUILDFLAG(IS_WIN)
#endif // defined(USE_AURA)
window_->Show();
@@ -112,7 +136,6 @@ class ChildWindowDelegate : public CefWindowDelegate {
browser_view_->RequestFocus();
}
private:
ChildWindowDelegate(CefRefPtr<CefBrowserView> browser_view,
const CefWindowInfo& window_info)
: browser_view_(browser_view), window_info_(window_info) {}
@@ -122,6 +145,11 @@ class ChildWindowDelegate : public CefWindowDelegate {
CefRefPtr<CefWindow> window_;
#if defined(USE_AURA)
base::raw_ptr<CefBrowserPlatformDelegateNativeAura> native_delegate_ =
nullptr;
#endif
IMPLEMENT_REFCOUNTING(ChildWindowDelegate);
};

View File

@@ -12,17 +12,19 @@
#include "base/task/current_thread.h"
#include "base/threading/thread_restrictions.h"
#include "cef/libcef/browser/browser_info_manager.h"
#include "cef/libcef/browser/prefs/pref_helper.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/browser/trace_subscriber.h"
#include "cef/libcef/common/cef_switches.h"
#include "chrome/browser/browser_process_impl.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "ui/base/ui_base_switches.h"
#if BUILDFLAG(IS_WIN)
#include "base/debug/alias.h"
#include "base/strings/utf_string_conversions.h"
#include "cef/include/internal/cef_win.h"
#include "cef/libcef/browser/preferred_stack_size_win.inc"
#include "chrome/chrome_elf/chrome_elf_main.h"
#include "chrome/install_static/initialize_from_primary_module.h"
#endif
@@ -183,112 +185,9 @@ 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
NO_STACK_PROTECTOR
int CefExecuteProcess(const CefMainArgs& args,
CefRefPtr<CefApp> application,
void* windows_sandbox_info) {
@@ -415,23 +314,6 @@ void CefQuitMessageLoop() {
#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 CefSetOSModalLoop(bool osModalLoop) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
@@ -570,12 +452,24 @@ CefTraceSubscriber* CefContext::GetTraceSubscriber() {
if (shutting_down_) {
return nullptr;
}
if (!trace_subscriber_.get()) {
if (!trace_subscriber_) {
trace_subscriber_ = std::make_unique<CefTraceSubscriber>();
}
return trace_subscriber_.get();
}
pref_helper::Registrar* CefContext::GetPrefRegistrar() {
CEF_REQUIRE_UIT();
if (shutting_down_) {
return nullptr;
}
if (!pref_registrar_) {
pref_registrar_ = std::make_unique<pref_helper::Registrar>();
pref_registrar_->Init(g_browser_process->local_state());
}
return pref_registrar_.get();
}
void CefContext::PopulateGlobalRequestContextSettings(
CefRequestContextSettings* settings) {
CefRefPtr<CefCommandLine> command_line =
@@ -645,12 +539,15 @@ void CefContext::ShutdownOnUIThread() {
observer.OnContextDestroyed();
}
if (trace_subscriber_.get()) {
trace_subscriber_.reset(nullptr);
if (trace_subscriber_) {
trace_subscriber_.reset();
}
if (pref_registrar_) {
pref_registrar_.reset();
}
}
void CefContext::FinalizeShutdown() {
browser_info_manager_.reset(nullptr);
browser_info_manager_.reset();
application_ = nullptr;
}

View File

@@ -16,6 +16,10 @@
#include "cef/libcef/browser/main_runner.h"
#include "third_party/skia/include/core/SkColor.h"
namespace pref_helper {
class Registrar;
}
class CefBrowserInfoManager;
class CefTraceSubscriber;
@@ -73,6 +77,7 @@ class CefContext {
cef_state_t windowless_state) const;
CefTraceSubscriber* GetTraceSubscriber();
pref_helper::Registrar* GetPrefRegistrar();
// Populate request context settings for the global system context based on
// CefSettings and command-line flags.
@@ -105,13 +110,14 @@ class CefContext {
int exit_code_ = -1;
// The thread on which the context was initialized.
base::PlatformThreadId init_thread_id_ = 0;
base::PlatformThreadId init_thread_id_;
CefSettings settings_;
CefRefPtr<CefApp> application_;
std::unique_ptr<CefMainRunner> main_runner_;
std::unique_ptr<CefTraceSubscriber> trace_subscriber_;
std::unique_ptr<pref_helper::Registrar> pref_registrar_;
std::unique_ptr<CefBrowserInfoManager> browser_info_manager_;
// Observers that want to be notified of changes to this object.

View File

@@ -0,0 +1,55 @@
// Copyright 2020 The Chromium Embedded Framework Authors.
// Portions copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/crashpad_runner.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "third_party/crashpad/crashpad/handler/handler_main.h"
namespace crashpad_runner {
// Based on components/crash/core/app/run_as_crashpad_handler_win.cc
int RunAsCrashpadHandler(const base::CommandLine& command_line) {
// Remove the "--type=crashpad-handler" command-line flag that will otherwise
// confuse the crashpad handler.
base::CommandLine::StringVector argv = command_line.argv();
const base::CommandLine::StringType process_type =
FILE_PATH_LITERAL("--type=");
argv.erase(
std::remove_if(argv.begin(), argv.end(),
[&process_type](const base::CommandLine::StringType& str) {
return base::StartsWith(str, process_type,
base::CompareCase::SENSITIVE) ||
(!str.empty() && str[0] == L'/');
}),
argv.end());
#if BUILDFLAG(IS_POSIX)
// HandlerMain on POSIX uses the system version of getopt_long which expects
// the first argument to be the program name.
argv.insert(argv.begin(), command_line.GetProgram().value());
#endif
std::unique_ptr<char*[]> argv_as_utf8(new char*[argv.size() + 1]);
std::vector<std::string> storage;
storage.reserve(argv.size());
for (size_t i = 0; i < argv.size(); ++i) {
#if BUILDFLAG(IS_WIN)
storage.push_back(base::WideToUTF8(argv[i]));
#else
storage.push_back(argv[i]);
#endif
argv_as_utf8[i] = &storage[i][0];
}
argv_as_utf8[argv.size()] = nullptr;
argv.clear();
return crashpad::HandlerMain(static_cast<int>(storage.size()),
argv_as_utf8.get(), nullptr);
}
} // namespace crashpad_runner

View File

@@ -0,0 +1,22 @@
// Copyright 2020 The Chromium Embedded Framework Authors.
// Portions copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_CRASHPAD_RUNNER_H_
#define CEF_LIBCEF_BROWSER_CRASHPAD_RUNNER_H_
#include "base/command_line.h"
namespace crashpad_runner {
// Chrome uses an embedded crashpad handler on Windows only and imports this
// function via the existing "run_as_crashpad_handler" target defined in
// components/crash/core/app/BUILD.gn. CEF uses an embedded handler on all
// platforms so we define the function here instead of using the existing
// target (because we can't use that target on macOS).
int RunAsCrashpadHandler(const base::CommandLine& command_line);
} // namespace crashpad_runner
#endif // CEF_LIBCEF_BROWSER_CRASHPAD_RUNNER_H_

View File

@@ -128,7 +128,7 @@ class CefSelectFileDialog final : public ui::SelectFileDialog {
}
private:
gfx::NativeWindow owning_window_ = nullptr;
gfx::NativeWindow owning_window_ = gfx::NativeWindow();
bool has_multiple_file_choices_ = false;
CefRefPtr<CefBrowserHostBase> browser_;

View File

@@ -4,10 +4,28 @@
#include "cef/libcef/browser/global_preference_manager_impl.h"
#include "base/metrics/field_trial_list_including_low_anonymity.h"
#include "base/strings/string_util.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/prefs/pref_helper.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/api_version_util.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/browser_process.h"
#include "components/variations/synthetic_trials_active_group_id_provider.h"
#include "components/webui/flags/pref_service_flags_storage.h"
namespace {
std::string GetActiveGroupNameAsString(
const base::FieldTrial::ActiveGroup& group) {
constexpr std::string_view kNonBreakingHyphenUTF8 = "\xE2\x80\x91";
std::string result = group.trial_name + ":" + group.group_name;
base::ReplaceChars(result, "-", kNonBreakingHyphenUTF8, &result);
return result;
}
} // namespace
bool CefGlobalPreferenceManagerImpl::HasPreference(const CefString& name) {
CEF_REQUIRE_UIT_RETURN(false);
@@ -40,6 +58,77 @@ bool CefGlobalPreferenceManagerImpl::SetPreference(const CefString& name,
value, error);
}
CefRefPtr<CefRegistration>
CefGlobalPreferenceManagerImpl::AddPreferenceObserver(
const CefString& name,
CefRefPtr<CefPreferenceObserver> observer) {
CEF_API_REQUIRE_ADDED(13401);
CEF_REQUIRE_UIT_RETURN(nullptr);
return CefContext::Get()->GetPrefRegistrar()->AddObserver(name, observer);
}
// static
void CefPreferenceManager::GetChromeVariationsAsSwitches(
std::vector<CefString>& switches) {
CEF_API_REQUIRE_ADDED(13401);
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
DCHECK(false) << "context not valid";
return;
}
switches.clear();
// Based on ChromeFeatureListCreator::ConvertFlagsToSwitches().
flags_ui::PrefServiceFlagsStorage flags_storage(
g_browser_process->local_state());
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
about_flags::ConvertFlagsToSwitches(&flags_storage, &command_line,
flags_ui::kNoSentinels);
for (const auto& arg : command_line.argv()) {
if (!arg.empty()) {
switches.push_back(arg);
}
}
}
// static
void CefPreferenceManager::GetChromeVariationsAsStrings(
std::vector<CefString>& strings) {
CEF_API_REQUIRE_ADDED(13401);
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
DCHECK(false) << "context not valid";
return;
}
strings.clear();
// Based on components/webui/version/version_handler_helper.cc
// GetVariationsList().
base::FieldTrial::ActiveGroups active_groups;
// Include low anonymity trial groups in the version string, as it is only
// displayed locally (and is useful for diagnostics purposes).
base::FieldTrialListIncludingLowAnonymity::
GetActiveFieldTrialGroupsForTesting(&active_groups);
for (const auto& group : active_groups) {
strings.push_back(GetActiveGroupNameAsString(group));
}
// Synthetic field trials.
for (const auto& group :
variations::SyntheticTrialsActiveGroupIdProvider::GetInstance()
->GetGroups()) {
strings.push_back(GetActiveGroupNameAsString(group.active_group()));
}
}
// static
CefRefPtr<CefPreferenceManager>
CefPreferenceManager::GetGlobalPreferenceManager() {

View File

@@ -27,6 +27,9 @@ class CefGlobalPreferenceManagerImpl : public CefPreferenceManager {
bool SetPreference(const CefString& name,
CefRefPtr<CefValue> value,
CefString& error) override;
CefRefPtr<CefRegistration> AddPreferenceObserver(
const CefString& name,
CefRefPtr<CefPreferenceObserver> observer) override;
private:
IMPLEMENT_REFCOUNTING(CefGlobalPreferenceManagerImpl);

View File

@@ -13,11 +13,13 @@
#include "base/synchronization/waitable_event.h"
#include "cef/libcef/browser/browser_message_loop.h"
#include "cef/libcef/browser/chrome/chrome_content_browser_client_cef.h"
#include "cef/libcef/browser/crashpad_runner.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/app_manager.h"
#include "cef/libcef/common/cef_switches.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/chrome_process_singleton.h"
#include "chrome/chrome_elf/chrome_elf_main.h"
#include "chrome/common/chrome_result_codes.h"
#include "components/crash/core/app/crash_switches.h"
#include "components/keep_alive_registry/keep_alive_types.h"
@@ -27,7 +29,6 @@
#include "content/public/app/content_main.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h"
#include "third_party/crashpad/crashpad/handler/handler_main.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
@@ -35,57 +36,11 @@
#include <memory>
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/policy/mojom/sandbox.mojom.h"
#include "sandbox/policy/sandbox_type.h"
#include "sandbox/win/src/sandbox_types.h"
#endif
namespace {
// Based on components/crash/core/app/run_as_crashpad_handler_win.cc
// Remove the "--type=crashpad-handler" command-line flag that will otherwise
// confuse the crashpad handler.
// Chrome uses an embedded crashpad handler on Windows only and imports this
// function via the existing "run_as_crashpad_handler" target defined in
// components/crash/core/app/BUILD.gn. CEF uses an embedded handler on all
// platforms so we define the function here instead of using the existing
// target (because we can't use that target on macOS).
int RunAsCrashpadHandler(const base::CommandLine& command_line) {
base::CommandLine::StringVector argv = command_line.argv();
const base::CommandLine::StringType process_type =
FILE_PATH_LITERAL("--type=");
argv.erase(
std::remove_if(argv.begin(), argv.end(),
[&process_type](const base::CommandLine::StringType& str) {
return base::StartsWith(str, process_type,
base::CompareCase::SENSITIVE) ||
(!str.empty() && str[0] == L'/');
}),
argv.end());
#if BUILDFLAG(IS_POSIX)
// HandlerMain on POSIX uses the system version of getopt_long which expects
// the first argument to be the program name.
argv.insert(argv.begin(), command_line.GetProgram().value());
#endif
std::unique_ptr<char*[]> argv_as_utf8(new char*[argv.size() + 1]);
std::vector<std::string> storage;
storage.reserve(argv.size());
for (size_t i = 0; i < argv.size(); ++i) {
#if BUILDFLAG(IS_WIN)
storage.push_back(base::WideToUTF8(argv[i]));
#else
storage.push_back(argv[i]);
#endif
argv_as_utf8[i] = &storage[i][0];
}
argv_as_utf8[argv.size()] = nullptr;
argv.clear();
return crashpad::HandlerMain(static_cast<int>(storage.size()),
argv_as_utf8.get(), nullptr);
}
} // namespace
CefMainRunner::CefMainRunner(bool multi_threaded_message_loop,
bool external_message_pump)
: multi_threaded_message_loop_(multi_threaded_message_loop),
@@ -117,8 +72,7 @@ bool CefMainRunner::Initialize(CefSettings* settings,
if (exit_code_ != content::RESULT_CODE_NORMAL_EXIT) {
// Some exit codes are used to exit early, but are otherwise a normal
// result. Don't log for those codes.
if (!chrome::IsNormalResultCode(
static_cast<chrome::ResultCode>(exit_code_))) {
if (!IsNormalResultCode(static_cast<ResultCode>(exit_code_))) {
LOG(ERROR) << "ContentMainRun failed with exit code " << exit_code_;
}
return false;
@@ -207,6 +161,7 @@ void CefMainRunner::QuitMessageLoop() {
}
// static
NO_STACK_PROTECTOR
int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args,
CefRefPtr<CefApp> application,
void* windows_sandbox_info) {
@@ -224,10 +179,15 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args,
// If no process type is specified then it represents the browser process and
// we do nothing.
if (!command_line.HasSwitch(switches::kProcessType)) {
return -1;
}
const std::string& process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
if (process_type.empty()) {
return -1;
// Early exit on invalid process type.
return CEF_RESULT_CODE_BAD_PROCESS_TYPE;
}
auto main_delegate = std::make_unique<ChromeMainDelegateCef>(
@@ -235,15 +195,35 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args,
BeforeMainInitialize(args);
if (process_type == crash_reporter::switches::kCrashpadHandler) {
return RunAsCrashpadHandler(command_line);
return crashpad_runner::RunAsCrashpadHandler(command_line);
}
// Execute the secondary process.
content::ContentMainParams main_params(main_delegate.get());
#if BUILDFLAG(IS_WIN)
// Initialize the sandbox services.
// Match the logic in MainDllLoader::Launch.
sandbox::SandboxInterfaceInfo sandbox_info = {nullptr};
if (windows_sandbox_info == nullptr) {
content::InitializeSandboxInfo(&sandbox_info);
// IsUnsandboxedSandboxType() can't be used here because its result can be
// gated behind a feature flag, which are not yet initialized.
const bool is_sandboxed =
sandbox::policy::SandboxTypeFromCommandLine(command_line) !=
sandbox::mojom::Sandbox::kNoSandbox;
// When using cef_sandbox_info_create() the sandbox info will always be
// initialized. This is incorrect for cases where the sandbox is disabled, and
// we adjust for that here.
if (!is_sandboxed || windows_sandbox_info == nullptr) {
if (is_sandboxed) {
// For child processes that are running as --no-sandbox, don't
// initialize the sandbox info, otherwise they'll be treated as brokers
// (as if they were the browser).
content::InitializeSandboxInfo(
&sandbox_info, IsExtensionPointDisableSet()
? sandbox::MITIGATION_EXTENSION_POINT_DISABLE
: 0);
}
windows_sandbox_info = &sandbox_info;
}
@@ -460,7 +440,7 @@ void CefMainRunner::FinishShutdownOnUIThread() {
ChromeProcessSingleton::DeleteInstance();
}
static_cast<content::ContentMainRunnerImpl*>(main_runner_.get())
static_cast<content::ContentMainRunnerImpl*>(main_runner_.get())
->ShutdownOnUIThread();
}

View File

@@ -215,8 +215,10 @@ class CefMediaAccessQuery {
content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN,
-1 /* webrtc::kFullDesktopScreenId */);
}
video_devices.emplace_back(request_.video_type, media_id.ToString(),
"Screen");
if (media_id.type != content::DesktopMediaID::TYPE_NONE) {
video_devices.emplace_back(request_.video_type, media_id.ToString(),
"Screen");
}
}
blink::mojom::StreamDevicesSetPtr stream_devices_set =

View File

@@ -20,6 +20,12 @@
#include "content/public/browser/render_widget_host_view.h"
#include "third_party/blink/public/mojom/context_menu/context_menu.mojom.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "components/spellcheck/browser/spellcheck_platform.h"
#endif
namespace {
CefString GetLabel(int message_id) {
@@ -120,8 +126,8 @@ bool CefMenuManager::IsShowingContextMenu() {
return web_contents()->IsShowingContextMenu();
}
bool CefMenuManager::CreateContextMenu(
const content::ContextMenuParams& params) {
bool CefMenuManager::CreateContextMenu(const content::ContextMenuParams& params,
bool query_spellcheck) {
// The renderer may send the "show context menu" message multiple times, one
// for each right click mouse event it receives. Normally, this doesn't happen
// because mouse events are not forwarded once the context menu is showing.
@@ -134,6 +140,24 @@ bool CefMenuManager::CreateContextMenu(
}
params_ = params;
#if BUILDFLAG(IS_WIN)
// System spellcheck suggestions need to be queried asynchronously.
if (query_spellcheck && !params_.misspelled_word.empty() &&
params_.dictionary_suggestions.empty()) {
SpellcheckService* spellcheck_service =
SpellcheckServiceFactory::GetForContext(
browser_->web_contents()->GetBrowserContext());
if (spellcheck_service) {
spellcheck_platform::GetPerLanguageSuggestions(
spellcheck_service->platform_spell_checker(), params_.misspelled_word,
base::BindOnce(&CefMenuManager::OnGetPlatformSuggestionsComplete,
weak_ptr_factory_.GetWeakPtr()));
}
return true;
}
#endif
model_->Clear();
// Create the default menu model.
@@ -511,3 +535,18 @@ bool CefMenuManager::IsCustomContextMenuCommand(int command_id) {
}
return false;
}
#if BUILDFLAG(IS_WIN)
void CefMenuManager::OnGetPlatformSuggestionsComplete(
const spellcheck::PerLanguageSuggestions&
platform_per_language_suggestions) {
std::vector<std::u16string> combined_suggestions;
spellcheck::FillSuggestions(platform_per_language_suggestions,
&combined_suggestions);
params_.dictionary_suggestions = combined_suggestions;
// Now that we have spelling suggestions, call CreateContextMenu again.
CreateContextMenu(params_, /*query_spellcheck=*/false);
}
#endif

View File

@@ -13,6 +13,10 @@
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/web_contents_observer.h"
#if BUILDFLAG(IS_WIN)
#include "components/spellcheck/common/spellcheck_common.h"
#endif
namespace content {
class RenderFrameHost;
class WebContents;
@@ -39,7 +43,8 @@ class CefMenuManager : public CefMenuModelImpl::Delegate,
bool IsShowingContextMenu();
// Create the context menu.
bool CreateContextMenu(const content::ContextMenuParams& params);
bool CreateContextMenu(const content::ContextMenuParams& params,
bool query_spellcheck = true);
void CancelContextMenu();
private:
@@ -62,6 +67,12 @@ class CefMenuManager : public CefMenuModelImpl::Delegate,
// Returns true if the specified id is a custom context menu command.
bool IsCustomContextMenuCommand(int command_id);
#if BUILDFLAG(IS_WIN)
void OnGetPlatformSuggestionsComplete(
const spellcheck::PerLanguageSuggestions&
platform_per_language_suggestions);
#endif
// AlloyBrowserHostImpl pointer is guaranteed to outlive this object.
raw_ptr<AlloyBrowserHostImpl> browser_;

View File

@@ -5,6 +5,7 @@
#include "cef/libcef/browser/native/browser_platform_delegate_native.h"
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
@@ -24,3 +25,25 @@ void CefBrowserPlatformDelegateNative::WasResized() {
host->GetWidget()->SynchronizeVisualProperties();
}
}
void CefBrowserPlatformDelegateNative::NotifyScreenInfoChanged() {
content::RenderWidgetHostImpl* render_widget_host = nullptr;
if (web_contents_) {
if (auto* rvh = web_contents_->GetRenderViewHost()) {
render_widget_host =
content::RenderWidgetHostImpl::From(rvh->GetWidget());
}
}
if (!render_widget_host) {
return;
}
// Send updated screen bounds information to the renderer process.
if (render_widget_host->delegate()) {
render_widget_host->delegate()->SendScreenRects();
} else {
render_widget_host->SendScreenRects();
}
render_widget_host->NotifyScreenInfoChanged();
}

View File

@@ -32,6 +32,7 @@ class CefBrowserPlatformDelegateNative
// CefBrowserPlatformDelegate methods:
SkColor GetBackgroundColor() const override;
void WasResized() override;
void NotifyScreenInfoChanged() override;
// Translate CEF events to Chromium/Blink Web events.
virtual input::NativeWebKeyboardEvent TranslateWebKeyEvent(

View File

@@ -4,6 +4,7 @@
#include "cef/libcef/browser/native/browser_platform_delegate_native_aura.h"
#include "cef/libcef/browser/browser_host_base.h"
#include "cef/libcef/browser/native/menu_runner_views_aura.h"
#include "cef/libcef/browser/views/view_util.h"
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
@@ -19,6 +20,42 @@ CefBrowserPlatformDelegateNativeAura::CefBrowserPlatformDelegateNativeAura(
SkColor background_color)
: CefBrowserPlatformDelegateNative(window_info, background_color) {}
void CefBrowserPlatformDelegateNativeAura::InstallRootWindowBoundsCallback() {
auto* host_view = GetHostView();
CHECK(host_view);
host_view->SetRootWindowBoundsCallback(base::BindRepeating(
[](base::WeakPtr<CefBrowserPlatformDelegateNativeAura> self) {
return self->RootWindowBoundsCallback();
},
weak_ptr_factory_.GetWeakPtr()));
}
std::optional<gfx::Rect>
CefBrowserPlatformDelegateNativeAura::RootWindowBoundsCallback() {
if (browser_) {
if (auto client = browser_->client()) {
if (auto handler = client->GetDisplayHandler()) {
CefRect rect;
if (handler->GetRootWindowScreenRect(browser_.get(), rect) &&
!rect.IsEmpty()) {
return gfx::Rect(rect.x, rect.y, rect.width, rect.height);
}
}
}
}
// Call the default platform implementation, if any.
return GetRootWindowBounds();
}
void CefBrowserPlatformDelegateNativeAura::RenderViewReady() {
CefBrowserPlatformDelegateNative::RenderViewReady();
// The RWHV should now exist for Alloy style browsers.
InstallRootWindowBoundsCallback();
}
void CefBrowserPlatformDelegateNativeAura::SendKeyEvent(
const CefKeyEvent& event) {
auto view = GetHostView();

View File

@@ -5,19 +5,19 @@
#ifndef CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_AURA_H_
#define CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_AURA_H_
#include <optional>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "cef/libcef/browser/native/browser_platform_delegate_native.h"
#include "ui/events/event.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/vector2d.h"
namespace content {
class RenderWidgetHostViewAura;
}
namespace gfx {
class Vector2d;
}
// Windowed browser implementation for Aura platforms.
class CefBrowserPlatformDelegateNativeAura
: public CefBrowserPlatformDelegateNative {
@@ -25,7 +25,10 @@ class CefBrowserPlatformDelegateNativeAura
CefBrowserPlatformDelegateNativeAura(const CefWindowInfo& window_info,
SkColor background_color);
void InstallRootWindowBoundsCallback();
// CefBrowserPlatformDelegate methods:
void RenderViewReady() override;
void SendKeyEvent(const CefKeyEvent& event) override;
void SendMouseClickEvent(const CefMouseEvent& event,
CefBrowserHost::MouseButtonType type,
@@ -71,9 +74,16 @@ class CefBrowserPlatformDelegateNativeAura
int deltaY) const;
virtual gfx::Vector2d GetUiWheelEventOffset(int deltaX, int deltaY) const;
// Returns the root window bounds in screen DIP coordinates.
virtual std::optional<gfx::Rect> GetRootWindowBounds() {
return std::nullopt;
}
protected:
base::OnceClosure GetWidgetDeleteCallback();
std::optional<gfx::Rect> RootWindowBoundsCallback();
static base::TimeTicks GetEventTimeStamp();
static int TranslateUiEventModifiers(uint32_t cef_modifiers);
static int TranslateUiChangedButtonFlags(uint32_t cef_modifiers);

View File

@@ -73,7 +73,7 @@ CefRect GetScreenFrameRectFromDIPContentRect(HWND window,
// 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);
display::win::GetScreenWin()->DIPToScreenRect(window, dip_rect);
RECT rect = {screen_rect.x(), screen_rect.y(),
screen_rect.x() + screen_rect.width(),
@@ -109,7 +109,7 @@ CefRect GetAdjustedScreenFrameRect(CefRect screen_rect,
// Convert to DIP using a method that can handle multiple displays with
// different DPI.
const auto dip_rect = display::win::ScreenWin::ScreenToDIPRect(
const auto dip_rect = display::win::GetScreenWin()->ScreenToDIPRect(
nullptr, gfx::Rect(screen_rect.x, screen_rect.y, screen_rect.width,
screen_rect.height));
const auto visible_dip_rect = MakeVisibleOnScreenRect(
@@ -173,10 +173,11 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
window_info_.parent_window, window_info_.menu,
::GetModuleHandle(nullptr), this);
// It's possible for CreateWindowEx to fail if the parent window was
// destroyed between the call to CreateBrowser and the above one.
DCHECK(window_info_.window);
if (!window_info_.window) {
// It's possible for CreateWindowEx to fail if the parent window was destroyed
// between the call to CreateBrowser and the above one. It's also possible
// that |browser_| will be nullptr if BrowserDestroyed() was called during
// this time.
if (!window_info_.window || !browser_) {
return false;
}
@@ -205,7 +206,7 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
// 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(
const gfx::Rect dip_rect = display::win::GetScreenWin()->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.
@@ -426,6 +427,27 @@ CefEventHandle CefBrowserPlatformDelegateNativeWin::GetEventHandle(
const_cast<CHROME_MSG*>(&event.os_event->native_event()));
}
std::optional<gfx::Rect>
CefBrowserPlatformDelegateNativeWin::GetRootWindowBounds() {
if (window_widget_) {
if (HWND hwnd = GetHostWindowHandle()) {
if (HWND root_hwnd = ::GetAncestor(hwnd, GA_ROOT)) {
RECT root_rect = {};
if (::GetWindowRect(root_hwnd, &root_rect)) {
auto* top_level =
window_widget_->GetNativeWindow()->GetToplevelWindow();
gfx::Rect bounds(root_rect);
bounds = display::Screen::GetScreen()->ScreenToDIPRectInWindow(
top_level, bounds);
return bounds;
}
}
}
}
return std::nullopt;
}
ui::KeyEvent CefBrowserPlatformDelegateNativeWin::TranslateUiKeyEvent(
const CefKeyEvent& key_event) const {
int flags = TranslateUiEventModifiers(key_event.modifiers);
@@ -569,10 +591,14 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
// Clear the user data pointer.
gfx::SetWindowUserData(hwnd, nullptr);
// Force the browser to be destroyed. This will result in a call to
// BrowserDestroyed() that will release the reference added in
// CreateHostWindow().
AlloyBrowserHostImpl::FromBaseChecked(browser)->WindowDestroyed();
// |browser| may be nullptr if the window was destroyed during browser
// creation (e.g. CreateHostWindow() returned false).
if (browser) {
// Force the browser to be destroyed. This will result in a call to
// BrowserDestroyed() that will release the reference added in
// CreateHostWindow().
AlloyBrowserHostImpl::FromBaseChecked(browser)->WindowDestroyed();
}
}
break;
@@ -591,8 +617,8 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
case WM_MOVING:
case WM_MOVE:
if (browser) {
browser->NotifyMoveOrResizeStarted();
if (platform_delegate) {
platform_delegate->NotifyMoveOrResizeStarted();
}
return 0;

View File

@@ -32,6 +32,7 @@ class CefBrowserPlatformDelegateNativeWin
bool HandleKeyboardEvent(const input::NativeWebKeyboardEvent& event) override;
CefEventHandle GetEventHandle(
const input::NativeWebKeyboardEvent& event) const override;
std::optional<gfx::Rect> GetRootWindowBounds() override;
// CefBrowserPlatformDelegateNativeAura methods:
ui::KeyEvent TranslateUiKeyEvent(const CefKeyEvent& key_event) const override;

View File

@@ -21,8 +21,7 @@ bool CefMenuRunnerMac::RunContextMenu(
// Create a menu controller based on the model.
MenuControllerCocoa* menu_controller =
[[MenuControllerCocoa alloc] initWithModel:model->model()
delegate:nil
useWithPopUpButtonCell:NO];
delegate:nil];
menu_controller_ = menu_controller;

View File

@@ -68,8 +68,10 @@ void CefWindowDelegateView::Init(gfx::AcceleratedWidget parent_widget,
DCHECK(widget->widget_delegate()->CanActivate());
// WidgetDelegate::DeleteDelegate() will execute the registered callback.
RegisterDeleteDelegateCallback(base::BindOnce(
&CefWindowDelegateView::DeleteDelegate, base::Unretained(this)));
RegisterDeleteDelegateCallback(
RegisterDeleteCallbackPassKey(),
base::BindOnce(&CefWindowDelegateView::DeleteDelegate,
base::Unretained(this)));
}
void CefWindowDelegateView::InitContent() {

View File

@@ -18,8 +18,13 @@ namespace throttle {
namespace {
bool NavigationOnUIThread(content::NavigationHandle* navigation_handle) {
void NavigationOnUIThread(
content::NavigationHandle* navigation_handle,
bool should_run_async,
navigation_interception::InterceptNavigationThrottle::ResultCallback
result_callback) {
CEF_REQUIRE_UIT();
CHECK(!should_run_async);
const bool is_main_frame = navigation_handle->IsInMainFrame();
const auto global_id = frame_util::GetGlobalId(navigation_handle);
@@ -45,7 +50,8 @@ bool NavigationOnUIThread(content::NavigationHandle* navigation_handle) {
navigation_handle->GetWebContents()->GetPrimaryMainFrame(),
open_params, browser)) {
// Cancel the navigation.
return true;
std::move(result_callback).Run(true);
return;
}
bool ignore_navigation = false;
@@ -81,24 +87,24 @@ bool NavigationOnUIThread(content::NavigationHandle* navigation_handle) {
}
}
return ignore_navigation;
std::move(result_callback).Run(ignore_navigation);
}
} // namespace
void CreateThrottlesForNavigation(content::NavigationHandle* navigation_handle,
NavigationThrottleList& throttles) {
void CreateThrottlesForNavigation(
content::NavigationThrottleRegistry& registry) {
CEF_REQUIRE_UIT();
// Must use SynchronyMode::kSync to ensure that OnBeforeBrowse is always
// called before OnBeforeResourceLoad.
std::unique_ptr<content::NavigationThrottle> throttle =
std::make_unique<navigation_interception::InterceptNavigationThrottle>(
navigation_handle, base::BindRepeating(&NavigationOnUIThread),
navigation_interception::SynchronyMode::kSync);
registry, base::BindRepeating(&NavigationOnUIThread),
navigation_interception::SynchronyMode::kSync, std::nullopt);
// Always execute our throttle first.
throttles.emplace(throttles.begin(), std::move(throttle));
registry.AddThrottle(std::move(throttle), /*first=*/true);
}
} // namespace throttle

View File

@@ -6,21 +6,14 @@
#define CEF_LIBCEF_BROWSER_NET_THROTTLE_HANDLER_H_
#pragma once
#include <memory>
#include <vector>
namespace content {
class NavigationHandle;
class NavigationThrottle;
class NavigationThrottleRegistry;
} // namespace content
namespace throttle {
using NavigationThrottleList =
std::vector<std::unique_ptr<content::NavigationThrottle>>;
void CreateThrottlesForNavigation(content::NavigationHandle* navigation_handle,
NavigationThrottleList& throttles);
void CreateThrottlesForNavigation(
content::NavigationThrottleRegistry& registry);
} // namespace throttle

View File

@@ -202,7 +202,8 @@ void SaveCookiesOnUIThread(
}
net::CookieInclusionStatus status;
status.AddExclusionReason(net::CookieInclusionStatus::EXCLUDE_UNKNOWN_ERROR);
status.AddExclusionReason(
net::CookieInclusionStatus::ExclusionReason::EXCLUDE_UNKNOWN_ERROR);
SetCanonicalCookieCallback(progress, net::CanonicalCookie(),
net::CookieAccessResult(std::move(status)));
}
@@ -251,7 +252,7 @@ void LoadCookies(const CefBrowserContext::Getter& browser_context_getter,
if (request.trusted_params.has_value() &&
!request.trusted_params->isolation_info.IsEmpty()) {
const auto& isolation_info = request.trusted_params->isolation_info;
partition_key_collection = net::CookiePartitionKeyCollection::FromOptional(
partition_key_collection = net::CookiePartitionKeyCollection(
net::CookiePartitionKey::FromNetworkIsolationKey(
isolation_info.network_isolation_key(), request.site_for_cookies,
net::SchemefulSite(request.url),

View File

@@ -307,7 +307,7 @@ bool CefCookieManagerImpl::SetCookieInternal(
if (!canonical_cookie) {
net::CookieInclusionStatus status;
status.AddExclusionReason(
net::CookieInclusionStatus::EXCLUDE_UNKNOWN_ERROR);
net::CookieInclusionStatus::ExclusionReason::EXCLUDE_UNKNOWN_ERROR);
SetCookieCallbackImpl(callback, net::CookieAccessResult(std::move(status)));
return true;
}

View File

@@ -111,11 +111,12 @@ void RunCallbackOnIOThread(
}
} // namespace
LoginDelegate::LoginDelegate(const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
const content::GlobalRequestID& request_id,
const GURL& origin_url,
LoginAuthRequiredCallback callback)
LoginDelegate::LoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
const content::GlobalRequestID& request_id,
const GURL& origin_url,
content::LoginDelegate::LoginAuthRequiredCallback callback)
: callback_(std::move(callback)), weak_ptr_factory_(this) {
CEF_REQUIRE_UIT();

View File

@@ -29,7 +29,7 @@ class LoginDelegate : public content::LoginDelegate {
content::WebContents* web_contents,
const content::GlobalRequestID& request_id,
const GURL& origin_url,
LoginAuthRequiredCallback callback);
content::LoginDelegate::LoginAuthRequiredCallback callback);
void Continue(const CefString& username, const CefString& password);
void Cancel();
@@ -40,7 +40,7 @@ class LoginDelegate : public content::LoginDelegate {
const content::GlobalRequestID& request_id,
const GURL& origin_url);
LoginAuthRequiredCallback callback_;
content::LoginDelegate::LoginAuthRequiredCallback callback_;
base::WeakPtrFactory<LoginDelegate> weak_ptr_factory_;
};

View File

@@ -103,8 +103,8 @@ class ResourceContextData : public base::SupportsUserData::Data {
// Maybe the browser was destroyed while AddProxyOnUIThread was pending.
if (!web_contents) {
// Delete on the IO thread as expected by mojo bindings.
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
proxy);
content::BrowserThread::GetTaskRunnerForThread(CEF_IOT)->DeleteSoon(
FROM_HERE, proxy);
return;
}
@@ -263,8 +263,6 @@ class InterceptedRequest : public network::mojom::URLLoader,
const std::optional<GURL>& new_url) override;
void SetPriority(net::RequestPriority priority,
int32_t intra_priority_value) override;
void PauseReadingBodyFromNet() override;
void ResumeReadingBodyFromNet() override;
int32_t id() const { return id_; }
@@ -343,6 +341,7 @@ class InterceptedRequest : public network::mojom::URLLoader,
network::URLLoaderCompletionStatus status_;
bool got_loader_error_ = false;
bool completed_ = false;
// Used for rate limiting OnUploadProgress callbacks.
bool waiting_for_upload_progress_ack_ = false;
@@ -764,18 +763,6 @@ void InterceptedRequest::SetPriority(net::RequestPriority priority,
}
}
void InterceptedRequest::PauseReadingBodyFromNet() {
if (target_loader_) {
target_loader_->PauseReadingBodyFromNet();
}
}
void InterceptedRequest::ResumeReadingBodyFromNet() {
if (target_loader_) {
target_loader_->ResumeReadingBodyFromNet();
}
}
// Helper methods.
void InterceptedRequest::BeforeRequestReceived(const GURL& original_url,
@@ -1155,7 +1142,17 @@ void InterceptedRequest::OnDestroy() {
// We don't want any callbacks after this point.
weak_factory_.InvalidateWeakPtrs();
factory_->request_handler_->OnRequestComplete(id_, request_, status_);
bool handled_externally = false;
factory_->request_handler_->OnRequestComplete(id_, request_, status_,
handled_externally);
// Don't call OnComplete() if an unhandled request might be handled
// externally. The request will instead be canceled implicitly with
// ERR_ABORTED.
if (!handled_externally && target_client_ && !completed_) {
target_client_->OnComplete(status_);
completed_ = true;
}
// Destroys |this|.
factory_->RemoveRequest(this);
@@ -1207,6 +1204,7 @@ void InterceptedRequest::CallOnComplete(
if (target_client_) {
target_client_->OnComplete(status);
completed_ = true;
}
if (proxied_loader_receiver_.is_bound() &&
@@ -1241,7 +1239,6 @@ void InterceptedRequest::SendErrorStatusAndCompleteImmediately(
const network::URLLoaderCompletionStatus& status) {
status_ = status;
SendErrorCallback(status_.error_code, false);
target_client_->OnComplete(status_);
OnDestroy();
}

View File

@@ -121,7 +121,8 @@ class InterceptedRequestHandler {
virtual void OnRequestComplete(
int32_t request_id,
const network::ResourceRequest& request,
const network::URLLoaderCompletionStatus& status) {}
const network::URLLoaderCompletionStatus& status,
bool& handled_externally) {}
// Called on error.
virtual void OnRequestError(int32_t request_id,

View File

@@ -1069,10 +1069,10 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
}
}
void OnRequestComplete(
int32_t request_id,
const network::ResourceRequest& request,
const network::URLLoaderCompletionStatus& status) override {
void OnRequestComplete(int32_t request_id,
const network::ResourceRequest& request,
const network::URLLoaderCompletionStatus& status,
bool& handled_externally) override {
CEF_REQUIRE_IOT();
RequestState* state = GetState(request_id);
@@ -1116,6 +1116,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
init_state_->browser_, init_state_->frame_,
state->pending_request_.get(), allow_os_execution);
if (allow_os_execution && init_state_->unhandled_request_callback_) {
handled_externally = true;
CEF_POST_TASK(TID_UI, init_state_->unhandled_request_callback_);
}
}

View File

@@ -584,10 +584,6 @@ void StreamReaderURLLoader::FollowRedirect(
void StreamReaderURLLoader::SetPriority(net::RequestPriority priority,
int intra_priority_value) {}
void StreamReaderURLLoader::PauseReadingBodyFromNet() {}
void StreamReaderURLLoader::ResumeReadingBodyFromNet() {}
void StreamReaderURLLoader::OnInputStreamOpened(
std::unique_ptr<StreamReaderURLLoader::Delegate> returned_delegate,
std::unique_ptr<InputStream> input_stream) {

View File

@@ -137,8 +137,6 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
const std::optional<GURL>& new_url) override;
void SetPriority(net::RequestPriority priority,
int intra_priority_value) override;
void PauseReadingBodyFromNet() override;
void ResumeReadingBodyFromNet() override;
private:
void ContinueWithRequestHeaders(

View File

@@ -197,7 +197,7 @@ struct PopulateAxNodeAttributes {
case ax::mojom::IntAttribute::kAriaNotificationPriorityDeprecated: {
auto state =
static_cast<ax::mojom::AriaNotificationPriority>(attr.second);
if (ax::mojom::AriaNotificationPriority::kNone != state) {
if (ax::mojom::AriaNotificationPriority::kNormal != state) {
attributes->SetString(ToString(attr.first), ToString(state));
}
} break;

View File

@@ -238,8 +238,7 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
root_layer_ = std::make_unique<ui::Layer>(ui::LAYER_SOLID_COLOR);
bool opaque = SkColorGetA(background_color_) == SK_AlphaOPAQUE;
GetRootLayer()->SetFillsBoundsOpaquely(opaque);
// Opacity of SOLID_COLOR layer is determined by the color's alpha channel.
GetRootLayer()->SetColor(background_color_);
external_begin_frame_enabled_ = use_external_begin_frame;
@@ -444,7 +443,9 @@ void CefRenderWidgetHostViewOSR::Hide() {
}
if (render_widget_host_) {
render_widget_host_->WasHidden();
if (render_widget_host_->delegate()) {
render_widget_host_->WasHidden();
}
auto provider = content::RenderWidgetHostImpl::From(render_widget_host_)
->render_frame_metadata_provider();
@@ -502,7 +503,11 @@ CefRenderWidgetHostViewOSR::GetDisplayFeature() {
return std::nullopt;
}
void CefRenderWidgetHostViewOSR::SetDisplayFeatureForTesting(
void CefRenderWidgetHostViewOSR::DisableDisplayFeatureOverrideForEmulation() {
DCHECK(false);
}
void CefRenderWidgetHostViewOSR::OverrideDisplayFeatureForEmulation(
const content::DisplayFeature* display_feature) {
DCHECK(false);
}
@@ -1865,8 +1870,7 @@ void CefRenderWidgetHostViewOSR::RequestImeCompositionUpdate(
void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged(
const gfx::Range& range,
const std::optional<std::vector<gfx::Rect>>& character_bounds,
const std::optional<std::vector<gfx::Rect>>& line_bounds) {
const std::optional<std::vector<gfx::Rect>>& character_bounds) {
if (browser_impl_.get()) {
CefRange cef_range(range.start(), range.end());
CefRenderHandler::RectList rcList;

View File

@@ -132,7 +132,8 @@ class CefRenderWidgetHostViewOSR
std::optional<SkColor> GetBackgroundColor() override;
void UpdateBackgroundColor() override;
std::optional<content::DisplayFeature> GetDisplayFeature() override;
void SetDisplayFeatureForTesting(
void DisableDisplayFeatureOverrideForEmulation() override;
void OverrideDisplayFeatureForEmulation(
const content::DisplayFeature* display_feature) override;
blink::mojom::PointerLockResult LockPointer(
bool request_unadjusted_movement) override;
@@ -185,8 +186,7 @@ class CefRenderWidgetHostViewOSR
viz::SurfaceId GetCurrentSurfaceId() const override;
void ImeCompositionRangeChanged(
const gfx::Range& range,
const std::optional<std::vector<gfx::Rect>>& character_bounds,
const std::optional<std::vector<gfx::Rect>>& line_bounds) override;
const std::optional<std::vector<gfx::Rect>>& character_bounds) override;
std::unique_ptr<content::SyntheticGestureTarget>
CreateSyntheticGestureTarget() override;
bool TransformPointToCoordSpaceForView(

View File

@@ -92,7 +92,7 @@ void SoftwareOutputDeviceProxy::Resize(const gfx::Size& viewport_pixel_size,
canvas_ = skia::CreatePlatformCanvasWithPixels(
viewport_pixel_size_.width(), viewport_pixel_size_.height(), false,
static_cast<uint8_t*>(shm_.memory()), skia::CRASH_ON_FAILURE);
static_cast<uint8_t*>(shm_.memory()), 0U, skia::CRASH_ON_FAILURE);
#else
canvas_ = skia::CreatePlatformCanvasWithSharedSection(
viewport_pixel_size_.width(), viewport_pixel_size_.height(), false,

View File

@@ -175,7 +175,7 @@ void CefVideoConsumerOSR::OnFrameCaptured(
auto& gmb_handle = data->get_gpu_memory_buffer_handle();
cef_accelerated_paint_info_t paint_info;
paint_info.extra = extra;
paint_info.shared_texture_handle = gmb_handle.dxgi_handle.Get();
paint_info.shared_texture_handle = gmb_handle.dxgi_handle().buffer_handle();
paint_info.format = pixel_format;
view_->OnAcceleratedPaint(damage_rect, info->coded_size, paint_info);
#elif BUILDFLAG(IS_APPLE)
@@ -187,7 +187,7 @@ void CefVideoConsumerOSR::OnFrameCaptured(
view_->OnAcceleratedPaint(damage_rect, info->coded_size, paint_info);
#elif BUILDFLAG(IS_LINUX)
auto& gmb_handle = data->get_gpu_memory_buffer_handle();
auto& native_pixmap = gmb_handle.native_pixmap_handle;
auto& native_pixmap = gmb_handle.native_pixmap_handle();
CHECK(native_pixmap.planes.size() <= kAcceleratedPaintMaxPlanes);
cef_accelerated_paint_info_t paint_info;

View File

@@ -9,6 +9,7 @@
#include "base/notreached.h"
#include "cef/libcef/browser/browser_host_base.h"
#include "chrome/browser/ui/permission_bubble/permission_prompt.h"
#include "components/permissions/permission_request.h"
namespace permission_prompt {
@@ -245,6 +246,8 @@ cef_permission_request_types_t GetCefRequestType(
return CEF_PERMISSION_TYPE_WINDOW_MANAGEMENT;
case permissions::RequestType::kFileSystemAccess:
return CEF_PERMISSION_TYPE_FILE_SYSTEM_ACCESS;
case permissions::RequestType::kLocalNetworkAccess:
return CEF_PERMISSION_TYPE_LOCAL_NETWORK_ACCESS;
}
DCHECK(false);

View File

@@ -0,0 +1,129 @@
#include "build/build_config.h"
// 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)
#include "base/debug/alias.h"
#include "include/internal/cef_app_win.h"
namespace {
// 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;
}
} // namespace
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 // BUILDFLAG(IS_WIN) && defined(ARCH_CPU_32_BITS)

View File

@@ -6,6 +6,7 @@
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "cef/include/cef_preference.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/values_impl.h"
#include "components/prefs/pref_service.h"
@@ -118,4 +119,145 @@ bool SetPreference(PrefService* pref_service,
return true;
}
class RegistrationImpl final : public Registration, public CefRegistration {
public:
RegistrationImpl(Registrar* registrar,
const CefString& name,
CefRefPtr<CefPreferenceObserver> observer)
: registrar_(registrar), name_(name), observer_(observer) {
DCHECK(registrar_);
DCHECK(observer_);
}
RegistrationImpl(const RegistrationImpl&) = delete;
RegistrationImpl& operator=(const RegistrationImpl&) = delete;
~RegistrationImpl() override {
CEF_REQUIRE_UIT();
if (registrar_) {
registrar_->RemoveObserver(name_.ToString(), this);
}
}
void Detach() override {
registrar_ = nullptr;
observer_ = nullptr;
}
void RunCallback() const override { RunCallback(name_); }
void RunCallback(const CefString& name) const override {
observer_->OnPreferenceChanged(name);
}
private:
raw_ptr<Registrar> registrar_;
CefString name_;
CefRefPtr<CefPreferenceObserver> observer_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(RegistrationImpl);
};
Registrar::~Registrar() {
RemoveAll();
}
void Registrar::Init(PrefService* service) {
DCHECK(service);
DCHECK(IsEmpty() || service_ == service);
service_ = service;
}
void Registrar::Reset() {
RemoveAll();
service_ = nullptr;
}
void Registrar::RemoveAll() {
if (!name_observers_.empty()) {
for (auto& [name, registrations] : name_observers_) {
service_->RemovePrefObserver(name, this);
for (auto& registration : registrations) {
registration.Detach();
}
}
name_observers_.clear();
}
if (!all_observers_.empty()) {
service_->RemovePrefObserverAllPrefs(this);
for (auto& registration : all_observers_) {
registration.Detach();
}
all_observers_.Clear();
}
}
bool Registrar::IsEmpty() const {
return name_observers_.empty() && all_observers_.empty();
}
CefRefPtr<CefRegistration> Registrar::AddObserver(
const CefString& name,
CefRefPtr<CefPreferenceObserver> observer) {
CHECK(service_);
RegistrationImpl* impl = new RegistrationImpl(this, name, observer);
if (name.empty()) {
if (all_observers_.empty()) {
service_->AddPrefObserverAllPrefs(this);
}
all_observers_.AddObserver(impl);
} else {
const std::string& name_str = name.ToString();
if (!name_observers_.contains(name_str)) {
service_->AddPrefObserver(name_str, this);
}
name_observers_[name_str].AddObserver(impl);
}
return impl;
}
void Registrar::RemoveObserver(std::string_view name,
Registration* registration) {
CHECK(service_);
if (name.empty()) {
all_observers_.RemoveObserver(registration);
if (all_observers_.empty()) {
service_->RemovePrefObserverAllPrefs(this);
}
} else {
auto it = name_observers_.find(std::string(name));
DCHECK(it != name_observers_.end());
it->second.RemoveObserver(registration);
if (it->second.empty()) {
name_observers_.erase(it);
service_->RemovePrefObserver(name, this);
}
}
}
void Registrar::OnPreferenceChanged(PrefService* service,
std::string_view pref_name) {
std::string pref_name_str(pref_name);
if (!name_observers_.empty()) {
auto it = name_observers_.find(pref_name_str);
if (it != name_observers_.end()) {
for (Registration& registration : it->second) {
registration.RunCallback();
}
}
}
if (!all_observers_.empty()) {
CefString name_str(pref_name_str);
for (Registration& registration : all_observers_) {
registration.RunCallback(name_str);
}
}
}
} // namespace pref_helper

View File

@@ -5,8 +5,16 @@
#ifndef CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_
#define CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_
#include "cef/include/cef_values.h"
#include <unordered_map>
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "cef/include/cef_registration.h"
#include "cef/include/cef_values.h"
#include "components/prefs/pref_observer.h"
class CefPreferenceObserver;
class CefRegistration;
class PrefService;
namespace pref_helper {
@@ -28,6 +36,69 @@ bool SetPreference(PrefService* pref_service,
CefRefPtr<CefValue> value,
CefString& error);
class Registration : public base::CheckedObserver {
public:
virtual void Detach() = 0;
virtual void RunCallback() const = 0;
virtual void RunCallback(const CefString& name) const = 0;
};
class RegistrationImpl;
// Automatically manages the registration of one or more CefPreferenceObserver
// objects with a PrefService. When the Registrar is destroyed, all registered
// observers are automatically unregistered with the PrefService. Loosely based
// on PrefChangeRegistrar.
class Registrar final : public PrefObserver {
public:
Registrar() = default;
Registrar(const Registrar&) = delete;
Registrar& operator=(const Registrar&) = delete;
~Registrar();
// Must be called before adding or removing observers. Can be called more
// than once as long as the value of |service| doesn't change.
void Init(PrefService* service);
// Removes all observers and clears the reference to the PrefService.
// `Init` must be called before adding or removing any observers.
void Reset();
// Removes all observers that have been previously added with a call to Add.
void RemoveAll();
// Returns true if no observers are registered.
bool IsEmpty() const;
// Adds a pref |observer| for the specified pref |name|. All registered
// observers will be automatically unregistered and detached when the
// Registrar's destructor is called.
CefRefPtr<CefRegistration> AddObserver(
const CefString& name,
CefRefPtr<CefPreferenceObserver> observer);
private:
friend class RegistrationImpl;
void RemoveObserver(std::string_view name, Registration* registration);
// PrefObserver:
void OnPreferenceChanged(PrefService* service,
std::string_view pref_name) override;
raw_ptr<PrefService, AcrossTasksDanglingUntriaged> service_ = nullptr;
// Observers registered for a preference by name.
using ObserverMap =
std::unordered_map<std::string, base::ObserverList<Registration>>;
ObserverMap name_observers_;
// Observers registered for all preferences.
base::ObserverList<Registration> all_observers_;
};
} // namespace pref_helper
#endif // CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_

View File

@@ -93,7 +93,6 @@ void SetCefPrefs(const CefBrowserSettings& cef,
SET_STATE(cef.text_area_resize, web.text_areas_are_resizable);
SET_STATE(cef.tab_to_links, web.tabs_to_links);
SET_STATE(cef.local_storage, web.local_storage_enabled);
SET_STATE(cef.databases, web.databases_enabled);
// Never explicitly enable GPU-related functions in this method because the
// GPU blacklist is not being checked here.

View File

@@ -107,7 +107,7 @@ void PrintToPDF(content::WebContents* web_contents,
}
}
absl::variant<printing::mojom::PrintPagesParamsPtr, std::string>
std::variant<printing::mojom::PrintPagesParamsPtr, std::string>
print_pages_params = print_to_pdf::GetPrintPagesParams(
web_contents->GetPrimaryMainFrame()->GetLastCommittedURL(),
!!settings.landscape, display_header_footer,
@@ -117,14 +117,14 @@ void PrintToPDF(content::WebContents* web_contents,
CefString(&settings.footer_template), !!settings.prefer_css_page_size,
!!settings.generate_tagged_pdf, !!settings.generate_document_outline);
if (absl::holds_alternative<std::string>(print_pages_params)) {
if (std::holds_alternative<std::string>(print_pages_params)) {
LOG(ERROR) << "PrintToPDF failed with error: "
<< absl::get<std::string>(print_pages_params);
<< std::get<std::string>(print_pages_params);
callback->OnPdfPrintFinished(CefString(), false);
return;
}
DCHECK(absl::holds_alternative<printing::mojom::PrintPagesParamsPtr>(
DCHECK(std::holds_alternative<printing::mojom::PrintPagesParamsPtr>(
print_pages_params));
if (auto* print_manager =

View File

@@ -10,7 +10,9 @@
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/prefs/pref_helper.h"
#include "cef/libcef/browser/setting_helper.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/api_version_util.h"
#include "cef/libcef/common/app_manager.h"
#include "cef/libcef/common/task_runner_impl.h"
#include "cef/libcef/common/values_impl.h"
@@ -459,6 +461,22 @@ bool CefRequestContextImpl::SetPreference(const CefString& name,
return pref_helper::SetPreference(pref_service, name, value, error);
}
CefRefPtr<CefRegistration> CefRequestContextImpl::AddPreferenceObserver(
const CefString& name,
CefRefPtr<CefPreferenceObserver> observer) {
CEF_API_REQUIRE_ADDED(13401);
if (!VerifyBrowserContext()) {
return nullptr;
}
if (!pref_registrar_) {
pref_registrar_ = std::make_unique<pref_helper::Registrar>();
pref_registrar_->Init(browser_context()->AsProfile()->GetPrefs());
}
return pref_registrar_->AddObserver(name, observer);
}
void CefRequestContextImpl::ClearCertificateExceptions(
CefRefPtr<CefCompletionCallback> callback) {
GetBrowserContext(
@@ -512,14 +530,18 @@ CefRefPtr<CefValue> CefRequestContextImpl::GetWebsiteSetting(
return nullptr;
}
const auto setting_type = setting_helper::FromCefType(content_type);
if (!setting_type) {
return nullptr;
}
// Either or both URLs may be invalid.
GURL requesting_gurl(requesting_url.ToString());
GURL top_level_gurl(top_level_url.ToString());
content_settings::SettingInfo info;
base::Value value = settings_map->GetWebsiteSetting(
requesting_gurl, top_level_gurl,
static_cast<ContentSettingsType>(content_type), &info);
requesting_gurl, top_level_gurl, *setting_type, &info);
if (value.is_none()) {
return nullptr;
}
@@ -558,19 +580,22 @@ cef_content_setting_values_t CefRequestContextImpl::GetContentSetting(
return CEF_CONTENT_SETTING_VALUE_DEFAULT;
}
const auto setting_type = setting_helper::FromCefType(content_type);
if (!setting_type) {
return CEF_CONTENT_SETTING_VALUE_DEFAULT;
}
ContentSetting value = ContentSetting::CONTENT_SETTING_DEFAULT;
if (requesting_url.empty() && top_level_url.empty()) {
value = settings_map->GetDefaultContentSetting(
static_cast<ContentSettingsType>(content_type),
/*provider_id=*/nullptr);
value = settings_map->GetDefaultContentSetting(*setting_type,
/*provider_id=*/nullptr);
} else {
GURL requesting_gurl(requesting_url.ToString());
GURL top_level_gurl(top_level_url.ToString());
if (requesting_gurl.is_valid() || top_level_gurl.is_valid()) {
value = settings_map->GetContentSetting(
requesting_gurl, top_level_gurl,
static_cast<ContentSettingsType>(content_type));
value = settings_map->GetContentSetting(requesting_gurl, top_level_gurl,
*setting_type);
}
}
@@ -588,6 +613,26 @@ void CefRequestContextImpl::SetContentSetting(
requesting_url, top_level_url, content_type, value));
}
CefRefPtr<CefRegistration> CefRequestContextImpl::AddSettingObserver(
CefRefPtr<CefSettingObserver> observer) {
CEF_API_REQUIRE_ADDED(13401);
if (!VerifyBrowserContext()) {
return nullptr;
}
if (!setting_registrar_) {
auto* settings_map = HostContentSettingsMapFactory::GetForProfile(
browser_context()->AsProfile());
if (!settings_map) {
return nullptr;
}
setting_registrar_ = std::make_unique<setting_helper::Registrar>();
setting_registrar_->Init(settings_map);
}
return setting_registrar_->AddObserver(observer);
}
void CefRequestContextImpl::SetChromeColorScheme(cef_color_variant_t variant,
cef_color_t user_color) {
GetBrowserContext(
@@ -863,6 +908,11 @@ void CefRequestContextImpl::SetWebsiteSettingInternal(
return;
}
const auto setting_type = setting_helper::FromCefType(content_type);
if (!setting_type) {
return;
}
// Starts as a NONE value.
base::Value new_value;
if (value && value->IsValid()) {
@@ -872,14 +922,13 @@ void CefRequestContextImpl::SetWebsiteSettingInternal(
if (requesting_url.empty() && top_level_url.empty()) {
settings_map->SetWebsiteSettingCustomScope(
ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(),
static_cast<ContentSettingsType>(content_type), std::move(new_value));
*setting_type, std::move(new_value));
} else {
GURL requesting_gurl(requesting_url.ToString());
GURL top_level_gurl(top_level_url.ToString());
if (requesting_gurl.is_valid() || top_level_gurl.is_valid()) {
settings_map->SetWebsiteSettingDefaultScope(
requesting_gurl, top_level_gurl,
static_cast<ContentSettingsType>(content_type), std::move(new_value));
requesting_gurl, top_level_gurl, *setting_type, std::move(new_value));
}
}
}
@@ -901,17 +950,20 @@ void CefRequestContextImpl::SetContentSettingInternal(
return;
}
const auto setting_type = setting_helper::FromCefType(content_type);
if (!setting_type) {
return;
}
if (requesting_url.empty() && top_level_url.empty()) {
settings_map->SetDefaultContentSetting(
static_cast<ContentSettingsType>(content_type),
static_cast<ContentSetting>(value));
settings_map->SetDefaultContentSetting(*setting_type,
static_cast<ContentSetting>(value));
} else {
GURL requesting_gurl(requesting_url.ToString());
GURL top_level_gurl(top_level_url.ToString());
if (requesting_gurl.is_valid() || top_level_gurl.is_valid()) {
settings_map->SetContentSettingDefaultScope(
requesting_gurl, top_level_gurl,
static_cast<ContentSettingsType>(content_type),
requesting_gurl, top_level_gurl, *setting_type,
static_cast<ContentSetting>(value));
}
}

View File

@@ -17,6 +17,14 @@ namespace content {
struct GlobalRenderFrameHostId;
}
namespace pref_helper {
class Registrar;
}
namespace setting_helper {
class Registrar;
}
class CefBrowserContext;
// Implementation of the CefRequestContext interface. All methods are thread-
@@ -80,6 +88,20 @@ class CefRequestContextImpl : public CefRequestContext {
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
BrowserContextCallback callback);
// 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;
CefRefPtr<CefRegistration> AddPreferenceObserver(
const CefString& name,
CefRefPtr<CefPreferenceObserver> observer) override;
// CefRequestContext methods.
bool IsSame(CefRefPtr<CefRequestContext> other) override;
bool IsSharingWith(CefRefPtr<CefRequestContext> other) override;
bool IsGlobal() override;
@@ -92,14 +114,6 @@ class CefRequestContextImpl : public CefRequestContext {
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(
@@ -125,6 +139,8 @@ class CefRequestContextImpl : public CefRequestContext {
const CefString& top_level_url,
cef_content_setting_types_t content_type,
cef_content_setting_values_t value) override;
CefRefPtr<CefRegistration> AddSettingObserver(
CefRefPtr<CefSettingObserver> observer) override;
void SetChromeColorScheme(cef_color_variant_t variant,
cef_color_t user_color) override;
cef_color_variant_t GetChromeColorSchemeMode() override;
@@ -218,6 +234,9 @@ class CefRequestContextImpl : public CefRequestContext {
Config config_;
std::unique_ptr<pref_helper::Registrar> pref_registrar_;
std::unique_ptr<setting_helper::Registrar> setting_registrar_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefRequestContextImpl);
};

View File

@@ -0,0 +1,389 @@
// Copyright (c) 2025 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "cef/libcef/browser/setting_helper.h"
#include "cef/include/cef_request_context.h"
#include "cef/libcef/browser/thread_util.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "url/gurl.h"
namespace setting_helper {
class RegistrationImpl final : public Registration, public CefRegistration {
public:
RegistrationImpl(Registrar* registrar, CefRefPtr<CefSettingObserver> observer)
: registrar_(registrar), observer_(observer) {
DCHECK(registrar_);
DCHECK(observer_);
}
RegistrationImpl(const RegistrationImpl&) = delete;
RegistrationImpl& operator=(const RegistrationImpl&) = delete;
~RegistrationImpl() override {
CEF_REQUIRE_UIT();
if (registrar_) {
registrar_->RemoveObserver(this);
}
}
void Detach() override {
registrar_ = nullptr;
observer_ = nullptr;
}
void RunCallback(const CefString& requesting_url,
const CefString& top_level_url,
cef_content_setting_types_t content_type) const override {
observer_->OnSettingChanged(requesting_url, top_level_url, content_type);
}
private:
raw_ptr<Registrar> registrar_;
CefRefPtr<CefSettingObserver> observer_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(RegistrationImpl);
};
Registrar::~Registrar() {
RemoveAll();
}
void Registrar::Init(HostContentSettingsMap* settings) {
DCHECK(settings);
DCHECK(IsEmpty() || settings_ == settings);
settings_ = settings;
}
void Registrar::Reset() {
RemoveAll();
settings_ = nullptr;
}
void Registrar::RemoveAll() {
if (!observers_.empty()) {
settings_->RemoveObserver(this);
for (auto& registration : observers_) {
registration.Detach();
}
observers_.Clear();
}
}
bool Registrar::IsEmpty() const {
return observers_.empty();
}
CefRefPtr<CefRegistration> Registrar::AddObserver(
CefRefPtr<CefSettingObserver> observer) {
CHECK(settings_);
RegistrationImpl* impl = new RegistrationImpl(this, observer);
if (observers_.empty()) {
settings_->AddObserver(this);
}
observers_.AddObserver(impl);
return impl;
}
void Registrar::RemoveObserver(Registration* registration) {
CHECK(settings_);
observers_.RemoveObserver(registration);
if (observers_.empty()) {
settings_->RemoveObserver(this);
}
}
void Registrar::OnContentSettingChanged(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsTypeSet content_type_set) {
DCHECK(!IsEmpty());
const CefString requesting_url(primary_pattern.ToRepresentativeUrl().spec());
const CefString top_level_url(secondary_pattern.ToRepresentativeUrl().spec());
const auto content_type = ToCefType(content_type_set.GetType());
for (Registration& registration : observers_) {
registration.RunCallback(requesting_url, top_level_url, content_type);
}
}
#define TO_CEF_TYPE(name) \
case ContentSettingsType::name: \
return CEF_CONTENT_SETTING_TYPE_##name
cef_content_setting_types_t ToCefType(ContentSettingsType type) {
switch (type) {
TO_CEF_TYPE(COOKIES);
TO_CEF_TYPE(IMAGES);
TO_CEF_TYPE(JAVASCRIPT);
TO_CEF_TYPE(POPUPS);
TO_CEF_TYPE(GEOLOCATION);
TO_CEF_TYPE(NOTIFICATIONS);
TO_CEF_TYPE(AUTO_SELECT_CERTIFICATE);
TO_CEF_TYPE(MIXEDSCRIPT);
TO_CEF_TYPE(MEDIASTREAM_MIC);
TO_CEF_TYPE(MEDIASTREAM_CAMERA);
TO_CEF_TYPE(PROTOCOL_HANDLERS);
TO_CEF_TYPE(DEPRECATED_PPAPI_BROKER);
TO_CEF_TYPE(AUTOMATIC_DOWNLOADS);
TO_CEF_TYPE(MIDI_SYSEX);
TO_CEF_TYPE(SSL_CERT_DECISIONS);
TO_CEF_TYPE(PROTECTED_MEDIA_IDENTIFIER);
TO_CEF_TYPE(APP_BANNER);
TO_CEF_TYPE(SITE_ENGAGEMENT);
TO_CEF_TYPE(DURABLE_STORAGE);
TO_CEF_TYPE(USB_CHOOSER_DATA);
TO_CEF_TYPE(BLUETOOTH_GUARD);
TO_CEF_TYPE(BACKGROUND_SYNC);
TO_CEF_TYPE(AUTOPLAY);
TO_CEF_TYPE(IMPORTANT_SITE_INFO);
TO_CEF_TYPE(PERMISSION_AUTOBLOCKER_DATA);
TO_CEF_TYPE(ADS);
TO_CEF_TYPE(ADS_DATA);
TO_CEF_TYPE(MIDI);
TO_CEF_TYPE(PASSWORD_PROTECTION);
TO_CEF_TYPE(MEDIA_ENGAGEMENT);
TO_CEF_TYPE(SOUND);
TO_CEF_TYPE(CLIENT_HINTS);
TO_CEF_TYPE(SENSORS);
TO_CEF_TYPE(DEPRECATED_ACCESSIBILITY_EVENTS);
TO_CEF_TYPE(PAYMENT_HANDLER);
TO_CEF_TYPE(USB_GUARD);
TO_CEF_TYPE(BACKGROUND_FETCH);
TO_CEF_TYPE(INTENT_PICKER_DISPLAY);
TO_CEF_TYPE(IDLE_DETECTION);
TO_CEF_TYPE(SERIAL_GUARD);
TO_CEF_TYPE(SERIAL_CHOOSER_DATA);
TO_CEF_TYPE(PERIODIC_BACKGROUND_SYNC);
TO_CEF_TYPE(BLUETOOTH_SCANNING);
TO_CEF_TYPE(HID_GUARD);
TO_CEF_TYPE(HID_CHOOSER_DATA);
TO_CEF_TYPE(WAKE_LOCK_SCREEN);
TO_CEF_TYPE(WAKE_LOCK_SYSTEM);
TO_CEF_TYPE(LEGACY_COOKIE_ACCESS);
TO_CEF_TYPE(FILE_SYSTEM_WRITE_GUARD);
TO_CEF_TYPE(NFC);
TO_CEF_TYPE(BLUETOOTH_CHOOSER_DATA);
TO_CEF_TYPE(CLIPBOARD_READ_WRITE);
TO_CEF_TYPE(CLIPBOARD_SANITIZED_WRITE);
TO_CEF_TYPE(SAFE_BROWSING_URL_CHECK_DATA);
TO_CEF_TYPE(VR);
TO_CEF_TYPE(AR);
TO_CEF_TYPE(FILE_SYSTEM_READ_GUARD);
TO_CEF_TYPE(STORAGE_ACCESS);
TO_CEF_TYPE(CAMERA_PAN_TILT_ZOOM);
TO_CEF_TYPE(WINDOW_MANAGEMENT);
TO_CEF_TYPE(LOCAL_FONTS);
TO_CEF_TYPE(PERMISSION_AUTOREVOCATION_DATA);
TO_CEF_TYPE(FILE_SYSTEM_LAST_PICKED_DIRECTORY);
TO_CEF_TYPE(DISPLAY_CAPTURE);
TO_CEF_TYPE(FILE_SYSTEM_ACCESS_CHOOSER_DATA);
TO_CEF_TYPE(FEDERATED_IDENTITY_SHARING);
TO_CEF_TYPE(JAVASCRIPT_JIT);
TO_CEF_TYPE(HTTP_ALLOWED);
TO_CEF_TYPE(FORMFILL_METADATA);
TO_CEF_TYPE(DEPRECATED_FEDERATED_IDENTITY_ACTIVE_SESSION);
TO_CEF_TYPE(AUTO_DARK_WEB_CONTENT);
TO_CEF_TYPE(REQUEST_DESKTOP_SITE);
TO_CEF_TYPE(FEDERATED_IDENTITY_API);
TO_CEF_TYPE(NOTIFICATION_INTERACTIONS);
TO_CEF_TYPE(REDUCED_ACCEPT_LANGUAGE);
TO_CEF_TYPE(NOTIFICATION_PERMISSION_REVIEW);
TO_CEF_TYPE(PRIVATE_NETWORK_GUARD);
TO_CEF_TYPE(PRIVATE_NETWORK_CHOOSER_DATA);
TO_CEF_TYPE(FEDERATED_IDENTITY_IDENTITY_PROVIDER_SIGNIN_STATUS);
TO_CEF_TYPE(REVOKED_UNUSED_SITE_PERMISSIONS);
TO_CEF_TYPE(TOP_LEVEL_STORAGE_ACCESS);
TO_CEF_TYPE(FEDERATED_IDENTITY_AUTO_REAUTHN_PERMISSION);
TO_CEF_TYPE(FEDERATED_IDENTITY_IDENTITY_PROVIDER_REGISTRATION);
TO_CEF_TYPE(ANTI_ABUSE);
TO_CEF_TYPE(THIRD_PARTY_STORAGE_PARTITIONING);
TO_CEF_TYPE(HTTPS_ENFORCED);
TO_CEF_TYPE(ALL_SCREEN_CAPTURE);
TO_CEF_TYPE(COOKIE_CONTROLS_METADATA);
TO_CEF_TYPE(TPCD_HEURISTICS_GRANTS);
TO_CEF_TYPE(TPCD_METADATA_GRANTS);
TO_CEF_TYPE(TPCD_TRIAL);
TO_CEF_TYPE(TOP_LEVEL_TPCD_TRIAL);
TO_CEF_TYPE(TOP_LEVEL_TPCD_ORIGIN_TRIAL);
TO_CEF_TYPE(AUTO_PICTURE_IN_PICTURE);
TO_CEF_TYPE(FILE_SYSTEM_ACCESS_EXTENDED_PERMISSION);
TO_CEF_TYPE(FILE_SYSTEM_ACCESS_RESTORE_PERMISSION);
TO_CEF_TYPE(CAPTURED_SURFACE_CONTROL);
TO_CEF_TYPE(SMART_CARD_GUARD);
TO_CEF_TYPE(SMART_CARD_DATA);
TO_CEF_TYPE(WEB_PRINTING);
TO_CEF_TYPE(AUTOMATIC_FULLSCREEN);
TO_CEF_TYPE(SUB_APP_INSTALLATION_PROMPTS);
TO_CEF_TYPE(SPEAKER_SELECTION);
TO_CEF_TYPE(DIRECT_SOCKETS);
TO_CEF_TYPE(KEYBOARD_LOCK);
TO_CEF_TYPE(POINTER_LOCK);
TO_CEF_TYPE(REVOKED_ABUSIVE_NOTIFICATION_PERMISSIONS);
TO_CEF_TYPE(TRACKING_PROTECTION);
TO_CEF_TYPE(DISPLAY_MEDIA_SYSTEM_AUDIO);
TO_CEF_TYPE(JAVASCRIPT_OPTIMIZER);
TO_CEF_TYPE(STORAGE_ACCESS_HEADER_ORIGIN_TRIAL);
TO_CEF_TYPE(HAND_TRACKING);
TO_CEF_TYPE(WEB_APP_INSTALLATION);
TO_CEF_TYPE(DIRECT_SOCKETS_PRIVATE_NETWORK_ACCESS);
TO_CEF_TYPE(LEGACY_COOKIE_SCOPE);
TO_CEF_TYPE(ARE_SUSPICIOUS_NOTIFICATIONS_ALLOWLISTED_BY_USER);
TO_CEF_TYPE(CONTROLLED_FRAME);
TO_CEF_TYPE(REVOKED_DISRUPTIVE_NOTIFICATION_PERMISSIONS);
TO_CEF_TYPE(LOCAL_NETWORK_ACCESS);
TO_CEF_TYPE(ON_DEVICE_SPEECH_RECOGNITION_LANGUAGES_DOWNLOADED);
TO_CEF_TYPE(INITIALIZED_TRANSLATIONS);
TO_CEF_TYPE(SUSPICIOUS_NOTIFICATION_IDS);
case ContentSettingsType::DEFAULT:
break;
}
NOTREACHED();
}
#define FROM_CEF_TYPE(name) \
case CEF_CONTENT_SETTING_TYPE_##name: \
return ContentSettingsType::name
std::optional<ContentSettingsType> FromCefType(
cef_content_setting_types_t type) {
switch (type) {
FROM_CEF_TYPE(COOKIES);
FROM_CEF_TYPE(IMAGES);
FROM_CEF_TYPE(JAVASCRIPT);
FROM_CEF_TYPE(POPUPS);
FROM_CEF_TYPE(GEOLOCATION);
FROM_CEF_TYPE(NOTIFICATIONS);
FROM_CEF_TYPE(AUTO_SELECT_CERTIFICATE);
FROM_CEF_TYPE(MIXEDSCRIPT);
FROM_CEF_TYPE(MEDIASTREAM_MIC);
FROM_CEF_TYPE(MEDIASTREAM_CAMERA);
FROM_CEF_TYPE(PROTOCOL_HANDLERS);
FROM_CEF_TYPE(DEPRECATED_PPAPI_BROKER);
FROM_CEF_TYPE(AUTOMATIC_DOWNLOADS);
FROM_CEF_TYPE(MIDI_SYSEX);
FROM_CEF_TYPE(SSL_CERT_DECISIONS);
FROM_CEF_TYPE(PROTECTED_MEDIA_IDENTIFIER);
FROM_CEF_TYPE(APP_BANNER);
FROM_CEF_TYPE(SITE_ENGAGEMENT);
FROM_CEF_TYPE(DURABLE_STORAGE);
FROM_CEF_TYPE(USB_CHOOSER_DATA);
FROM_CEF_TYPE(BLUETOOTH_GUARD);
FROM_CEF_TYPE(BACKGROUND_SYNC);
FROM_CEF_TYPE(AUTOPLAY);
FROM_CEF_TYPE(IMPORTANT_SITE_INFO);
FROM_CEF_TYPE(PERMISSION_AUTOBLOCKER_DATA);
FROM_CEF_TYPE(ADS);
FROM_CEF_TYPE(ADS_DATA);
FROM_CEF_TYPE(MIDI);
FROM_CEF_TYPE(PASSWORD_PROTECTION);
FROM_CEF_TYPE(MEDIA_ENGAGEMENT);
FROM_CEF_TYPE(SOUND);
FROM_CEF_TYPE(CLIENT_HINTS);
FROM_CEF_TYPE(SENSORS);
FROM_CEF_TYPE(DEPRECATED_ACCESSIBILITY_EVENTS);
FROM_CEF_TYPE(PAYMENT_HANDLER);
FROM_CEF_TYPE(USB_GUARD);
FROM_CEF_TYPE(BACKGROUND_FETCH);
FROM_CEF_TYPE(INTENT_PICKER_DISPLAY);
FROM_CEF_TYPE(IDLE_DETECTION);
FROM_CEF_TYPE(SERIAL_GUARD);
FROM_CEF_TYPE(SERIAL_CHOOSER_DATA);
FROM_CEF_TYPE(PERIODIC_BACKGROUND_SYNC);
FROM_CEF_TYPE(BLUETOOTH_SCANNING);
FROM_CEF_TYPE(HID_GUARD);
FROM_CEF_TYPE(HID_CHOOSER_DATA);
FROM_CEF_TYPE(WAKE_LOCK_SCREEN);
FROM_CEF_TYPE(WAKE_LOCK_SYSTEM);
FROM_CEF_TYPE(LEGACY_COOKIE_ACCESS);
FROM_CEF_TYPE(FILE_SYSTEM_WRITE_GUARD);
FROM_CEF_TYPE(NFC);
FROM_CEF_TYPE(BLUETOOTH_CHOOSER_DATA);
FROM_CEF_TYPE(CLIPBOARD_READ_WRITE);
FROM_CEF_TYPE(CLIPBOARD_SANITIZED_WRITE);
FROM_CEF_TYPE(SAFE_BROWSING_URL_CHECK_DATA);
FROM_CEF_TYPE(VR);
FROM_CEF_TYPE(AR);
FROM_CEF_TYPE(FILE_SYSTEM_READ_GUARD);
FROM_CEF_TYPE(STORAGE_ACCESS);
FROM_CEF_TYPE(CAMERA_PAN_TILT_ZOOM);
FROM_CEF_TYPE(WINDOW_MANAGEMENT);
FROM_CEF_TYPE(LOCAL_FONTS);
FROM_CEF_TYPE(PERMISSION_AUTOREVOCATION_DATA);
FROM_CEF_TYPE(FILE_SYSTEM_LAST_PICKED_DIRECTORY);
FROM_CEF_TYPE(DISPLAY_CAPTURE);
FROM_CEF_TYPE(FILE_SYSTEM_ACCESS_CHOOSER_DATA);
FROM_CEF_TYPE(FEDERATED_IDENTITY_SHARING);
FROM_CEF_TYPE(JAVASCRIPT_JIT);
FROM_CEF_TYPE(HTTP_ALLOWED);
FROM_CEF_TYPE(FORMFILL_METADATA);
FROM_CEF_TYPE(DEPRECATED_FEDERATED_IDENTITY_ACTIVE_SESSION);
FROM_CEF_TYPE(AUTO_DARK_WEB_CONTENT);
FROM_CEF_TYPE(REQUEST_DESKTOP_SITE);
FROM_CEF_TYPE(FEDERATED_IDENTITY_API);
FROM_CEF_TYPE(NOTIFICATION_INTERACTIONS);
FROM_CEF_TYPE(REDUCED_ACCEPT_LANGUAGE);
FROM_CEF_TYPE(NOTIFICATION_PERMISSION_REVIEW);
FROM_CEF_TYPE(PRIVATE_NETWORK_GUARD);
FROM_CEF_TYPE(PRIVATE_NETWORK_CHOOSER_DATA);
FROM_CEF_TYPE(FEDERATED_IDENTITY_IDENTITY_PROVIDER_SIGNIN_STATUS);
FROM_CEF_TYPE(REVOKED_UNUSED_SITE_PERMISSIONS);
FROM_CEF_TYPE(TOP_LEVEL_STORAGE_ACCESS);
FROM_CEF_TYPE(FEDERATED_IDENTITY_AUTO_REAUTHN_PERMISSION);
FROM_CEF_TYPE(FEDERATED_IDENTITY_IDENTITY_PROVIDER_REGISTRATION);
FROM_CEF_TYPE(ANTI_ABUSE);
FROM_CEF_TYPE(THIRD_PARTY_STORAGE_PARTITIONING);
FROM_CEF_TYPE(HTTPS_ENFORCED);
FROM_CEF_TYPE(ALL_SCREEN_CAPTURE);
FROM_CEF_TYPE(COOKIE_CONTROLS_METADATA);
FROM_CEF_TYPE(TPCD_HEURISTICS_GRANTS);
FROM_CEF_TYPE(TPCD_METADATA_GRANTS);
FROM_CEF_TYPE(TPCD_TRIAL);
FROM_CEF_TYPE(TOP_LEVEL_TPCD_TRIAL);
FROM_CEF_TYPE(TOP_LEVEL_TPCD_ORIGIN_TRIAL);
FROM_CEF_TYPE(AUTO_PICTURE_IN_PICTURE);
FROM_CEF_TYPE(FILE_SYSTEM_ACCESS_EXTENDED_PERMISSION);
FROM_CEF_TYPE(FILE_SYSTEM_ACCESS_RESTORE_PERMISSION);
FROM_CEF_TYPE(CAPTURED_SURFACE_CONTROL);
FROM_CEF_TYPE(SMART_CARD_GUARD);
FROM_CEF_TYPE(SMART_CARD_DATA);
FROM_CEF_TYPE(WEB_PRINTING);
FROM_CEF_TYPE(AUTOMATIC_FULLSCREEN);
FROM_CEF_TYPE(SUB_APP_INSTALLATION_PROMPTS);
FROM_CEF_TYPE(SPEAKER_SELECTION);
FROM_CEF_TYPE(DIRECT_SOCKETS);
FROM_CEF_TYPE(KEYBOARD_LOCK);
FROM_CEF_TYPE(POINTER_LOCK);
FROM_CEF_TYPE(REVOKED_ABUSIVE_NOTIFICATION_PERMISSIONS);
FROM_CEF_TYPE(TRACKING_PROTECTION);
FROM_CEF_TYPE(DISPLAY_MEDIA_SYSTEM_AUDIO);
FROM_CEF_TYPE(JAVASCRIPT_OPTIMIZER);
FROM_CEF_TYPE(STORAGE_ACCESS_HEADER_ORIGIN_TRIAL);
FROM_CEF_TYPE(HAND_TRACKING);
FROM_CEF_TYPE(WEB_APP_INSTALLATION);
FROM_CEF_TYPE(DIRECT_SOCKETS_PRIVATE_NETWORK_ACCESS);
FROM_CEF_TYPE(LEGACY_COOKIE_SCOPE);
FROM_CEF_TYPE(ARE_SUSPICIOUS_NOTIFICATIONS_ALLOWLISTED_BY_USER);
FROM_CEF_TYPE(CONTROLLED_FRAME);
FROM_CEF_TYPE(REVOKED_DISRUPTIVE_NOTIFICATION_PERMISSIONS);
FROM_CEF_TYPE(LOCAL_NETWORK_ACCESS);
FROM_CEF_TYPE(ON_DEVICE_SPEECH_RECOGNITION_LANGUAGES_DOWNLOADED);
FROM_CEF_TYPE(INITIALIZED_TRANSLATIONS);
FROM_CEF_TYPE(SUSPICIOUS_NOTIFICATION_IDS);
case CEF_CONTENT_SETTING_TYPE_INSECURE_PRIVATE_NETWORK_DEPRECATED:
case CEF_CONTENT_SETTING_TYPE_NUM_VALUES:
break;
}
return std::nullopt;
}
} // namespace setting_helper

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