Compare commits

..

89 Commits

Author SHA1 Message Date
Marshall Greenblatt
5c0b03a4ba Pin depot_tools version for out-of-support branch 2024-11-19 13:37:48 -05:00
Marshall Greenblatt
5a7e5ed359 Update to Chromium version 130.0.6723.117 2024-11-06 14:20:43 +00:00
Marshall Greenblatt
34b05bb541 win: Reland screen_1443650 changes (fixes #3489)
Use ScaleToRoundedRect instead of ScaleToEnclosedRect.
2024-11-05 12:42:02 -05:00
Marshall Greenblatt
de32089516 cefclient: Add RootWindowManager tracking of other browsers (see #3790)
The message loop should not quit until all browsers have closed,
including browsers that are not directly associated with a RootWindow.
2024-11-04 17:16:27 -05:00
Marshall Greenblatt
16488e5564 Free CefMenuRunnerViews on BrowserView destruction (see #3790)
CefMenuRunnerViews holds a raw_ptr<CefBrowserViewImpl> that must be
cleared during CefBrowserViewImpl destruction.
2024-11-04 17:16:18 -05:00
Marshall Greenblatt
7bb6b2569c mac: Fix accelerators in overlay BrowserView (see #3188)
CefWindowImpl::CanHandleAccelerators was returning false for
accelerators triggered in the overlay BrowserView due to
IsWindowKey (called from NativeWidgetMac::IsActive) returning
false. View::CanHandleAccelerators, on the other hand, only
checks IsActive for Aura (non-MacOS) windows. We therefore
delegate to the View implementation for consistent handling.
2024-11-04 17:16:10 -05:00
Marshall Greenblatt
7a98b3fece Execute HandleExternalProtocolHelper on the UI thread (fixes #3821) 2024-11-04 12:01:19 -05:00
Marshall Greenblatt
3470f6ade4 Update to Chromium version 130.0.6723.92 2024-10-31 15:33:29 +00:00
Marshall Greenblatt
fc4256797d win: Revert screen_1443650 changes (fixes #3744)
This change broke tooltip display at 125% scale factor on Windows 10
with high-dpi display.

Reopening the original issue #3489.
2024-10-23 14:33:13 -04:00
Marshall Greenblatt
3dedcced94 Update to Chromium version 130.0.6723.70 2024-10-23 12:50:40 +00:00
Marshall Greenblatt
59f3b143ef mac: cefclient: Fix window.close() with --hide-window-on-close (fixes #3660) 2024-10-22 16:19:53 -04:00
Marshall Greenblatt
6514b929c4 Fix raw_ptr leak of main frame RFH during WebContents close (see #3660) 2024-10-22 16:19:45 -04:00
Mike Bragg
a747221b01 Implement PrintCrossProcessSubframe for AlloyBrowserHostImpl (fixes #3768) 2024-10-22 16:06:43 -04:00
Marshall Greenblatt
351ea86650 win: Add SHA256 impl for Sid::FromNamedCapability (fixes #3791)
The cef_sandbox build can't use the default BoringSSL implementation
so we add an alternative implementation using the Crypto API.
2024-10-22 13:12:13 -04:00
Marshall Greenblatt
06c1602d18 Update to Chromium version 130.0.6723.59 2024-10-21 15:25:21 +00:00
Marshall Greenblatt
48f3ef63e2 linux: Fix callbacks to CefPrintHandler (fixes #3729)
Out-of-process printing must also be disabled by passing
`--disable-features=EnableOopPrintDrivers`.
2024-10-18 15:04:17 -04:00
Marshall Greenblatt
7268dc8cd3 cefclient: views: Add ability to pop out the overlay Browser (see #3790)
When running with the overlay Browser enabled (`--show-overlay-browser`),
pressing Alt+O will move the overlay Browser to a new top-level Window.
Pressing Alt+O again or closing the new Window via the close button will
return the Browser to the overlay. Closing the Browser via `window.close()`
(in the new Window or overlay) will dismiss the overlay completely as
required to maintain consistent internal state. Detection of this state is
supported by the new CefBrowserHost::IsReadyToBeClosed method.

Draggable regions in the main Browser are updated to account for the
presence or absence of the overlay Browser. Support for draggable regions
in the overlay Browser in not implemented in cefclient.

Behavior with multiple overlays, `window.close()` and draggable regions
can be tested by adding `--hide-frame --hide-controls`.
2024-10-18 15:04:08 -04:00
Marshall Greenblatt
45861b1b08 chrome: Support unload handlers with TryCloseBrowser
TryCloseBrowser should potentially trigger JavaScript unload handlers
and return false. Add CefBrowserHost::IsReadyToBeClosed for detecting
mandatory close state. Enable, for Chrome style browsers, LifeSpanTest
that don't require DoClose(). Update related documentation.
2024-10-18 15:03:59 -04:00
Marshall Greenblatt
efe558cd28 views: Fix dangling raw_ptr on CefToolbarViewView destruction 2024-10-18 15:03:49 -04:00
Marshall Greenblatt
f1e634393f views: cefclient: Fix crash when ID_MENU_BUTTON doesn't exist 2024-10-18 15:03:40 -04:00
Marshall Greenblatt
0187046a2e views: Trigger CefBrowser destruction on CefBrowserView release (see #3790)
Avoid a circular ownership dependency between CefBrowserViewImpl and
CefBrowserPlatformDelegate[Chrome]Views (owned by CefBrowserHostBase).
Trigger CefBrowserHostBase destruction when the last CefBrowserViewImpl
reference is released.

This fixes a number of shutdown crashes related to overlay CefBrowsers
still existing at CefShutdown.
2024-10-18 15:03:29 -04:00
Marshall Greenblatt
6f4c2bf8df Fix DiscardableSharedMemoryManager destruction timing
Move DiscardableSharedMemoryManager destruction to the end of UI thread
shutdown, after Mojo messages have stopped arriving. See related comments
at https://chromium-review.googlesource.com/c/chromium/src/+/5925441
2024-10-18 15:03:19 -04:00
Marshall Greenblatt
de2da368c6 cefclient: views: Add overlay BrowserView demo (see #3790)
Adds new `--show-overlay-browser` command-line flag that creates an
overlay containing an Alloy-style BrowserView.  The main BrowserView
may be Chrome- (default) or Alloy-style (add `--use-alloy-style`).
This overlay will only be added to standalone (non-popup) windows.

Popups triggered via the overlay will receive standard Alloy-style
handling in cefclient (e.g. Views-hosted window). Add
`--use-default-popup` for default popup handling.
2024-10-18 15:03:08 -04:00
Marshall Greenblatt
4797681694 views: Fix style calculation for popup BrowserViews (fixes #3499)
Don't depend on a CefBrowserViewDelegate for popup BrowserView style.
Popup style must always match the opener style.
2024-10-18 15:02:57 -04:00
Nik Pavlov
ffbc53a9e6 views: Fix overlay bounds outside of window (fixes #3457) 2024-10-18 15:02:46 -04:00
Marshall Greenblatt
92f14410ae wrapper: Add missing algorithm include (fixes #3804) 2024-10-18 15:02:35 -04:00
Nik Pavlov
e68b0169a1 ceftests: Simplify ViewsWindowTest.WindowAccelerator test (see #3188)
Remove the CefWindowDelegate::OnKeyEvent check as that method
is not currently triggered with the Chrome runtime (see #3797).
2024-10-18 15:02:24 -04:00
Nik Pavlov
1fd6000c70 mac: views: Always initialize CommandDispatcher (see #3188)
ChromeCommandDispatcherDelegate forwards accelerator events to
the FocusManager through NativeWidgetMacNSWindowHost::
HandleAccelerator. Always initialize it so that accelerators also
work in a CefWindow without a BrowserView.
2024-10-18 15:02:14 -04:00
Marshall Greenblatt
5e348cb1fc cefclient: Fix toolbar visibility with --hide-controls (fixes #3745) 2024-10-18 15:02:01 -04:00
Marshall Greenblatt
02b371879b Update to Chromium version 130.0.6723.44 2024-10-11 16:27:48 +00:00
Marshall Greenblatt
3f4d8297f2 Update to Chromium version 130.0.6723.31 2024-10-09 16:36:31 +00:00
Marshall Greenblatt
057c1b1409 cmake: Fix set_property argument (fixes #3775) 2024-09-30 12:49:22 -04:00
Marshall Greenblatt
96ddcee086 Fix dangling ptr in RenderProcessHostTaskProvider (fixes #3758) 2024-09-30 12:19:33 -04:00
Marshall Greenblatt
625ea52a4b Update to Chromium version 130.0.6723.19 2024-09-27 15:50:51 -04:00
Marshall Greenblatt
cd052ec7c3 Update to Chromium version 130.0.6723.0 (#1356013) 2024-09-27 14:15:44 +00:00
Nik Pavlov
e44d33d5bf ceftests: mac: Wait for fullscreen window destruction (see #3188) 2024-09-26 17:52:28 +00:00
Jacobo Aragunde Pérez
6459917c0a Fix index out of bounds with dialog accept_types description (fixes #3779) 2024-09-16 09:08:22 +00:00
Nik Pavlov
b90f0048da Account for overlay host Widget in CefWidget::GetForWidget (fixes #3784) 2024-09-16 09:05:42 +00:00
Nik Pavlov
8c6f8dd404 Add missing <array> header to performance_test_tests.cc 2024-09-02 14:06:21 +00:00
Nik Pavlov
af1f40a2d3 Update to Chromium version 129.0.6668.0
- Mac: Minimum system version is now 11.0.
- Win: Windows SDK version is now 10.0.22621.2428.
2024-08-26 12:44:25 +00:00
Nik Pavlov
2cd405baac Fix handler insertion in CefMessageRouterBrowserSideImpl (fixes #3586) 2024-08-13 18:30:35 +00:00
Marshall Greenblatt
b98eac265a bazel: mac: Copy but don't link the CEF framework (see #3757)
Copy the CEF framework into the app bundle but do not link it. See
https://groups.google.com/g/cef-announce/c/Fith0A3kWtw/m/6ds_mJVMCQAJ
for background.

Use `**kwargs` to pass all other arguments to the actual
`macos_application` target declaration.
2024-08-09 13:18:06 -04:00
Marshall Greenblatt
701c9470f2 Route Download bubble file open to OnOpenURLFromTab (fixes #3750)
Some downloaded file types [1] default to opening in a Browser. Open
requests for these file types originating from the Download bubble UI
should route to the source Browser (call OnOpenURLFromTab). If
OnOpenURLFromTab is unhandled proceed with the default Chrome behavior
of opening the URL in a new default Browser.

[1] PDF, html, etc. For the complete list of file types see
ChromeDownloadManagerDelegate::IsOpenInBrowserPreferredForFile.
2024-08-09 12:07:00 -04:00
Marshall Greenblatt
889cfcf8d1 Fix path override ordering (fixes #3749)
The chrome::DIR_RESOURCES and ui::DIR_LOCALES overrides need to be
configured before calling ChromeMainDelegate::PreSandboxStartup.
2024-08-08 13:39:22 -04:00
Marshall Greenblatt
ebb3c962da Add WebUI allowlist for Alloy-style browsers (fixes #3763) 2024-08-07 14:12:31 -04:00
Marshall Greenblatt
64a2f681aa cefclient: mac: Fix "undefined symbol" link error (see #3499) 2024-08-07 11:34:05 -04:00
Marshall Greenblatt
52888f346f Use int instead of bool in cef_settings_t 2024-08-07 10:41:20 -04:00
Marshall Greenblatt
9e9ba2c543 bazel: Limit define scope to specific cc targets (see #3757)
- Add `declare_[cc|objc]_library` macros to configure common `copts`
  and `local_defines` (where supported) on `[cc|objc]_library`
  targets. This limits the scope of defines to the specific target
  without inheritance by dependent targets.
- `objc_library` does not currently support `local_defines` so we
  use `copts` instead of MacOS.
- Use `**kwargs` to pass all other arguments to the actual cc
  target declaration.
2024-08-06 14:43:45 -04:00
Marshall Greenblatt
166eec85e0 cefclient: Fix invalid cast to ClientHandlerStd (see #3499) 2024-08-05 18:48:30 -04:00
Marshall Greenblatt
f6f4ba8317 bazel: Support <angled> includes of CEF headers (see #3757)
Fixes "file not found with <angled> include" errors.
2024-08-05 17:24:44 -04:00
JC Yang
bed7f420aa Fix dangling ptr in ReadResponseCallbackWrapper (fixes #3760) 2024-08-05 12:36:28 -04:00
Sergey Markelov
be4085981c linux: Fix TLS error on dlopen of libcef.so (fixes #3616) 2024-08-05 12:36:28 -04:00
Loic Frasse-Mathon
785713c4cc posix: Added option to disable signal handlers
See https://github.com/chromiumembedded/java-cef/issues/477
2024-08-05 12:36:28 -04:00
Pedro de Carvalho Gomes
b61c106b6b linux: Add CefWindowDelegate::GetLinuxWindowProperties (fixes #3383) 2024-08-05 12:36:28 -04:00
Nik Pavlov
295ea1f715 Enable V8 sandbox by default (fixes #3332)
When the V8 sandbox is enabled, ArrayBuffer backing stores must be
allocated inside the sandbox address space. This change introduces a new
CefV8Value::CreateArrayBufferWithCopy method that copies the memory
contents into the sandbox address space.

Enabling the V8 sandbox can have a performance impact, especially when
passing large ArrayBuffers from C++ code to the JS side. We have therefore
retained the old CefV8Value::CreateArrayBuffer method that references
external memory. However, this method can only be used if the V8 sandbox is
disabled at CEF/Chromium build time.

To disable the V8 sandbox add `v8_enable_sandbox=false` to
`GN_DEFINES` when building CEF/Chromium.
2024-08-05 16:00:58 +00:00
Marshall Greenblatt
08ae3a44a6 bazel: Fix resource paths as external repo (see #3757)
- Headers that are included by .rc files need to be supplied to
  `declare_exe` via the `resources_deps` attribute (passed as the `deps
  attribute to `compile_rc`). The headers must be part of a cc_library
  target via either the `hdrs` or `srcs` attribute.
- File paths for CEF resources are prefixed with "external/<repo>"
  when CEF is loaded as an external repo. Update `copy_filegroups` to
  work with these paths.
2024-08-02 16:51:11 -04:00
Marshall Greenblatt
5ddeef736a bazel: Add repo for package-local target labels (see #3757)
Unqualified target labels don't resolve correctly when the
disribution is loaded as an external repo. Mapping, if necessary,
can be performed using the `repo_mapping` parameter to
http_archive() or local_repository().
2024-07-31 17:53:30 -04:00
Marshall Greenblatt
446b7d6535 Update to Chromium version 128.0.6613.0 (#1331488) 2024-07-30 11:10:09 -04:00
Marshall Greenblatt
a6c00b2ff6 bazel: Add initial config for binary distribution (see #3757)
Add support for building the CEF binary distribution using Bazel
and the default platform toolchain. Tested to work for Windows
x64, MacOS ARM64 and x64 (cross-compile from ARM64), and
Linux x64. Windows x86 (cross-compile from x64) is known to
be broken, see https://github.com/bazelbuild/bazel/issues/22164.

Includes minor changes to tests directory structure to meet
Bazel build requirements.
2024-07-28 18:19:47 +00:00
Marshall Greenblatt
69b884d39c Add CefTaskManager::GetTaskIdForBrowserId
Update https://tests/task_manager to show the current browser's
renderer task in bold.


Approved-by: Nik Pavlov
2024-07-19 15:19:06 +00:00
Marshall Greenblatt
3acdbac061 Use direct member for CefBrowserHostBase::contents_delegate_
There's no reason to use unique_ptr here as the lifespan of
|contents_delegate_| exactly matches CefBrowserHostBase.
2024-07-18 13:50:40 -04:00
Nik Pavlov
d470cf8204 Add CefTaskManager API
See https://tests/task_manager example in cefclient.
2024-07-18 11:34:41 -04:00
Marshall Greenblatt
cbbca050e0 cefclient: Allow download with --hide-controls (fixes #3742) 2024-07-17 15:06:23 -04:00
Marshall Greenblatt
69fbadd0bc Disable dangling ptr check for PendingRequest::request_ (fixes #3743)
The InterceptedRequestHandlerWrapper object may be deleted (likely via
~InterceptedRequest) while the task to call
InterceptedRequestHandlerWrapper:ContinueCreateURLLoaderNetworkObserver
is still pending. That binding holds a
WeakPtr<InterceptedRequestHandlerWrapper> (which is now nullptr)
resulting in the bound std::unique_ptr<PendingRequest> being deleted
while still holding a raw_ptr<network::ResourceRequest> to the
already-deleted object. This is always safe (raw_ptr will never be
dereferenced) because of the WeakPtr check.
2024-07-17 14:35:33 -04:00
Marshall Greenblatt
4023fea237 cefbuilds: Add tools distribution (see #3734) 2024-07-16 12:43:12 -04:00
Marshall Greenblatt
5607a4d347 distrib: Add new tools distribution for mksnapshot (see #3734) 2024-07-16 12:43:12 -04:00
Marshall Greenblatt
8f4a47479c mac: cefclient: Fix zombie NSWindow object on exit (fixes #3602)
- Don't create a TempWindow when using Views.
- Don't call `close` on an NSWindow that is never opened.
2024-07-15 16:44:38 -04:00
Marshall Greenblatt
02ea88f79f Call SetIsShutdown after CefInitialize (fixes #3738)
Delay shutdown checking until after CefInitialize has drained existing
task pools.
2024-07-15 16:44:38 -04:00
Marshall Greenblatt
ddb0ab8187 Fix DCHECK adding menu separator with hidden items (fixes #3577) 2024-07-15 12:20:43 -04:00
Marshall Greenblatt
ed4257c807 Fix duplicate open from DevTools when handling OnOpenURLFromTab (fixes #3735) 2024-07-11 14:33:55 -04:00
Marshall Greenblatt
b7a172fefc tools: Build using autoninja
Applies automatic `-j (#cores)` configuration
2024-07-11 10:17:21 -04:00
Marshall Greenblatt
68e1fcf3a4 tools: win: Remove dynamic_annotations.lib from cef_sandbox
This library was removed in https://crbug.com/40209570.
2024-07-10 12:35:47 -04:00
Marshall Greenblatt
1f35258023 Include debug symbols for all distributed binaries (fixes #2235) 2024-07-08 12:18:01 -04:00
Marshall Greenblatt
60ce575e53 Remove libcef/features/runtime.h (see #3685)
Use BUILDFLAG(ENABLE_CEF) exclusively in patch files.
2024-07-05 13:24:40 -04:00
Marshall Greenblatt
0d166c3c90 mac: Remove chrome_crash_reporter_client_stub.cc
Compile out the call to ChromeCrashReporterClient::Create() instead.
2024-07-05 12:28:47 -04:00
Marshall Greenblatt
9b284ec8f7 Remove custom chrome scheme handling (see #3685)
- Add CEF info to existing chrome://version WebUI.
- Move chrome://license handling to WebUI.
- Remove chrome://webui-hosts; use chrome://chrome-urls instead.
- Remove chrome://extension-support; navigate to docs directly instead.
2024-07-05 11:58:08 -04:00
Marshall Greenblatt
b080705ec8 Remove empty runtime_checks.h (see #3685) 2024-07-05 11:58:08 -04:00
Marshall Greenblatt
1cdf02815e Remove devtools window runner abstraction (see #3685)
Remove code abstractions that are no longer required after deletion of
the Alloy bootstrap. This is a functional no-op.
2024-07-05 11:58:08 -04:00
Marshall Greenblatt
cd3f617171 Rename browser_util to browser_event_util (seee #3685)
Use more specific file naming. This change is a functional no-op.
2024-07-03 12:16:26 -04:00
Marshall Greenblatt
bd57a40256 Rename browser_extensions_util to browser_guest_util (seee #3685)
After Alloy bootstrap deletion the remaining functions are no longer
related to extensions. This change is a functional no-op.
2024-07-03 12:16:26 -04:00
Marshall Greenblatt
c0a3c897cf Remove main runner abstractions (see #3685)
Remove code abstractions that are no longer required after deletion of
the Alloy bootstrap. This is a functional no-op.
2024-07-03 12:16:26 -04:00
Nik Pavlov
231701d98b Expose DumpWithoutCrashing (fixes #3588) 2024-07-02 18:08:16 +00:00
Marshall Greenblatt
a461a89728 Delete Alloy bootstrap (fixes #3685) 2024-07-01 12:32:14 -04:00
Nik Pavlov
b95b3e6fd5 tools: Fix "invalid escape sequence '\s'" warning 2024-07-01 15:12:35 +00:00
Marshall Greenblatt
c4a6797059 Allow dangling Listener in CefFileDialogManager (fixes #3720) 2024-06-25 14:03:58 -04:00
Marshall Greenblatt
ebb99fbd58 Fix dangling ResourceRequest* (fixes #3719)
Add raw_ptr<network::ResourceRequest> to RequestState instead of
passing ResourceRequest* as a bound parameter.
2024-06-21 16:54:02 -04:00
Marshall Greenblatt
1d7e83336f Allow dangling UnretainedWrapper for ResourceRequest* (fixes #3717)
Change UnretainedWrapper traits from MayNotDangle (default) to
MayDangleUntriaged as a short-term fix.
2024-06-21 12:57:13 -04:00
Yuta Sekiguchi
2a19d3dc57 Rewrite raw pointers reported by clang plugin (see #3239)
Found using a CEF build with clang_use_chrome_plugins=true
and treat_warnings_as_errors=false.

This change rewrites remaining raw pointers reported by
chromium-rawptr checker and fixes a build error reported
by StackAllocatedChecker.
2024-06-21 11:29:23 -04:00
Marshall Greenblatt
810c51026c Fix assertions with Save As dialog
Fixes some issues introduced by 8e79307a62 (see #3314) and
6354d8daf1 (see #3239).

To test:
- Run `cefclient --url=chrome://net-export`
- Click the "Start Logging to Disk" button
- Exit cefclient; get no debug assertions
2024-06-20 14:04:02 -04:00
579 changed files with 9886 additions and 25924 deletions

263
BUILD.gn
View File

@@ -477,8 +477,12 @@ source_set("libcef_static") {
"libcef/browser/browser_contents_delegate.h",
"libcef/browser/browser_context.cc",
"libcef/browser/browser_context.h",
"libcef/browser/browser_event_util.cc",
"libcef/browser/browser_event_util.h",
"libcef/browser/browser_frame.cc",
"libcef/browser/browser_frame.h",
"libcef/browser/browser_guest_util.cc",
"libcef/browser/browser_guest_util.h",
"libcef/browser/browser_host_base.cc",
"libcef/browser/browser_host_base.h",
"libcef/browser/browser_host_create.cc",
@@ -493,8 +497,6 @@ source_set("libcef_static") {
"libcef/browser/browser_platform_delegate.cc",
"libcef/browser/browser_platform_delegate.h",
"libcef/browser/browser_platform_delegate_create.cc",
"libcef/browser/browser_util.cc",
"libcef/browser/browser_util.h",
"libcef/browser/certificate_query.cc",
"libcef/browser/certificate_query.h",
"libcef/browser/chrome/browser_delegate.h",
@@ -512,12 +514,9 @@ source_set("libcef_static") {
"libcef/browser/chrome/chrome_content_browser_client_cef.h",
"libcef/browser/chrome/chrome_context_menu_handler.cc",
"libcef/browser/chrome/chrome_context_menu_handler.h",
"libcef/browser/chrome/chrome_devtools_window_runner.cc",
"libcef/browser/chrome/chrome_devtools_window_runner.h",
"libcef/browser/chrome/chrome_startup_browser_creator.cc",
"libcef/browser/chrome/chrome_startup_browser_creator.h",
"libcef/browser/chrome/chrome_web_contents_view_delegate_cef.h",
"libcef/browser/chrome_crash_reporter_client_stub.cc",
"libcef/browser/chrome/extensions/chrome_extension_util.cc",
"libcef/browser/chrome/extensions/chrome_extension_util.h",
"libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.cc",
@@ -546,16 +545,14 @@ source_set("libcef_static") {
"libcef/browser/devtools/devtools_controller.h",
"libcef/browser/devtools/devtools_protocol_manager.cc",
"libcef/browser/devtools/devtools_protocol_manager.h",
"libcef/browser/devtools/devtools_window_runner.cc",
"libcef/browser/devtools/devtools_window_runner.h",
"libcef/browser/devtools/devtools_window_runner_create.cc",
"libcef/browser/download_item_impl.cc",
"libcef/browser/download_item_impl.h",
"libcef/browser/download_manager_delegate.cc",
"libcef/browser/download_manager_delegate.h",
"libcef/browser/download_manager_delegate_impl.cc",
"libcef/browser/download_manager_delegate_impl.h",
"libcef/browser/extensions/browser_extensions_util.cc",
"libcef/browser/extensions/browser_extensions_util.h",
"libcef/browser/file_dialog_manager.cc",
"libcef/browser/file_dialog_manager.h",
"libcef/browser/file_dialog_runner.cc",
@@ -603,8 +600,6 @@ source_set("libcef_static") {
"libcef/browser/native/window_delegate_view.h",
"libcef/browser/navigation_entry_impl.cc",
"libcef/browser/navigation_entry_impl.h",
"libcef/browser/net/chrome_scheme_handler.cc",
"libcef/browser/net/chrome_scheme_handler.h",
"libcef/browser/net/crlset_file_util_impl.cc",
"libcef/browser/net/throttle_handler.cc",
"libcef/browser/net/throttle_handler.h",
@@ -683,10 +678,14 @@ source_set("libcef_static") {
"libcef/browser/ssl_status_impl.h",
"libcef/browser/stream_impl.cc",
"libcef/browser/stream_impl.h",
"libcef/browser/task_manager_impl.cc",
"libcef/browser/task_manager_impl.h",
"libcef/browser/trace_impl.cc",
"libcef/browser/trace_subscriber.cc",
"libcef/browser/trace_subscriber.h",
"libcef/browser/thread_util.h",
"libcef/browser/ui_thread.cc",
"libcef/browser/ui_thread.h",
"libcef/browser/views/basic_label_button_impl.cc",
"libcef/browser/views/basic_label_button_impl.h",
"libcef/browser/views/basic_label_button_view.cc",
@@ -768,8 +767,6 @@ source_set("libcef_static") {
"libcef/common/chrome/chrome_content_client_cef.h",
"libcef/common/chrome/chrome_main_delegate_cef.cc",
"libcef/common/chrome/chrome_main_delegate_cef.h",
"libcef/common/chrome/chrome_main_runner_delegate.cc",
"libcef/common/chrome/chrome_main_runner_delegate.h",
"libcef/common/command_line_impl.cc",
"libcef/common/command_line_impl.h",
"libcef/common/crash_reporter_client.cc",
@@ -783,8 +780,6 @@ source_set("libcef_static") {
"libcef/common/frame_util.h",
"libcef/common/i18n_util_impl.cc",
"libcef/common/json_impl.cc",
"libcef/common/main_runner_delegate.h",
"libcef/common/main_runner_handler.h",
"libcef/common/net/http_header_utils.cc",
"libcef/common/net/http_header_utils.h",
"libcef/common/net/scheme_registration.cc",
@@ -834,8 +829,6 @@ source_set("libcef_static") {
"libcef/common/values_impl.h",
"libcef/common/waitable_event_impl.cc",
"libcef/common/waitable_event_impl.h",
"libcef/features/runtime.h",
"libcef/features/runtime_checks.h",
"libcef/renderer/browser_impl.cc",
"libcef/renderer/browser_impl.h",
"libcef/renderer/chrome/chrome_content_renderer_client_cef.cc",
@@ -844,10 +837,6 @@ source_set("libcef_static") {
"libcef/renderer/dom_document_impl.h",
"libcef/renderer/dom_node_impl.cc",
"libcef/renderer/dom_node_impl.h",
"libcef/renderer/extensions/extensions_renderer_api_provider.cc",
"libcef/renderer/extensions/extensions_renderer_api_provider.h",
"libcef/renderer/extensions/extensions_renderer_client.cc",
"libcef/renderer/extensions/extensions_renderer_client.h",
"libcef/renderer/frame_impl.cc",
"libcef/renderer/frame_impl.h",
"libcef/renderer/render_frame_observer.cc",
@@ -865,121 +854,6 @@ source_set("libcef_static") {
"//chrome/app/chrome_main_delegate.h",
]
if (enable_alloy_bootstrap) {
sources += [
"libcef/browser/alloy/alloy_browser_context.cc",
"libcef/browser/alloy/alloy_browser_context.h",
"libcef/browser/alloy/alloy_browser_main.cc",
"libcef/browser/alloy/alloy_browser_main.h",
"libcef/browser/alloy/alloy_content_browser_client.cc",
"libcef/browser/alloy/alloy_content_browser_client.h",
"libcef/browser/alloy/alloy_download_manager_delegate.cc",
"libcef/browser/alloy/alloy_download_manager_delegate.h",
"libcef/browser/alloy/alloy_download_util.cc",
"libcef/browser/alloy/alloy_download_util.h",
"libcef/browser/alloy/alloy_web_contents_view_delegate.cc",
"libcef/browser/alloy/alloy_web_contents_view_delegate.h",
"libcef/browser/alloy/devtools/alloy_devtools_window_runner.cc",
"libcef/browser/alloy/devtools/alloy_devtools_window_runner.h",
"libcef/browser/alloy/devtools/devtools_file_manager.cc",
"libcef/browser/alloy/devtools/devtools_file_manager.h",
"libcef/browser/alloy/devtools/devtools_frontend.cc",
"libcef/browser/alloy/devtools/devtools_frontend.h",
"libcef/browser/alloy/devtools/devtools_manager_delegate.cc",
"libcef/browser/alloy/devtools/devtools_manager_delegate.h",
"libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.cc",
"libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h",
"libcef/browser/alloy/chrome_browser_process_alloy.cc",
"libcef/browser/alloy/chrome_browser_process_alloy.h",
"libcef/browser/alloy/chrome_profile_manager_alloy.cc",
"libcef/browser/alloy/chrome_profile_manager_alloy.h",
"libcef/browser/alloy/chrome_profile_alloy.cc",
"libcef/browser/alloy/chrome_profile_alloy.h",
"libcef/browser/browser_context_keyed_service_factories.cc",
"libcef/browser/browser_context_keyed_service_factories.h",
"libcef/browser/extension_impl.cc",
"libcef/browser/extension_impl.h",
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.cc",
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.h",
"libcef/browser/extensions/api/storage/sync_value_store_cache.cc",
"libcef/browser/extensions/api/storage/sync_value_store_cache.h",
"libcef/browser/extensions/api/tabs/tabs_api.cc",
"libcef/browser/extensions/api/tabs/tabs_api.h",
"libcef/browser/extensions/alloy_extensions_util.cc",
"libcef/browser/extensions/alloy_extensions_util.h",
"libcef/browser/extensions/browser_platform_delegate_background.cc",
"libcef/browser/extensions/browser_platform_delegate_background.h",
"libcef/browser/extensions/chrome_api_registration.cc",
"libcef/browser/extensions/chrome_api_registration.h",
"libcef/browser/extensions/component_extension_resource_manager.cc",
"libcef/browser/extensions/component_extension_resource_manager.h",
"libcef/browser/extensions/extensions_api_client.cc",
"libcef/browser/extensions/extensions_api_client.h",
"libcef/browser/extensions/extensions_browser_api_provider.cc",
"libcef/browser/extensions/extensions_browser_api_provider.h",
"libcef/browser/extensions/extensions_browser_client.cc",
"libcef/browser/extensions/extensions_browser_client.h",
"libcef/browser/extensions/extension_background_host.cc",
"libcef/browser/extensions/extension_background_host.h",
"libcef/browser/extensions/extension_function_details.cc",
"libcef/browser/extensions/extension_function_details.h",
"libcef/browser/extensions/extension_host_delegate.cc",
"libcef/browser/extensions/extension_host_delegate.h",
"libcef/browser/extensions/extension_system.cc",
"libcef/browser/extensions/extension_system.h",
"libcef/browser/extensions/extension_system_factory.cc",
"libcef/browser/extensions/extension_system_factory.h",
"libcef/browser/extensions/extension_view_host.cc",
"libcef/browser/extensions/extension_view_host.h",
"libcef/browser/extensions/extension_web_contents_observer.cc",
"libcef/browser/extensions/extension_web_contents_observer.h",
"libcef/browser/extensions/mime_handler_view_guest_delegate.cc",
"libcef/browser/extensions/mime_handler_view_guest_delegate.h",
"libcef/browser/extensions/value_store/cef_value_store.cc",
"libcef/browser/extensions/value_store/cef_value_store.h",
"libcef/browser/extensions/value_store/cef_value_store_factory.cc",
"libcef/browser/extensions/value_store/cef_value_store_factory.h",
"libcef/browser/media_capture_devices_dispatcher.cc",
"libcef/browser/media_capture_devices_dispatcher.h",
"libcef/browser/net/devtools_scheme_handler.cc",
"libcef/browser/net/devtools_scheme_handler.h",
"libcef/browser/net/internal_scheme_handler.cc",
"libcef/browser/net/internal_scheme_handler.h",
"libcef/browser/net/scheme_handler.cc",
"libcef/browser/net/scheme_handler.h",
"libcef/browser/prefs/pref_store.cc",
"libcef/browser/prefs/pref_store.h",
"libcef/browser/speech_recognition_manager_delegate.cc",
"libcef/browser/speech_recognition_manager_delegate.h",
"libcef/browser/ssl_host_state_delegate.cc",
"libcef/browser/ssl_host_state_delegate.h",
"libcef/common/alloy/alloy_content_client.cc",
"libcef/common/alloy/alloy_content_client.h",
"libcef/common/alloy/alloy_main_delegate.cc",
"libcef/common/alloy/alloy_main_delegate.h",
"libcef/common/alloy/alloy_main_runner_delegate.cc",
"libcef/common/alloy/alloy_main_runner_delegate.h",
"libcef/common/extensions/chrome_generated_schemas.cc",
"libcef/common/extensions/chrome_generated_schemas.h",
"libcef/common/extensions/extensions_api_provider.cc",
"libcef/common/extensions/extensions_api_provider.h",
"libcef/common/extensions/extensions_client.cc",
"libcef/common/extensions/extensions_client.h",
"libcef/common/extensions/extensions_util.cc",
"libcef/common/extensions/extensions_util.h",
"libcef/common/net/net_resource_provider.cc",
"libcef/common/net/net_resource_provider.h",
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
"libcef/renderer/alloy/alloy_content_renderer_client.h",
"libcef/renderer/alloy/alloy_render_frame_observer.cc",
"libcef/renderer/alloy/alloy_render_frame_observer.h",
"libcef/renderer/alloy/alloy_render_thread_observer.cc",
"libcef/renderer/alloy/alloy_render_thread_observer.h",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.cc",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.h",
]
}
configs += [
"libcef/features:config",
"//build/config:precompiled_headers",
@@ -1008,13 +882,6 @@ source_set("libcef_static") {
":libcef_static_unittested",
# Generate API bindings for extensions.
# TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See
# libcef/common/extensions/api/README.txt for details.
#"libcef/common/extensions/api",
#"libcef/common/extensions/api:api_registration",
"libcef/common/extensions/api:extensions_features",
# Normal build dependencies. Should be sorted alphabetically.
"//base:base_static",
"//cc",
@@ -1111,7 +978,6 @@ source_set("libcef_static") {
if (is_win) {
sources += includes_win + [
"libcef/browser/alloy/alloy_browser_main_win.cc",
"libcef/browser/native/browser_platform_delegate_native_win.cc",
"libcef/browser/native/browser_platform_delegate_native_win.h",
"libcef/browser/osr/browser_platform_delegate_osr_win.cc",
@@ -1462,8 +1328,9 @@ make_pack_header("strings") {
"$root_gen_dir/components/strings/grit/components_strings.h",
"$root_gen_dir/extensions/strings/grit/extensions_strings.h",
"$root_gen_dir/services/strings/grit/services_strings.h",
"$root_gen_dir/third_party/blink/public/strings/grit/blink_accessibility_strings.h",
"$root_gen_dir/third_party/blink/public/strings/grit/blink_strings.h",
"$root_gen_dir/ui/strings/grit/app_locale_settings.h",
"$root_gen_dir/ui/strings/grit/auto_image_annotation_strings.h",
"$root_gen_dir/ui/strings/grit/ui_strings.h",
]
@@ -1480,8 +1347,8 @@ make_pack_header("strings") {
"//extensions/strings",
"//services/strings",
"//third_party/blink/public/strings",
"//third_party/blink/public/strings:accessibility_strings",
"//ui/strings:app_locale_settings",
"//ui/strings:auto_image_annotation_strings",
"//ui/strings:ui_strings",
]
}
@@ -1605,50 +1472,32 @@ if (is_mac) {
]
}
if (use_egl) {
# Add the ANGLE .dylibs in the MODULE_DIR of the Framework app bundle.
bundle_data("cef_framework_angle_binaries") {
sources = [
"$root_out_dir/egl_intermediates/libEGL.dylib",
"$root_out_dir/egl_intermediates/libGLESv2.dylib",
]
outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
]
public_deps = [
"//ui/gl:angle_library_copy",
]
}
# Add the SwiftShader .dylibs in the MODULE_DIR of the Framework app bundle.
bundle_data("cef_framework_swiftshader_binaries") {
sources = [
"$root_out_dir/vk_intermediates/libvk_swiftshader.dylib",
"$root_out_dir/vk_intermediates/vk_swiftshader_icd.json",
]
outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
]
public_deps = [
"//ui/gl:swiftshader_vk_library_copy",
]
}
# Add the ANGLE .dylibs in the MODULE_DIR of the Framework app bundle.
bundle_data("cef_framework_angle_binaries") {
sources = [
"$root_out_dir/egl_intermediates/libEGL.dylib",
"$root_out_dir/egl_intermediates/libGLESv2.dylib",
]
outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
]
public_deps = [
"//ui/gl:angle_library_copy",
]
}
group("cef_framework_angle_library") {
if (use_egl) {
deps = [
":cef_framework_angle_binaries",
]
}
}
group("cef_framework_swiftshader_library") {
if (use_egl) {
deps = [
":cef_framework_swiftshader_binaries",
]
}
# Add the SwiftShader .dylibs in the MODULE_DIR of the Framework app bundle.
bundle_data("cef_framework_swiftshader_binaries") {
sources = [
"$root_out_dir/vk_intermediates/libvk_swiftshader.dylib",
"$root_out_dir/vk_intermediates/vk_swiftshader_icd.json",
]
outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
]
public_deps = [
"//ui/gl:swiftshader_vk_library_copy",
]
}
mac_framework_bundle("cef_framework") {
@@ -1672,9 +1521,9 @@ if (is_mac) {
gypi_paths.autogen_library_side
deps = [
":cef_framework_angle_library",
":cef_framework_angle_binaries",
":cef_framework_resources",
":cef_framework_swiftshader_library",
":cef_framework_swiftshader_binaries",
":libcef_static",
":libcef_test_support",
]
@@ -1968,7 +1817,7 @@ if (is_mac) {
bundle_data("cefclient_resources_bundle_data") {
sources = gypi_paths2.shared_sources_resources +
gypi_paths2.cefclient_sources_resources + [
"tests/cefclient/resources/mac/cefclient.icns",
"tests/cefclient/mac/cefclient.icns",
]
outputs = [
@@ -1978,7 +1827,7 @@ if (is_mac) {
bundle_data("cefclient_resources_bundle_data_english") {
sources = [
"tests/cefclient/resources/mac/English.lproj/InfoPlist.strings",
"tests/cefclient/mac/English.lproj/InfoPlist.strings",
]
outputs = [
@@ -1988,7 +1837,7 @@ if (is_mac) {
mac_xib_bundle_data("cefclient_xibs") {
sources = [
"tests/cefclient/resources/mac/English.lproj/MainMenu.xib",
"tests/cefclient/mac/English.lproj/MainMenu.xib",
]
output_path = "{{bundle_resources_dir}}/English.lproj"
@@ -1998,7 +1847,7 @@ if (is_mac) {
# Necessary because the cef_framework target is testonly.
testonly = true
helper_info_plist = "tests/cefclient/resources/mac/helper-Info.plist"
helper_info_plist = "tests/cefclient/mac/helper-Info.plist.in"
helper_sources = includes_common +
includes_mac +
gypi_paths2.includes_wrapper +
@@ -2012,7 +1861,7 @@ if (is_mac) {
"CEF_USE_SANDBOX",
]
info_plist = "tests/cefclient/resources/mac/Info.plist"
info_plist = "tests/cefclient/mac/Info.plist.in"
sources = includes_common +
includes_mac +
gypi_paths2.includes_wrapper +
@@ -2074,7 +1923,7 @@ if (is_mac) {
# Necessary because the cef_framework target is testonly.
testonly = true
helper_info_plist = "tests/cefsimple/mac/helper-Info.plist"
helper_info_plist = "tests/cefsimple/mac/helper-Info.plist.in"
helper_sources = includes_common +
includes_mac +
gypi_paths2.includes_wrapper +
@@ -2084,7 +1933,7 @@ if (is_mac) {
"CEF_USE_SANDBOX",
]
info_plist = "tests/cefsimple/mac/Info.plist"
info_plist = "tests/cefsimple/mac/Info.plist.in"
sources = includes_common +
includes_mac +
gypi_paths2.includes_wrapper +
@@ -2111,7 +1960,7 @@ if (is_mac) {
bundle_data("ceftests_resources_bundle_data") {
sources = gypi_paths2.shared_sources_resources + [
"tests/ceftests/resources/mac/ceftests.icns",
"tests/ceftests/mac/ceftests.icns",
]
outputs = [
@@ -2121,7 +1970,7 @@ if (is_mac) {
bundle_data("ceftests_resources_bundle_data_english") {
sources = [
"tests/ceftests/resources/mac/English.lproj/InfoPlist.strings",
"tests/ceftests/mac/English.lproj/InfoPlist.strings",
]
outputs = [
@@ -2131,7 +1980,7 @@ if (is_mac) {
mac_xib_bundle_data("ceftests_xibs") {
sources = [
"tests/ceftests/resources/mac/English.lproj/MainMenu.xib",
"tests/ceftests/mac/English.lproj/MainMenu.xib",
]
output_path = "{{bundle_resources_dir}}/English.lproj"
}
@@ -2139,11 +1988,12 @@ if (is_mac) {
cef_app("ceftests") {
testonly = true
helper_info_plist = "tests/ceftests/resources/mac/helper-Info.plist"
helper_info_plist = "tests/ceftests/mac/helper-Info.plist.in"
helper_sources = gypi_paths2.shared_sources_common +
gypi_paths2.shared_sources_renderer +
gypi_paths2.shared_sources_mac_helper +
gypi_paths2.ceftests_sources_mac_helper
gypi_paths2.ceftests_sources_mac_helper +
gypi_paths2.ceftests_sources_mac_helper_shared
helper_deps = [
":gtest_teamcity",
"//testing/gtest",
@@ -2156,7 +2006,7 @@ if (is_mac) {
"CEF_TESTS_IN_SRC_DIRECTORY",
]
info_plist = "tests/ceftests/resources/mac/Info.plist"
info_plist = "tests/ceftests/mac/Info.plist.in"
sources = includes_common +
includes_mac +
gypi_paths2.includes_wrapper +
@@ -2241,7 +2091,8 @@ if (is_mac) {
if (is_win) {
sources += includes_win +
gypi_paths2.shared_sources_win +
gypi_paths2.cefclient_sources_win
gypi_paths2.cefclient_sources_win +
gypi_paths2.cefclient_sources_resources_win_rc
# Set /SUBSYSTEM:WINDOWS.
configs -= [ "//build/config/win:console" ]
@@ -2337,7 +2188,8 @@ if (is_mac) {
if (is_win) {
sources += includes_win +
gypi_paths2.cefsimple_sources_win
gypi_paths2.cefsimple_sources_win +
gypi_paths2.cefsimple_sources_resources_win_rc
# Set /SUBSYSTEM:WINDOWS.
configs -= [ "//build/config/win:console" ]
@@ -2412,7 +2264,8 @@ if (is_mac) {
if (is_win) {
sources += gypi_paths2.shared_sources_win +
gypi_paths2.ceftests_sources_win
gypi_paths2.ceftests_sources_win +
gypi_paths2.ceftests_sources_resources_win_rc
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.

View File

@@ -7,5 +7,6 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/127.0.6533.43'
'chromium_checkout': 'refs/tags/130.0.6723.117',
'depot_tools_checkout': 'c22f4dc74f'
}

View File

@@ -27,17 +27,6 @@
# Files in the chromium/src directory that should be evaluated for changes.
# Similar changes may need to be applied to the CEF source code.
'files': [
'chrome/browser/browser_process.h',
'chrome/browser/extensions/api/tabs/tabs_api.*',
'chrome/browser/extensions/chrome_component_extension_resource_manager.*',
'chrome/browser/extensions/chrome_extension_web_contents_observer.*',
'chrome/browser/extensions/component_loader.*',
'chrome/browser/extensions/extension_service.*',
'chrome/browser/profiles/profile.h',
'chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.*',
'chrome/common/extensions/api/*_features.json',
'chrome/renderer/chrome_content_renderer_client.*',
'chrome/renderer/extensions/chrome_extensions_renderer_client.*',
'components/content_settings/core/common/content_settings_types.mojom',
'components/permissions/request_type.h',
'content/browser/renderer_host/render_widget_host_view_base.*',

View File

@@ -48,10 +48,9 @@
# libgtk3.0-dev (required by the cefclient target only)
#
# - MacOS requirements:
# Xcode 12.2 to 15.0 building on MacOS 10.15.4 (Catalina) or newer. Only
# 64-bit builds are supported. The Xcode command-line tools must also be
# installed. Newer Xcode versions may not have been been tested and are not
# recommended.
# Xcode 12.2 to 15.4 building on MacOS 11.0 (Big Sur) or newer. The Xcode
# command-line tools must also be installed. Newer Xcode versions may not have
# been been tested and are not recommended.
#
# - Windows requirements:
# Visual Studio 2022 building on Windows 10 or newer. Windows 10/11 64-bit is
@@ -143,7 +142,7 @@ set(CMAKE_CONFIGURATION_TYPES Debug Release)
project(cef)
# Use folders in the resulting project files.
set_property(GLOBAL PROPERTY OS_FOLDERS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#
@@ -254,4 +253,4 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile")
else()
message(WARNING "Doxygen must be installed to generate API documentation.")
endif()
endif()
endif()

8
bazel/BUILD.bazel Normal file
View File

@@ -0,0 +1,8 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
# Allow access from targets in other packages.
package(default_visibility = [
"//visibility:public",
])

65
bazel/copy_filegroups.bzl Normal file
View File

@@ -0,0 +1,65 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
def _copy_filegroups_impl(ctx):
inputs = ctx.files.filegroups
remove_prefixes = ctx.attr.remove_prefixes
add_prefix = ctx.attr.add_prefix
outputs = []
for f in inputs:
relative_path = f.path
if relative_path.startswith("external/"):
# Remove the "external/<repo>" component, if any.
relative_path = "/".join(relative_path.split("/")[2:])
for prefix in remove_prefixes:
# Add trailing forward slash if necessary.
if prefix[-1] != "/":
prefix += "/"
if len(prefix) > 0 and relative_path.startswith(prefix):
relative_path = relative_path[len(prefix):]
break
if len(add_prefix) > 0:
# Add trailing forward slash if necessary.
if add_prefix[-1] != "/":
add_prefix += "/"
relative_path = add_prefix + relative_path
out = ctx.actions.declare_file(relative_path)
outputs.append(out)
if relative_path.find("/") > 0:
command="mkdir -p $(dirname {}) && cp {} {}".format(out.path, f.path, out.path)
else:
command="cp {} {}".format(f.path, out.path)
ctx.actions.run_shell(
outputs=[out],
inputs=depset([f]),
command=command
)
# Small sanity check
if len(inputs) != len(outputs):
fail("Output count should be 1-to-1 with input count.")
return DefaultInfo(
files=depset(outputs),
runfiles=ctx.runfiles(files=outputs)
)
# Allows the file contents of |filegroups| to be copied next to a cc_binary
# target via the |data| attribute.
# Implementation based on https://stackoverflow.com/a/57983629
copy_filegroups = rule(
implementation=_copy_filegroups_impl,
attrs={
"filegroups": attr.label_list(),
"remove_prefixes": attr.string_list(default = []),
"add_prefix": attr.string(default = ""),
},
)

90
bazel/library_helpers.bzl Normal file
View File

@@ -0,0 +1,90 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
load("//bazel/win:variables.bzl",
WIN_COMMON_COPTS="COMMON_COPTS",
WIN_COMMON_COPTS_RELEASE="COMMON_COPTS_RELEASE",
WIN_COMMON_COPTS_DEBUG="COMMON_COPTS_DEBUG",
WIN_COMMON_DEFINES="COMMON_DEFINES",
WIN_COMMON_DEFINES_RELEASE="COMMON_DEFINES_RELEASE",
WIN_COMMON_DEFINES_DEBUG="COMMON_DEFINES_DEBUG")
load("//bazel/linux:variables.bzl",
LINUX_COMMON_COPTS="COMMON_COPTS",
LINUX_COMMON_COPTS_RELEASE="COMMON_COPTS_RELEASE",
LINUX_COMMON_COPTS_DEBUG="COMMON_COPTS_DEBUG",
LINUX_COMMON_DEFINES="COMMON_DEFINES",
LINUX_COMMON_DEFINES_RELEASE="COMMON_DEFINES_RELEASE",
LINUX_COMMON_DEFINES_DEBUG="COMMON_DEFINES_DEBUG")
load("//bazel/mac:variables.bzl",
MAC_COMMON_COPTS="COMMON_COPTS",
MAC_COMMON_COPTS_RELEASE="COMMON_COPTS_RELEASE",
MAC_COMMON_COPTS_DEBUG="COMMON_COPTS_DEBUG")
load("@rules_cc//cc:defs.bzl", "cc_library", "objc_library")
def declare_cc_library(copts=[], local_defines=[], **kwargs):
"""
cc_library wrapper that applies common copts and local_defines.
"""
# NOTE: objc_library does not support local_defines on MacOS, so on
# that platform we put the defines in copts instead.
cc_library(
copts = select({
"@platforms//os:windows": WIN_COMMON_COPTS,
"@platforms//os:linux": LINUX_COMMON_COPTS,
"@platforms//os:macos": MAC_COMMON_COPTS,
"//conditions:default": None,
}) + select({
"@cef//:windows_opt": WIN_COMMON_COPTS_RELEASE,
"@cef//:windows_dbg": WIN_COMMON_COPTS_DEBUG,
"@cef//:windows_fastbuild": WIN_COMMON_COPTS_RELEASE,
"@cef//:linux_opt": LINUX_COMMON_COPTS_RELEASE,
"@cef//:linux_dbg": LINUX_COMMON_COPTS_DEBUG,
"@cef//:linux_fastbuild": LINUX_COMMON_COPTS_RELEASE,
"@cef//:macos_opt": MAC_COMMON_COPTS_RELEASE,
"@cef//:macos_dbg": MAC_COMMON_COPTS_DEBUG,
"@cef//:macos_fastbuild": MAC_COMMON_COPTS_RELEASE,
"//conditions:default": None,
}) + copts,
local_defines = select({
"@platforms//os:windows": WIN_COMMON_DEFINES,
"@platforms//os:linux": LINUX_COMMON_DEFINES,
"//conditions:default": None,
}) + select({
"@cef//:windows_opt": WIN_COMMON_DEFINES_RELEASE,
"@cef//:windows_dbg": WIN_COMMON_DEFINES_DEBUG,
"@cef//:windows_fastbuild": WIN_COMMON_DEFINES_RELEASE,
"@cef//:linux_opt": LINUX_COMMON_DEFINES_RELEASE,
"@cef//:linux_dbg": LINUX_COMMON_DEFINES_DEBUG,
"@cef//:linux_fastbuild": LINUX_COMMON_DEFINES_RELEASE,
"//conditions:default": None,
}) + local_defines,
**kwargs
)
def declare_objc_library(copts=[], **kwargs):
"""
objc_library wrapper that applies common copts.
"""
# NOTE: objc_library does not support local_defines on MacOS, so on
# that platform we put the defines in copts instead.
objc_library(
copts = select({
"@platforms//os:windows": WIN_COMMON_COPTS,
"@platforms//os:linux": LINUX_COMMON_COPTS,
"@platforms//os:macos": MAC_COMMON_COPTS,
"//conditions:default": None,
}) + select({
"@cef//:windows_opt": WIN_COMMON_COPTS_RELEASE,
"@cef//:windows_dbg": WIN_COMMON_COPTS_DEBUG,
"@cef//:windows_fastbuild": WIN_COMMON_COPTS_RELEASE,
"@cef//:linux_opt": LINUX_COMMON_COPTS_RELEASE,
"@cef//:linux_dbg": LINUX_COMMON_COPTS_DEBUG,
"@cef//:linux_fastbuild": LINUX_COMMON_COPTS_RELEASE,
"@cef//:macos_opt": MAC_COMMON_COPTS_RELEASE,
"@cef//:macos_dbg": MAC_COMMON_COPTS_DEBUG,
"@cef//:macos_fastbuild": MAC_COMMON_COPTS_RELEASE,
"//conditions:default": None,
}) + copts,
**kwargs
)

8
bazel/linux/BUILD.bazel Executable file
View File

@@ -0,0 +1,8 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
# Allow access from targets in other packages.
package(default_visibility = [
"//visibility:public",
])

63
bazel/linux/exe_helpers.bzl Executable file
View File

@@ -0,0 +1,63 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
load("//bazel:copy_filegroups.bzl", "copy_filegroups")
load("//bazel/linux:fix_rpath.bzl", "fix_rpath")
load("//bazel/linux:variables.bzl",
"COMMON_LINKOPTS",
"COMMON_COPTS", "COMMON_COPTS_RELEASE", "COMMON_COPTS_DEBUG",
"COMMON_DEFINES", "COMMON_DEFINES_RELEASE", "COMMON_DEFINES_DEBUG")
load("@rules_cc//cc:defs.bzl", "cc_binary")
def declare_exe(name, srcs=[], deps=[], linkopts=[], copts=[], local_defines=[], data=[], **kwargs):
# Copy SOs and resources into the current project.
copy_target = "{}_sos_and_resources".format(name)
copy_filegroups(
name = copy_target,
filegroups = [
"@cef//:sos",
"@cef//:resources",
],
remove_prefixes = [
"Debug",
"Release",
"Resources",
],
)
# Executable target.
binary_target = "{}_incorrect_rpath".format(name)
cc_binary(
name = binary_target,
srcs = srcs,
deps = [
"@cef//:cef_wrapper",
"@cef//:cef",
"@cef//:cef_sandbox",
] + deps,
linkopts = COMMON_LINKOPTS + linkopts,
copts = COMMON_COPTS + select({
"@cef//:linux_dbg": COMMON_COPTS_DEBUG,
"//conditions:default": COMMON_COPTS_RELEASE,
}) + copts,
local_defines = COMMON_DEFINES + select({
"@cef//:linux_dbg": COMMON_DEFINES_DEBUG,
"//conditions:default": COMMON_DEFINES_RELEASE,
}) + local_defines,
data = [
":{}".format(copy_target),
] + data,
target_compatible_with = ["@platforms//os:linux"],
**kwargs
)
# Set rpath to $ORIGIN so that libraries can be loaded from next to the
# executable.
fix_rpath(
name = "{}_fixed_rpath".format(name),
src = ":{}".format(binary_target),
out = name,
target_compatible_with = ["@platforms//os:linux"],
)

41
bazel/linux/fix_rpath.bzl Normal file
View File

@@ -0,0 +1,41 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
def _fix_rpath_impl(ctx):
inputs = ctx.runfiles(files = [ctx.file.src])
# Bring over 'data' dependencies from the input.
inputs = inputs.merge_all([ctx.attr.src[DefaultInfo].default_runfiles])
src = ctx.file.src.path
out = ctx.outputs.out.path
ctx.actions.run_shell(
outputs = [ctx.outputs.out],
inputs = inputs.files,
arguments = [src, out],
command = "cp $1 $2 && " +
"chmod +w $2 && " +
"patchelf --remove-rpath $2 && " +
"patchelf --set-rpath '$ORIGIN' $2"
)
return [DefaultInfo(files = depset([ctx.outputs.out]))]
# Set rpath to $ORIGIN so that libraries can be loaded from next to the
# executable. The result can be confirmed with:
# $ objdump -x ./bazel-bin/path/to/binary | grep 'R.*PATH'
#
# Alternatively, define a custom CC toolchain that overrides
# 'runtime_library_search_directories'.
#
# This rule requires preinstallation of the patchelf package:
# $ sudo apt install patchelf
fix_rpath = rule(
implementation = _fix_rpath_impl,
attrs = {
"src": attr.label(allow_single_file = True),
"out": attr.output(mandatory = True),
},
)

View File

@@ -0,0 +1,7 @@
package(default_visibility = ["//visibility:public"])
exports_files([
"pkg_config.bzl",
"BUILD.tmpl",
])

View File

@@ -0,0 +1,32 @@
# vi: ft=bzl
package(default_visibility = ["//visibility:private"])
_imports = [p[:len(p)-2] for p in glob(["{}/**/*.a".format(d) for d in [%{deps}]])]
[cc_import(
name = i.replace("/", "_"),
hdrs = glob([%{hdrs}]),
# TODO: library extension for platform.
static_library = "{}.a".format(i),
shared_library = "{}.dylib".format(i),
) for i in _imports]
cc_library(
name = "internal_lib",
hdrs = glob([%{hdrs}]),
copts = [%{copts}],
includes = [%{includes}],
linkopts = [%{linkopts}],
deps = [(":" + i.replace("/", "_")) for i in _imports],
)
cc_library(
name = "lib",
hdrs = glob(["%{strip_include}/**/*.h"]),
copts = [%{extra_copts}],
linkopts = [%{extra_linkopts}],
deps = [":internal_lib"] + [%{extra_deps}],
visibility = ["//visibility:public"],
strip_include_prefix = "%{strip_include}",
include_prefix = "%{include_prefix}",
)

View File

@@ -0,0 +1,11 @@
Name: pkg_config
URL: https://github.com/cherrry/bazel_pkg_config
Version: 284219a
Description:
Bazel rules for pkg-config tools.
CEF-specific changes:
- Fix failure with duplicate symlinks.
- Remove `--static` flag from pkg-config invocation.

View File

@@ -0,0 +1,2 @@
workspace(name = "pkg_config")

View File

@@ -0,0 +1,194 @@
def _success(value):
return struct(error = None, value = value)
def _error(message):
return struct(error = message, value = None)
def _split(result, delimeter = " "):
if result.error != None:
return result
return _success([arg for arg in result.value.strip().split(delimeter) if arg])
def _find_binary(ctx, binary_name):
binary = ctx.which(binary_name)
if binary == None:
return _error("Unable to find binary: {}".format(binary_name))
return _success(binary)
def _execute(ctx, binary, args):
result = ctx.execute([binary] + args)
if result.return_code != 0:
return _error("Failed execute {} {}".format(binary, args))
return _success(result.stdout)
def _pkg_config(ctx, pkg_config, pkg_name, args):
return _execute(ctx, pkg_config, [pkg_name] + args)
def _check(ctx, pkg_config, pkg_name):
exist = _pkg_config(ctx, pkg_config, pkg_name, ["--exists"])
if exist.error != None:
return _error("Package {} does not exist".format(pkg_name))
if ctx.attr.version != "":
version = _pkg_config(ctx, pkg_config, pkg_name, ["--exact-version", ctx.attr.version])
if version.error != None:
return _error("Require {} version = {}".format(pkg_name, ctx.attr.version))
if ctx.attr.min_version != "":
version = _pkg_config(ctx, pkg_config, pkg_name, ["--atleast-version", ctx.attr.min_version])
if version.error != None:
return _error("Require {} version >= {}".format(pkg_name, ctx.attr.min_version))
if ctx.attr.max_version != "":
version = _pkg_config(ctx, pkg_config, pkg_name, ["--max-version", ctx.attr.max_version])
if version.error != None:
return _error("Require {} version <= {}".format(pkg_name, ctx.attr.max_version))
return _success(None)
def _extract_prefix(flags, prefix, strip = True):
stripped, remain = [], []
for arg in flags:
if arg.startswith(prefix):
if strip:
stripped += [arg[len(prefix):]]
else:
stripped += [arg]
else:
remain += [arg]
return stripped, remain
def _includes(ctx, pkg_config, pkg_name):
includes = _split(_pkg_config(ctx, pkg_config, pkg_name, ["--cflags-only-I"]))
if includes.error != None:
return includes
includes, unused = _extract_prefix(includes.value, "-I", strip = True)
return _success(includes)
def _copts(ctx, pkg_config, pkg_name):
return _split(_pkg_config(ctx, pkg_config, pkg_name, [
"--cflags-only-other",
"--libs-only-L",
]))
def _linkopts(ctx, pkg_config, pkg_name):
return _split(_pkg_config(ctx, pkg_config, pkg_name, [
"--libs-only-other",
"--libs-only-l",
]))
def _ignore_opts(opts, ignore_opts):
remain = []
for opt in opts:
if opt not in ignore_opts:
remain += [opt]
return remain
def _symlinks(ctx, basename, srcpaths):
result = []
root = ctx.path("")
base = root.get_child(basename)
rootlen = len(str(base)) - len(basename)
for src in [ctx.path(p) for p in srcpaths]:
dest = base.get_child(src.basename)
if not dest.exists:
ctx.symlink(src, dest)
result += [str(dest)[rootlen:]]
return result
def _deps(ctx, pkg_config, pkg_name):
deps = _split(_pkg_config(ctx, pkg_config, pkg_name, [
"--libs-only-L",
"--static",
]))
if deps.error != None:
return deps
deps, unused = _extract_prefix(deps.value, "-L", strip = True)
result = []
for dep in {dep: True for dep in deps}.keys():
base = "deps_" + dep.replace("/", "_").replace(".", "_")
result += _symlinks(ctx, base, [dep])
return _success(result)
def _fmt_array(array):
return ",".join(['"{}"'.format(a) for a in array])
def _fmt_glob(array):
return _fmt_array(["{}/**/*.h".format(a) for a in array])
def _pkg_config_impl(ctx):
pkg_name = ctx.attr.pkg_name
if pkg_name == "":
pkg_name = ctx.attr.name
pkg_config = _find_binary(ctx, "pkg-config")
if pkg_config.error != None:
return pkg_config
pkg_config = pkg_config.value
check = _check(ctx, pkg_config, pkg_name)
if check.error != None:
return check
includes = _includes(ctx, pkg_config, pkg_name)
if includes.error != None:
return includes
includes = includes.value
includes = _symlinks(ctx, "includes", includes)
strip_include = "includes"
if len(includes) == 1:
strip_include = includes[0]
if ctx.attr.strip_include != "":
strip_include += "/" + ctx.attr.strip_include
ignore_opts = ctx.attr.ignore_opts
copts = _copts(ctx, pkg_config, pkg_name)
if copts.error != None:
return copts
copts = _ignore_opts(copts.value, ignore_opts)
linkopts = _linkopts(ctx, pkg_config, pkg_name)
if linkopts.error != None:
return linkopts
linkopts = _ignore_opts(linkopts.value, ignore_opts)
deps = _deps(ctx, pkg_config, pkg_name)
if deps.error != None:
return deps
deps = deps.value
include_prefix = ctx.attr.name
if ctx.attr.include_prefix != "":
include_prefix = ctx.attr.include_prefix + "/" + ctx.attr.name
build = ctx.template("BUILD", Label("//:BUILD.tmpl"), substitutions = {
"%{name}": ctx.attr.name,
"%{hdrs}": _fmt_glob(includes),
"%{includes}": _fmt_array(includes),
"%{copts}": _fmt_array(copts),
"%{extra_copts}": _fmt_array(ctx.attr.copts),
"%{deps}": _fmt_array(deps),
"%{extra_deps}": _fmt_array(ctx.attr.deps),
"%{linkopts}": _fmt_array(linkopts),
"%{extra_linkopts}": _fmt_array(ctx.attr.linkopts),
"%{strip_include}": strip_include,
"%{include_prefix}": include_prefix,
}, executable = False)
pkg_config = repository_rule(
attrs = {
"pkg_name": attr.string(doc = "Package name for pkg-config query, default to name."),
"include_prefix": attr.string(doc = "Additional prefix when including file, e.g. third_party. Compatible with strip_include option to produce desired include paths."),
"strip_include": attr.string(doc = "Strip prefix when including file, e.g. libs, files not included will be invisible. Compatible with include_prefix option to produce desired include paths."),
"version": attr.string(doc = "Exact package version."),
"min_version": attr.string(doc = "Minimum package version."),
"max_version": attr.string(doc = "Maximum package version."),
"deps": attr.string_list(doc = "Dependency targets."),
"linkopts": attr.string_list(doc = "Extra linkopts value."),
"copts": attr.string_list(doc = "Extra copts value."),
"ignore_opts": attr.string_list(doc = "Ignore listed opts in copts or linkopts."),
},
local = True,
implementation = _pkg_config_impl,
)

68
bazel/linux/variables.bzl Executable file
View File

@@ -0,0 +1,68 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
#
# Distribution SOs.
#
SOS = [
"libcef.so",
"libEGL.so",
"libGLESv2.so",
"libvk_swiftshader.so",
"libvulkan.so.1",
]
#
# Common 'linkopts' for cc_binary targets.
#
# Standard link libraries.
STANDARD_LIBS = [
"X11",
]
COMMON_LINKOPTS_DEBUG = [
]
COMMON_LINKOPTS_RELEASE = [
]
COMMON_LINKOPTS = [
"-l{}".format(lib) for lib in STANDARD_LIBS
] + select({
"@cef//:linux_dbg": COMMON_LINKOPTS_DEBUG,
"//conditions:default": COMMON_LINKOPTS_RELEASE,
})
#
# Common 'copts' for cc_libary and cc_binary targets.
#
COMMON_COPTS = [
]
COMMON_COPTS_DEBUG = [
]
COMMON_COPTS_RELEASE = [
]
#
# Common 'defines' for cc_libary targets.
#
COMMON_DEFINES = [
# Used by apps to test if the sandbox is enabled
"CEF_USE_SANDBOX",
]
COMMON_DEFINES_DEBUG = [
]
COMMON_DEFINES_RELEASE = [
# Not a debug build
"NDEBUG",
]

8
bazel/mac/BUILD.bazel Normal file
View File

@@ -0,0 +1,8 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
# Allow access from targets in other packages.
package(default_visibility = [
"//visibility:public",
])

113
bazel/mac/app_helpers.bzl Normal file
View File

@@ -0,0 +1,113 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application")
load("//bazel:variables.bzl", "VERSION_PLIST")
load("//bazel/mac:variables.bzl",
"MACOS_DEPLOYMENT_TARGET",
"MACOS_BUNDLE_ID_BASE",
"CEF_FRAMEWORK_NAME",
"COMMON_LINKOPTS")
def _declare_helper_app(name, info_plist, deps, helper_base_name, helper_suffix, **kwargs):
"""
Creates a Helper .app target.
"""
helper_name = "{} Helper".format(name)
bundle_id_suffix = ""
if helper_suffix:
helper_name += " ({})".format(helper_suffix)
bundle_id_suffix += ".{}".format(helper_suffix.lower())
# Helper app bundle Info.plist.
expand_template(
name = "{}_InfoPList".format(helper_base_name),
template = info_plist,
out = "{}Info.plist".format(helper_base_name),
substitutions = {
"${EXECUTABLE_NAME}": helper_name,
"${PRODUCT_NAME}": name,
"${BUNDLE_ID_SUFFIX}": bundle_id_suffix,
"${VERSION_SHORT}": VERSION_PLIST,
"${VERSION_LONG}": VERSION_PLIST,
},
)
# Helper app bundle.
macos_application(
name = helper_base_name,
bundle_name = helper_name,
bundle_id = "{}.{}.helper{}".format(MACOS_BUNDLE_ID_BASE, name.lower(), bundle_id_suffix),
infoplists = [":{}_InfoPList".format(helper_base_name)],
minimum_os_version = MACOS_DEPLOYMENT_TARGET,
deps = [
"@cef//:cef_sandbox",
] + deps,
**kwargs,
)
HELPERS = {
"HelperBase": "",
"HelperAlerts": "Alerts",
"HelperGPU": "GPU",
"HelperPlugin": "Plugin",
"HelperRenderer": "Renderer",
}
def declare_all_helper_apps(name, info_plist, deps, **kwargs):
"""
Creates all Helper .app targets.
"""
[_declare_helper_app(
name = name,
info_plist = info_plist,
deps = deps,
helper_base_name = h,
helper_suffix = v,
**kwargs,
) for h, v in HELPERS.items()]
def declare_main_app(name, info_plist, deps, resources, linkopts=[], **kwargs):
"""
Creates the main .app target.
"""
# Main app bundle Info.plist.
expand_template(
name = "InfoPList",
template = info_plist,
out = "Info.plist",
substitutions = {
"${EXECUTABLE_NAME}": name,
"${PRODUCT_NAME}": name,
"${VERSION_SHORT}": VERSION_PLIST,
"${VERSION_LONG}": VERSION_PLIST,
},
)
# Main app bindle.
macos_application(
name = name,
additional_contents = {
":HelperBase": "Frameworks",
":HelperAlerts": "Frameworks",
":HelperGPU": "Frameworks",
":HelperPlugin": "Frameworks",
":HelperRenderer": "Frameworks",
"@cef//:cef_framework": "Frameworks/{}.framework".format(CEF_FRAMEWORK_NAME),
},
bundle_name = name,
bundle_id = "{}.{}".format(MACOS_BUNDLE_ID_BASE, name.lower()),
infoplists = [":InfoPList"],
linkopts = COMMON_LINKOPTS + linkopts,
minimum_os_version = MACOS_DEPLOYMENT_TARGET,
resources = resources,
target_compatible_with = [
"@platforms//os:macos",
],
deps = deps,
**kwargs,
)

52
bazel/mac/variables.bzl Normal file
View File

@@ -0,0 +1,52 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
MACOS_DEPLOYMENT_TARGET="11.0"
MACOS_BUNDLE_ID_BASE="org.cef"
CEF_FRAMEWORK_NAME="Chromium Embedded Framework"
#
# Common 'linkopts' for macos_application targets.
#
# Standard link frameworks.
STANDARD_FRAMEWORKS = [
"AppKit",
]
COMMON_LINKOPTS_DEBUG = [
]
COMMON_LINKOPTS_RELEASE = [
]
COMMON_LINKOPTS = [
"-framework {}".format(lib) for lib in STANDARD_FRAMEWORKS
] + select({
"@cef//:macos_dbg": COMMON_LINKOPTS_DEBUG,
"//conditions:default": COMMON_LINKOPTS_RELEASE,
})
#
# Common 'copts' for cc_libary, objc_library and macos_application targets.
# We include defines in 'copts' because objc_library does not support
# 'local_defines'. See https://github.com/bazelbuild/bazel/issues/17482.
#
COMMON_COPTS = [
"-Wno-undefined-var-template",
"-Wno-missing-field-initializers",
"-Wno-deprecated-copy",
# Used by apps to test if the sandbox is enabled
"-DCEF_USE_SANDBOX",
]
COMMON_COPTS_DEBUG = [
]
COMMON_COPTS_RELEASE = [
# Not a debug build
"-DNDEBUG",
]

8
bazel/win/BUILD.bazel Normal file
View File

@@ -0,0 +1,8 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
# Allow access from targets in other packages.
package(default_visibility = [
"//visibility:public",
])

33
bazel/win/cc_env.bzl Normal file
View File

@@ -0,0 +1,33 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", _use_cpp_toolchain="use_cpp_toolchain")
load("@rules_cc//cc:action_names.bzl", "CPP_COMPILE_ACTION_NAME")
# Since we need windows.h and other headers, we should ensure we have the same
# development environment as a regular cl.exe call. So use the current toolchain
# to grab environment variables to feed into the actual rc.exe call
# Much of this is taken from:
# https://github.com/bazelbuild/rules_cc/blob/main/examples/my_c_archive/my_c_archive.bzl
def collect_compilation_env(ctx):
cc_toolchain = find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
)
compiler_variables = cc_common.create_compile_variables(
feature_configuration = feature_configuration,
cc_toolchain = cc_toolchain,
)
return cc_common.get_environment_variables(
feature_configuration = feature_configuration,
action_name = CPP_COMPILE_ACTION_NAME,
variables = compiler_variables,
)
use_cpp_toolchain=_use_cpp_toolchain

82
bazel/win/exe_helpers.bzl Normal file
View File

@@ -0,0 +1,82 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
load("//bazel:copy_filegroups.bzl", "copy_filegroups")
load("//bazel/win:mt.bzl", "add_manifest")
load("//bazel/win:rc.bzl", "compile_rc")
load("//bazel/win:variables.bzl",
"COMMON_LINKOPTS",
"COMMON_COPTS", "COMMON_COPTS_RELEASE", "COMMON_COPTS_DEBUG",
"COMMON_DEFINES", "COMMON_DEFINES_RELEASE", "COMMON_DEFINES_DEBUG")
load("@rules_cc//cc:defs.bzl", "cc_binary")
def declare_exe(name, srcs, manifest_srcs, rc_file, resources_srcs, resources_deps=[],
deps=[], linkopts=[], copts=[], local_defines=[], data=[],
additional_linker_inputs=[], features=[], **kwargs):
# Resource file.
res_target = "{}_res".format(name)
compile_rc(
name = res_target,
rc_file = rc_file,
srcs = resources_srcs,
deps = resources_deps,
out = "{}.res".format(name),
target_compatible_with = ["@platforms//os:windows"],
)
# Copy DLLs and resources into the current project.
copy_target = "{}_dlls_and_resources".format(name)
copy_filegroups(
name = copy_target,
filegroups = [
"@cef//:dlls",
"@cef//:resources",
],
remove_prefixes = [
"Debug",
"Release",
"Resources",
],
)
# Executable target.
binary_target = "{}_no_manifest".format(name)
cc_binary(
name = binary_target,
srcs = srcs,
deps = [
"@cef//:cef_wrapper",
"@cef//:cef",
"@cef//:cef_sandbox",
] + deps,
linkopts = [
"$(location :{})".format(res_target),
] + COMMON_LINKOPTS + linkopts,
copts = COMMON_COPTS + select({
"@cef//:windows_dbg": COMMON_COPTS_DEBUG,
"//conditions:default": COMMON_COPTS_RELEASE,
}) + copts,
local_defines = COMMON_DEFINES + select({
"@cef//:windows_dbg": COMMON_DEFINES_DEBUG,
"//conditions:default": COMMON_DEFINES_RELEASE,
}) + local_defines,
additional_linker_inputs = [
":{}".format(res_target),
] + additional_linker_inputs,
data = [
":{}".format(copy_target),
] + data,
features = ["generate_pdb_file"] + features,
target_compatible_with = ["@platforms//os:windows"],
**kwargs
)
# Add manifest and rename to final executable.
add_manifest(
name = name,
mt_files = manifest_srcs,
in_binary = ":{}".format(binary_target),
out_binary = "{}.exe".format(name),
target_compatible_with = ["@platforms//os:windows"],
)

72
bazel/win/mt.bzl Normal file
View File

@@ -0,0 +1,72 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
load("//bazel/win:cc_env.bzl", "collect_compilation_env", "use_cpp_toolchain")
# Copy exe and pdb file without tracking the destination as an output.
# Based on https://github.com/bazelbuild/bazel-skylib/blob/main/rules/private/copy_file_private.bzl
def _write_copy_cmd(ctx, src, dst):
# Most Windows binaries built with MSVC use a certain argument quoting
# scheme. Bazel uses that scheme too to quote arguments. However,
# cmd.exe uses different semantics, so Bazel's quoting is wrong here.
# To fix that we write the command to a .bat file so no command line
# quoting or escaping is required.
bat = ctx.actions.declare_file(ctx.label.name + "-cmd.bat")
src_path = src.path.replace("/", "\\")
dst_path = dst.path.replace("/", "\\")
ctx.actions.write(
output = bat,
# Do not use lib/shell.bzl's shell.quote() method, because that uses
# Bash quoting syntax, which is different from cmd.exe's syntax.
content = "@copy /Y \"%s\" \"%s\" >NUL\n@copy /Y \"%s\" \"%s\" >NUL" % (
src_path,
dst_path,
src_path.replace(".exe", ".pdb"),
dst_path.replace(".exe", ".pdb"),
),
is_executable = True,
)
return bat
def _add_mt_impl(ctx):
mt_files = ctx.files.mt_files
input = ctx.attr.in_binary[DebugPackageInfo].unstripped_file
output = ctx.outputs.out_binary
bat = _write_copy_cmd(ctx, input, output)
inputs = mt_files + [input, bat]
# Bring over 'data' dependencies from the input.
deps_inputs = ctx.runfiles(files = inputs)
deps_inputs = deps_inputs.merge_all([ctx.attr.in_binary[DefaultInfo].default_runfiles])
ctx.actions.run(
executable = ctx.executable._tool,
inputs = deps_inputs.files,
outputs = [output],
env = collect_compilation_env(ctx),
# The bat file will be executed before the tool command.
arguments = [bat.path, "-nologo", "-manifest"] + [f.path for f in mt_files] +
["-outputresource:{}".format(output.path)],
mnemonic = "AddMT"
)
return DefaultInfo(files = depset([output]))
add_manifest = rule(
implementation = _add_mt_impl,
attrs = {
"mt_files": attr.label_list(allow_files = [".manifest"]),
"in_binary": attr.label(providers = [CcInfo], allow_single_file = True),
"out_binary": attr.output(),
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
"_tool": attr.label(
default = "@winsdk//:mt_pybin",
executable = True,
cfg = "exec"
)
},
fragments = ["cpp"],
toolchains = use_cpp_toolchain(),
)

50
bazel/win/rc.bzl Normal file
View File

@@ -0,0 +1,50 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
load("//bazel/win:cc_env.bzl", "collect_compilation_env", "use_cpp_toolchain")
def _compile_rc_impl(ctx):
rc_file = ctx.file.rc_file
output = ctx.outputs.out
inputs = [rc_file] + ctx.files.srcs
includes = ["/i{}/{}".format(ctx.label.package, i) for i in ctx.attr.includes]
# Grab all include paths/files required for the run
for dep in ctx.attr.deps:
comp_ctx = dep[CcInfo].compilation_context
includes += ["/i{}".format(i) for i in comp_ctx.quote_includes.to_list()]
includes += ["/i{}".format(i) for i in comp_ctx.system_includes.to_list()]
inputs += comp_ctx.headers.to_list()
ctx.actions.run(
executable = ctx.executable._tool,
inputs = inputs,
outputs = [output],
env = collect_compilation_env(ctx),
arguments = includes + ["/fo", output.path, rc_file.path],
mnemonic = "CompileRC"
)
return DefaultInfo(files = depset([output]))
compile_rc = rule(
implementation = _compile_rc_impl,
attrs = {
"rc_file": attr.label(allow_single_file = [".rc"]),
"srcs": attr.label_list(allow_files = True),
"deps": attr.label_list(providers = [CcInfo]),
"includes": attr.string_list(),
"out": attr.output(),
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
"_tool": attr.label(
default = "@winsdk//:rc_pybin",
executable = True,
cfg = "exec"
)
},
fragments = ["cpp"],
toolchains = use_cpp_toolchain(),
)

124
bazel/win/setup_sdk.bzl Normal file
View File

@@ -0,0 +1,124 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
load("@bazel_tools//tools/cpp:windows_cc_configure.bzl", "find_vc_path", "setup_vc_env_vars")
def _get_arch(rctx):
if rctx.os.arch == "amd64":
return "x64"
def _is_windows(rctx):
return rctx.os.name.find("windows") != -1
# Tools in the form <Target>: [<Tool>, <Other files needed for that target>]
TOOLS = {
"mt": {
"tool": "mt.exe",
"deps": [],
},
"rc": {
"tool": "rc.exe",
"deps": ["rcdll.dll"],
},
}
def _setup_tools(rctx, sdk_bin_path, sdk_metadata_path):
contents = ""
rctx.symlink(sdk_metadata_path, "VerUnionMetadata")
contents += """
exports_files(["VerUnionMetadata"])
"""
for toolname, toolcfg in TOOLS.items():
toolexec = toolcfg["tool"]
deps = toolcfg["deps"]
direct_deps = [toolexec] + deps
shared_deps = toolcfg.get("shared_deps", [])
# Symlink any tools into the right places
for dep in direct_deps:
rctx.symlink(
"{}/{}".format(sdk_bin_path, dep),
dep,
)
# Setting up a filegroup for those dependents
contents += """
filegroup(
name = "{}_deps",
srcs = {},
)
""".format(toolname, direct_deps + shared_deps)
# Now create a wrapper for this tool that simply calls it
rctx.template(
"{}_wrapper.py".format(toolname),
Label("//bazel/win:wrapper.py.tpl"),
substitutions = {
"${binary}": toolexec,
},
executable = True,
)
# And add that newly created wrapper to the BUILD.bazel file
contents += """
py_binary(
name = "{0}_pybin",
srcs = ["{0}_wrapper.py"],
main = "{0}_wrapper.py",
data = [
"@rules_python//python/runfiles",
":{0}_deps"
],
python_version = "PY3",
)
""".format(toolname)
return contents
def _setup_vc_debug_runtime(rctx, sdk_bin_path):
ucrtbased_dll = "ucrtbased.dll"
rctx.symlink("{}/ucrt/{}".format(sdk_bin_path, ucrtbased_dll), ucrtbased_dll)
contents = """
filegroup(
name = "vc_debug_runtime",
srcs = ["{}"],
)
""".format(ucrtbased_dll)
return contents
def _windows_sdk_impl(rctx):
# We only support Windows
if not _is_windows(rctx):
fail("This rule only supports Windows")
# Figure out where the SDK is, which is based on a registry key.
vc_path = find_vc_path(rctx)
env = setup_vc_env_vars(rctx, vc_path, envvars = ["WINDOWSSDKVERBINPATH", "WindowsSdkDir", "WindowsSDKVersion"])
sdk_bin_path = "{}{}".format(env["WINDOWSSDKVERBINPATH"], _get_arch(rctx))
sdk_metadata_path = "{}UnionMetadata/{}".format(env["WindowsSdkDir"], env["WindowsSDKVersion"])
# Start with some pre-amble
contents = """# Autogenerated by //bazel/win:sdk.bzl
load("@rules_python//python:defs.bzl", "py_binary")
package(default_visibility = ["//visibility:public"])
"""
# Handle setting up tools from our list
contents += _setup_tools(rctx, sdk_bin_path, sdk_metadata_path)
contents += _setup_vc_debug_runtime(rctx, sdk_bin_path)
rctx.file("BUILD.bazel", contents)
setup_sdk = repository_rule(
attrs = {},
local = True,
configure = True,
implementation = _windows_sdk_impl,
)

199
bazel/win/variables.bzl Normal file
View File

@@ -0,0 +1,199 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
#
# Distribution DLLs.
#
# NOTE: libcef.dll is included via the //:cef dependency.
DLLS = [
"chrome_elf.dll",
"d3dcompiler_47.dll",
"libEGL.dll",
"libGLESv2.dll",
"vk_swiftshader.dll",
"vulkan-1.dll",
]
DLLS_X64 = [
"dxil.dll",
"dxcompiler.dll",
]
#
# Common 'linkopts' for cc_binary targets.
#
# Windows delayload DLLs.
# Delayload most libraries as the DLLs are simply not required at startup (or
# at all, depending on the process type). Some dlls open handles when they are
# loaded, and we may not want them to be loaded in renderers or other sandboxed
# processes. Conversely, some DLLs must be loaded before sandbox lockdown. In
# unsandboxed processes they will load when first needed. The linker will
# automatically ignore anything which is not linked to the binary at all (it is
# harmless to have an unmatched /delayload). This list should be kept in sync
# with Chromium's "delayloads" target from the //build/config/win/BUILD.gn file.
DELAYLOAD_DLLS = [
"api-ms-win-core-winrt-error-l1-1-0.dll",
"api-ms-win-core-winrt-l1-1-0.dll",
"api-ms-win-core-winrt-string-l1-1-0.dll",
"advapi32.dll",
"comctl32.dll",
"comdlg32.dll",
"credui.dll",
"cryptui.dll",
"d3d11.dll",
"d3d9.dll",
"dwmapi.dll",
"dxgi.dll",
"dxva2.dll",
"esent.dll",
"gdi32.dll",
"hid.dll",
"imagehlp.dll",
"imm32.dll",
"msi.dll",
"netapi32.dll",
"ncrypt.dll",
"ole32.dll",
"oleacc.dll",
"propsys.dll",
"psapi.dll",
"rpcrt4.dll",
"rstrtmgr.dll",
"setupapi.dll",
"shell32.dll",
"shlwapi.dll",
"uiautomationcore.dll",
"urlmon.dll",
"user32.dll",
"usp10.dll",
"uxtheme.dll",
"wer.dll",
"wevtapi.dll",
"wininet.dll",
"winusb.dll",
"wsock32.dll",
"wtsapi32.dll",
]
# Standard link libraries.
STANDARD_LIBS = [
"comctl32.lib",
"gdi32.lib",
"rpcrt4.lib",
"shlwapi.lib",
"user32.lib",
"ws2_32.lib",
]
# Sandbox link libraries.
SANDBOX_LIBS = [
"Advapi32.lib",
"dbghelp.lib",
"Delayimp.lib",
"ntdll.lib",
"OleAut32.lib",
"PowrProf.lib",
"Propsys.lib",
"psapi.lib",
"SetupAPI.lib",
"Shcore.lib",
"Shell32.lib",
"Userenv.lib",
"version.lib",
"wbemuuid.lib",
"WindowsApp.lib",
"winmm.lib",
]
COMMON_LINKOPTS_DEBUG = [
]
COMMON_LINKOPTS_RELEASE = [
]
COMMON_LINKOPTS = [
# No default manifest (see compile_rc target).
"/MANIFEST:NO",
# Allow 32-bit processes to access 3GB of RAM.
"/LARGEADDRESSAWARE",
# Generate Debug information.
# TODO: Remove after fixing opt builds to work without it.
"/DEBUG",
] + [
"/DELAYLOAD:{}".format(dll) for dll in DELAYLOAD_DLLS
] + [
"/DEFAULTLIB:{}".format(lib) for lib in STANDARD_LIBS
] + select({
# Set the initial stack size to 0.5MiB, instead of the 1.5MiB minimum
# needed by CEF's main thread. This saves significant memory on threads
# (like those in the Windows thread pool, and others) whose stack size we
# can only control through this setting. The main thread (in 32-bit builds
# only) uses fibers to switch to a 4MiB stack at runtime via
# CefRunWinMainWithPreferredStackSize().
"@cef//:windows_32": ["/STACK:0x80000"],
# Increase the initial stack size to 8MiB from the default 1MiB.
"//conditions:default": ["/STACK:0x800000"],
}) + select({
"@cef//:windows_dbg": COMMON_LINKOPTS_DEBUG,
"//conditions:default": COMMON_LINKOPTS_RELEASE,
})
#
# Common 'copts' for cc_libary and cc_binary targets.
#
COMMON_COPTS = [
]
COMMON_COPTS_DEBUG = [
]
COMMON_COPTS_RELEASE = [
]
#
# Common 'defines' for cc_libary targets.
#
COMMON_DEFINES = [
# Windows platform
"WIN32",
"_WIN32",
"_WINDOWS",
# Unicode build
"UNICODE",
"_UNICODE",
# Targeting Windows 10. We can't say `=_WIN32_WINNT_WIN10` here because
# some files do `#if WINVER < 0x0600` without including windows.h before,
# and then _WIN32_WINNT_WIN10 isn't yet known to be 0x0A00.
"WINVER=0x0A00",
"_WIN32_WINNT=0x0A00",
"NTDDI_VERSION=NTDDI_WIN10_FE",
# Use the standard's templated min/max
"NOMINMAX",
# Exclude less common API declarations
"WIN32_LEAN_AND_MEAN",
# Disable exceptions
"_HAS_EXCEPTIONS=0",
# Required by cef_sandbox.lib
"PSAPI_VERSION=1",
# Used by apps to test if the sandbox is enabled
"CEF_USE_SANDBOX",
]
COMMON_DEFINES_DEBUG = [
# Required by cef_sandbox.lib
# Disable iterator debugging
"HAS_ITERATOR_DEBUGGING=0",
"_ITERATOR_DEBUG_LEVEL=0",
]
COMMON_DEFINES_RELEASE = [
# Not a debug build
"NDEBUG",
"_NDEBUG",
]

69
bazel/win/wrapper.py.tpl Normal file
View File

@@ -0,0 +1,69 @@
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
import os
import subprocess
import sys
from rules_python.python.runfiles import runfiles
REPLACEMENTS = {
"XXX_GETCWD_XXX": os.getcwd(),
}
def replace_in_str(input):
output = input
for placeholder, replacement in REPLACEMENTS.items():
if placeholder in output:
output = output.replace(placeholder, replacement)
return output
def print_error(str):
print(str, file=sys.stderr)
r = runfiles.Create()
wrapped_binary = r.Rlocation("winsdk/${binary}")
args = list(map(replace_in_str, sys.argv[1:]))
# Optionally execute a script before tool execution.
if args[0].endswith('.bat') or args[0].endswith('.cmd'):
if sys.platform != 'win32':
raise RuntimeError("Error running bat file; unsupported platform")
# Execute the .bat file first.
bat_file = args[0].replace('/', '\\')
p = subprocess.run(
bat_file, shell=True,
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT,
text=True)
if p.returncode != 0:
print_error("[Generated python wrapper] Error running bat file:")
print_error(f"CWD: {os.getcwd()}")
print_error(f"EXEC: {bat_file}")
print_error(f"Exec output:")
print_error(p.stdout)
raise RuntimeError(f"Error running bat file; {bat_file}")
args = args[1:]
try:
p = subprocess.run(
[wrapped_binary] + args,
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT,
text=True)
if p.returncode != 0:
print_error("[Generated python wrapper] Error running command:")
print_error(f"CWD: {os.getcwd()}")
print_error(f"EXEC: {wrapped_binary}")
print_error(f"ARGS: {args}")
print_error(f"Exec output:")
print_error(p.stdout)
raise RuntimeError(f"Error running wrapped command; {wrapped_binary}")
except OSError as e:
print_error("[Generated python wrapper] Error running command:")
print_error(f"CWD: {os.getcwd()}")
print_error(f"EXEC: {wrapped_binary}")
print_error(f"ARGS: {args}")
raise

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=3b28f3236c16d2b776a44674ae3bae0a070e9f27$
# $hash=e092ed49124ef5969b2052fd6ae5f6e6d89390ba$
#
{
@@ -35,8 +35,6 @@
'include/cef_download_item.h',
'include/cef_drag_data.h',
'include/cef_drag_handler.h',
'include/cef_extension.h',
'include/cef_extension_handler.h',
'include/cef_file_util.h',
'include/cef_find_handler.h',
'include/cef_focus_handler.h',
@@ -83,6 +81,7 @@
'include/cef_stream.h',
'include/cef_string_visitor.h',
'include/cef_task.h',
'include/cef_task_manager.h',
'include/cef_thread.h',
'include/cef_trace.h',
'include/cef_unresponsive_process_callback.h',
@@ -140,8 +139,6 @@
'include/capi/cef_download_item_capi.h',
'include/capi/cef_drag_data_capi.h',
'include/capi/cef_drag_handler_capi.h',
'include/capi/cef_extension_capi.h',
'include/capi/cef_extension_handler_capi.h',
'include/capi/cef_file_util_capi.h',
'include/capi/cef_find_handler_capi.h',
'include/capi/cef_focus_handler_capi.h',
@@ -188,6 +185,7 @@
'include/capi/cef_stream_capi.h',
'include/capi/cef_string_visitor_capi.h',
'include/capi/cef_task_capi.h',
'include/capi/cef_task_manager_capi.h',
'include/capi/cef_thread_capi.h',
'include/capi/cef_trace_capi.h',
'include/capi/cef_unresponsive_process_callback_capi.h',
@@ -304,10 +302,6 @@
'libcef_dll/ctocpp/drag_handler_ctocpp.h',
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.cc',
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.h',
'libcef_dll/cpptoc/extension_cpptoc.cc',
'libcef_dll/cpptoc/extension_cpptoc.h',
'libcef_dll/ctocpp/extension_handler_ctocpp.cc',
'libcef_dll/ctocpp/extension_handler_ctocpp.h',
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc',
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.h',
'libcef_dll/cpptoc/views/fill_layout_cpptoc.cc',
@@ -320,8 +314,6 @@
'libcef_dll/cpptoc/frame_cpptoc.h',
'libcef_dll/ctocpp/frame_handler_ctocpp.cc',
'libcef_dll/ctocpp/frame_handler_ctocpp.h',
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.cc',
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h',
'libcef_dll/cpptoc/image_cpptoc.cc',
'libcef_dll/cpptoc/image_cpptoc.h',
'libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc',
@@ -470,6 +462,8 @@
'libcef_dll/ctocpp/string_visitor_ctocpp.h',
'libcef_dll/ctocpp/task_ctocpp.cc',
'libcef_dll/ctocpp/task_ctocpp.h',
'libcef_dll/cpptoc/task_manager_cpptoc.cc',
'libcef_dll/cpptoc/task_manager_cpptoc.h',
'libcef_dll/cpptoc/task_runner_cpptoc.cc',
'libcef_dll/cpptoc/task_runner_cpptoc.h',
'libcef_dll/cpptoc/test/test_server_cpptoc.cc',
@@ -634,10 +628,6 @@
'libcef_dll/cpptoc/drag_handler_cpptoc.h',
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.cc',
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.h',
'libcef_dll/ctocpp/extension_ctocpp.cc',
'libcef_dll/ctocpp/extension_ctocpp.h',
'libcef_dll/cpptoc/extension_handler_cpptoc.cc',
'libcef_dll/cpptoc/extension_handler_cpptoc.h',
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc',
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.h',
'libcef_dll/ctocpp/views/fill_layout_ctocpp.cc',
@@ -650,8 +640,6 @@
'libcef_dll/ctocpp/frame_ctocpp.h',
'libcef_dll/cpptoc/frame_handler_cpptoc.cc',
'libcef_dll/cpptoc/frame_handler_cpptoc.h',
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.cc',
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h',
'libcef_dll/ctocpp/image_ctocpp.cc',
'libcef_dll/ctocpp/image_ctocpp.h',
'libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc',
@@ -800,6 +788,8 @@
'libcef_dll/cpptoc/string_visitor_cpptoc.h',
'libcef_dll/cpptoc/task_cpptoc.cc',
'libcef_dll/cpptoc/task_cpptoc.h',
'libcef_dll/ctocpp/task_manager_ctocpp.cc',
'libcef_dll/ctocpp/task_manager_ctocpp.h',
'libcef_dll/ctocpp/task_runner_ctocpp.cc',
'libcef_dll/ctocpp/task_runner_ctocpp.h',
'libcef_dll/ctocpp/test/test_server_ctocpp.cc',

View File

@@ -16,6 +16,7 @@
'include/base/cef_callback_list.h',
'include/base/cef_cancelable_callback.h',
'include/base/cef_compiler_specific.h',
'include/base/cef_dump_without_crashing.h',
'include/base/cef_lock.h',
'include/base/cef_logging.h',
'include/base/cef_macros.h',
@@ -43,6 +44,7 @@
'include/internal/cef_types_wrappers.h',
],
'includes_common_capi': [
'include/internal/cef_dump_without_crashing_internal.h',
'include/internal/cef_logging_internal.h',
'include/internal/cef_string.h',
'include/internal/cef_string_list.h',
@@ -123,6 +125,7 @@
'libcef_dll/base/cef_atomic_flag.cc',
'libcef_dll/base/cef_callback_helpers.cc',
'libcef_dll/base/cef_callback_internal.cc',
'libcef_dll/base/cef_dump_without_crashing.cc',
'libcef_dll/base/cef_lock.cc',
'libcef_dll/base/cef_lock_impl.cc',
'libcef_dll/base/cef_logging.cc',
@@ -242,6 +245,7 @@
'tests/cefclient/browser/client_prefs.cc',
'tests/cefclient/browser/client_prefs.h',
'tests/cefclient/browser/client_types.h',
'tests/cefclient/browser/default_client_handler.cc',
'tests/cefclient/browser/default_client_handler.h',
'tests/cefclient/browser/dialog_test.cc',
'tests/cefclient/browser/dialog_test.h',
@@ -275,6 +279,8 @@
'tests/cefclient/browser/scheme_test.h',
'tests/cefclient/browser/server_test.cc',
'tests/cefclient/browser/server_test.h',
'tests/cefclient/browser/task_manager_test.cc',
'tests/cefclient/browser/task_manager_test.h',
'tests/cefclient/browser/temp_window.h',
'tests/cefclient/browser/test_runner.cc',
'tests/cefclient/browser/test_runner.h',
@@ -282,6 +288,8 @@
'tests/cefclient/browser/urlrequest_test.h',
'tests/cefclient/browser/views_menu_bar.cc',
'tests/cefclient/browser/views_menu_bar.h',
'tests/cefclient/browser/views_overlay_browser.cc',
'tests/cefclient/browser/views_overlay_browser.h',
'tests/cefclient/browser/views_overlay_controls.cc',
'tests/cefclient/browser/views_overlay_controls.h',
'tests/cefclient/browser/views_style.cc',
@@ -329,6 +337,7 @@
'tests/cefclient/resources/preferences.html',
'tests/cefclient/resources/response_filter.html',
'tests/cefclient/resources/server.html',
'tests/cefclient/resources/task_manager.html',
'tests/cefclient/resources/transparency.html',
'tests/cefclient/resources/urlrequest.html',
'tests/cefclient/resources/websocket.html',
@@ -370,12 +379,14 @@
'tests/cefclient/browser/window_test_runner_win.cc',
'tests/cefclient/browser/window_test_runner_win.h',
'tests/cefclient/cefclient_win.cc',
'tests/cefclient/resources/win/cefclient.rc',
],
'cefclient_sources_resources_win': [
'tests/cefclient/resources/win/cefclient.exe.manifest',
'tests/cefclient/resources/win/cefclient.ico',
'tests/cefclient/resources/win/small.ico',
'tests/cefclient/win/cefclient.exe.manifest',
'tests/cefclient/win/cefclient.ico',
'tests/cefclient/win/small.ico',
],
'cefclient_sources_resources_win_rc': [
'tests/cefclient/win/cefclient.rc',
],
'cefclient_sources_mac': [
'tests/cefclient/browser/browser_window_osr_mac.h',
@@ -398,12 +409,12 @@
'tests/cefclient/browser/window_test_runner_mac.h',
'tests/cefclient/browser/window_test_runner_mac.mm',
'tests/cefclient/cefclient_mac.mm',
],
],
'cefclient_bundle_resources_mac': [
'tests/cefclient/resources/mac/cefclient.icns',
'tests/cefclient/resources/mac/English.lproj/InfoPlist.strings',
'tests/cefclient/resources/mac/English.lproj/MainMenu.xib',
'tests/cefclient/resources/mac/Info.plist',
'tests/cefclient/mac/cefclient.icns',
'tests/cefclient/mac/English.lproj/InfoPlist.strings',
'tests/cefclient/mac/English.lproj/MainMenu.xib',
'tests/cefclient/mac/Info.plist.in',
],
'cefclient_sources_linux': [
'tests/cefclient/browser/browser_window_osr_gtk.cc',
@@ -435,15 +446,17 @@
'tests/cefsimple/simple_handler.h',
],
'cefsimple_sources_win': [
'tests/cefsimple/cefsimple.rc',
'tests/cefsimple/cefsimple_win.cc',
'tests/cefsimple/simple_handler_win.cc',
'tests/cefsimple/resource.h',
'tests/cefsimple/simple_handler_win.cc',
],
'cefsimple_sources_resources_win': [
'tests/cefsimple/cefsimple.exe.manifest',
'tests/cefsimple/res/cefsimple.ico',
'tests/cefsimple/res/small.ico',
'tests/cefsimple/win/cefsimple.exe.manifest',
'tests/cefsimple/win/cefsimple.ico',
'tests/cefsimple/win/small.ico',
],
'cefsimple_sources_resources_win_rc': [
'tests/cefsimple/win/cefsimple.rc',
],
'cefsimple_sources_mac': [
'tests/cefsimple/cefsimple_mac.mm',
@@ -456,7 +469,7 @@
'tests/cefsimple/mac/cefsimple.icns',
'tests/cefsimple/mac/English.lproj/InfoPlist.strings',
'tests/cefsimple/mac/English.lproj/MainMenu.xib',
'tests/cefsimple/mac/Info.plist',
'tests/cefsimple/mac/Info.plist.in',
],
'cefsimple_sources_linux': [
'tests/cefsimple/cefsimple_linux.cc',
@@ -574,24 +587,32 @@
'ceftests_sources_win': [
'tests/ceftests/resource_util_win_dir.cc',
'tests/ceftests/resource_util_win_idmap.cc',
'tests/ceftests/resources/win/ceftests.rc',
],
'ceftests_sources_resources_win': [
'tests/ceftests/resources/win/ceftests.exe.manifest',
'tests/ceftests/resources/win/ceftests.ico',
'tests/ceftests/resources/win/small.ico',
'tests/ceftests/win/ceftests.exe.manifest',
'tests/ceftests/win/ceftests.ico',
'tests/ceftests/win/small.ico',
],
'ceftests_sources_resources_win_rc': [
'tests/ceftests/win/ceftests.rc',
],
'ceftests_sources_mac': [
'tests/ceftests/os_rendering_unittest_mac.h',
'tests/ceftests/os_rendering_unittest_mac.mm',
'tests/ceftests/run_all_unittests_mac.mm',
],
'ceftests_sources_mac_helper': [
'ceftests_sources_mac_browser_shared': [
'tests/shared/renderer/client_app_renderer.h',
],
'ceftests_sources_mac_helper_shared': [
'tests/shared/browser/client_app_browser.h',
'tests/shared/browser/file_util.cc',
'tests/shared/browser/file_util.h',
'tests/shared/browser/resource_util.h',
'tests/shared/browser/resource_util_mac.mm',
'tests/shared/browser/resource_util_posix.cc',
],
'ceftests_sources_mac_helper': [
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/client_app_delegates.cc',
'tests/ceftests/cookie_unittest.cc',
@@ -647,10 +668,10 @@
'tests/ceftests/v8_unittest.cc',
],
'ceftests_bundle_resources_mac': [
'tests/ceftests/resources/mac/ceftests.icns',
'tests/ceftests/resources/mac/English.lproj/InfoPlist.strings',
'tests/ceftests/resources/mac/English.lproj/MainMenu.xib',
'tests/ceftests/resources/mac/Info.plist',
'tests/ceftests/mac/ceftests.icns',
'tests/ceftests/mac/English.lproj/InfoPlist.strings',
'tests/ceftests/mac/English.lproj/MainMenu.xib',
'tests/ceftests/mac/Info.plist.in',
],
'ceftests_sources_linux': [
'tests/ceftests/resource_util_linux.cc',

View File

@@ -59,7 +59,7 @@ set(CEF_LIBCEF_DLL_WRAPPER_PATH "${_CEF_ROOT}/libcef_dll")
# Shared compiler/linker flags.
list(APPEND CEF_COMPILER_DEFINES
# Allow C++ programs to use stdint.h macros specified in the C99 standard that aren't
# Allow C++ programs to use stdint.h macros specified in the C99 standard that aren't
# in the C++ standard (e.g. UINT8_MAX, INT64_MIN, etc)
__STDC_CONSTANT_MACROS __STDC_FORMAT_MACROS
)
@@ -311,7 +311,7 @@ if(OS_MAC)
# Find the newest available base SDK.
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
foreach(OS_VERSION 14.2 14.0 10.15)
foreach(OS_VERSION 14.2 14.0 11.0)
set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk")
if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}")
set(CMAKE_OSX_SYSROOT ${SDK})
@@ -319,7 +319,7 @@ if(OS_MAC)
endforeach()
# Target SDK.
set(CEF_TARGET_SDK "10.15")
set(CEF_TARGET_SDK "11.0")
list(APPEND CEF_COMPILER_FLAGS
-mmacosx-version-min=${CEF_TARGET_SDK}
)

View File

@@ -84,10 +84,6 @@
#endif
#endif
#if !BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
#define DISABLE_ALLOY_BOOTSTRAP 1
#endif
#else // !USING_CHROMIUM_INCLUDES
#include "include/cef_config.h"

View File

@@ -0,0 +1,76 @@
// Copyright (c) 2024 Marshall A. Greenblatt. Portions copyright (c) 2012
// Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
///
/// \file
/// Provides functions for generating crash dumps.
///
/// NOTE: The contents of this file are only available to applications that link
/// against the libcef_dll_wrapper target.
///
/// NOTE: Ensure crash reporting is configured before use. See
/// https://bitbucket.org/chromiumembedded/cef/wiki/CrashReporting.md for more
/// information
///
/// WARNING: Crash reporting should not be used in the main/browser process
/// before calling CefInitialize or in sub-processes before CefExecuteProcess.
///
#ifndef CEF_INCLUDE_BASE_CEF_DUMP_WITHOUT_CRASHING_H_
#define CEF_INCLUDE_BASE_CEF_DUMP_WITHOUT_CRASHING_H_
#pragma once
constexpr long long kOneDayInMilliseconds = 86400000;
///
/// CefDumpWithoutCrashing allows for generating 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
/// |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.
///
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());
///
/// CefDumpWithoutCrashingUnthrottled allows for immediate crash dumping without
/// any throttling constraints.
///
/// Returns true if the dump was successfully generated, false otherwise.
///
bool CefDumpWithoutCrashingUnthrottled();
#endif // CEF_INCLUDE_BASE_CEF_DUMP_WITHOUT_CRASHING_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=dfa0d4d2da319b2fd5e92324fd14301b500ceb5c$
// $hash=608f4520d7901b6e18bf9164c9460f1b75bad8f4$
//
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
@@ -91,11 +91,9 @@ typedef struct _cef_app_t {
struct _cef_scheme_registrar_t* registrar);
///
/// Return the handler for resource bundle events. If
/// cef_settings_t.pack_loading_disabled is true (1) a handler must be
/// returned. If no handler is returned resources will be loaded from pack
/// files. This function is called by the browser and render processes on
/// multiple threads.
/// Return the handler for resource bundle events. If no handler is returned
/// resources will be loaded from pack files. This function is called by the
/// browser and render processes on multiple threads.
///
struct _cef_resource_bundle_handler_t*(
CEF_CALLBACK* get_resource_bundle_handler)(struct _cef_app_t* self);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=6ee74f31d37a1b5ab3c9c5ccbe2dce9841329b38$
// $hash=e9f34d90eb4af614e35cbb29da0639b62acec7fd$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
@@ -301,29 +301,62 @@ typedef struct _cef_browser_host_t {
struct _cef_browser_host_t* self);
///
/// Request that the browser close. The JavaScript 'onbeforeunload' event will
/// be fired. If |force_close| is false (0) the event handler, if any, will be
/// allowed to prompt the user and the user can optionally cancel the close.
/// If |force_close| is true (1) the prompt will not be displayed and the
/// close will proceed. Results in a call to
/// cef_life_span_handler_t::do_close() if the event handler allows the close
/// or if |force_close| is true (1). See cef_life_span_handler_t::do_close()
/// documentation for additional usage information.
/// Request that the browser close. Closing a browser is a multi-stage process
/// that may complete either synchronously or asynchronously, and involves
/// callbacks such as cef_life_span_handler_t::DoClose (Alloy style only),
/// cef_life_span_handler_t::OnBeforeClose, and a top-level window close
/// handler such as cef_window_delegate_t::CanClose (or platform-specific
/// equivalent). In some cases a close request may be delayed or canceled by
/// the user. Using try_close_browser() instead of close_browser() is
/// recommended for most use cases. See cef_life_span_handler_t::do_close()
/// documentation for detailed usage and examples.
///
/// If |force_close| is false (0) then JavaScript unload handlers, if any, may
/// be fired and the close may be delayed or canceled by the user. If
/// |force_close| is true (1) then the user will not be prompted and the close
/// will proceed immediately (possibly asynchronously). If browser close is
/// delayed and not canceled the default behavior is to call the top-level
/// window close handler once the browser is ready to be closed. This default
/// behavior can be changed for Alloy style browsers by implementing
/// cef_life_span_handler_t::do_close(). is_ready_to_be_closed() can be used
/// to detect mandatory browser close events when customizing close behavior
/// on the browser process UI thread.
///
void(CEF_CALLBACK* close_browser)(struct _cef_browser_host_t* self,
int force_close);
///
/// Helper for closing a browser. Call this function from the top-level window
/// close handler (if any). Internally this calls CloseBrowser(false (0)) if
/// the close has not yet been initiated. This function returns false (0)
/// while the close is pending and true (1) after the close has completed. See
/// close_browser() and cef_life_span_handler_t::do_close() documentation for
/// additional usage information. This function must be called on the browser
/// process UI thread.
/// Helper for closing a browser. This is similar in behavior to
/// CLoseBrowser(false (0)) but returns a boolean to reflect the immediate
/// close status. Call this function from a top-level window close handler
/// such as cef_window_delegate_t::CanClose (or platform-specific equivalent)
/// to request that the browser close, and return the result to indicate if
/// the window close should proceed. Returns false (0) if the close will be
/// delayed (JavaScript unload handlers triggered but still pending) or true
/// (1) if the close will proceed immediately (possibly asynchronously). See
/// close_browser() documentation for additional usage information. This
/// function must be called on the browser process UI thread.
///
int(CEF_CALLBACK* try_close_browser)(struct _cef_browser_host_t* self);
///
/// Returns true (1) if the browser is ready to be closed, meaning that the
/// close has already been initiated and that JavaScript unload handlers have
/// already executed or should be ignored. This can be used from a top-level
/// window close handler such as cef_window_delegate_t::CanClose (or platform-
/// specific equivalent) to distringuish between potentially cancelable
/// browser close events (like the user clicking the top-level window close
/// button before browser close has started) and mandatory browser close
/// events (like JavaScript `window.close()` or after browser close has
/// started in response to [Try]close_browser()). Not completing the browser
/// close for mandatory close events (when this function returns true (1))
/// will leave the browser in a partially closed state that interferes with
/// proper functioning. See close_browser() documentation for additional usage
/// information. This function must be called on the browser process UI
/// thread.
///
int(CEF_CALLBACK* is_ready_to_be_closed)(struct _cef_browser_host_t* self);
///
/// Set whether the browser is focused.
///
@@ -381,8 +414,7 @@ typedef struct _cef_browser_host_t {
///
/// Get the default zoom level. This value will be 0.0 by default but can be
/// configured with the Chrome runtime. This function can only be called on
/// the UI thread.
/// configured. This function can only be called on the UI thread.
///
double(CEF_CALLBACK* get_default_zoom_level)(
struct _cef_browser_host_t* self);
@@ -907,24 +939,6 @@ typedef struct _cef_browser_host_t {
const cef_size_t* min_size,
const cef_size_t* max_size);
///
/// Returns the extension hosted in this browser or NULL if no extension is
/// hosted. See cef_request_context_t::LoadExtension for details.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
struct _cef_browser_host_t* self);
///
/// Returns true (1) if this browser is hosting an extension background
/// script. Background hosts do not have a window and are not displayable. See
/// cef_request_context_t::LoadExtension for details.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
int(CEF_CALLBACK* is_background_host)(struct _cef_browser_host_t* self);
///
/// Set whether the browser's audio is muted.
///
@@ -948,12 +962,12 @@ typedef struct _cef_browser_host_t {
///
/// Requests the renderer to exit browser fullscreen. In most cases exiting
/// window fullscreen should also exit browser fullscreen. With the Alloy
/// runtime this function should be called in response to a user action such
/// as clicking the green traffic light button on MacOS
/// window fullscreen should also exit browser fullscreen. With Alloy style
/// this function should be called in response to a user action such as
/// clicking the green traffic light button on MacOS
/// (cef_window_delegate_t::OnWindowFullscreenTransition callback) or pressing
/// the "ESC" key (cef_keyboard_handler_t::OnPreKeyEvent callback). With the
/// Chrome runtime these standard exit actions are handled internally but
/// the "ESC" key (cef_keyboard_handler_t::OnPreKeyEvent callback). With
/// Chrome style these standard exit actions are handled internally but
/// new/additional user actions can use this function. Set |will_cause_resize|
/// to true (1) if exiting browser fullscreen will cause a view resize.
///
@@ -963,7 +977,7 @@ typedef struct _cef_browser_host_t {
///
/// Returns true (1) if a Chrome command is supported and enabled. Values for
/// |command_id| can be found in the cef_command_ids.h file. This function can
/// only be called on the UI thread. Only used with the Chrome runtime.
/// only be called on the UI thread. Only used with Chrome style.
///
int(CEF_CALLBACK* can_execute_chrome_command)(
struct _cef_browser_host_t* self,
@@ -972,7 +986,7 @@ typedef struct _cef_browser_host_t {
///
/// Execute a Chrome command. Values for |command_id| can be found in the
/// cef_command_ids.h file. |disposition| provides information about the
/// intended command target. Only used with the Chrome runtime.
/// intended command target. Only used with Chrome style.
///
void(CEF_CALLBACK* execute_chrome_command)(
struct _cef_browser_host_t* self,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=d958d5bed7f909f6313facef3440fb8ba07a5c01$
// $hash=56ad161a75ca5083812e11959053abbcafbb9a5d$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
@@ -69,8 +69,8 @@ typedef struct _cef_browser_process_handler_t {
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
/// accessed via cef_preference_manager_t::GetGlobalPreferences after
/// OnContextInitialized is called. Global preferences are registered a single
/// time at application startup. See related cef_settings_t.cache_path and
/// cef_settings_t.persist_user_preferences configuration.
/// time at application startup. See related cef_settings_t.cache_path
/// configuration.
///
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
/// accessed via the cef_request_context_t after
@@ -78,8 +78,7 @@ typedef struct _cef_browser_process_handler_t {
/// Request context preferences are registered each time a new
/// cef_request_context_t is created. It is intended but not required that all
/// request contexts have the same registered preferences. See related
/// cef_request_context_settings_t.cache_path and
/// cef_request_context_settings_t.persist_user_preferences configuration.
/// cef_request_context_settings_t.cache_path configuration.
///
/// Do not keep a reference to the |registrar| object. This function is called
/// on the browser process UI thread.
@@ -152,8 +151,8 @@ typedef struct _cef_browser_process_handler_t {
/// (cef_browser_t object). If null is returned the cef_browser_t will be
/// unmanaged (no callbacks will be executed for that cef_browser_t) and
/// application shutdown will be blocked until the browser window is closed
/// manually. This function is currently only used with the Chrome runtime
/// when creating new browser windows via Chrome UI.
/// manually. This function is currently only used with Chrome style when
/// creating new browser windows via Chrome UI.
///
struct _cef_client_t*(CEF_CALLBACK* get_default_client)(
struct _cef_browser_process_handler_t* self);
@@ -162,8 +161,8 @@ typedef struct _cef_browser_process_handler_t {
/// Return the default handler for use with a new user or incognito profile
/// (cef_request_context_t object). If null is returned the
/// cef_request_context_t will be unmanaged (no callbacks will be executed for
/// that cef_request_context_t). This function is currently only used with the
/// Chrome runtime when creating new browser windows via Chrome UI.
/// that cef_request_context_t). This function is currently only used with
/// Chrome style when creating new browser windows via Chrome UI.
///
struct _cef_request_context_handler_t*(
CEF_CALLBACK* get_default_request_context_handler)(

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=dd183a473b1e8c5ee8bdcf99949fc5274c4cc892$
// $hash=9c7d613d1256bd6353f5102ece5a04e572f20627$
//
#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_HANDLER_CAPI_H_
@@ -64,7 +64,7 @@ typedef struct _cef_command_handler_t {
/// intended command target. Return true (1) if the command was handled or
/// false (0) for the default implementation. For context menu commands this
/// will be called after cef_context_menu_handler_t::OnContextMenuCommand.
/// Only used with the Chrome runtime.
/// Only used with Chrome style.
///
int(CEF_CALLBACK* on_chrome_command)(
struct _cef_command_handler_t* self,
@@ -75,8 +75,7 @@ typedef struct _cef_command_handler_t {
///
/// Called to check if a Chrome app menu item should be visible. Values for
/// |command_id| can be found in the cef_command_ids.h file. Only called for
/// menu items that would be visible by default. Only used with the Chrome
/// runtime.
/// menu items that would be visible by default. Only used with Chrome style.
///
int(CEF_CALLBACK* is_chrome_app_menu_item_visible)(
struct _cef_command_handler_t* self,
@@ -86,8 +85,7 @@ typedef struct _cef_command_handler_t {
///
/// Called to check if a Chrome app menu item should be enabled. Values for
/// |command_id| can be found in the cef_command_ids.h file. Only called for
/// menu items that would be enabled by default. Only used with the Chrome
/// runtime.
/// menu items that would be enabled by default. Only used with Chrome style.
///
int(CEF_CALLBACK* is_chrome_app_menu_item_enabled)(
struct _cef_command_handler_t* self,
@@ -97,7 +95,7 @@ typedef struct _cef_command_handler_t {
///
/// Called during browser creation to check if a Chrome page action icon
/// should be visible. Only called for icons that would be visible by default.
/// Only used with the Chrome runtime.
/// Only used with Chrome style.
///
int(CEF_CALLBACK* is_chrome_page_action_icon_visible)(
struct _cef_command_handler_t* self,
@@ -106,7 +104,7 @@ typedef struct _cef_command_handler_t {
///
/// Called during browser creation to check if a Chrome toolbar button should
/// be visible. Only called for buttons that would be visible by default. Only
/// used with the Chrome runtime.
/// used with Chrome style.
///
int(CEF_CALLBACK* is_chrome_toolbar_button_visible)(
struct _cef_command_handler_t* self,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=5a99c5e88ea0e123087234b2795fa625fed183f2$
// $hash=b42d9e5a03f6ef5444e8037b8dc4de08ee6b0834$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
@@ -84,13 +84,12 @@ typedef struct _cef_display_handler_t {
/// Called when web content in the page has toggled fullscreen mode. If
/// |fullscreen| is true (1) the content will automatically be sized to fill
/// the browser content area. If |fullscreen| is false (0) the content will
/// automatically return to its original size and position. With the Alloy
/// runtime the client is responsible for triggering the fullscreen transition
/// (for example, by calling cef_window_t::SetFullscreen when using Views).
/// With the Chrome runtime the fullscreen transition will be triggered
/// automatically. The cef_window_delegate_t::OnWindowFullscreenTransition
/// function will be called during the fullscreen transition for notification
/// purposes.
/// automatically return to its original size and position. With Alloy style
/// the client is responsible for triggering the fullscreen transition (for
/// example, by calling cef_window_t::SetFullscreen when using Views). With
/// Chrome style the fullscreen transition will be triggered automatically.
/// The cef_window_delegate_t::OnWindowFullscreenTransition function will be
/// called during the fullscreen transition for notification purposes.
///
void(CEF_CALLBACK* on_fullscreen_mode_change)(
struct _cef_display_handler_t* self,

View File

@@ -1,132 +0,0 @@
// Copyright (c) 2024 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=634054ad25154c30fb4ec630fe7fb79b0cf1f9b3$
//
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_extension_handler_t;
struct _cef_request_context_t;
///
/// Object representing an extension. Methods may be called on any thread unless
/// otherwise indicated.
///
/// WARNING: This API is deprecated and will be removed in ~M127.
///
typedef struct _cef_extension_t {
///
/// Base structure.
///
cef_base_ref_counted_t base;
///
/// Returns the unique extension identifier. This is calculated based on the
/// extension public key, if available, or on the extension path. See
/// https://developer.chrome.com/extensions/manifest/key for details.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_identifier)(
struct _cef_extension_t* self);
///
/// Returns the absolute path to the extension directory on disk. This value
/// will be prefixed with PK_DIR_RESOURCES if a relative path was passed to
/// cef_request_context_t::LoadExtension.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_path)(struct _cef_extension_t* self);
///
/// Returns the extension manifest contents as a cef_dictionary_value_t
/// object. See https://developer.chrome.com/extensions/manifest for details.
///
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_manifest)(
struct _cef_extension_t* self);
///
/// Returns true (1) if this object is the same extension as |that| object.
/// Extensions are considered the same if identifier, path and loader context
/// match.
///
int(CEF_CALLBACK* is_same)(struct _cef_extension_t* self,
struct _cef_extension_t* that);
///
/// Returns the handler for this extension. Will return NULL for internal
/// extensions or if no handler was passed to
/// cef_request_context_t::LoadExtension.
///
struct _cef_extension_handler_t*(CEF_CALLBACK* get_handler)(
struct _cef_extension_t* self);
///
/// Returns the request context that loaded this extension. Will return NULL
/// for internal extensions or if the extension has been unloaded. See the
/// cef_request_context_t::LoadExtension documentation for more information
/// about loader contexts. Must be called on the browser process UI thread.
///
struct _cef_request_context_t*(CEF_CALLBACK* get_loader_context)(
struct _cef_extension_t* self);
///
/// Returns true (1) if this extension is currently loaded. Must be called on
/// the browser process UI thread.
///
int(CEF_CALLBACK* is_loaded)(struct _cef_extension_t* self);
///
/// Unload this extension if it is not an internal extension and is currently
/// loaded. Will result in a call to
/// cef_extension_handler_t::OnExtensionUnloaded on success.
///
void(CEF_CALLBACK* unload)(struct _cef_extension_t* self);
} cef_extension_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_

View File

@@ -1,214 +0,0 @@
// Copyright (c) 2024 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=ebac34c9b85de780ce7524211c5dd61a80d4576c$
//
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_stream_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_client_t;
///
/// Callback structure used for asynchronous continuation of
/// cef_extension_handler_t::GetExtensionResource.
///
typedef struct _cef_get_extension_resource_callback_t {
///
/// Base structure.
///
cef_base_ref_counted_t base;
///
/// Continue the request. Read the resource contents from |stream|.
///
void(CEF_CALLBACK* cont)(struct _cef_get_extension_resource_callback_t* self,
struct _cef_stream_reader_t* stream);
///
/// Cancel the request.
///
void(CEF_CALLBACK* cancel)(
struct _cef_get_extension_resource_callback_t* self);
} cef_get_extension_resource_callback_t;
///
/// Implement this structure to handle events related to browser extensions. The
/// functions of this structure will be called on the UI thread. See
/// cef_request_context_t::LoadExtension for information about extension
/// loading.
///
/// WARNING: This API is deprecated and will be removed in ~M127.
///
typedef struct _cef_extension_handler_t {
///
/// Base structure.
///
cef_base_ref_counted_t base;
///
/// Called if the cef_request_context_t::LoadExtension request fails. |result|
/// will be the error code.
///
void(CEF_CALLBACK* on_extension_load_failed)(
struct _cef_extension_handler_t* self,
cef_errorcode_t result);
///
/// Called if the cef_request_context_t::LoadExtension request succeeds.
/// |extension| is the loaded extension.
///
void(CEF_CALLBACK* on_extension_loaded)(struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension);
///
/// Called after the cef_extension_t::Unload request has completed.
///
void(CEF_CALLBACK* on_extension_unloaded)(
struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension);
///
/// Called when an extension needs a browser to host a background script
/// specified via the "background" manifest key. The browser will have no
/// visible window and cannot be displayed. |extension| is the extension that
/// is loading the background script. |url| is an internally generated
/// reference to an HTML page that will be used to load the background script
/// via a "<script>" src attribute. To allow creation of the browser
/// optionally modify |client| and |settings| and return false (0). To cancel
/// creation of the browser (and consequently cancel load of the background
/// script) return true (1). Successful creation will be indicated by a call
/// to cef_life_span_handler_t::OnAfterCreated, and
/// cef_browser_host_t::IsBackgroundHost will return true (1) for the
/// resulting browser. See https://developer.chrome.com/extensions/event_pages
/// for more information about extension background script usage.
///
int(CEF_CALLBACK* on_before_background_browser)(
struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension,
const cef_string_t* url,
struct _cef_client_t** client,
struct _cef_browser_settings_t* settings);
///
/// Called when an extension API (e.g. chrome.tabs.create) requests creation
/// of a new browser. |extension| and |browser| are the source of the API
/// call. |active_browser| may optionally be specified via the windowId
/// property or returned via the get_active_browser() callback and provides
/// the default |client| and |settings| values for the new browser. |index| is
/// the position value optionally specified via the index property. |url| is
/// the URL that will be loaded in the browser. |active| is true (1) if the
/// new browser should be active when opened. To allow creation of the
/// browser optionally modify |windowInfo|, |client| and |settings| and return
/// false (0). To cancel creation of the browser return true (1). Successful
/// creation will be indicated by a call to
/// cef_life_span_handler_t::OnAfterCreated. Any modifications to |windowInfo|
/// will be ignored if |active_browser| is wrapped in a cef_browser_view_t.
///
int(CEF_CALLBACK* on_before_browser)(
struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension,
struct _cef_browser_t* browser,
struct _cef_browser_t* active_browser,
int index,
const cef_string_t* url,
int active,
struct _cef_window_info_t* windowInfo,
struct _cef_client_t** client,
struct _cef_browser_settings_t* settings);
///
/// Called when no tabId is specified to an extension API call that accepts a
/// tabId parameter (e.g. chrome.tabs.*). |extension| and |browser| are the
/// source of the API call. Return the browser that will be acted on by the
/// API call or return NULL to act on |browser|. The returned browser must
/// share the same cef_request_context_t as |browser|. Incognito browsers
/// should not be considered unless the source extension has incognito access
/// enabled, in which case |include_incognito| will be true (1).
///
struct _cef_browser_t*(CEF_CALLBACK* get_active_browser)(
struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension,
struct _cef_browser_t* browser,
int include_incognito);
///
/// Called when the tabId associated with |target_browser| is specified to an
/// extension API call that accepts a tabId parameter (e.g. chrome.tabs.*).
/// |extension| and |browser| are the source of the API call. Return true (1)
/// to allow access of false (0) to deny access. Access to incognito browsers
/// should not be allowed unless the source extension has incognito access
/// enabled, in which case |include_incognito| will be true (1).
///
int(CEF_CALLBACK* can_access_browser)(struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension,
struct _cef_browser_t* browser,
int include_incognito,
struct _cef_browser_t* target_browser);
///
/// Called to retrieve an extension resource that would normally be loaded
/// from disk (e.g. if a file parameter is specified to
/// chrome.tabs.executeScript). |extension| and |browser| are the source of
/// the resource request. |file| is the requested relative file path. To
/// handle the resource request return true (1) and execute |callback| either
/// synchronously or asynchronously. For the default behavior which reads the
/// resource from the extension directory on disk return false (0).
/// Localization substitutions will not be applied to resources handled via
/// this function.
///
int(CEF_CALLBACK* get_extension_resource)(
struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension,
struct _cef_browser_t* browser,
const cef_string_t* file,
struct _cef_get_extension_resource_callback_t* callback);
} cef_extension_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=54edf9e9c2a12acdc4cab55079a4a5cb8e2a1e43$
// $hash=6aad2ccf30a6c519bbeee64d83866e82a41a48d8$
//
#ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
@@ -117,7 +117,7 @@ typedef struct _cef_life_span_handler_t {
/// Views-hosted source browsers will create Views-hosted DevTools popups
/// unless |use_default_window| is set to to true (1). DevTools popups can be
/// blocked by returning true (1) from cef_command_handler_t::OnChromeCommand
/// for IDC_DEV_TOOLS. Only used with the Chrome runtime.
/// for IDC_DEV_TOOLS. Only used with Chrome style.
///
void(CEF_CALLBACK* on_before_dev_tools_popup)(
struct _cef_life_span_handler_t* self,
@@ -138,35 +138,44 @@ typedef struct _cef_life_span_handler_t {
struct _cef_browser_t* browser);
///
/// Called when a browser has received a request to close. This may result
/// directly from a call to cef_browser_host_t::*close_browser() or indirectly
/// if the browser is parented to a top-level window created by CEF and the
/// user attempts to close that window (by clicking the 'X', for example). The
/// do_close() function will be called after the JavaScript 'onunload' event
/// has been fired.
/// Called when an Alloy style browser is ready to be closed, meaning that the
/// close has already been initiated and that JavaScript unload handlers have
/// already executed or should be ignored. This may result directly from a
/// call to cef_browser_host_t::[Try]close_browser() or indirectly if the
/// browser's top-level parent window was created by CEF and the user attempts
/// to close that window (by clicking the 'X', for example). do_close() will
/// not be called if the browser's host window/view has already been destroyed
/// (via parent window/view hierarchy tear-down, for example), as it is no
/// longer possible to customize the close behavior at that point.
///
/// An application should handle top-level owner window close notifications by
/// calling cef_browser_host_t::try_close_browser() or
/// An application should handle top-level parent window close notifications
/// by calling cef_browser_host_t::try_close_browser() or
/// cef_browser_host_t::CloseBrowser(false (0)) instead of allowing the window
/// to close immediately (see the examples below). This gives CEF an
/// opportunity to process the 'onbeforeunload' event and optionally cancel
/// opportunity to process JavaScript unload handlers and optionally cancel
/// the close before do_close() is called.
///
/// When windowed rendering is enabled CEF will internally create a window or
/// view to host the browser. In that case returning false (0) from do_close()
/// will send the standard close notification to the browser's top-level owner
/// window (e.g. WM_CLOSE on Windows, performClose: on OS X, "delete_event" on
/// Linux or cef_window_delegate_t::can_close() callback from Views). If the
/// browser's host window/view has already been destroyed (via view hierarchy
/// tear-down, for example) then do_close() will not be called for that
/// browser since is no longer possible to cancel the close.
/// When windowed rendering is enabled CEF will create an internal child
/// window/view to host the browser. In that case returning false (0) from
/// do_close() will send the standard close notification to the browser's top-
/// level parent window (e.g. WM_CLOSE on Windows, performClose: on OS X,
/// "delete_event" on Linux or cef_window_delegate_t::can_close() callback
/// from Views).
///
/// When windowed rendering is disabled returning false (0) from do_close()
/// will cause the browser object to be destroyed immediately.
/// When windowed rendering is disabled there is no internal window/view and
/// returning false (0) from do_close() will cause the browser object to be
/// destroyed immediately.
///
/// If the browser's top-level owner window requires a non-standard close
/// If the browser's top-level parent window requires a non-standard close
/// notification then send that notification from do_close() and return true
/// (1).
/// (1). You are still required to complete the browser close as soon as
/// possible (either by calling [Try]close_browser() or by proceeding with
/// window/view hierarchy tear-down), otherwise the browser will be left in a
/// partially closed state that interferes with proper functioning. Top-level
/// windows created on the browser process UI thread can alternately call
/// cef_browser_host_t::is_ready_to_be_closed() in the close handler to check
/// close status instead of relying on custom do_close() handling. See
/// documentation on that function for additional details.
///
/// The cef_life_span_handler_t::on_before_close() function will be called
/// after do_close() (if do_close() is called) and immediately before the
@@ -182,22 +191,26 @@ typedef struct _cef_life_span_handler_t {
/// which sends a close notification
/// to the application's top-level window.
/// 2. Application's top-level window receives the close notification and
/// calls TryCloseBrowser() (which internally calls CloseBrowser(false)).
/// calls TryCloseBrowser() (similar to calling CloseBrowser(false)).
/// TryCloseBrowser() returns false so the client cancels the window
/// close.
/// 3. JavaScript 'onbeforeunload' handler executes and shows the close
/// confirmation dialog (which can be overridden via
/// CefJSDialogHandler::OnBeforeUnloadDialog()).
/// 4. User approves the close. 5. JavaScript 'onunload' handler executes.
/// 6. CEF sends a close notification to the application's top-level window
/// (because DoClose() returned false by default).
/// 7. Application's top-level window receives the close notification and
/// 6. Application's do_close() handler is called and returns false (0) by
/// default.
/// 7. CEF sends a close notification to the application's top-level window
/// (because DoClose() returned false).
/// 8. Application's top-level window receives the close notification and
/// calls TryCloseBrowser(). TryCloseBrowser() returns true so the client
/// allows the window close.
/// 8. Application's top-level window is destroyed. 9. Application's
/// on_before_close() handler is called and the browser object
/// 9. Application's top-level window is destroyed, triggering destruction
/// of the child browser window.
/// 10. Application's on_before_close() handler is called and the browser
/// object
/// is destroyed.
/// 10. Application exits by calling cef_quit_message_loop() if no other
/// 11. Application exits by calling cef_quit_message_loop() if no other
/// browsers
/// exist.
///
@@ -215,13 +228,17 @@ typedef struct _cef_life_span_handler_t {
/// CefJSDialogHandler::OnBeforeUnloadDialog()).
/// 4. User approves the close. 5. JavaScript 'onunload' handler executes.
/// 6. Application's do_close() handler is called. Application will:
/// A. Set a flag to indicate that the next close attempt will be allowed.
/// A. Set a flag to indicate that the next top-level window close attempt
/// will be allowed.
/// B. Return false.
/// 7. CEF sends an close notification to the application's top-level window.
/// 7. CEF sends a close notification to the application's top-level window
/// (because DoClose() returned false).
/// 8. Application's top-level window receives the close notification and
/// allows the window to close based on the flag from #6B.
/// 9. Application's top-level window is destroyed. 10. Application's
/// on_before_close() handler is called and the browser object
/// allows the window to close based on the flag from #6A.
/// 9. Application's top-level window is destroyed, triggering destruction
/// of the child browser window.
/// 10. Application's on_before_close() handler is called and the browser
/// object
/// is destroyed.
/// 11. Application exits by calling cef_quit_message_loop() if no other
/// browsers

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=c9b3913701581cd6a1077fa3a39d197f338a2507$
// $hash=66aebf0e910224fb8eaa7f847feeccac73378374$
//
#ifndef CEF_INCLUDE_CAPI_CEF_PERMISSION_HANDLER_CAPI_H_
@@ -108,11 +108,11 @@ typedef struct _cef_permission_handler_t {
/// cef_media_access_permission_types_t that represent the requested
/// permissions. Return true (1) and call cef_media_access_callback_t
/// functions either in this function or at a later time to continue or cancel
/// the request. Return false (0) to proceed with default handling. With the
/// Chrome runtime, default handling will display the permission request UI.
/// With the Alloy runtime, default handling will deny the request. This
/// function will not be called if the "--enable-media-stream" command-line
/// switch is used to grant all permissions.
/// the request. Return false (0) to proceed with default handling. With
/// Chrome style, default handling will display the permission request UI.
/// With Alloy style, default handling will deny the request. This function
/// will not be called if the "--enable-media-stream" command-line switch is
/// used to grant all permissions.
///
int(CEF_CALLBACK* on_request_media_access_permission)(
struct _cef_permission_handler_t* self,
@@ -129,9 +129,9 @@ typedef struct _cef_permission_handler_t {
/// cef_permission_request_types_t that represent the requested permissions.
/// Return true (1) and call cef_permission_prompt_callback_t::Continue either
/// in this function or at a later time to continue or cancel the request.
/// Return false (0) to proceed with default handling. With the Chrome
/// runtime, default handling will display the permission prompt UI. With the
/// Alloy runtime, default handling is CEF_PERMISSION_RESULT_IGNORE.
/// Return false (0) to proceed with default handling. With Chrome style,
/// default handling will display the permission prompt UI. With Alloy style,
/// default handling is CEF_PERMISSION_RESULT_IGNORE.
///
int(CEF_CALLBACK* on_show_permission_prompt)(
struct _cef_permission_handler_t* self,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=2c496139ca9a59303b1493ee93d2c3ae96a956c0$
// $hash=c63fac0c620ead3525405feb5cc9db561e1a508a$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@@ -42,8 +42,6 @@
#include "include/capi/cef_callback_capi.h"
#include "include/capi/cef_cookie_capi.h"
#include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/capi/cef_media_router_capi.h"
#include "include/capi/cef_preference_capi.h"
#include "include/capi/cef_values_capi.h"
@@ -205,105 +203,6 @@ typedef struct _cef_request_context_t {
const cef_string_t* origin,
struct _cef_resolve_callback_t* callback);
///
/// Load an extension.
///
/// If extension resources will be read from disk using the default load
/// implementation then |root_directory| should be the absolute path to the
/// extension resources directory and |manifest| should be NULL. If extension
/// resources will be provided by the client (e.g. via cef_request_handler_t
/// and/or cef_extension_handler_t) then |root_directory| should be a path
/// component unique to the extension (if not absolute this will be internally
/// prefixed with the PK_DIR_RESOURCES path) and |manifest| should contain the
/// contents that would otherwise be read from the "manifest.json" file on
/// disk.
///
/// The loaded extension will be accessible in all contexts sharing the same
/// storage (HasExtension returns true (1)). However, only the context on
/// which this function was called is considered the loader (DidLoadExtension
/// returns true (1)) and only the loader will receive
/// cef_request_context_handler_t callbacks for the extension.
///
/// cef_extension_handler_t::OnExtensionLoaded will be called on load success
/// or cef_extension_handler_t::OnExtensionLoadFailed will be called on load
/// failure.
///
/// If the extension specifies a background script via the "background"
/// manifest key then cef_extension_handler_t::OnBeforeBackgroundBrowser will
/// be called to create the background browser. See that function for
/// additional information about background scripts.
///
/// For visible extension views the client application should evaluate the
/// manifest to determine the correct extension URL to load and then pass that
/// URL to the cef_browser_host_t::CreateBrowser* function after the extension
/// has loaded. For example, the client can look for the "browser_action"
/// manifest key as documented at
/// https://developer.chrome.com/extensions/browserAction. Extension URLs take
/// the form "chrome-extension://<extension_id>/<path>".
///
/// Browsers that host extensions differ from normal browsers as follows:
/// - Can access chrome.* JavaScript APIs if allowed by the manifest. Visit
/// chrome://extensions-support for the list of extension APIs currently
/// supported by CEF.
/// - Main frame navigation to non-extension content is blocked.
/// - Pinch-zooming is disabled.
/// - CefBrowserHost::GetExtension returns the hosted extension.
/// - CefBrowserHost::IsBackgroundHost returns true for background hosts.
///
/// See https://developer.chrome.com/extensions for extension implementation
/// and usage documentation.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
void(CEF_CALLBACK* load_extension)(struct _cef_request_context_t* self,
const cef_string_t* root_directory,
struct _cef_dictionary_value_t* manifest,
struct _cef_extension_handler_t* handler);
///
/// Returns true (1) if this context was used to load the extension identified
/// by |extension_id|. Other contexts sharing the same storage will also have
/// access to the extension (see HasExtension). This function must be called
/// on the browser process UI thread.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
int(CEF_CALLBACK* did_load_extension)(struct _cef_request_context_t* self,
const cef_string_t* extension_id);
///
/// Returns true (1) if this context has access to the extension identified by
/// |extension_id|. This may not be the context that was used to load the
/// extension (see DidLoadExtension). This function must be called on the
/// browser process UI thread.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
int(CEF_CALLBACK* has_extension)(struct _cef_request_context_t* self,
const cef_string_t* extension_id);
///
/// Retrieve the list of all extensions that this context has access to (see
/// HasExtension). |extension_ids| will be populated with the list of
/// extension ID values. Returns true (1) on success. This function must be
/// called on the browser process UI thread.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
int(CEF_CALLBACK* get_extensions)(struct _cef_request_context_t* self,
cef_string_list_t extension_ids);
///
/// Returns the extension matching |extension_id| or NULL if no matching
/// extension is accessible in this context (see HasExtension). This function
/// must be called on the browser process UI thread.
///
/// WARNING: This function is deprecated and will be removed in ~M127.
///
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
struct _cef_request_context_t* self,
const cef_string_t* extension_id);
///
/// Returns the MediaRouter object associated with this context. If
/// |callback| is non-NULL it will be executed asnychronously on the UI thread

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=2e8b5c5107f61e3d4c333dc02c76a9f30cd0cf83$
// $hash=db7cfb76483d6ab73eba74deaefafa7700ad1988$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_
@@ -227,20 +227,19 @@ typedef struct _cef_request_handler_t {
/// Called on the browser process UI thread when the render process is
/// unresponsive as indicated by a lack of input event processing for at least
/// 15 seconds. Return false (0) for the default behavior which is an
/// indefinite wait with the Alloy runtime or display of the "Page
/// unresponsive" dialog with the Chrome runtime. Return true (1) and don't
/// execute the callback for an indefinite wait without display of the Chrome
/// runtime dialog. Return true (1) and call
/// cef_unresponsive_process_callback_t::Wait either in this function or at a
/// later time to reset the wait timer, potentially triggering another call to
/// this function if the process remains unresponsive. Return true (1) and
/// call cef_unresponsive_process_callback_t:: Terminate either in this
/// function or at a later time to terminate the unresponsive process,
/// resulting in a call to OnRenderProcessTerminated.
/// OnRenderProcessResponsive will be called if the process becomes responsive
/// after this function is called. This functionality depends on the hang
/// monitor which can be disabled by passing the `--disable-hang-monitor`
/// command-line flag.
/// indefinite wait with Alloy style or display of the "Page unresponsive"
/// dialog with Chrome style. Return true (1) and don't execute the callback
/// for an indefinite wait without display of the Chrome style dialog. Return
/// true (1) and call cef_unresponsive_process_callback_t::Wait either in this
/// function or at a later time to reset the wait timer, potentially
/// triggering another call to this function if the process remains
/// unresponsive. Return true (1) and call
/// cef_unresponsive_process_callback_t:: Terminate either in this function or
/// at a later time to terminate the unresponsive process, resulting in a call
/// to OnRenderProcessTerminated. OnRenderProcessResponsive will be called if
/// the process becomes responsive after this function is called. This
/// functionality depends on the hang monitor which can be disabled by passing
/// the `--disable-hang-monitor` command-line flag.
///
int(CEF_CALLBACK* on_render_process_unresponsive)(
struct _cef_request_handler_t* self,

View File

@@ -0,0 +1,117 @@
// Copyright (c) 2024 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=324b0399edef39e64fb54fce053e7f8e347e07de$
//
#ifndef CEF_INCLUDE_CAPI_CEF_TASK_MANAGER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_TASK_MANAGER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
/// Structure that facilitates managing the browser-related tasks. The functions
/// of this structure may only be called on the UI thread.
///
typedef struct _cef_task_manager_t {
///
/// Base structure.
///
cef_base_ref_counted_t base;
///
/// Returns the number of tasks currently tracked by the task manager. Returns
/// 0 if the function was called from the incorrect thread.
///
size_t(CEF_CALLBACK* get_tasks_count)(struct _cef_task_manager_t* self);
///
/// Gets the list of task IDs currently tracked by the task manager. Tasks
/// that share the same process id will always be consecutive. The list will
/// be sorted in a way that reflects the process tree: the browser process
/// will be first, followed by the gpu process if it exists. Related processes
/// (e.g., a subframe process and its parent) will be kept together if
/// possible. Callers can expect this ordering to be stable when a process is
/// added or removed. The task IDs are unique within the application lifespan.
/// Returns false (0) if the function was called from the incorrect thread.
///
int(CEF_CALLBACK* get_task_ids_list)(struct _cef_task_manager_t* self,
size_t* task_idsCount,
int64_t* task_ids);
///
/// Gets information about the task with |task_id|. Returns true (1) if the
/// information about the task was successfully retrieved and false (0) if the
/// |task_id| is invalid or the function was called from the incorrect thread.
///
int(CEF_CALLBACK* get_task_info)(struct _cef_task_manager_t* self,
int64_t task_id,
struct _cef_task_info_t* info);
///
/// Attempts to terminate a task with |task_id|. Returns false (0) if the
/// |task_id| is invalid, the call is made from an incorrect thread, or if the
/// task cannot be terminated.
///
int(CEF_CALLBACK* kill_task)(struct _cef_task_manager_t* self,
int64_t task_id);
///
/// Returns the task ID associated with the main task for |browser_id| (value
/// from cef_browser_t::GetIdentifier). Returns -1 if |browser_id| is invalid,
/// does not currently have an associated task, or the function was called
/// from the incorrect thread.
///
int64_t(CEF_CALLBACK* get_task_id_for_browser_id)(
struct _cef_task_manager_t* self,
int browser_id);
} cef_task_manager_t;
///
/// Returns the global task manager object. Returns nullptr if the function was
/// called from the incorrect thread.
///
CEF_EXPORT cef_task_manager_t* cef_task_manager_get(void);
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_TASK_MANAGER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=5dd4948a92af2ad69e2171f2dffb8f2c23e5c147$
// $hash=0b56c483bee6489e591c54c9dbb0940cd3098eaa$
//
#ifndef CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_
@@ -832,11 +832,24 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_array(int length);
/// cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling
/// enter() and exit() on a stored cef_v8context_t reference.
///
/// NOTE: Always returns nullptr when V8 sandbox is enabled.
///
CEF_EXPORT cef_v8value_t* cef_v8value_create_array_buffer(
void* buffer,
size_t length,
cef_v8array_buffer_release_callback_t* release_callback);
///
/// Create a new cef_v8value_t object of type ArrayBuffer which copies the
/// provided |buffer| of size |length| bytes. This function should only be
/// called from within the scope of a cef_render_process_handler_t,
/// cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling
/// enter() and exit() on a stored cef_v8context_t reference.
///
CEF_EXPORT cef_v8value_t* cef_v8value_create_array_buffer_with_copy(
void* buffer,
size_t length);
///
/// Create a new cef_v8value_t object of type function. This function should
/// only be called from within the scope of a cef_render_process_handler_t,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=1c2fbbffaf51e90a2d55bfa7eb3fa3a4e315f4ac$
// $hash=76897eedc7c858601fd7d98cb55b8808810f8493$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
@@ -67,7 +67,7 @@ typedef struct _cef_browser_view_t {
///
/// Returns the Chrome toolbar associated with this BrowserView. Only
/// supported when using the Chrome runtime. The cef_browser_view_delegate_t::
/// supported when using Chrome style. The cef_browser_view_delegate_t::
/// get_chrome_toolbar_type() function must return a value other than
/// CEF_CTT_NONE and the toolbar will not be available until after this
/// BrowserView is added to a cef_window_t and
@@ -81,8 +81,8 @@ typedef struct _cef_browser_view_t {
/// content (`keydown` event handler) or cef_keyboard_handler_t. Normal
/// priority accelerators can be registered via cef_window_t::SetAccelerator
/// (with |high_priority|=false (0)) or internally for standard accelerators
/// supported by the Chrome runtime. If |prefer_accelerators| is true (1) then
/// the matching accelerator will be triggered immediately (calling
/// supported by Chrome style. If |prefer_accelerators| is true (1) then the
/// matching accelerator will be triggered immediately (calling
/// cef_window_delegate_t::OnAccelerator or
/// cef_command_handler_t::OnChromeCommand respectively) and the event will
/// not be forwarded to the web content or cef_keyboard_handler_t first. If

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=a0a9f2bfcdf8e05d3d1114fcd8860caaa726ec98$
// $hash=f8e8992eedf254a60e2875715c3adfa23ca4ae20$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_
@@ -134,7 +134,7 @@ typedef struct _cef_browser_view_delegate_t {
///
/// Called when |browser_view| receives a gesture command. Return true (1) to
/// handle (or disable) a |gesture_command| or false (0) to propagate the
/// gesture to the browser for default handling. With the Chrome runtime these
/// gesture to the browser for default handling. With Chrome style these
/// commands can also be handled via cef_command_handler_t::OnChromeCommand.
///
int(CEF_CALLBACK* on_gesture_command)(

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=e8c9e32caa8d317a7cb6ff2f0ad6be49cf1b7ad1$
// $hash=bafa7ddf3dfbc3fa82b1fb8a064b51f0791b29b6$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
@@ -101,9 +101,9 @@ typedef struct _cef_window_delegate_t {
/// the transition occurs asynchronously with |is_competed| set to false (0)
/// when the transition starts and true (1) after the transition completes. On
/// other platforms the transition occurs synchronously with |is_completed|
/// set to true (1) after the transition completes. With the Alloy runtime you
/// must also implement cef_display_handler_t::OnFullscreenModeChange to
/// handle fullscreen transitions initiated by browser content.
/// set to true (1) after the transition completes. With Alloy style you must
/// also implement cef_display_handler_t::OnFullscreenModeChange to handle
/// fullscreen transitions initiated by browser content.
///
void(CEF_CALLBACK* on_window_fullscreen_transition)(
struct _cef_window_delegate_t* self,
@@ -253,12 +253,10 @@ typedef struct _cef_window_delegate_t {
/// Chrome theme colors will be applied and this callback will be triggered
/// if/when a BrowserView is added to the Window's component hierarchy. Chrome
/// theme colors can be configured on a per-RequestContext basis using
/// cef_request_context_t::SetChromeColorScheme or (Chrome runtime only) by
/// cef_request_context_t::SetChromeColorScheme or (Chrome style only) by
/// visiting chrome://settings/manageProfile. Any theme changes using those
/// mechanisms will also trigger this callback. Chrome theme colors will be
/// persisted and restored from disk cache with the Chrome runtime, and with
/// the Alloy runtime if persist_user_preferences is set to true (1) via
/// CefSettings or cef_request_context_tSettings.
/// persisted and restored from disk cache.
///
/// This callback is not triggered on Window creation so clients that wish to
/// customize the initial native/OS theme must call
@@ -282,6 +280,15 @@ typedef struct _cef_window_delegate_t {
///
cef_runtime_style_t(CEF_CALLBACK* get_window_runtime_style)(
struct _cef_window_delegate_t* self);
///
/// Return Linux-specific window properties for correctly handling by window
/// managers
///
int(CEF_CALLBACK* get_linux_window_properties)(
struct _cef_window_delegate_t* self,
struct _cef_window_t* window,
struct _cef_linux_window_properties_t* properties);
} cef_window_delegate_t;
#ifdef __cplusplus

View File

@@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "ed1dfa5ff8a041241f8fb72eb7454811f358f0d3"
#define CEF_API_HASH_UNIVERSAL "676af077d6826353caf40425f5f2bae1262347ea"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "0d99d1b9b85b2efab91a39d6fc325bb6d56fd524"
#define CEF_API_HASH_PLATFORM "51848171cdea10858c4e0fca0f7099b0fdc759f9"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "e585e190387e31a71267207b66d175e213991470"
#define CEF_API_HASH_PLATFORM "8cc826c5f5fe97c275dfa3b9c020470678a5d2fd"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "09d3e280ed38f7a082b794c56ff71c52f86f0ea8"
#define CEF_API_HASH_PLATFORM "0aec2348de1bf14fafa7a23baa0df942d342d409"
#endif
#ifdef __cplusplus

View File

@@ -174,10 +174,9 @@ class CefApp : public virtual CefBaseRefCounted {
CefRawPtr<CefSchemeRegistrar> registrar) {}
///
/// Return the handler for resource bundle events. If
/// cef_settings_t.pack_loading_disabled is true a handler must be returned.
/// If no handler is returned resources will be loaded from pack files. This
/// method is called by the browser and render processes on multiple threads.
/// Return the handler for resource bundle events. If no handler is returned
/// resources will be loaded from pack files. This method is called by the
/// browser and render processes on multiple threads.
///
/*--cef()--*/
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() {

View File

@@ -331,30 +331,63 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
virtual CefRefPtr<CefBrowser> GetBrowser() = 0;
///
/// Request that the browser close. The JavaScript 'onbeforeunload' event will
/// be fired. If |force_close| is false the event handler, if any, will be
/// allowed to prompt the user and the user can optionally cancel the close.
/// If |force_close| is true the prompt will not be displayed and the close
/// will proceed. Results in a call to CefLifeSpanHandler::DoClose() if the
/// event handler allows the close or if |force_close| is true. See
/// CefLifeSpanHandler::DoClose() documentation for additional usage
/// information.
/// Request that the browser close. Closing a browser is a multi-stage process
/// that may complete either synchronously or asynchronously, and involves
/// callbacks such as CefLifeSpanHandler::DoClose (Alloy style only),
/// CefLifeSpanHandler::OnBeforeClose, and a top-level window close handler
/// such as CefWindowDelegate::CanClose (or platform-specific equivalent). In
/// some cases a close request may be delayed or canceled by the user. Using
/// TryCloseBrowser() instead of CloseBrowser() is recommended for most use
/// cases. See CefLifeSpanHandler::DoClose() documentation for detailed usage
/// and examples.
///
/// If |force_close| is false then JavaScript unload handlers, if any, may be
/// fired and the close may be delayed or canceled by the user. If
/// |force_close| is true then the user will not be prompted and the close
/// will proceed immediately (possibly asynchronously). If browser close is
/// delayed and not canceled the default behavior is to call the top-level
/// window close handler once the browser is ready to be closed. This default
/// behavior can be changed for Alloy style browsers by implementing
/// CefLifeSpanHandler::DoClose(). IsReadyToBeClosed() can be used to detect
/// mandatory browser close events when customizing close behavior on the
/// browser process UI thread.
///
/*--cef()--*/
virtual void CloseBrowser(bool force_close) = 0;
///
/// Helper for closing a browser. Call this method from the top-level window
/// close handler (if any). Internally this calls CloseBrowser(false) if the
/// close has not yet been initiated. This method returns false while the
/// close is pending and true after the close has completed. See
/// CloseBrowser() and CefLifeSpanHandler::DoClose() documentation for
/// additional usage information. This method must be called on the browser
/// process UI thread.
/// Helper for closing a browser. This is similar in behavior to
/// CLoseBrowser(false) but returns a boolean to reflect the immediate close
/// status. Call this method from a top-level window close handler such as
/// CefWindowDelegate::CanClose (or platform-specific equivalent) to request
/// that the browser close, and return the result to indicate if the window
/// close should proceed. Returns false if the close will be delayed
/// (JavaScript unload handlers triggered but still pending) or true if the
/// close will proceed immediately (possibly asynchronously). See
/// CloseBrowser() documentation for additional usage information. This method
/// must be called on the browser process UI thread.
///
/*--cef()--*/
virtual bool TryCloseBrowser() = 0;
///
/// Returns true if the browser is ready to be closed, meaning that the close
/// has already been initiated and that JavaScript unload handlers have
/// already executed or should be ignored. This can be used from a top-level
/// window close handler such as CefWindowDelegate::CanClose (or
/// platform-specific equivalent) to distringuish between potentially
/// cancelable browser close events (like the user clicking the top-level
/// window close button before browser close has started) and mandatory
/// browser close events (like JavaScript `window.close()` or after browser
/// close has started in response to [Try]CloseBrowser()). Not completing the
/// browser close for mandatory close events (when this method returns true)
/// will leave the browser in a partially closed state that interferes with
/// proper functioning. See CloseBrowser() documentation for additional usage
/// information. This method must be called on the browser process UI thread.
///
/*--cef()--*/
virtual bool IsReadyToBeClosed() = 0;
///
/// Set whether the browser is focused.
///
@@ -414,8 +447,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
///
/// Get the default zoom level. This value will be 0.0 by default but can be
/// configured with the Chrome runtime. This method can only be called on the
/// UI thread.
/// configured. This method can only be called on the UI thread.
///
/*--cef()--*/
virtual double GetDefaultZoomLevel() = 0;
@@ -939,25 +971,6 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
const CefSize& min_size,
const CefSize& max_size) = 0;
///
/// Returns the extension hosted in this browser or NULL if no extension is
/// hosted. See CefRequestContext::LoadExtension for details.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual CefRefPtr<CefExtension> GetExtension() = 0;
///
/// Returns true if this browser is hosting an extension background script.
/// Background hosts do not have a window and are not displayable. See
/// CefRequestContext::LoadExtension for details.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual bool IsBackgroundHost() = 0;
///
/// Set whether the browser's audio is muted.
///
@@ -983,12 +996,12 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
///
/// Requests the renderer to exit browser fullscreen. In most cases exiting
/// window fullscreen should also exit browser fullscreen. With the Alloy
/// runtime this method should be called in response to a user action such as
/// window fullscreen should also exit browser fullscreen. With Alloy
/// style this method should be called in response to a user action such as
/// clicking the green traffic light button on MacOS
/// (CefWindowDelegate::OnWindowFullscreenTransition callback) or pressing the
/// "ESC" key (CefKeyboardHandler::OnPreKeyEvent callback). With the Chrome
/// runtime these standard exit actions are handled internally but
/// "ESC" key (CefKeyboardHandler::OnPreKeyEvent callback). With Chrome
/// style these standard exit actions are handled internally but
/// new/additional user actions can use this method. Set |will_cause_resize|
/// to true if exiting browser fullscreen will cause a view resize.
///
@@ -998,7 +1011,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
///
/// Returns true if a Chrome command is supported and enabled. Values for
/// |command_id| can be found in the cef_command_ids.h file. This method can
/// only be called on the UI thread. Only used with the Chrome runtime.
/// only be called on the UI thread. Only used with Chrome style.
///
/*--cef()--*/
virtual bool CanExecuteChromeCommand(int command_id) = 0;
@@ -1006,7 +1019,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
///
/// Execute a Chrome command. Values for |command_id| can be found in the
/// cef_command_ids.h file. |disposition| provides information about the
/// intended command target. Only used with the Chrome runtime.
/// intended command target. Only used with Chrome style.
///
/*--cef()--*/
virtual void ExecuteChromeCommand(

View File

@@ -60,8 +60,8 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
/// accessed via CefPreferenceManager::GetGlobalPreferences after
/// OnContextInitialized is called. Global preferences are registered a single
/// time at application startup. See related cef_settings_t.cache_path and
/// cef_settings_t.persist_user_preferences configuration.
/// time at application startup. See related cef_settings_t.cache_path
/// configuration.
///
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
/// accessed via the CefRequestContext after
@@ -69,8 +69,7 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
/// context preferences are registered each time a new CefRequestContext is
/// created. It is intended but not required that all request contexts have
/// the same registered preferences. See related
/// cef_request_context_settings_t.cache_path and
/// cef_request_context_settings_t.persist_user_preferences configuration.
/// cef_request_context_settings_t.cache_path configuration.
///
/// Do not keep a reference to the |registrar| object. This method is called
/// on the browser process UI thread.
@@ -144,8 +143,8 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
/// (CefBrowser object). If null is returned the CefBrowser will be unmanaged
/// (no callbacks will be executed for that CefBrowser) and application
/// shutdown will be blocked until the browser window is closed manually. This
/// method is currently only used with the Chrome runtime when creating new
/// browser windows via Chrome UI.
/// method is currently only used with Chrome style when creating new browser
/// windows via Chrome UI.
///
/*--cef()--*/
virtual CefRefPtr<CefClient> GetDefaultClient() { return nullptr; }
@@ -154,8 +153,8 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
/// Return the default handler for use with a new user or incognito profile
/// (CefRequestContext object). If null is returned the CefRequestContext will
/// be unmanaged (no callbacks will be executed for that CefRequestContext).
/// This method is currently only used with the Chrome runtime when creating
/// new browser windows via Chrome UI.
/// This method is currently only used with Chrome style when creating new
/// browser windows via Chrome UI.
///
/*--cef()--*/
virtual CefRefPtr<CefRequestContextHandler>

View File

@@ -55,7 +55,7 @@ class CefCommandHandler : public virtual CefBaseRefCounted {
/// intended command target. Return true if the command was handled or false
/// for the default implementation. For context menu commands this will be
/// called after CefContextMenuHandler::OnContextMenuCommand. Only used with
/// the Chrome runtime.
/// Chrome style.
///
/*--cef()--*/
virtual bool OnChromeCommand(CefRefPtr<CefBrowser> browser,
@@ -67,8 +67,7 @@ class CefCommandHandler : public virtual CefBaseRefCounted {
///
/// Called to check if a Chrome app menu item should be visible. Values for
/// |command_id| can be found in the cef_command_ids.h file. Only called for
/// menu items that would be visible by default. Only used with the Chrome
/// runtime.
/// menu items that would be visible by default. Only used with Chrome style.
///
/*--cef()--*/
virtual bool IsChromeAppMenuItemVisible(CefRefPtr<CefBrowser> browser,
@@ -79,8 +78,7 @@ class CefCommandHandler : public virtual CefBaseRefCounted {
///
/// Called to check if a Chrome app menu item should be enabled. Values for
/// |command_id| can be found in the cef_command_ids.h file. Only called for
/// menu items that would be enabled by default. Only used with the Chrome
/// runtime.
/// menu items that would be enabled by default. Only used with Chrome style.
///
/*--cef()--*/
virtual bool IsChromeAppMenuItemEnabled(CefRefPtr<CefBrowser> browser,
@@ -91,7 +89,7 @@ class CefCommandHandler : public virtual CefBaseRefCounted {
///
/// Called during browser creation to check if a Chrome page action icon
/// should be visible. Only called for icons that would be visible by default.
/// Only used with the Chrome runtime.
/// Only used with Chrome style.
///
/*--cef(optional_param=browser)--*/
virtual bool IsChromePageActionIconVisible(
@@ -102,7 +100,7 @@ class CefCommandHandler : public virtual CefBaseRefCounted {
///
/// Called during browser creation to check if a Chrome toolbar button
/// should be visible. Only called for buttons that would be visible by
/// default. Only used with the Chrome runtime.
/// default. Only used with Chrome style.
///
/*--cef(optional_param=browser)--*/
virtual bool IsChromeToolbarButtonVisible(

View File

@@ -75,12 +75,12 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
/// Called when web content in the page has toggled fullscreen mode. If
/// |fullscreen| is true the content will automatically be sized to fill the
/// browser content area. If |fullscreen| is false the content will
/// automatically return to its original size and position. With the Alloy
/// runtime the client is responsible for triggering the fullscreen transition
/// (for example, by calling CefWindow::SetFullscreen when using Views). With
/// the Chrome runtime the fullscreen transition will be triggered
/// automatically. The CefWindowDelegate::OnWindowFullscreenTransition method
/// will be called during the fullscreen transition for notification purposes.
/// automatically return to its original size and position. With Alloy style
/// the client is responsible for triggering the fullscreen transition (for
/// example, by calling CefWindow::SetFullscreen when using Views). With
/// Chrome style the fullscreen transition will be triggered automatically.
/// The CefWindowDelegate::OnWindowFullscreenTransition method will be called
/// during the fullscreen transition for notification purposes.
///
/*--cef()--*/
virtual void OnFullscreenModeChange(CefRefPtr<CefBrowser> browser,

View File

@@ -1,120 +0,0 @@
// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_EXTENSION_H_
#define CEF_INCLUDE_CEF_EXTENSION_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_values.h"
class CefExtensionHandler;
class CefRequestContext;
///
/// Object representing an extension. Methods may be called on any thread unless
/// otherwise indicated.
///
/// WARNING: This API is deprecated and will be removed in ~M127.
///
/*--cef(source=library)--*/
class CefExtension : public CefBaseRefCounted {
public:
///
/// Returns the unique extension identifier. This is calculated based on the
/// extension public key, if available, or on the extension path. See
/// https://developer.chrome.com/extensions/manifest/key for details.
///
/*--cef()--*/
virtual CefString GetIdentifier() = 0;
///
/// Returns the absolute path to the extension directory on disk. This value
/// will be prefixed with PK_DIR_RESOURCES if a relative path was passed to
/// CefRequestContext::LoadExtension.
///
/*--cef()--*/
virtual CefString GetPath() = 0;
///
/// Returns the extension manifest contents as a CefDictionaryValue object.
/// See https://developer.chrome.com/extensions/manifest for details.
///
/*--cef()--*/
virtual CefRefPtr<CefDictionaryValue> GetManifest() = 0;
///
/// Returns true if this object is the same extension as |that| object.
/// Extensions are considered the same if identifier, path and loader context
/// match.
///
/*--cef()--*/
virtual bool IsSame(CefRefPtr<CefExtension> that) = 0;
///
/// Returns the handler for this extension. Will return NULL for internal
/// extensions or if no handler was passed to
/// CefRequestContext::LoadExtension.
///
/*--cef()--*/
virtual CefRefPtr<CefExtensionHandler> GetHandler() = 0;
///
/// Returns the request context that loaded this extension. Will return NULL
/// for internal extensions or if the extension has been unloaded. See the
/// CefRequestContext::LoadExtension documentation for more information about
/// loader contexts. Must be called on the browser process UI thread.
///
/*--cef()--*/
virtual CefRefPtr<CefRequestContext> GetLoaderContext() = 0;
///
/// Returns true if this extension is currently loaded. Must be called on the
/// browser process UI thread.
///
/*--cef()--*/
virtual bool IsLoaded() = 0;
///
/// Unload this extension if it is not an internal extension and is currently
/// loaded. Will result in a call to CefExtensionHandler::OnExtensionUnloaded
/// on success.
///
/*--cef()--*/
virtual void Unload() = 0;
};
#endif // CEF_INCLUDE_CEF_EXTENSION_H_

View File

@@ -1,202 +0,0 @@
// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_
#define CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "include/cef_extension.h"
#include "include/cef_stream.h"
class CefClient;
///
/// Callback interface used for asynchronous continuation of
/// CefExtensionHandler::GetExtensionResource.
///
/*--cef(source=library)--*/
class CefGetExtensionResourceCallback : public CefBaseRefCounted {
public:
///
/// Continue the request. Read the resource contents from |stream|.
///
/*--cef(capi_name=cont,optional_param=stream)--*/
virtual void Continue(CefRefPtr<CefStreamReader> stream) = 0;
///
/// Cancel the request.
///
/*--cef()--*/
virtual void Cancel() = 0;
};
///
/// Implement this interface to handle events related to browser extensions.
/// The methods of this class will be called on the UI thread. See
/// CefRequestContext::LoadExtension for information about extension loading.
///
/// WARNING: This API is deprecated and will be removed in ~M127.
///
/*--cef(source=client)--*/
class CefExtensionHandler : public virtual CefBaseRefCounted {
public:
///
/// Called if the CefRequestContext::LoadExtension request fails. |result|
/// will be the error code.
///
/*--cef()--*/
virtual void OnExtensionLoadFailed(cef_errorcode_t result) {}
///
/// Called if the CefRequestContext::LoadExtension request succeeds.
/// |extension| is the loaded extension.
///
/*--cef()--*/
virtual void OnExtensionLoaded(CefRefPtr<CefExtension> extension) {}
///
/// Called after the CefExtension::Unload request has completed.
///
/*--cef()--*/
virtual void OnExtensionUnloaded(CefRefPtr<CefExtension> extension) {}
///
/// Called when an extension needs a browser to host a background script
/// specified via the "background" manifest key. The browser will have no
/// visible window and cannot be displayed. |extension| is the extension that
/// is loading the background script. |url| is an internally generated
/// reference to an HTML page that will be used to load the background script
/// via a "<script>" src attribute. To allow creation of the browser
/// optionally modify |client| and |settings| and return false. To cancel
/// creation of the browser (and consequently cancel load of the background
/// script) return true. Successful creation will be indicated by a call to
/// CefLifeSpanHandler::OnAfterCreated, and CefBrowserHost::IsBackgroundHost
/// will return true for the resulting browser. See
/// https://developer.chrome.com/extensions/event_pages for more information
/// about extension background script usage.
///
/*--cef()--*/
virtual bool OnBeforeBackgroundBrowser(CefRefPtr<CefExtension> extension,
const CefString& url,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings) {
return false;
}
///
/// Called when an extension API (e.g. chrome.tabs.create) requests creation
/// of a new browser. |extension| and |browser| are the source of the API
/// call. |active_browser| may optionally be specified via the windowId
/// property or returned via the GetActiveBrowser() callback and provides the
/// default |client| and |settings| values for the new browser. |index| is the
/// position value optionally specified via the index property. |url| is the
/// URL that will be loaded in the browser. |active| is true if the new
/// browser should be active when opened. To allow creation of the browser
/// optionally modify |windowInfo|, |client| and |settings| and return false.
/// To cancel creation of the browser return true. Successful creation will be
/// indicated by a call to CefLifeSpanHandler::OnAfterCreated. Any
/// modifications to |windowInfo| will be ignored if |active_browser| is
/// wrapped in a CefBrowserView.
///
/*--cef()--*/
virtual bool OnBeforeBrowser(CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefBrowser> active_browser,
int index,
const CefString& url,
bool active,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings) {
return false;
}
///
/// Called when no tabId is specified to an extension API call that accepts a
/// tabId parameter (e.g. chrome.tabs.*). |extension| and |browser| are the
/// source of the API call. Return the browser that will be acted on by the
/// API call or return NULL to act on |browser|. The returned browser must
/// share the same CefRequestContext as |browser|. Incognito browsers should
/// not be considered unless the source extension has incognito access
/// enabled, in which case |include_incognito| will be true.
///
/*--cef()--*/
virtual CefRefPtr<CefBrowser> GetActiveBrowser(
CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
bool include_incognito) {
return nullptr;
}
///
/// Called when the tabId associated with |target_browser| is specified to an
/// extension API call that accepts a tabId parameter (e.g. chrome.tabs.*).
/// |extension| and |browser| are the source of the API call. Return true
/// to allow access of false to deny access. Access to incognito browsers
/// should not be allowed unless the source extension has incognito access
/// enabled, in which case |include_incognito| will be true.
///
/*--cef()--*/
virtual bool CanAccessBrowser(CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
bool include_incognito,
CefRefPtr<CefBrowser> target_browser) {
return true;
}
///
/// Called to retrieve an extension resource that would normally be loaded
/// from disk (e.g. if a file parameter is specified to
/// chrome.tabs.executeScript). |extension| and |browser| are the source of
/// the resource request. |file| is the requested relative file path. To
/// handle the resource request return true and execute |callback| either
/// synchronously or asynchronously. For the default behavior which reads the
/// resource from the extension directory on disk return false. Localization
/// substitutions will not be applied to resources handled via this method.
///
/*--cef()--*/
virtual bool GetExtensionResource(
CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
const CefString& file,
CefRefPtr<CefGetExtensionResourceCallback> callback) {
return false;
}
};
#endif // CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_

View File

@@ -111,7 +111,7 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
/// Views-hosted source browsers will create Views-hosted DevTools popups
/// unless |use_default_window| is set to to true. DevTools popups can be
/// blocked by returning true from CefCommandHandler::OnChromeCommand for
/// IDC_DEV_TOOLS. Only used with the Chrome runtime.
/// IDC_DEV_TOOLS. Only used with Chrome style.
///
/*--cef()--*/
virtual void OnBeforeDevToolsPopup(CefRefPtr<CefBrowser> browser,
@@ -131,34 +131,44 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) {}
///
/// Called when a browser has received a request to close. This may result
/// directly from a call to CefBrowserHost::*CloseBrowser() or indirectly if
/// the browser is parented to a top-level window created by CEF and the user
/// attempts to close that window (by clicking the 'X', for example). The
/// DoClose() method will be called after the JavaScript 'onunload' event has
/// been fired.
/// Called when an Alloy style browser is ready to be closed, meaning that the
/// close has already been initiated and that JavaScript unload handlers have
/// already executed or should be ignored. This may result directly from a
/// call to CefBrowserHost::[Try]CloseBrowser() or indirectly if the browser's
/// top-level parent window was created by CEF and the user attempts to
/// close that window (by clicking the 'X', for example). DoClose() will not
/// be called if the browser's host window/view has already been destroyed
/// (via parent window/view hierarchy tear-down, for example), as it is no
/// longer possible to customize the close behavior at that point.
///
/// An application should handle top-level owner window close notifications by
/// calling CefBrowserHost::TryCloseBrowser() or
/// An application should handle top-level parent window close notifications
/// by calling CefBrowserHost::TryCloseBrowser() or
/// CefBrowserHost::CloseBrowser(false) instead of allowing the window to
/// close immediately (see the examples below). This gives CEF an opportunity
/// to process the 'onbeforeunload' event and optionally cancel the close
/// to process JavaScript unload handlers and optionally cancel the close
/// before DoClose() is called.
///
/// When windowed rendering is enabled CEF will internally create a window or
/// view to host the browser. In that case returning false from DoClose() will
/// send the standard close notification to the browser's top-level owner
/// window (e.g. WM_CLOSE on Windows, performClose: on OS X, "delete_event" on
/// Linux or CefWindowDelegate::CanClose() callback from Views). If the
/// browser's host window/view has already been destroyed (via view hierarchy
/// tear-down, for example) then DoClose() will not be called for that browser
/// since is no longer possible to cancel the close.
/// When windowed rendering is enabled CEF will create an internal child
/// window/view to host the browser. In that case returning false from
/// DoClose() will send the standard close notification to the browser's
/// top-level parent window (e.g. WM_CLOSE on Windows, performClose: on OS X,
/// "delete_event" on Linux or CefWindowDelegate::CanClose() callback from
/// Views).
///
/// When windowed rendering is disabled returning false from DoClose() will
/// cause the browser object to be destroyed immediately.
/// When windowed rendering is disabled there is no internal window/view
/// and returning false from DoClose() will cause the browser object to be
/// destroyed immediately.
///
/// If the browser's top-level owner window requires a non-standard close
/// If the browser's top-level parent window requires a non-standard close
/// notification then send that notification from DoClose() and return true.
/// You are still required to complete the browser close as soon as possible
/// (either by calling [Try]CloseBrowser() or by proceeding with window/view
/// hierarchy tear-down), otherwise the browser will be left in a partially
/// closed state that interferes with proper functioning. Top-level windows
/// created on the browser process UI thread can alternately call
/// CefBrowserHost::IsReadyToBeClosed() in the close handler to check close
/// status instead of relying on custom DoClose() handling. See documentation
/// on that method for additional details.
///
/// The CefLifeSpanHandler::OnBeforeClose() method will be called after
/// DoClose() (if DoClose() is called) and immediately before the browser
@@ -174,7 +184,7 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
/// 1. User clicks the window close button which sends a close notification
/// to the application's top-level window.
/// 2. Application's top-level window receives the close notification and
/// calls TryCloseBrowser() (which internally calls CloseBrowser(false)).
/// calls TryCloseBrowser() (similar to calling CloseBrowser(false)).
/// TryCloseBrowser() returns false so the client cancels the window
/// close.
/// 3. JavaScript 'onbeforeunload' handler executes and shows the close
@@ -182,15 +192,18 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
/// CefJSDialogHandler::OnBeforeUnloadDialog()).
/// 4. User approves the close.
/// 5. JavaScript 'onunload' handler executes.
/// 6. CEF sends a close notification to the application's top-level window
/// (because DoClose() returned false by default).
/// 7. Application's top-level window receives the close notification and
/// 6. Application's DoClose() handler is called and returns false by
/// default.
/// 7. CEF sends a close notification to the application's top-level window
/// (because DoClose() returned false).
/// 8. Application's top-level window receives the close notification and
/// calls TryCloseBrowser(). TryCloseBrowser() returns true so the client
/// allows the window close.
/// 8. Application's top-level window is destroyed.
/// 9. Application's OnBeforeClose() handler is called and the browser object
/// 9. Application's top-level window is destroyed, triggering destruction
/// of the child browser window.
/// 10. Application's OnBeforeClose() handler is called and the browser object
/// is destroyed.
/// 10. Application exits by calling CefQuitMessageLoop() if no other browsers
/// 11. Application exits by calling CefQuitMessageLoop() if no other browsers
/// exist.
///
/// Example 2: Using CefBrowserHost::CloseBrowser(false) and implementing the
@@ -208,12 +221,15 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
/// 4. User approves the close.
/// 5. JavaScript 'onunload' handler executes.
/// 6. Application's DoClose() handler is called. Application will:
/// A. Set a flag to indicate that the next close attempt will be allowed.
/// A. Set a flag to indicate that the next top-level window close attempt
/// will be allowed.
/// B. Return false.
/// 7. CEF sends an close notification to the application's top-level window.
/// 7. CEF sends a close notification to the application's top-level window
/// (because DoClose() returned false).
/// 8. Application's top-level window receives the close notification and
/// allows the window to close based on the flag from #6B.
/// 9. Application's top-level window is destroyed.
/// allows the window to close based on the flag from #6A.
/// 9. Application's top-level window is destroyed, triggering destruction
/// of the child browser window.
/// 10. Application's OnBeforeClose() handler is called and the browser object
/// is destroyed.
/// 11. Application exits by calling CefQuitMessageLoop() if no other browsers

View File

@@ -93,8 +93,8 @@ class CefPermissionHandler : public virtual CefBaseRefCounted {
/// cef_media_access_permission_types_t that represent the requested
/// permissions. Return true and call CefMediaAccessCallback methods either in
/// this method or at a later time to continue or cancel the request. Return
/// false to proceed with default handling. With the Chrome runtime, default
/// handling will display the permission request UI. With the Alloy runtime,
/// false to proceed with default handling. With Chrome style, default
/// handling will display the permission request UI. With Alloy style,
/// default handling will deny the request. This method will not be called if
/// the "--enable-media-stream" command-line switch is used to grant all
/// permissions.
@@ -116,9 +116,9 @@ class CefPermissionHandler : public virtual CefBaseRefCounted {
/// cef_permission_request_types_t that represent the requested permissions.
/// Return true and call CefPermissionPromptCallback::Continue either in this
/// method or at a later time to continue or cancel the request. Return false
/// to proceed with default handling. With the Chrome runtime, default
/// handling will display the permission prompt UI. With the Alloy runtime,
/// default handling is CEF_PERMISSION_RESULT_IGNORE.
/// to proceed with default handling. With Chrome style, default handling will
/// display the permission prompt UI. With Alloy style, default handling is
/// CEF_PERMISSION_RESULT_IGNORE.
///
/*--cef()--*/
virtual bool OnShowPermissionPrompt(

View File

@@ -42,8 +42,6 @@
#include "include/cef_callback.h"
#include "include/cef_cookie.h"
#include "include/cef_extension.h"
#include "include/cef_extension_handler.h"
#include "include/cef_media_router.h"
#include "include/cef_preference.h"
#include "include/cef_values.h"
@@ -219,104 +217,6 @@ class CefRequestContext : public CefPreferenceManager {
virtual void ResolveHost(const CefString& origin,
CefRefPtr<CefResolveCallback> callback) = 0;
///
/// Load an extension.
///
/// If extension resources will be read from disk using the default load
/// implementation then |root_directory| should be the absolute path to the
/// extension resources directory and |manifest| should be NULL. If extension
/// resources will be provided by the client (e.g. via CefRequestHandler
/// and/or CefExtensionHandler) then |root_directory| should be a path
/// component unique to the extension (if not absolute this will be internally
/// prefixed with the PK_DIR_RESOURCES path) and |manifest| should contain the
/// contents that would otherwise be read from the "manifest.json" file on
/// disk.
///
/// The loaded extension will be accessible in all contexts sharing the same
/// storage (HasExtension returns true). However, only the context on which
/// this method was called is considered the loader (DidLoadExtension returns
/// true) and only the loader will receive CefRequestContextHandler callbacks
/// for the extension.
///
/// CefExtensionHandler::OnExtensionLoaded will be called on load success or
/// CefExtensionHandler::OnExtensionLoadFailed will be called on load failure.
///
/// If the extension specifies a background script via the "background"
/// manifest key then CefExtensionHandler::OnBeforeBackgroundBrowser will be
/// called to create the background browser. See that method for additional
/// information about background scripts.
///
/// For visible extension views the client application should evaluate the
/// manifest to determine the correct extension URL to load and then pass that
/// URL to the CefBrowserHost::CreateBrowser* function after the extension has
/// loaded. For example, the client can look for the "browser_action" manifest
/// key as documented at
/// https://developer.chrome.com/extensions/browserAction. Extension URLs take
/// the form "chrome-extension://<extension_id>/<path>".
///
/// Browsers that host extensions differ from normal browsers as follows:
/// - Can access chrome.* JavaScript APIs if allowed by the manifest. Visit
/// chrome://extensions-support for the list of extension APIs currently
/// supported by CEF.
/// - Main frame navigation to non-extension content is blocked.
/// - Pinch-zooming is disabled.
/// - CefBrowserHost::GetExtension returns the hosted extension.
/// - CefBrowserHost::IsBackgroundHost returns true for background hosts.
///
/// See https://developer.chrome.com/extensions for extension implementation
/// and usage documentation.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef(optional_param=manifest,optional_param=handler)--*/
virtual void LoadExtension(const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler) = 0;
///
/// Returns true if this context was used to load the extension identified by
/// |extension_id|. Other contexts sharing the same storage will also have
/// access to the extension (see HasExtension). This method must be called on
/// the browser process UI thread.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual bool DidLoadExtension(const CefString& extension_id) = 0;
///
/// Returns true if this context has access to the extension identified by
/// |extension_id|. This may not be the context that was used to load the
/// extension (see DidLoadExtension). This method must be called on the
/// browser process UI thread.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual bool HasExtension(const CefString& extension_id) = 0;
///
/// Retrieve the list of all extensions that this context has access to (see
/// HasExtension). |extension_ids| will be populated with the list of
/// extension ID values. Returns true on success. This method must be called
/// on the browser process UI thread.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual bool GetExtensions(std::vector<CefString>& extension_ids) = 0;
///
/// Returns the extension matching |extension_id| or NULL if no matching
/// extension is accessible in this context (see HasExtension). This method
/// must be called on the browser process UI thread.
///
/// WARNING: This method is deprecated and will be removed in ~M127.
///
/*--cef()--*/
virtual CefRefPtr<CefExtension> GetExtension(
const CefString& extension_id) = 0;
///
/// Returns the MediaRouter object associated with this context. If
/// |callback| is non-NULL it will be executed asnychronously on the UI thread

View File

@@ -226,10 +226,10 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
/// Called on the browser process UI thread when the render process is
/// unresponsive as indicated by a lack of input event processing for at
/// least 15 seconds. Return false for the default behavior which is an
/// indefinite wait with the Alloy runtime or display of the "Page
/// unresponsive" dialog with the Chrome runtime. Return true and don't
/// indefinite wait with Alloy style or display of the "Page
/// unresponsive" dialog with Chrome style. Return true and don't
/// execute the callback for an indefinite wait without display of the Chrome
/// runtime dialog. Return true and call CefUnresponsiveProcessCallback::Wait
/// style dialog. Return true and call CefUnresponsiveProcessCallback::Wait
/// either in this method or at a later time to reset the wait timer,
/// potentially triggering another call to this method if the process remains
/// unresponsive. Return true and call CefUnresponsiveProcessCallback::

109
include/cef_task_manager.h Normal file
View File

@@ -0,0 +1,109 @@
// Copyright (c) 2024 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_TASK_MANAGER_H_
#define CEF_INCLUDE_CEF_TASK_MANAGER_H_
#pragma once
#include <vector>
#include "include/cef_base.h"
///
/// Class that facilitates managing the browser-related tasks.
/// The methods of this class may only be called on the UI thread.
///
/*--cef(source=library)--*/
class CefTaskManager : public virtual CefBaseRefCounted {
public:
typedef std::vector<int64_t> TaskIdList;
typedef cef_task_type_t TaskType;
///
/// Returns the global task manager object.
/// Returns nullptr if the method was called from the incorrect thread.
///
/*--cef()--*/
static CefRefPtr<CefTaskManager> GetTaskManager();
///
/// Returns the number of tasks currently tracked by the task manager.
/// Returns 0 if the method was called from the incorrect thread.
///
/*--cef()--*/
virtual size_t GetTasksCount() = 0;
///
/// Gets the list of task IDs currently tracked by the task manager. Tasks
/// that share the same process id will always be consecutive. The list will
/// be sorted in a way that reflects the process tree: the browser process
/// will be first, followed by the gpu process if it exists. Related processes
/// (e.g., a subframe process and its parent) will be kept together if
/// possible. Callers can expect this ordering to be stable when a process is
/// added or removed. The task IDs are unique within the application lifespan.
/// Returns false if the method was called from the incorrect thread.
///
/*--cef(count_func=task_ids:GetTasksCount)--*/
virtual bool GetTaskIdsList(TaskIdList& task_ids) = 0;
///
/// Gets information about the task with |task_id|.
/// Returns true if the information about the task was successfully
/// retrieved and false if the |task_id| is invalid or the method was called
/// from the incorrect thread.
///
/*--cef()--*/
virtual bool GetTaskInfo(int64_t task_id, CefTaskInfo& info) = 0;
///
/// Attempts to terminate a task with |task_id|.
/// Returns false if the |task_id| is invalid, the call is made from an
/// incorrect thread, or if the task cannot be terminated.
///
/*--cef()--*/
virtual bool KillTask(int64_t task_id) = 0;
///
/// Returns the task ID associated with the main task for |browser_id|
/// (value from CefBrowser::GetIdentifier). Returns -1 if |browser_id| is
/// invalid, does not currently have an associated task, or the method was
/// called from the incorrect thread.
///
/*--cef()--*/
virtual int64_t GetTaskIdForBrowserId(int browser_id) = 0;
};
#endif // CEF_INCLUDE_CEF_TASK_MANAGER_H_

View File

@@ -520,12 +520,26 @@ class CefV8Value : public virtual CefBaseRefCounted {
/// or CefV8Accessor callback, or in combination with calling Enter() and
/// Exit() on a stored CefV8Context reference.
///
/// NOTE: Always returns nullptr when V8 sandbox is enabled.
///
/*--cef(optional_param=buffer)--*/
static CefRefPtr<CefV8Value> CreateArrayBuffer(
void* buffer,
size_t length,
CefRefPtr<CefV8ArrayBufferReleaseCallback> release_callback);
///
/// Create a new CefV8Value object of type ArrayBuffer which copies the
/// provided |buffer| of size |length| bytes.
/// This method should only be called from within the scope of a
/// CefRenderProcessHandler, CefV8Handler or CefV8Accessor callback, or in
/// combination with calling Enter() and Exit() on a stored CefV8Context
/// reference.
///
/*--cef(optional_param=buffer)--*/
static CefRefPtr<CefV8Value> CreateArrayBufferWithCopy(void* buffer,
size_t length);
///
/// Create a new CefV8Value object of type function. This method should only
/// be called from within the scope of a CefRenderProcessHandler, CefV8Handler

View File

@@ -0,0 +1,68 @@
// Copyright (c) 2024 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_DUMP_WITHOUT_CRASHING_INTERNAL_H_
#define CEF_INCLUDE_INTERNAL_CEF_DUMP_WITHOUT_CRASHING_INTERNAL_H_
#pragma once
#include <stddef.h>
#include "include/internal/cef_export.h"
#ifdef __cplusplus
extern "C" {
#endif
// 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.
///
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.
///
CEF_EXPORT int cef_dump_without_crashing_unthrottled();
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // CEF_INCLUDE_INTERNAL_CEF_DUMP_WITHOUT_CRASHING_INTERNAL_H_

View File

@@ -235,15 +235,6 @@ typedef struct _cef_settings_t {
///
cef_string_t main_bundle_path;
#if !defined(DISABLE_ALLOY_BOOTSTRAP)
///
/// Set to true (1) to enable use of the Chrome runtime in CEF. This feature
/// is considered experimental and is not recommended for most users at this
/// time. See issue #2969 for details.
///
int chrome_runtime;
#endif
///
/// Set to true (1) to have the browser process message loop run in a separate
/// thread. If false (0) then the CefDoMessageLoopWork() function must be
@@ -290,9 +281,9 @@ typedef struct _cef_settings_t {
/// in root_cache_path). HTML5 databases such as localStorage will only
/// persist across sessions if a cache path is specified. Can be overridden
/// for individual CefRequestContext instances via the
/// CefRequestContextSettings.cache_path value. When using the Chrome runtime
/// any child directory value will be ignored and the "default" profile (also
/// a child directory) will be used instead.
/// CefRequestContextSettings.cache_path value. Any child directory value will
/// be ignored and the "default" profile (also a child directory) will be used
/// instead.
///
cef_string_t cache_path;
@@ -336,16 +327,6 @@ typedef struct _cef_settings_t {
///
int persist_session_cookies;
///
/// To persist user preferences as a JSON file in the cache path directory set
/// this value to true (1). A |cache_path| value must also be specified
/// to enable this feature. Also configurable using the
/// "persist-user-preferences" command-line switch. Can be overridden for
/// individual CefRequestContext instances via the
/// CefRequestContextSettings.persist_user_preferences value.
///
int persist_user_preferences;
///
/// Value that will be returned as the User-Agent HTTP header. If empty the
/// default User-Agent string will be used. Also configurable using the
@@ -423,15 +404,6 @@ typedef struct _cef_settings_t {
///
cef_string_t locales_dir_path;
///
/// Set to true (1) to disable loading of pack files for resources and
/// locales. A resource bundle handler must be provided for the browser and
/// render processes via CefApp::GetResourceBundleHandler() if loading of pack
/// files is disabled. Also configurable using the "disable-pack-loading"
/// command- line switch.
///
int pack_loading_disabled;
///
/// Set to a value between 1024 and 65535 to enable remote debugging on the
/// specified port. Also configurable using the "remote-debugging-port"
@@ -496,7 +468,7 @@ typedef struct _cef_settings_t {
/// policies. On Windows, this is a registry key like
/// "SOFTWARE\\Policies\\Google\\Chrome". On MacOS, this is a bundle ID like
/// "com.google.Chrome". On Linux, this is an absolute directory path like
/// "/etc/opt/chrome/policies". Only supported with the Chrome runtime. See
/// "/etc/opt/chrome/policies". Only supported with Chrome style. See
/// https://support.google.com/chrome/a/answer/9037717 for details.
///
/// Chrome Browser Cloud Management integration, when enabled via the
@@ -510,10 +482,17 @@ typedef struct _cef_settings_t {
/// Specify an ID for an ICON resource that can be loaded from the main
/// executable and used when creating default Chrome windows such as DevTools
/// and Task Manager. If unspecified the default Chromium ICON (IDR_MAINFRAME
/// [101]) will be loaded from libcef.dll. Only supported with the Chrome
/// runtime on Windows.
/// [101]) will be loaded from libcef.dll. Only supported with Chrome style on
/// Windows.
///
int chrome_app_icon_id;
#if defined(OS_POSIX) && !defined(OS_ANDROID)
///
/// Specify whether signal handlers must be disabled on POSIX systems.
///
int disable_signal_handlers;
#endif
} cef_settings_t;
///
@@ -550,14 +529,6 @@ typedef struct _cef_request_context_settings_t {
///
int persist_session_cookies;
///
/// To persist user preferences as a JSON file in the cache path directory set
/// this value to true (1). Can be set globally using the
/// CefSettings.persist_user_preferences value. This value will be ignored if
/// |cache_path| is empty or if it matches the CefSettings.cache_path value.
///
int persist_user_preferences;
///
/// Comma delimited ordered list of language codes without any whitespace that
/// will be used in the "Accept-Language" HTTP request header and
@@ -720,14 +691,14 @@ typedef struct _cef_browser_settings_t {
///
/// Controls whether the Chrome status bubble will be used. Only supported
/// with the Chrome runtime. For details about the status bubble see
/// with Chrome style. For details about the status bubble see
/// https://www.chromium.org/user-experience/status-bubble/
///
cef_state_t chrome_status_bubble;
///
/// Controls whether the Chrome zoom bubble will be shown when zooming. Only
/// supported with the Chrome runtime.
/// supported with Chrome style.
///
cef_state_t chrome_zoom_bubble;
} cef_browser_settings_t;
@@ -1401,7 +1372,7 @@ typedef enum {
///
/// User got to this page through a suggestion in the UI (for example, via the
/// destinations page). Chrome runtime only.
/// destinations page). Chrome style only.
///
TT_AUTO_BOOKMARK = 2,
@@ -1428,7 +1399,7 @@ typedef enum {
/// that did not look like a URL. For example, a match might have the URL
/// of a Google search result page, but appear like "Search Google for ...".
/// These are not quite the same as EXPLICIT navigations because the user
/// didn't type or see the destination URL. Chrome runtime only.
/// didn't type or see the destination URL. Chrome style only.
/// See also TT_KEYWORD.
///
TT_GENERATED = 5,
@@ -1438,7 +1409,7 @@ typedef enum {
/// loaded in a toplevel frame. For example, opening a tab to show the ASH
/// screen saver, opening the devtools window, opening the NTP after the safe
/// browsing warning, opening web-based dialog boxes are examples of
/// AUTO_TOPLEVEL navigations. Chrome runtime only.
/// AUTO_TOPLEVEL navigations. Chrome style only.
///
TT_AUTO_TOPLEVEL = 6,
@@ -1465,13 +1436,13 @@ typedef enum {
/// the url 'http://' + keyword. For example, if you do a tab-to-search
/// against wikipedia the generated url has a transition qualifer of
/// TT_KEYWORD, and TemplateURLModel generates a visit for 'wikipedia.org'
/// with a transition type of TT_KEYWORD_GENERATED. Chrome runtime only.
/// with a transition type of TT_KEYWORD_GENERATED. Chrome style only.
///
TT_KEYWORD = 9,
///
/// Corresponds to a visit generated for a keyword. See description of
/// TT_KEYWORD for more details. Chrome runtime only.
/// TT_KEYWORD for more details. Chrome style only.
///
TT_KEYWORD_GENERATED = 10,
@@ -1501,14 +1472,13 @@ typedef enum {
TT_DIRECT_LOAD_FLAG = 0x02000000,
///
/// User is navigating to the home page. Chrome runtime only.
/// User is navigating to the home page. Chrome style only.
///
TT_HOME_PAGE_FLAG = 0x04000000,
///
/// The transition originated from an external application; the exact
/// definition of this is embedder dependent. Chrome runtime and
/// extension system only.
/// definition of this is embedder dependent. Chrome style only.
///
TT_FROM_API_FLAG = 0x08000000,
@@ -1884,6 +1854,34 @@ typedef struct _cef_screen_info_t {
cef_rect_t available_rect;
} cef_screen_info_t;
///
/// Linux window properties, such as X11's WM_CLASS or Wayland's app_id.
/// Those are passed to CefWindowDelegate, so the client can set them
/// for the CefWindow's top-level. Thus, allowing window managers to correctly
/// display the application's information (e.g., icons).
///
typedef struct _cef_linux_window_properties_t {
///
/// Main window's Wayland's app_id
///
cef_string_t wayland_app_id;
///
/// Main window's WM_CLASS_CLASS in X11
///
cef_string_t wm_class_class;
///
/// Main window's WM_CLASS_NAME in X11
///
cef_string_t wm_class_name;
///
/// Main window's WM_WINDOW_ROLE in X11
///
cef_string_t wm_role_name;
} cef_linux_window_properties_t;
///
/// Supported menu IDs. Non-English translations can be provided for the
/// IDS_MENU_* strings in CefResourceBundleHandler::GetLocalizedString().
@@ -3488,7 +3486,8 @@ typedef enum {
CEF_CPAIT_PRICE_READ_ANYTHING,
CEF_CPAIT_PRODUCT_SPECIFICATIONS,
CEF_CPAIT_LENS_OVERLAY,
CEF_CPAIT_MAX_VALUE = CEF_CPAIT_LENS_OVERLAY,
CEF_CPAIT_DISCOUNTS,
CEF_CPAIT_MAX_VALUE = CEF_CPAIT_DISCOUNTS,
} cef_chrome_page_action_icon_type_t;
///
@@ -3613,7 +3612,7 @@ typedef enum {
///
/// Permission types used with OnShowPermissionPrompt. Some types are
/// platform-specific or only supported with the Chrome runtime. Should be kept
/// platform-specific or only supported with Chrome style. Should be kept
/// in sync with Chromium's permissions::RequestType type.
///
typedef enum {
@@ -3628,20 +3627,22 @@ typedef enum {
CEF_PERMISSION_TYPE_DISK_QUOTA = 1 << 7,
CEF_PERMISSION_TYPE_LOCAL_FONTS = 1 << 8,
CEF_PERMISSION_TYPE_GEOLOCATION = 1 << 9,
CEF_PERMISSION_TYPE_IDENTITY_PROVIDER = 1 << 10,
CEF_PERMISSION_TYPE_IDLE_DETECTION = 1 << 11,
CEF_PERMISSION_TYPE_MIC_STREAM = 1 << 12,
CEF_PERMISSION_TYPE_MIDI_SYSEX = 1 << 13,
CEF_PERMISSION_TYPE_MULTIPLE_DOWNLOADS = 1 << 14,
CEF_PERMISSION_TYPE_NOTIFICATIONS = 1 << 15,
CEF_PERMISSION_TYPE_KEYBOARD_LOCK = 1 << 16,
CEF_PERMISSION_TYPE_POINTER_LOCK = 1 << 17,
CEF_PERMISSION_TYPE_PROTECTED_MEDIA_IDENTIFIER = 1 << 18,
CEF_PERMISSION_TYPE_REGISTER_PROTOCOL_HANDLER = 1 << 19,
CEF_PERMISSION_TYPE_STORAGE_ACCESS = 1 << 20,
CEF_PERMISSION_TYPE_VR_SESSION = 1 << 21,
CEF_PERMISSION_TYPE_WINDOW_MANAGEMENT = 1 << 22,
CEF_PERMISSION_TYPE_FILE_SYSTEM_ACCESS = 1 << 23,
CEF_PERMISSION_TYPE_HAND_TRACKING = 1 << 10,
CEF_PERMISSION_TYPE_IDENTITY_PROVIDER = 1 << 11,
CEF_PERMISSION_TYPE_IDLE_DETECTION = 1 << 12,
CEF_PERMISSION_TYPE_MIC_STREAM = 1 << 13,
CEF_PERMISSION_TYPE_MIDI_SYSEX = 1 << 14,
CEF_PERMISSION_TYPE_MULTIPLE_DOWNLOADS = 1 << 15,
CEF_PERMISSION_TYPE_NOTIFICATIONS = 1 << 16,
CEF_PERMISSION_TYPE_KEYBOARD_LOCK = 1 << 17,
CEF_PERMISSION_TYPE_POINTER_LOCK = 1 << 18,
CEF_PERMISSION_TYPE_PROTECTED_MEDIA_IDENTIFIER = 1 << 19,
CEF_PERMISSION_TYPE_REGISTER_PROTOCOL_HANDLER = 1 << 20,
CEF_PERMISSION_TYPE_STORAGE_ACCESS = 1 << 21,
CEF_PERMISSION_TYPE_VR_SESSION = 1 << 22,
CEF_PERMISSION_TYPE_WEB_APP_INSTALLATION = 1 << 23,
CEF_PERMISSION_TYPE_WINDOW_MANAGEMENT = 1 << 24,
CEF_PERMISSION_TYPE_FILE_SYSTEM_ACCESS = 1 << 25,
} cef_permission_request_types_t;
///
@@ -3849,6 +3850,67 @@ typedef enum {
CEF_COLOR_VARIANT_EXPRESSIVE,
} cef_color_variant_t;
///
/// Specifies the task type variants supported by CefTaskManager.
/// Should be kept in sync with Chromium's task_manager::Task::Type type.
///
typedef enum {
CEF_TASK_TYPE_UNKNOWN = 0,
/// The main browser process.
CEF_TASK_TYPE_BROWSER,
/// A graphics process.
CEF_TASK_TYPE_GPU,
/// A Linux zygote process.
CEF_TASK_TYPE_ZYGOTE,
/// A browser utility process.
CEF_TASK_TYPE_UTILITY,
/// A normal WebContents renderer process.
CEF_TASK_TYPE_RENDERER,
/// An extension or app process.
CEF_TASK_TYPE_EXTENSION,
/// A browser plugin guest process.
CEF_TASK_TYPE_GUEST,
/// A plugin process.
CEF_TASK_TYPE_PLUGIN,
/// A sandbox helper process
CEF_TASK_TYPE_SANDBOX_HELPER,
/// A dedicated worker running on the renderer process.
CEF_TASK_TYPE_DEDICATED_WORKER,
/// A shared worker running on the renderer process.
CEF_TASK_TYPE_SHARED_WORKER,
/// A service worker running on the renderer process.
CEF_TASK_TYPE_SERVICE_WORKER,
} cef_task_type_t;
///
/// Structure representing task information provided by CefTaskManager.
///
typedef struct _cef_task_info_t {
/// The task ID.
int64_t id;
/// The task type.
cef_task_type_t type;
/// Set to true (1) if the task is killable.
int is_killable;
/// The task title.
cef_string_t title;
/// The CPU usage of the process on which the task is running. The value is
/// in the range zero to number_of_processors * 100%.
double cpu_usage;
/// The number of processors available on the system.
int number_of_processors;
/// The memory footprint of the task in bytes. A value of -1 means no valid
/// value is currently available.
int64_t memory;
/// The GPU memory usage of the task in bytes. A value of -1 means no valid
/// value is currently available.
int64_t gpu_memory;
/// Set to true (1) if this task process' GPU resource count is inflated
/// because it is counting other processes' resources (e.g, the GPU process
/// has this value set to true because it is the aggregate of all processes).
int is_gpu_memory_inflated;
} cef_task_info_t;
#ifdef __cplusplus
}
#endif

View File

@@ -37,7 +37,7 @@ extern "C" {
///
/// Supported content setting types. Some types are platform-specific or only
/// supported with the Chrome runtime. Should be kept in sync with Chromium's
/// supported with Chrome style. Should be kept in sync with Chromium's
/// ContentSettingsType type.
///
typedef enum {
@@ -438,12 +438,42 @@ typedef enum {
/// Website setting which is used for UnusedSitePermissionsService to store
/// auto-revoked notification permissions from abusive sites.
REVOKED_ABUSIVE_NOTIFICATION_PERMISSIONS,
CEF_CONTENT_SETTING_TYPE_REVOKED_ABUSIVE_NOTIFICATION_PERMISSIONS,
/// Content setting that controls tracking protection status per site.
/// BLOCK: Protections enabled. This is the default state.
/// ALLOW: Protections disabled.
TRACKING_PROTECTION,
CEF_CONTENT_SETTING_TYPE_TRACKING_PROTECTION,
/// With this permission, when the application calls `getDisplayMedia()`, a
/// system audio track can be returned without showing the display media
/// selection picker. The application can explicitly specify
/// `systemAudio: 'exclude'` or `video: true` to still show the display media
/// selection picker if needed. Please note that the setting only works for
/// WebUI.
CEF_CONTENT_SETTING_TYPE_DISPLAY_MEDIA_SYSTEM_AUDIO,
/// Whether to use the higher-tier v8 optimizers for running JavaScript on the
/// page.
CEF_CONTENT_SETTING_TYPE_JAVASCRIPT_OPTIMIZER,
/// Content Setting for the Storage Access Headers persistent origin trial
/// that allows origins to opt into the storage access header behavior. Should
/// be scoped to `REQUESTING_ORIGIN_AND_TOP_SCHEMEFUL_SITE_SCOPE` in order to
/// correspond to the design of persistent origin trials. See also:
/// https://github.com/cfredric/storage-access-headers
/// ALLOW: storage access request headers will be attached to cross-site
/// requests, and url requests will look for response headers from
/// origins to retry a request or load with storage access.
/// BLOCK (default): no effect.
CEF_CONTENT_SETTING_TYPE_STORAGE_ACCESS_HEADER_ORIGIN_TRIAL,
/// Whether or not sites can request Hand Tracking data within WebXR Sessions.
CEF_CONTENT_SETTING_TYPE_HAND_TRACKING,
/// Website setting to indicate whether user has opted in to allow web apps to
/// install other web apps.
CEF_CONTENT_SETTING_TYPE_WEB_APP_INSTALLATION,
} cef_content_setting_types_t;
///

View File

@@ -36,20 +36,16 @@ extern "C" {
#endif
///
/// CEF supports both a Chrome runtime (based on the Chrome UI layer) and an
/// Alloy runtime (based on the Chromium content layer). The Chrome runtime
/// provides the full Chrome UI and browser functionality whereas the Alloy
/// runtime provides less default browser functionality but adds additional
/// client callbacks and support for windowless (off-screen) rendering. For
/// additional comparative details on runtime types see
/// CEF supports both a Chrome runtime style (based on the Chrome UI layer) and
/// an Alloy runtime style (based on the Chromium content layer). Chrome style
/// provides the full Chrome UI and browser functionality whereas Alloy style
/// provides less default browser functionality but adds additional client
/// callbacks and support for windowless (off-screen) rendering. The style type
/// is individually configured for each window/browser at creation time and
/// different styles can be mixed during runtime. For additional comparative
/// details on runtime styles see
/// https://bitbucket.org/chromiumembedded/cef/wiki/Architecture.md#markdown-header-cef3
///
/// Each runtime is composed of a bootstrap component and a style component. The
/// bootstrap component is configured via CefSettings.chrome_runtime and cannot
/// be changed after CefInitialize. The style component is individually
/// configured for each window/browser at creation time and, in combination with
/// the Chrome bootstrap, different styles can be mixed during runtime.
///
/// Windowless rendering will always use Alloy style. Windowed rendering with a
/// default window or client-provided parent window can configure the style via
/// CefWindowInfo.runtime_style. Windowed rendering with the Views framework can
@@ -63,20 +59,17 @@ extern "C" {
///
typedef enum {
///
/// Use the default runtime style. The default style will match the
/// CefSettings.chrome_runtime value in most cases. See above documentation
/// for exceptions.
/// Use the default style. See above documentation for exceptions.
///
CEF_RUNTIME_STYLE_DEFAULT,
///
/// Use the Chrome runtime style. Only supported with the Chrome runtime.
/// Use Chrome style.
///
CEF_RUNTIME_STYLE_CHROME,
///
/// Use the Alloy runtime style. Supported with both the Alloy and Chrome
/// runtime.
/// Use Alloy style.
///
CEF_RUNTIME_STYLE_ALLOY,
} cef_runtime_style_t;

View File

@@ -387,9 +387,6 @@ struct CefSettingsTraits {
&target->framework_dir_path, copy);
cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length,
&target->main_bundle_path, copy);
#if !defined(DISABLE_ALLOY_BOOTSTRAP)
target->chrome_runtime = src->chrome_runtime;
#endif
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
target->external_message_pump = src->external_message_pump;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
@@ -400,7 +397,6 @@ struct CefSettingsTraits {
cef_string_set(src->root_cache_path.str, src->root_cache_path.length,
&target->root_cache_path, copy);
target->persist_session_cookies = src->persist_session_cookies;
target->persist_user_preferences = src->persist_user_preferences;
cef_string_set(src->user_agent.str, src->user_agent.length,
&target->user_agent, copy);
@@ -419,7 +415,6 @@ struct CefSettingsTraits {
&target->resources_dir_path, copy);
cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
&target->locales_dir_path, copy);
target->pack_loading_disabled = src->pack_loading_disabled;
target->remote_debugging_port = src->remote_debugging_port;
target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
target->background_color = src->background_color;
@@ -437,6 +432,10 @@ struct CefSettingsTraits {
cef_string_set(src->chrome_policy_id.str, src->chrome_policy_id.length,
&target->chrome_policy_id, copy);
target->chrome_app_icon_id = src->chrome_app_icon_id;
#if defined(OS_POSIX) && !defined(OS_ANDROID)
target->disable_signal_handlers = src->disable_signal_handlers;
#endif
}
};
@@ -462,7 +461,6 @@ struct CefRequestContextSettingsTraits {
cef_string_set(src->cache_path.str, src->cache_path.length,
&target->cache_path, copy);
target->persist_session_cookies = src->persist_session_cookies;
target->persist_user_preferences = src->persist_user_preferences;
cef_string_set(src->accept_language_list.str,
src->accept_language_list.length,
&target->accept_language_list, copy);
@@ -762,4 +760,63 @@ class CefAcceleratedPaintInfo : public cef_accelerated_paint_info_t {
: cef_accelerated_paint_info_t(r) {}
};
struct CefTaskInfoTraits {
using struct_type = cef_task_info_t;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) { cef_string_clear(&s->title); }
static inline void set(const struct_type* src,
struct_type* target,
bool copy) {
target->id = src->id;
target->type = src->type;
target->is_killable = src->is_killable;
cef_string_set(src->title.str, src->title.length, &target->title, copy);
target->cpu_usage = src->cpu_usage;
target->number_of_processors = src->number_of_processors;
target->memory = src->memory;
target->gpu_memory = src->gpu_memory;
target->is_gpu_memory_inflated = src->is_gpu_memory_inflated;
}
};
///
/// Class representing task information.
///
using CefTaskInfo = CefStructBase<CefTaskInfoTraits>;
struct CefLinuxWindowPropertiesTraits {
using struct_type = cef_linux_window_properties_t;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->wayland_app_id);
cef_string_clear(&s->wm_class_class);
cef_string_clear(&s->wm_class_name);
cef_string_clear(&s->wm_role_name);
}
static inline void set(const struct_type* src,
struct_type* target,
bool copy) {
cef_string_set(src->wayland_app_id.str, src->wayland_app_id.length,
&target->wayland_app_id, copy);
cef_string_set(src->wm_class_class.str, src->wm_class_class.length,
&target->wm_class_class, copy);
cef_string_set(src->wm_class_name.str, src->wm_class_name.length,
&target->wm_class_name, copy);
cef_string_set(src->wm_role_name.str, src->wm_role_name.length,
&target->wm_role_name, copy);
}
};
///
/// Class representing the Linux-specific window properties required
/// for the window managers to correct group and display the window.
///
using CefLinuxWindowProperties = CefStructBase<CefLinuxWindowPropertiesTraits>;
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_

View File

@@ -82,7 +82,7 @@ class CefBrowserView : public CefView {
///
/// Returns the Chrome toolbar associated with this BrowserView. Only
/// supported when using the Chrome runtime. The CefBrowserViewDelegate::
/// supported when using Chrome style. The CefBrowserViewDelegate::
/// GetChromeToolbarType() method must return a value other than
/// CEF_CTT_NONE and the toolbar will not be available until after this
/// BrowserView is added to a CefWindow and CefViewDelegate::OnWindowChanged()
@@ -96,7 +96,7 @@ class CefBrowserView : public CefView {
/// content (`keydown` event handler) or CefKeyboardHandler. Normal priority
/// accelerators can be registered via CefWindow::SetAccelerator (with
/// |high_priority|=false) or internally for standard accelerators supported
/// by the Chrome runtime. If |prefer_accelerators| is true then the matching
/// by Chrome style. If |prefer_accelerators| is true then the matching
/// accelerator will be triggered immediately (calling
/// CefWindowDelegate::OnAccelerator or CefCommandHandler::OnChromeCommand
/// respectively) and the event will not be forwarded to the web content or

View File

@@ -132,8 +132,8 @@ class CefBrowserViewDelegate : public CefViewDelegate {
///
/// Called when |browser_view| receives a gesture command. Return true to
/// handle (or disable) a |gesture_command| or false to propagate the gesture
/// to the browser for default handling. With the Chrome runtime these
/// commands can also be handled via CefCommandHandler::OnChromeCommand.
/// to the browser for default handling. With Chrome style these commands can
/// also be handled via CefCommandHandler::OnChromeCommand.
///
/*--cef()--*/
virtual bool OnGestureCommand(CefRefPtr<CefBrowserView> browser_view,

View File

@@ -89,7 +89,7 @@ class CefWindowDelegate : public CefPanelDelegate {
/// the transition occurs asynchronously with |is_competed| set to false when
/// the transition starts and true after the transition completes. On other
/// platforms the transition occurs synchronously with |is_completed| set to
/// true after the transition completes. With the Alloy runtime you must also
/// true after the transition completes. With Alloy style you must also
/// implement CefDisplayHandler::OnFullscreenModeChange to handle fullscreen
/// transitions initiated by browser content.
///
@@ -251,12 +251,10 @@ class CefWindowDelegate : public CefPanelDelegate {
/// Chrome theme colors will be applied and this callback will be triggered
/// if/when a BrowserView is added to the Window's component hierarchy. Chrome
/// theme colors can be configured on a per-RequestContext basis using
/// CefRequestContext::SetChromeColorScheme or (Chrome runtime only) by
/// CefRequestContext::SetChromeColorScheme or (Chrome style only) by
/// visiting chrome://settings/manageProfile. Any theme changes using those
/// mechanisms will also trigger this callback. Chrome theme colors will be
/// persisted and restored from disk cache with the Chrome runtime, and with
/// the Alloy runtime if persist_user_preferences is set to true via
/// CefSettings or CefRequestContextSettings.
/// persisted and restored from disk cache.
///
/// This callback is not triggered on Window creation so clients that wish to
/// customize the initial native/OS theme must call CefWindow::SetThemeColor
@@ -280,6 +278,16 @@ class CefWindowDelegate : public CefPanelDelegate {
virtual cef_runtime_style_t GetWindowRuntimeStyle() {
return CEF_RUNTIME_STYLE_DEFAULT;
}
///
/// Return Linux-specific window properties for correctly handling by window
/// managers
///
/*--cef()--*/
virtual bool GetLinuxWindowProperties(CefRefPtr<CefWindow> window,
CefLinuxWindowProperties& properties) {
return false;
}
};
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_

View File

@@ -1,486 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_browser_context.h"
#include <map>
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "cef/libcef/browser/alloy/alloy_download_manager_delegate.h"
#include "cef/libcef/browser/extensions/extension_system.h"
#include "cef/libcef/browser/prefs/browser_prefs.h"
#include "cef/libcef/browser/ssl_host_state_delegate.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/cef_switches.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "chrome/browser/font_family_cache.h"
#include "chrome/browser/permissions/permission_manager_factory.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/reduce_accept_language/reduce_accept_language_factory.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
#include "chrome/common/pref_names.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/core/simple_dependency_manager.h"
#include "components/keyed_service/core/simple_key_map.h"
#include "components/permissions/permission_manager.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/user_prefs/user_prefs.h"
#include "components/visitedlink/browser/visitedlink_event_listener.h"
#include "components/visitedlink/browser/visitedlink_writer.h"
#include "components/zoom/zoom_event_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/constants.h"
#include "net/proxy_resolution/proxy_config_service.h"
#include "services/network/public/mojom/cors_origin_pattern.mojom.h"
using content::BrowserThread;
// Creates and manages VisitedLinkEventListener objects for each
// AlloyBrowserContext sharing the same VisitedLinkWriter.
class CefVisitedLinkListener : public visitedlink::VisitedLinkWriter::Listener {
public:
CefVisitedLinkListener() { DCHECK(listener_map_.empty()); }
CefVisitedLinkListener(const CefVisitedLinkListener&) = delete;
CefVisitedLinkListener& operator=(const CefVisitedLinkListener&) = delete;
void CreateListenerForContext(content::BrowserContext* context) {
CEF_REQUIRE_UIT();
auto listener =
std::make_unique<visitedlink::VisitedLinkEventListener>(context);
listener_map_.insert(std::make_pair(context, std::move(listener)));
}
void RemoveListenerForContext(content::BrowserContext* context) {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.find(context);
DCHECK(it != listener_map_.end());
listener_map_.erase(it);
}
// visitedlink::VisitedLinkWriter::Listener methods.
void NewTable(base::ReadOnlySharedMemoryRegion* table_region) override {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.begin();
for (; it != listener_map_.end(); ++it) {
it->second->NewTable(table_region);
}
}
void Add(visitedlink::VisitedLinkCommon::Fingerprint fingerprint) override {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.begin();
for (; it != listener_map_.end(); ++it) {
it->second->Add(fingerprint);
}
}
void Reset(bool invalidate_hashes) override {
CEF_REQUIRE_UIT();
ListenerMap::iterator it = listener_map_.begin();
for (; it != listener_map_.end(); ++it) {
it->second->Reset(invalidate_hashes);
}
}
private:
// Map of AlloyBrowserContext to the associated VisitedLinkEventListener.
using ListenerMap =
std::map<const content::BrowserContext*,
std::unique_ptr<visitedlink::VisitedLinkEventListener>>;
ListenerMap listener_map_;
};
AlloyBrowserContext::AlloyBrowserContext(
const CefRequestContextSettings& settings)
: CefBrowserContext(settings) {}
AlloyBrowserContext::~AlloyBrowserContext() = default;
bool AlloyBrowserContext::IsInitialized() const {
CEF_REQUIRE_UIT();
return !!key_;
}
void AlloyBrowserContext::StoreOrTriggerInitCallback(
base::OnceClosure callback) {
CEF_REQUIRE_UIT();
// Initialization is always synchronous.
std::move(callback).Run();
}
void AlloyBrowserContext::Initialize() {
CefBrowserContext::Initialize();
key_ = std::make_unique<ProfileKey>(cache_path_);
SimpleKeyMap::GetInstance()->Associate(this, key_.get());
// Initialize the PrefService object.
pref_service_ = browser_prefs::CreatePrefService(
this, cache_path_, !!settings_.persist_user_preferences);
// This must be called before creating any services to avoid hitting
// DependencyManager::AssertContextWasntDestroyed when creating/destroying
// multiple browser contexts (due to pointer address reuse).
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
this);
const bool extensions_enabled = extensions::ExtensionsEnabled();
if (extensions_enabled) {
// Create the custom ExtensionSystem first because other KeyedServices
// depend on it.
extension_system_ = static_cast<extensions::CefExtensionSystem*>(
extensions::ExtensionSystem::Get(this));
extension_system_->InitForRegularProfile(true);
// Make sure the ProcessManager is created so that it receives extension
// load notifications. This is necessary for the proper initialization of
// background/event pages.
extensions::ProcessManager::Get(this);
}
// Initialize visited links management.
base::FilePath visited_link_path;
if (!cache_path_.empty()) {
visited_link_path = cache_path_.Append(FILE_PATH_LITERAL("Visited Links"));
}
visitedlink_listener_ = new CefVisitedLinkListener;
visitedlink_master_ = std::make_unique<visitedlink::VisitedLinkWriter>(
visitedlink_listener_, this, !visited_link_path.empty(), false,
visited_link_path, 0);
visitedlink_listener_->CreateListenerForContext(this);
visitedlink_master_->Init();
// Initialize proxy configuration tracker.
pref_proxy_config_tracker_ = std::make_unique<PrefProxyConfigTrackerImpl>(
GetPrefs(), content::GetIOThreadTaskRunner({}));
// Spell checking support and possibly other subsystems retrieve the
// PrefService associated with a BrowserContext via UserPrefs::Get().
PrefService* pref_service = GetPrefs();
DCHECK(pref_service);
user_prefs::UserPrefs::Set(this, pref_service);
key_->SetPrefs(pref_service);
if (extensions_enabled) {
extension_system_->Init();
}
ChromePluginServiceFilter::GetInstance()->RegisterProfile(this);
}
void AlloyBrowserContext::Shutdown() {
CefBrowserContext::Shutdown();
// Send notifications to clean up objects associated with this Profile.
MaybeSendDestroyedNotification();
ChromePluginServiceFilter::GetInstance()->UnregisterProfile(this);
// Clear this reference before the associated KeyedServiceFactory is destroyed
// by PerformInterlockedTwoPhaseShutdown().
extension_system_ = nullptr;
// Remove any BrowserContextKeyedServiceFactory associations. This must be
// called before the ProxyService owned by AlloyBrowserContext is destroyed.
// The SimpleDependencyManager should always be passed after the
// BrowserContextDependencyManager. This is because the KeyedService instances
// in the BrowserContextDependencyManager's dependency graph can depend on the
// ones in the SimpleDependencyManager's graph.
DependencyManager::PerformInterlockedTwoPhaseShutdown(
BrowserContextDependencyManager::GetInstance(), this,
SimpleDependencyManager::GetInstance(), key_.get());
key_.reset();
SimpleKeyMap::GetInstance()->Dissociate(this);
// Shuts down the storage partitions associated with this browser context.
// This must be called before the browser context is actually destroyed
// and before a clean-up task for its corresponding IO thread residents
// (e.g. ResourceContext) is posted, so that the classes that hung on
// StoragePartition can have time to do necessary cleanups on IO thread.
ShutdownStoragePartitions();
visitedlink_listener_->RemoveListenerForContext(this);
// The FontFamilyCache references the ProxyService so delete it before the
// ProxyService is deleted.
SetUserData(&kFontFamilyCacheKey, nullptr);
pref_proxy_config_tracker_->DetachFromPrefService();
// Delete the download manager delegate here because otherwise we'll crash
// when it's accessed from the content::BrowserContext destructor.
if (download_manager_delegate_) {
download_manager_delegate_.reset(nullptr);
}
}
void AlloyBrowserContext::RemoveCefRequestContext(
CefRequestContextImpl* context) {
CEF_REQUIRE_UIT();
if (extensions::ExtensionsEnabled()) {
extension_system()->OnRequestContextDeleted(context);
}
// May result in |this| being deleted.
CefBrowserContext::RemoveCefRequestContext(context);
}
void AlloyBrowserContext::LoadExtension(
const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler,
CefRefPtr<CefRequestContext> loader_context) {
if (!extensions::ExtensionsEnabled()) {
if (handler) {
handler->OnExtensionLoadFailed(ERR_ABORTED);
}
return;
}
if (manifest && manifest->GetSize() > 0) {
CefDictionaryValueImpl* value_impl =
static_cast<CefDictionaryValueImpl*>(manifest.get());
auto value = value_impl->CopyValue();
extension_system()->LoadExtension(std::move(value.GetDict()),
root_directory, false /* builtin */,
loader_context, handler);
} else {
extension_system()->LoadExtension(root_directory, false /* builtin */,
loader_context, handler);
}
}
bool AlloyBrowserContext::GetExtensions(std::vector<CefString>& extension_ids) {
if (!extensions::ExtensionsEnabled()) {
return false;
}
extensions::CefExtensionSystem::ExtensionMap extension_map =
extension_system()->GetExtensions();
extensions::CefExtensionSystem::ExtensionMap::const_iterator it =
extension_map.begin();
for (; it != extension_map.end(); ++it) {
extension_ids.push_back(it->second->GetIdentifier());
}
return true;
}
CefRefPtr<CefExtension> AlloyBrowserContext::GetExtension(
const CefString& extension_id) {
if (!extensions::ExtensionsEnabled()) {
return nullptr;
}
return extension_system()->GetExtension(extension_id);
}
bool AlloyBrowserContext::UnloadExtension(const CefString& extension_id) {
DCHECK(extensions::ExtensionsEnabled());
return extension_system()->UnloadExtension(extension_id);
}
content::ClientHintsControllerDelegate*
AlloyBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;
}
ChromeZoomLevelPrefs* AlloyBrowserContext::GetZoomLevelPrefs() {
return static_cast<ChromeZoomLevelPrefs*>(
GetStoragePartition(nullptr)->GetZoomLevelDelegate());
}
scoped_refptr<network::SharedURLLoaderFactory>
AlloyBrowserContext::GetURLLoaderFactory() {
return GetDefaultStoragePartition()->GetURLLoaderFactoryForBrowserProcess();
}
base::FilePath AlloyBrowserContext::GetPath() {
return cache_path_;
}
base::FilePath AlloyBrowserContext::GetPath() const {
return cache_path_;
}
std::unique_ptr<content::ZoomLevelDelegate>
AlloyBrowserContext::CreateZoomLevelDelegate(
const base::FilePath& partition_path) {
if (cache_path_.empty()) {
return std::unique_ptr<content::ZoomLevelDelegate>();
}
return base::WrapUnique(new ChromeZoomLevelPrefs(
GetPrefs(), cache_path_, partition_path,
zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
}
content::DownloadManagerDelegate*
AlloyBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_) {
download_manager_delegate_ =
std::make_unique<AlloyDownloadManagerDelegate>(GetDownloadManager());
}
return download_manager_delegate_.get();
}
content::BrowserPluginGuestManager* AlloyBrowserContext::GetGuestManager() {
if (!extensions::ExtensionsEnabled()) {
return nullptr;
}
return guest_view::GuestViewManager::FromBrowserContext(this);
}
storage::SpecialStoragePolicy* AlloyBrowserContext::GetSpecialStoragePolicy() {
return nullptr;
}
content::PlatformNotificationService*
AlloyBrowserContext::GetPlatformNotificationService() {
return nullptr;
}
content::PushMessagingService* AlloyBrowserContext::GetPushMessagingService() {
return nullptr;
}
content::StorageNotificationService*
AlloyBrowserContext::GetStorageNotificationService() {
return nullptr;
}
content::SSLHostStateDelegate* AlloyBrowserContext::GetSSLHostStateDelegate() {
if (!ssl_host_state_delegate_) {
ssl_host_state_delegate_ = std::make_unique<CefSSLHostStateDelegate>();
}
return ssl_host_state_delegate_.get();
}
content::PermissionControllerDelegate*
AlloyBrowserContext::GetPermissionControllerDelegate() {
return PermissionManagerFactory::GetForProfile(this);
}
content::BackgroundFetchDelegate*
AlloyBrowserContext::GetBackgroundFetchDelegate() {
return nullptr;
}
content::BackgroundSyncController*
AlloyBrowserContext::GetBackgroundSyncController() {
return nullptr;
}
content::BrowsingDataRemoverDelegate*
AlloyBrowserContext::GetBrowsingDataRemoverDelegate() {
return nullptr;
}
content::ReduceAcceptLanguageControllerDelegate*
AlloyBrowserContext::GetReduceAcceptLanguageControllerDelegate() {
return ReduceAcceptLanguageFactory::GetForProfile(this);
}
PrefService* AlloyBrowserContext::GetPrefs() {
return pref_service_.get();
}
const PrefService* AlloyBrowserContext::GetPrefs() const {
return pref_service_.get();
}
ProfileKey* AlloyBrowserContext::GetProfileKey() const {
DCHECK(key_);
return key_.get();
}
policy::SchemaRegistryService*
AlloyBrowserContext::GetPolicySchemaRegistryService() {
DCHECK(false);
return nullptr;
}
policy::UserCloudPolicyManager*
AlloyBrowserContext::GetUserCloudPolicyManager() {
DCHECK(false);
return nullptr;
}
policy::ProfileCloudPolicyManager*
AlloyBrowserContext::GetProfileCloudPolicyManager() {
DCHECK(false);
return nullptr;
}
policy::CloudPolicyManager* AlloyBrowserContext::GetCloudPolicyManager() {
DCHECK(false);
return nullptr;
}
policy::ProfilePolicyConnector*
AlloyBrowserContext::GetProfilePolicyConnector() {
DCHECK(false);
return nullptr;
}
const policy::ProfilePolicyConnector*
AlloyBrowserContext::GetProfilePolicyConnector() const {
DCHECK(false);
return nullptr;
}
bool AlloyBrowserContext::IsNewProfile() const {
DCHECK(false);
return false;
}
void AlloyBrowserContext::RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) {
// Called when visited links will not or cannot be loaded from disk.
enumerator->OnComplete(true);
}
void AlloyBrowserContext::BuildVisitedLinkTable(
const scoped_refptr<VisitedLinkEnumerator>& enumerator) {
// Called when visited links will not or cannot be loaded from disk.
enumerator->OnVisitedLinkComplete(true);
}
DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() {
CEF_REQUIRE_UIT();
if (!download_prefs_) {
download_prefs_ = std::make_unique<DownloadPrefs>(this);
}
return download_prefs_.get();
}
void AlloyBrowserContext::AddVisitedURLs(
const GURL& url,
const std::vector<GURL>& redirect_chain,
ui::PageTransition /*transition*/) {
if (!redirect_chain.empty()) {
visitedlink_master_->AddURLs(redirect_chain);
} else {
visitedlink_master_->AddURL(url);
}
}

View File

@@ -1,148 +0,0 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_
#pragma once
#include "base/memory/raw_ptr.h"
#include "cef/include/cef_request_context_handler.h"
#include "cef/libcef/browser/alloy/chrome_profile_alloy.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/request_context_handler_map.h"
#include "chrome/browser/download/download_prefs.h"
#include "components/proxy_config/pref_proxy_config_tracker.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
class AlloyDownloadManagerDelegate;
class CefSSLHostStateDelegate;
class CefVisitedLinkListener;
class PrefService;
namespace extensions {
class CefExtensionSystem;
}
namespace visitedlink {
class VisitedLinkWriter;
}
// See CefBrowserContext documentation for usage. Only accessed on the UI thread
// unless otherwise indicated. ChromeProfileAlloy must be the first listed base
// class to avoid issues when casting between void* and content::BrowserContext*
// in Chromium code.
class AlloyBrowserContext : public ChromeProfileAlloy,
public CefBrowserContext,
public visitedlink::VisitedLinkDelegate {
public:
explicit AlloyBrowserContext(const CefRequestContextSettings& settings);
AlloyBrowserContext(const AlloyBrowserContext&) = delete;
AlloyBrowserContext& operator=(const AlloyBrowserContext&) = delete;
// CefBrowserContext overrides.
content::BrowserContext* AsBrowserContext() override { return this; }
Profile* AsProfile() override { return this; }
bool IsInitialized() const override;
void StoreOrTriggerInitCallback(base::OnceClosure callback) override;
void Initialize() override;
void Shutdown() override;
void RemoveCefRequestContext(CefRequestContextImpl* context) override;
void LoadExtension(const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler,
CefRefPtr<CefRequestContext> loader_context) override;
bool GetExtensions(std::vector<CefString>& extension_ids) override;
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
bool UnloadExtension(const CefString& extension_id) override;
void AddVisitedURLs(const GURL& url,
const std::vector<GURL>& redirect_chain,
ui::PageTransition transition) override;
// content::BrowserContext overrides.
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
base::FilePath GetPath() override;
base::FilePath GetPath() const override;
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath& partition_path) override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::PlatformNotificationService* GetPlatformNotificationService()
override;
content::PushMessagingService* GetPushMessagingService() override;
content::StorageNotificationService* GetStorageNotificationService() override;
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::PermissionControllerDelegate* GetPermissionControllerDelegate()
override;
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
content::BackgroundSyncController* GetBackgroundSyncController() override;
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()
override;
content::ReduceAcceptLanguageControllerDelegate*
GetReduceAcceptLanguageControllerDelegate() override;
// Profile overrides.
ChromeZoomLevelPrefs* GetZoomLevelPrefs() override;
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
PrefService* GetPrefs() override;
bool AllowsBrowserWindows() const override { return false; }
const PrefService* GetPrefs() const override;
ProfileKey* GetProfileKey() const override;
policy::SchemaRegistryService* GetPolicySchemaRegistryService() override;
policy::UserCloudPolicyManager* GetUserCloudPolicyManager() override;
policy::ProfileCloudPolicyManager* GetProfileCloudPolicyManager() override;
policy::CloudPolicyManager* GetCloudPolicyManager() override;
policy::ProfilePolicyConnector* GetProfilePolicyConnector() override;
const policy::ProfilePolicyConnector* GetProfilePolicyConnector()
const override;
bool IsNewProfile() const override;
// Values checked in ProfileNetworkContextService::CreateNetworkContextParams
// when creating the NetworkContext.
bool ShouldRestoreOldSessionCookies() override {
return ShouldPersistSessionCookies();
}
bool ShouldPersistSessionCookies() const override {
return !!settings_.persist_session_cookies;
}
// visitedlink::VisitedLinkDelegate methods.
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
void BuildVisitedLinkTable(
const scoped_refptr<VisitedLinkEnumerator>& enumerator) override;
// Manages extensions.
extensions::CefExtensionSystem* extension_system() const {
return extension_system_;
}
// Called from DownloadPrefs::FromBrowserContext via
// alloy::GetDownloadPrefsFromBrowserContext.
DownloadPrefs* GetDownloadPrefs();
private:
~AlloyBrowserContext() override;
std::unique_ptr<PrefService> pref_service_;
std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
std::unique_ptr<AlloyDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_master_;
// |visitedlink_listener_| is owned by visitedlink_master_.
raw_ptr<CefVisitedLinkListener> visitedlink_listener_ = nullptr;
// Owned by the KeyedService system.
raw_ptr<extensions::CefExtensionSystem> extension_system_ = nullptr;
// The key to index KeyedService instances created by
// SimpleKeyedServiceFactory.
std::unique_ptr<ProfileKey> key_;
std::unique_ptr<DownloadPrefs> download_prefs_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_

View File

@@ -15,11 +15,11 @@
#include "cef/libcef/browser/alloy/browser_platform_delegate_alloy.h"
#include "cef/libcef/browser/audio_capturer.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/browser_guest_util.h"
#include "cef/libcef/browser/browser_info.h"
#include "cef/libcef/browser/browser_info_manager.h"
#include "cef/libcef/browser/browser_platform_delegate.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/extensions/browser_extensions_util.h"
#include "cef/libcef/browser/hang_monitor.h"
#include "cef/libcef/browser/media_access_query.h"
#include "cef/libcef/browser/osr/osr_util.h"
@@ -31,10 +31,11 @@
#include "cef/libcef/common/net/url_util.h"
#include "cef/libcef/common/request_impl.h"
#include "cef/libcef/common/values_impl.h"
#include "cef/libcef/features/runtime.h"
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h"
#include "chrome/common/webui_url_constants.h"
#include "components/input/native_web_keyboard_event.h"
#include "components/printing/browser/print_composite_client.h"
#include "components/zoom/page_zoom.h"
#include "content/browser/gpu/compositor_util.h"
#include "content/public/browser/desktop_media_id.h"
@@ -52,16 +53,53 @@
#include "net/base/net_errors.h"
#include "ui/events/base_event_utils.h"
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
#include "extensions/common/extension.h"
#endif
using content::KeyboardEventProcessingResult;
namespace {
static constexpr base::TimeDelta kRecentlyAudibleTimeout = base::Seconds(2);
// List of WebUI hosts that have been tested to work in Alloy-style browsers.
// Do not add new hosts to this list without also manually testing all related
// functionality in CEF.
const char* kAllowedWebUIHosts[] = {
chrome::kChromeUIAccessibilityHost,
content::kChromeUIBlobInternalsHost,
chrome::kChromeUIChromeURLsHost,
chrome::kChromeUICreditsHost,
content::kChromeUIGpuHost,
content::kChromeUIHistogramHost,
content::kChromeUIIndexedDBInternalsHost,
chrome::kChromeUILicenseHost,
content::kChromeUIMediaInternalsHost,
chrome::kChromeUINetExportHost,
chrome::kChromeUINetInternalsHost,
content::kChromeUINetworkErrorHost,
content::kChromeUINetworkErrorsListingHost,
chrome::kChromeUIPrintHost,
content::kChromeUIProcessInternalsHost,
content::kChromeUIResourcesHost,
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
chrome::kChromeUISandboxHost,
#endif
content::kChromeUIServiceWorkerInternalsHost,
chrome::kChromeUISystemInfoHost,
chrome::kChromeUITermsHost,
chrome::kChromeUIThemeHost,
content::kChromeUITracingHost,
chrome::kChromeUIVersionHost,
content::kChromeUIWebRTCInternalsHost,
};
bool IsAllowedWebUIHost(const std::string_view& host) {
for (auto& allowed_host : kAllowedWebUIHosts) {
if (base::EqualsCaseInsensitiveASCII(allowed_host, host)) {
return true;
}
}
return false;
}
} // namespace
// AlloyBrowserHostImpl static methods.
@@ -77,15 +115,9 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
// Expect runtime style to match.
CHECK(platform_delegate->IsAlloyStyle());
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
const bool is_devtools_popup = !!create_params.devtools_opener;
#else
const bool is_devtools_popup = false;
#endif
scoped_refptr<CefBrowserInfo> info =
CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
is_devtools_popup, platform_delegate->IsWindowless(),
/*is_devtools_popup=*/false, platform_delegate->IsWindowless(),
platform_delegate->IsPrintPreviewSupported(),
create_params.extra_info);
@@ -98,47 +130,18 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
auto request_context_impl =
static_cast<CefRequestContextImpl*>(create_params.request_context.get());
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
CefRefPtr<CefExtension> cef_extension;
if (create_params.extension) {
auto cef_browser_context = request_context_impl->GetBrowserContext();
cef_extension =
cef_browser_context->GetExtension(create_params.extension->id());
CHECK(cef_extension);
}
#endif
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
auto platform_delegate_ptr = platform_delegate.get();
#endif
CefRefPtr<AlloyBrowserHostImpl> browser = CreateInternal(
create_params.settings, create_params.client, web_contents,
own_web_contents, info,
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
FromBaseChecked(create_params.devtools_opener),
#else
/*opener=*/nullptr,
#endif
is_devtools_popup, request_context_impl, std::move(platform_delegate)
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
cef_extension
#endif
);
CefRefPtr<AlloyBrowserHostImpl> browser =
CreateInternal(create_params.settings, create_params.client, web_contents,
own_web_contents, info,
/*opener=*/nullptr, /*is_devtools_popup=*/false,
request_context_impl, std::move(platform_delegate));
if (!browser) {
return nullptr;
}
GURL url = url_util::MakeGURL(create_params.url, /*fixup=*/true);
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
if (create_params.extension) {
platform_delegate_ptr->CreateExtensionHost(
create_params.extension, url, create_params.extension_host_type);
} else
#endif
if (!url.is_empty()) {
if (!url.is_empty()) {
content::OpenURLParams params(url, content::Referrer(),
WindowOpenDisposition::CURRENT_TAB,
CefFrameHostImpl::kPageTransitionExplicit,
@@ -159,12 +162,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
CefRefPtr<AlloyBrowserHostImpl> opener,
bool is_devtools_popup,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
CefRefPtr<CefExtension> extension
#endif
) {
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate) {
CEF_REQUIRE_UIT();
DCHECK(web_contents);
DCHECK(browser_info);
@@ -195,12 +193,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
CefRefPtr<AlloyBrowserHostImpl> browser = new AlloyBrowserHostImpl(
settings, client, web_contents, browser_info, opener, request_context,
std::move(platform_delegate)
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
extension
#endif
);
std::move(platform_delegate));
browser->InitializeBrowser();
if (!browser->CreateHostWindow()) {
@@ -213,7 +206,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
if (opener && opener->platform_delegate_) {
// 1. Notify the opener browser's platform delegate. With Views this will
// result in a call to CefBrowserViewDelegate::OnPopupBrowserViewCreated().
// Do this first for consistency with the Chrome runtime.
// Do this first for consistency with Chrome style.
opener->platform_delegate_->PopupBrowserCreated(
browser->platform_delegate(), browser.get(), is_devtools_popup);
}
@@ -383,16 +376,6 @@ void AlloyBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
}
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
CefRefPtr<CefExtension> AlloyBrowserHostImpl::GetExtension() {
return extension_;
}
bool AlloyBrowserHostImpl::IsBackgroundHost() {
return is_background_host_;
}
#endif
bool AlloyBrowserHostImpl::CanExecuteChromeCommand(int command_id) {
return false;
}
@@ -568,6 +551,10 @@ void AlloyBrowserHostImpl::WindowDestroyed() {
CEF_REQUIRE_UIT();
DCHECK(!window_destroyed_);
window_destroyed_ = true;
// Destroy objects that may reference the window.
menu_manager_.reset(nullptr);
CloseBrowser(true);
}
@@ -619,16 +606,16 @@ void AlloyBrowserHostImpl::CancelContextMenu() {
bool AlloyBrowserHostImpl::MaybeAllowNavigation(
content::RenderFrameHost* opener,
const content::OpenURLParams& params) {
const bool is_guest_view = extensions::IsBrowserPluginGuest(
content::WebContents::FromRenderFrameHost(opener));
const bool is_guest_view =
IsBrowserPluginGuest(content::WebContents::FromRenderFrameHost(opener));
if (is_guest_view && !params.is_pdf &&
!params.url.SchemeIs(extensions::kExtensionScheme) &&
!params.url.SchemeIs(content::kChromeUIScheme)) {
// The PDF viewer will load the PDF extension in the guest view, and print
// preview will load chrome://print in the guest view. The PDF renderer
// used with PdfUnseasoned will set |params.is_pdf| when loading the PDF
// stream (see PdfNavigationThrottle::WillStartRequest). All other
// navigations are passed to the owner browser.
// stream (see PdfNavigationThrottle::WillStartRequest). All other guest
// view navigations are passed to the owner browser.
CEF_POST_TASK(CEF_UIT,
base::BindOnce(
base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
@@ -637,17 +624,17 @@ bool AlloyBrowserHostImpl::MaybeAllowNavigation(
return false;
}
if (!is_guest_view && params.url.SchemeIs(content::kChromeUIScheme) &&
!IsAllowedWebUIHost(params.url.host_piece())) {
// Block navigation to non-allowlisted WebUI pages.
LOG(WARNING) << "Navigation to " << params.url.spec()
<< " is blocked in Alloy-style browser.";
return false;
}
return true;
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
extensions::ExtensionHost* AlloyBrowserHostImpl::GetExtensionHost() const {
CEF_REQUIRE_UIT();
DCHECK(platform_delegate_);
return platform_delegate_->GetExtensionHost();
}
#endif
void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::OnSetFocus,
@@ -655,7 +642,7 @@ void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
return;
}
if (contents_delegate_->OnSetFocus(source)) {
if (contents_delegate_.OnSetFocus(source)) {
return;
}
@@ -667,13 +654,13 @@ void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
void AlloyBrowserHostImpl::EnterFullscreenModeForTab(
content::RenderFrameHost* requesting_frame,
const blink::mojom::FullscreenOptions& options) {
contents_delegate_->EnterFullscreenModeForTab(requesting_frame, options);
contents_delegate_.EnterFullscreenModeForTab(requesting_frame, options);
WasResized();
}
void AlloyBrowserHostImpl::ExitFullscreenModeForTab(
content::WebContents* web_contents) {
contents_delegate_->ExitFullscreenModeForTab(web_contents);
contents_delegate_.ExitFullscreenModeForTab(web_contents);
WasResized();
}
@@ -940,12 +927,23 @@ bool AlloyBrowserHostImpl::IsAudioMuted() {
// content::WebContentsDelegate methods.
// -----------------------------------------------------------------------------
void AlloyBrowserHostImpl::PrintCrossProcessSubframe(
content::WebContents* web_contents,
const gfx::Rect& rect,
int document_cookie,
content::RenderFrameHost* subframe_host) const {
auto* client = printing::PrintCompositeClient::FromWebContents(web_contents);
if (client) {
client->PrintCrossProcessSubframe(rect, document_cookie, subframe_host);
}
}
content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>
navigation_handle_callback) {
auto target_contents = contents_delegate_->OpenURLFromTabEx(
auto target_contents = contents_delegate_.OpenURLFromTabEx(
source, params, navigation_handle_callback);
if (target_contents) {
// Start a navigation in the current browser that will result in the
@@ -958,15 +956,7 @@ content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
return nullptr;
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool AlloyBrowserHostImpl::ShouldAllowRendererInitiatedCrossProcessNavigation(
bool is_main_frame_navigation) {
return platform_delegate_->ShouldAllowRendererInitiatedCrossProcessNavigation(
is_main_frame_navigation);
}
#endif
void AlloyBrowserHostImpl::AddNewContents(
content::WebContents* AlloyBrowserHostImpl::AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
@@ -974,14 +964,16 @@ void AlloyBrowserHostImpl::AddNewContents(
const blink::mojom::WindowFeatures& window_features,
bool user_gesture,
bool* was_blocked) {
auto* new_contents_ptr = new_contents.get();
platform_delegate_->AddNewContents(source, std::move(new_contents),
target_url, disposition, window_features,
user_gesture, was_blocked);
return new_contents_ptr;
}
void AlloyBrowserHostImpl::LoadingStateChanged(content::WebContents* source,
bool should_show_loading_ui) {
contents_delegate_->LoadingStateChanged(source, should_show_loading_ui);
contents_delegate_.LoadingStateChanged(source, should_show_loading_ui);
}
void AlloyBrowserHostImpl::CloseContents(content::WebContents* source) {
@@ -1034,7 +1026,7 @@ void AlloyBrowserHostImpl::CloseContents(content::WebContents* source) {
void AlloyBrowserHostImpl::UpdateTargetURL(content::WebContents* source,
const GURL& url) {
contents_delegate_->UpdateTargetURL(source, url);
contents_delegate_.UpdateTargetURL(source, url);
}
bool AlloyBrowserHostImpl::DidAddMessageToConsole(
@@ -1043,8 +1035,8 @@ bool AlloyBrowserHostImpl::DidAddMessageToConsole(
const std::u16string& message,
int32_t line_no,
const std::u16string& source_id) {
return contents_delegate_->DidAddMessageToConsole(source, level, message,
line_no, source_id);
return contents_delegate_.DidAddMessageToConsole(source, level, message,
line_no, source_id);
}
void AlloyBrowserHostImpl::ContentsZoomChange(bool zoom_in) {
@@ -1079,13 +1071,13 @@ void AlloyBrowserHostImpl::CanDownload(
const GURL& url,
const std::string& request_method,
base::OnceCallback<void(bool)> callback) {
contents_delegate_->CanDownload(url, request_method, std::move(callback));
contents_delegate_.CanDownload(url, request_method, std::move(callback));
}
KeyboardEventProcessingResult AlloyBrowserHostImpl::PreHandleKeyboardEvent(
content::WebContents* source,
const input::NativeWebKeyboardEvent& event) {
return contents_delegate_->PreHandleKeyboardEvent(source, event);
return contents_delegate_.PreHandleKeyboardEvent(source, event);
}
bool AlloyBrowserHostImpl::HandleKeyboardEvent(
@@ -1096,7 +1088,7 @@ bool AlloyBrowserHostImpl::HandleKeyboardEvent(
return false;
}
if (contents_delegate_->HandleKeyboardEvent(source, event)) {
if (contents_delegate_.HandleKeyboardEvent(source, event)) {
return true;
}
@@ -1106,14 +1098,6 @@ bool AlloyBrowserHostImpl::HandleKeyboardEvent(
return false;
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool AlloyBrowserHostImpl::PreHandleGestureEvent(
content::WebContents* source,
const blink::WebGestureEvent& event) {
return platform_delegate_->PreHandleGestureEvent(source, event);
}
#endif
bool AlloyBrowserHostImpl::CanDragEnter(content::WebContents* source,
const content::DropData& data,
blink::DragOperationsMask mask) {
@@ -1186,12 +1170,8 @@ void AlloyBrowserHostImpl::WebContentsCreated(
// However, we need to install observers/delegates here.
CefRefPtr<AlloyBrowserHostImpl> browser = CreateInternal(
settings, client, new_contents, /*own_web_contents=*/false, info, opener,
/*is_devtools_popup=*/false, request_context, std::move(platform_delegate)
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
/*extension=*/nullptr
#endif
);
/*is_devtools_popup=*/false, request_context,
std::move(platform_delegate));
}
void AlloyBrowserHostImpl::RendererUnresponsive(
@@ -1275,13 +1255,6 @@ bool AlloyBrowserHostImpl::CheckMediaAccessPermission(
security_origin, type);
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool AlloyBrowserHostImpl::IsNeverComposited(
content::WebContents* web_contents) {
return platform_delegate_->IsNeverComposited(web_contents);
}
#endif
content::PictureInPictureResult AlloyBrowserHostImpl::EnterPictureInPicture(
content::WebContents* web_contents) {
if (!IsPictureInPictureSupported()) {
@@ -1299,12 +1272,7 @@ void AlloyBrowserHostImpl::ExitPictureInPicture() {
bool AlloyBrowserHostImpl::IsBackForwardCacheSupported(
content::WebContents& web_contents) {
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
return true;
#else
// Disabled with Alloy bootstrap due to issue #3237.
return cef::IsChromeRuntimeEnabled();
#endif
}
content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
@@ -1315,7 +1283,7 @@ content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
void AlloyBrowserHostImpl::DraggableRegionsChanged(
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
content::WebContents* contents) {
contents_delegate_->DraggableRegionsChanged(regions, contents);
contents_delegate_.DraggableRegionsChanged(regions, contents);
}
// content::WebContentsObserver methods.
@@ -1389,7 +1357,7 @@ void AlloyBrowserHostImpl::WebContentsDestroyed() {
// In case we're notified before the CefBrowserContentsDelegate,
// reset it first for consistent state in DestroyWebContents.
if (GetWebContents()) {
contents_delegate_->WebContentsDestroyed();
contents_delegate_.WebContentsDestroyed();
}
auto wc = web_contents();
@@ -1438,12 +1406,7 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<AlloyBrowserHostImpl> opener,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
CefRefPtr<CefExtension> extension
#endif
)
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate)
: CefBrowserHostBase(settings,
client,
std::move(platform_delegate),
@@ -1451,13 +1414,8 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
request_context),
content::WebContentsObserver(web_contents),
opener_(kNullWindowHandle),
is_windowless_(platform_delegate_->IsWindowless())
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
extension_(extension)
#endif
{
contents_delegate_->ObserveWebContents(web_contents);
is_windowless_(platform_delegate_->IsWindowless()) {
contents_delegate_.ObserveWebContents(web_contents);
if (opener.get() && !is_views_hosted_) {
// GetOpenerWindowHandle() only returns a value for non-views-hosted

View File

@@ -24,16 +24,12 @@
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
#include "extensions/common/mojom/view_type.mojom-forward.h"
#endif
class CefAudioCapturer;
class CefBrowserInfo;
class SiteInstance;
// CefBrowser implementation for the alloy runtime. Method calls are delegated
// to the CefPlatformDelegate or the WebContents as appropriate. All methods are
// CefBrowser implementation for Alloy style. Method calls are delegated to the
// CefPlatformDelegate or the WebContents as appropriate. All methods are
// thread-safe unless otherwise indicated.
//
// WebContentsDelegate: Interface for handling WebContents delegations. There is
@@ -124,10 +120,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
CefRefPtr<CefExtension> GetExtension() override;
bool IsBackgroundHost() override;
#endif
bool CanExecuteChromeCommand(int command_id) override;
void ExecuteChromeCommand(int command_id,
cef_window_open_disposition_t disposition) override;
@@ -169,11 +161,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void UpdateDragOperation(ui::mojom::DragOperation operation,
bool document_is_handling_drag);
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
// Accessors that must be called on the UI thread.
extensions::ExtensionHost* GetExtensionHost() const;
#endif
void OnSetFocus(cef_focus_source_t source) override;
bool ShowContextMenu(const content::ContextMenuParams& params);
@@ -187,22 +174,23 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
DestructionState destruction_state() const { return destruction_state_; }
// content::WebContentsDelegate methods.
void PrintCrossProcessSubframe(content::WebContents* web_contents,
const gfx::Rect& rect,
int document_cookie,
content::RenderFrameHost* subframe_host) const override;
content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>
navigation_handle_callback) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
bool is_main_frame_navigation) override;
#endif
void AddNewContents(content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const blink::mojom::WindowFeatures& window_features,
bool user_gesture,
bool* was_blocked) override;
content::WebContents* AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const blink::mojom::WindowFeatures& window_features,
bool user_gesture,
bool* was_blocked) override;
void LoadingStateChanged(content::WebContents* source,
bool should_show_loading_ui) override;
void CloseContents(content::WebContents* source) override;
@@ -225,10 +213,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
const input::NativeWebKeyboardEvent& event) override;
bool HandleKeyboardEvent(content::WebContents* source,
const input::NativeWebKeyboardEvent& event) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) override;
#endif
bool CanDragEnter(content::WebContents* source,
const content::DropData& data,
blink::DragOperationsMask operations_allowed) override;
@@ -282,9 +266,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const url::Origin& security_origin,
blink::mojom::MediaStreamType type) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool IsNeverComposited(content::WebContents* web_contents) override;
#endif
content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents) override;
void ExitPictureInPicture() override;
@@ -318,12 +299,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
CefRefPtr<AlloyBrowserHostImpl> opener,
bool is_devtools_popup,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
CefRefPtr<CefExtension> extension
#endif
);
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate);
AlloyBrowserHostImpl(
const CefBrowserSettings& settings,
@@ -332,12 +308,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<AlloyBrowserHostImpl> opener,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
,
CefRefPtr<CefExtension> extension
#endif
);
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate);
// Give the platform delegate an opportunity to create the host window.
bool CreateHostWindow();
@@ -348,10 +319,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
CefWindowHandle opener_;
const bool is_windowless_;
CefWindowHandle host_window_handle_ = kNullWindowHandle;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
CefRefPtr<CefExtension> extension_;
bool is_background_host_ = false;
#endif
// Represents the current browser destruction state. Only accessed on the UI
// thread.

View File

@@ -1,426 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_browser_main.h"
#include <stdint.h>
#include <memory>
#include <string>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/thread_pool.h"
#include "cef/libcef/browser/alloy/devtools/devtools_manager_delegate.h"
#include "cef/libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/browser_context_keyed_service_factories.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/extensions/extension_system_factory.h"
#include "cef/libcef/browser/file_dialog_runner.h"
#include "cef/libcef/browser/net/chrome_scheme_handler.h"
#include "cef/libcef/browser/permission_prompt.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/app_manager.h"
#include "cef/libcef/common/command_line_impl.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "cef/libcef/common/net/net_resource_provider.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_process_singleton.h"
#include "chrome/browser/media/router/chrome_media_router_factory.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/ui/color/chrome_color_mixers.h"
#include "chrome/browser/ui/javascript_dialogs/chrome_javascript_app_modal_dialog_view_factory.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "components/color/color_mixers.h"
#include "components/constrained_window/constrained_window_views.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/common/result_codes.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/constants.h"
#include "net/base/net_module.h"
#include "third_party/widevine/cdm/buildflags.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/color/color_provider_manager.h"
#include "ui/native_theme/native_theme.h"
#if BUILDFLAG(IS_LINUX)
#include "components/password_manager/core/browser/password_manager_switches.h"
#include "ui/base/ozone_buildflags.h"
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
#include "ui/events/devices/x11/touch_factory_x11.h"
#endif
#if defined(USE_DBUS)
#include "chrome/browser/ui/views/dark_mode_manager_linux.h"
#endif
#endif
#if defined(USE_AURA)
#include "ui/aura/env.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#include "ui/wm/core/wm_state.h"
#if BUILDFLAG(IS_WIN)
#include "base/enterprise_util.h"
#include "base/files/file_util.h"
#include "chrome/browser/chrome_browser_main_win.h"
#include "chrome/browser/win/parental_controls.h"
#endif
#endif // defined(USE_AURA)
#if BUILDFLAG(IS_MAC)
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_views_delegate.h"
#else
#include "ui/views/test/desktop_test_views_delegate.h"
#endif
#if defined(USE_AURA) && BUILDFLAG(IS_LINUX)
#include "ui/base/ime/init/input_method_initializer.h"
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
#include "components/os_crypt/sync/os_crypt.h"
#endif
#if BUILDFLAG(IS_LINUX)
#include "base/path_service.h"
#include "cef/libcef/browser/printing/print_dialog_linux.h"
#include "chrome/browser/themes/theme_service_aura_linux.h"
#include "chrome/browser/ui/views/theme_profile_key.h"
#include "chrome/grit/branded_strings.h"
#include "components/os_crypt/sync/key_storage_config_linux.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/linux/linux_ui.h"
#include "ui/linux/linux_ui_delegate.h"
#include "ui/linux/linux_ui_factory.h"
#include "ui/linux/linux_ui_getter.h"
#include "ui/ozone/public/ozone_platform.h"
#endif // BUILDFLAG(IS_LINUX)
#if BUILDFLAG(ENABLE_MEDIA_FOUNDATION_WIDEVINE_CDM)
#include "chrome/browser/component_updater/media_foundation_widevine_cdm_component_installer.h"
#endif
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
#endif
namespace {
#if BUILDFLAG(IS_LINUX)
class LinuxUiGetterImpl : public ui::LinuxUiGetter {
public:
LinuxUiGetterImpl() = default;
~LinuxUiGetterImpl() override = default;
ui::LinuxUiTheme* GetForWindow(aura::Window* window) override {
return window ? GetForProfile(GetThemeProfileForWindow(window)) : nullptr;
}
ui::LinuxUiTheme* GetForProfile(Profile* profile) override {
return ui::GetLinuxUiTheme(
ThemeServiceAuraLinux::GetSystemThemeForProfile(profile));
}
};
#endif // BUILDFLAG(IS_LINUX)
void ProcessSingletonNotificationCallbackImpl(
base::CommandLine command_line,
const base::FilePath& current_directory) {
// Drop the request if the browser process is already shutting down.
if (!CONTEXT_STATE_VALID()) {
return;
}
bool handled = false;
if (auto app = CefAppManager::Get()->GetApplication()) {
if (auto handler = app->GetBrowserProcessHandler()) {
CefRefPtr<CefCommandLineImpl> commandLinePtr(
new CefCommandLineImpl(command_line));
handled = handler->OnAlreadyRunningAppRelaunch(commandLinePtr.get(),
current_directory.value());
std::ignore = commandLinePtr->Detach(nullptr);
}
}
if (!handled) {
LOG(WARNING) << "Unhandled app relaunch; implement "
"CefBrowserProcessHandler::OnAlreadyRunningAppRelaunch.";
}
}
// Based on ChromeBrowserMainParts::ProcessSingletonNotificationCallback.
bool ProcessSingletonNotificationCallback(
base::CommandLine command_line,
const base::FilePath& current_directory) {
// Drop the request if the browser process is already shutting down.
// Note that we're going to post an async task below. Even if the browser
// process isn't shutting down right now, it could be by the time the task
// starts running. So, an additional check needs to happen when it starts.
// But regardless of any future check, there is no reason to post the task
// now if we know we're already shutting down.
if (!CONTEXT_STATE_VALID()) {
return false;
}
// In order to handle this request on Windows, there is platform specific
// code in browser_finder.cc that requires making outbound COM calls to
// cross-apartment shell objects (via IVirtualDesktopManager). That is not
// allowed within a SendMessage handler, which this function is a part of.
// So, we post a task to asynchronously finish the command line processing.
return base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
FROM_HERE, base::BindOnce(&ProcessSingletonNotificationCallbackImpl,
std::move(command_line), current_directory));
}
} // namespace
AlloyBrowserMainParts::AlloyBrowserMainParts() = default;
AlloyBrowserMainParts::~AlloyBrowserMainParts() {
constrained_window::SetConstrainedWindowViewsClient(nullptr);
}
void AlloyBrowserMainParts::ToolkitInitialized() {
SetConstrainedWindowViewsClient(
CreateAlloyConstrainedWindowViewsClient(nullptr));
#if defined(USE_AURA)
CHECK(aura::Env::GetInstance());
wm_state_ = std::make_unique<wm::WMState>();
#endif // defined(USE_AURA)
#if BUILDFLAG(IS_MAC)
views_delegate_ = std::make_unique<ChromeViewsDelegate>();
layout_provider_ = ChromeLayoutProvider::CreateLayoutProvider();
#else
views_delegate_ = std::make_unique<views::DesktopTestViewsDelegate>();
#endif
#if BUILDFLAG(IS_LINUX)
// Based on chrome_browser_main_extra_parts_views_linux.cc
// |linux_ui| will be nullptr with multi-threaded-message-loop. See
// CefUiThread::InitializeBrowserRunner.
if (auto linux_ui = ui::GetDefaultLinuxUi()) {
linux_ui_getter_ = std::make_unique<LinuxUiGetterImpl>();
ui::LinuxUi::SetInstance(linux_ui);
// Cursor theme changes are tracked by LinuxUI (via a CursorThemeManager
// implementation). Start observing them once it's initialized.
ui::CursorFactory::GetInstance()->ObserveThemeChanges();
}
#if defined(USE_DBUS)
if (!ui::NativeTheme::IsForcedDarkMode() &&
!ui::NativeTheme::IsForcedLightMode()) {
dark_mode_manager_ = std::make_unique<ui::DarkModeManagerLinux>();
}
#endif
auto printing_delegate = new CefPrintingContextLinuxDelegate();
auto default_delegate =
ui::PrintingContextLinuxDelegate::SetInstance(printing_delegate);
printing_delegate->SetDefaultDelegate(default_delegate);
#endif // BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_MAC)
if (base::FeatureList::IsEnabled(features::kViewsJSAppModalDialog)) {
InstallChromeJavaScriptAppModalDialogViewFactory();
} else {
InstallChromeJavaScriptAppModalDialogViewCocoaFactory();
}
#else
InstallChromeJavaScriptAppModalDialogViewFactory();
#endif
// On GTK that builds the native theme that, in turn, adds the GTK core color
// mixer; core mixers should all be added before we add chrome mixers.
ui::ColorProviderManager::Get().AppendColorProviderInitializer(
base::BindRepeating(color::AddComponentsColorMixers));
ui::ColorProviderManager::Get().AppendColorProviderInitializer(
base::BindRepeating(AddChromeColorMixers));
}
void AlloyBrowserMainParts::PreCreateMainMessageLoop() {
#if BUILDFLAG(IS_LINUX)
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif
#endif
#if BUILDFLAG(IS_WIN)
// Initialize the OSCrypt.
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);
bool os_crypt_init = OSCrypt::Init(local_state);
DCHECK(os_crypt_init);
// installer_util references strings that are normally compiled into
// setup.exe. In Chrome, these strings are in the locale files.
ChromeBrowserMainPartsWin::SetupInstallerUtilStrings();
#endif // BUILDFLAG(IS_WIN)
media_router::ChromeMediaRouterFactory::DoPlatformInit();
}
void AlloyBrowserMainParts::PostCreateMainMessageLoop() {
#if BUILDFLAG(IS_LINUX)
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
// Set up crypt config. This needs to be done before anything starts the
// network service, as the raw encryption key needs to be shared with the
// network service for encrypted cookie storage.
// Based on ChromeBrowserMainPartsLinux::PostCreateMainMessageLoop.
std::unique_ptr<os_crypt::Config> config =
std::make_unique<os_crypt::Config>();
// Forward to os_crypt the flag to use a specific password store.
config->store =
command_line->GetSwitchValueASCII(password_manager::kPasswordStore);
// Forward the product name
config->product_name = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
// OSCrypt can be disabled in a special settings file.
config->should_use_preference =
command_line->HasSwitch(password_manager::kEnableEncryptionSelection);
base::PathService::Get(chrome::DIR_USER_DATA, &config->user_data_path);
DCHECK(!config->user_data_path.empty());
OSCrypt::SetConfig(std::move(config));
#endif // BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_WIN)
base::SetExtraNoExecuteAllowedPath(chrome::DIR_USER_DATA);
#endif
}
int AlloyBrowserMainParts::PreCreateThreads() {
#if BUILDFLAG(IS_WIN)
PlatformInitialize();
#endif
net::NetModule::SetResourceProvider(&NetResourceProvider);
// Initialize these objects before IO access restrictions are applied and
// before the IO thread is started.
content::GpuDataManager::GetInstance();
SystemNetworkContextManager::CreateInstance(g_browser_process->local_state());
return 0;
}
void AlloyBrowserMainParts::PostCreateThreads() {
ChromeProcessSingleton::GetInstance()->StartWatching();
}
int AlloyBrowserMainParts::PreMainMessageLoopRun() {
#if defined(USE_AURA)
screen_ = views::CreateDesktopScreen();
#endif
#if BUILDFLAG(IS_MAC)
screen_ = std::make_unique<display::ScopedNativeScreen>();
#endif
if (extensions::ExtensionsEnabled()) {
// This should be set in ChromeBrowserProcessAlloy::Initialize.
DCHECK(extensions::ExtensionsBrowserClient::Get());
// Initialize extension global objects before creating the global
// BrowserContext.
extensions::CefExtensionSystemFactory::GetInstance();
}
// Register additional KeyedService factories here. See
// ChromeBrowserMainExtraPartsProfiles for details.
cef::EnsureBrowserContextKeyedServiceFactoriesBuilt();
background_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_visible_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_blocking_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
{base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
CefRequestContextSettings settings;
CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
// Create the global RequestContext.
global_request_context_ =
CefRequestContextImpl::CreateGlobalRequestContext(settings);
auto browser_context =
global_request_context_->GetBrowserContext()->AsBrowserContext();
CefDevToolsManagerDelegate::StartHttpHandler(browser_context);
#if BUILDFLAG(IS_WIN)
// Windows parental controls calls can be slow, so we do an early init here
// that calculates this value off of the UI thread.
InitializeWinParentalControls();
// These methods may call LoadLibrary and could trigger
// AssertBlockingAllowed() failures if executed at a later time on the UI
// thread.
base::IsManagedDevice();
base::IsEnterpriseDevice();
#endif // BUILDFLAG(IS_WIN)
scheme::RegisterWebUIControllerFactory();
file_dialog_runner::RegisterFactory();
permission_prompt::RegisterCreateCallback();
// Initialize theme configuration (high contrast, dark mode, etc).
ui::NativeTheme::GetInstanceForNativeUi();
#if BUILDFLAG(ENABLE_MEDIA_FOUNDATION_WIDEVINE_CDM) || \
BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kDisableComponentUpdate)) {
auto* const cus = g_browser_process->component_updater();
#if BUILDFLAG(ENABLE_MEDIA_FOUNDATION_WIDEVINE_CDM)
RegisterMediaFoundationWidevineCdmComponent(cus);
#endif
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
RegisterWidevineCdmComponent(cus);
#endif
}
#endif
// Allow ProcessSingleton to process messages.
// This is done here instead of just relying on the main message loop's start
// to avoid rendezvous in RunLoops that may precede MainMessageLoopRun.
ChromeProcessSingleton::GetInstance()->Unlock(
base::BindRepeating(&ProcessSingletonNotificationCallback));
return content::RESULT_CODE_NORMAL_EXIT;
}
void AlloyBrowserMainParts::PostMainMessageLoopRun() {
// NOTE: Destroy objects in reverse order of creation.
CefDevToolsManagerDelegate::StopHttpHandler();
ChromeProcessSingleton::GetInstance()->Cleanup();
// There should be no additional references to the global CefRequestContext
// during shutdown. Did you forget to release a CefBrowser reference?
DCHECK(global_request_context_->HasOneRef());
global_request_context_ = nullptr;
}
void AlloyBrowserMainParts::PostDestroyThreads() {
views_delegate_.reset();
#if BUILDFLAG(IS_MAC)
layout_provider_.reset();
#endif
}

View File

@@ -1,112 +0,0 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
#pragma once
#include <string_view>
#include "base/command_line.h"
#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_main_parts.h"
#include "ui/display/screen.h"
#if defined(USE_AURA)
namespace wm {
class WMState;
}
#endif
namespace views {
class ViewsDelegate;
#if BUILDFLAG(IS_MAC)
class LayoutProvider;
#endif
} // namespace views
#if BUILDFLAG(IS_LINUX)
namespace ui {
class LinuxUiGetter;
#if defined(USE_DBUS)
class DarkModeManagerLinux;
#endif
} // namespace ui
#endif
class CefDevToolsDelegate;
class AlloyBrowserMainParts : public content::BrowserMainParts {
public:
AlloyBrowserMainParts();
AlloyBrowserMainParts(const AlloyBrowserMainParts&) = delete;
AlloyBrowserMainParts& operator=(const AlloyBrowserMainParts&) = delete;
~AlloyBrowserMainParts() override;
void ToolkitInitialized() override;
void PreCreateMainMessageLoop() override;
void PostCreateMainMessageLoop() override;
int PreCreateThreads() override;
void PostCreateThreads() override;
int PreMainMessageLoopRun() override;
void PostMainMessageLoopRun() override;
void PostDestroyThreads() override;
CefRefPtr<CefRequestContextImpl> request_context() const {
return global_request_context_;
}
CefDevToolsDelegate* devtools_delegate() const { return devtools_delegate_; }
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const {
return background_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const {
return user_visible_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner()
const {
return user_blocking_task_runner_;
}
private:
#if BUILDFLAG(IS_WIN)
void PlatformInitialize();
#endif // BUILDFLAG(IS_WIN)
CefRefPtr<CefRequestContextImpl> global_request_context_;
raw_ptr<CefDevToolsDelegate> devtools_delegate_ = nullptr; // Deletes itself.
// Blocking task runners exposed via CefTaskRunner. For consistency with
// previous named thread behavior always execute all pending tasks before
// shutdown (e.g. to make sure critical data is saved to disk).
// |background_task_runner_| is also passed to SQLitePersistentCookieStore.
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner_;
#if defined(USE_AURA)
std::unique_ptr<display::Screen> screen_;
std::unique_ptr<wm::WMState> wm_state_;
#endif
std::unique_ptr<views::ViewsDelegate> views_delegate_;
#if BUILDFLAG(IS_MAC)
std::unique_ptr<display::ScopedNativeScreen> screen_;
std::unique_ptr<views::LayoutProvider> layout_provider_;
#endif
#if BUILDFLAG(IS_LINUX)
std::unique_ptr<ui::LinuxUiGetter> linux_ui_getter_;
#if defined(USE_DBUS)
std::unique_ptr<ui::DarkModeManagerLinux> dark_mode_manager_;
#endif
#endif
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_

View File

@@ -1,29 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_browser_main.h"
#include <Objbase.h>
#include <windows.h>
#include <commctrl.h>
#include "base/logging.h"
void AlloyBrowserMainParts::PlatformInitialize() {
HRESULT res;
// Initialize common controls.
res = CoInitialize(nullptr);
DCHECK(SUCCEEDED(res));
INITCOMMONCONTROLSEX InitCtrlEx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCtrlEx.dwICC = ICC_STANDARD_CLASSES;
InitCommonControlsEx(&InitCtrlEx);
// Start COM stuff.
res = OleInitialize(nullptr);
DCHECK(SUCCEEDED(res));
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,287 +0,0 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
#pragma once
#include <string>
#include <utility>
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "cef/include/cef_request_context_handler.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/web_contents.h"
#include "third_party/skia/include/core/SkColor.h"
class AlloyBrowserMainParts;
class CefDevToolsDelegate;
namespace content {
class SiteInstance;
} // namespace content
namespace extensions {
class Extension;
}
class AlloyContentBrowserClient : public content::ContentBrowserClient {
public:
AlloyContentBrowserClient();
~AlloyContentBrowserClient() override;
void CleanupOnUIThread();
// ContentBrowserClient implementation.
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
bool is_integration_test) override;
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
const GURL& site_url) override;
bool ShouldUseSpareRenderProcessHost(content::BrowserContext* browser_context,
const GURL& site_url) override;
bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context,
const GURL& effective_site_url) override;
bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
std::string_view scheme,
bool is_embedded_origin_secure) override;
bool ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
std::string_view scheme,
bool is_embedded_origin_secure) override;
void OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
const url::Origin& origin,
bool is_for_isolated_world,
network::mojom::URLLoaderFactoryParams* factory_params) override;
void GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) override;
void GetAdditionalViewSourceSchemes(
std::vector<std::string>* additional_schemes) override;
std::unique_ptr<ui::SelectFilePolicy> CreateSelectFilePolicy(
content::WebContents* web_contents) override;
void GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* additional_allowed_schemes) override;
bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) override;
bool IsHandledURL(const GURL& url) override;
void SiteInstanceGotProcessAndSite(
content::SiteInstance* site_instance) override;
void BindHostReceiverForRenderer(
content::RenderProcessHost* render_process_host,
mojo::GenericPendingReceiver receiver) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override;
std::string GetApplicationLocale() override;
scoped_refptr<network::SharedURLLoaderFactory>
GetSystemSharedURLLoaderFactory() override;
network::mojom::NetworkContext* GetSystemNetworkContext() override;
content::MediaObserver* GetMediaObserver() override;
content::SpeechRecognitionManagerDelegate*
CreateSpeechRecognitionManagerDelegate() override;
content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings(
content::BrowserContext* context) override;
void AllowCertificateError(
content::WebContents* web_contents,
int cert_error,
const net::SSLInfo& ssl_info,
const GURL& request_url,
bool is_main_frame_request,
bool strict_enforcement,
base::OnceCallback<void(content::CertificateRequestResultType)> callback)
override;
base::OnceClosure SelectClientCertificate(
content::BrowserContext* browser_context,
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList client_certs,
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
bool CanCreateWindow(content::RenderFrameHost* opener,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const url::Origin& source_origin,
content::mojom::WindowContainerType container_type,
const GURL& target_url,
const content::Referrer& referrer,
const std::string& frame_name,
WindowOpenDisposition disposition,
const blink::mojom::WindowFeatures& features,
bool user_gesture,
bool opener_suppressed,
bool* no_javascript_access) override;
void OverrideWebkitPrefs(content::WebContents* web_contents,
blink::web_pref::WebPreferences* prefs) override;
bool OverrideWebPreferencesAfterNavigation(
content::WebContents* web_contents,
blink::web_pref::WebPreferences* prefs) override;
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
std::string GetDefaultDownloadName() override;
std::unique_ptr<content::DevToolsManagerDelegate>
CreateDevToolsManagerDelegate() override;
void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* render_process_host) override;
void RegisterAssociatedInterfaceBindersForServiceWorker(
const content::ServiceWorkerVersionBaseInfo& service_worker_version_info,
blink::AssociatedInterfaceRegistry& associated_registry) override;
void RegisterAssociatedInterfaceBindersForRenderFrameHost(
content::RenderFrameHost& render_frame_host,
blink::AssociatedInterfaceRegistry& associated_registry) override;
std::vector<std::unique_ptr<content::NavigationThrottle>>
CreateThrottlesForNavigation(
content::NavigationHandle* navigation_handle) override;
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
CreateURLLoaderThrottles(
const network::ResourceRequest& request,
content::BrowserContext* browser_context,
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id,
std::optional<int64_t> navigation_id) override;
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
CreateURLLoaderThrottlesForKeepAlive(
const network::ResourceRequest& request,
content::BrowserContext* browser_context,
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
int frame_tree_node_id) override;
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
WillCreateURLLoaderRequestInterceptors(
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id,
int64_t navigation_id,
scoped_refptr<base::SequencedTaskRunner> navigation_response_task_runner)
override;
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
void GetAdditionalMappedFilesForChildProcess(
const base::CommandLine& command_line,
int child_process_id,
content::PosixFileDescriptorInfo* mappings) override;
#endif
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
content::BrowserContext* browser_context) override;
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
content::BrowserContext* browser_context,
const content::GlobalRequestID& request_id,
bool is_request_for_main_frame,
const GURL& url,
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback) override;
mojo::PendingRemote<network::mojom::URLLoaderFactory>
CreateNonNetworkNavigationURLLoaderFactory(const std::string& scheme,
int frame_tree_node_id) override;
void RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
int render_frame_id,
const std::optional<url::Origin>& request_initiator_origin,
NonNetworkURLLoaderFactoryMap* factories) override;
void WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,
content::RenderFrameHost* frame,
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
const net::IsolationInfo& isolation_info,
std::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
network::URLLoaderFactoryBuilder& factory_builder,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
header_client,
bool* bypass_redirect_checks,
bool* disable_secure_dns,
network::mojom::URLLoaderFactoryOverridePtr* factory_override,
scoped_refptr<base::SequencedTaskRunner> navigation_response_task_runner)
override;
void OnNetworkServiceCreated(
network::mojom::NetworkService* network_service) override;
bool ConfigureNetworkContextParams(
content::BrowserContext* context,
bool in_memory,
const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
cert_verifier::mojom::CertVerifierCreationParams*
cert_verifier_creation_params) override;
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
bool HandleExternalProtocol(
const GURL& url,
content::WebContents::Getter web_contents_getter,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
bool is_primary_main_frame,
bool is_in_fenced_frame_tree,
network::mojom::WebSandboxFlags sandbox_flags,
ui::PageTransition page_transition,
bool has_user_gesture,
const std::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
bool HandleExternalProtocol(
content::WebContents::Getter web_contents_getter,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
bool is_primary_main_frame,
bool is_in_fenced_frame_tree,
network::mojom::WebSandboxFlags sandbox_flags,
const network::ResourceRequest& request,
const std::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
std::unique_ptr<content::VideoOverlayWindow>
CreateWindowForVideoPictureInPicture(
content::VideoPictureInPictureWindowController* controller) override;
void RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override;
void RegisterBrowserInterfaceBindersForServiceWorker(
content::BrowserContext* browser_context,
const content::ServiceWorkerVersionBaseInfo& service_worker_version_info,
mojo::BinderMapWithContext<const content::ServiceWorkerVersionBaseInfo&>*
map) override;
base::FilePath GetSandboxedStorageServiceDataDirectory() override;
base::FilePath GetShaderDiskCacheDirectory() override;
base::FilePath GetGrShaderDiskCacheDirectory() override;
base::FilePath GetGraphiteDawnDiskCacheDirectory() override;
base::FilePath GetNetLogDefaultDirectory() override;
base::FilePath GetFirstPartySetsDirectory() override;
std::optional<base::FilePath> GetLocalTracesDirectory() override;
std::string GetProduct() override;
std::string GetChromeProduct() override;
std::string GetUserAgent() override;
std::unique_ptr<content::WebContentsViewDelegate> GetWebContentsViewDelegate(
content::WebContents* web_contents) override;
blink::UserAgentMetadata GetUserAgentMetadata() override;
base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers(
content::BrowserContext* browser_context) override;
void GetMediaDeviceIDSalt(
content::RenderFrameHost* rfh,
const net::SiteForCookies& site_for_cookies,
const blink::StorageKey& storage_key,
base::OnceCallback<void(bool, const std::string&)> callback) override;
void OnWebContentsCreated(content::WebContents* web_contents) override;
bool IsFindInPageDisabledForOrigin(const url::Origin& origin) override;
CefRefPtr<CefRequestContextImpl> request_context() const;
CefDevToolsDelegate* devtools_delegate() const;
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const;
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const;
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner() const;
private:
// Returns the extension or app associated with |site_instance| or NULL.
const extensions::Extension* GetExtension(
content::SiteInstance* site_instance);
raw_ptr<AlloyBrowserMainParts> browser_main_parts_ = nullptr;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_

View File

@@ -1,22 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_download_manager_delegate.h"
#include "chrome/common/chrome_constants.h"
#include "components/download/public/common/download_item.h"
AlloyDownloadManagerDelegate::AlloyDownloadManagerDelegate(
content::DownloadManager* manager)
: CefDownloadManagerDelegateImpl(manager, /*alloy_bootstrap=*/true) {}
void AlloyDownloadManagerDelegate::GetNextId(
content::DownloadIdCallback callback) {
static uint32_t next_id = download::DownloadItem::kInvalidId + 1;
std::move(callback).Run(next_id++);
}
std::string AlloyDownloadManagerDelegate::ApplicationClientIdForFileScanning() {
return std::string(chrome::kApplicationClientIDStringForAVScanning);
}

View File

@@ -1,26 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
#pragma once
#include "cef/libcef/browser/download_manager_delegate_impl.h"
// Specialization for the Alloy bootstrap.
class AlloyDownloadManagerDelegate : public CefDownloadManagerDelegateImpl {
public:
explicit AlloyDownloadManagerDelegate(content::DownloadManager* manager);
AlloyDownloadManagerDelegate(const AlloyDownloadManagerDelegate&) = delete;
AlloyDownloadManagerDelegate& operator=(const AlloyDownloadManagerDelegate&) =
delete;
private:
// DownloadManagerDelegate methods.
void GetNextId(content::DownloadIdCallback callback) override;
std::string ApplicationClientIdForFileScanning() override;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_

View File

@@ -1,18 +0,0 @@
// Copyright 2021 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/alloy/alloy_download_util.h"
#include "cef/libcef/browser/alloy/alloy_browser_context.h"
namespace alloy {
DownloadPrefs* GetDownloadPrefsFromBrowserContext(
content::BrowserContext* context) {
// This function is only called with Alloy bootstrap, so the static_cast is
// safe.
return static_cast<AlloyBrowserContext*>(context)->GetDownloadPrefs();
}
} // namespace alloy

View File

@@ -1,25 +0,0 @@
// Copyright 2021 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_ALLOY_ALLOY_DOWNLOAD_UTIL_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_UTIL_H_
#pragma once
#include "cef/libcef/features/features.h"
class DownloadPrefs;
namespace content {
class BrowserContext;
} // namespace content
namespace alloy {
// Called from DownloadPrefs::FromBrowserContext.
DownloadPrefs* GetDownloadPrefsFromBrowserContext(
content::BrowserContext* context);
} // namespace alloy
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_UTIL_H_

View File

@@ -1,21 +0,0 @@
// Copyright 2022 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/alloy_web_contents_view_delegate.h"
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "content/public/browser/web_contents.h"
AlloyWebContentsViewDelegate::AlloyWebContentsViewDelegate(
content::WebContents* web_contents)
: web_contents_(web_contents) {}
void AlloyWebContentsViewDelegate::ShowContextMenu(
content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) {
if (auto browser =
AlloyBrowserHostImpl::GetBrowserForContents(web_contents_)) {
browser->ShowContextMenu(params);
}
}

View File

@@ -1,33 +0,0 @@
// Copyright 2022 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_
#pragma once
#include "base/memory/raw_ptr.h"
#include "cef/include/internal/cef_ptr.h"
#include "content/public/browser/web_contents_view_delegate.h"
namespace content {
class WebContents;
}
class AlloyWebContentsViewDelegate : public content::WebContentsViewDelegate {
public:
explicit AlloyWebContentsViewDelegate(content::WebContents* web_contents);
AlloyWebContentsViewDelegate(const AlloyWebContentsViewDelegate&) = delete;
AlloyWebContentsViewDelegate& operator=(const AlloyWebContentsViewDelegate&) =
delete;
// WebContentsViewDelegate methods:
void ShowContextMenu(content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) override;
private:
const raw_ptr<content::WebContents> web_contents_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_

View File

@@ -8,13 +8,7 @@
#include "base/logging.h"
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "cef/libcef/browser/extensions/extension_background_host.h"
#include "cef/libcef/browser/extensions/extension_system.h"
#include "cef/libcef/browser/extensions/extension_view_host.h"
#include "cef/libcef/browser/extensions/extension_web_contents_observer.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "cef/libcef/common/net/url_util.h"
#include "cef/libcef/features/features.h"
#include "chrome/browser/task_manager/web_contents_tags.h"
#include "chrome/browser/ui/tab_helpers.h"
#include "components/find_in_page/find_tab_helper.h"
@@ -26,34 +20,10 @@
#include "pdf/pdf_features.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
#include "cef/libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h"
#include "cef/libcef/features/runtime_checks.h"
#include "chrome/browser/printing/printing_init.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
#include "components/permissions/permission_request_manager.h"
#include "components/zoom/zoom_controller.h"
#include "extensions/browser/extension_registry.h"
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
namespace {
const char kAttachedHelpersUserDataKey[] = "CefAttachedHelpers";
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
const extensions::Extension* GetExtensionForUrl(
content::BrowserContext* browser_context,
const GURL& url) {
auto* registry = extensions::ExtensionRegistry::Get(browser_context);
if (!registry) {
return nullptr;
}
std::string extension_id = url.host();
return registry->enabled_extensions().GetByID(extension_id);
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
} // namespace
CefBrowserPlatformDelegateAlloy::CefBrowserPlatformDelegateAlloy()
@@ -73,38 +43,7 @@ content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
CefRequestContextImpl::GetBrowserContext(create_params.request_context);
CHECK(browser_context);
scoped_refptr<content::SiteInstance> site_instance;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
if (extensions::ExtensionsEnabled() && !create_params.url.empty()) {
GURL gurl = url_util::MakeGURL(create_params.url, /*fixup=*/true);
if (!create_params.extension) {
// We might be loading an extension app view where the extension URL is
// provided by the client.
create_params.extension = GetExtensionForUrl(browser_context, gurl);
}
if (create_params.extension) {
if (create_params.extension_host_type ==
extensions::mojom::ViewType::kInvalid) {
// Default to popup behavior.
create_params.extension_host_type =
extensions::mojom::ViewType::kExtensionPopup;
}
// Extension resources will fail to load if we don't use a SiteInstance
// associated with the extension.
// (AlloyContentBrowserClient::SiteInstanceGotProcessAndSite won't find
// the extension to register with InfoMap, and AllowExtensionResourceLoad
// in ExtensionProtocolHandler::MaybeCreateJob will return false resulting
// in ERR_BLOCKED_BY_CLIENT).
site_instance = extensions::ProcessManager::Get(browser_context)
->GetSiteInstanceForURL(gurl);
DCHECK(site_instance);
}
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
content::WebContents::CreateParams wc_create_params(browser_context,
site_instance);
content::WebContents::CreateParams wc_create_params(browser_context, nullptr);
if (IsWindowless()) {
// Create the OSR view for the WebContents.
@@ -154,28 +93,8 @@ void CefBrowserPlatformDelegateAlloy::AddNewContents(
->SetOwnedWebContents(new_contents.release());
return;
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
if (extension_host_) {
extension_host_->AddNewContents(source, std::move(new_contents), target_url,
disposition, window_features, user_gesture,
was_blocked);
}
#endif
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool CefBrowserPlatformDelegateAlloy::
ShouldAllowRendererInitiatedCrossProcessNavigation(
bool is_main_frame_navigation) {
if (extension_host_) {
return extension_host_->ShouldAllowRendererInitiatedCrossProcessNavigation(
is_main_frame_navigation);
}
return true;
}
#endif
void CefBrowserPlatformDelegateAlloy::RenderViewReady() {
ConfigureAutoResize();
}
@@ -200,55 +119,9 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
std::make_unique<AlloyWebContentsDialogHelper>(web_contents_, this);
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type) {
REQUIRE_ALLOY_RUNTIME();
DCHECK(primary_);
// Should get WebContentsCreated and BrowserCreated calls first.
DCHECK(web_contents_);
DCHECK(browser_);
DCHECK(!extension_host_);
auto alloy_browser = AlloyBrowserHostImpl::FromBaseChecked(browser_.get());
if (host_type == extensions::mojom::ViewType::kExtensionPopup) {
// Create an extension host that we own.
extension_host_ = new extensions::CefExtensionViewHost(
alloy_browser.get(), extension, web_contents_, url, host_type);
// Trigger load of the extension URL.
extension_host_->CreateRendererSoon();
} else if (host_type ==
extensions::mojom::ViewType::kExtensionBackgroundPage) {
is_background_host_ = true;
alloy_browser->is_background_host_ = true;
// Create an extension host that will be owned by ProcessManager.
extension_host_ = new extensions::CefExtensionBackgroundHost(
alloy_browser.get(),
base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted,
weak_ptr_factory_.GetWeakPtr()),
extension, web_contents_, url, host_type);
// Load will be triggered by ProcessManager::CreateBackgroundHost.
} else {
DCHECK(false) << " Unsupported extension host type: " << host_type;
}
}
extensions::ExtensionHost* CefBrowserPlatformDelegateAlloy::GetExtensionHost()
const {
return extension_host_;
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CefBrowserPlatformDelegateAlloy::BrowserDestroyed(
CefBrowserHostBase* browser) {
if (primary_) {
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
DestroyExtensionHost();
#endif
owned_web_contents_.reset();
}
@@ -290,25 +163,6 @@ void CefBrowserPlatformDelegateAlloy::NotifyMoveOrResizeStarted() {
}
#endif
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool CefBrowserPlatformDelegateAlloy::PreHandleGestureEvent(
content::WebContents* source,
const blink::WebGestureEvent& event) {
if (extension_host_) {
return extension_host_->PreHandleGestureEvent(source, event);
}
return false;
}
bool CefBrowserPlatformDelegateAlloy::IsNeverComposited(
content::WebContents* web_contents) {
if (extension_host_) {
return extension_host_->IsNeverComposited(web_contents);
}
return false;
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CefBrowserPlatformDelegateAlloy::SetAutoResizeEnabled(
bool enabled,
const CefSize& min_size,
@@ -404,34 +258,6 @@ void CefBrowserPlatformDelegateAlloy::SetOwnedWebContents(
owned_web_contents_.reset(owned_contents);
}
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CefBrowserPlatformDelegateAlloy::DestroyExtensionHost() {
if (!extension_host_) {
return;
}
if (extension_host_->extension_host_type() ==
extensions::mojom::ViewType::kExtensionBackgroundPage) {
DCHECK(is_background_host_);
// Close notification for background pages arrives via CloseContents.
// The extension host will be deleted by
// ProcessManager::CloseBackgroundHost and OnExtensionHostDeleted will be
// called to notify us.
extension_host_->Close();
} else {
DCHECK(!is_background_host_);
// We own the extension host and must delete it.
delete extension_host_;
extension_host_ = nullptr;
}
}
void CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted() {
DCHECK(is_background_host_);
DCHECK(extension_host_);
extension_host_ = nullptr;
}
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CefBrowserPlatformDelegateAlloy::AttachHelpers(
content::WebContents* web_contents) {
// If already attached, nothing to be done.
@@ -445,36 +271,20 @@ void CefBrowserPlatformDelegateAlloy::AttachHelpers(
web_contents->SetUserData(&kAttachedHelpersUserDataKey,
std::make_unique<base::SupportsUserData::Data>());
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
// Create all the helpers.
if (cef::IsAlloyRuntimeEnabled()) {
find_in_page::FindTabHelper::CreateForWebContents(web_contents);
permissions::PermissionRequestManager::CreateForWebContents(web_contents);
PrefsTabHelper::CreateForWebContents(web_contents);
printing::InitializePrintingForWebContents(web_contents);
zoom::ZoomController::CreateForWebContents(web_contents);
javascript_dialogs::TabModalDialogManager::CreateForWebContents(
web_contents, CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(
web_contents));
} else
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
{
if (IsWindowless()) {
// Logic from ChromeContentBrowserClientCef::GetWebContentsViewDelegate
// which is not called for windowless browsers. Needs to be done before
// calling AttachTabHelpers.
if (auto* registry =
performance_manager::PerformanceManagerRegistry::GetInstance()) {
registry->MaybeCreatePageNodeForWebContents(web_contents);
}
if (IsWindowless()) {
// Logic from ChromeContentBrowserClientCef::GetWebContentsViewDelegate
// which is not called for windowless browsers. Needs to be done before
// calling AttachTabHelpers.
if (auto* registry =
performance_manager::PerformanceManagerRegistry::GetInstance()) {
registry->MaybeCreatePageNodeForWebContents(web_contents);
}
// Adopt the WebContents now, so all observers are in place, as the network
// requests for its initial navigation will start immediately
TabHelpers::AttachTabHelpers(web_contents);
// Make the tab show up in the task manager.
task_manager::WebContentsTags::CreateForTabContents(web_contents);
}
// Adopt the WebContents now, so all observers are in place, as the network
// requests for its initial navigation will start immediately
TabHelpers::AttachTabHelpers(web_contents);
// Make the tab show up in the task manager.
task_manager::WebContentsTags::CreateForTabContents(web_contents);
}

View File

@@ -33,29 +33,14 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
const blink::mojom::WindowFeatures& window_features,
bool user_gesture,
bool* was_blocked) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
bool is_main_frame_navigation) override;
#endif
void RenderViewReady() override;
void BrowserCreated(CefBrowserHostBase* browser) override;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::mojom::ViewType host_type) override;
extensions::ExtensionHost* GetExtensionHost() const override;
#endif
void BrowserDestroyed(CefBrowserHostBase* browser) override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
const override;
void SendCaptureLostEvent() override;
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC))
void NotifyMoveOrResizeStarted() override;
#endif
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) override;
bool IsNeverComposited(content::WebContents* web_contents) override;
#endif
bool IsAlloyStyle() const override { return true; }
void SetAutoResizeEnabled(bool enabled,
@@ -89,11 +74,6 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
private:
void SetOwnedWebContents(content::WebContents* owned_contents);
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
void DestroyExtensionHost();
void OnExtensionHostDeleted();
#endif
void ConfigureAutoResize();
// Attach all the associated helpers that are needed for the WebContents. It
@@ -113,12 +93,6 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
// matches, the find selection rectangle, etc.
find_in_page::FindNotificationDetails last_search_result_;
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
// Used when the browser is hosting an extension.
raw_ptr<extensions::ExtensionHost> extension_host_ = nullptr;
bool is_background_host_ = false;
#endif
// Used with auto-resize.
bool auto_resize_enabled_ = false;
gfx::Size auto_resize_min_;

View File

@@ -1,468 +0,0 @@
// Copyright (c) 2013 The Chromium Embedded Framework Authors.
// Portions (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/chrome_browser_process_alloy.h"
#include <memory>
#include "base/command_line.h"
#include "base/path_service.h"
#include "cef/libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/extensions/extensions_browser_client.h"
#include "cef/libcef/browser/prefs/browser_prefs.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/cef_switches.h"
#include "cef/libcef/common/extensions/extensions_client.h"
#include "cef/libcef/common/extensions/extensions_util.h"
#include "chrome/browser/component_updater/chrome_component_updater_configurator.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/permissions/chrome_permissions_client.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#include "chrome/browser/ui/prefs/pref_watcher.h"
#include "chrome/common/chrome_paths.h"
#include "components/component_updater/component_updater_service.h"
#include "components/component_updater/timer_update_scheduler.h"
#include "components/net_log/chrome_net_log.h"
#include "components/os_crypt/async/browser/os_crypt_async.h"
#include "components/prefs/pref_service.h"
#include "content/browser/startup_helper.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/common/content_switches.h"
#include "net/log/net_log_capture_mode.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if BUILDFLAG(IS_WIN)
#include "components/os_crypt/async/browser/dpapi_key_provider.h"
#endif
ChromeBrowserProcessAlloy::ChromeBrowserProcessAlloy() : locale_("en-US") {}
ChromeBrowserProcessAlloy::~ChromeBrowserProcessAlloy() {
DCHECK((!initialized_ && !context_initialized_) || shutdown_);
if (extensions::ExtensionsEnabled()) {
extensions::ExtensionsBrowserClient::Set(nullptr);
extensions_browser_client_.reset();
}
}
void ChromeBrowserProcessAlloy::Initialize() {
DCHECK(!initialized_);
DCHECK(!context_initialized_);
DCHECK(!shutdown_);
DCHECK(!field_trial_list_);
// Initialize this early before any code tries to check feature flags.
field_trial_list_ = content::SetUpFieldTrialsAndFeatureList();
if (extensions::ExtensionsEnabled()) {
// Initialize extension global objects before creating the global
// BrowserContext.
extensions_client_ = std::make_unique<extensions::CefExtensionsClient>();
extensions::ExtensionsClient::Set(extensions_client_.get());
extensions_browser_client_ =
std::make_unique<extensions::CefExtensionsBrowserClient>();
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
}
// Make sure permissions client has been set.
ChromePermissionsClient::GetInstance();
initialized_ = true;
}
void ChromeBrowserProcessAlloy::OnContextInitialized() {
CEF_REQUIRE_UIT();
DCHECK(initialized_);
DCHECK(!context_initialized_);
DCHECK(!shutdown_);
// OSCryptAsync provider configuration. If empty, this delegates all
// encryption operations to OSCrypt.
std::vector<std::pair<size_t, std::unique_ptr<os_crypt_async::KeyProvider>>>
providers;
#if BUILDFLAG(IS_WIN)
// The DPAPI key provider requires OSCrypt::Init to have already been called
// to initialize the key storage. This happens in
// AlloyBrowserMainParts::PreCreateMainMessageLoop.
providers.emplace_back(std::make_pair(
/*precedence=*/10u,
std::make_unique<os_crypt_async::DPAPIKeyProvider>(local_state())));
#endif // BUILDFLAG(IS_WIN)
os_crypt_async_ =
std::make_unique<os_crypt_async::OSCryptAsync>(std::move(providers));
// Trigger async initialization of OSCrypt key providers.
std::ignore = os_crypt_async_->GetInstance(base::DoNothing());
// Must be created after the NotificationService.
print_job_manager_ = std::make_unique<printing::PrintJobManager>();
profile_manager_ = std::make_unique<ChromeProfileManagerAlloy>();
event_router_forwarder_ = new extensions::EventRouterForwarder();
context_initialized_ = true;
}
void ChromeBrowserProcessAlloy::CleanupOnUIThread() {
CEF_REQUIRE_UIT();
DCHECK(initialized_);
DCHECK(context_initialized_);
DCHECK(!shutdown_);
// Wait for the pending print jobs to finish. Don't do this later, since
// this might cause a nested message loop to run, and we don't want pending
// tasks to run once teardown has started.
print_job_manager_->Shutdown();
print_job_manager_.reset(nullptr);
print_preview_dialog_controller_ = nullptr;
profile_manager_.reset();
event_router_forwarder_ = nullptr;
if (SystemNetworkContextManager::GetInstance()) {
SystemNetworkContextManager::DeleteInstance();
}
// Release any references held by objects associated with a Profile. The
// Profile will be deleted later.
for (const auto& browser_context : CefBrowserContext::GetAll()) {
// Release any references to |local_state_|.
auto profile = browser_context->AsProfile();
PrefWatcher* pref_watcher = PrefWatcher::Get(profile);
if (pref_watcher) {
pref_watcher->Shutdown();
}
// Unregister observers for |background_printing_manager_|.
if (background_printing_manager_) {
background_printing_manager_->DeletePreviewContentsForBrowserContext(
profile);
}
}
os_crypt_async_.reset();
local_state_.reset();
browser_policy_connector_.reset();
background_printing_manager_.reset();
field_trial_list_.reset();
component_updater_.reset();
shutdown_ = true;
}
void ChromeBrowserProcessAlloy::EndSession() {
DCHECK(false);
}
void ChromeBrowserProcessAlloy::FlushLocalStateAndReply(
base::OnceClosure reply) {
DCHECK(false);
}
metrics_services_manager::MetricsServicesManager*
ChromeBrowserProcessAlloy::GetMetricsServicesManager() {
DCHECK(false);
return nullptr;
}
metrics::MetricsService* ChromeBrowserProcessAlloy::metrics_service() {
DCHECK(false);
return nullptr;
}
SystemNetworkContextManager*
ChromeBrowserProcessAlloy::system_network_context_manager() {
DCHECK(SystemNetworkContextManager::GetInstance());
return SystemNetworkContextManager::GetInstance();
}
network::NetworkQualityTracker*
ChromeBrowserProcessAlloy::network_quality_tracker() {
DCHECK(false);
return nullptr;
}
embedder_support::OriginTrialsSettingsStorage*
ChromeBrowserProcessAlloy::GetOriginTrialsSettingsStorage() {
DCHECK(false);
return nullptr;
}
ProfileManager* ChromeBrowserProcessAlloy::profile_manager() {
DCHECK(context_initialized_);
return profile_manager_.get();
}
PrefService* ChromeBrowserProcessAlloy::local_state() {
DCHECK(initialized_);
if (!local_state_) {
base::FilePath user_data_path;
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_path);
DCHECK(!user_data_path.empty());
// Used for very early NetworkService initialization.
// Always persist preferences for this PrefService if possible because it
// contains the cookie encryption key on Windows.
local_state_ =
browser_prefs::CreatePrefService(nullptr /* profile */, user_data_path,
true /* persist_user_preferences */);
}
return local_state_.get();
}
scoped_refptr<network::SharedURLLoaderFactory>
ChromeBrowserProcessAlloy::shared_url_loader_factory() {
DCHECK(false);
return nullptr;
}
variations::VariationsService* ChromeBrowserProcessAlloy::variations_service() {
DCHECK(false);
return nullptr;
}
BrowserProcessPlatformPart* ChromeBrowserProcessAlloy::platform_part() {
DCHECK(false);
return nullptr;
}
extensions::EventRouterForwarder*
ChromeBrowserProcessAlloy::extension_event_router_forwarder() {
DCHECK(context_initialized_);
return event_router_forwarder_.get();
}
NotificationUIManager* ChromeBrowserProcessAlloy::notification_ui_manager() {
DCHECK(false);
return nullptr;
}
NotificationPlatformBridge*
ChromeBrowserProcessAlloy::notification_platform_bridge() {
DCHECK(false);
return nullptr;
}
policy::ChromeBrowserPolicyConnector*
ChromeBrowserProcessAlloy::browser_policy_connector() {
if (!browser_policy_connector_) {
browser_policy_connector_ =
std::make_unique<policy::ChromeBrowserPolicyConnector>();
}
return browser_policy_connector_.get();
}
policy::PolicyService* ChromeBrowserProcessAlloy::policy_service() {
return browser_policy_connector()->GetPolicyService();
}
IconManager* ChromeBrowserProcessAlloy::icon_manager() {
DCHECK(false);
return nullptr;
}
GpuModeManager* ChromeBrowserProcessAlloy::gpu_mode_manager() {
DCHECK(false);
return nullptr;
}
void ChromeBrowserProcessAlloy::CreateDevToolsProtocolHandler() {
DCHECK(false);
}
void ChromeBrowserProcessAlloy::CreateDevToolsAutoOpener() {
DCHECK(false);
}
bool ChromeBrowserProcessAlloy::IsShuttingDown() {
DCHECK(false);
return false;
}
printing::PrintJobManager* ChromeBrowserProcessAlloy::print_job_manager() {
DCHECK(context_initialized_);
return print_job_manager_.get();
}
printing::PrintPreviewDialogController*
ChromeBrowserProcessAlloy::print_preview_dialog_controller() {
if (!print_preview_dialog_controller_) {
print_preview_dialog_controller_ =
std::make_unique<printing::PrintPreviewDialogController>();
}
return print_preview_dialog_controller_.get();
}
printing::BackgroundPrintingManager*
ChromeBrowserProcessAlloy::background_printing_manager() {
if (!background_printing_manager_.get()) {
background_printing_manager_ =
std::make_unique<printing::BackgroundPrintingManager>();
}
return background_printing_manager_.get();
}
IntranetRedirectDetector*
ChromeBrowserProcessAlloy::intranet_redirect_detector() {
DCHECK(false);
return nullptr;
}
const std::string& ChromeBrowserProcessAlloy::GetApplicationLocale() {
DCHECK(!locale_.empty());
return locale_;
}
void ChromeBrowserProcessAlloy::SetApplicationLocale(
const std::string& locale) {
locale_ = locale;
}
DownloadStatusUpdater* ChromeBrowserProcessAlloy::download_status_updater() {
DCHECK(false);
return nullptr;
}
DownloadRequestLimiter* ChromeBrowserProcessAlloy::download_request_limiter() {
DCHECK(false);
return nullptr;
}
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
BackgroundModeManager* ChromeBrowserProcessAlloy::background_mode_manager() {
DCHECK(false);
return nullptr;
}
void ChromeBrowserProcessAlloy::set_background_mode_manager_for_test(
std::unique_ptr<BackgroundModeManager> manager) {
DCHECK(false);
}
#endif
StatusTray* ChromeBrowserProcessAlloy::status_tray() {
DCHECK(false);
return nullptr;
}
safe_browsing::SafeBrowsingService*
ChromeBrowserProcessAlloy::safe_browsing_service() {
return nullptr;
}
subresource_filter::RulesetService*
ChromeBrowserProcessAlloy::subresource_filter_ruleset_service() {
DCHECK(false);
return nullptr;
}
subresource_filter::RulesetService*
ChromeBrowserProcessAlloy::fingerprinting_protection_ruleset_service() {
DCHECK(false);
return nullptr;
}
StartupData* ChromeBrowserProcessAlloy::startup_data() {
DCHECK(false);
return nullptr;
}
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
void ChromeBrowserProcessAlloy::StartAutoupdateTimer() {}
#endif
component_updater::ComponentUpdateService*
ChromeBrowserProcessAlloy::component_updater() {
if (component_updater_) {
return component_updater_.get();
}
if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
return nullptr;
}
std::unique_ptr<component_updater::UpdateScheduler> scheduler =
std::make_unique<component_updater::TimerUpdateScheduler>();
component_updater_ = component_updater::ComponentUpdateServiceFactory(
component_updater::MakeChromeComponentUpdaterConfigurator(
base::CommandLine::ForCurrentProcess(),
g_browser_process->local_state()),
std::move(scheduler), /*brand=*/std::string());
return component_updater_.get();
}
MediaFileSystemRegistry*
ChromeBrowserProcessAlloy::media_file_system_registry() {
DCHECK(false);
return nullptr;
}
WebRtcLogUploader* ChromeBrowserProcessAlloy::webrtc_log_uploader() {
DCHECK(false);
return nullptr;
}
network_time::NetworkTimeTracker*
ChromeBrowserProcessAlloy::network_time_tracker() {
DCHECK(false);
return nullptr;
}
gcm::GCMDriver* ChromeBrowserProcessAlloy::gcm_driver() {
DCHECK(false);
return nullptr;
}
resource_coordinator::TabManager* ChromeBrowserProcessAlloy::GetTabManager() {
DCHECK(false);
return nullptr;
}
resource_coordinator::ResourceCoordinatorParts*
ChromeBrowserProcessAlloy::resource_coordinator_parts() {
DCHECK(false);
return nullptr;
}
os_crypt_async::OSCryptAsync* ChromeBrowserProcessAlloy::os_crypt_async() {
DCHECK(os_crypt_async_);
return os_crypt_async_.get();
}
void ChromeBrowserProcessAlloy::set_additional_os_crypt_async_provider_for_test(
size_t precedence,
std::unique_ptr<os_crypt_async::KeyProvider> provider) {
DCHECK(false);
}
BuildState* ChromeBrowserProcessAlloy::GetBuildState() {
DCHECK(false);
return nullptr;
}
SerialPolicyAllowedPorts*
ChromeBrowserProcessAlloy::serial_policy_allowed_ports() {
DCHECK(false);
return nullptr;
}
HidSystemTrayIcon* ChromeBrowserProcessAlloy::hid_system_tray_icon() {
DCHECK(false);
return nullptr;
}
UsbSystemTrayIcon* ChromeBrowserProcessAlloy::usb_system_tray_icon() {
DCHECK(false);
return nullptr;
}

View File

@@ -1,149 +0,0 @@
// Copyright (c) 2013 The Chromium Embedded Framework Authors.
// Portions (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file provides a stub implementation of Chrome's BrowserProcess object
// for use as an interop layer between CEF and files that live in chrome/.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_
#define CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_
#include <memory>
#include <string>
#include "base/metrics/field_trial.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "media/media_buildflags.h"
namespace extensions {
class ExtensionsBrowserClient;
class ExtensionsClient;
} // namespace extensions
class ChromeProfileManagerAlloy;
class BackgroundModeManager {
public:
BackgroundModeManager();
BackgroundModeManager(const BackgroundModeManager&) = delete;
BackgroundModeManager& operator=(const BackgroundModeManager&) = delete;
virtual ~BackgroundModeManager();
};
class ChromeBrowserProcessAlloy : public BrowserProcess {
public:
ChromeBrowserProcessAlloy();
ChromeBrowserProcessAlloy(const ChromeBrowserProcessAlloy&) = delete;
ChromeBrowserProcessAlloy& operator=(const ChromeBrowserProcessAlloy&) =
delete;
~ChromeBrowserProcessAlloy() override;
void Initialize();
void OnContextInitialized();
void CleanupOnUIThread();
// BrowserProcess implementation.
void EndSession() override;
void FlushLocalStateAndReply(base::OnceClosure reply) override;
metrics_services_manager::MetricsServicesManager* GetMetricsServicesManager()
override;
metrics::MetricsService* metrics_service() override;
SystemNetworkContextManager* system_network_context_manager() override;
network::NetworkQualityTracker* network_quality_tracker() override;
embedder_support::OriginTrialsSettingsStorage*
GetOriginTrialsSettingsStorage() override;
ProfileManager* profile_manager() override;
PrefService* local_state() override;
scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory()
override;
variations::VariationsService* variations_service() override;
BrowserProcessPlatformPart* platform_part() override;
extensions::EventRouterForwarder* extension_event_router_forwarder() override;
NotificationUIManager* notification_ui_manager() override;
NotificationPlatformBridge* notification_platform_bridge() override;
policy::ChromeBrowserPolicyConnector* browser_policy_connector() override;
policy::PolicyService* policy_service() override;
IconManager* icon_manager() override;
GpuModeManager* gpu_mode_manager() override;
void CreateDevToolsProtocolHandler() override;
void CreateDevToolsAutoOpener() override;
bool IsShuttingDown() override;
printing::PrintJobManager* print_job_manager() override;
printing::PrintPreviewDialogController* print_preview_dialog_controller()
override;
printing::BackgroundPrintingManager* background_printing_manager() override;
IntranetRedirectDetector* intranet_redirect_detector() override;
const std::string& GetApplicationLocale() override;
void SetApplicationLocale(const std::string& locale) override;
DownloadStatusUpdater* download_status_updater() override;
DownloadRequestLimiter* download_request_limiter() override;
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
BackgroundModeManager* background_mode_manager() override;
void set_background_mode_manager_for_test(
std::unique_ptr<BackgroundModeManager> manager) override;
#endif
StatusTray* status_tray() override;
safe_browsing::SafeBrowsingService* safe_browsing_service() override;
subresource_filter::RulesetService* subresource_filter_ruleset_service()
override;
subresource_filter::RulesetService*
fingerprinting_protection_ruleset_service() override;
StartupData* startup_data() override;
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
void StartAutoupdateTimer() override;
#endif
component_updater::ComponentUpdateService* component_updater() override;
MediaFileSystemRegistry* media_file_system_registry() override;
WebRtcLogUploader* webrtc_log_uploader() override;
network_time::NetworkTimeTracker* network_time_tracker() override;
gcm::GCMDriver* gcm_driver() override;
resource_coordinator::TabManager* GetTabManager() override;
resource_coordinator::ResourceCoordinatorParts* resource_coordinator_parts()
override;
os_crypt_async::OSCryptAsync* os_crypt_async() override;
void set_additional_os_crypt_async_provider_for_test(
size_t precedence,
std::unique_ptr<os_crypt_async::KeyProvider> provider) override;
BuildState* GetBuildState() override;
SerialPolicyAllowedPorts* serial_policy_allowed_ports() override;
HidSystemTrayIcon* hid_system_tray_icon() override;
UsbSystemTrayIcon* usb_system_tray_icon() override;
private:
bool initialized_ = false;
bool context_initialized_ = false;
bool shutdown_ = false;
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
std::unique_ptr<extensions::ExtensionsBrowserClient>
extensions_browser_client_;
std::string locale_;
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
std::unique_ptr<ChromeProfileManagerAlloy> profile_manager_;
scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
std::unique_ptr<printing::PrintPreviewDialogController>
print_preview_dialog_controller_;
std::unique_ptr<printing::BackgroundPrintingManager>
background_printing_manager_;
std::unique_ptr<PrefService> local_state_;
// Must be destroyed after |local_state_|.
std::unique_ptr<policy::ChromeBrowserPolicyConnector>
browser_policy_connector_;
std::unique_ptr<base::FieldTrialList> field_trial_list_;
std::unique_ptr<component_updater::ComponentUpdateService> component_updater_;
std::unique_ptr<os_crypt_async::OSCryptAsync> os_crypt_async_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_

View File

@@ -1,156 +0,0 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/chrome_profile_alloy.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "components/profile_metrics/browser_profile_type.h"
#include "components/variations/variations_client.h"
#include "components/variations/variations_ids_provider.h"
#include "net/url_request/url_request_context.h"
namespace {
class CefVariationsClient : public variations::VariationsClient {
public:
explicit CefVariationsClient(content::BrowserContext* browser_context)
: browser_context_(browser_context) {}
~CefVariationsClient() override = default;
bool IsOffTheRecord() const override {
return browser_context_->IsOffTheRecord();
}
variations::mojom::VariationsHeadersPtr GetVariationsHeaders()
const override {
return variations::VariationsIdsProvider::GetInstance()
->GetClientDataHeaders(false /* is_signed_in */);
}
private:
raw_ptr<content::BrowserContext> browser_context_;
};
} // namespace
ChromeProfileAlloy::ChromeProfileAlloy() : Profile(nullptr) {
// Alloy contexts are never flagged as off-the-record. It causes problems
// for the extension system.
DCHECK(!IsOffTheRecord());
profile_metrics::SetBrowserProfileType(
this, profile_metrics::BrowserProfileType::kRegular);
}
ChromeProfileAlloy::~ChromeProfileAlloy() = default;
variations::VariationsClient* ChromeProfileAlloy::GetVariationsClient() {
if (!variations_client_) {
variations_client_ = std::make_unique<CefVariationsClient>(this);
}
return variations_client_.get();
}
scoped_refptr<base::SequencedTaskRunner> ChromeProfileAlloy::GetIOTaskRunner() {
DCHECK(false);
return scoped_refptr<base::SequencedTaskRunner>();
}
std::string ChromeProfileAlloy::GetProfileUserName() const {
DCHECK(false);
return std::string();
}
Profile* ChromeProfileAlloy::GetOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id,
bool create_if_needed) {
DCHECK(false);
return nullptr;
}
std::vector<Profile*> ChromeProfileAlloy::GetAllOffTheRecordProfiles() {
return {};
}
void ChromeProfileAlloy::DestroyOffTheRecordProfile(Profile* otr_profile) {
DCHECK(false);
}
bool ChromeProfileAlloy::HasOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) {
return false;
}
bool ChromeProfileAlloy::HasAnyOffTheRecordProfile() {
return false;
}
Profile* ChromeProfileAlloy::GetOriginalProfile() {
return this;
}
const Profile* ChromeProfileAlloy::GetOriginalProfile() const {
return this;
}
bool ChromeProfileAlloy::IsChild() const {
return false;
}
ExtensionSpecialStoragePolicy*
ChromeProfileAlloy::GetExtensionSpecialStoragePolicy() {
DCHECK(false);
return nullptr;
}
bool ChromeProfileAlloy::IsSameOrParent(Profile* profile) {
DCHECK(false);
return false;
}
base::Time ChromeProfileAlloy::GetStartTime() const {
DCHECK(false);
return base::Time();
}
base::FilePath ChromeProfileAlloy::last_selected_directory() {
return last_selected_directory_;
}
void ChromeProfileAlloy::set_last_selected_directory(
const base::FilePath& path) {
last_selected_directory_ = path;
}
GURL ChromeProfileAlloy::GetHomePage() {
DCHECK(false);
return GURL();
}
bool ChromeProfileAlloy::WasCreatedByVersionOrLater(
const std::string& version) {
DCHECK(false);
return false;
}
base::Time ChromeProfileAlloy::GetCreationTime() const {
DCHECK(false);
return base::Time();
}
void ChromeProfileAlloy::SetCreationTimeForTesting(base::Time creation_time) {
DCHECK(false);
}
void ChromeProfileAlloy::RecordPrimaryMainFrameNavigation() {
DCHECK(false);
}
bool ChromeProfileAlloy::IsSignedIn() {
DCHECK(false);
return false;
}

View File

@@ -1,58 +0,0 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This class gathers state related to a single user profile.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_
#define CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_
#include "base/files/file_path.h"
#include "chrome/browser/profiles/profile.h"
// This file provides a stub implementation of Chrome's Profile object for use
// as an interop layer between CEF and files that live in chrome/.
class ChromeProfileAlloy : public Profile {
public:
ChromeProfileAlloy();
ChromeProfileAlloy(const ChromeProfileAlloy&) = delete;
ChromeProfileAlloy& operator=(const ChromeProfileAlloy&) = delete;
~ChromeProfileAlloy() override;
protected:
// Profile methods.
variations::VariationsClient* GetVariationsClient() override;
scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override;
std::string GetProfileUserName() const override;
Profile* GetOffTheRecordProfile(const Profile::OTRProfileID& otr_profile_id,
bool create_if_needed) override;
std::vector<Profile*> GetAllOffTheRecordProfiles() override;
void DestroyOffTheRecordProfile(Profile* otr_profile) override;
bool HasOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) override;
bool HasAnyOffTheRecordProfile() override;
Profile* GetOriginalProfile() override;
const Profile* GetOriginalProfile() const override;
bool IsChild() const override;
ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
bool IsSameOrParent(Profile* profile) override;
base::Time GetStartTime() const override;
base::FilePath last_selected_directory() override;
void set_last_selected_directory(const base::FilePath& path) override;
GURL GetHomePage() override;
bool WasCreatedByVersionOrLater(const std::string& version) override;
base::Time GetCreationTime() const override;
void SetCreationTimeForTesting(base::Time creation_time) override;
void RecordPrimaryMainFrameNavigation() override;
bool IsSignedIn() override;
private:
std::unique_ptr<variations::VariationsClient> variations_client_;
base::FilePath last_selected_directory_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_

View File

@@ -1,59 +0,0 @@
// Copyright (c) 2016 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/request_context_impl.h"
#include "cef/libcef/common/app_manager.h"
namespace {
// Return the active browser context. This is primarily called from Chrome code
// that handles WebUI views and wishes to associate the view's data with a
// particular context (profile). Chrome stores multiple profiles in sub-
// directories of |user_data_dir| and then uses ProfileManager to track which
// profile (sub-directory name) was last active.
//
// TODO(cef): To most closely match Chrome behavior this should return the
// context for the currently active browser (e.g. the browser with input focus).
// Return the main context for now since we don't currently have a good way to
// determine that.
CefBrowserContext* GetActiveBrowserContext() {
auto request_context = static_cast<CefRequestContextImpl*>(
CefAppManager::Get()->GetGlobalRequestContext().get());
return request_context->GetBrowserContext();
}
} // namespace
ChromeProfileManagerAlloy::ChromeProfileManagerAlloy()
: ProfileManager(base::FilePath()) {}
ChromeProfileManagerAlloy::~ChromeProfileManagerAlloy() = default;
Profile* ChromeProfileManagerAlloy::GetProfile(
const base::FilePath& profile_dir) {
CefBrowserContext* browser_context =
CefBrowserContext::FromCachePath(profile_dir);
if (!browser_context) {
// ProfileManager makes assumptions about profile directory paths that do
// not match CEF usage. For example, the default Chrome profile name is
// "Default" so it will append that sub-directory name to an empty
// |user_data_dir| value and then call this method. Use the active context
// in cases such as this where we don't understand what ProfileManager is
// asking for.
browser_context = GetActiveBrowserContext();
}
return browser_context->AsProfile();
}
bool ChromeProfileManagerAlloy::IsValidProfile(const void* profile) {
if (!profile) {
return false;
}
return !!CefBrowserContext::FromBrowserContext(
static_cast<const content::BrowserContext*>(profile));
}

View File

@@ -1,28 +0,0 @@
// Copyright (c) 2016 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file provides a stub implementation of Chrome's ProfileManager object
// for use as an interop layer between CEF and files that live in chrome/.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_
#define CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_
#include "chrome/browser/profiles/profile_manager.h"
class ChromeProfileManagerAlloy : public ProfileManager {
public:
ChromeProfileManagerAlloy();
ChromeProfileManagerAlloy(const ChromeProfileManagerAlloy&) = delete;
ChromeProfileManagerAlloy& operator=(const ChromeProfileManagerAlloy&) =
delete;
~ChromeProfileManagerAlloy() override;
Profile* GetProfile(const base::FilePath& profile_dir) override;
bool IsValidProfile(const void* profile) override;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_

View File

@@ -1,46 +0,0 @@
// Copyright 2024 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/devtools/alloy_devtools_window_runner.h"
#include "cef/libcef/browser/alloy/devtools/devtools_frontend.h"
#include "cef/libcef/browser/thread_util.h"
void AlloyDevToolsWindowRunner::ShowDevTools(
CefBrowserHostBase* opener,
std::unique_ptr<CefShowDevToolsParams> params) {
CEF_REQUIRE_UIT();
if (devtools_frontend_) {
if (!params->inspect_element_at_.IsEmpty()) {
devtools_frontend_->InspectElementAt(params->inspect_element_at_.x,
params->inspect_element_at_.y);
}
devtools_frontend_->Focus();
return;
}
auto alloy_browser = AlloyBrowserHostImpl::FromBaseChecked(opener);
devtools_frontend_ = CefDevToolsFrontend::Show(
alloy_browser.get(), params->window_info_, params->client_,
params->settings_, params->inspect_element_at_,
base::BindOnce(&AlloyDevToolsWindowRunner::OnFrontEndDestroyed,
weak_ptr_factory_.GetWeakPtr()));
}
void AlloyDevToolsWindowRunner::CloseDevTools() {
CEF_REQUIRE_UIT();
if (devtools_frontend_) {
devtools_frontend_->Close();
}
}
bool AlloyDevToolsWindowRunner::HasDevTools() {
CEF_REQUIRE_UIT();
return !!devtools_frontend_;
}
void AlloyDevToolsWindowRunner::OnFrontEndDestroyed() {
CEF_REQUIRE_UIT();
devtools_frontend_ = nullptr;
}

View File

@@ -1,40 +0,0 @@
// Copyright 2024 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_
#pragma once
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "cef/libcef/browser/devtools/devtools_window_runner.h"
class CefDevToolsFrontend;
// Creates and runs a DevTools window instance. Only accessed on the UI thread.
class AlloyDevToolsWindowRunner : public CefDevToolsWindowRunner {
public:
AlloyDevToolsWindowRunner() = default;
AlloyDevToolsWindowRunner(const AlloyDevToolsWindowRunner&) = delete;
AlloyDevToolsWindowRunner& operator=(const AlloyDevToolsWindowRunner&) =
delete;
// CefDevToolsWindowRunner methods:
void ShowDevTools(CefBrowserHostBase* opener,
std::unique_ptr<CefShowDevToolsParams> params) override;
void CloseDevTools() override;
bool HasDevTools() override;
private:
void OnFrontEndDestroyed();
// CefDevToolsFrontend will delete itself when the frontend WebContents is
// destroyed.
raw_ptr<CefDevToolsFrontend> devtools_frontend_ = nullptr;
base::WeakPtrFactory<AlloyDevToolsWindowRunner> weak_ptr_factory_{this};
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_

View File

@@ -1,206 +0,0 @@
// Copyright 2019 The Chromium Embedded Framework Authors. Portions copyright
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "cef/libcef/browser/alloy/devtools/devtools_file_manager.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/hash/md5.h"
#include "base/json/json_writer.h"
#include "base/json/values_util.h"
#include "base/lazy_instance.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/values.h"
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/web_contents.h"
namespace {
base::LazyInstance<base::FilePath>::Leaky g_last_save_path =
LAZY_INSTANCE_INITIALIZER;
void WriteToFile(const base::FilePath& path, const std::string& content) {
DCHECK(!path.empty());
base::WriteFile(path, content.c_str(), content.length());
}
void AppendToFile(const base::FilePath& path, const std::string& content) {
DCHECK(!path.empty());
base::AppendToFile(path, std::string_view(content));
}
} // namespace
CefDevToolsFileManager::CefDevToolsFileManager(
AlloyBrowserHostImpl* browser_impl,
PrefService* prefs)
: browser_impl_(browser_impl),
prefs_(prefs),
file_task_runner_(
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})),
weak_factory_(this) {}
void CefDevToolsFileManager::SaveToFile(const std::string& url,
const std::string& content,
bool save_as) {
Save(url, content, save_as,
base::BindOnce(&CefDevToolsFileManager::FileSavedAs,
weak_factory_.GetWeakPtr(), url),
base::BindOnce(&CefDevToolsFileManager::CanceledFileSaveAs,
weak_factory_.GetWeakPtr(), url));
}
void CefDevToolsFileManager::AppendToFile(const std::string& url,
const std::string& content) {
Append(url, content,
base::BindOnce(&CefDevToolsFileManager::AppendedTo,
weak_factory_.GetWeakPtr(), url));
}
void CefDevToolsFileManager::Save(const std::string& url,
const std::string& content,
bool save_as,
SaveCallback saveCallback,
CancelCallback cancelCallback) {
auto it = saved_files_.find(url);
if (it != saved_files_.end() && !save_as) {
SaveAsFileSelected(url, content, std::move(saveCallback), it->second);
return;
}
const base::Value::Dict& file_map =
prefs_->GetDict(prefs::kDevToolsEditedFiles);
base::FilePath initial_path;
if (const base::Value* path_value = file_map.Find(base::MD5String(url))) {
std::optional<base::FilePath> path = base::ValueToFilePath(*path_value);
if (path) {
initial_path = std::move(*path);
}
}
if (initial_path.empty()) {
GURL gurl(url);
std::string suggested_file_name =
gurl.is_valid() ? gurl.ExtractFileName() : url;
if (suggested_file_name.length() > 64) {
suggested_file_name = suggested_file_name.substr(0, 64);
}
if (!g_last_save_path.Pointer()->empty()) {
initial_path = g_last_save_path.Pointer()->DirName().AppendASCII(
suggested_file_name);
} else {
// Use the temp directory. It may be an empty value.
base::PathService::Get(base::DIR_TEMP, &initial_path);
initial_path = initial_path.AppendASCII(suggested_file_name);
}
}
blink::mojom::FileChooserParams params;
params.mode = blink::mojom::FileChooserParams::Mode::kSave;
if (!initial_path.empty()) {
params.default_file_name = initial_path;
if (!initial_path.Extension().empty()) {
params.accept_types.push_back(CefString(initial_path.Extension()));
}
}
browser_impl_->RunFileChooserForBrowser(
params,
base::BindOnce(&CefDevToolsFileManager::SaveAsDialogDismissed,
weak_factory_.GetWeakPtr(), url, content,
std::move(saveCallback), std::move(cancelCallback)));
}
void CefDevToolsFileManager::SaveAsDialogDismissed(
const std::string& url,
const std::string& content,
SaveCallback saveCallback,
CancelCallback cancelCallback,
const std::vector<base::FilePath>& file_paths) {
if (file_paths.size() == 1) {
SaveAsFileSelected(url, content, std::move(saveCallback), file_paths[0]);
} else {
std::move(cancelCallback).Run();
}
}
void CefDevToolsFileManager::SaveAsFileSelected(const std::string& url,
const std::string& content,
SaveCallback callback,
const base::FilePath& path) {
*g_last_save_path.Pointer() = path;
saved_files_[url] = path;
ScopedDictPrefUpdate update(prefs_, prefs::kDevToolsEditedFiles);
update->Set(base::MD5String(url), base::FilePathToValue(path));
std::string file_system_path = path.AsUTF8Unsafe();
std::move(callback).Run(file_system_path);
file_task_runner_->PostTask(FROM_HERE,
base::BindOnce(&::WriteToFile, path, content));
}
void CefDevToolsFileManager::FileSavedAs(const std::string& url,
const std::string& file_system_path) {
base::Value url_value(url);
base::Value file_system_path_value(file_system_path);
CallClientFunction("DevToolsAPI.savedURL", &url_value,
&file_system_path_value, nullptr);
}
void CefDevToolsFileManager::CanceledFileSaveAs(const std::string& url) {
base::Value url_value(url);
CallClientFunction("DevToolsAPI.canceledSaveURL", &url_value, nullptr,
nullptr);
}
void CefDevToolsFileManager::Append(const std::string& url,
const std::string& content,
AppendCallback callback) {
auto it = saved_files_.find(url);
if (it == saved_files_.end()) {
return;
}
std::move(callback).Run();
file_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&::AppendToFile, it->second, content));
}
void CefDevToolsFileManager::AppendedTo(const std::string& url) {
base::Value url_value(url);
CallClientFunction("DevToolsAPI.appendedToURL", &url_value, nullptr, nullptr);
}
void CefDevToolsFileManager::CallClientFunction(
const std::string& function_name,
const base::Value* arg1,
const base::Value* arg2,
const base::Value* arg3) {
std::string javascript = function_name + "(";
if (arg1) {
std::string json;
base::JSONWriter::Write(*arg1, &json);
javascript.append(json);
if (arg2) {
base::JSONWriter::Write(*arg2, &json);
javascript.append(", ").append(json);
if (arg3) {
base::JSONWriter::Write(*arg3, &json);
javascript.append(", ").append(json);
}
}
}
javascript.append(");");
browser_impl_->web_contents()->GetPrimaryMainFrame()->ExecuteJavaScript(
base::UTF8ToUTF16(javascript), base::NullCallback());
}

View File

@@ -1,83 +0,0 @@
// Copyright 2019 The Chromium Embedded Framework Authors. Portions copyright
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
#include <map>
#include <string>
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
namespace base {
class FilePath;
class SequencedTaskRunner;
class Value;
} // namespace base
class AlloyBrowserHostImpl;
class PrefService;
// File management helper for DevTools.
// Based on chrome/browser/devtools/devtools_ui_bindings.cc and
// chrome/browser/devtools/devtools_file_helper.cc.
class CefDevToolsFileManager {
public:
CefDevToolsFileManager(AlloyBrowserHostImpl* browser_impl,
PrefService* prefs);
CefDevToolsFileManager(const CefDevToolsFileManager&) = delete;
CefDevToolsFileManager& operator=(const CefDevToolsFileManager&) = delete;
void SaveToFile(const std::string& url,
const std::string& content,
bool save_as);
void AppendToFile(const std::string& url, const std::string& content);
private:
// SaveToFile implementation:
using SaveCallback = base::OnceCallback<void(const std::string&)>;
using CancelCallback = base::OnceCallback<void()>;
void Save(const std::string& url,
const std::string& content,
bool save_as,
SaveCallback saveCallback,
CancelCallback cancelCallback);
void SaveAsDialogDismissed(const std::string& url,
const std::string& content,
SaveCallback saveCallback,
CancelCallback cancelCallback,
const std::vector<base::FilePath>& file_paths);
void SaveAsFileSelected(const std::string& url,
const std::string& content,
SaveCallback callback,
const base::FilePath& path);
void FileSavedAs(const std::string& url, const std::string& file_system_path);
void CanceledFileSaveAs(const std::string& url);
// AppendToFile implementation:
using AppendCallback = base::OnceCallback<void(void)>;
void Append(const std::string& url,
const std::string& content,
AppendCallback callback);
void AppendedTo(const std::string& url);
void CallClientFunction(const std::string& function_name,
const base::Value* arg1,
const base::Value* arg2,
const base::Value* arg3);
// Guaranteed to outlive this object.
raw_ptr<AlloyBrowserHostImpl> browser_impl_;
raw_ptr<PrefService> prefs_;
using PathsMap = std::map<std::string, base::FilePath>;
PathsMap saved_files_;
scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
base::WeakPtrFactory<CefDevToolsFileManager> weak_factory_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_

View File

@@ -1,673 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/devtools/devtools_frontend.h"
#include <stddef.h>
#include <iomanip>
#include <memory>
#include <utility>
#include "base/base64.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/json/string_escape.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/uuid.h"
#include "base/values.h"
#include "cef/libcef/browser/alloy/devtools/devtools_manager_delegate.h"
#include "cef/libcef/browser/browser_context.h"
#include "cef/libcef/browser/net/devtools_scheme_handler.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/cef_switches.h"
#include "cef/libcef/common/task_runner_manager.h"
#include "cef/libcef/features/runtime_checks.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/file_url_loader.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/shared_cors_origin_access_list.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_client.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h"
#include "ipc/ipc_channel.h"
#include "net/base/completion_once_callback.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/http/http_response_headers.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "storage/browser/file_system/native_file_util.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#elif BUILDFLAG(IS_POSIX)
#include <time.h>
#endif
namespace {
// This constant should be in sync with the constant in
// chrome/browser/devtools/devtools_ui_bindings.cc.
constexpr size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
constexpr int kMaxLogLineLength = 1024;
static std::string GetFrontendURL() {
return base::StringPrintf("%s://%s/devtools_app.html",
content::kChromeDevToolsScheme,
scheme::kChromeDevToolsHost);
}
base::Value::Dict BuildObjectForResponse(const net::HttpResponseHeaders* rh,
bool success,
int net_error) {
base::Value::Dict response;
int responseCode = 200;
if (rh) {
responseCode = rh->response_code();
} else if (!success) {
// In case of no headers, assume file:// URL and failed to load
responseCode = 404;
}
response.Set("statusCode", responseCode);
response.Set("netError", net_error);
response.Set("netErrorName", net::ErrorToString(net_error));
base::Value::Dict headers;
size_t iterator = 0;
std::string name;
std::string value;
// TODO(caseq): this probably needs to handle duplicate header names
// correctly by folding them.
while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value)) {
headers.Set(name, value);
}
response.Set("headers", std::move(headers));
return response;
}
void WriteTimestamp(std::stringstream& stream) {
#if BUILDFLAG(IS_WIN)
SYSTEMTIME local_time;
GetLocalTime(&local_time);
stream << std::setfill('0') << std::setw(2) << local_time.wMonth
<< std::setw(2) << local_time.wDay << '/' << std::setw(2)
<< local_time.wHour << std::setw(2) << local_time.wMinute
<< std::setw(2) << local_time.wSecond << '.' << std::setw(3)
<< local_time.wMilliseconds;
#elif BUILDFLAG(IS_POSIX)
timeval tv;
gettimeofday(&tv, nullptr);
time_t t = tv.tv_sec;
struct tm local_time;
localtime_r(&t, &local_time);
struct tm* tm_time = &local_time;
stream << std::setfill('0') << std::setw(2) << 1 + tm_time->tm_mon
<< std::setw(2) << tm_time->tm_mday << '/' << std::setw(2)
<< tm_time->tm_hour << std::setw(2) << tm_time->tm_min << std::setw(2)
<< tm_time->tm_sec << '.' << std::setw(6) << tv.tv_usec;
#else
#error Unsupported platform
#endif
}
void LogProtocolMessage(const base::FilePath& log_file,
ProtocolMessageType type,
std::string to_log) {
// Track if logging has failed, in which case we don't keep trying.
static bool log_error = false;
if (log_error) {
return;
}
if (storage::NativeFileUtil::EnsureFileExists(log_file, nullptr) !=
base::File::FILE_OK) {
LOG(ERROR) << "Failed to create file " << log_file.value();
log_error = true;
return;
}
std::string type_label;
switch (type) {
case ProtocolMessageType::METHOD:
type_label = "METHOD";
break;
case ProtocolMessageType::RESULT:
type_label = "RESULT";
break;
case ProtocolMessageType::EVENT:
type_label = "EVENT";
break;
}
std::stringstream stream;
WriteTimestamp(stream);
stream << ": " << type_label << ": " << to_log << "\n";
const std::string& str = stream.str();
if (!base::AppendToFile(log_file, std::string_view(str))) {
LOG(ERROR) << "Failed to write file " << log_file.value();
log_error = true;
}
}
} // namespace
class CefDevToolsFrontend::NetworkResourceLoader
: public network::SimpleURLLoaderStreamConsumer {
public:
NetworkResourceLoader(int stream_id,
CefDevToolsFrontend* bindings,
std::unique_ptr<network::SimpleURLLoader> loader,
network::mojom::URLLoaderFactory* url_loader_factory,
int request_id)
: stream_id_(stream_id),
bindings_(bindings),
loader_(std::move(loader)),
request_id_(request_id) {
loader_->SetOnResponseStartedCallback(base::BindOnce(
&NetworkResourceLoader::OnResponseStarted, base::Unretained(this)));
loader_->DownloadAsStream(url_loader_factory, this);
}
NetworkResourceLoader(const NetworkResourceLoader&) = delete;
NetworkResourceLoader& operator=(const NetworkResourceLoader&) = delete;
private:
void OnResponseStarted(const GURL& final_url,
const network::mojom::URLResponseHead& response_head) {
response_headers_ = response_head.headers;
}
void OnDataReceived(std::string_view chunk,
base::OnceClosure resume) override {
base::Value chunkValue;
bool encoded = !base::IsStringUTF8(chunk);
if (encoded) {
chunkValue = base::Value(base::Base64Encode(chunk));
} else {
chunkValue = base::Value(chunk);
}
base::Value id(stream_id_);
base::Value encodedValue(encoded);
bindings_->CallClientFunction("DevToolsAPI", "streamWrite", std::move(id),
std::move(chunkValue),
std::move(encodedValue));
std::move(resume).Run();
}
void OnComplete(bool success) override {
auto response = BuildObjectForResponse(response_headers_.get(), success,
loader_->NetError());
bindings_->SendMessageAck(request_id_, std::move(response));
bindings_->loaders_.erase(bindings_->loaders_.find(this));
}
void OnRetry(base::OnceClosure start_retry) override { DCHECK(false); }
const int stream_id_;
const raw_ptr<CefDevToolsFrontend> bindings_;
std::unique_ptr<network::SimpleURLLoader> loader_;
int request_id_;
scoped_refptr<net::HttpResponseHeaders> response_headers_;
};
// static
CefDevToolsFrontend* CefDevToolsFrontend::Show(
AlloyBrowserHostImpl* inspected_browser,
const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at,
base::OnceClosure frontend_destroyed_callback) {
REQUIRE_ALLOY_RUNTIME();
CefBrowserSettings new_settings = settings;
if (!windowInfo.windowless_rendering_enabled &&
CefColorGetA(new_settings.background_color) != SK_AlphaOPAQUE) {
// Use white as the default background color for windowed DevTools instead
// of the CefSettings.background_color value.
new_settings.background_color = SK_ColorWHITE;
}
CefBrowserCreateParams create_params;
create_params.MaybeSetWindowInfo(windowInfo, /*allow_alloy_style=*/true,
/*allow_chrome_style=*/false);
if (inspected_browser->is_views_hosted()) {
create_params.popup_with_views_hosted_opener = true;
}
create_params.popup_with_alloy_style_opener = true;
create_params.client = client;
create_params.settings = new_settings;
create_params.devtools_opener = inspected_browser;
create_params.request_context = inspected_browser->GetRequestContext();
create_params.extra_info = inspected_browser->browser_info()->extra_info();
CefRefPtr<AlloyBrowserHostImpl> frontend_browser =
AlloyBrowserHostImpl::Create(create_params);
content::WebContents* inspected_contents = inspected_browser->web_contents();
// CefDevToolsFrontend will delete itself when the frontend WebContents is
// destroyed.
CefDevToolsFrontend* devtools_frontend = new CefDevToolsFrontend(
frontend_browser.get(), inspected_contents, inspect_element_at,
std::move(frontend_destroyed_callback));
// Need to load the URL after creating the DevTools objects.
frontend_browser->GetMainFrame()->LoadURL(GetFrontendURL());
return devtools_frontend;
}
void CefDevToolsFrontend::Activate() {
frontend_browser_->ActivateContents(web_contents());
}
void CefDevToolsFrontend::Focus() {
frontend_browser_->SetFocus(true);
}
void CefDevToolsFrontend::InspectElementAt(int x, int y) {
if (inspect_element_at_.x != x || inspect_element_at_.y != y) {
inspect_element_at_.Set(x, y);
}
if (agent_host_) {
agent_host_->InspectElement(inspected_contents_->GetFocusedFrame(), x, y);
}
}
void CefDevToolsFrontend::Close() {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::CloseBrowser,
frontend_browser_.get(), true));
}
CefDevToolsFrontend::CefDevToolsFrontend(
AlloyBrowserHostImpl* frontend_browser,
content::WebContents* inspected_contents,
const CefPoint& inspect_element_at,
base::OnceClosure frontend_destroyed_callback)
: content::WebContentsObserver(frontend_browser->web_contents()),
frontend_browser_(frontend_browser),
inspected_contents_(inspected_contents),
inspect_element_at_(inspect_element_at),
frontend_destroyed_callback_(std::move(frontend_destroyed_callback)),
file_manager_(frontend_browser, GetPrefs()),
protocol_log_file_(
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
switches::kDevToolsProtocolLogFile)),
weak_factory_(this) {
DCHECK(!frontend_destroyed_callback_.is_null());
}
CefDevToolsFrontend::~CefDevToolsFrontend() = default;
void CefDevToolsFrontend::ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) {
content::RenderFrameHost* frame = navigation_handle->GetRenderFrameHost();
if (navigation_handle->IsInMainFrame()) {
frontend_host_ = content::DevToolsFrontendHost::Create(
frame, base::BindRepeating(
&CefDevToolsFrontend::HandleMessageFromDevToolsFrontend,
base::Unretained(this)));
return;
}
std::string origin =
navigation_handle->GetURL().DeprecatedGetOriginAsURL().spec();
auto it = extensions_api_.find(origin);
if (it == extensions_api_.end()) {
return;
}
std::string script = base::StringPrintf(
"%s(\"%s\")", it->second.c_str(),
base::Uuid::GenerateRandomV4().AsLowercaseString().c_str());
content::DevToolsFrontendHost::SetupExtensionsAPI(frame, script);
}
void CefDevToolsFrontend::PrimaryMainDocumentElementAvailable() {
// Don't call AttachClient multiple times for the same DevToolsAgentHost.
// Otherwise it will call AgentHostClosed which closes the DevTools window.
// This may happen in cases where the DevTools content fails to load.
scoped_refptr<content::DevToolsAgentHost> agent_host =
content::DevToolsAgentHost::GetOrCreateFor(inspected_contents_);
if (agent_host != agent_host_) {
if (agent_host_) {
agent_host_->DetachClient(this);
}
agent_host_ = agent_host;
agent_host_->AttachClient(this);
if (!inspect_element_at_.IsEmpty()) {
agent_host_->InspectElement(inspected_contents_->GetFocusedFrame(),
inspect_element_at_.x, inspect_element_at_.y);
}
}
}
void CefDevToolsFrontend::WebContentsDestroyed() {
if (agent_host_) {
agent_host_->DetachClient(this);
agent_host_ = nullptr;
}
std::move(frontend_destroyed_callback_).Run();
delete this;
}
void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
base::Value::Dict message) {
const std::string* method = message.FindString("method");
if (!method) {
return;
}
int request_id = message.FindInt("id").value_or(0);
base::Value::List* params_value = message.FindList("params");
// Since we've received message by value, we can take the list.
base::Value::List params;
if (params_value) {
params = std::move(*params_value);
}
if (*method == "dispatchProtocolMessage") {
if (params.size() < 1) {
return;
}
const std::string* protocol_message = params[0].GetIfString();
if (!agent_host_ || !protocol_message) {
return;
}
if (ProtocolLoggingEnabled()) {
LogProtocolMessage(ProtocolMessageType::METHOD, *protocol_message);
}
agent_host_->DispatchProtocolMessage(
this, base::as_bytes(base::make_span(*protocol_message)));
} else if (*method == "loadCompleted") {
web_contents()->GetPrimaryMainFrame()->ExecuteJavaScriptForTests(
u"DevToolsAPI.setUseSoftMenu(true);", base::NullCallback());
} else if (*method == "loadNetworkResource") {
if (params.size() < 3) {
return;
}
// TODO(pfeldman): handle some of the embedder messages in content.
const std::string* url = params[0].GetIfString();
const std::string* headers = params[1].GetIfString();
std::optional<const int> stream_id = params[2].GetIfInt();
if (!url || !headers || !stream_id.has_value()) {
return;
}
GURL gurl(*url);
if (!gurl.is_valid()) {
base::Value::Dict response;
response.Set("statusCode", 404);
response.Set("urlValid", false);
SendMessageAck(request_id, std::move(response));
return;
}
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation(
"devtools_handle_front_end_messages", R"(
semantics {
sender: "Developer Tools"
description:
"When user opens Developer Tools, the browser may fetch "
"additional resources from the network to enrich the debugging "
"experience (e.g. source map resources)."
trigger: "User opens Developer Tools to debug a web page."
data: "Any resources requested by Developer Tools."
destination: OTHER
}
policy {
cookies_allowed: YES
cookies_store: "user"
setting:
"It's not possible to disable this feature from settings."
chrome_policy {
DeveloperToolsAvailability {
policy_options {mode: MANDATORY}
DeveloperToolsAvailability: 2
}
}
})");
// Based on DevToolsUIBindings::LoadNetworkResource.
auto resource_request = std::make_unique<network::ResourceRequest>();
resource_request->url = gurl;
// TODO(caseq): this preserves behavior of URLFetcher-based
// implementation. We really need to pass proper first party origin from
// the front-end.
resource_request->site_for_cookies = net::SiteForCookies::FromUrl(gurl);
resource_request->headers.AddHeadersFromString(*headers);
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory;
if (gurl.SchemeIsFile()) {
mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_remote =
content::CreateFileURLLoaderFactory(
base::FilePath() /* profile_path */,
nullptr /* shared_cors_origin_access_list */);
url_loader_factory = network::SharedURLLoaderFactory::Create(
std::make_unique<network::WrapperPendingSharedURLLoaderFactory>(
std::move(pending_remote)));
} else if (content::HasWebUIScheme(gurl)) {
base::Value::Dict response;
response.Set("statusCode", 403);
SendMessageAck(request_id, std::move(response));
return;
} else {
auto* partition =
inspected_contents_->GetPrimaryMainFrame()->GetStoragePartition();
url_loader_factory = partition->GetURLLoaderFactoryForBrowserProcess();
}
auto simple_url_loader = network::SimpleURLLoader::Create(
std::move(resource_request), traffic_annotation);
auto resource_loader = std::make_unique<NetworkResourceLoader>(
*stream_id, this, std::move(simple_url_loader),
url_loader_factory.get(), request_id);
loaders_.insert(std::move(resource_loader));
return;
} else if (*method == "getHostConfig") {
SendMessageAck(request_id, {});
return;
} else if (*method == "getPreferences") {
SendMessageAck(request_id,
GetPrefs()->GetDict(prefs::kDevToolsPreferences).Clone());
return;
} else if (*method == "setPreference") {
if (params.size() < 2) {
return;
}
const std::string* name = params[0].GetIfString();
// We're just setting params[1] as a value anyways, so just make sure it's
// the type we want, but don't worry about getting it.
if (!name || !params[1].is_string()) {
return;
}
ScopedDictPrefUpdate update(GetPrefs(), prefs::kDevToolsPreferences);
update->Set(*name, std::move(params[1]));
} else if (*method == "removePreference") {
const std::string* name = params[0].GetIfString();
if (!name) {
return;
}
ScopedDictPrefUpdate update(GetPrefs(), prefs::kDevToolsPreferences);
update->Remove(*name);
} else if (*method == "requestFileSystems") {
web_contents()->GetPrimaryMainFrame()->ExecuteJavaScriptForTests(
u"DevToolsAPI.fileSystemsLoaded([]);", base::NullCallback());
} else if (*method == "reattach") {
if (!agent_host_) {
return;
}
agent_host_->DetachClient(this);
agent_host_->AttachClient(this);
} else if (*method == "registerExtensionsAPI") {
if (params.size() < 2) {
return;
}
const std::string* origin = params[0].GetIfString();
const std::string* script = params[1].GetIfString();
if (!origin || !script) {
return;
}
extensions_api_[*origin + "/"] = *script;
} else if (*method == "save") {
if (params.size() < 3) {
return;
}
const std::string* url = params[0].GetIfString();
const std::string* content = params[1].GetIfString();
std::optional<bool> save_as = params[2].GetIfBool();
if (!url || !content || !save_as.has_value()) {
return;
}
file_manager_.SaveToFile(*url, *content, *save_as);
} else if (*method == "append") {
if (params.size() < 2) {
return;
}
const std::string* url = params[0].GetIfString();
const std::string* content = params[1].GetIfString();
if (!url || !content) {
return;
}
file_manager_.AppendToFile(*url, *content);
} else {
return;
}
if (request_id) {
SendMessageAck(request_id, base::Value::Dict());
}
}
void CefDevToolsFrontend::DispatchProtocolMessage(
content::DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) {
if (!frontend_browser_->GetWebContents() ||
frontend_browser_->GetWebContents()->IsBeingDestroyed()) {
return;
}
std::string_view str_message(reinterpret_cast<const char*>(message.data()),
message.size());
if (ProtocolLoggingEnabled()) {
// Quick check to avoid parsing the JSON object. Events begin with a
// "method" value whereas method results begin with an "id" value.
LogProtocolMessage(base::StartsWith(str_message, "{\"method\":")
? ProtocolMessageType::EVENT
: ProtocolMessageType::RESULT,
str_message);
}
if (str_message.length() < kMaxMessageChunkSize) {
CallClientFunction("DevToolsAPI", "dispatchMessage",
base::Value(std::string(str_message)));
} else {
size_t total_size = str_message.length();
for (size_t pos = 0; pos < str_message.length();
pos += kMaxMessageChunkSize) {
std::string_view str_message_chunk =
str_message.substr(pos, kMaxMessageChunkSize);
CallClientFunction(
"DevToolsAPI", "dispatchMessageChunk",
base::Value(std::string(str_message_chunk)),
base::Value(base::NumberToString(pos ? 0 : total_size)));
}
}
}
void CefDevToolsFrontend::CallClientFunction(
const std::string& object_name,
const std::string& method_name,
base::Value arg1,
base::Value arg2,
base::Value arg3,
base::OnceCallback<void(base::Value)> cb) {
std::string javascript;
web_contents()->GetPrimaryMainFrame()->AllowInjectingJavaScript();
base::Value::List arguments;
if (!arg1.is_none()) {
arguments.Append(std::move(arg1));
if (!arg2.is_none()) {
arguments.Append(std::move(arg2));
if (!arg3.is_none()) {
arguments.Append(std::move(arg3));
}
}
}
web_contents()->GetPrimaryMainFrame()->ExecuteJavaScriptMethod(
base::ASCIIToUTF16(object_name), base::ASCIIToUTF16(method_name),
std::move(arguments), std::move(cb));
}
void CefDevToolsFrontend::SendMessageAck(int request_id,
base::Value::Dict arg) {
CallClientFunction("DevToolsAPI", "embedderMessageAck",
base::Value(request_id), base::Value(std::move(arg)));
}
bool CefDevToolsFrontend::ProtocolLoggingEnabled() const {
return !protocol_log_file_.empty();
}
void CefDevToolsFrontend::LogProtocolMessage(ProtocolMessageType type,
const std::string_view& message) {
DCHECK(ProtocolLoggingEnabled());
std::string to_log(message.substr(0, kMaxLogLineLength));
// Execute in an ordered context that allows blocking.
auto task_runner = CefTaskRunnerManager::Get()->GetBackgroundTaskRunner();
task_runner->PostTask(
FROM_HERE, base::BindOnce(::LogProtocolMessage, protocol_log_file_, type,
std::move(to_log)));
}
void CefDevToolsFrontend::AgentHostClosed(
content::DevToolsAgentHost* agent_host) {
DCHECK(agent_host == agent_host_.get());
agent_host_ = nullptr;
Close();
}
PrefService* CefDevToolsFrontend::GetPrefs() const {
return CefBrowserContext::FromBrowserContext(
frontend_browser_->web_contents()->GetBrowserContext())
->AsProfile()
->GetPrefs();
}

View File

@@ -1,114 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_
#include <memory>
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
#include "cef/libcef/browser/alloy/devtools/devtools_file_manager.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_frontend_host.h"
#include "content/public/browser/web_contents_observer.h"
namespace base {
class Value;
}
namespace content {
class NavigationHandle;
class RenderViewHost;
class WebContents;
} // namespace content
class PrefService;
enum class ProtocolMessageType {
METHOD,
RESULT,
EVENT,
};
class CefDevToolsFrontend : public content::WebContentsObserver,
public content::DevToolsAgentHostClient {
public:
CefDevToolsFrontend(const CefDevToolsFrontend&) = delete;
CefDevToolsFrontend& operator=(const CefDevToolsFrontend&) = delete;
static CefDevToolsFrontend* Show(
AlloyBrowserHostImpl* inspected_browser,
const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at,
base::OnceClosure frontend_destroyed_callback);
void Activate();
void Focus();
void InspectElementAt(int x, int y);
void Close();
void CallClientFunction(
const std::string& object_name,
const std::string& method_name,
const base::Value arg1 = {},
const base::Value arg2 = {},
const base::Value arg3 = {},
base::OnceCallback<void(base::Value)> cb = base::NullCallback());
private:
CefDevToolsFrontend(AlloyBrowserHostImpl* frontend_browser,
content::WebContents* inspected_contents,
const CefPoint& inspect_element_at,
base::OnceClosure destroyed_callback);
~CefDevToolsFrontend() override;
// content::DevToolsAgentHostClient implementation.
void AgentHostClosed(content::DevToolsAgentHost* agent_host) override;
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) override;
void HandleMessageFromDevToolsFrontend(base::Value::Dict message);
private:
// WebContentsObserver overrides
void ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) override;
void PrimaryMainDocumentElementAvailable() override;
void WebContentsDestroyed() override;
void SendMessageAck(int request_id, base::Value::Dict arg);
bool ProtocolLoggingEnabled() const;
void LogProtocolMessage(ProtocolMessageType type,
const std::string_view& message);
PrefService* GetPrefs() const;
CefRefPtr<AlloyBrowserHostImpl> frontend_browser_;
raw_ptr<content::WebContents> inspected_contents_;
scoped_refptr<content::DevToolsAgentHost> agent_host_;
CefPoint inspect_element_at_;
base::OnceClosure frontend_destroyed_callback_;
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
class NetworkResourceLoader;
std::set<std::unique_ptr<NetworkResourceLoader>, base::UniquePtrComparator>
loaders_;
using ExtensionsAPIs = std::map<std::string, std::string>;
ExtensionsAPIs extensions_api_;
CefDevToolsFileManager file_manager_;
const base::FilePath protocol_log_file_;
base::WeakPtrFactory<CefDevToolsFrontend> weak_factory_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_

View File

@@ -1,148 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef/libcef/browser/alloy/devtools/devtools_manager_delegate.h"
#include <stdint.h>
#include <vector>
#include "base/atomicops.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "cef/grit/cef_resources.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_frontend_host.h"
#include "content/public/browser/devtools_socket_factory.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/user_agent.h"
#include "net/base/net_errors.h"
#include "net/log/net_log_source.h"
#include "net/socket/tcp_server_socket.h"
#include "ui/base/resource/resource_bundle.h"
namespace {
const int kBackLog = 10;
class TCPServerSocketFactory : public content::DevToolsSocketFactory {
public:
TCPServerSocketFactory(const std::string& address, uint16_t port)
: address_(address), port_(port) {}
TCPServerSocketFactory(const TCPServerSocketFactory&) = delete;
TCPServerSocketFactory& operator=(const TCPServerSocketFactory&) = delete;
private:
// content::DevToolsSocketFactory.
std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
std::unique_ptr<net::ServerSocket> socket(
new net::TCPServerSocket(nullptr, net::NetLogSource()));
if (socket->ListenWithAddressAndPort(address_, port_, kBackLog) !=
net::OK) {
return std::unique_ptr<net::ServerSocket>();
}
return socket;
}
std::unique_ptr<net::ServerSocket> CreateForTethering(
std::string* out_name) override {
return nullptr;
}
std::string address_;
uint16_t port_;
};
std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
// See if the user specified a port on the command line. Specifying 0 will
// result in the selection of an ephemeral port and the port number will be
// printed as part of the WebSocket endpoint URL to stderr. If a cache
// directory path is provided the port will also be written to the
// <cache-dir>/DevToolsActivePort file.
//
// It's not allowed to bind ports between 0 and 1024 exclusive because
// they're normally restricted to root on Posix-based systems.
if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
int port = 0;
std::string port_str =
command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);
if (base::StringToInt(port_str, &port) &&
(0 == port || (port >= 1024 && port < 65535))) {
return std::unique_ptr<content::DevToolsSocketFactory>(
new TCPServerSocketFactory("127.0.0.1", port));
} else {
DLOG(WARNING) << "Invalid http debugger port number '" << port_str << "'";
}
}
return nullptr;
}
} // namespace
// CefDevToolsManagerDelegate ----------------------------------------------
// static
void CefDevToolsManagerDelegate::StartHttpHandler(
content::BrowserContext* browser_context) {
std::unique_ptr<content::DevToolsSocketFactory> socket_factory =
CreateSocketFactory();
if (!socket_factory) {
return;
}
content::DevToolsAgentHost::StartRemoteDebuggingServer(
std::move(socket_factory), browser_context->GetPath(), base::FilePath());
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kRemoteDebuggingPipe)) {
content::DevToolsAgentHost::StartRemoteDebuggingPipeHandler(
base::OnceClosure());
}
}
// static
void CefDevToolsManagerDelegate::StopHttpHandler() {
// This is a no-op if the server was never started.
content::DevToolsAgentHost::StopRemoteDebuggingServer();
}
CefDevToolsManagerDelegate::CefDevToolsManagerDelegate() = default;
CefDevToolsManagerDelegate::~CefDevToolsManagerDelegate() = default;
scoped_refptr<content::DevToolsAgentHost>
CefDevToolsManagerDelegate::CreateNewTarget(
const GURL& url,
content::DevToolsManagerDelegate::TargetType target_type) {
// This is reached when the user selects "Open link in new tab" from the
// DevTools interface.
// TODO(cef): Consider exposing new API to support this.
return nullptr;
}
std::string CefDevToolsManagerDelegate::GetDiscoveryPageHTML() {
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
IDR_CEF_DEVTOOLS_DISCOVERY_PAGE);
}
bool CefDevToolsManagerDelegate::HasBundledFrontendResources() {
return true;
}

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