Compare commits

..

23 Commits
master ... 7049

Author SHA1 Message Date
Marshall Greenblatt
c3988e90bb Pin depot_tools version for out-of-support branch 2025-05-06 17:17:45 -04:00
Marshall Greenblatt
442c6008f9 Update to Chromium version 135.0.7049.115 2025-04-23 15:45:08 +00:00
Marshall Greenblatt
d008a99a60 Update to Chromium version 135.0.7049.96 2025-04-16 15:08:44 +00:00
Marshall Greenblatt
e7de5c3d91 Update to Chromium version 135.0.7049.85 2025-04-09 16:25:17 +00:00
Marshall Greenblatt
85b7cdfa58 vscode: Fix error running build tasks
Running tasks without explicit "cwd" broke in VSCode 1.99.0.
2025-04-08 11:44:59 -04:00
Marshall Greenblatt
f316e3d072 Fix dangling menu observer on browser destruction 2025-04-08 11:44:52 -04:00
Marshall Greenblatt
cbc1c5b766 alloy: Fix display of modal JS dialogs (fixes #3818) 2025-04-02 14:37:59 -04:00
Marshall Greenblatt
5aac06d3fe Update to Chromium version 135.0.7049.52 2025-04-02 15:23:13 +00:00
Marshall Greenblatt
0556b3019a 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:20:01 -04:00
Marshall Greenblatt
a076956043 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:17:08 -04:00
Marshall Greenblatt
95d37ffb05 Fix crash on invalid chromeMediaSourceId (fixes #3911) 2025-03-31 12:18:49 -04:00
Marshall Greenblatt
aa21e05ef5 Update to Chromium version 135.0.7049.41 2025-03-27 14:37:22 +00:00
Marshall Greenblatt
81c1144af1 mac: Fix compile error
Caused by https://crrev.com/0a4a424cc4
2025-03-24 13:54:55 -04:00
Marshall Greenblatt
f9c2d00bf2 Update to Chromium version 135.0.7049.28 2025-03-24 17:53:11 +00:00
Marshall Greenblatt
cf8c6b2e4c win: alloy: Fix potential crash if browser creation is aborted (fixes #3862) 2025-03-21 14:32:52 -04:00
Marshall Greenblatt
9f9c3933ba chrome: Implement CefBrowserHost::SetAudioMuted/IsAudioMuted (fixes #3893) 2025-03-21 13:21:20 -04:00
Marshall Greenblatt
326fa6594a chrome: Implement CefFocusHandler::OnTakeFocus callback (fixes #3897) 2025-03-21 13:20:29 -04:00
Marshall Greenblatt
52aa456302 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-21 13:20:21 -04:00
Marshall Greenblatt
98006e1d14 distrib: Include CREDITS.html with third-party licenses
This is the same content currently available via about:credits.
2025-03-19 14:02:34 -04:00
Michael Bragg
d6b6801d33 alloy: win: Add spelling suggestions in context menu (fixes #3055) 2025-03-18 12:18:54 -04:00
David Cernoch
2b6e40a822 Make PrintToPDF path parameter optional (fixes #3879) 2025-03-18 12:18:54 -04:00
Marshall Greenblatt
ee5de71957 Update to Chromium version 135.0.7049.17 2025-03-14 15:01:09 +00:00
Marshall Greenblatt
d336310385 Update to Chromium version 135.0.7049.3 2025-03-12 15:01:06 -04:00
269 changed files with 3745 additions and 7707 deletions

341
BUILD.gn
View File

@@ -319,16 +319,6 @@ 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" ]
}
@@ -383,10 +373,6 @@ 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",
]
@@ -562,8 +548,6 @@ 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",
@@ -855,7 +839,6 @@ 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",
@@ -1008,9 +991,6 @@ 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 += [
@@ -1175,9 +1155,6 @@ 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.
@@ -1213,14 +1190,6 @@ 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" ]
@@ -1240,13 +1209,14 @@ if (is_win) {
configs += [ ":libcef_includes_config" ]
deps = [
":make_config_header",
"libcef/features:buildflags",
"//sandbox",
]
}
}
if (is_mac) {
shared_library("cef_sandbox") {
static_library("cef_sandbox") {
sources = [ "libcef_dll/sandbox/sandbox_mac.mm" ]
configs += [ ":libcef_includes_config" ]
deps = [
@@ -1257,97 +1227,6 @@ 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.
#
@@ -1661,46 +1540,17 @@ if (is_mac) {
]
}
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") {
# Add the ANGLE .dylibs in the MODULE_DIR of the Framework app bundle.
bundle_data("cef_framework_angle_binaries") {
sources = [
"$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",
"$root_out_dir/egl_intermediates/libEGL.dylib",
"$root_out_dir/egl_intermediates/libGLESv2.dylib",
]
outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
]
public_deps = [
":cef_library_copy",
"//ui/gl:angle_library_copy",
]
}
@@ -1733,15 +1583,11 @@ if (is_mac) {
sources = libcef_sources_common + includes_mac
deps = libcef_deps_common + [
":cef_framework_cef_binaries",
":cef_framework_angle_binaries",
":cef_framework_resources",
":cef_framework_swiftshader_binaries",
]
if (!use_static_angle) {
deps += [ ":cef_framework_angle_binaries" ]
}
configs += [
":libcef_autogen_config",
":libcef_includes_config",
@@ -1806,8 +1652,7 @@ if (is_mac) {
]
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements. Don't use "delayloads_not_for_child_dll" here because
# we need some DLLs loaded in child processes before sandbox lockdown.
# improvements.
configs += [ "//build/config/win:delayloads" ]
libs = [
@@ -1903,6 +1748,7 @@ if (is_mac) {
deps = [
":cef_make_headers",
":cef_sandbox",
":libcef_dll_wrapper",
]
if (defined(invoker.helper_deps)) {
@@ -2303,7 +2149,6 @@ 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
@@ -2314,10 +2159,7 @@ if (is_mac) {
# 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",
]
configs += [ "//build/config/win:delayloads" ]
defines += [
"CEF_USE_ATL",
@@ -2381,70 +2223,6 @@ 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.
@@ -2469,7 +2247,6 @@ 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
@@ -2479,10 +2256,7 @@ if (is_mac) {
# 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",
]
configs += [ "//build/config/win:delayloads" ]
deps += [
":cef_sandbox",
@@ -2513,48 +2287,6 @@ 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.
@@ -2590,17 +2322,13 @@ if (is_mac) {
]
if (is_win) {
sources += gypi_paths2.includes_wrapper_win +
gypi_paths2.shared_sources_win +
sources += 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",
"//build/config/win:delayloads_not_for_child_dll",
]
configs += [ "//build/config/win:delayloads" ]
deps += [
":cef_sandbox",
@@ -2632,45 +2360,4 @@ 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,5 +7,6 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/138.0.7204.0'
'chromium_checkout': 'refs/tags/135.0.7049.115',
'depot_tools_checkout': '6678906cf8'
}

View File

@@ -43,7 +43,9 @@ 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 = deps,
deps = [
"@cef//:cef_sandbox",
] + deps,
**kwargs,
)

View File

@@ -47,6 +47,7 @@ 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,13 +32,9 @@ 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). Lists should be kept in sync with
# targets from Chromium's //build/config/win/BUILD.gn file.
# 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_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",
@@ -80,36 +76,38 @@ 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 = [
]
@@ -180,9 +178,18 @@ 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

@@ -47,32 +47,8 @@
"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": "13800",
"last": "13500",
"min": "13300"
}

View File

@@ -17,7 +17,6 @@
'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',
@@ -80,11 +79,6 @@
'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',
@@ -171,15 +165,9 @@
'libcef_dll/wrapper/libcef_dll_wrapper2.cc',
],
'libcef_dll_wrapper_sources_mac': [
'libcef_dll/wrapper/cef_scoped_library_loader_mac.mm',
'libcef_dll/wrapper/cef_scoped_sandbox_context_mac.mm',
'libcef_dll/wrapper/cef_library_loader_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',
@@ -422,8 +410,6 @@
'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',
@@ -540,7 +526,6 @@
'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,7 +36,11 @@ macro(PRINT_CEF_CONFIG)
message(STATUS "CEF sandbox: ${USE_SANDBOX}")
message(STATUS "Standard libraries: ${CEF_STANDARD_LIBS}")
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 "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 15.4 14.2 14.0 11.0)
foreach(OS_VERSION 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,6 +361,14 @@ 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.
@@ -388,6 +396,15 @@ 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")
@@ -432,20 +449,18 @@ 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). 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 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: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
@@ -487,31 +502,6 @@ 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
@@ -550,12 +540,9 @@ 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
)
@@ -600,8 +587,36 @@ if(OS_WINDOWS)
if(USE_SANDBOX)
list(APPEND CEF_COMPILER_DEFINES
CEF_USE_BOOTSTRAP # Used by apps to test if the bootstrap is enabled
PSAPI_VERSION=1 # Required by cef_sandbox.lib
CEF_USE_SANDBOX # Used by apps to test if the sandbox 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

@@ -1,197 +0,0 @@
// 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,50 +189,16 @@
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 internal::GetImplementation()->get_min_log_level();
return cef_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 internal::GetImplementation()->get_vlog_level(file, N);
return cef_get_vlog_level(file, N);
}
typedef int LogSeverity;
@@ -252,64 +218,6 @@ 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

@@ -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,
/// CefGetExitCode. The |windows_sandbox_info| parameter is only used on Windows
/// and may be NULL (see cef_sandbox_win.h for details).
/// CefGetErrorCode. The |windows_sandbox_info| parameter is only used on
/// Windows and may be NULL (see cef_sandbox_win.h for details).
///
/*--cef(api_hash_check,optional_param=application,
optional_param=windows_sandbox_info)--*/

View File

@@ -707,24 +707,12 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
virtual void WasHidden(bool hidden) = 0;
///
/// 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.
/// 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.
///
/*--cef()--*/
virtual void NotifyScreenInfoChanged() = 0;

View File

@@ -38,7 +38,6 @@
#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"
@@ -124,7 +123,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 DIP coordinates. Return true if
/// |new_size| will be the desired size in view coordinates. Return true if
/// the resize was handled or false for default handling.
///
/*--cef()--*/
@@ -163,46 +162,6 @@ 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

@@ -48,8 +48,14 @@ 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
/// https://bitbucket.org/chromiumembedded/cef/wiki/SandboxSetup.md for usage
/// details. See include/wrapper/cef_library_loader.h for example usage.
/// 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.
///
///
@@ -70,7 +76,7 @@ CEF_EXPORT void cef_sandbox_destroy(void* sandbox_context);
///
/// Scoped helper for managing the life span of a sandbox context handle.
///
class CefScopedSandboxContext final {
class CEF_EXPORT CefScopedSandboxContext {
public:
CefScopedSandboxContext();
~CefScopedSandboxContext();
@@ -81,8 +87,7 @@ class CefScopedSandboxContext final {
bool Initialize(int argc, char** argv);
private:
void* library_handle_ = nullptr;
void* sandbox_context_ = nullptr;
void* sandbox_context_;
};
#endif // __cplusplus

View File

@@ -37,12 +37,6 @@
#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
@@ -52,9 +46,17 @@ 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
/// https://bitbucket.org/chromiumembedded/cef/wiki/SandboxSetup.md for usage
/// http://www.chromium.org/developers/design-documents/sandbox for complete
/// 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
@@ -74,7 +76,7 @@ void cef_sandbox_info_destroy(void* sandbox_info);
///
/// Manages the life span of a sandbox information object.
///
class CefScopedSandboxInfo final {
class CefScopedSandboxInfo {
public:
CefScopedSandboxInfo() { sandbox_info_ = cef_sandbox_info_create(); }
~CefScopedSandboxInfo() { cef_sandbox_info_destroy(sandbox_info_); }
@@ -86,39 +88,6 @@ class CefScopedSandboxInfo final {
};
#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,9 +30,6 @@
#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)
@@ -58,66 +55,6 @@ 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,8 +41,6 @@
#include <windows.h>
#endif
#include "include/internal/cef_export.h"
#ifdef __cplusplus
extern "C" {
#endif

View File

@@ -672,11 +672,7 @@ 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
@@ -1065,11 +1061,6 @@ 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,
@@ -1102,16 +1093,7 @@ 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.
@@ -1289,11 +1271,7 @@ 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;
///
@@ -3646,9 +3624,6 @@ typedef enum {
#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;
@@ -3659,13 +3634,8 @@ 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;
@@ -3818,9 +3788,6 @@ 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

@@ -43,12 +43,11 @@ 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,
@@ -236,15 +235,11 @@ 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.
#if CEF_API_ADDED(13800)
CEF_CONTENT_SETTING_TYPE_INSECURE_PRIVATE_NETWORK_DEPRECATED,
#else
/// Stores whether to allow insecure websites to make private network
/// requests.
/// See also: https://wicg.github.io/cors-rfc1918
/// Set through enterprise policies only.
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.
@@ -334,7 +329,7 @@ typedef enum {
/// HTTP header.
CEF_CONTENT_SETTING_TYPE_FEDERATED_IDENTITY_IDENTITY_PROVIDER_SIGNIN_STATUS,
/// Website setting which is used for RevokedPermissionsService to
/// Website setting which is used for UnusedSitePermissionsService to
/// store revoked permissions of unused sites from unused site permissions
/// feature.
CEF_CONTENT_SETTING_TYPE_REVOKED_UNUSED_SITE_PERMISSIONS,
@@ -387,16 +382,12 @@ 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.
#if CEF_API_ADDED(13601)
CEF_CONTENT_SETTING_TYPE_TOP_LEVEL_TPCD_ORIGIN_TRIAL,
#else
/// Content Setting for a first-party origin trial that allows websites to
/// enable third-party cookie deprecation.
/// ALLOW (default): no effect (e.g. third-party cookies allowed, if not
/// blocked otherwise).
/// BLOCK: third-party cookies blocked, but 3PCD mitigations enabled.
CEF_CONTENT_SETTING_TOP_LEVEL_TPCD_ORIGIN_TRIAL,
#endif
/// Content setting used to indicate whether entering picture-in-picture
/// automatically should be enabled.
@@ -447,7 +438,7 @@ typedef enum {
/// access to mouse inputs.
CEF_CONTENT_SETTING_TYPE_POINTER_LOCK,
/// Website setting which is used for RevokedPermissionsService to store
/// Website setting which is used for UnusedSitePermissionsService to store
/// auto-revoked notification permissions from abusive sites.
CEF_CONTENT_SETTING_TYPE_REVOKED_ABUSIVE_NOTIFICATION_PERMISSIONS,
@@ -505,32 +496,11 @@ typedef enum {
#endif
#if CEF_API_ADDED(13500)
/// Website setting which is used for RevokedPermissionsService to
/// Website setting which is used for UnusedSitePermissionsService 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,9 +567,7 @@ 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,7 +38,6 @@
#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"
@@ -130,18 +129,6 @@ 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,9 +50,6 @@
/// 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:
@@ -132,9 +129,7 @@ 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. Windowed browsers with 1.0 zoom will have a
/// JavaScript `window.devicePixelRatio` value matching the associated
/// Display's GetDeviceScaleFactor() value.
/// values differ by platform.
///
/*--cef()--*/
virtual float GetDeviceScaleFactor() = 0;

View File

@@ -1,151 +0,0 @@
// 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"
#if defined(OS_MAC)
#ifdef __cplusplus
#include <string>
extern "C" {
#endif
#endif // __cplusplus
///
/// Load the CEF library at the specified |path|. Returns true (1) on
@@ -53,12 +53,6 @@ int cef_unload_library(void);
#ifdef __cplusplus
}
#endif
#endif // defined(OS_MAC)
#ifdef __cplusplus
#include <string>
#if defined(OS_MAC)
@@ -90,8 +84,7 @@ int cef_unload_library(void);
/// #include "include/wrapper/cef_library_loader.h"
///
/// int main(int argc, char* argv[]) {
/// // Dynamically load and initialize the macOS sandbox for this helper
/// // process.
/// // Initialize the macOS sandbox for this helper process.
/// CefScopedSandboxContext sandbox_context;
/// if (!sandbox_context.Initialize(argc, argv))
/// return 1;
@@ -105,7 +98,7 @@ int cef_unload_library(void);
/// }
/// </pre>
///
class CefScopedLibraryLoader final {
class CefScopedLibraryLoader {
public:
CefScopedLibraryLoader();
@@ -131,101 +124,10 @@ class CefScopedLibraryLoader final {
private:
bool Load(bool helper);
bool loaded_ = false;
bool loaded_;
};
#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 // defined(OS_MAC)
#endif // __cplusplus
#endif // CEF_INCLUDE_WRAPPER_CEF_LIBRARY_LOADER_H_

View File

@@ -1,65 +0,0 @@
// 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,7 +117,8 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
scoped_refptr<CefBrowserInfo> info =
CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
/*is_devtools_popup=*/false, platform_delegate->GetBrowserConfig(),
/*is_devtools_popup=*/false, platform_delegate->IsWindowless(),
platform_delegate->IsPrintPreviewSupported(),
create_params.extra_info);
bool own_web_contents = false;
@@ -131,7 +132,8 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
CefRefPtr<AlloyBrowserHostImpl> browser =
CreateInternal(create_params.settings, create_params.client, web_contents,
own_web_contents, info, /*opener=*/nullptr,
own_web_contents, info,
/*opener=*/nullptr, /*is_devtools_popup=*/false,
request_context_impl, std::move(platform_delegate));
if (!browser) {
return nullptr;
@@ -158,6 +160,7 @@ 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();
@@ -182,7 +185,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
// new browser's platform delegate.
opener->platform_delegate_->PopupWebContentsCreated(
settings, client, web_contents, platform_delegate.get(),
/*is_devtools=*/false);
is_devtools_popup);
}
// Take ownership of |web_contents| if |own_web_contents| is true.
@@ -205,7 +208,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=*/false);
browser->platform_delegate(), browser.get(), is_devtools_popup);
}
// 2. Notify the browser's LifeSpanHandler. This must always be the first
@@ -416,6 +419,24 @@ 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";
@@ -980,11 +1001,6 @@ 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);
@@ -1105,7 +1121,8 @@ void AlloyBrowserHostImpl::WebContentsCreated(
scoped_refptr<CefBrowserInfo> info =
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
new_contents, platform_delegate->GetBrowserConfig(), extra_info);
new_contents, platform_delegate->IsWindowless(),
platform_delegate->IsPrintPreviewSupported(), extra_info);
CHECK(info.get());
CHECK(info->is_popup());
@@ -1123,7 +1140,8 @@ 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,
request_context, std::move(platform_delegate));
/*is_devtools_popup=*/false, request_context,
std::move(platform_delegate));
}
void AlloyBrowserHostImpl::RendererUnresponsive(

View File

@@ -90,6 +90,7 @@ 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;
@@ -192,8 +193,6 @@ 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,
@@ -299,6 +298,7 @@ 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_ = base::MakeRefCounted<media::AudioInputDevice>(
audio_input_device_ = new media::AudioInputDevice(
std::make_unique<mirroring::CapturedAudioInput>(
base::BindRepeating(&StreamCreatorHelper,
base::Unretained(browser_->web_contents()),

View File

@@ -142,18 +142,6 @@ 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) {

View File

@@ -87,10 +87,6 @@ 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;

View File

@@ -817,30 +817,9 @@ 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";

View File

@@ -265,7 +265,6 @@ class CefBrowserHostBase : public CefBrowserHost,
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;

View File

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

View File

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

View File

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

View File

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

View File

@@ -244,7 +244,8 @@ void CefBrowserPlatformDelegate::PopupBrowserCreated(
return;
}
auto new_browser_view = new_browser->GetBrowserView();
CefRefPtr<CefBrowserView> new_browser_view =
CefBrowserView::GetForBrowser(new_browser);
CHECK(new_browser_view);
bool popup_handled = false;
@@ -388,7 +389,9 @@ bool CefBrowserPlatformDelegate::IsHidden() const {
return false;
}
void CefBrowserPlatformDelegate::NotifyScreenInfoChanged() {}
void CefBrowserPlatformDelegate::NotifyScreenInfoChanged() {
DCHECK(false);
}
void CefBrowserPlatformDelegate::Invalidate(cef_paint_element_type_t type) {
DCHECK(false);
@@ -564,15 +567,6 @@ 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,7 +15,6 @@
#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"
@@ -306,7 +305,7 @@ class CefBrowserPlatformDelegate {
virtual bool IsHidden() const;
// Notify the browser that screen information has changed. Only used with
// windowless rendering and external (client-provided) root window.
// windowless rendering.
virtual void NotifyScreenInfoChanged();
// Invalidate the view. Only used with windowless rendering.
@@ -371,12 +370,6 @@ 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_DEPRECATED,
kSendTabToSelf_DEPRECATED,
kDownload,
kSendTabToSelf,
kSidePanel,
kMaxValue = kSidePanel,
};
@@ -173,12 +173,6 @@ 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, platform_delegate->GetBrowserConfig(),
create_params_.extra_info);
is_devtools_popup, /*is_windowless=*/false,
platform_delegate->IsPrintPreviewSupported(), create_params_.extra_info);
auto request_context_impl =
CefRequestContextImpl::GetOrCreateForRequestContext(
@@ -573,14 +573,6 @@ 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)) {
@@ -767,7 +759,8 @@ ChromeBrowserDelegate::CreateBrowserHostForPopup(
auto browser_info =
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
web_contents, platform_delegate->GetBrowserConfig(), extra_info);
web_contents, /*is_windowless=*/false,
platform_delegate->IsPrintPreviewSupported(), extra_info);
CHECK(browser_info->is_popup());
// Popups must share the same RequestContext as the parent.

View File

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

View File

@@ -250,6 +250,10 @@ void ChromeBrowserHostImpl::WasHidden(bool hidden) {
NOTIMPLEMENTED();
}
void ChromeBrowserHostImpl::NotifyScreenInfoChanged() {
NOTIMPLEMENTED();
}
void ChromeBrowserHostImpl::Invalidate(PaintElementType type) {
NOTIMPLEMENTED();
}
@@ -496,7 +500,8 @@ void ChromeBrowserHostImpl::Attach(content::WebContents* web_contents,
is_devtools_popup);
}
platform_delegate_->WebContentsCreated(web_contents, /*owned=*/false);
platform_delegate_->WebContentsCreated(web_contents,
/*own_web_contents=*/false);
contents_delegate_.ObserveWebContents(web_contents);
// Associate the platform delegate with this browser.

View File

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

View File

@@ -9,7 +9,6 @@
#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"
@@ -51,10 +50,6 @@
#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
@@ -165,18 +160,6 @@ void HandleExternalProtocolHelper(
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;
@@ -231,23 +214,6 @@ 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);
@@ -588,10 +554,13 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
return true;
}
void ChromeContentBrowserClientCef::CreateThrottlesForNavigation(
content::NavigationThrottleRegistry& registry) {
ChromeContentBrowserClient::CreateThrottlesForNavigation(registry);
throttle::CreateThrottlesForNavigation(registry);
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;
}
bool ChromeContentBrowserClientCef::ConfigureNetworkContextParams(

View File

@@ -113,8 +113,9 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
const net::IsolationInfo& isolation_info,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
void CreateThrottlesForNavigation(
content::NavigationThrottleRegistry& registry) override;
std::vector<std::unique_ptr<content::NavigationThrottle>>
CreateThrottlesForNavigation(
content::NavigationHandle* navigation_handle) override;
bool ConfigureNetworkContextParams(
content::BrowserContext* context,
bool in_memory,

View File

@@ -130,16 +130,6 @@ 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,7 +34,6 @@ 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,10 +14,6 @@
#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) {
@@ -65,9 +61,6 @@ 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 {
@@ -78,38 +71,22 @@ 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 Windows delegate needs state to perform some actions.
auto* delegate_win =
static_cast<CefBrowserPlatformDelegateNativeWin*>(native_delegate_);
delegate_win->set_widget(widget, 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);
if (window_info_.ex_style & WS_EX_NOACTIVATE) {
const DWORD widget_ex_styles = GetWindowLongPtr(widget_hwnd, GWL_EXSTYLE);
@@ -128,7 +105,6 @@ class ChildWindowDelegate : public CefWindowDelegate {
return;
}
#endif // BUILDFLAG(IS_WIN)
#endif // defined(USE_AURA)
window_->Show();
@@ -136,6 +112,7 @@ 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) {}
@@ -145,11 +122,6 @@ class ChildWindowDelegate : public CefWindowDelegate {
CefRefPtr<CefWindow> window_;
#if defined(USE_AURA)
base::raw_ptr<CefBrowserPlatformDelegateNativeAura> native_delegate_ =
nullptr;
#endif
IMPLEMENT_REFCOUNTING(ChildWindowDelegate);
};

View File

@@ -22,9 +22,9 @@
#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
@@ -185,6 +185,110 @@ 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
@@ -314,6 +418,23 @@ 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()) {

View File

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

@@ -1,22 +0,0 @@
// 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_ = gfx::NativeWindow();
gfx::NativeWindow owning_window_ = nullptr;
bool has_multiple_file_choices_ = false;
CefRefPtr<CefBrowserHostBase> browser_;

View File

@@ -13,13 +13,11 @@
#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"
@@ -29,6 +27,7 @@
#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>
@@ -36,11 +35,57 @@
#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),
@@ -179,15 +224,10 @@ 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()) {
// Early exit on invalid process type.
return CEF_RESULT_CODE_BAD_PROCESS_TYPE;
return -1;
}
auto main_delegate = std::make_unique<ChromeMainDelegateCef>(
@@ -195,35 +235,15 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args,
BeforeMainInitialize(args);
if (process_type == crash_reporter::switches::kCrashpadHandler) {
return crashpad_runner::RunAsCrashpadHandler(command_line);
return 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};
// 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);
}
if (windows_sandbox_info == nullptr) {
content::InitializeSandboxInfo(&sandbox_info);
windows_sandbox_info = &sandbox_info;
}

View File

@@ -5,7 +5,6 @@
#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"
@@ -25,25 +24,3 @@ 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,7 +32,6 @@ 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,7 +4,6 @@
#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"
@@ -20,42 +19,6 @@ 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,10 +25,7 @@ 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,
@@ -74,16 +71,9 @@ 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::GetScreenWin()->DIPToScreenRect(window, dip_rect);
display::win::ScreenWin::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::GetScreenWin()->ScreenToDIPRect(
const auto dip_rect = display::win::ScreenWin::ScreenToDIPRect(
nullptr, gfx::Rect(screen_rect.x, screen_rect.y, screen_rect.width,
screen_rect.height));
const auto visible_dip_rect = MakeVisibleOnScreenRect(
@@ -206,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::GetScreenWin()->ScreenToDIPRect(
const gfx::Rect dip_rect = display::win::ScreenWin::ScreenToDIPRect(
window_info_.window, gfx::Rect(0, 0, cr.right, cr.bottom));
// Stay on top if top-most window hosting the web view is topmost.
@@ -427,27 +427,6 @@ 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);
@@ -617,8 +596,8 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
case WM_MOVING:
case WM_MOVE:
if (platform_delegate) {
platform_delegate->NotifyMoveOrResizeStarted();
if (browser) {
browser->NotifyMoveOrResizeStarted();
}
return 0;

View File

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

View File

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

View File

@@ -92,19 +92,19 @@ void NavigationOnUIThread(
} // namespace
void CreateThrottlesForNavigation(
content::NavigationThrottleRegistry& registry) {
void CreateThrottlesForNavigation(content::NavigationHandle* navigation_handle,
NavigationThrottleList& throttles) {
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>(
registry, base::BindRepeating(&NavigationOnUIThread),
navigation_handle, base::BindRepeating(&NavigationOnUIThread),
navigation_interception::SynchronyMode::kSync, std::nullopt);
// Always execute our throttle first.
registry.AddThrottle(std::move(throttle), /*first=*/true);
throttles.emplace(throttles.begin(), std::move(throttle));
}
} // namespace throttle

View File

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

View File

@@ -252,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(
partition_key_collection = net::CookiePartitionKeyCollection::FromOptional(
net::CookiePartitionKey::FromNetworkIsolationKey(
isolation_info.network_isolation_key(), request.site_for_cookies,
net::SchemefulSite(request.url),

View File

@@ -443,9 +443,7 @@ void CefRenderWidgetHostViewOSR::Hide() {
}
if (render_widget_host_) {
if (render_widget_host_->delegate()) {
render_widget_host_->WasHidden();
}
render_widget_host_->WasHidden();
auto provider = content::RenderWidgetHostImpl::From(render_widget_host_)
->render_frame_metadata_provider();
@@ -503,11 +501,7 @@ CefRenderWidgetHostViewOSR::GetDisplayFeature() {
return std::nullopt;
}
void CefRenderWidgetHostViewOSR::DisableDisplayFeatureOverrideForEmulation() {
DCHECK(false);
}
void CefRenderWidgetHostViewOSR::OverrideDisplayFeatureForEmulation(
void CefRenderWidgetHostViewOSR::SetDisplayFeatureForTesting(
const content::DisplayFeature* display_feature) {
DCHECK(false);
}

View File

@@ -132,8 +132,7 @@ class CefRenderWidgetHostViewOSR
std::optional<SkColor> GetBackgroundColor() override;
void UpdateBackgroundColor() override;
std::optional<content::DisplayFeature> GetDisplayFeature() override;
void DisableDisplayFeatureOverrideForEmulation() override;
void OverrideDisplayFeatureForEmulation(
void SetDisplayFeatureForTesting(
const content::DisplayFeature* display_feature) override;
blink::mojom::PointerLockResult LockPointer(
bool request_unadjusted_movement) override;

View File

@@ -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,7 +9,6 @@
#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 {
@@ -246,8 +245,6 @@ 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

@@ -1,129 +0,0 @@
#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

@@ -93,6 +93,7 @@ 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,
}
}
std::variant<printing::mojom::PrintPagesParamsPtr, std::string>
absl::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 (std::holds_alternative<std::string>(print_pages_params)) {
if (absl::holds_alternative<std::string>(print_pages_params)) {
LOG(ERROR) << "PrintToPDF failed with error: "
<< std::get<std::string>(print_pages_params);
<< absl::get<std::string>(print_pages_params);
callback->OnPdfPrintFinished(CefString(), false);
return;
}
DCHECK(std::holds_alternative<printing::mojom::PrintPagesParamsPtr>(
DCHECK(absl::holds_alternative<printing::mojom::PrintPagesParamsPtr>(
print_pages_params));
if (auto* print_manager =

View File

@@ -530,18 +530,14 @@ 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, *setting_type, &info);
requesting_gurl, top_level_gurl,
static_cast<ContentSettingsType>(content_type), &info);
if (value.is_none()) {
return nullptr;
}
@@ -580,22 +576,19 @@ 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(*setting_type,
/*provider_id=*/nullptr);
value = settings_map->GetDefaultContentSetting(
static_cast<ContentSettingsType>(content_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,
*setting_type);
value = settings_map->GetContentSetting(
requesting_gurl, top_level_gurl,
static_cast<ContentSettingsType>(content_type));
}
}
@@ -908,11 +901,6 @@ 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()) {
@@ -922,13 +910,14 @@ void CefRequestContextImpl::SetWebsiteSettingInternal(
if (requesting_url.empty() && top_level_url.empty()) {
settings_map->SetWebsiteSettingCustomScope(
ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(),
*setting_type, std::move(new_value));
static_cast<ContentSettingsType>(content_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, *setting_type, std::move(new_value));
requesting_gurl, top_level_gurl,
static_cast<ContentSettingsType>(content_type), std::move(new_value));
}
}
}
@@ -950,20 +939,17 @@ 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(*setting_type,
static_cast<ContentSetting>(value));
settings_map->SetDefaultContentSetting(
static_cast<ContentSettingsType>(content_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, *setting_type,
requesting_gurl, top_level_gurl,
static_cast<ContentSettingsType>(content_type),
static_cast<ContentSetting>(value));
}
}

View File

@@ -107,283 +107,12 @@ void Registrar::OnContentSettingChanged(
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());
const auto content_type =
static_cast<cef_content_setting_types_t>(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

View File

@@ -5,14 +5,10 @@
#ifndef CEF_LIBCEF_BROWSER_SETTING_HELPER_H_
#define CEF_LIBCEF_BROWSER_SETTING_HELPER_H_
#include <optional>
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "cef/include/cef_registration.h"
#include "cef/include/internal/cef_types_content_settings.h"
#include "components/content_settings/core/browser/content_settings_observer.h"
#include "components/content_settings/core/common/content_settings_types.h"
class CefSettingObserver;
class CefRegistration;
@@ -80,11 +76,6 @@ class Registrar final : public content_settings::Observer {
base::ObserverList<Registration> observers_;
};
// Convert between cef_content_setting_types_t and ContentSettingsType.
cef_content_setting_types_t ToCefType(ContentSettingsType type);
std::optional<ContentSettingsType> FromCefType(
cef_content_setting_types_t type);
} // namespace setting_helper
#endif // CEF_LIBCEF_BROWSER_SETTING_HELPER_H_

View File

@@ -3,6 +3,7 @@
// can be found in the LICENSE file.
#include "base/feature_list.h"
#include "base/features.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "cef/include/test/cef_test_helpers.h"
@@ -19,6 +20,7 @@ bool CefIsFeatureEnabledForTests(const CefString& feature_name) {
// Only includes values that are queried by unit tests.
const base::Feature* features[] = {
&net::features::kIgnoreHSTSForLocalhost,
&base::features::kUseRustJsonParser,
&network::features::kReduceAcceptLanguage,
};

View File

@@ -190,9 +190,7 @@ void CefOverlayViewHost::Init(views::View* host_view,
// Initialize the Widget. |widget_| will be deleted by the NativeWidget or
// when WidgetDelegate::DeleteDelegate() deletes |this|.
widget_ = std::make_unique<ThemeCopyingWidget>(window_view_->GetWidget());
views::Widget::InitParams params(
views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET,
views::Widget::InitParams::TYPE_CONTROL);
views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
params.delegate = this;
params.name = "CefOverlayViewHost";
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
@@ -216,9 +214,8 @@ void CefOverlayViewHost::Init(views::View* host_view,
// Cause WidgetDelegate::DeleteDelegate() to delete |this| after executing the
// registered DeleteDelegate callback.
SetOwnedByWidget(OwnedByWidgetPassKey());
SetOwnedByWidget(true);
RegisterDeleteDelegateCallback(
RegisterDeleteCallbackPassKey(),
base::BindOnce(&CefOverlayViewHost::Cleanup, base::Unretained(this)));
if (window_view_->IsChromeStyle()) {

View File

@@ -218,7 +218,7 @@ display::Display GetDisplayNearestPoint(const gfx::Point& point,
#if BUILDFLAG(IS_WIN)
if (input_pixel_coords) {
find_point = gfx::ToFlooredPoint(
display::win::GetScreenWin()->ScreenToDIPPoint(gfx::PointF(point)));
display::win::ScreenWin::ScreenToDIPPoint(gfx::PointF(point)));
}
#endif
return display::Screen::GetScreen()->GetDisplayNearestPoint(find_point);
@@ -230,7 +230,7 @@ display::Display GetDisplayMatchingBounds(const gfx::Rect& bounds,
#if BUILDFLAG(IS_WIN)
if (input_pixel_coords) {
find_bounds =
display::win::GetScreenWin()->ScreenToDIPRect(nullptr, find_bounds);
display::win::ScreenWin::ScreenToDIPRect(nullptr, find_bounds);
}
#endif
return display::Screen::GetScreen()->GetDisplayMatching(find_bounds);
@@ -249,19 +249,19 @@ void ConvertPointToPixels(gfx::Point* point, float device_scale_factor) {
#if BUILDFLAG(IS_WIN)
gfx::Point ConvertPointFromPixels(const gfx::Point& point) {
return gfx::ToFlooredPoint(
display::win::GetScreenWin()->ScreenToDIPPoint(gfx::PointF(point)));
display::win::ScreenWin::ScreenToDIPPoint(gfx::PointF(point)));
}
gfx::Point ConvertPointToPixels(const gfx::Point& point) {
return display::win::GetScreenWin()->DIPToScreenPoint(point);
return display::win::ScreenWin::DIPToScreenPoint(point);
}
gfx::Rect ConvertRectFromPixels(const gfx::Rect& rect) {
return display::win::GetScreenWin()->ScreenToDIPRect(nullptr, rect);
return display::win::ScreenWin::ScreenToDIPRect(nullptr, rect);
}
gfx::Rect ConvertRectToPixels(const gfx::Rect& rect) {
return display::win::GetScreenWin()->DIPToScreenRect(nullptr, rect);
return display::win::ScreenWin::DIPToScreenRect(nullptr, rect);
}
#endif // BUILDFLAG(IS_WIN)
@@ -377,7 +377,7 @@ std::optional<SkColor> GetBackgroundColor(const views::View* view,
bool allow_transparent) {
// Return the configured background color, if any.
if (view->background()) {
return view->background()->color().GetSkColor();
return view->background()->get_color();
}
// If the containing Widget is an overlay then it has a transparent background

View File

@@ -110,7 +110,7 @@ class NativeFrameViewEx : public views::NativeFrameView {
// Convert from DIP to pixel coordinates using a method that can handle
// multiple displays with different DPI.
const auto screen_rect =
display::win::GetScreenWin()->DIPToScreenRect(window, client_bounds);
display::win::ScreenWin::DIPToScreenRect(window, client_bounds);
RECT rect = {screen_rect.x(), screen_rect.y(),
screen_rect.x() + screen_rect.width(),
@@ -123,7 +123,7 @@ class NativeFrameViewEx : public views::NativeFrameView {
rect.right - rect.left, rect.bottom - rect.top);
// Convert back to DIP.
return display::win::GetScreenWin()->ScreenToDIPRect(window, pixel_rect);
return display::win::ScreenWin::ScreenToDIPRect(window, pixel_rect);
#else
// Use the default implementation.
return views::NativeFrameView::GetWindowBoundsForClientBounds(
@@ -420,9 +420,8 @@ void CefWindowView::CreateWidget(gfx::AcceleratedWidget parent_widget) {
// Cause WidgetDelegate::DeleteDelegate() to delete |this| after executing the
// registered DeleteDelegate callback.
SetOwnedByWidget(OwnedByWidgetPassKey());
SetOwnedByWidget(true);
RegisterDeleteDelegateCallback(
RegisterDeleteCallbackPassKey(),
base::BindOnce(&CefWindowView::DeleteDelegate, base::Unretained(this)));
if (cef_delegate()) {

View File

@@ -463,7 +463,7 @@ std::optional<int> ChromeMainDelegateCef::PostEarlyInitialization(
const auto result = ChromeMainDelegate::PostEarlyInitialization(invoked_in);
if (!result) {
const auto* invoked_in_browser =
std::get_if<InvokedInBrowserProcess>(&invoked_in);
absl::get_if<InvokedInBrowserProcess>(&invoked_in);
if (invoked_in_browser) {
// At this point local_state has been created but ownership has not yet
// been passed to BrowserProcessImpl (g_browser_process is nullptr).
@@ -479,7 +479,7 @@ std::optional<int> ChromeMainDelegateCef::PostEarlyInitialization(
return result;
}
std::variant<int, content::MainFunctionParams>
absl::variant<int, content::MainFunctionParams>
ChromeMainDelegateCef::RunProcess(
const std::string& process_type,
content::MainFunctionParams main_function_params) {

View File

@@ -43,7 +43,7 @@ class ChromeMainDelegateCef : public ChromeMainDelegate,
void SandboxInitialized(const std::string& process_type) override;
std::optional<int> PreBrowserMain() override;
std::optional<int> PostEarlyInitialization(InvokedIn invoked_in) override;
std::variant<int, content::MainFunctionParams> RunProcess(
absl::variant<int, content::MainFunctionParams> RunProcess(
const std::string& process_type,
content::MainFunctionParams main_function_params) override;
#if BUILDFLAG(IS_LINUX)

View File

@@ -548,12 +548,13 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
// Allow override of some values via environment variables.
{
std::unique_ptr<base::Environment> env(base::Environment::Create());
if (const auto& var_str = env->GetVar("CEF_CRASH_REPORTER_SERVER_URL")) {
ParseURL(*var_str, &server_url_);
std::string val_str;
if (env->GetVar("CEF_CRASH_REPORTER_SERVER_URL", &val_str)) {
ParseURL(val_str, &server_url_);
}
if (const auto& var_str =
env->GetVar("CEF_CRASH_REPORTER_RATE_LIMIT_ENABLED")) {
rate_limit_ = ParseBool(*var_str);
if (env->GetVar("CEF_CRASH_REPORTER_RATE_LIMIT_ENABLED", &val_str)) {
rate_limit_ = ParseBool(val_str);
}
}
@@ -641,9 +642,11 @@ bool CefCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
// By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
// location to write breakpad crash dumps can be set.
std::unique_ptr<base::Environment> env(base::Environment::Create());
if (const auto& val = env->GetVar("BREAKPAD_DUMP_LOCATION")) {
base::PathService::Override(chrome::DIR_CRASH_DUMPS,
base::FilePath::FromUTF8Unsafe(*val));
std::string alternate_crash_dump_location;
if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) {
base::FilePath crash_dumps_dir_path =
base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location);
base::PathService::Override(chrome::DIR_CRASH_DUMPS, crash_dumps_dir_path);
}
return base::PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir);
}
@@ -723,7 +726,8 @@ bool CefCrashReporterClient::EnableBrowserCrashForwarding() {
// storage for each key size and later substituting the actual key name during
// crash dump processing.
#define IDKEY(name) {name, IDKey::Tag::kArray}
#define IDKEY(name) \
{ name, IDKey::Tag::kArray }
#define IDKEY_ENTRIES(n) \
IDKEY(n "-A"), IDKEY(n "-B"), IDKEY(n "-C"), IDKEY(n "-D"), IDKEY(n "-E"), \

View File

@@ -111,19 +111,12 @@ struct NewRenderThreadInfo {
array<CrossOriginWhiteListEntry>? cross_origin_whitelist_entries;
};
struct NewBrowserConfig {
bool is_popup;
// Values from cef::BrowserConfig.
bool is_windowless;
bool print_preview_enabled;
bool move_pip_enabled;
};
struct NewBrowserInfo {
int32 browser_id;
bool? is_popup;
bool? is_windowless;
bool? print_preview_enabled;
bool is_excluded;
NewBrowserConfig? config;
mojo_base.mojom.DictionaryValue? extra_info;
};

View File

@@ -36,7 +36,9 @@ std::string GenerateHeaders(const HeaderMap& map) {
void ParseHeaders(const std::string& header_str, HeaderMap& map) {
// Parse the request header values
for (net::HttpUtil::HeadersIterator i(header_str, "\n\r"); i.GetNext();) {
for (net::HttpUtil::HeadersIterator i(header_str.begin(), header_str.end(),
"\n\r");
i.GetNext();) {
map.insert(std::make_pair(i.name(), i.values()));
}
}

View File

@@ -568,7 +568,8 @@ void CefRequestImpl::Get(const cef::mojom::RequestParamsPtr& params,
CefRequest::HeaderMap headerMap;
if (!params->headers.empty()) {
for (net::HttpUtil::HeadersIterator i(params->headers, "\n\r");
for (net::HttpUtil::HeadersIterator i(params->headers.begin(),
params->headers.end(), "\n\r");
i.GetNext();) {
request.AddHttpHeaderField(blink::WebString::FromUTF8(i.name()),
blink::WebString::FromUTF8(i.values()));

View File

@@ -48,7 +48,7 @@ void OverrideBaseBundleID() {
std::string bundle_id = GetMainBundleID();
DCHECK(!bundle_id.empty());
base::apple::SetBaseBundleIDOverride(bundle_id);
base::apple::SetBaseBundleID(bundle_id.c_str());
}
base::FilePath GetNormalChildProcessPath() {

View File

@@ -84,6 +84,7 @@ buildflag_header("buildflags") {
flags = [
"ENABLE_CEF=$enable_cef",
"IS_CEF_SANDBOX_BUILD=$is_cef_sandbox_build",
]
}

View File

@@ -5,6 +5,13 @@
declare_args() {
enable_cef = true
# Enables base target customizations necessary for distribution of the
# cef_sandbox static library. This value will be set via gn_args.py for the
# official sandbox build configurations only. DO NOT SET THIS VALUE MANUALLY
# FOR OTHER CHROMIUM/CEF BUILD CONFIGURATIONS AS ITS USE MAY HAVE SIGNIFICANT
# PERFORMANCE AND/OR SECURITY IMPLICATIONS.
is_cef_sandbox_build = false
# Optionally configure the CEF API version. This impacts wrapper-side only.
cef_api_version = ""
}

View File

@@ -1,22 +0,0 @@
// Copyright 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.
#ifndef CEF_LIBCEF_RENDERER_BROWSER_CONFIG_H_
#define CEF_LIBCEF_RENDERER_BROWSER_CONFIG_H_
#pragma once
namespace cef {
// CefBrowser configuration determined prior to CefBrowserHost creation (in
// CefBrowserPlatformDelegate::GetBrowserConfig) and passed to the renderer
// process via the GetNewBrowserInfo Mojo request.
struct BrowserConfig {
bool is_windowless;
bool print_preview_enabled;
bool move_pip_enabled;
};
} // namespace cef
#endif // CEF_LIBCEF_RENDERER_BROWSER_CONFIG_H_

View File

@@ -276,11 +276,13 @@ void CefBrowserImpl::GetFrameNames(std::vector<CefString>& names) {
CefBrowserImpl::CefBrowserImpl(blink::WebView* web_view,
int browser_id,
bool is_popup,
const cef::BrowserConfig& config)
bool is_windowless,
bool print_preview_enabled)
: blink::WebViewObserver(web_view),
browser_id_(browser_id),
is_popup_(is_popup),
config_(config) {}
is_windowless_(is_windowless),
print_preview_enabled_(print_preview_enabled) {}
CefBrowserImpl::~CefBrowserImpl() = default;

View File

@@ -16,7 +16,6 @@
#include "cef/include/cef_browser.h"
#include "cef/include/cef_client.h"
#include "cef/libcef/renderer/browser_config.h"
#include "cef/libcef/renderer/frame_impl.h"
#include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/public/web/web_view_observer.h"
@@ -67,7 +66,8 @@ class CefBrowserImpl : public CefBrowser, public blink::WebViewObserver {
CefBrowserImpl(blink::WebView* web_view,
int browser_id,
bool is_popup,
const cef::BrowserConfig& config);
bool is_windowless,
bool print_preview_enabled);
CefBrowserImpl(const CefBrowserImpl&) = delete;
CefBrowserImpl& operator=(const CefBrowserImpl&) = delete;
@@ -80,7 +80,8 @@ class CefBrowserImpl : public CefBrowser, public blink::WebViewObserver {
int browser_id() const { return browser_id_; }
bool is_popup() const { return is_popup_; }
const cef::BrowserConfig& config() const { return config_; }
bool is_windowless() const { return is_windowless_; }
bool print_preview_enabled() const { return print_preview_enabled_; }
// blink::WebViewObserver methods.
void OnDestruct() override;
@@ -95,7 +96,8 @@ class CefBrowserImpl : public CefBrowser, public blink::WebViewObserver {
// same browser ID.
const int browser_id_;
const bool is_popup_;
const cef::BrowserConfig config_;
const bool is_windowless_;
const bool print_preview_enabled_;
// Map of unique frame tokens to CefFrameImpl references.
using FrameMap = std::map<blink::LocalFrameToken, CefRefPtr<CefFrameImpl>>;

View File

@@ -46,19 +46,20 @@ void ChromeContentRendererClientCef::RenderFrameCreated(
new CefRenderFrameObserver(render_frame);
bool browser_created;
std::optional<cef::BrowserConfig> config;
std::optional<bool> is_windowless;
std::optional<bool> print_preview_enabled;
render_manager_->RenderFrameCreated(render_frame, render_frame_observer,
browser_created, config);
browser_created, is_windowless,
print_preview_enabled);
if (browser_created) {
CHECK(config.has_value());
OnBrowserCreated(render_frame->GetWebView(), *config);
OnBrowserCreated(render_frame->GetWebView(), is_windowless);
}
if (config.has_value()) {
// This value will be used when the ChromeContentRendererClient
if (print_preview_enabled.has_value()) {
// This value will be used when the when ChromeContentRendererClient
// creates the new ChromePrintRenderFrameHelperDelegate below.
ChromePrintRenderFrameHelperDelegate::SetNextPrintPreviewEnabled(
(*config).print_preview_enabled);
*print_preview_enabled);
}
ChromeContentRendererClient::RenderFrameCreated(render_frame);
@@ -72,11 +73,12 @@ void ChromeContentRendererClientCef::WebViewCreated(
outermost_origin);
bool browser_created;
std::optional<cef::BrowserConfig> config;
render_manager_->WebViewCreated(web_view, browser_created, config);
std::optional<bool> is_windowless;
std::optional<bool> print_preview_enabled;
render_manager_->WebViewCreated(web_view, browser_created, is_windowless,
print_preview_enabled);
if (browser_created) {
CHECK(config.has_value());
OnBrowserCreated(web_view, *config);
OnBrowserCreated(web_view, is_windowless);
}
}
@@ -115,9 +117,14 @@ void ChromeContentRendererClientCef::ExposeInterfacesToBrowser(
void ChromeContentRendererClientCef::OnBrowserCreated(
blink::WebView* web_view,
const cef::BrowserConfig& config) {
std::optional<bool> is_windowless) {
#if BUILDFLAG(IS_MAC)
web_view->SetUseExternalPopupMenusThisInstance(!config.is_windowless);
const bool windowless = is_windowless.has_value() && *is_windowless;
// FIXME: It would be better if this API would be a callback from the
// WebKit layer, or if it would be exposed as an WebView instance method; the
// current implementation uses a static variable, and WebKit needs to be
// patched in order to make it work for each WebView instance
web_view->SetUseExternalPopupMenusThisInstance(!windowless);
#endif
web_view->SetMovePictureInPictureEnabled(config.move_pip_enabled);
}

View File

@@ -12,10 +12,6 @@
#include "base/task/single_thread_task_runner.h"
#include "chrome/renderer/chrome_content_renderer_client.h"
namespace cef {
struct BrowserConfig;
}
class CefRenderManager;
// CEF override of ChromeContentRendererClient.
@@ -52,7 +48,7 @@ class ChromeContentRendererClientCef : public ChromeContentRendererClient {
private:
void OnBrowserCreated(blink::WebView* web_view,
const cef::BrowserConfig& config);
std::optional<bool> is_windowless);
std::unique_ptr<CefRenderManager> render_manager_;

View File

@@ -56,17 +56,25 @@ class CefExcludedView : public blink::WebViewObserver {
public:
CefExcludedView(CefRenderManager* manager,
blink::WebView* web_view,
const std::optional<cef::BrowserConfig>& config)
: blink::WebViewObserver(web_view), manager_(manager), config_(config) {}
std::optional<bool> is_windowless,
std::optional<bool> print_preview_enabled)
: blink::WebViewObserver(web_view),
manager_(manager),
is_windowless_(is_windowless),
print_preview_enabled_(print_preview_enabled) {}
const std::optional<cef::BrowserConfig>& config() const { return config_; }
std::optional<bool> is_windowless() const { return is_windowless_; }
std::optional<bool> print_preview_enabled() const {
return print_preview_enabled_;
}
private:
// RenderViewObserver methods.
void OnDestruct() override { manager_->OnExcludedViewDestroyed(this); }
CefRenderManager* const manager_;
const std::optional<cef::BrowserConfig> config_;
const std::optional<bool> is_windowless_;
const std::optional<bool> print_preview_enabled_;
};
CefRenderManager::CefRenderManager() {
@@ -102,9 +110,11 @@ void CefRenderManager::RenderFrameCreated(
content::RenderFrame* render_frame,
CefRenderFrameObserver* render_frame_observer,
bool& browser_created,
std::optional<cef::BrowserConfig>& config) {
std::optional<bool>& is_windowless,
std::optional<bool>& print_preview_enabled) {
auto browser = MaybeCreateBrowser(render_frame->GetWebView(), render_frame,
browser_created, config);
&browser_created, &is_windowless,
&print_preview_enabled);
if (browser) {
// Attach the frame to the observer for message routing purposes.
render_frame_observer->AttachFrame(
@@ -120,14 +130,16 @@ void CefRenderManager::RenderFrameCreated(
void CefRenderManager::WebViewCreated(
blink::WebView* web_view,
bool& browser_created,
std::optional<cef::BrowserConfig>& config) {
std::optional<bool>& is_windowless,
std::optional<bool>& print_preview_enabled) {
content::RenderFrame* render_frame = nullptr;
if (web_view->MainFrame()->IsWebLocalFrame()) {
render_frame = content::RenderFrame::FromWebFrame(
web_view->MainFrame()->ToWebLocalFrame());
}
MaybeCreateBrowser(web_view, render_frame, browser_created, config);
MaybeCreateBrowser(web_view, render_frame, &browser_created, &is_windowless,
&print_preview_enabled);
}
void CefRenderManager::DevToolsAgentAttached() {
@@ -282,9 +294,12 @@ void CefRenderManager::WebKitInitialized() {
CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
blink::WebView* web_view,
content::RenderFrame* render_frame,
bool& browser_created,
std::optional<cef::BrowserConfig>& config) {
browser_created = false;
bool* browser_created,
std::optional<bool>* is_windowless,
std::optional<bool>* print_preview_enabled) {
if (browser_created) {
*browser_created = false;
}
if (!web_view || !render_frame) {
return nullptr;
@@ -292,13 +307,25 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
// Don't create another browser or excluded view object if one already exists
// for the view.
if (auto browser = GetBrowserForView(web_view)) {
config = browser->config();
auto browser = GetBrowserForView(web_view);
if (browser) {
if (is_windowless) {
*is_windowless = browser->is_windowless();
}
if (print_preview_enabled) {
*print_preview_enabled = browser->print_preview_enabled();
}
return browser;
}
if (auto excluded_view = GetExcludedViewForView(web_view)) {
config = excluded_view->config();
auto excluded_view = GetExcludedViewForView(web_view);
if (excluded_view) {
if (is_windowless) {
*is_windowless = excluded_view->is_windowless();
}
if (print_preview_enabled) {
*print_preview_enabled = excluded_view->print_preview_enabled();
}
return nullptr;
}
@@ -311,10 +338,11 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
return nullptr;
}
if (params->config) {
config = cef::BrowserConfig{params->config->is_windowless,
params->config->print_preview_enabled,
params->config->move_pip_enabled};
if (is_windowless) {
*is_windowless = params->is_windowless;
}
if (print_preview_enabled) {
*print_preview_enabled = params->print_preview_enabled;
}
if (params->is_excluded || params->browser_id < 0) {
@@ -322,13 +350,15 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
// extension or print preview dialog), or if the new browser info response
// has timed out.
excluded_views_.insert(std::make_pair(
web_view, std::make_unique<CefExcludedView>(this, web_view, config)));
web_view,
std::make_unique<CefExcludedView>(this, web_view, params->is_windowless,
params->print_preview_enabled)));
return nullptr;
}
CHECK(params->config);
CefRefPtr<CefBrowserImpl> browser = new CefBrowserImpl(
web_view, params->browser_id, params->config->is_popup, *config);
browser = new CefBrowserImpl(web_view, params->browser_id, *params->is_popup,
*params->is_windowless,
*params->print_preview_enabled);
browsers_.insert(std::make_pair(web_view, browser));
// Notify the render process handler.
@@ -347,7 +377,9 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
}
}
browser_created = true;
if (browser_created) {
*browser_created = true;
}
return browser;
}

View File

@@ -12,7 +12,6 @@
#include "cef/include/internal/cef_ptr.h"
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "cef/libcef/renderer/browser_config.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
@@ -53,10 +52,12 @@ class CefRenderManager : public cef::mojom::RenderManager {
void RenderFrameCreated(content::RenderFrame* render_frame,
CefRenderFrameObserver* render_frame_observer,
bool& browser_created,
std::optional<cef::BrowserConfig>& config);
std::optional<bool>& is_windowless,
std::optional<bool>& print_preview_enabled);
void WebViewCreated(blink::WebView* web_view,
bool& browser_created,
std::optional<cef::BrowserConfig>& config);
std::optional<bool>& is_windowless,
std::optional<bool>& print_preview_enabled);
void DevToolsAgentAttached();
void DevToolsAgentDetached();
void ExposeInterfacesToBrowser(mojo::BinderMap* binders);
@@ -93,8 +94,9 @@ class CefRenderManager : public cef::mojom::RenderManager {
CefRefPtr<CefBrowserImpl> MaybeCreateBrowser(
blink::WebView* web_view,
content::RenderFrame* render_frame,
bool& browser_created,
std::optional<cef::BrowserConfig>& config);
bool* browser_created,
std::optional<bool>* is_windowless,
std::optional<bool>* print_preview_enabled);
// Called from CefBrowserImpl::OnDestruct().
void OnBrowserDestroyed(CefBrowserImpl* browser);

View File

@@ -29,7 +29,6 @@ set(CEF_TARGET libcef_dll_wrapper)
'autogen_capi_includes',
'includes_wrapper',
'includes_wrapper_mac:MAC',
'includes_wrapper_win:WINDOWS',
'includes_win:WINDOWS',
'includes_win_capi:WINDOWS',
'includes_mac:MAC',
@@ -39,7 +38,6 @@ set(CEF_TARGET libcef_dll_wrapper)
'libcef_dll_wrapper_sources_base',
'libcef_dll_wrapper_sources_common',
'libcef_dll_wrapper_sources_mac:MAC',
'libcef_dll_wrapper_sources_win:WINDOWS',
'autogen_client_side',
],
}}

View File

@@ -9,26 +9,13 @@
#include <windows.h>
#include <algorithm>
#include <sstream>
#elif defined(OS_POSIX)
#include <errno.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#endif
#if defined(OS_APPLE)
#include <mach/mach_time.h>
#endif
#include <iomanip>
#include <iostream>
#include <sstream>
#include "include/base/cef_immediate_crash.h"
#include "include/internal/cef_string_types.h"
namespace cef {
@@ -143,254 +130,8 @@ std::string safe_strerror(int err) {
}
#endif // defined(OS_POSIX)
const internal::Implementation* g_impl_override = nullptr;
const char* const log_severity_names[] = {"INFO", "WARNING", "ERROR", "FATAL"};
static_assert(LOG_NUM_SEVERITIES == std::size(log_severity_names),
"Incorrect number of log_severity_names");
const char* log_severity_name(int severity) {
if (severity >= 0 && severity < LOG_NUM_SEVERITIES) {
return log_severity_names[severity];
}
return "UNKNOWN";
}
#if !defined(NDEBUG) && defined(OS_WIN)
bool IsUser32AndGdi32Available() {
static const bool is_user32_and_gdi32_available = [] {
// If win32k syscalls aren't disabled, then user32 and gdi32 are available.
PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY policy = {};
if (::GetProcessMitigationPolicy(GetCurrentProcess(),
ProcessSystemCallDisablePolicy, &policy,
sizeof(policy))) {
return policy.DisallowWin32kSystemCalls == 0;
}
return true;
}();
return is_user32_and_gdi32_available;
}
std::wstring UTF8ToWide(const std::string& utf8) {
if (utf8.empty()) {
return {};
}
int size = MultiByteToWideChar(CP_UTF8, 0, utf8.data(),
static_cast<int>(utf8.size()), nullptr, 0);
if (size <= 0) {
return {};
}
std::wstring utf16(size, L'\0');
if (MultiByteToWideChar(CP_UTF8, 0, utf8.data(),
static_cast<int>(utf8.size()), &utf16[0],
size) != size) {
return {};
}
return utf16;
}
// Displays a message box to the user with the error message in it. Used for
// fatal messages, where we close the app simultaneously. This is for developers
// only; we don't use this in circumstances (like release builds) where users
// could see it, since users don't understand these messages anyway.
void DisplayDebugMessageInDialog(const std::string& message) {
if (IsUser32AndGdi32Available()) {
MessageBoxW(nullptr, UTF8ToWide(message).c_str(), L"Fatal error",
MB_OK | MB_ICONHAND | MB_TOPMOST);
} else {
OutputDebugStringW(UTF8ToWide(message).c_str());
}
}
#endif // !defined(NDEBUG) && defined(OS_WIN)
[[noreturn]] void HandleFatal(const std::string& message) {
// Don't display assertions to the user in release mode. The enduser can't do
// anything with this information, and displaying message boxes when the
// application is hosed can cause additional problems. We intentionally don't
// implement a dialog on other platforms. You can just look at stderr.
#if !defined(NDEBUG) && defined(OS_WIN)
if (!::IsDebuggerPresent()) {
// Displaying a dialog is unnecessary when debugging and can complicate
// debugging.
DisplayDebugMessageInDialog(message);
}
#endif
// Crash the process to generate a dump.
base::ImmediateCrash();
}
uint64_t TickCount() {
#if defined(OS_WIN)
return ::GetTickCount();
#elif defined(OS_APPLE)
return mach_absolute_time();
#elif defined(OS_POSIX)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
uint64_t absolute_micro = static_cast<uint64_t>(ts.tv_sec) * 1000000 +
static_cast<uint64_t>(ts.tv_nsec) / 1000;
return absolute_micro;
#else
#error Unsupported platform
#endif
}
} // namespace
namespace internal {
const Implementation* GetImplementation() {
if (g_impl_override) {
return g_impl_override;
}
static constexpr Implementation default_impl = {
&cef_get_min_log_level, &cef_get_vlog_level, &cef_log};
return &default_impl;
}
ScopedImplementation::~ScopedImplementation() {
g_impl_override = previous_;
}
ScopedImplementation::ScopedImplementation() = default;
void ScopedImplementation::Init(const Implementation* impl) {
previous_ = g_impl_override;
g_impl_override = impl;
}
} // namespace internal
ScopedEarlySupport::ScopedEarlySupport(const Config& config)
: impl_{{&ScopedEarlySupport::get_min_log_level,
&ScopedEarlySupport::get_vlog_level, &ScopedEarlySupport::log},
config} {
Init(&impl_.ptrs);
}
// static
const ScopedEarlySupport::Config& ScopedEarlySupport::GetConfig() {
return reinterpret_cast<const ScopedEarlySupport::Impl*>(g_impl_override)
->config;
}
// static
int ScopedEarlySupport::get_min_log_level() {
return GetConfig().min_log_level;
}
// static
int ScopedEarlySupport::get_vlog_level(const char* file_start, size_t N) {
return GetConfig().vlog_level;
}
// static
void ScopedEarlySupport::log(const char* file,
int line,
int severity,
const char* message) {
const Config& config = GetConfig();
// Most logging initializes `file` from __FILE__. Unfortunately, because we
// build from out/Foo we get a `../../` (or \) prefix for all of our
// __FILE__s. This isn't true for base::Location::Current() which already does
// the stripping (and is used for some logging, especially CHECKs).
//
// Here we strip the first 6 (../../ or ..\..\) characters if `file` starts
// with `.` but defensively clamp to strlen(file) just in case.
const std::string_view filename =
file[0] == '.' ? std::string_view(file).substr(
std::min(std::size_t{6}, strlen(file)))
: file;
std::stringstream stream;
stream << '[';
if (config.log_prefix) {
stream << config.log_prefix << ':';
}
if (config.log_process_id) {
#if defined(OS_WIN)
stream << ::GetCurrentProcessId() << ':';
#elif defined(OS_POSIX)
stream << getpid() << ':';
#else
#error Unsupported platform
#endif
}
if (config.log_thread_id) {
#if defined(OS_WIN)
stream << ::GetCurrentThreadId() << ':';
#elif defined(OS_APPLE)
uint64_t tid;
if (pthread_threadid_np(nullptr, &tid) == 0) {
stream << tid << ':';
}
#elif defined(OS_POSIX)
stream << pthread_self() << ':';
#else
#error Unsupported platform
#endif
}
if (config.log_timestamp) {
#if defined(OS_WIN)
SYSTEMTIME local_time;
GetLocalTime(&local_time);
stream << std::setfill('0') << std::setw(2) << local_time.wMonth
<< std::setw(2) << local_time.wDay << '/' << std::setw(2)
<< local_time.wHour << std::setw(2) << local_time.wMinute
<< std::setw(2) << local_time.wSecond << '.' << std::setw(3)
<< local_time.wMilliseconds << ':';
#elif defined(OS_POSIX)
timeval tv;
gettimeofday(&tv, nullptr);
time_t t = tv.tv_sec;
struct tm local_time;
localtime_r(&t, &local_time);
struct tm* tm_time = &local_time;
stream << std::setfill('0') << std::setw(2) << 1 + tm_time->tm_mon
<< std::setw(2) << tm_time->tm_mday << '/' << std::setw(2)
<< tm_time->tm_hour << std::setw(2) << tm_time->tm_min
<< std::setw(2) << tm_time->tm_sec << '.' << std::setw(6)
<< tv.tv_usec << ':';
#else
#error Unsupported platform
#endif
}
if (config.log_tickcount) {
stream << TickCount() << ':';
}
if (severity >= 0) {
stream << log_severity_name(severity);
} else {
stream << "VERBOSE" << -severity;
}
stream << ":" << filename << ":" << line << "] " << message;
const std::string& log_line = stream.str();
if (!config.formatted_log_handler ||
!config.formatted_log_handler(log_line.c_str())) {
// Log to stderr.
std::cerr << log_line << std::endl;
#if !defined(NDEBUG) && defined(OS_WIN)
if (severity < LOG_FATAL) {
// Log to the debugger console in debug builds.
OutputDebugStringW(UTF8ToWide(log_line).c_str());
}
#endif
}
if (severity == LOG_FATAL) {
HandleFatal(log_line);
}
}
// MSVC doesn't like complex extern templates and DLLs.
#if !defined(COMPILER_MSVC)
// Explicit instantiations for commonly used comparisons.
@@ -443,8 +184,7 @@ LogMessage::LogMessage(const char* file,
LogMessage::~LogMessage() {
std::string str_newline(stream_.str());
internal::GetImplementation()->log(file_, line_, severity_,
str_newline.c_str());
cef_log(file_, line_, severity_, str_newline.c_str());
}
#if defined(OS_WIN)

View File

@@ -1,82 +0,0 @@
// 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_dll/bootstrap/bootstrap_util_win.h"
#include "base/check_op.h"
#include "base/command_line.h"
namespace bootstrap_util {
namespace {
// Changes to these values require rebuilding libcef.dll.
constexpr wchar_t kWindowsSelfName[] = TEXT("bootstrap");
constexpr wchar_t kConsoleSelfName[] = TEXT("bootstrapc");
// Returns the file name only without extension, if any.
inline std::wstring NamePart(const base::FilePath& path) {
return path.BaseName().RemoveExtension().value();
}
} // namespace
bool IsDefaultExeName(const std::wstring& name) {
return base::FilePath::CompareEqualIgnoreCase(name, kWindowsSelfName) ||
base::FilePath::CompareEqualIgnoreCase(name, kConsoleSelfName);
}
std::wstring GetModuleValue(const base::CommandLine& command_line) {
if (command_line.HasSwitch(switches::kModule)) {
const auto& value = command_line.GetSwitchValuePath(switches::kModule);
if (!value.empty()) {
return NamePart(value);
}
}
return std::wstring();
}
base::FilePath GetExePath() {
HMODULE hModule = ::GetModuleHandle(nullptr);
CHECK(hModule);
return GetModulePath(hModule);
}
base::FilePath GetModulePath(HMODULE module) {
wchar_t buffer[MAX_PATH];
DWORD length = ::GetModuleFileName(module, buffer, MAX_PATH);
CHECK_NE(length, 0U);
CHECK_LT(length, static_cast<DWORD>(MAX_PATH));
return base::FilePath(buffer);
}
std::wstring GetValidatedModuleValue(const base::CommandLine& command_line,
const base::FilePath& exe_path) {
// Allow module value configuration if the bootstrap executable has the
// default name.
const auto& value = GetModuleValue(command_line);
if (!value.empty() && IsDefaultExeName(NamePart(exe_path))) {
return value;
}
return std::wstring();
}
std::wstring GetDefaultModuleValue(const base::FilePath& exe_path) {
return NamePart(exe_path);
}
bool IsModulePathAllowed(const base::FilePath& module_path,
const base::FilePath& exe_path) {
// Allow any module path if the bootstrap executable has the default name.
if (IsDefaultExeName(NamePart(exe_path))) {
return true;
}
// Module must be at the same path as the executable.
return module_path.DirName() == exe_path.DirName();
}
} // namespace bootstrap_util

View File

@@ -1,53 +0,0 @@
// 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.
#ifndef CEF_LIBCEF_DLL_BOOTSTRAP_BOOTSTRAP_UTIL_WIN_H_
#define CEF_LIBCEF_DLL_BOOTSTRAP_BOOTSTRAP_UTIL_WIN_H_
#pragma once
#include <windows.h>
#include <string>
#include "base/files/file_path.h"
namespace base {
class CommandLine;
}
namespace bootstrap_util {
namespace switches {
// Changes to this value require rebuilding libcef.dll.
inline constexpr char kModule[] = "module";
} // namespace switches
// Returns true if |name| is one of the default bootstrap executable names.
bool IsDefaultExeName(const std::wstring& name);
// Returns the command-line configured module value without validation.
std::wstring GetModuleValue(const base::CommandLine& command_line);
// The following functions can only be called in unsandboxed processes.
// Returns the fully qualified file path for the executable module.
base::FilePath GetExePath();
// Returns the fully qualified file path for |module|.
base::FilePath GetModulePath(HMODULE module);
// Returns the command-line configured module value if it passes validation.
std::wstring GetValidatedModuleValue(const base::CommandLine& command_line,
const base::FilePath& exe_path);
// Returns the default module name (executable name without extension).
std::wstring GetDefaultModuleValue(const base::FilePath& exe_path);
// Returns true if loading |module_path| is allowed.
bool IsModulePathAllowed(const base::FilePath& module_path,
const base::FilePath& exe_path);
} // namespace bootstrap_util
#endif // CEF_LIBCEF_DLL_BOOTSTRAP_BOOTSTRAP_UTIL_WIN_H_

View File

@@ -1,391 +0,0 @@
// 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 <windows.h>
#include <iostream>
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/process/memory.h"
#include "base/process/process_info.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "cef/include/cef_sandbox_win.h"
#include "cef/include/cef_version.h"
#include "cef/include/cef_version_info.h"
#include "cef/include/internal/cef_types.h"
#include "cef/include/wrapper/cef_certificate_util_win.h"
#include "cef/include/wrapper/cef_util_win.h"
#include "cef/libcef/browser/crashpad_runner.h"
#include "cef/libcef/browser/preferred_stack_size_win.inc"
#include "cef/libcef_dll/bootstrap/bootstrap_util_win.h"
#include "cef/libcef_dll/bootstrap/win/resource.h"
#include "chrome/app/delay_load_failure_hook_win.h"
#include "chrome/chrome_elf/chrome_elf_main.h"
#include "chrome/install_static/initialize_from_primary_module.h"
#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.h"
namespace {
// Sets the current working directory for the process to the directory holding
// the executable if this is the browser process. This avoids leaking a handle
// to an arbitrary directory to child processes (e.g., the crashpad handler
// process).
void SetCwdForBrowserProcess() {
if (!::IsBrowserProcess()) {
return;
}
std::array<wchar_t, MAX_PATH + 1> buffer;
buffer[0] = L'\0';
DWORD length = ::GetModuleFileName(nullptr, &buffer[0], buffer.size());
if (!length || length >= buffer.size()) {
return;
}
base::SetCurrentDirectory(
base::FilePath(base::FilePath::StringViewType(&buffer[0], length))
.DirName());
}
#if DCHECK_IS_ON()
// Displays a message to the user with the error message. Used for fatal
// messages, where we close the app simultaneously. This is for developers only;
// we don't use this in circumstances (like release builds) where users could
// see it, since users don't understand these messages anyway.
// Load a string from the string table in bootstrap.rc.
std::wstring LoadString(int string_id) {
const int kMaxSize = 100;
TCHAR buff[kMaxSize] = {0};
::LoadString(::GetModuleHandle(nullptr), string_id, buff, kMaxSize);
return buff;
}
// Replace $1-$2-$3..$9 in the format string with values from |subst|.
// Additionally, any number of consecutive '$' characters is replaced by that
// number less one. Eg $$->$, $$$->$$, etc. Supports up to 9 replacements.
std::wstring FormatErrorString(int string_id,
base::span<const std::u16string> subst) {
return base::UTF16ToWide(base::ReplaceStringPlaceholders(
base::WideToUTF16(LoadString(string_id)), subst, nullptr));
}
void ShowError(const std::wstring& error) {
const auto subst = std::to_array<std::u16string>(
{base::WideToUTF16(bootstrap_util::GetExePath().BaseName().value())});
const auto& title = FormatErrorString(IDS_ERROR_TITLE, subst);
const auto& extra_info = LoadString(IDS_ERROR_EXTRA_INFO);
#if defined(CEF_BUILD_BOOTSTRAP_CONSOLE)
std::wcerr << title.c_str() << ": " << error << extra_info;
#else
if (!::IsDebuggerPresent()) {
// Displaying a dialog is unnecessary when debugging and can complicate
// debugging.
const std::wstring& msg = error + extra_info;
::MessageBox(nullptr, msg.c_str(), title.c_str(), MB_ICONERROR | MB_OK);
}
#endif
}
#endif // DCHECK_IS_ON()
std::wstring NormalizeError(const std::wstring& err) {
std::wstring str = err;
// Replace newlines.
std::replace(str.begin(), str.end(), L'\n', L' ');
return str;
}
// Verify DLL code signing requirements.
void CheckDllCodeSigning(
const base::FilePath& dll_path,
const cef_certificate_util::ThumbprintsInfo& exe_thumbprints) {
cef_certificate_util::ThumbprintsInfo dll_thumbprints;
cef_certificate_util::GetClientThumbprints(
dll_path.value(), /*verify_binary=*/true, dll_thumbprints);
// The DLL and EXE must either both be unsigned or both have all valid
// signatures and the same primary thumbprint.
if (!dll_thumbprints.IsSame(exe_thumbprints, /*allow_unsigned=*/true)) {
// Some part of the certificate validation process failed.
#if DCHECK_IS_ON()
const auto subst = std::to_array<std::u16string>(
{base::WideToUTF16(dll_path.BaseName().value()),
base::WideToUTF16(dll_thumbprints.errors)});
ShowError(FormatErrorString(IDS_ERROR_INVALID_CERT, subst));
#endif
if (dll_thumbprints.errors.empty()) {
LOG(FATAL) << "Failed " << dll_path.value()
<< " certificate requirements";
} else {
LOG(FATAL) << "Failed " << dll_path.value() << " certificate checks: "
<< NormalizeError(dll_thumbprints.errors);
}
}
}
} // namespace
#if defined(CEF_BUILD_BOOTSTRAP_CONSOLE)
int main(int argc, char* argv[]) {
#else // !defined(CEF_BUILD_BOOTSTRAP_CONSOLE)
// Entry point function for all processes.
int APIENTRY wWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow) {
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
#endif // !defined(CEF_BUILD_BOOTSTRAP_CONSOLE)
#if defined(ARCH_CPU_32_BITS)
// Run the main thread on 32-bit Windows using a fiber with the preferred 4MiB
// stack size. This function must be called at the top of the executable entry
// point function (`main()` or `wWinMain()`). It is used in combination with
// the initial stack size of 0.5MiB configured via the `/STACK:0x80000` linker
// flag on executable targets. This saves significant memory on threads (like
// those in the Windows thread pool, and others) whose stack size can only be
// controlled via the linker flag.
#if defined(CEF_BUILD_BOOTSTRAP_CONSOLE)
int exit_code = CefRunMainWithPreferredStackSize(main, argc, argv);
#else
int exit_code = CefRunWinMainWithPreferredStackSize(wWinMain, hInstance,
lpCmdLine, nCmdShow);
#endif
if (exit_code >= 0) {
// The fiber has completed so return here.
return exit_code;
}
#endif
SetCwdForBrowserProcess();
install_static::InitializeFromPrimaryModule();
SignalInitializeCrashReporting();
if (IsBrowserProcess()) {
chrome::DisableDelayLoadFailureHooksForMainExecutable();
}
// Done here to ensure that OOMs that happen early in process initialization
// are correctly signaled to the OS.
base::EnableTerminationOnOutOfMemory();
logging::RegisterAbslAbortHook();
// Parse command-line arguments.
const base::CommandLine command_line =
base::CommandLine::FromString(::GetCommandLineW());
constexpr char kProcessType[] = "type";
const bool is_subprocess = command_line.HasSwitch(kProcessType);
const std::string& process_type =
command_line.GetSwitchValueASCII(kProcessType);
if (is_subprocess && process_type.empty()) {
// Early exit on invalid process type.
return CEF_RESULT_CODE_BAD_PROCESS_TYPE;
}
// Run the crashpad handler now instead of waiting for libcef to load.
constexpr char kCrashpadHandler[] = "crashpad-handler";
if (process_type == kCrashpadHandler) {
return crashpad_runner::RunAsCrashpadHandler(command_line);
}
// IsUnsandboxedSandboxType() can't be used here because its result can be
// gated behind a feature flag, which are not yet initialized.
// Match the logic in MainDllLoader::Launch.
const bool is_sandboxed =
sandbox::policy::SandboxTypeFromCommandLine(command_line) !=
sandbox::mojom::Sandbox::kNoSandbox;
std::wstring dll_name;
base::FilePath exe_path;
cef_certificate_util::ThumbprintsInfo exe_thumbprints;
if (is_sandboxed) {
// Running as a sandboxed sub-process. May already be locked down, so we
// can't call WinAPI functions. The command-line will already have been
// validated in ChromeContentBrowserClientCef::
// AppendExtraCommandLineSwitches. Retrieve the module value without
// additional validation.
dll_name = bootstrap_util::GetModuleValue(command_line);
if (dll_name.empty()) {
// Default to the command-line program name without extension.
dll_name = command_line.GetProgram().BaseName().RemoveExtension().value();
}
} else {
// Running as the main process or unsandboxed sub-process.
exe_path = bootstrap_util::GetExePath();
// Retrieve the module name with validation.
dll_name = bootstrap_util::GetValidatedModuleValue(command_line, exe_path);
if (dll_name.empty()) {
// Default to the executable module file name without extension. This is
// safer than relying on the command-line program name.
dll_name = bootstrap_util::GetDefaultModuleValue(exe_path);
}
if (bootstrap_util::IsDefaultExeName(dll_name)) {
#if DCHECK_IS_ON()
ShowError(LoadString(IDS_ERROR_NO_MODULE_NAME));
#endif
LOG(FATAL) << "Missing module name";
}
cef_certificate_util::GetClientThumbprints(
exe_path.value(), /*verify_binary=*/true, exe_thumbprints);
// The executable must either be unsigned or have all valid signatures.
if (!exe_thumbprints.IsUnsignedOrValid()) {
// Some part of the certificate validation process failed.
#if DCHECK_IS_ON()
const auto subst = std::to_array<std::u16string>(
{base::WideToUTF16(exe_path.BaseName().value()),
base::WideToUTF16(exe_thumbprints.errors)});
ShowError(FormatErrorString(IDS_ERROR_INVALID_CERT, subst));
#endif
if (exe_thumbprints.errors.empty()) {
LOG(FATAL) << "Failed " << exe_path.value()
<< " certificate requirements";
} else {
LOG(FATAL) << "Failed " << exe_path.value() << " certificate checks: "
<< NormalizeError(exe_thumbprints.errors);
}
}
}
if (!is_sandboxed) {
// Check chrome_elf.dll which should be preloaded to support crash
// reporting.
if (HMODULE hModule = ::LoadLibrary(L"chrome_elf")) {
const auto& dll_path = bootstrap_util::GetModulePath(hModule);
// Must be in the same directory as the EXE.
if (dll_path.DirName() != exe_path.DirName()) {
#if DCHECK_IS_ON()
const auto subst = std::to_array<std::u16string>({u"chrome_elf"});
ShowError(FormatErrorString(IDS_ERROR_INVALID_LOCATION, subst));
#endif
LOG(FATAL) << "Invalid location: " << dll_path.value();
}
CheckDllCodeSigning(dll_path, exe_thumbprints);
FreeLibrary(hModule);
} else {
LOG(FATAL) << "Failed to load chrome_elf.dll with error "
<< ::GetLastError();
}
// Load the client DLL as untrusted (e.g. without executing DllMain or
// loading additional modules) so that we can first check requirements.
// LoadLibrary's "default search order" is tricky and we don't want to
// guess about what DLL it will load. DONT_RESOLVE_DLL_REFERENCES is the
// only option that doesn't execute DllMain while still allowing us
// retrieve the path using GetModuleFileName. No execution of the DLL
// should be attempted while loaded in this mode.
if (HMODULE hModule = ::LoadLibraryEx(dll_name.c_str(), nullptr,
DONT_RESOLVE_DLL_REFERENCES)) {
const auto& dll_path = bootstrap_util::GetModulePath(hModule);
if (!bootstrap_util::IsModulePathAllowed(dll_path, exe_path)) {
#if DCHECK_IS_ON()
const auto subst =
std::to_array<std::u16string>({base::WideToUTF16(dll_name)});
ShowError(FormatErrorString(IDS_ERROR_INVALID_LOCATION, subst));
#endif
LOG(FATAL) << "Invalid location: " << dll_path.value();
}
CheckDllCodeSigning(dll_path, exe_thumbprints);
FreeLibrary(hModule);
} else {
#if DCHECK_IS_ON()
const auto subst = std::to_array<std::u16string>(
{base::WideToUTF16(dll_name),
base::WideToUTF16(cef_util::GetLastErrorAsString())});
ShowError(FormatErrorString(IDS_ERROR_LOAD_FAILED, subst));
#endif
LOG(FATAL) << "Failed to load " << dll_name << ".dll with error "
<< ::GetLastError();
}
}
#if defined(CEF_BUILD_BOOTSTRAP_CONSOLE)
constexpr char kProcName[] = "RunConsoleMain";
using kProcType = decltype(&RunConsoleMain);
#else
constexpr char kProcName[] = "RunWinMain";
using kProcType = decltype(&RunWinMain);
#endif
// Load the client DLL normally.
if (HMODULE hModule = ::LoadLibrary(dll_name.c_str())) {
if (auto* pFunc = (kProcType)::GetProcAddress(hModule, kProcName)) {
// Initialize the sandbox services.
// Match the logic in MainDllLoader::Launch.
sandbox::SandboxInterfaceInfo sandbox_info = {nullptr};
if (!is_subprocess || 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);
}
cef_version_info_t version_info = {};
CEF_POPULATE_VERSION_INFO(&version_info);
// Return immediately without calling FreeLibrary() to avoid an illegal
// access during shutdown. The sandbox broker owns objects created inside
// libcef.dll (SandboxWin::InitBrokerServices) and cleanup is triggered
// via an _onexit handler (SingletonBase::OnExit) called after wWinMain
// exits.
#if defined(CEF_BUILD_BOOTSTRAP_CONSOLE)
return pFunc(argc, argv, &sandbox_info, &version_info);
#else
return pFunc(hInstance, lpCmdLine, nCmdShow, &sandbox_info,
&version_info);
#endif
} else {
#if DCHECK_IS_ON()
if (!is_sandboxed) {
const auto subst = std::to_array<std::u16string>(
{base::WideToUTF16(dll_name),
base::WideToUTF16(cef_util::GetLastErrorAsString()),
base::ASCIIToUTF16(std::string(kProcName))});
ShowError(FormatErrorString(IDS_ERROR_NO_PROC_EXPORT, subst));
}
#endif
LOG(FATAL) << "Failed to find " << kProcName << " in " << dll_name
<< ".dll with error " << ::GetLastError();
}
} else {
#if DCHECK_IS_ON()
if (!is_sandboxed) {
const auto subst = std::to_array<std::u16string>(
{base::WideToUTF16(dll_name),
base::WideToUTF16(cef_util::GetLastErrorAsString())});
ShowError(FormatErrorString(IDS_ERROR_LOAD_FAILED, subst));
}
#endif
LOG(FATAL) << "Failed to load " << dll_name << ".dll with error "
<< ::GetLastError();
}
// LOG(FATAL) is [[noreturn]], so we never reach this point.
NOTREACHED();
}

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