Compare commits

...

51 Commits
6998 ... 7151

Author SHA1 Message Date
Marshall Greenblatt
7e14fe138e Fix read of crash reporting env vars 2025-06-03 16:05:06 -04:00
Marshall Greenblatt
1547f8c8ce Update to Chromium version 137.0.7151.69 2025-06-03 13:23:05 +00:00
Marshall Greenblatt
aaaa0bf625 Update to Chromium version 137.0.7151.56 2025-05-29 13:19:01 -04:00
Tom Crowley
2c2bc6e86d ceftests: Add tests for PrintToPdf 2025-05-29 13:00:58 -04:00
Pedro de Carvalho Gomes
d5187afaac linux: Fix parenting of select widget on Wayland (fixes #3937) 2025-05-29 13:00:47 -04:00
Marshall Greenblatt
24fa18a759 libcef: Fix incorrect sandbox init with --no-sandbox
Match the current logic for chrome.exe.
2025-05-29 12:59:57 -04:00
Marshall Greenblatt
8614a8dc19 bazel: Remove support for angle bracket includes
Fixes the following error:

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

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

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

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

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

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

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

View File

@@ -340,7 +340,7 @@ if (is_win) {
# to maintain.
"//chrome/common/crash_keys.cc",
"//chrome/common/chrome_switches.cc",
"//components/flags_ui/flags_ui_switches.cc",
"//components/webui/flags/flags_ui_switches.cc",
"//content/public/common/content_switches.cc",
]
@@ -677,6 +677,8 @@ source_set("libcef_static") {
"libcef/browser/scheme_impl.cc",
"libcef/browser/server_impl.cc",
"libcef/browser/server_impl.h",
"libcef/browser/setting_helper.cc",
"libcef/browser/setting_helper.h",
"libcef/browser/simple_menu_model_impl.cc",
"libcef/browser/simple_menu_model_impl.h",
"libcef/browser/ssl_info_impl.cc",
@@ -837,6 +839,7 @@ source_set("libcef_static") {
"libcef/common/values_impl.h",
"libcef/common/waitable_event_impl.cc",
"libcef/common/waitable_event_impl.h",
"libcef/renderer/browser_config.h",
"libcef/renderer/browser_impl.cc",
"libcef/renderer/browser_impl.h",
"libcef/renderer/chrome/chrome_content_renderer_client_cef.cc",

View File

@@ -7,5 +7,5 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/134.0.6998.0'
'chromium_checkout': 'refs/tags/137.0.7151.69'
}

View File

@@ -1,41 +1,72 @@
{
"hashes": {
"13300": {
"comment": "Added February 17, 2025.",
"linux": "87d31692cf1ff1f0f2445dd026dcc0aeb02c5786",
"mac": "3891d2358697f15e046afc65fefd7019d888817a",
"universal": "c1a7d47be6fc130795366a1627573aa8eba1106f",
"windows": "0efb201c9e981c4513aeea04f9f2f8041ee9ce1f"
"comment": "Added February 21, 2025.",
"linux": "2508f3f0b0e5dfa191036fa6c04f8dcfa18c94b9",
"mac": "80c0b59ba9dd783aa71fae0aa5f7dad64620e8c9",
"windows": "45d39c3669ba75467e3e609f626c31506c0eae22"
},
"13301": {
"comment": "Added February 17, 2025.",
"linux": "747f624e5059839e6a7d385de7997d45bbd42184",
"mac": "d3ec7d79adbde067590ab1bfff1f30dd8b06546a",
"universal": "892e654249acc7360f8aca4ee77da896753b87b8",
"windows": "cf9fbb7aa6778fedce78b8557044f219f2b5ba0b"
"comment": "Added February 21, 2025.",
"linux": "aa073dd1c586812503ca293c718358460d8c2dd6",
"mac": "fda40a5df44628cac50a589ff979c0746011591e",
"windows": "7109702038d51512d35dd2ed77231f9100e38214"
},
"13302": {
"comment": "Added February 17, 2025.",
"linux": "ae4ab1c52ad951d37e6397db9f4e0ab0ce5044cf",
"mac": "cfe09351db37aa275613c27145fe622d9c28d4cc",
"universal": "acab8df1244923f1f80b18214e73c276a553ded6",
"windows": "c4b5a65478bc1a679f4a47ba5ff6899e5c3d8761"
"comment": "Added February 21, 2025.",
"linux": "d5597ebfa30081953425e897209a8387b9584205",
"mac": "4aa24470ba3a4bd9c06bc0e4a201b896394a86b5",
"windows": "18799961f4461a9cbae2aed89ac04b73ab7c37f3"
},
"13303": {
"comment": "Added February 17, 2025.",
"linux": "2683698b779f11bba19f4051e3760fe327a1c8b2",
"mac": "8085a0f62f15946343c63788300e5c2b422b3301",
"universal": "128210b71e3f621cb6d2c4b05c6d0408a4547f2f",
"windows": "5a22d42c3e6294eb4ee2424053eebdeae3027899"
"comment": "Added February 21, 2025.",
"linux": "f3a696ee30ce1e00490a58df017393c126c89709",
"mac": "f2cdce2b9a4b635c28b5b92c42c35625a937380c",
"windows": "20016fd6a9b87ef4c539cd1f42bf1ca09b6903ca"
},
"13304": {
"comment": "Added February 17, 2025.",
"linux": "c709233cd071e0d715eb10ceec4c5aea805df997",
"mac": "32af7e8f8828b04cf2908de9857940faa54deb8a",
"universal": "131b720865dd5c54c72041c0fbfb7c9bbfee8e0b",
"windows": "979b48138012378192dac7ee972fa731e9c0dae9"
"comment": "Added February 21, 2025.",
"linux": "f1ababb4ff51ecbf77c481cee3721ef0eca9c8ca",
"mac": "98964c37b8917d83da4b173e22905503d38ad08f",
"windows": "19c014af0082aa901398e006381b6980e4f806e9"
},
"13400": {
"comment": "Added February 21, 2025.",
"linux": "ea2106b5bc012c25d735521e0c7fb719d433ea4a",
"mac": "ba5ab71db4f9447f19eb7b1943024981c88064dd",
"windows": "6ab74b90e88b7397aab9911baac5484f12466eef"
},
"13401": {
"comment": "Added March 10, 2025.",
"linux": "b14bee2c0fd250da67faea421f620b58e5dea9a2",
"mac": "b54732b528bc2669481ec0cf17c7b97b033720b9",
"windows": "751255204f006b8b883a8baf552a2da792f8aa44"
},
"13500": {
"comment": "Added March 12, 2025.",
"linux": "5b7c2284ed2542cf6212981d62ca9122fb2a4e88",
"mac": "9862177631e8059a497d6086058168dd47477ab7",
"windows": "3e78b6fe5fd31d69049499450849ada17a720a53"
},
"13600": {
"comment": "Added April 07, 2025.",
"linux": "eb353ba7b8b9bcbef890217971cd8ec41efeaa75",
"mac": "22c77d1f2305de8a6147f14e52f074b4a4e5222c",
"windows": "a8832519b4eb058567d68b65be1e1c9e80aae566"
},
"13601": {
"comment": "Added April 22, 2025.",
"linux": "40b224f295a20694241c5db49721bc90a3796f30",
"mac": "ff885fe921f9eae1a5ce6a71b30b0c37b306bf56",
"windows": "116a4153047ee1ee67f17fc938f084ee72b24e54"
},
"13700": {
"comment": "Added May 07, 2025.",
"linux": "e5ac12b1bd88b9ece6ceaa57848aaba61ab85242",
"mac": "9e84009c92c25aa80935727b5e4526b23439a575",
"windows": "65c7157dd3e8eba9bcc38db2bd7f26508c717f3e"
}
},
"last": "13304",
"last": "13700",
"min": "13300"
}

View File

@@ -247,6 +247,8 @@
'tests/cefclient/browser/client_prefs.cc',
'tests/cefclient/browser/client_prefs.h',
'tests/cefclient/browser/client_types.h',
'tests/cefclient/browser/config_test.cc',
'tests/cefclient/browser/config_test.h',
'tests/cefclient/browser/default_client_handler.cc',
'tests/cefclient/browser/default_client_handler.h',
'tests/cefclient/browser/dialog_test.cc',
@@ -324,6 +326,7 @@
'cefclient_sources_resources': [
'tests/cefclient/resources/binary_transfer.html',
'tests/cefclient/resources/binding.html',
'tests/cefclient/resources/config.html',
'tests/cefclient/resources/dialogs.html',
'tests/cefclient/resources/draggable.html',
'tests/cefclient/resources/hang.html',
@@ -407,6 +410,8 @@
'tests/cefclient/browser/temp_window_mac.mm',
'tests/cefclient/browser/text_input_client_osr_mac.h',
'tests/cefclient/browser/text_input_client_osr_mac.mm',
'tests/cefclient/browser/util_mac.h',
'tests/cefclient/browser/util_mac.mm',
'tests/cefclient/browser/views_window_mac.mm',
'tests/cefclient/browser/window_test_runner_mac.h',
'tests/cefclient/browser/window_test_runner_mac.mm',
@@ -523,6 +528,7 @@
'tests/ceftests/permission_prompt_unittest.cc',
'tests/ceftests/preference_unittest.cc',
'tests/ceftests/print_unittest.cc',
'tests/ceftests/print_to_pdf_unittest.cc',
'tests/ceftests/process_message_unittest.cc',
'tests/ceftests/request_context_unittest.cc',
'tests/ceftests/request_handler_unittest.cc',

View File

@@ -271,6 +271,17 @@ macro(ADD_WINDOWS_MANIFEST manifest_path target extension)
)
endmacro()
# Set LPAC ACLs required for Windows sandbox support.
# See https://github.com/chromiumembedded/cef/issues/3791#issuecomment-2664128961
macro(SET_LPAC_ACLS target)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND "icacls" "${CEF_TARGET_OUT_DIR}" "/grant" "*S-1-15-2-2:(OI)(CI)(RX)"
COMMENT "Setting LPAC ACLs..."
)
endmacro()
endif(OS_WINDOWS)

View File

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

View File

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

View File

@@ -77,19 +77,15 @@
#endif
#endif
#define _CEF_AH_PASTE(a, b, c) a##_##b##_##c
#define _CEF_AH_EVAL(a, b, c) _CEF_AH_PASTE(a, b, c)
#define _CEF_AH_DECLARE(version, suffix) \
_CEF_AH_EVAL(CEF_API_HASH, version, suffix)
#define _CEF_AH_PASTE(a, b) a##_##b
#define _CEF_AH_EVAL(a, b) _CEF_AH_PASTE(a, b)
#define _CEF_AH_DECLARE(version) _CEF_AH_EVAL(CEF_API_HASH, version)
// API hashes for the selected CEF_API_VERSION. API hashes are created for
// each version by analyzing CEF header files for C API type definitions. The
// hash value will change when header files are modified in a way that may
// cause binary incompatibility with other builds. The universal hash value
// will change if any platform is affected whereas the platform hash values
// will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL _CEF_AH_DECLARE(CEF_API_VERSION, UNIVERSAL)
#define CEF_API_HASH_PLATFORM _CEF_AH_DECLARE(CEF_API_VERSION, PLATFORM)
// cause binary incompatibility with other builds.
#define CEF_API_HASH_PLATFORM _CEF_AH_DECLARE(CEF_API_VERSION)
#if defined(BUILDING_CEF_SHARED)
@@ -132,7 +128,7 @@ extern "C" {
/// parameter describes which hash value will be returned:
///
/// 0 - CEF_API_HASH_PLATFORM
/// 1 - CEF_API_HASH_UNIVERSAL
/// 1 - CEF_API_HASH_UNIVERSAL (deprecated, same as CEF_API_HASH_PLATFORM)
/// 2 - CEF_COMMIT_HASH (from cef_version.h)
///
CEF_EXPORT const char* cef_api_hash(int version, int entry);

View File

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

View File

@@ -31,8 +31,11 @@
#define CEF_INCLUDE_CEF_BASE_H_
#pragma once
#include "include/base/cef_atomic_ref_count.h"
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#include "include/base/cef_atomic_ref_count.h"
#include "include/base/cef_macros.h"
// Bring in common C++ type definitions used by CEF consumers.

View File

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

View File

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

View File

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

View File

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

View File

@@ -31,7 +31,10 @@
#define CEF_INCLUDE_CEF_SANDBOX_MAC_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#include "include/internal/cef_export.h"
#if defined(OS_MAC)

View File

@@ -31,7 +31,9 @@
#define CEF_INCLUDE_CEF_SANDBOX_WIN_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(OS_WIN)

View File

@@ -31,7 +31,9 @@
#define CEF_INCLUDE_INTERNAL_CEF_APP_WIN_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(OS_WIN)

View File

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

View File

@@ -32,7 +32,9 @@
#define CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(COMPILER_MSVC)

View File

@@ -31,12 +31,14 @@
#define CEF_INCLUDE_INTERNAL_CEF_THREAD_INTERNAL_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_POSIX)
#include <pthread.h>
#include <unistd.h>
#endif
#endif
#include "include/internal/cef_export.h"

View File

@@ -35,8 +35,11 @@
extern "C" {
#endif
#include <stdint.h>
#if !defined(GENERATING_CEF_API_HASH)
#include <time.h>
#endif
#include <stdint.h>
#include "include/internal/cef_export.h"

View File

@@ -1271,7 +1271,11 @@ typedef enum {
PDE_TYPE_BYTES,
PDE_TYPE_FILE,
#if CEF_API_ADDED(13601)
PDE_TYPE_NUM_VALUES,
#else
PDF_TYPE_NUM_VALUES,
#endif
} cef_postdataelement_type_t;
///
@@ -3622,7 +3626,7 @@ typedef enum {
#if CEF_API_ADDED(13304)
CEF_CPAIT_COLLABORATION_MESSAGING,
#endif
#if CEF_API_ADDED(CEF_NEXT)
#if CEF_API_ADDED(13400)
CEF_CPAIT_CHANGE_PASSWORD,
#endif
CEF_CPAIT_NUM_VALUES,
@@ -3634,8 +3638,13 @@ typedef enum {
///
typedef enum {
CEF_CTBT_CAST,
#if CEF_API_REMOVED(13600)
CEF_CTBT_DOWNLOAD,
CEF_CTBT_SEND_TAB_TO_SELF,
#else
CEF_CTBT_DOWNLOAD_DEPRECATED,
CEF_CTBT_SEND_TAB_TO_SELF_DEPRECATED,
#endif
CEF_CTBT_SIDE_PANEL,
CEF_CTBT_NUM_VALUES,
} cef_chrome_toolbar_button_type_t;
@@ -3788,6 +3797,9 @@ typedef enum {
CEF_PERMISSION_TYPE_WEB_APP_INSTALLATION = 1 << 22,
CEF_PERMISSION_TYPE_WINDOW_MANAGEMENT = 1 << 23,
CEF_PERMISSION_TYPE_FILE_SYSTEM_ACCESS = 1 << 24,
#if CEF_API_ADDED(13600)
CEF_PERMISSION_TYPE_LOCAL_NETWORK_ACCESS = 1 << 25,
#endif
} cef_permission_request_types_t;
///

View File

@@ -329,7 +329,7 @@ typedef enum {
/// HTTP header.
CEF_CONTENT_SETTING_TYPE_FEDERATED_IDENTITY_IDENTITY_PROVIDER_SIGNIN_STATUS,
/// Website setting which is used for UnusedSitePermissionsService to
/// Website setting which is used for RevokedPermissionsService to
/// store revoked permissions of unused sites from unused site permissions
/// feature.
CEF_CONTENT_SETTING_TYPE_REVOKED_UNUSED_SITE_PERMISSIONS,
@@ -382,12 +382,16 @@ typedef enum {
/// a requesting-origin/top-level-site combination and persistent.
CEF_CONTENT_SETTING_TYPE_TOP_LEVEL_TPCD_TRIAL,
/// Content Setting for a first-party origin trial that allows websites to
/// enable third-party cookie deprecation.
/// ALLOW (default): no effect (e.g. third-party cookies allowed, if not
/// blocked otherwise).
/// BLOCK: third-party cookies blocked, but 3PCD mitigations enabled.
/// Content Setting for a first-party origin trial that allows websites to
/// enable third-party cookie deprecation.
/// ALLOW (default): no effect (e.g. third-party cookies allowed, if not
/// blocked otherwise).
/// BLOCK: third-party cookies blocked, but 3PCD mitigations enabled.
#if CEF_API_ADDED(13601)
CEF_CONTENT_SETTING_TYPE_TOP_LEVEL_TPCD_ORIGIN_TRIAL,
#else
CEF_CONTENT_SETTING_TOP_LEVEL_TPCD_ORIGIN_TRIAL,
#endif
/// Content setting used to indicate whether entering picture-in-picture
/// automatically should be enabled.
@@ -438,7 +442,7 @@ typedef enum {
/// access to mouse inputs.
CEF_CONTENT_SETTING_TYPE_POINTER_LOCK,
/// Website setting which is used for UnusedSitePermissionsService to store
/// Website setting which is used for RevokedPermissionsService to store
/// auto-revoked notification permissions from abusive sites.
CEF_CONTENT_SETTING_TYPE_REVOKED_ABUSIVE_NOTIFICATION_PERMISSIONS,
@@ -486,7 +490,7 @@ typedef enum {
/// or legacy behavior.
CEF_CONTENT_SETTING_TYPE_LEGACY_COOKIE_SCOPE,
#if CEF_API_ADDED(CEF_NEXT)
#if CEF_API_ADDED(13400)
/// Website setting to indicate whether the user has allowlisted suspicious
/// notifications for the origin.
CEF_CONTENT_SETTING_TYPE_ARE_SUSPICIOUS_NOTIFICATIONS_ALLOWLISTED_BY_USER,
@@ -495,6 +499,18 @@ typedef enum {
CEF_CONTENT_SETTING_TYPE_CONTROLLED_FRAME,
#endif
#if CEF_API_ADDED(13500)
/// Website setting which is used for RevokedPermissionsService to
/// store revoked notification permissions of disruptive sites.
CEF_CONTENT_SETTING_TYPE_REVOKED_DISRUPTIVE_NOTIFICATION_PERMISSIONS,
#endif
#if CEF_API_ADDED(13600)
/// Content setting for whether the site is allowed to make local network
/// requests.
CEF_CONTENT_SETTING_TYPE_LOCAL_NETWORK_ACCESS,
#endif
CEF_CONTENT_SETTING_TYPE_NUM_VALUES,
} cef_content_setting_types_t;

View File

@@ -31,15 +31,12 @@
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(OS_LINUX)
#if defined(CEF_X11)
typedef union _XEvent XEvent;
typedef struct _XDisplay XDisplay;
#endif
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_color.h"
@@ -47,17 +44,6 @@ typedef struct _XDisplay XDisplay;
#include "include/internal/cef_types_osr.h"
#include "include/internal/cef_types_runtime.h"
// Handle types.
#if defined(CEF_X11)
#define cef_cursor_handle_t unsigned long
#define cef_event_handle_t XEvent*
#else
#define cef_cursor_handle_t void*
#define cef_event_handle_t void*
#endif
#define cef_window_handle_t unsigned long
#define kNullCursorHandle 0
#define kNullEventHandle NULL
#define kNullWindowHandle 0
@@ -66,6 +52,20 @@ typedef struct _XDisplay XDisplay;
extern "C" {
#endif
#if defined(CEF_X11)
typedef union _XEvent XEvent;
typedef struct _XDisplay XDisplay;
// Handle types.
typedef unsigned long cef_cursor_handle_t;
typedef XEvent* cef_event_handle_t;
#else
typedef void* cef_cursor_handle_t;
typedef void* cef_event_handle_t;
#endif
typedef unsigned long cef_window_handle_t;
///
/// Return the singleton X11 display shared with Chromium. The display is not
/// thread-safe and must only be accessed on the browser process UI thread.

View File

@@ -31,7 +31,9 @@
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(OS_MAC)
#include "include/internal/cef_string.h"
@@ -40,16 +42,6 @@
#include "include/internal/cef_types_osr.h"
#include "include/internal/cef_types_runtime.h"
// Handle types.
// Actually NSCursor*
#define cef_cursor_handle_t void*
// Acutally NSEvent*
#define cef_event_handle_t void*
// Actually NSView*
#define cef_window_handle_t void*
// Actually IOSurface*
#define cef_shared_texture_handle_t void*
#define kNullCursorHandle NULL
#define kNullEventHandle NULL
#define kNullWindowHandle NULL
@@ -78,6 +70,16 @@
extern "C" {
#endif
// Handle types.
// Actually NSCursor*
typedef void* cef_cursor_handle_t;
// Actually NSEvent*
typedef void* cef_event_handle_t;
// Actually NSView*
typedef void* cef_window_handle_t;
// Actually IOSurface*
typedef void* cef_shared_texture_handle_t;
///
/// Structure representing CefExecuteProcess arguments.
///

View File

@@ -31,10 +31,15 @@
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(OS_WIN)
#if !defined(GENERATING_CEF_API_HASH)
#include <windows.h>
#endif
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_color.h"
@@ -42,12 +47,6 @@
#include "include/internal/cef_types_osr.h"
#include "include/internal/cef_types_runtime.h"
// Handle types.
#define cef_cursor_handle_t HCURSOR
#define cef_event_handle_t MSG*
#define cef_window_handle_t HWND
#define cef_shared_texture_handle_t HANDLE
#define kNullCursorHandle NULL
#define kNullEventHandle NULL
#define kNullWindowHandle NULL
@@ -56,6 +55,12 @@
extern "C" {
#endif
// Handle types.
typedef HCURSOR cef_cursor_handle_t;
typedef MSG* cef_event_handle_t;
typedef HWND cef_window_handle_t;
typedef HANDLE cef_shared_texture_handle_t;
///
/// Structure representing CefExecuteProcess arguments.
///

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -132,7 +132,7 @@ void HandleExternalProtocolHelper(
ChromeContentBrowserClientCef* self,
content::WebContents::Getter web_contents_getter,
content::FrameTreeNodeId frame_tree_node_id,
content::NavigationUIData* navigation_data,
std::unique_ptr<content::NavigationUIData> navigation_data,
bool is_primary_main_frame,
bool is_in_fenced_frame_tree,
network::mojom::WebSandboxFlags sandbox_flags,
@@ -153,7 +153,7 @@ void HandleExternalProtocolHelper(
// NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
self->HandleExternalProtocol(
resource_request.url, web_contents_getter, frame_tree_node_id,
navigation_data, is_primary_main_frame, is_in_fenced_frame_tree,
navigation_data.get(), is_primary_main_frame, is_in_fenced_frame_tree,
sandbox_flags,
static_cast<ui::PageTransition>(resource_request.transition_type),
resource_request.has_user_gesture, initiating_origin, initiator_rfh,
@@ -544,10 +544,10 @@ bool ChromeContentBrowserClientCef::HandleExternalProtocol(
web_contents_getter, frame_tree_node_id, request,
base::BindRepeating(HandleExternalProtocolHelper, base::Unretained(this),
web_contents_getter, frame_tree_node_id,
navigation_data, is_primary_main_frame,
is_in_fenced_frame_tree, sandbox_flags, request,
initiating_origin, std::move(weak_initiator_document),
isolation_info));
base::Passed(navigation_data->Clone()),
is_primary_main_frame, is_in_fenced_frame_tree,
sandbox_flags, request, initiating_origin,
std::move(weak_initiator_document), isolation_info));
net_service::ProxyURLLoaderFactory::CreateProxy(
web_contents_getter, std::move(receiver), std::move(request_handler));
@@ -602,7 +602,7 @@ ChromeContentBrowserClientCef::CreateLoginDelegate(
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
content::GuestPageHolder* guest,
LoginAuthRequiredCallback auth_required_callback) {
content::LoginDelegate::LoginAuthRequiredCallback auth_required_callback) {
// |web_contents| is nullptr for CefURLRequests without an associated frame.
if (!web_contents || base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableChromeLoginPrompt)) {

View File

@@ -134,7 +134,8 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
content::GuestPageHolder* guest,
LoginAuthRequiredCallback auth_required_callback) override;
content::LoginDelegate::LoginAuthRequiredCallback auth_required_callback)
override;
void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,

View File

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

View File

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

View File

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

View File

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

View File

@@ -12,10 +12,12 @@
#include "base/task/current_thread.h"
#include "base/threading/thread_restrictions.h"
#include "cef/libcef/browser/browser_info_manager.h"
#include "cef/libcef/browser/prefs/pref_helper.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/browser/trace_subscriber.h"
#include "cef/libcef/common/cef_switches.h"
#include "chrome/browser/browser_process_impl.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "ui/base/ui_base_switches.h"
@@ -289,6 +291,7 @@ int RunMainWithPreferredStackSize(FiberState& fiber_state) {
} // namespace
NO_STACK_PROTECTOR
int CefExecuteProcess(const CefMainArgs& args,
CefRefPtr<CefApp> application,
void* windows_sandbox_info) {
@@ -570,12 +573,24 @@ CefTraceSubscriber* CefContext::GetTraceSubscriber() {
if (shutting_down_) {
return nullptr;
}
if (!trace_subscriber_.get()) {
if (!trace_subscriber_) {
trace_subscriber_ = std::make_unique<CefTraceSubscriber>();
}
return trace_subscriber_.get();
}
pref_helper::Registrar* CefContext::GetPrefRegistrar() {
CEF_REQUIRE_UIT();
if (shutting_down_) {
return nullptr;
}
if (!pref_registrar_) {
pref_registrar_ = std::make_unique<pref_helper::Registrar>();
pref_registrar_->Init(g_browser_process->local_state());
}
return pref_registrar_.get();
}
void CefContext::PopulateGlobalRequestContextSettings(
CefRequestContextSettings* settings) {
CefRefPtr<CefCommandLine> command_line =
@@ -645,12 +660,15 @@ void CefContext::ShutdownOnUIThread() {
observer.OnContextDestroyed();
}
if (trace_subscriber_.get()) {
trace_subscriber_.reset(nullptr);
if (trace_subscriber_) {
trace_subscriber_.reset();
}
if (pref_registrar_) {
pref_registrar_.reset();
}
}
void CefContext::FinalizeShutdown() {
browser_info_manager_.reset(nullptr);
browser_info_manager_.reset();
application_ = nullptr;
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,6 +18,7 @@
#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"
@@ -35,6 +36,8 @@
#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
@@ -117,8 +120,7 @@ bool CefMainRunner::Initialize(CefSettings* settings,
if (exit_code_ != content::RESULT_CODE_NORMAL_EXIT) {
// Some exit codes are used to exit early, but are otherwise a normal
// result. Don't log for those codes.
if (!chrome::IsNormalResultCode(
static_cast<chrome::ResultCode>(exit_code_))) {
if (!IsNormalResultCode(static_cast<ResultCode>(exit_code_))) {
LOG(ERROR) << "ContentMainRun failed with exit code " << exit_code_;
}
return false;
@@ -207,6 +209,7 @@ void CefMainRunner::QuitMessageLoop() {
}
// static
NO_STACK_PROTECTOR
int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args,
CefRefPtr<CefApp> application,
void* windows_sandbox_info) {
@@ -241,9 +244,29 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args,
// Execute the secondary process.
content::ContentMainParams main_params(main_delegate.get());
#if BUILDFLAG(IS_WIN)
// Initialize the sandbox services.
// Match the logic in MainDllLoader::Launch.
sandbox::SandboxInterfaceInfo sandbox_info = {nullptr};
if (windows_sandbox_info == nullptr) {
content::InitializeSandboxInfo(&sandbox_info);
// IsUnsandboxedSandboxType() can't be used here because its result can be
// gated behind a feature flag, which are not yet initialized.
const bool is_sandboxed =
sandbox::policy::SandboxTypeFromCommandLine(command_line) !=
sandbox::mojom::Sandbox::kNoSandbox;
// When using cef_sandbox_info_create() the sandbox info will always be
// initialized. This is incorrect for cases where the sandbox is disabled, and
// we adjust for that here.
if (!is_sandboxed || windows_sandbox_info == nullptr) {
if (is_sandboxed) {
// For child processes that are running as --no-sandbox, don't
// initialize the sandbox info, otherwise they'll be treated as brokers
// (as if they were the browser).
content::InitializeSandboxInfo(
&sandbox_info, IsExtensionPointDisableSet()
? sandbox::MITIGATION_EXTENSION_POINT_DISABLE
: 0);
}
windows_sandbox_info = &sandbox_info;
}
@@ -460,7 +483,7 @@ void CefMainRunner::FinishShutdownOnUIThread() {
ChromeProcessSingleton::DeleteInstance();
}
static_cast<content::ContentMainRunnerImpl*>(main_runner_.get())
static_cast<content::ContentMainRunnerImpl*>(main_runner_.get())
->ShutdownOnUIThread();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -501,7 +501,11 @@ CefRenderWidgetHostViewOSR::GetDisplayFeature() {
return std::nullopt;
}
void CefRenderWidgetHostViewOSR::SetDisplayFeatureForTesting(
void CefRenderWidgetHostViewOSR::DisableDisplayFeatureOverrideForEmulation() {
DCHECK(false);
}
void CefRenderWidgetHostViewOSR::OverrideDisplayFeatureForEmulation(
const content::DisplayFeature* display_feature) {
DCHECK(false);
}
@@ -1864,8 +1868,7 @@ void CefRenderWidgetHostViewOSR::RequestImeCompositionUpdate(
void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged(
const gfx::Range& range,
const std::optional<std::vector<gfx::Rect>>& character_bounds,
const std::optional<std::vector<gfx::Rect>>& line_bounds) {
const std::optional<std::vector<gfx::Rect>>& character_bounds) {
if (browser_impl_.get()) {
CefRange cef_range(range.start(), range.end());
CefRenderHandler::RectList rcList;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -10,7 +10,9 @@
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/prefs/pref_helper.h"
#include "cef/libcef/browser/setting_helper.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/api_version_util.h"
#include "cef/libcef/common/app_manager.h"
#include "cef/libcef/common/task_runner_impl.h"
#include "cef/libcef/common/values_impl.h"
@@ -459,6 +461,22 @@ bool CefRequestContextImpl::SetPreference(const CefString& name,
return pref_helper::SetPreference(pref_service, name, value, error);
}
CefRefPtr<CefRegistration> CefRequestContextImpl::AddPreferenceObserver(
const CefString& name,
CefRefPtr<CefPreferenceObserver> observer) {
CEF_API_REQUIRE_ADDED(13401);
if (!VerifyBrowserContext()) {
return nullptr;
}
if (!pref_registrar_) {
pref_registrar_ = std::make_unique<pref_helper::Registrar>();
pref_registrar_->Init(browser_context()->AsProfile()->GetPrefs());
}
return pref_registrar_->AddObserver(name, observer);
}
void CefRequestContextImpl::ClearCertificateExceptions(
CefRefPtr<CefCompletionCallback> callback) {
GetBrowserContext(
@@ -588,6 +606,26 @@ void CefRequestContextImpl::SetContentSetting(
requesting_url, top_level_url, content_type, value));
}
CefRefPtr<CefRegistration> CefRequestContextImpl::AddSettingObserver(
CefRefPtr<CefSettingObserver> observer) {
CEF_API_REQUIRE_ADDED(13401);
if (!VerifyBrowserContext()) {
return nullptr;
}
if (!setting_registrar_) {
auto* settings_map = HostContentSettingsMapFactory::GetForProfile(
browser_context()->AsProfile());
if (!settings_map) {
return nullptr;
}
setting_registrar_ = std::make_unique<setting_helper::Registrar>();
setting_registrar_->Init(settings_map);
}
return setting_registrar_->AddObserver(observer);
}
void CefRequestContextImpl::SetChromeColorScheme(cef_color_variant_t variant,
cef_color_t user_color) {
GetBrowserContext(

View File

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

View File

@@ -0,0 +1,118 @@
// Copyright (c) 2025 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "cef/libcef/browser/setting_helper.h"
#include "cef/include/cef_request_context.h"
#include "cef/libcef/browser/thread_util.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "url/gurl.h"
namespace setting_helper {
class RegistrationImpl final : public Registration, public CefRegistration {
public:
RegistrationImpl(Registrar* registrar, CefRefPtr<CefSettingObserver> observer)
: registrar_(registrar), observer_(observer) {
DCHECK(registrar_);
DCHECK(observer_);
}
RegistrationImpl(const RegistrationImpl&) = delete;
RegistrationImpl& operator=(const RegistrationImpl&) = delete;
~RegistrationImpl() override {
CEF_REQUIRE_UIT();
if (registrar_) {
registrar_->RemoveObserver(this);
}
}
void Detach() override {
registrar_ = nullptr;
observer_ = nullptr;
}
void RunCallback(const CefString& requesting_url,
const CefString& top_level_url,
cef_content_setting_types_t content_type) const override {
observer_->OnSettingChanged(requesting_url, top_level_url, content_type);
}
private:
raw_ptr<Registrar> registrar_;
CefRefPtr<CefSettingObserver> observer_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(RegistrationImpl);
};
Registrar::~Registrar() {
RemoveAll();
}
void Registrar::Init(HostContentSettingsMap* settings) {
DCHECK(settings);
DCHECK(IsEmpty() || settings_ == settings);
settings_ = settings;
}
void Registrar::Reset() {
RemoveAll();
settings_ = nullptr;
}
void Registrar::RemoveAll() {
if (!observers_.empty()) {
settings_->RemoveObserver(this);
for (auto& registration : observers_) {
registration.Detach();
}
observers_.Clear();
}
}
bool Registrar::IsEmpty() const {
return observers_.empty();
}
CefRefPtr<CefRegistration> Registrar::AddObserver(
CefRefPtr<CefSettingObserver> observer) {
CHECK(settings_);
RegistrationImpl* impl = new RegistrationImpl(this, observer);
if (observers_.empty()) {
settings_->AddObserver(this);
}
observers_.AddObserver(impl);
return impl;
}
void Registrar::RemoveObserver(Registration* registration) {
CHECK(settings_);
observers_.RemoveObserver(registration);
if (observers_.empty()) {
settings_->RemoveObserver(this);
}
}
void Registrar::OnContentSettingChanged(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsTypeSet content_type_set) {
DCHECK(!IsEmpty());
const CefString requesting_url(primary_pattern.ToRepresentativeUrl().spec());
const CefString top_level_url(secondary_pattern.ToRepresentativeUrl().spec());
const auto content_type =
static_cast<cef_content_setting_types_t>(content_type_set.GetType());
for (Registration& registration : observers_) {
registration.RunCallback(requesting_url, top_level_url, content_type);
}
}
} // namespace setting_helper

View File

@@ -0,0 +1,81 @@
// 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_BROWSER_SETTING_HELPER_H_
#define CEF_LIBCEF_BROWSER_SETTING_HELPER_H_
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "cef/include/cef_registration.h"
#include "components/content_settings/core/browser/content_settings_observer.h"
class CefSettingObserver;
class CefRegistration;
class HostContentSettingsMap;
namespace setting_helper {
class Registration : public base::CheckedObserver {
public:
virtual void Detach() = 0;
virtual void RunCallback(const CefString& requesting_url,
const CefString& top_level_url,
cef_content_setting_types_t content_type) const = 0;
};
class RegistrationImpl;
// Automatically manages the registration of one or more CefSettingObserver
// objects with a HostContentSettingsMap. When the Registrar is destroyed, all
// registered observers are automatically unregistered with the
// HostContentSettingsMap. Loosely based on PrefChangeRegistrar.
class Registrar final : public content_settings::Observer {
public:
Registrar() = default;
Registrar(const Registrar&) = delete;
Registrar& operator=(const Registrar&) = delete;
~Registrar();
// Must be called before adding or removing observers. Can be called more
// than once as long as the value of |settings| doesn't change.
void Init(HostContentSettingsMap* settings);
// Removes all observers and clears the reference to the
// HostContentSettingsMap. `Init` must be called before adding or removing any
// observers.
void Reset();
// Removes all observers that have been previously added with a call to Add.
void RemoveAll();
// Returns true if no observers are registered.
bool IsEmpty() const;
// Adds a setting observer. All registered observers will be automatically
// unregistered and detached when the Registrar's destructor is called.
CefRefPtr<CefRegistration> AddObserver(
CefRefPtr<CefSettingObserver> observer);
private:
friend class RegistrationImpl;
void RemoveObserver(Registration* registration);
// content_settings::Observer:
void OnContentSettingChanged(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsTypeSet content_type_set) override;
raw_ptr<HostContentSettingsMap, AcrossTasksDanglingUntriaged> settings_ =
nullptr;
base::ObserverList<Registration> observers_;
};
} // namespace setting_helper
#endif // CEF_LIBCEF_BROWSER_SETTING_HELPER_H_

View File

@@ -62,12 +62,12 @@ CEF_LABEL_BUTTON_IMPL_T class CefLabelButtonImpl : public CEF_BUTTON_IMPL_D {
CEF_LABEL_BUTTON_IMPL_T void CEF_LABEL_BUTTON_IMPL_D::SetText(
const CefString& text) {
CEF_REQUIRE_VALID_RETURN_VOID();
ParentClass::root_view()->SetText(text);
ParentClass::root_view()->SetText(text.ToString16());
}
CEF_LABEL_BUTTON_IMPL_T CefString CEF_LABEL_BUTTON_IMPL_D::GetText() {
CEF_REQUIRE_VALID_RETURN(CefString());
return ParentClass::root_view()->GetText();
return std::u16string(ParentClass::root_view()->GetText());
}
CEF_LABEL_BUTTON_IMPL_T void CEF_LABEL_BUTTON_IMPL_D::SetImage(

View File

@@ -190,7 +190,9 @@ 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::TYPE_CONTROL);
views::Widget::InitParams params(
views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET,
views::Widget::InitParams::TYPE_CONTROL);
params.delegate = this;
params.name = "CefOverlayViewHost";
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
@@ -214,8 +216,9 @@ void CefOverlayViewHost::Init(views::View* host_view,
// Cause WidgetDelegate::DeleteDelegate() to delete |this| after executing the
// registered DeleteDelegate callback.
SetOwnedByWidget(true);
SetOwnedByWidget(OwnedByWidgetPassKey());
RegisterDeleteDelegateCallback(
RegisterDeleteCallbackPassKey(),
base::BindOnce(&CefOverlayViewHost::Cleanup, base::Unretained(this)));
if (window_view_->IsChromeStyle()) {

View File

@@ -77,12 +77,12 @@ bool CefTextfieldImpl::IsReadOnly() {
CefString CefTextfieldImpl::GetText() {
CEF_REQUIRE_VALID_RETURN(CefString());
return root_view()->GetText();
return std::u16string(root_view()->GetText());
}
void CefTextfieldImpl::SetText(const CefString& text) {
CEF_REQUIRE_VALID_RETURN_VOID();
root_view()->SetText(text);
root_view()->SetText(text.ToString16());
}
void CefTextfieldImpl::AppendText(const CefString& text) {
@@ -102,7 +102,7 @@ bool CefTextfieldImpl::HasSelection() {
CefString CefTextfieldImpl::GetSelectedText() {
CEF_REQUIRE_VALID_RETURN(CefString());
return root_view()->GetSelectedText();
return std::u16string(root_view()->GetSelectedText());
}
void CefTextfieldImpl::SelectAll(bool reversed) {
@@ -208,12 +208,12 @@ void CefTextfieldImpl::ClearEditHistory() {
void CefTextfieldImpl::SetPlaceholderText(const CefString& text) {
CEF_REQUIRE_VALID_RETURN_VOID();
root_view()->SetPlaceholderText(text);
root_view()->SetPlaceholderText(text.ToString16());
}
CefString CefTextfieldImpl::GetPlaceholderText() {
CEF_REQUIRE_VALID_RETURN(CefString());
return root_view()->GetPlaceholderText();
return std::u16string(root_view()->GetPlaceholderText());
}
void CefTextfieldImpl::SetPlaceholderTextColor(cef_color_t color) {

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::ScreenWin::ScreenToDIPPoint(gfx::PointF(point)));
display::win::GetScreenWin()->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::ScreenWin::ScreenToDIPRect(nullptr, find_bounds);
display::win::GetScreenWin()->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::ScreenWin::ScreenToDIPPoint(gfx::PointF(point)));
display::win::GetScreenWin()->ScreenToDIPPoint(gfx::PointF(point)));
}
gfx::Point ConvertPointToPixels(const gfx::Point& point) {
return display::win::ScreenWin::DIPToScreenPoint(point);
return display::win::GetScreenWin()->DIPToScreenPoint(point);
}
gfx::Rect ConvertRectFromPixels(const gfx::Rect& rect) {
return display::win::ScreenWin::ScreenToDIPRect(nullptr, rect);
return display::win::GetScreenWin()->ScreenToDIPRect(nullptr, rect);
}
gfx::Rect ConvertRectToPixels(const gfx::Rect& rect) {
return display::win::ScreenWin::DIPToScreenRect(nullptr, rect);
return display::win::GetScreenWin()->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()->get_color();
return view->background()->color().GetSkColor();
}
// 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::ScreenWin::DIPToScreenRect(window, client_bounds);
display::win::GetScreenWin()->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::ScreenWin::ScreenToDIPRect(window, pixel_rect);
return display::win::GetScreenWin()->ScreenToDIPRect(window, pixel_rect);
#else
// Use the default implementation.
return views::NativeFrameView::GetWindowBoundsForClientBounds(
@@ -420,8 +420,9 @@ void CefWindowView::CreateWidget(gfx::AcceleratedWidget parent_widget) {
// Cause WidgetDelegate::DeleteDelegate() to delete |this| after executing the
// registered DeleteDelegate callback.
SetOwnedByWidget(true);
SetOwnedByWidget(OwnedByWidgetPassKey());
RegisterDeleteDelegateCallback(
RegisterDeleteCallbackPassKey(),
base::BindOnce(&CefWindowView::DeleteDelegate, base::Unretained(this)));
if (cef_delegate()) {

View File

@@ -11,6 +11,7 @@
#include "cef/include/internal/cef_logging_internal.h"
#include "cef/include/internal/cef_thread_internal.h"
#include "cef/include/internal/cef_trace_event_internal.h"
#include "cef/libcef/common/api_version_util.h"
namespace {
@@ -218,13 +219,13 @@ CEF_EXPORT void cef_log(const char* file,
}
CEF_EXPORT cef_platform_thread_id_t cef_get_current_platform_thread_id() {
return base::PlatformThread::CurrentId();
return base::PlatformThread::CurrentId().raw();
}
CEF_EXPORT cef_platform_thread_handle_t
cef_get_current_platform_thread_handle() {
#if BUILDFLAG(IS_WIN)
return base::PlatformThread::CurrentId();
return base::PlatformThread::CurrentId().raw();
#else
return base::PlatformThread::CurrentHandle().platform_handle();
#endif
@@ -240,5 +241,7 @@ CEF_EXPORT int cef_dump_without_crashing(long long mseconds_between_dumps,
}
CEF_EXPORT int cef_dump_without_crashing_unthrottled() {
return base::debug::DumpWithoutCrashingUnthrottled();
CEF_API_REQUIRE_REMOVED(13500);
NOTIMPLEMENTED();
return 0;
}

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 =
absl::get_if<InvokedInBrowserProcess>(&invoked_in);
std::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;
}
absl::variant<int, content::MainFunctionParams>
std::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;
absl::variant<int, content::MainFunctionParams> RunProcess(
std::variant<int, content::MainFunctionParams> RunProcess(
const std::string& process_type,
content::MainFunctionParams main_function_params) override;
#if BUILDFLAG(IS_LINUX)

View File

@@ -548,13 +548,12 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
// Allow override of some values via environment variables.
{
std::unique_ptr<base::Environment> env(base::Environment::Create());
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_SERVER_URL")) {
ParseURL(*var_str, &server_url_);
}
if (env->GetVar("CEF_CRASH_REPORTER_RATE_LIMIT_ENABLED", &val_str)) {
rate_limit_ = ParseBool(val_str);
if (const auto& var_str =
env->GetVar("CEF_CRASH_REPORTER_RATE_LIMIT_ENABLED")) {
rate_limit_ = ParseBool(*var_str);
}
}
@@ -642,11 +641,9 @@ 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());
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);
if (const auto& val = env->GetVar("BREAKPAD_DUMP_LOCATION")) {
base::PathService::Override(chrome::DIR_CRASH_DUMPS,
base::FilePath::FromUTF8Unsafe(*val));
}
return base::PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir);
}
@@ -726,8 +723,7 @@ 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

@@ -62,7 +62,7 @@ bool CefCreateTempDirectoryInDirectory(const CefString& base_dir,
base::FilePath result;
base::FilePath::StringType prefix_str = prefix;
if (base::CreateTemporaryDirInDir(
base_dir, base::FilePath::StringPieceType(prefix_str), &result)) {
base_dir, base::FilePath::StringViewType(prefix_str), &result)) {
new_dir = result.value();
return true;
}

View File

@@ -111,12 +111,19 @@ 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,9 +36,7 @@ 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.begin(), header_str.end(),
"\n\r");
i.GetNext();) {
for (net::HttpUtil::HeadersIterator i(header_str, "\n\r"); i.GetNext();) {
map.insert(std::make_pair(i.name(), i.values()));
}
}

View File

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

View File

@@ -114,7 +114,7 @@ bool CefThreadImpl::Create(const CefString& display_name,
}
thread_task_runner_ = new CefTaskRunnerImpl(thread_->task_runner());
thread_id_ = thread_->GetThreadId();
thread_id_ = thread_->GetThreadId().raw();
return true;
}

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