Compare commits

...

139 Commits
3987 ... 4240

Author SHA1 Message Date
Marshall Greenblatt
85e79d418d Update to Chromium version 86.0.4240.198 2020-11-17 17:44:35 -05:00
Marshall Greenblatt
a2c2edf404 Update to Chromium version 86.0.4240.193 2020-11-10 11:55:42 -05:00
Marshall Greenblatt
3315d732c3 Prevent UB if a WeakPtr to an already-destroyed object is dereferenced.
If a WeakPtr references an already-destroyed object, operator-> and
operator* end up simply dereferencing nullptr. However, dereferencing
nullptr is undefined behavior and can be optimized in surprising ways
by compilers. To prevent this from happening, add a defence of last
resort and CHECK that the WeakPtr is still valid.

Based on https://crrev.com/bbb64b5c69
2020-11-10 11:54:55 -05:00
Marshall Greenblatt
6a2c8e7a58 Update to Chromium version 86.0.4240.183 2020-11-03 16:10:21 -05:00
Marshall Greenblatt
f2039ae1e6 Mac: Fix missing safe_browsing dependency on ntp_background_proto
Fixes the below build error with macOS official builds.

FAILED: obj/chrome/browser/safe_browsing/safe_browsing/settings_reset_prompt_model.o
In file included from ../../chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_model.cc:5:
In file included from ../../chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_model.h:19:
In file included from ../../chrome/browser/profile_resetter/profile_resetter.h:22:
In file included from ../../chrome/browser/search/instant_service.h:20:
In file included from ../../chrome/browser/search/background/ntp_background_service.h:15:
../../chrome/browser/search/background/ntp_background_data.h:10:10: fatal error: 'chrome/browser/search/background/ntp_background.pb.h' file not found
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
2020-10-29 14:44:34 -04:00
Marshall Greenblatt
9c5fca54c5 Windows: Fix focus assignment when clicking WebView with external parent (fixes issue #3031) 2020-10-27 14:31:57 -04:00
Marshall Greenblatt
d3ead8bbaa Update to Chromium version 86.0.4240.111 2020-10-22 20:07:27 -04:00
Sergey Markelov
4a330489a7 Mac: cefclient: Remove duplicated cleanup code 2020-10-15 16:23:37 -04:00
Marshall Greenblatt
76cf508876 Linux: Fix origin calculation for views window tests 2020-10-15 16:08:28 -04:00
Marshall Greenblatt
7674be40d6 Windows: Fix warning C4458: declaration of 'method' hides class member 2020-10-15 16:06:50 -04:00
Cristian Amarie
0b3aeae7cd Windows: Fix duplicate symbol ThrowBadVariantAccess with cef_sandbox build (fixes issue #3021) 2020-10-09 16:27:58 +00:00
Marshall Greenblatt
aae6ed68b6 Update to Chromium version 86.0.4240.75 2020-10-08 22:34:00 -04:00
Marshall Greenblatt
d33ff7fe6a Update to Chromium version 86.0.4240.68 2020-10-01 23:59:23 -04:00
Marshall Greenblatt
d77d73050c Improve documentation related to views screen coordinates (see issue #2980) 2020-09-25 14:31:14 -04:00
Marshall Greenblatt
7cbd964bee Add missing print preview resources and prefs (fixes issue #2989) 2020-09-22 17:41:58 -04:00
Marshall Greenblatt
21f017a346 Linux: cmake: Disable GTK deprecated functions (fixes issue #2791) 2020-09-15 12:44:16 -04:00
Marshall Greenblatt
37c9e4cdf8 Add support for prefers-color-scheme media queries (fixes issue #2824) 2020-09-15 12:35:33 -04:00
Marshall Greenblatt
eecf45514c Fix crash when sending programmatic event to a Views-hosted browser window.
The |web_contents_| member was nullptr in CefBrowserPlatformDelegateNativeAura
when calling methods like SendKeyEvent from CefBrowserPlatformDelegateViews.
2020-09-15 11:14:43 -04:00
Marshall Greenblatt
6c5d52fb54 Persist media device IDs across navigation and restart (fixes issue #2064)
Media device IDs will now be persisted across navigation and reload by default.
The device IDs will also be persisted across restart if --cache-path=<path> and
--persist-user-preferences settings are specified.
2020-09-14 16:34:06 -04:00
Marshall Greenblatt
4cfacc4743 Support CORS preflight requests with OutOfBlinkCors (fixes issue #3006)
A CORS preflight request is an "OPTIONS" request sent to a server prior to a
cross-origin XMLHttpRequest or Fetch request. The server's response determines
which HTTP request methods are allowed and supported, and whether credentials
such as Cookies and HTTP Authentication should be sent with requests.

A CORS preflight request will only be sent if certain conditions are met. For
example, it will be sent for requests that have potentially unsafe HTTP
methods [1] or request headers [2]. See the NeedsPreflight function in
services/network/cors/cors_url_loader.cc for full details.

CORS preflight functionality is implemented in the network service and will not
be triggered if the client handles the request instead of allowing it to proceed
over the network. Since the preflight request itself also runs in the network
service it cannot be intercepted by the client.

[1] https://fetch.spec.whatwg.org/#cors-safelisted-method
[2] https://fetch.spec.whatwg.org/#cors-safelisted-request-header
2020-09-11 19:17:27 -04:00
Marshall Greenblatt
331d3bf3cb Fix incorrect Origin and Cookie headers for POST redirects (fixes issue #2806)
This change also adds unit test coverage for cross-origin POST redirects.
2020-09-09 18:38:54 -04:00
Marshall Greenblatt
172c072ee8 Fix DCHECK failure in the URLLoader constructor.
The request.trusted_params.isolation_info.site_for_cookies value must
match request.site_for_cookies.

This change also adds unit test coverage for cross-origin GET redirects.
2020-09-09 18:38:48 -04:00
Marshall Greenblatt
88c9b2c827 Don't save or load cookies for non-cookieable scheme requests.
This fixes an IsCanonical() DCHECK failure triggered by calling
CanonicalCookie::Create for a non-cookieable URL.

This change also adds unit test coverage for cross-origin cookie
behavior with sub-resource requests (iframe, XHR, Fetch).
2020-09-09 18:38:40 -04:00
Marshall Greenblatt
848d22607d Update to Chromium version 86.0.4240.22 2020-09-03 22:10:36 -04:00
Marshall Greenblatt
59a779c38a Disable Badging API which is not supported (fixes issue #3005) 2020-09-03 17:52:09 -04:00
Marshall Greenblatt
b579b37db4 views: Support specification of screen bounds for CefWindow creation (fixes issue #2980) 2020-09-03 17:51:57 -04:00
Marshall Greenblatt
4aad5f23a0 Include capi sub-directories in API hash calculation 2020-09-03 17:51:22 -04:00
Marshall Greenblatt
e6047bd54b Restore the CefRenderHandler::OnScrollOffsetChanged callback (fixes issue #2810) 2020-09-03 17:51:09 -04:00
Marshall Greenblatt
24c2f2fa38 Update to Chromium version 86.0.4240.0 (#800218)
- CefURLRequest::Create is no longer supported in the renderer process
  (see https://crbug.com/891872). Use CefFrame::CreateURLRequest instead.
- Mac platform definitions have been changed from `MACOSX` to `MAC`
  (see https://crbug.com/1105907) and related CMake macro names have
  been updated. The old `OS_MACOSX` define is still set in code and CMake
  for backwards compatibility.
- Linux ARM build is currently broken (see https://crbug.com/1123214).
2020-09-03 17:44:25 -04:00
Marshall Greenblatt
6b1e5335bc Add support and enable out-of-Blink CORS (fixes issue #2716)
It can still be disabled for a short time by passing
`--disable-features=OutOfBlinkCors` on the command-line.
2020-08-26 16:25:25 -04:00
Marshall Greenblatt
2e94bfafea wrapper: Allow null stream parameter to CefStreamResourceHandler 2020-08-26 16:25:25 -04:00
Marshall Greenblatt
b09cd1a197 ceftests: Add shared test_request and test_server implementations
To reduce text execution time and flakyness this change also
introduces a global test server that is initialized when needed
and torn down after all tests have completed.
2020-08-26 16:23:19 -04:00
Marshall Greenblatt
d63e5bbd8a wrapper: Add thread-specific IMPLEMENT_REFCOUNTING variant 2020-08-26 16:21:51 -04:00
Marshall Greenblatt
6337aa6fad ceftests: Move TrackCallback to a separate header file 2020-08-26 16:21:51 -04:00
Marshall Greenblatt
08ebbb395a ceftests: Fix incorrect include guard #ifdef names 2020-08-26 16:21:30 -04:00
Masako Toda
87c8a72831 Fix initial transparency delay for OSR + gpu-disabled (see issue #2938) 2020-08-13 14:50:40 -04:00
Cristian Amarie
11f37bc6eb Add limit on request redirects (fixes issue #3001) 2020-08-13 18:45:26 +00:00
Marshall Greenblatt
a5d88d697a Update API hash to include enums (see issue #300) 2020-08-07 13:14:41 -04:00
Dmitry Azaraev
f89c0d74dd Include enum declarations into API hash calculation (fixes issue #3000) 2020-08-07 13:03:51 -04:00
Marshall Greenblatt
9e60357fc8 cefbuilds: Improve display time for index.html 2020-08-06 16:10:16 -04:00
Marshall Greenblatt
75e0f9f60e Fix automate-git.py argument error 2020-08-03 15:00:38 -04:00
Marshall Greenblatt
9717d3e1da Add --distrib-subdir-suffix option to make_distrib 2020-08-03 14:37:24 -04:00
Marshall Greenblatt
b822ea43b9 Fix DCHECK when showing print preview dialog (see issue #2952) 2020-07-23 15:46:57 -04:00
Marshall Greenblatt
ac99621829 Fix link navigation from PDF files (fixes issue #2952)
Navigations initiated from a guest view will now be routed to the
OpenURLFromTab callback.
2020-07-23 14:48:25 -04:00
Marshall Greenblatt
99d66db930 Windows: cmake: Simplify the MSVC version check 2020-07-23 12:28:45 -04:00
Czarek Tomczak
c27fceb7de MacOS: Update target SDK to 10.10 for cmake and tests 2020-07-23 12:12:16 -04:00
Marshall Greenblatt
845322b5fb cmake: Update documentation of build requirements and examples 2020-07-21 16:12:43 -04:00
Marshall Greenblatt
ef7e98c616 Fix crash in ThemeService with --disable-extensions (fixes issue #2852) 2020-07-21 13:09:26 -04:00
Masako Toda
a3919cb0ec Fix excessive CPU usage with external and multi-threaded message loops (fixes issue #2809, fixes issue #2970). 2020-07-21 16:26:41 +00:00
Mike Wiedenbauer
034bd641de Return decompressed values from CefResourceBundle (fixes issue #2976) 2020-07-21 15:55:54 +00:00
Masako Toda
ca1c00f95d Fix timing of InstallTransparency for OSR + gpu-disabled (see issue #2938) 2020-07-20 20:01:13 +00:00
Marshall Greenblatt
0add3eaacb cefclient: Fix rendering of example background for OSR transparency (see issue #2938) 2020-07-20 15:43:26 -04:00
Andrei Kurushin
574d4dcedc Fix crash when closing an OSR browser (fixes issue #2919)
Release the Compositor before the WebContents is destroyed to match
the behavior in non-OSR code.
2020-07-20 14:33:00 -04:00
Cristian Amarie
82d6bcbbea Properly disable the notification and push APIs (fixes issue #2951) 2020-07-20 18:16:48 +00:00
Marshall Greenblatt
e87fedd27c Fix shutdown crash in InitNetworkContext with multi-threaded message loop (fixes issue #2985) 2020-07-20 13:49:16 -04:00
Marshall Greenblatt
fab2af8876 Windows: Avoid cef_sandbox compile errors with perfetto (fixes issue #2984) 2020-07-16 19:11:19 -04:00
Marshall Greenblatt
e8573173dd Expose MediaSink device ip/port and model name (see issue #2900) 2020-07-16 19:11:19 -04:00
Marshall Greenblatt
13e3c8b42a Fix official build errors caused by chrome runtime changes (see issue #2969) 2020-07-16 19:11:18 -04:00
Marshall Greenblatt
280c9127c1 Remove render thread created callbacks (see issue #2498)
With site-per-process enabled a spare renderer process will be created
for use with a future browser or navigation. Consequently the
|extra_info| parameter populated in OnRenderProcessThreadCreated will no
longer be delivered to OnRenderThreadCreated in the expected renderer
process. To avoid confusion these callbacks have been removed completely.

After this change CefRenderProcessHandler::OnWebKitInitialized should
be used for startup tasks in the render process, and OnBrowserCreated
should be used in the render process to recieve |extra_info| passed from
CefBrowserHost::CreateBrowser or CefLifeSpanHandler::OnBeforePopup.
2020-07-16 19:11:18 -04:00
Marshall Greenblatt
6573df6cc3 Update to Chromium version 85.0.4183.0 (#782793)
- Windows: 10.0.19041 SDK is now required.
- macOS: 10.15.1 SDK (at least Xcode 11.2) is now required.
- Remove CefMediaSource::IsValid and CefMediaSink::IsValid which would
  always return true.
2020-07-16 19:11:12 -04:00
Marshall Greenblatt
03c9156c80 Fix build and initial Chrome runtime issues on macOS (see issue #2969)
This change moves shared resource initialization to a common location and
disables crash reporting initialization in chrome/ code via patch files.

When using the Chrome runtime on macOS the Chrome application window will
display, but web content is currently blank and the application does not
exit cleanly. This will need to be debugged further in the future.
2020-07-06 15:20:53 -04:00
Marshall Greenblatt
02cdf05848 Move Alloy-specific logic to CefBrowserPlatformDelegateAlloy (see issue #2969)
Also remove OSR-related methods where the attributes can instead be passed
to the OSR platform delegate constructor directly.
2020-07-04 16:13:30 -04:00
Marshall Greenblatt
e9bf3cdb98 Add initial Chrome runtime support for browser APIs (see issue #2969)
This change adds basic Chrome runtime implementations for CefBrowserContext
and CefBrowserPlatformDelegate. A Chrome browser window with default frame
and styling can now be created using CefBrowserHost::CreateBrowser and some
CefClient callbacks will be triggered via the WebContentsObserver
implementation in CefBrowserHostImpl.

Any additional browser windows created via the Chrome UI will be unmanaged
by CEF. The application message loop will block until all browser windows
have been closed by the user.
2020-07-04 16:13:30 -04:00
Marshall Greenblatt
6cb9f0c695 Move browser runtime-specific logic to CefBrowserPlatformDelegate (see issue #2969)
This change moves the runtime-specific implementations of CefBrowserHostImpl
methods to CefBrowserPlatformDelegate. Some WebContentsDelegate methods
implemented by CefBrowserHostImpl set state or trigger client callbacks.
Those implementations will likely stay with CefBrowserHostImpl and will
need to be called from the Browser equivalents when using the Chrome runtime.
2020-07-03 18:09:52 -04:00
Marshall Greenblatt
6152d68b6a Make chrome://chrome-urls an alias for chrome://webui-hosts (fixes issue #2977) 2020-07-02 15:44:48 -04:00
Marshall Greenblatt
88b88251e7 Fix decoding of resources (fixes issue #2966)
Use LoadDataResourceString instead of GetDataResource. It will perform
decoding if necessary.
2020-07-02 14:45:23 -04:00
Marshall Greenblatt
48fc0bd220 Make CefBrowserContext an abstract base class (see issue #2969)
Existing CefBrowserContext functionality is now split between
CefBrowserContext and AlloyBrowserContext. Runtime implementations of
CefBrowserContext will provide access to the content::BrowserContext and
Profile types via different inheritance paths. For example, the Alloy
runtime uses ChromeProfileAlloy and the Chrome runtime uses ProfileImpl.

This change also renames CefResourceContext to CefIOThreadState to more
accurately represent its purpose as it no longer needs to extend
content::ResourceContext.
2020-07-01 15:35:07 -04:00
lwttai.lu
619f18fea0 Windows: File dialog add filter with all supported extensions as default (see issue #860) 2020-06-30 18:45:50 +00:00
Cristian Amarie
7b518511df Fix crash when reading malformed Flash manifest file (fixes issue #2948) 2020-06-30 18:44:14 +00:00
Marshall Greenblatt
5c1118230d Windows: Fix CefCookieVisitor crash on invalid date (fixes issue #2927) 2020-06-30 14:32:48 -04:00
Mike Wiedenbauer
0dfefe391c Fix decoding of the DevTools remote debugging discovery page (fixes issue #2974) 2020-06-30 14:43:48 +00:00
Marshall Greenblatt
b3a8da9b25 Add CefAppManager and remove global ContentClient accessors (see issue #2969)
This is the first pass in removing direct dependencies on the Alloy
runtime from code that can potentially be shared between runtimes.

CefBrowserHost and CefRequestContext APIs (including CefCookieManager,
CefURLRequest, etc.) are not yet implemented for the Chrome runtime.
Assert early if these API methods are called while the Chrome runtime
is enabled.
2020-06-29 16:17:58 -04:00
Marshall Greenblatt
84f3ff2afd Rename the current CEF runtime to Alloy (see issue #2969)
As part of introducing the Chrome runtime we now need to distinguish
between the classes that implement the current CEF runtime and the
classes the implement the shared CEF library/runtime structure and
public API. We choose the name Alloy for the current CEF runtime
because it describes a combination of Chrome and other elements.

Shared CEF library/runtime classes will continue to use the Cef
prefix. Classes that implement the Alloy or Chrome runtime will use
the Alloy or Chrome prefixes respectively. Classes that extend an
existing Chrome-prefixed class will add the Cef or Alloy suffix,
thereby following the existing naming pattern of Chrome-derived
classes.

This change applies the new naming pattern to an initial set of
runtime-related classes. Additional classes/files will be renamed
and moved as the Chrome runtime implementation progresses.
2020-06-29 16:17:41 -04:00
Marshall Greenblatt
f5587b74f0 Set enable_background_mode=false by default (see issue #2969)
This mode doesn't make sense with CEF, and it was causing strange
shutdown crashes when running with Chrome mode enabled.
2020-06-29 16:17:32 -04:00
Marshall Greenblatt
1174994211 Add initial chrome runtime support (see issue #2969)
Running `cefsimple --enable-chrome-runtime` will create and run a
Chrome browser window using the CEF app methods, and call
CefApp::OnContextInitialized as expected. CEF task methods also
work as expected in the main process. No browser-related methods or
callbacks are currently supported for the Chrome window, and the
application will exit when the last Chrome window closes.

The Chrome runtime requires resources.pak, chrome_100_percent.pak
and chrome_200_percent.pak files which were not previously built
with CEF. It shares the existing locales pak files which have been
updated to include additional Chrome-specific strings.

On Linux, the Chrome runtime requires GTK so use_gtk=true must be
specified via GN_DEFINES when building.

This change also refactors the CEF runtime, which can be tested in
the various supported modes by running:
$ cefclient
$ cefclient --multi-threaded-message-loop
$ cefclient --external-message-pump
2020-06-29 16:17:23 -04:00
Marshall Greenblatt
049caf9131 Refactor process execution logic (see issue #2969)
CefContext implements the public CEF API functions and delegates
the stages of content & service_manager process execution to
CefMainRunner. CEF-specific runtime logic (which may be replaced
with chrome-specific runtime logic) is then delegated to
CefMainDelegate which implements content::ContentMainDelegate.
2020-06-29 16:17:13 -04:00
Marshall Greenblatt
39aed35644 Add support for direct DevTools protocol messaging (fixes issue #2961).
This change allows the client to directly send and receive DevTools
protocol messages (send method calls, and receive method results and
events) without requiring a DevTools front-end or remote-debugging
session.

This change includes additional supporting changes:
- Add a new CefRequestHandler::OnDocumentAvailableInMainFrame
  callback (see issue #1454).
- Add a CefParseJSON variant that accepts a UTF8-encoded buffer.
- Add a `--devtools-protocol-log-file=<path>` command-line flag for
  logging protocol messages sent to/from the DevTools front-end
  while it is displayed. This is useful for understanding existing
  DevTools protocol usage.
- Add a new "libcef_static_unittests" executable target to support
  light-weight unit tests of libcef_static internals (e.g. without
  requiring exposure via the CEF API). Files to be unittested are
  placed in the new "libcef_static_unittested" source_set which is
  then included by both the existing libcef_static library and the
  new unittests executable target.
- Linux: Remove use_bundled_fontconfig=false, which is no longer
  required and causes unittest build errors (see issue #2424).

This change also adds a cefclient demo for configuring offline mode
using the DevTools protocol (fixes issue #245). This is controlled
by the "Offline mode" context menu option and the `--offline`
command-line switch which will launch cefclient in offline mode. When
cefclient is offline all network requests will fail with
ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when
called from JavaScript in any frame. This mode is per-browser so
newly created browser windows will have the default mode. Note that
configuring offline mode in this way will not update the Network tab
UI ("Throtting" option) in a displayed DevTools front-end instance.
2020-06-19 22:15:22 -04:00
Marshall Greenblatt
a9aef28966 Improve AudioOutputTest.AudioTogglePlaybackTest to avoid flakyness. 2020-06-10 15:26:40 -04:00
Alexander Guettler
790d248111 Update to Chromium version 84.0.4147.0 (#768962) 2020-06-10 15:26:29 -04:00
Marshall Greenblatt
640cd0f411 Remove duplicate local_discovery file entries (see issue #2900)
This fixes duplicate symbol errors when linking libcef on Linux. These files
are now included by default with enable_service_discovery=true.
2020-05-26 12:32:40 -04:00
Marshall Greenblatt
cfe8e320be Enable DNS-SD discovery for cast devices (see issue #2900) 2020-05-25 16:54:45 -04:00
Marshall Greenblatt
5780bf40d4 Linux: Fix undefined symbol: ui::GtkUiDelegate::SetInstance
See https://crbug.com/1085806 for details.
2020-05-22 14:56:09 -04:00
Marshall Greenblatt
31d3e88d32 Add |client_| nullptr check in CefBrowserHostImpl::CanDragEnter (fixes issue #2934) 2020-05-13 14:30:44 -04:00
Marshall Greenblatt
7ecaa8afdd Windows: Add VS2019 path discovery to msvs_env.bat (fixes issue #2925) 2020-05-13 13:23:05 -04:00
Marshall Greenblatt
8c996d2efd Remember the user-selected printer by default (fixes issue #2875) 2020-05-13 13:10:08 -04:00
Marshall Greenblatt
d8b4281c06 Fix window.print() of PDF file (fixes issue #2987) 2020-05-12 16:25:13 -04:00
Marshall Greenblatt
c82eb3e80f Windows: cefclient: Fix return value check for AcquireSync (fixes issue #2933) 2020-05-12 15:41:20 -04:00
Marshall Greenblatt
14571658a2 Fix load of non-standard custom scheme URI as iframe src (see issue #2929) 2020-05-11 18:12:34 -04:00
Marshall Greenblatt
aa4473e2c6 Fix registration of WebSafe schemes (fixes issue #2929) 2020-05-11 18:11:53 -04:00
Marshall Greenblatt
9deef4189c Update AUTHORS.txt documentation 2020-05-08 12:35:04 -04:00
Marshall Greenblatt
25d81e0f1d Update AUTHORS.txt documentation 2020-05-08 12:25:35 -04:00
Marshall Greenblatt
70590a759d Update API hash for audio handler changes (see issue #2755) 2020-05-01 14:24:53 -04:00
Mike Wiedenbauer
8d01442d75 Re-implement audio capturing based on the AudioService API (fixes issue #2755) 2020-05-01 18:18:18 +00:00
Marshall Greenblatt
d65483ae16 Update cef_api_hash.h at build time if necessary (fixes issue #2922)
The cef_api_hash.h file was previously only updated when the translator tool
was run manually. Forgetting to run the translator tool after changing
include/internal/cef_types*.h files would result in cef_parser.py
incorrectly computing the CEF minor version number for future builds. By
updating this file automatically at build time the number of errors should be
reduced.
2020-04-30 17:52:10 -04:00
Marshall Greenblatt
7c6e53ddfb Save LocalPrefs.json in CefSettings.root_cache_path (see issue #2890) 2020-04-29 15:36:29 -04:00
Marshall Greenblatt
ff0c36b465 Add CefMediaSink::GetIconType (see issue #2900)
This attribute is useful for identifying different classes of cast devices
without first requiring a connection (CAST, CAST_AUDIO, CAST_AUDIO_GROUP, etc).
2020-04-29 15:01:12 -04:00
Vladislav
dafce45e49 Fix OSR resize issue with DPI scaling (fixes issue #2733) 2020-04-27 16:48:06 +00:00
Dmitry Azaraev
be6af15754 Add SameSite (same_site) and Priority attributes to CefCookie (fixes issue #2524)
This change also restores the Chromium default values for the
SameSiteByDefaultCookies and CookiesWithoutSameSiteMustBeSecure features. See
https://www.chromium.org/updates/same-site for feature details and rollout
timeline.
2020-04-24 17:48:26 -04:00
Marshall Greenblatt
cbc0625272 Revert "Fix background color assignment for popups (fixes issue #2482)"
This change is causing the OSRTest.OsrPopupJSOtherClient test to fail.

This reverts commit 3adb801ca8.
2020-04-24 15:41:07 -04:00
Marshall Greenblatt
fd1f465fa7 Normalize path values and add additional error logging (fixes issue #2405)
This change also improves the settings documentation and enforces the
requirement that path values be absolute (see issue #2916).
2020-04-23 17:51:19 -04:00
Marshall Greenblatt
8ed39e4ae5 Fix transposed variables in GetRequestInfo (fixes issue #2530) 2020-04-23 14:40:19 -04:00
Marshall Greenblatt
3adb801ca8 Fix background color assignment for popups (fixes issue #2482) 2020-04-23 13:47:10 -04:00
Marshall Greenblatt
ccf7b28723 Fix PDF extension loading of large files (fixes issue #2905)
The PDF extension will send Range requests when loading large PDF files. For
these cross-origin requests to be allowed (from extension origin to PDF origin)
the CORB checks in URLLoader must be disabled.
2020-04-22 16:26:22 -04:00
Alex Maitland
e876217e24 Change cef_pdf_print_settings_t custom margins from double to int (fixes issue #2694) 2020-04-21 18:44:52 +00:00
Mike Wiedenbauer
ec0c57d0e1 Fix OSR keyboard input for editable PDF (fixes issue #2907) 2020-04-21 18:30:52 +00:00
Jengerer
87a7c4f94b Fix handling of partial range request (fixes issue #2873) 2020-04-20 13:19:42 -04:00
Marshall Greenblatt
27257d0288 Remove DCHECK in InterceptedRequest::OnReceiveRedirect (fixes issue #2917) 2020-04-20 12:38:31 -04:00
Marshall Greenblatt
245bc9bfab Windows: Early init parental controls to avoid blocking assertions 2020-04-15 21:46:31 -04:00
Marshall Greenblatt
fa519f5108 Update to Chromium version 83.0.4103.0 (#756066) 2020-04-15 16:47:50 -04:00
Mike Wiedenbauer
30d83cb94a Fix AltGr handling for OSR keyboard events (fixes issue #2892) 2020-04-08 15:43:39 +00:00
Mike Wiedenbauer
f5c79bf50c Linux: Fix CefPrintHandler callbacks from PDF viewer (fixes issue #2906) 2020-04-02 21:26:14 +00:00
Andrei Kurushin
ea1324a9f1 Windows: cefclient: Fix accessibility where TreeId type has changed from int to string 2020-04-02 21:19:25 +00:00
Andy Tzeng
261a8899fc Fix UU_REPLACE_PLUS_WITH_SPACE value to match Chromium (fixes issue #2904) 2020-04-02 21:16:52 +00:00
Vladislav
a5de549456 Fix OSR popup position when the view origin is offset in screen coords (fixes issue #2902) 2020-04-02 21:14:28 +00:00
rcdrone
bdaa857c49 Windows: Disable the sandbox if windows_sandbox_info is null
This restores the behavior prior to revision 438382c. Calling
InitializeSandboxInfo from inside libcef won’t work unless libcef is
statically linked with the executable, so there's no point in doing so.
See the Chromium sandbox docs for background.
2020-04-02 21:11:16 +00:00
Cristian Amarie
1c14900093 Remove unexpected content headers when converting from POST to GET request on 302 redirect response (fixes issue #2883) 2020-04-02 21:05:07 +00:00
Andrei Kurushin
01f385a6f7 Fix CefFrame::GetSource crash on detached frame (fixes issue #2898) 2020-04-02 21:01:33 +00:00
Mike Wiedenbauer
cf6b57d659 Enable smooth scrolling with OSR (fixes issue #2895) 2020-04-02 20:59:26 +00:00
Marshall Greenblatt
f742ab4994 Mac: Remove unicode character in README.redistrib.txt (fixes issue #2910) 2020-04-02 13:44:27 -04:00
Marshall Greenblatt
cfac1c347c Fix no newline at end of file error with Xcode 11.3.1 2020-04-02 13:36:45 -04:00
Marshall Greenblatt
047e8f9349 Update to Chromium version 82.0.4085.0 (#749737)
- Building on macOS now requires the 10.15 SDK. Xcode 11.3 is recommended as
  Xcode 11.4 is not currently supported (see https://crbug.com/1065146).
- Jumbo build configuration is no longer supported.

Chromium is skipping the M82 release and consequently no CEF 4085 branch will
be created. For details on the Chromium decision see
https://groups.google.com/a/chromium.org/d/msg/chromium-dev/Vn7uzglqLz0/JItlSrZxBAAJ
2020-04-02 13:20:25 -04:00
Marshall Greenblatt
3d87a68561 Always persist local_state by default (fixes issue #2890)
If a cache_path is specified local_state will now be persisted to a
LocalPrefs.json file. This is necessary because local_state is used to store
the cookie encryption key on Windows.
2020-04-01 17:06:19 -04:00
Marshall Greenblatt
66433c1869 Windows: Fix warning C4457: declaration of 'result' hides function parameter in VS2019 2020-04-01 17:06:19 -04:00
Marshall Greenblatt
869ae21c9f Convert CefCookieManagerImpl to use CefBrowserContext::Getter.
With this change CefCookieManagerImpl no longer keeps a reference to the
originating CefRequestContextImpl. This means that the CefRequestContextImpl
can be destroyed if all other references are released while the
CefCookieManagerImpl exists. If CefRequestContextImpl destruction results in
the underlying CefBrowserContext being destroyed then the CefCookieManagerImpl's
reference to that CefBrowserContext will be invalidated.

This is the same ownership model introduced with CefMediaRouterImpl in the
previous commit.
2020-03-27 16:22:34 -04:00
Marshall Greenblatt
03fd5b15da Add support for media device discovery and messaging (fixes issue #2900)
Chromium supports communication with media devices on the local network via
the Cast and DIAL protocols. This takes two primary forms:

1. Messaging, where strings representing state information are passed between
   the client and a dedicated receiver app on the media device. The receiver
   app communicates directly with an app-specific backend service to retrieve
   and possibly control media playback.
2. Tab/desktop mirroring, where the media contents are streamed directly from
   the browser to a generic streaming app on the media device and playback is
   controlled by the browser.

This change adds support for device discovery and messaging (but not
mirroring) with functionality exposed via the new CefMediaRouter interface.

To test: Navigate to http://tests/media_router in cefclient and follow the
on-screen instructions.
2020-03-27 15:54:39 -04:00
Vladislav
fecd582035 Fix OSR crash on window.open with new client (fixes issue #2894) 2020-03-06 19:51:58 +00:00
Andy Tzeng
180e9bd362 Support fragment (hash) component in CefParseURL (fixes issue #2896) 2020-03-06 17:40:28 +00:00
Marshall Greenblatt
2fbb6ba1e9 automate-git: Add support for depot_tools version pinning (fixes issue #2893) 2020-03-06 11:42:08 -05:00
Marshall Greenblatt
51e12b3866 automate-git: Remove support for branches older than 3071.
3071 and newer branches use Git and GN exclusively.
2020-03-05 13:56:17 -05:00
rcdrone
a6f9d78c1c Windows: Skip InitializeSandboxInfo if no_sandbox is true
The InitializeSandboxInfo method applies mitigations to the main process
that are inappropriate when the sandbox is disabled.
2020-03-05 17:53:13 +00:00
rcdrone
8cf82c24dc Windows: Skip InitializeSandboxInfo if no_sandbox is true
The InitializeSandboxInfo method applies mitigations to the main process
that are inappropriate when the sandbox is disabled.
2020-03-05 17:52:51 +00:00
rcdrone
438382c5df Windows: Skip InitializeSandboxInfo if no_sandbox is true
The InitializeSandboxInfo method applies mitigations to the main process
that are inappropriate when the sandbox is disabled.
2020-03-05 17:52:41 +00:00
Marshall Greenblatt
1ab44722e8 Windows: Fix ScreenlockMonitorDeviceSource window creation error.
See https://crbug.com/1058556 for details.
2020-03-04 19:31:55 -05:00
Marshall Greenblatt
4291776473 Windows: Update cef_sandbox mitigations to match Chromium 2020-03-04 19:31:55 -05:00
Marshall Greenblatt
06a5ef3cd8 automate-git: Windows: Patch VS toolchain scripts before runhooks
Split `gclient sync` into separate `gclient sync --nohooks` and
`gclient runhooks` steps so that we can optionally apply patches
from `runhooks.patch` in-between. This is necessary because the
src/tools/clang/scripts/update.py script is run via a hook and has
dependencies on the VS toolchain scripts which must be patched to
properly consider the GYP_MSVS_VERSION environment variable.
2020-03-04 19:31:54 -05:00
Marshall Greenblatt
9d9ee8b45f Update to Chromium version 81.0.4044.0 (#737173) 2020-03-04 19:31:54 -05:00
Marshall Greenblatt
a22b670a00 automate-git: Remove unsupported --disable-syntax-validation flag 2020-03-03 23:00:58 -05:00
Marshall Greenblatt
8c6cc302d0 Fix OSR surface sizing on browser resize (fixes issue #2733).
This includes the following changes:
- Update usage of surface IDs to match the Aura implementation from the
  RWHVAura/Window classes.
- Batch CefBrowserHost::WasResized calls to avoid excessive/unnecessary calls
  to SynchronizeVisualProperties.
- Cache the results of CefRenderHandler::GetViewRect after resize and make
  RWHVOSR::GetViewBounds the source of truth for all size calculations.
- Fix bounds calculations in CefVideoConsumerOSR with GPU enabled.

Known issues:
- The size passed to OnPaint may be off by 1 pixel in cases where the device
  scale factor is not 1 and does not divide evenly into the pixel size. This is
  due to the inexact conversion from integer pixel size to integer logical size
  for GetViewRect.
2020-02-21 15:02:52 -05:00
Iain Apreotesei
afcee77abe Windows: Add ARM64 binary distribution support (see issue #2773) 2020-02-19 16:33:27 +00:00
594 changed files with 26762 additions and 9980 deletions

View File

@@ -1,6 +1,8 @@
# This file is an addendum to the Chromium AUTHORS file. # This file is an addendum to the Chromium AUTHORS file. It lists authors
# Names should be added to this file like so: # through March 16, 2015 when Git was introduced for source code management.
# Name or Organization <email address> # A list of additional authors added after that date can be found by executing
# this command on a local Git checkout:
# git log --all --format="%aN <%aE>" | sort -u
Marshall Greenblatt <magreenblatt@gmail.com> Marshall Greenblatt <magreenblatt@gmail.com>
Jamie Kirkpatrick <jkp@spotify.com> Jamie Kirkpatrick <jkp@spotify.com>

360
BUILD.gn
View File

@@ -106,6 +106,7 @@ import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni") import("//mojo/public/tools/bindings/mojom.gni")
import("//ppapi/buildflags/buildflags.gni") import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni") import("//printing/buildflags/buildflags.gni")
import("//testing/test.gni")
import("//third_party/icu/config.gni") import("//third_party/icu/config.gni")
import("//third_party/widevine/cdm/widevine.gni") import("//third_party/widevine/cdm/widevine.gni")
import("//tools/grit/repack.gni") import("//tools/grit/repack.gni")
@@ -121,8 +122,8 @@ if (is_linux) {
import("//third_party/fontconfig/fontconfig.gni") import("//third_party/fontconfig/fontconfig.gni")
} }
if (is_mac) { if (is_mac) {
import("//build/apple/tweak_info_plist.gni")
import("//build/config/mac/rules.gni") import("//build/config/mac/rules.gni")
import("//build/mac/tweak_info_plist.gni")
import("//build/util/version.gni") import("//build/util/version.gni")
import("//media/cdm/library_cdm/cdm_paths.gni") import("//media/cdm/library_cdm/cdm_paths.gni")
import("//build/config/mac/base_rules.gni") import("//build/config/mac/base_rules.gni")
@@ -253,7 +254,6 @@ if (is_linux) {
# Set ENABLE_PRINTING=1 ENABLE_BASIC_PRINTING=1. # Set ENABLE_PRINTING=1 ENABLE_BASIC_PRINTING=1.
assert(enable_basic_printing) assert(enable_basic_printing)
assert(enable_print_preview) assert(enable_print_preview)
assert(!enable_service_discovery)
# Enable support for Widevine CDM. # Enable support for Widevine CDM.
assert(enable_widevine) assert(enable_widevine)
@@ -263,12 +263,6 @@ if (is_clang) {
assert(!clang_use_chrome_plugins) assert(!clang_use_chrome_plugins)
} }
if (is_linux) {
# Use system fontconfig. This avoids a startup hang on Ubuntu 16.04.4 (see
# issue #2424).
assert(!use_bundled_fontconfig)
}
if (is_mac) { if (is_mac) {
# Always generate dSYM files. The make_distrib script will fail if # Always generate dSYM files. The make_distrib script will fail if
# enable_dsyms=true is not explicitly set when is_official_build=false. # enable_dsyms=true is not explicitly set when is_official_build=false.
@@ -303,6 +297,10 @@ gypi_paths2 = exec_script("//cef/tools/gypi_to_gn.py",
"scope", "scope",
[ "cef_paths2.gypi" ]) [ "cef_paths2.gypi" ])
includes_common = gypi_paths2.includes_common + gypi_paths2.includes_common_capi
includes_mac = gypi_paths2.includes_mac + gypi_paths2.includes_mac_capi
includes_linux = gypi_paths2.includes_linux + gypi_paths2.includes_linux_capi
includes_win = gypi_paths2.includes_win + gypi_paths2.includes_win_capi
# #
# Targets that will be built when depending on "//cef". # Targets that will be built when depending on "//cef".
@@ -313,6 +311,7 @@ group("cef") {
deps = [ deps = [
":cefsimple", ":cefsimple",
":ceftests", ":ceftests",
":libcef_static_unittests",
] ]
if (!is_linux || use_x11) { if (!is_linux || use_x11) {
@@ -370,9 +369,60 @@ if (is_win) {
} }
} }
# libcef_static source files that have unit tests.
source_set("libcef_static_unittested") {
sources = [
"libcef/browser/devtools/devtools_util.cc",
"libcef/browser/devtools/devtools_util.h",
]
deps = [
"//base",
]
configs += [
"libcef/features:config",
"//build/config:precompiled_headers",
]
}
# Executable target for libcef_static unit tests.
test("libcef_static_unittests") {
sources = [
"libcef/browser/devtools/devtools_util_unittest.cc",
]
deps = [
":libcef_static_unittested",
"//base/test:run_all_unittests",
"//testing/gtest",
]
configs += [
"libcef/features:config",
"//build/config:precompiled_headers",
]
}
static_library("libcef_static") { static_library("libcef_static") {
sources = gypi_paths2.includes_common + sources = includes_common +
gypi_paths.autogen_cpp_includes + [ gypi_paths.autogen_cpp_includes + [
"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/browser_platform_delegate_alloy.cc",
"libcef/browser/alloy/browser_platform_delegate_alloy.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/alloy/alloy_content_browser_client.cc",
"libcef/browser/alloy/alloy_content_browser_client.h",
"libcef/browser/audio_capturer.cc",
"libcef/browser/audio_capturer.h",
"libcef/browser/browser_context.cc", "libcef/browser/browser_context.cc",
"libcef/browser/browser_context.h", "libcef/browser/browser_context.h",
"libcef/browser/browser_context_keyed_service_factories.cc", "libcef/browser/browser_context_keyed_service_factories.cc",
@@ -383,8 +433,6 @@ static_library("libcef_static") {
"libcef/browser/browser_info.h", "libcef/browser/browser_info.h",
"libcef/browser/browser_info_manager.cc", "libcef/browser/browser_info_manager.cc",
"libcef/browser/browser_info_manager.h", "libcef/browser/browser_info_manager.h",
"libcef/browser/browser_main.cc",
"libcef/browser/browser_main.h",
"libcef/browser/browser_message_filter.cc", "libcef/browser/browser_message_filter.cc",
"libcef/browser/browser_message_filter.h", "libcef/browser/browser_message_filter.h",
"libcef/browser/browser_message_loop.cc", "libcef/browser/browser_message_loop.cc",
@@ -394,23 +442,27 @@ static_library("libcef_static") {
"libcef/browser/browser_platform_delegate_create.cc", "libcef/browser/browser_platform_delegate_create.cc",
"libcef/browser/browser_util.cc", "libcef/browser/browser_util.cc",
"libcef/browser/browser_util.h", "libcef/browser/browser_util.h",
"libcef/browser/chrome_browser_process_stub.cc", "libcef/browser/chrome/browser_platform_delegate_chrome.cc",
"libcef/browser/chrome_browser_process_stub.h", "libcef/browser/chrome/browser_platform_delegate_chrome.h",
"libcef/browser/chrome/chrome_browser_context.cc",
"libcef/browser/chrome/chrome_browser_context.h",
"libcef/browser/chrome/chrome_browser_main_extra_parts_cef.cc",
"libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h",
"libcef/browser/chrome/chrome_content_browser_client_cef.cc",
"libcef/browser/chrome/chrome_content_browser_client_cef.h",
"libcef/browser/chrome_crash_reporter_client_stub.cc", "libcef/browser/chrome_crash_reporter_client_stub.cc",
"libcef/browser/chrome_profile_manager_stub.cc",
"libcef/browser/chrome_profile_manager_stub.h",
"libcef/browser/chrome_profile_stub.cc",
"libcef/browser/chrome_profile_stub.h",
"libcef/browser/content_browser_client.cc",
"libcef/browser/content_browser_client.h",
"libcef/browser/context.cc", "libcef/browser/context.cc",
"libcef/browser/context.h", "libcef/browser/context.h",
"libcef/browser/context_menu_params_impl.cc", "libcef/browser/context_menu_params_impl.cc",
"libcef/browser/context_menu_params_impl.h", "libcef/browser/context_menu_params_impl.h",
"libcef/browser/devtools/devtools_controller.cc",
"libcef/browser/devtools/devtools_controller.h",
"libcef/browser/devtools/devtools_file_manager.cc", "libcef/browser/devtools/devtools_file_manager.cc",
"libcef/browser/devtools/devtools_file_manager.h", "libcef/browser/devtools/devtools_file_manager.h",
"libcef/browser/devtools/devtools_frontend.cc", "libcef/browser/devtools/devtools_frontend.cc",
"libcef/browser/devtools/devtools_frontend.h", "libcef/browser/devtools/devtools_frontend.h",
"libcef/browser/devtools/devtools_manager.cc",
"libcef/browser/devtools/devtools_manager.h",
"libcef/browser/devtools/devtools_manager_delegate.cc", "libcef/browser/devtools/devtools_manager_delegate.cc",
"libcef/browser/devtools/devtools_manager_delegate.h", "libcef/browser/devtools/devtools_manager_delegate.h",
"libcef/browser/download_item_impl.cc", "libcef/browser/download_item_impl.cc",
@@ -468,11 +520,25 @@ static_library("libcef_static") {
"libcef/browser/frame_host_impl.h", "libcef/browser/frame_host_impl.h",
"libcef/browser/image_impl.cc", "libcef/browser/image_impl.cc",
"libcef/browser/image_impl.h", "libcef/browser/image_impl.h",
"libcef/browser/iothread_state.cc",
"libcef/browser/iothread_state.h",
"libcef/browser/javascript_dialog_runner.h", "libcef/browser/javascript_dialog_runner.h",
"libcef/browser/javascript_dialog_manager.cc", "libcef/browser/javascript_dialog_manager.cc",
"libcef/browser/javascript_dialog_manager.h", "libcef/browser/javascript_dialog_manager.h",
"libcef/browser/main_runner.cc",
"libcef/browser/main_runner.h",
"libcef/browser/media_capture_devices_dispatcher.cc", "libcef/browser/media_capture_devices_dispatcher.cc",
"libcef/browser/media_capture_devices_dispatcher.h", "libcef/browser/media_capture_devices_dispatcher.h",
"libcef/browser/media_router/media_route_impl.cc",
"libcef/browser/media_router/media_route_impl.h",
"libcef/browser/media_router/media_router_impl.cc",
"libcef/browser/media_router/media_router_impl.h",
"libcef/browser/media_router/media_router_manager.cc",
"libcef/browser/media_router/media_router_manager.h",
"libcef/browser/media_router/media_sink_impl.cc",
"libcef/browser/media_router/media_sink_impl.h",
"libcef/browser/media_router/media_source_impl.cc",
"libcef/browser/media_router/media_source_impl.h",
"libcef/browser/menu_manager.cc", "libcef/browser/menu_manager.cc",
"libcef/browser/menu_manager.h", "libcef/browser/menu_manager.h",
"libcef/browser/menu_model_impl.cc", "libcef/browser/menu_model_impl.cc",
@@ -551,8 +617,6 @@ static_library("libcef_static") {
"libcef/browser/printing/print_view_manager.cc", "libcef/browser/printing/print_view_manager.cc",
"libcef/browser/printing/print_view_manager.h", "libcef/browser/printing/print_view_manager.h",
"libcef/browser/process_util_impl.cc", "libcef/browser/process_util_impl.cc",
"libcef/browser/resource_context.cc",
"libcef/browser/resource_context.h",
"libcef/browser/request_context_handler_map.cc", "libcef/browser/request_context_handler_map.cc",
"libcef/browser/request_context_handler_map.h", "libcef/browser/request_context_handler_map.h",
"libcef/browser/request_context_impl.cc", "libcef/browser/request_context_impl.cc",
@@ -586,6 +650,14 @@ static_library("libcef_static") {
"libcef/browser/xml_reader_impl.h", "libcef/browser/xml_reader_impl.h",
"libcef/browser/zip_reader_impl.cc", "libcef/browser/zip_reader_impl.cc",
"libcef/browser/zip_reader_impl.h", "libcef/browser/zip_reader_impl.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/app_manager.cc",
"libcef/common/app_manager.h",
"libcef/common/base_impl.cc", "libcef/common/base_impl.cc",
"libcef/common/cef_message_generator.cc", "libcef/common/cef_message_generator.cc",
"libcef/common/cef_message_generator.h", "libcef/common/cef_message_generator.h",
@@ -593,10 +665,14 @@ static_library("libcef_static") {
"libcef/common/cef_messages.h", "libcef/common/cef_messages.h",
"libcef/common/cef_switches.cc", "libcef/common/cef_switches.cc",
"libcef/common/cef_switches.h", "libcef/common/cef_switches.h",
"libcef/common/chrome/chrome_content_client_cef.cc",
"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.cc",
"libcef/common/command_line_impl.h", "libcef/common/command_line_impl.h",
"libcef/common/content_client.cc",
"libcef/common/content_client.h",
"libcef/common/crash_reporter_client.cc", "libcef/common/crash_reporter_client.cc",
"libcef/common/crash_reporter_client.h", "libcef/common/crash_reporter_client.h",
"libcef/common/crash_reporting.cc", "libcef/common/crash_reporting.cc",
@@ -615,8 +691,8 @@ static_library("libcef_static") {
"libcef/common/frame_util.cc", "libcef/common/frame_util.cc",
"libcef/common/frame_util.h", "libcef/common/frame_util.h",
"libcef/common/json_impl.cc", "libcef/common/json_impl.cc",
"libcef/common/main_delegate.cc", "libcef/common/main_runner_delegate.h",
"libcef/common/main_delegate.h", "libcef/common/main_runner_handler.h",
"libcef/common/net/http_header_utils.cc", "libcef/common/net/http_header_utils.cc",
"libcef/common/net/http_header_utils.h", "libcef/common/net/http_header_utils.h",
"libcef/common/net/net_resource_provider.cc", "libcef/common/net/net_resource_provider.cc",
@@ -638,6 +714,8 @@ static_library("libcef_static") {
"libcef/common/resource_bundle_delegate.h", "libcef/common/resource_bundle_delegate.h",
"libcef/common/resource_bundle_impl.cc", "libcef/common/resource_bundle_impl.cc",
"libcef/common/resource_bundle_impl.h", "libcef/common/resource_bundle_impl.h",
"libcef/common/resource_util.cc",
"libcef/common/resource_util.h",
"libcef/common/response_impl.cc", "libcef/common/response_impl.cc",
"libcef/common/response_impl.h", "libcef/common/response_impl.h",
"libcef/common/response_manager.cc", "libcef/common/response_manager.cc",
@@ -651,6 +729,8 @@ static_library("libcef_static") {
"libcef/common/task_impl.cc", "libcef/common/task_impl.cc",
"libcef/common/task_runner_impl.cc", "libcef/common/task_runner_impl.cc",
"libcef/common/task_runner_impl.h", "libcef/common/task_runner_impl.h",
"libcef/common/task_runner_manager.cc",
"libcef/common/task_runner_manager.h",
"libcef/common/test/translator_test_impl.cc", "libcef/common/test/translator_test_impl.cc",
"libcef/common/thread_impl.cc", "libcef/common/thread_impl.cc",
"libcef/common/thread_impl.h", "libcef/common/thread_impl.h",
@@ -667,10 +747,12 @@ static_library("libcef_static") {
"libcef/common/waitable_event_impl.h", "libcef/common/waitable_event_impl.h",
"libcef/common/widevine_loader.cc", "libcef/common/widevine_loader.cc",
"libcef/common/widevine_loader.h", "libcef/common/widevine_loader.h",
"libcef/features/runtime.h",
"libcef/features/runtime_checks.h",
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
"libcef/renderer/alloy/alloy_content_renderer_client.h",
"libcef/renderer/browser_impl.cc", "libcef/renderer/browser_impl.cc",
"libcef/renderer/browser_impl.h", "libcef/renderer/browser_impl.h",
"libcef/renderer/content_renderer_client.cc",
"libcef/renderer/content_renderer_client.h",
"libcef/renderer/dom_document_impl.cc", "libcef/renderer/dom_document_impl.cc",
"libcef/renderer/dom_document_impl.h", "libcef/renderer/dom_document_impl.h",
"libcef/renderer/dom_node_impl.cc", "libcef/renderer/dom_node_impl.cc",
@@ -697,16 +779,9 @@ static_library("libcef_static") {
"libcef/renderer/v8_impl.cc", "libcef/renderer/v8_impl.cc",
"libcef/renderer/v8_impl.h", "libcef/renderer/v8_impl.h",
"//chrome/browser/local_discovery/service_discovery_device_lister.cc", # For Chrome runtime support.
"//chrome/browser/local_discovery/service_discovery_device_lister.h", "//chrome/app/chrome_main_delegate.cc",
"//chrome/browser/local_discovery/service_discovery_client_impl.cc", "//chrome/app/chrome_main_delegate.h",
"//chrome/browser/local_discovery/service_discovery_client_impl.h",
"//chrome/browser/local_discovery/service_discovery_client.cc",
"//chrome/browser/local_discovery/service_discovery_client.h",
"//chrome/browser/local_discovery/service_discovery_client_mdns.cc",
"//chrome/browser/local_discovery/service_discovery_client_mdns.h",
"//chrome/browser/local_discovery/service_discovery_shared_client.cc",
"//chrome/browser/local_discovery/service_discovery_shared_client.h",
] ]
configs += [ configs += [
@@ -733,7 +808,8 @@ static_library("libcef_static") {
deps = [ deps = [
":cef_make_headers", ":cef_make_headers",
":cef_service_manifests",
":libcef_static_unittested",
# Generate API bindings for extensions. # Generate API bindings for extensions.
# TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See # TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See
@@ -747,12 +823,13 @@ static_library("libcef_static") {
"//base:base_static", "//base:base_static",
"//base/third_party/dynamic_annotations", "//base/third_party/dynamic_annotations",
"//cc", "//cc",
"//chrome/browser", "//chrome:browser_dependencies",
"//chrome/child", "//chrome:child_dependencies",
"//chrome/common", "//chrome:packed_resources",
"//chrome/renderer", "//chrome:resources",
"//chrome:strings",
"//chrome/common:buildflags",
"//chrome/services/printing:lib", "//chrome/services/printing:lib",
"//chrome/utility",
"//components/cdm/renderer", "//components/cdm/renderer",
"//components/certificate_transparency", "//components/certificate_transparency",
"//components/content_settings/core/browser", "//components/content_settings/core/browser",
@@ -763,7 +840,7 @@ static_library("libcef_static") {
"//components/keyed_service/content:content", "//components/keyed_service/content:content",
"//components/keyed_service/core:core", "//components/keyed_service/core:core",
"//components/navigation_interception", "//components/navigation_interception",
"//components/network_session_configurator/browser", "//components/network_session_configurator/common",
"//components/pdf/browser", "//components/pdf/browser",
"//components/pdf/renderer", "//components/pdf/renderer",
"//components/plugins/renderer", "//components/plugins/renderer",
@@ -772,10 +849,9 @@ static_library("libcef_static") {
"//components/printing/common", "//components/printing/common",
"//components/printing/renderer", "//components/printing/renderer",
"//components/proxy_config", "//components/proxy_config",
"//components/safe_browsing/db:test_database_manager", "//components/safe_browsing/core/db:test_database_manager",
"//components/services/pdf_compositor/public/cpp", "//components/services/print_compositor/public/cpp",
"//components/services/pdf_compositor/public/mojom", "//components/services/print_compositor/public/mojom",
"//components/tracing",
"//components/update_client", "//components/update_client",
"//components/url_formatter", "//components/url_formatter",
"//components/user_prefs", "//components/user_prefs",
@@ -785,7 +861,7 @@ static_library("libcef_static") {
"//components/visitedlink/renderer", "//components/visitedlink/renderer",
"//components/viz/service", "//components/viz/service",
"//components/web_cache/renderer", "//components/web_cache/renderer",
"//content/public/app:both", "//content/public/app",
"//content/public/browser", "//content/public/browser",
"//content/public/child", "//content/public/child",
"//content/public/common", "//content/public/common",
@@ -838,8 +914,8 @@ static_library("libcef_static") {
] ]
if (is_win) { if (is_win) {
sources += gypi_paths2.includes_win + [ sources += includes_win + [
"libcef/browser/browser_main_win.cc", "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.cc",
"libcef/browser/native/browser_platform_delegate_native_win.h", "libcef/browser/native/browser_platform_delegate_native_win.h",
"libcef/browser/native/file_dialog_runner_win.cc", "libcef/browser/native/file_dialog_runner_win.cc",
@@ -883,7 +959,7 @@ static_library("libcef_static") {
} }
if (is_linux) { if (is_linux) {
sources += gypi_paths2.includes_linux + [ sources += includes_linux + [
"libcef/browser/native/browser_platform_delegate_native_linux.cc", "libcef/browser/native/browser_platform_delegate_native_linux.cc",
"libcef/browser/native/browser_platform_delegate_native_linux.h", "libcef/browser/native/browser_platform_delegate_native_linux.h",
"libcef/browser/native/menu_runner_linux.cc", "libcef/browser/native/menu_runner_linux.cc",
@@ -915,7 +991,7 @@ static_library("libcef_static") {
} }
if (is_mac) { if (is_mac) {
sources += gypi_paths2.includes_mac + [ sources += includes_mac + [
"libcef/browser/native/browser_platform_delegate_native_mac.h", "libcef/browser/native/browser_platform_delegate_native_mac.h",
"libcef/browser/native/browser_platform_delegate_native_mac.mm", "libcef/browser/native/browser_platform_delegate_native_mac.mm",
"libcef/browser/native/file_dialog_runner_mac.h", "libcef/browser/native/file_dialog_runner_mac.h",
@@ -928,6 +1004,10 @@ static_library("libcef_static") {
"libcef/browser/osr/browser_platform_delegate_osr_mac.mm", "libcef/browser/osr/browser_platform_delegate_osr_mac.mm",
"libcef/common/util_mac.h", "libcef/common/util_mac.h",
"libcef/common/util_mac.mm", "libcef/common/util_mac.mm",
# For Chrome runtime support.
"//chrome/app/chrome_main_mac.h",
"//chrome/app/chrome_main_mac.mm",
] ]
} }
@@ -946,7 +1026,7 @@ static_library("libcef_static") {
] ]
deps += [ deps += [
"//components/crash/content/app", "//components/crash/core/app",
"//components/crash/content/browser", "//components/crash/content/browser",
] ]
} }
@@ -1078,15 +1158,14 @@ static_library("libcef_static") {
"//ui/aura/test/aura_test_utils.cc", "//ui/aura/test/aura_test_utils.cc",
"//ui/aura/test/aura_test_utils.h", "//ui/aura/test/aura_test_utils.h",
# Part of //ui/events:test_support which is testingonly. # Part of //ui/events:test_support which is testingonly.
"//ui/events/test/platform_event_waiter.cc", "//ui/events/test/x11_event_waiter.cc",
"//ui/events/test/platform_event_waiter.h", "//ui/events/test/x11_event_waiter.h",
] ]
if (use_x11) { if (use_x11) {
sources += [ sources += [
# Support for UI input events. # Support for UI input events.
# Part of //ui/aura:test_support which is testingonly. # Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/ui_controls_factory_aurax11.cc",
"//ui/aura/test/x11_event_sender.cc", "//ui/aura/test/x11_event_sender.cc",
"//ui/aura/test/x11_event_sender.h", "//ui/aura/test/x11_event_sender.h",
# Part of //ui/views:test_support which is testingonly. # Part of //ui/views:test_support which is testingonly.
@@ -1129,7 +1208,7 @@ config("libcef_dll_wrapper_config") {
# libcef_dll_wrapper target. # libcef_dll_wrapper target.
static_library("libcef_dll_wrapper") { static_library("libcef_dll_wrapper") {
sources = gypi_paths2.includes_common + sources = includes_common +
gypi_paths.autogen_cpp_includes + gypi_paths.autogen_cpp_includes +
gypi_paths2.includes_capi + gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes + gypi_paths.autogen_capi_includes +
@@ -1158,7 +1237,7 @@ if (is_win) {
sources = [ "libcef_dll/sandbox/sandbox_win.cc" ] sources = [ "libcef_dll/sandbox/sandbox_win.cc" ]
# CEF sources use include paths relative to the CEF root directory. # CEF sources use include paths relative to the CEF root directory.
include_dirs = [ "." ] include_dirs = [ "." ]
deps = [ "//sandbox" ] deps = [ "libcef/features", "//sandbox" ]
} }
} }
@@ -1171,56 +1250,6 @@ if (is_mac) {
} }
} }
#
# Service manifests.
#
source_set("cef_content_browser_overlay_manifest") {
sources = [
"libcef/common/service_manifests/cef_content_browser_overlay_manifest.cc",
"libcef/common/service_manifests/cef_content_browser_overlay_manifest.h",
]
configs += [
"libcef/features:config"
]
deps = [
"//base",
"//extensions/buildflags",
"//extensions/common:mojom",
"//extensions/common/api:mojom",
"//services/service_manager/public/cpp",
"//third_party/blink/public/common",
]
}
source_set("cef_content_renderer_overlay_manifest") {
sources = [
"libcef/common/service_manifests/cef_content_renderer_overlay_manifest.h",
]
configs += [
"libcef/features:config"
]
deps = [
"//base",
"//components/subresource_filter/content/mojom",
"//extensions/buildflags",
"//extensions/common:mojom",
"//services/service_manager/public/cpp",
"//third_party/blink/public/common",
]
}
source_set("cef_service_manifests") {
public_deps = [
":cef_content_browser_overlay_manifest",
":cef_content_renderer_overlay_manifest",
]
}
# #
# Resource grit/pack targets. # Resource grit/pack targets.
# #
@@ -1289,13 +1318,15 @@ repack("pak_devtools") {
# Add associated .h files in the make_pack_header("resources") target. # Add associated .h files in the make_pack_header("resources") target.
sources = [ sources = [
"$root_gen_dir/content/browser/devtools/devtools_resources.pak", "$root_gen_dir/content/browser/devtools/devtools_resources.pak",
"$root_gen_dir/third_party/blink/public/resources/inspector_overlay_resources.pak",
] ]
# Use public_deps so that generated grit headers are discoverable from # Use public_deps so that generated grit headers are discoverable from
# the libcef_static target. Grit deps that generate .cc files must be # the libcef_static target. Grit deps that generate .cc files must be
# listed both here and in the libcef_static target. # listed both here and in the libcef_static target.
public_deps = [ public_deps = [
"//content/browser/devtools:resources", "//content/browser/devtools:devtools_resources",
"//third_party/blink/public:devtools_inspector_resources",
] ]
output = "$root_out_dir/devtools_resources.pak" output = "$root_out_dir/devtools_resources.pak"
@@ -1377,13 +1408,17 @@ repack("pak") {
# Add associated .h files in the make_pack_header("resources") target. # Add associated .h files in the make_pack_header("resources") target.
sources = [ sources = [
"$root_gen_dir/chrome/browser_resources.pak", "$root_gen_dir/chrome/browser_resources.pak",
"$root_gen_dir/chrome/dev_ui_browser_resources.pak",
"$root_gen_dir/chrome/net_internals_resources.pak", "$root_gen_dir/chrome/net_internals_resources.pak",
"$root_gen_dir/chrome/print_preview_pdf_resources.pak",
"$root_gen_dir/chrome/print_preview_resources.pak", "$root_gen_dir/chrome/print_preview_resources.pak",
"$root_gen_dir/chrome/common_resources.pak", "$root_gen_dir/chrome/common_resources.pak",
"$root_gen_dir/components/components_resources.pak", "$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/components/dev_ui_components_resources.pak",
"$root_gen_dir/cef/cef_resources.pak", "$root_gen_dir/cef/cef_resources.pak",
"$root_gen_dir/content/browser/tracing/tracing_resources.pak", "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
"$root_gen_dir/content/content_resources.pak", "$root_gen_dir/content/content_resources.pak",
"$root_gen_dir/content/dev_ui_content_resources.pak",
"$root_gen_dir/net/net_resources.pak", "$root_gen_dir/net/net_resources.pak",
"$root_gen_dir/third_party/blink/public/resources/blink_resources.pak", "$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
] ]
@@ -1392,14 +1427,18 @@ repack("pak") {
# the libcef_static target. Grit deps that generate .cc files must be # the libcef_static target. Grit deps that generate .cc files must be
# listed both here and in the libcef_static target. # listed both here and in the libcef_static target.
public_deps = [ public_deps = [
"//chrome/browser:dev_ui_browser_resources",
"//chrome/browser:resources", "//chrome/browser:resources",
"//chrome/browser/resources/net_internals:net_internals_resources", "//chrome/browser/resources/net_internals:net_internals_resources",
"//chrome/browser/resources:print_preview_pdf_resources",
"//chrome/browser/resources:print_preview_resources", "//chrome/browser/resources:print_preview_resources",
"//chrome/common:resources", "//chrome/common:resources",
"//components/resources:components_resources", "//components/resources:components_resources",
"//components/resources:dev_ui_components_resources",
":cef_resources", ":cef_resources",
"//content/browser/tracing:resources", "//content/browser/tracing:resources",
"//content:resources", "//content:content_resources",
"//content:dev_ui_content_resources",
"//net:net_resources", "//net:net_resources",
"//third_party/blink/public:resources", "//third_party/blink/public:resources",
] ]
@@ -1442,12 +1481,17 @@ make_pack_header("resources") {
"$root_gen_dir/chrome/grit/browser_resources.h", "$root_gen_dir/chrome/grit/browser_resources.h",
"$root_gen_dir/chrome/grit/common_resources.h", "$root_gen_dir/chrome/grit/common_resources.h",
"$root_gen_dir/chrome/grit/component_extension_resources.h", "$root_gen_dir/chrome/grit/component_extension_resources.h",
"$root_gen_dir/chrome/grit/dev_ui_browser_resources.h",
"$root_gen_dir/chrome/grit/net_internals_resources.h", "$root_gen_dir/chrome/grit/net_internals_resources.h",
"$root_gen_dir/chrome/grit/print_preview_pdf_resources.h",
"$root_gen_dir/chrome/grit/print_preview_resources.h",
"$root_gen_dir/chrome/grit/renderer_resources.h", "$root_gen_dir/chrome/grit/renderer_resources.h",
"$root_gen_dir/components/grit/components_resources.h", "$root_gen_dir/components/grit/components_resources.h",
"$root_gen_dir/components/grit/dev_ui_components_resources.h",
"$root_gen_dir/content/browser/devtools/grit/devtools_resources.h", "$root_gen_dir/content/browser/devtools/grit/devtools_resources.h",
"$root_gen_dir/content/browser/tracing/grit/tracing_resources.h", "$root_gen_dir/content/browser/tracing/grit/tracing_resources.h",
"$root_gen_dir/content/grit/content_resources.h", "$root_gen_dir/content/grit/content_resources.h",
"$root_gen_dir/content/grit/dev_ui_content_resources.h",
"$root_gen_dir/extensions/grit/extensions_browser_resources.h", "$root_gen_dir/extensions/grit/extensions_browser_resources.h",
"$root_gen_dir/extensions/grit/extensions_renderer_resources.h", "$root_gen_dir/extensions/grit/extensions_renderer_resources.h",
"$root_gen_dir/extensions/grit/extensions_resources.h", "$root_gen_dir/extensions/grit/extensions_resources.h",
@@ -1468,6 +1512,7 @@ make_pack_header("strings") {
"$root_gen_dir/chrome/grit/generated_resources.h", "$root_gen_dir/chrome/grit/generated_resources.h",
"$root_gen_dir/chrome/grit/locale_settings.h", "$root_gen_dir/chrome/grit/locale_settings.h",
"$root_gen_dir/chrome/grit/platform_locale_settings.h", "$root_gen_dir/chrome/grit/platform_locale_settings.h",
"$root_gen_dir/components/strings/grit/components_chromium_strings.h",
"$root_gen_dir/components/strings/grit/components_strings.h", "$root_gen_dir/components/strings/grit/components_strings.h",
"$root_gen_dir/extensions/strings/grit/extensions_strings.h", "$root_gen_dir/extensions/strings/grit/extensions_strings.h",
"$root_gen_dir/services/strings/grit/services_strings.h", "$root_gen_dir/services/strings/grit/services_strings.h",
@@ -1476,11 +1521,29 @@ make_pack_header("strings") {
] ]
} }
# Generate cef_api_hash.h.
action("make_api_hash_header") {
script = "tools/make_api_hash_header.py"
# List of all C API files that will be checked for changes by cef_api_hash.py.
inputs = gypi_paths2.includes_common_capi +
gypi_paths2.includes_linux_capi +
gypi_paths2.includes_mac_capi +
gypi_paths2.includes_win_capi +
gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes
include_dir = [ "include" ]
outputs = [ "$root_out_dir/includes/include/cef_api_hash.h" ]
args = rebase_path(outputs + include_dir, root_build_dir)
}
# Generate pack files and associated CEF header files. # Generate pack files and associated CEF header files.
group("cef_make_headers") { group("cef_make_headers") {
deps = [ deps = [
":make_pack_header_resources", ":make_pack_header_resources",
":make_pack_header_strings", ":make_pack_header_strings",
":make_api_hash_header",
] ]
} }
@@ -1578,12 +1641,15 @@ if (is_mac) {
sources = [ sources = [
"$root_out_dir/egl_intermediates/libswiftshader_libEGL.dylib", "$root_out_dir/egl_intermediates/libswiftshader_libEGL.dylib",
"$root_out_dir/egl_intermediates/libswiftshader_libGLESv2.dylib", "$root_out_dir/egl_intermediates/libswiftshader_libGLESv2.dylib",
"$root_out_dir/vk_intermediates/libvk_swiftshader.dylib",
"$root_out_dir/vk_intermediates/vk_swiftshader_icd.json",
] ]
outputs = [ outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}", "{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
] ]
public_deps = [ public_deps = [
"//ui/gl:swiftshader_library_copy", "//ui/gl:swiftshader_egl_library_copy",
"//ui/gl:swiftshader_vk_library_copy",
] ]
} }
} }
@@ -1613,18 +1679,14 @@ if (is_mac) {
"Resources", "Resources",
] ]
sources = gypi_paths2.includes_common + sources = includes_common +
gypi_paths2.includes_mac + includes_mac +
gypi_paths.autogen_cpp_includes + gypi_paths.autogen_cpp_includes +
gypi_paths2.includes_capi + gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes + gypi_paths.autogen_capi_includes +
gypi_paths2.libcef_sources_common + gypi_paths2.libcef_sources_common +
gypi_paths.autogen_library_side gypi_paths.autogen_library_side
# TODO(rsesek): Handle these missing pieces:
# - crash_inspector
# - crash_report_sender.app
deps = [ deps = [
":cef_framework_angle_library", ":cef_framework_angle_library",
":cef_framework_locales", ":cef_framework_locales",
@@ -1657,7 +1719,7 @@ if (is_mac) {
} }
} else { } else {
shared_library("libcef") { shared_library("libcef") {
sources = gypi_paths2.includes_common + sources = includes_common +
gypi_paths.autogen_cpp_includes + gypi_paths.autogen_cpp_includes +
gypi_paths2.includes_capi + gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes + gypi_paths.autogen_capi_includes +
@@ -1669,15 +1731,10 @@ if (is_mac) {
] ]
if (is_win) { if (is_win) {
sources += gypi_paths2.includes_win + [ sources += includes_win + [
"libcef_dll/libcef_dll.rc", "libcef_dll/libcef_dll.rc",
] ]
# This is a large module that can't do incremental linking in some cases.
configs -= [ "//build/config/win:default_incremental_linking" ]
configs +=
[ "//build/config/win:default_large_module_incremental_linking" ]
deps += [ deps += [
# Bring in ui_unscaled_resources.rc which contains custom cursors. # Bring in ui_unscaled_resources.rc which contains custom cursors.
# TODO(cef): Remove this once custom cursors can be loaded via # TODO(cef): Remove this once custom cursors can be loaded via
@@ -1830,8 +1887,8 @@ if (is_mac) {
deps += invoker.deps deps += invoker.deps
} }
if (defined(invoker.libs)) { if (defined(invoker.frameworks)) {
libs = invoker.libs frameworks = invoker.frameworks
} }
if (defined(invoker.defines)) { if (defined(invoker.defines)) {
@@ -1885,8 +1942,8 @@ if (is_mac) {
cef_app("cefclient") { cef_app("cefclient") {
helper_info_plist = "tests/cefclient/resources/mac/helper-Info.plist" helper_info_plist = "tests/cefclient/resources/mac/helper-Info.plist"
helper_sources = gypi_paths2.includes_mac + helper_sources = includes_common +
gypi_paths2.includes_common + includes_mac +
gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_mac + gypi_paths2.includes_wrapper_mac +
gypi_paths2.shared_sources_common + gypi_paths2.shared_sources_common +
@@ -1899,8 +1956,8 @@ if (is_mac) {
] ]
info_plist = "tests/cefclient/resources/mac/Info.plist" info_plist = "tests/cefclient/resources/mac/Info.plist"
sources = gypi_paths2.includes_mac + sources = includes_common +
gypi_paths2.includes_common + includes_mac +
gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_mac + gypi_paths2.includes_wrapper_mac +
gypi_paths2.shared_sources_browser + gypi_paths2.shared_sources_browser +
@@ -1915,7 +1972,7 @@ if (is_mac) {
":cefclient_resources_bundle_data_english", ":cefclient_resources_bundle_data_english",
":cefclient_xibs", ":cefclient_xibs",
] ]
libs = [ frameworks = [
"AppKit.framework", "AppKit.framework",
"OpenGL.framework", "OpenGL.framework",
] ]
@@ -1958,8 +2015,8 @@ if (is_mac) {
cef_app("cefsimple") { cef_app("cefsimple") {
helper_info_plist = "tests/cefsimple/mac/helper-Info.plist" helper_info_plist = "tests/cefsimple/mac/helper-Info.plist"
helper_sources = gypi_paths2.includes_mac + helper_sources = includes_common +
gypi_paths2.includes_common + includes_mac +
gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_mac + gypi_paths2.includes_wrapper_mac +
gypi_paths2.cefsimple_sources_mac_helper gypi_paths2.cefsimple_sources_mac_helper
@@ -1968,8 +2025,8 @@ if (is_mac) {
] ]
info_plist = "tests/cefsimple/mac/Info.plist" info_plist = "tests/cefsimple/mac/Info.plist"
sources = gypi_paths2.includes_mac + sources = includes_common +
gypi_paths2.includes_common + includes_mac +
gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_mac + gypi_paths2.includes_wrapper_mac +
gypi_paths2.cefsimple_sources_common + gypi_paths2.cefsimple_sources_common +
@@ -1979,7 +2036,7 @@ if (is_mac) {
":cefsimple_resources_bundle_data_english", ":cefsimple_resources_bundle_data_english",
":cefsimple_xibs", ":cefsimple_xibs",
] ]
libs = [ frameworks = [
"AppKit.framework", "AppKit.framework",
] ]
defines = [ defines = [
@@ -2035,8 +2092,8 @@ if (is_mac) {
] ]
info_plist = "tests/ceftests/resources/mac/Info.plist" info_plist = "tests/ceftests/resources/mac/Info.plist"
sources = gypi_paths2.includes_mac + sources = includes_common +
gypi_paths2.includes_common + includes_mac +
gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper +
gypi_paths2.includes_wrapper_mac + gypi_paths2.includes_wrapper_mac +
gypi_paths2.shared_sources_browser + gypi_paths2.shared_sources_browser +
@@ -2050,7 +2107,7 @@ if (is_mac) {
":ceftests_xibs", ":ceftests_xibs",
"//testing/gtest", "//testing/gtest",
] ]
libs = [ frameworks = [
"AppKit.framework", "AppKit.framework",
] ]
defines = [ defines = [
@@ -2104,7 +2161,7 @@ if (is_mac) {
} }
executable("cefclient") { executable("cefclient") {
sources = gypi_paths2.includes_common + sources = includes_common +
gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper +
gypi_paths2.shared_sources_browser + gypi_paths2.shared_sources_browser +
gypi_paths2.shared_sources_common + gypi_paths2.shared_sources_common +
@@ -2123,7 +2180,7 @@ if (is_mac) {
] ]
if (is_win) { if (is_win) {
sources += gypi_paths2.includes_win + sources += includes_win +
gypi_paths2.shared_sources_win + gypi_paths2.shared_sources_win +
gypi_paths2.cefclient_sources_win gypi_paths2.cefclient_sources_win
@@ -2143,17 +2200,22 @@ if (is_mac) {
libs = [ libs = [
"comctl32.lib", "comctl32.lib",
"d3d11.lib", "d3d11.lib",
"glu32.lib",
"imm32.lib", "imm32.lib",
"oleacc.lib", "oleacc.lib",
"opengl32.lib",
"rpcrt4.lib", "rpcrt4.lib",
"shlwapi.lib", "shlwapi.lib",
] ]
if (target_cpu != "arm64") {
libs += [
"opengl32.lib",
"glu32.lib"
]
}
} }
if (is_linux) { if (is_linux) {
sources += gypi_paths2.includes_linux + sources += includes_linux +
gypi_paths2.shared_sources_linux + gypi_paths2.shared_sources_linux +
gypi_paths2.cefclient_sources_linux gypi_paths2.cefclient_sources_linux
@@ -2192,7 +2254,7 @@ if (is_mac) {
# #
executable("cefsimple") { executable("cefsimple") {
sources = gypi_paths2.includes_common + sources = includes_common +
gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper +
gypi_paths2.cefsimple_sources_common gypi_paths2.cefsimple_sources_common
@@ -2206,7 +2268,7 @@ if (is_mac) {
] ]
if (is_win) { if (is_win) {
sources += gypi_paths2.includes_win + sources += includes_win +
gypi_paths2.cefsimple_sources_win gypi_paths2.cefsimple_sources_win
# Set /SUBSYSTEM:WINDOWS. # Set /SUBSYSTEM:WINDOWS.
@@ -2226,7 +2288,7 @@ if (is_mac) {
} }
if (is_linux) { if (is_linux) {
sources += gypi_paths2.includes_linux + sources += includes_linux +
gypi_paths2.cefsimple_sources_linux gypi_paths2.cefsimple_sources_linux
if (use_x11) { if (use_x11) {
@@ -2257,7 +2319,7 @@ if (is_mac) {
executable("ceftests") { executable("ceftests") {
testonly = true testonly = true
sources = gypi_paths2.includes_common + sources = includes_common +
gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper +
gypi_paths2.shared_sources_browser + gypi_paths2.shared_sources_browser +
gypi_paths2.shared_sources_common + gypi_paths2.shared_sources_common +

View File

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

View File

@@ -27,8 +27,6 @@
# Files in the chromium/src directory that should be evaluated for changes. # Files in the chromium/src directory that should be evaluated for changes.
# Similar changes may need to be applied to the CEF source code. # Similar changes may need to be applied to the CEF source code.
'files': [ 'files': [
'chrome/app/chrome_*_manifest.*',
'chrome/app/chrome_*_manifests.*',
'chrome/browser/browser_process.h', 'chrome/browser/browser_process.h',
'chrome/browser/extensions/api/tabs/tabs_api.*', 'chrome/browser/extensions/api/tabs/tabs_api.*',
'chrome/browser/extensions/chrome_component_extension_resource_manager.*', 'chrome/browser/extensions/chrome_component_extension_resource_manager.*',
@@ -57,7 +55,9 @@
'content/shell/renderer/shell_*', 'content/shell/renderer/shell_*',
'content/shell/utility/shell_*', 'content/shell/utility/shell_*',
'extensions/shell/*', 'extensions/shell/*',
'net/base/features.cc',
'net/cookies/cookie_store.h', 'net/cookies/cookie_store.h',
'services/network/public/cpp/features.cc',
'ui/base/ui_base_features.cc', 'ui/base/ui_base_features.cc',
], ],
# Patterns that should not be found in the chromium/src directory after # Patterns that should not be found in the chromium/src directory after

View File

@@ -12,8 +12,8 @@
# distribution include: # distribution include:
# #
# Linux: Ninja, Unix Makefiles # Linux: Ninja, Unix Makefiles
# Mac OS X: Ninja, Xcode 5+ # MacOS: Ninja, Xcode 8+
# Windows: Ninja, Visual Studio 2010+ # Windows: Ninja, Visual Studio 2015+
# #
# Ninja is a cross-platform open-source tool for running fast builds using # Ninja is a cross-platform open-source tool for running fast builds using
# pre-installed platform toolchains (GNU, clang, Xcode or MSVC). It can be # pre-installed platform toolchains (GNU, clang, Xcode or MSVC). It can be
@@ -40,21 +40,21 @@
# #
# - Linux requirements: # - Linux requirements:
# Currently supported distributions include Debian Wheezy, Ubuntu Precise, and # Currently supported distributions include Debian Wheezy, Ubuntu Precise, and
# related. Ubuntu 14.04 64-bit is recommended. Newer versions will likely also # related. Ubuntu 18.04 64-bit is recommended. Newer versions will likely also
# work but may not have been tested. # work but may not have been tested.
# Required packages include: # Required packages include:
# build-essential # build-essential
# libgtk2.0-dev (required by the cefclient target only) # libgtk2.0-dev (required by the cefclient target only)
# libgtkglext1-dev (required by the cefclient target only) # libgtkglext1-dev (required by the cefclient target only)
# #
# - Mac OS X requirements: # - MacOS requirements:
# Xcode 5 or newer building on Mac OS X 10.9 (Mavericks) or newer. Xcode 8.3 # Xcode 8 or newer building on MacOS 10.10 (Yosemite) or newer. Xcode 11.2
# and OS X 10.12 are recommended. The Xcode command-line tools must also be # and MacOS 10.14 are recommended. The Xcode command-line tools must also be
# installed. Only 64-bit builds are supported on OS X. # installed. Only 64-bit builds are supported.
# #
# - Windows requirements: # - Windows requirements:
# Visual Studio 2010 or newer building on Windows 7 or newer. Visual Studio # Visual Studio 2015 or newer building on Windows 7 or newer. Visual Studio
# 2015 Update 3 and Windows 10 64-bit are recommended. # 2019 and Windows 10 64-bit are recommended.
# #
# BUILD EXAMPLES # BUILD EXAMPLES
# #
@@ -75,7 +75,7 @@
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug .. # > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja cefclient cefsimple # > ninja cefclient cefsimple
# #
# To perform a Mac OS X build using a 64-bit CEF binary distribution: # To perform a MacOS build using a 64-bit CEF binary distribution:
# Using the Xcode IDE: # Using the Xcode IDE:
# > cmake -G "Xcode" -DPROJECT_ARCH="x86_64" .. # > cmake -G "Xcode" -DPROJECT_ARCH="x86_64" ..
# Open build\cef.xcodeproj in Xcode and select Product > Build. # Open build\cef.xcodeproj in Xcode and select Product > Build.
@@ -85,24 +85,24 @@
# > ninja cefclient cefsimple # > ninja cefclient cefsimple
# #
# To perform a Windows build using a 32-bit CEF binary distribution: # To perform a Windows build using a 32-bit CEF binary distribution:
# Using the Visual Studio 2015 IDE: # Using the Visual Studio 2019 IDE:
# > cmake -G "Visual Studio 14" .. # > cmake -G "Visual Studio 16" -A Win32 ..
# Open build\cef.sln in Visual Studio and select Build > Build Solution. # Open build\cef.sln in Visual Studio and select Build > Build Solution.
# #
# Using Ninja with Visual Studio 2015 command-line tools: # Using Ninja with Visual Studio 2019 command-line tools:
# (this path may be different depending on your Visual Studio installation) # (this path may be different depending on your Visual Studio installation)
# > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat" # > "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat"
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug .. # > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja cefclient cefsimple # > ninja cefclient cefsimple
# #
# To perform a Windows build using a 64-bit CEF binary distribution: # To perform a Windows build using a 64-bit CEF binary distribution:
# Using the Visual Studio 2015 IDE: # Using the Visual Studio 2019 IDE:
# > cmake -G "Visual Studio 14 Win64" .. # > cmake -G "Visual Studio 16" -A x64 ..
# Open build\cef.sln in Visual Studio and select Build > Build Solution. # Open build\cef.sln in Visual Studio and select Build > Build Solution.
# #
# Using Ninja with Visual Studio 2015 command-line tools: # Using Ninja with Visual Studio 2019 command-line tools:
# (this path may be different depending on your Visual Studio installation) # (this path may be different depending on your Visual Studio installation)
# > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat" # > "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug .. # > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja cefclient cefsimple # > ninja cefclient cefsimple

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for # by hand. See the translator.README.txt file in the tools directory for
# more information. # more information.
# #
# $hash=98198bc4243deb46c848735f0d5499aa4891e535$ # $hash=72268a78a76d7d91b8ad47f6b6e9f6d9cb04d9cf$
# #
{ {
@@ -16,6 +16,7 @@
'autogen_cpp_includes': [ 'autogen_cpp_includes': [
'include/cef_accessibility_handler.h', 'include/cef_accessibility_handler.h',
'include/cef_app.h', 'include/cef_app.h',
'include/cef_audio_handler.h',
'include/cef_auth_callback.h', 'include/cef_auth_callback.h',
'include/cef_browser.h', 'include/cef_browser.h',
'include/cef_browser_process_handler.h', 'include/cef_browser_process_handler.h',
@@ -25,6 +26,7 @@
'include/cef_context_menu_handler.h', 'include/cef_context_menu_handler.h',
'include/cef_cookie.h', 'include/cef_cookie.h',
'include/cef_crash_util.h', 'include/cef_crash_util.h',
'include/cef_devtools_message_observer.h',
'include/cef_dialog_handler.h', 'include/cef_dialog_handler.h',
'include/cef_display_handler.h', 'include/cef_display_handler.h',
'include/cef_dom.h', 'include/cef_dom.h',
@@ -43,6 +45,7 @@
'include/cef_keyboard_handler.h', 'include/cef_keyboard_handler.h',
'include/cef_life_span_handler.h', 'include/cef_life_span_handler.h',
'include/cef_load_handler.h', 'include/cef_load_handler.h',
'include/cef_media_router.h',
'include/cef_menu_model.h', 'include/cef_menu_model.h',
'include/cef_menu_model_delegate.h', 'include/cef_menu_model_delegate.h',
'include/cef_navigation_entry.h', 'include/cef_navigation_entry.h',
@@ -53,6 +56,7 @@
'include/cef_print_settings.h', 'include/cef_print_settings.h',
'include/cef_process_message.h', 'include/cef_process_message.h',
'include/cef_process_util.h', 'include/cef_process_util.h',
'include/cef_registration.h',
'include/cef_render_handler.h', 'include/cef_render_handler.h',
'include/cef_render_process_handler.h', 'include/cef_render_process_handler.h',
'include/cef_request.h', 'include/cef_request.h',
@@ -109,6 +113,7 @@
'autogen_capi_includes': [ 'autogen_capi_includes': [
'include/capi/cef_accessibility_handler_capi.h', 'include/capi/cef_accessibility_handler_capi.h',
'include/capi/cef_app_capi.h', 'include/capi/cef_app_capi.h',
'include/capi/cef_audio_handler_capi.h',
'include/capi/cef_auth_callback_capi.h', 'include/capi/cef_auth_callback_capi.h',
'include/capi/cef_browser_capi.h', 'include/capi/cef_browser_capi.h',
'include/capi/cef_browser_process_handler_capi.h', 'include/capi/cef_browser_process_handler_capi.h',
@@ -118,6 +123,7 @@
'include/capi/cef_context_menu_handler_capi.h', 'include/capi/cef_context_menu_handler_capi.h',
'include/capi/cef_cookie_capi.h', 'include/capi/cef_cookie_capi.h',
'include/capi/cef_crash_util_capi.h', 'include/capi/cef_crash_util_capi.h',
'include/capi/cef_devtools_message_observer_capi.h',
'include/capi/cef_dialog_handler_capi.h', 'include/capi/cef_dialog_handler_capi.h',
'include/capi/cef_display_handler_capi.h', 'include/capi/cef_display_handler_capi.h',
'include/capi/cef_dom_capi.h', 'include/capi/cef_dom_capi.h',
@@ -136,6 +142,7 @@
'include/capi/cef_keyboard_handler_capi.h', 'include/capi/cef_keyboard_handler_capi.h',
'include/capi/cef_life_span_handler_capi.h', 'include/capi/cef_life_span_handler_capi.h',
'include/capi/cef_load_handler_capi.h', 'include/capi/cef_load_handler_capi.h',
'include/capi/cef_media_router_capi.h',
'include/capi/cef_menu_model_capi.h', 'include/capi/cef_menu_model_capi.h',
'include/capi/cef_menu_model_delegate_capi.h', 'include/capi/cef_menu_model_delegate_capi.h',
'include/capi/cef_navigation_entry_capi.h', 'include/capi/cef_navigation_entry_capi.h',
@@ -146,6 +153,7 @@
'include/capi/cef_print_settings_capi.h', 'include/capi/cef_print_settings_capi.h',
'include/capi/cef_process_message_capi.h', 'include/capi/cef_process_message_capi.h',
'include/capi/cef_process_util_capi.h', 'include/capi/cef_process_util_capi.h',
'include/capi/cef_registration_capi.h',
'include/capi/cef_render_handler_capi.h', 'include/capi/cef_render_handler_capi.h',
'include/capi/cef_render_process_handler_capi.h', 'include/capi/cef_render_process_handler_capi.h',
'include/capi/cef_request_capi.h', 'include/capi/cef_request_capi.h',
@@ -204,6 +212,8 @@
'libcef_dll/ctocpp/accessibility_handler_ctocpp.h', 'libcef_dll/ctocpp/accessibility_handler_ctocpp.h',
'libcef_dll/ctocpp/app_ctocpp.cc', 'libcef_dll/ctocpp/app_ctocpp.cc',
'libcef_dll/ctocpp/app_ctocpp.h', 'libcef_dll/ctocpp/app_ctocpp.h',
'libcef_dll/ctocpp/audio_handler_ctocpp.cc',
'libcef_dll/ctocpp/audio_handler_ctocpp.h',
'libcef_dll/cpptoc/auth_callback_cpptoc.cc', 'libcef_dll/cpptoc/auth_callback_cpptoc.cc',
'libcef_dll/cpptoc/auth_callback_cpptoc.h', 'libcef_dll/cpptoc/auth_callback_cpptoc.h',
'libcef_dll/cpptoc/before_download_callback_cpptoc.cc', 'libcef_dll/cpptoc/before_download_callback_cpptoc.cc',
@@ -252,6 +262,8 @@
'libcef_dll/ctocpp/domvisitor_ctocpp.h', 'libcef_dll/ctocpp/domvisitor_ctocpp.h',
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.cc', 'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.cc',
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.h', 'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.h',
'libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.cc',
'libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.h',
'libcef_dll/ctocpp/dialog_handler_ctocpp.cc', 'libcef_dll/ctocpp/dialog_handler_ctocpp.cc',
'libcef_dll/ctocpp/dialog_handler_ctocpp.h', 'libcef_dll/ctocpp/dialog_handler_ctocpp.h',
'libcef_dll/cpptoc/dictionary_value_cpptoc.cc', 'libcef_dll/cpptoc/dictionary_value_cpptoc.cc',
@@ -308,6 +320,20 @@
'libcef_dll/cpptoc/list_value_cpptoc.h', 'libcef_dll/cpptoc/list_value_cpptoc.h',
'libcef_dll/ctocpp/load_handler_ctocpp.cc', 'libcef_dll/ctocpp/load_handler_ctocpp.cc',
'libcef_dll/ctocpp/load_handler_ctocpp.h', 'libcef_dll/ctocpp/load_handler_ctocpp.h',
'libcef_dll/ctocpp/media_observer_ctocpp.cc',
'libcef_dll/ctocpp/media_observer_ctocpp.h',
'libcef_dll/cpptoc/media_route_cpptoc.cc',
'libcef_dll/cpptoc/media_route_cpptoc.h',
'libcef_dll/ctocpp/media_route_create_callback_ctocpp.cc',
'libcef_dll/ctocpp/media_route_create_callback_ctocpp.h',
'libcef_dll/cpptoc/media_router_cpptoc.cc',
'libcef_dll/cpptoc/media_router_cpptoc.h',
'libcef_dll/cpptoc/media_sink_cpptoc.cc',
'libcef_dll/cpptoc/media_sink_cpptoc.h',
'libcef_dll/ctocpp/media_sink_device_info_callback_ctocpp.cc',
'libcef_dll/ctocpp/media_sink_device_info_callback_ctocpp.h',
'libcef_dll/cpptoc/media_source_cpptoc.cc',
'libcef_dll/cpptoc/media_source_cpptoc.h',
'libcef_dll/cpptoc/views/menu_button_cpptoc.cc', 'libcef_dll/cpptoc/views/menu_button_cpptoc.cc',
'libcef_dll/cpptoc/views/menu_button_cpptoc.h', 'libcef_dll/cpptoc/views/menu_button_cpptoc.h',
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc', 'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc',
@@ -346,6 +372,8 @@
'libcef_dll/ctocpp/read_handler_ctocpp.h', 'libcef_dll/ctocpp/read_handler_ctocpp.h',
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.cc', 'libcef_dll/ctocpp/register_cdm_callback_ctocpp.cc',
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.h', 'libcef_dll/ctocpp/register_cdm_callback_ctocpp.h',
'libcef_dll/cpptoc/registration_cpptoc.cc',
'libcef_dll/cpptoc/registration_cpptoc.h',
'libcef_dll/ctocpp/render_handler_ctocpp.cc', 'libcef_dll/ctocpp/render_handler_ctocpp.cc',
'libcef_dll/ctocpp/render_handler_ctocpp.h', 'libcef_dll/ctocpp/render_handler_ctocpp.h',
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc', 'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
@@ -494,6 +522,8 @@
'libcef_dll/cpptoc/accessibility_handler_cpptoc.h', 'libcef_dll/cpptoc/accessibility_handler_cpptoc.h',
'libcef_dll/cpptoc/app_cpptoc.cc', 'libcef_dll/cpptoc/app_cpptoc.cc',
'libcef_dll/cpptoc/app_cpptoc.h', 'libcef_dll/cpptoc/app_cpptoc.h',
'libcef_dll/cpptoc/audio_handler_cpptoc.cc',
'libcef_dll/cpptoc/audio_handler_cpptoc.h',
'libcef_dll/ctocpp/auth_callback_ctocpp.cc', 'libcef_dll/ctocpp/auth_callback_ctocpp.cc',
'libcef_dll/ctocpp/auth_callback_ctocpp.h', 'libcef_dll/ctocpp/auth_callback_ctocpp.h',
'libcef_dll/ctocpp/before_download_callback_ctocpp.cc', 'libcef_dll/ctocpp/before_download_callback_ctocpp.cc',
@@ -542,6 +572,8 @@
'libcef_dll/cpptoc/domvisitor_cpptoc.h', 'libcef_dll/cpptoc/domvisitor_cpptoc.h',
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.cc', 'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.cc',
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.h', 'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.h',
'libcef_dll/cpptoc/dev_tools_message_observer_cpptoc.cc',
'libcef_dll/cpptoc/dev_tools_message_observer_cpptoc.h',
'libcef_dll/cpptoc/dialog_handler_cpptoc.cc', 'libcef_dll/cpptoc/dialog_handler_cpptoc.cc',
'libcef_dll/cpptoc/dialog_handler_cpptoc.h', 'libcef_dll/cpptoc/dialog_handler_cpptoc.h',
'libcef_dll/ctocpp/dictionary_value_ctocpp.cc', 'libcef_dll/ctocpp/dictionary_value_ctocpp.cc',
@@ -598,6 +630,20 @@
'libcef_dll/ctocpp/list_value_ctocpp.h', 'libcef_dll/ctocpp/list_value_ctocpp.h',
'libcef_dll/cpptoc/load_handler_cpptoc.cc', 'libcef_dll/cpptoc/load_handler_cpptoc.cc',
'libcef_dll/cpptoc/load_handler_cpptoc.h', 'libcef_dll/cpptoc/load_handler_cpptoc.h',
'libcef_dll/cpptoc/media_observer_cpptoc.cc',
'libcef_dll/cpptoc/media_observer_cpptoc.h',
'libcef_dll/ctocpp/media_route_ctocpp.cc',
'libcef_dll/ctocpp/media_route_ctocpp.h',
'libcef_dll/cpptoc/media_route_create_callback_cpptoc.cc',
'libcef_dll/cpptoc/media_route_create_callback_cpptoc.h',
'libcef_dll/ctocpp/media_router_ctocpp.cc',
'libcef_dll/ctocpp/media_router_ctocpp.h',
'libcef_dll/ctocpp/media_sink_ctocpp.cc',
'libcef_dll/ctocpp/media_sink_ctocpp.h',
'libcef_dll/cpptoc/media_sink_device_info_callback_cpptoc.cc',
'libcef_dll/cpptoc/media_sink_device_info_callback_cpptoc.h',
'libcef_dll/ctocpp/media_source_ctocpp.cc',
'libcef_dll/ctocpp/media_source_ctocpp.h',
'libcef_dll/ctocpp/views/menu_button_ctocpp.cc', 'libcef_dll/ctocpp/views/menu_button_ctocpp.cc',
'libcef_dll/ctocpp/views/menu_button_ctocpp.h', 'libcef_dll/ctocpp/views/menu_button_ctocpp.h',
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc', 'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc',
@@ -636,6 +682,8 @@
'libcef_dll/cpptoc/read_handler_cpptoc.h', 'libcef_dll/cpptoc/read_handler_cpptoc.h',
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.cc', 'libcef_dll/cpptoc/register_cdm_callback_cpptoc.cc',
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.h', 'libcef_dll/cpptoc/register_cdm_callback_cpptoc.h',
'libcef_dll/ctocpp/registration_ctocpp.cc',
'libcef_dll/ctocpp/registration_ctocpp.h',
'libcef_dll/cpptoc/render_handler_cpptoc.cc', 'libcef_dll/cpptoc/render_handler_cpptoc.cc',
'libcef_dll/cpptoc/render_handler_cpptoc.h', 'libcef_dll/cpptoc/render_handler_cpptoc.h',
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc', 'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',

View File

@@ -39,19 +39,21 @@
'include/cef_config.h', 'include/cef_config.h',
'include/cef_version.h', 'include/cef_version.h',
'include/internal/cef_export.h', 'include/internal/cef_export.h',
'include/internal/cef_logging_internal.h',
'include/internal/cef_ptr.h', 'include/internal/cef_ptr.h',
'include/internal/cef_string_wrappers.h',
'include/internal/cef_types_wrappers.h',
],
'includes_common_capi': [
'include/internal/cef_logging_internal.h',
'include/internal/cef_string.h', 'include/internal/cef_string.h',
'include/internal/cef_string_list.h', 'include/internal/cef_string_list.h',
'include/internal/cef_string_map.h', 'include/internal/cef_string_map.h',
'include/internal/cef_string_multimap.h', 'include/internal/cef_string_multimap.h',
'include/internal/cef_string_types.h', 'include/internal/cef_string_types.h',
'include/internal/cef_string_wrappers.h',
'include/internal/cef_thread_internal.h', 'include/internal/cef_thread_internal.h',
'include/internal/cef_time.h', 'include/internal/cef_time.h',
'include/internal/cef_trace_event_internal.h', 'include/internal/cef_trace_event_internal.h',
'include/internal/cef_types.h', 'include/internal/cef_types.h',
'include/internal/cef_types_wrappers.h',
], ],
'includes_capi': [ 'includes_capi': [
'include/capi/cef_base_capi.h', 'include/capi/cef_base_capi.h',
@@ -75,15 +77,19 @@
'include/base/internal/cef_atomicops_x86_msvc.h', 'include/base/internal/cef_atomicops_x86_msvc.h',
'include/base/internal/cef_bind_internal_win.h', 'include/base/internal/cef_bind_internal_win.h',
'include/cef_sandbox_win.h', 'include/cef_sandbox_win.h',
'include/internal/cef_types_win.h',
'include/internal/cef_win.h', 'include/internal/cef_win.h',
], ],
'includes_win_capi': [
'include/internal/cef_types_win.h',
],
'includes_mac': [ 'includes_mac': [
'include/base/internal/cef_atomicops_atomicword_compat.h', 'include/base/internal/cef_atomicops_atomicword_compat.h',
'include/base/internal/cef_atomicops_mac.h', 'include/base/internal/cef_atomicops_mac.h',
'include/cef_application_mac.h', 'include/cef_application_mac.h',
'include/cef_sandbox_mac.h', 'include/cef_sandbox_mac.h',
'include/internal/cef_mac.h', 'include/internal/cef_mac.h',
],
'includes_mac_capi': [
'include/internal/cef_types_mac.h', 'include/internal/cef_types_mac.h',
], ],
'includes_linux': [ 'includes_linux': [
@@ -92,6 +98,8 @@
'include/base/internal/cef_atomicops_arm64_gcc.h', 'include/base/internal/cef_atomicops_arm64_gcc.h',
'include/base/internal/cef_atomicops_x86_gcc.h', 'include/base/internal/cef_atomicops_x86_gcc.h',
'include/internal/cef_linux.h', 'include/internal/cef_linux.h',
],
'includes_linux_capi': [
'include/internal/cef_types_linux.h', 'include/internal/cef_types_linux.h',
], ],
'libcef_sources_common': [ 'libcef_sources_common': [
@@ -238,6 +246,8 @@
'tests/cefclient/browser/main_context.h', 'tests/cefclient/browser/main_context.h',
'tests/cefclient/browser/main_context_impl.cc', 'tests/cefclient/browser/main_context_impl.cc',
'tests/cefclient/browser/main_context_impl.h', 'tests/cefclient/browser/main_context_impl.h',
'tests/cefclient/browser/media_router_test.cc',
'tests/cefclient/browser/media_router_test.h',
'tests/cefclient/browser/osr_dragdrop_events.h', 'tests/cefclient/browser/osr_dragdrop_events.h',
'tests/cefclient/browser/osr_renderer.h', 'tests/cefclient/browser/osr_renderer.h',
'tests/cefclient/browser/osr_renderer.cc', 'tests/cefclient/browser/osr_renderer.cc',
@@ -287,6 +297,7 @@
'tests/cefclient/resources/drm.html', 'tests/cefclient/resources/drm.html',
'tests/cefclient/resources/localstorage.html', 'tests/cefclient/resources/localstorage.html',
'tests/cefclient/resources/logo.png', 'tests/cefclient/resources/logo.png',
'tests/cefclient/resources/media_router.html',
'tests/cefclient/resources/menu_icon.1x.png', 'tests/cefclient/resources/menu_icon.1x.png',
'tests/cefclient/resources/menu_icon.2x.png', 'tests/cefclient/resources/menu_icon.2x.png',
'tests/cefclient/resources/other_tests.html', 'tests/cefclient/resources/other_tests.html',
@@ -455,9 +466,12 @@
'tests/cefsimple/simple_handler_linux.cc', 'tests/cefsimple/simple_handler_linux.cc',
], ],
'ceftests_sources_common': [ 'ceftests_sources_common': [
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/browser_info_map_unittest.cc', 'tests/ceftests/browser_info_map_unittest.cc',
'tests/ceftests/command_line_unittest.cc', 'tests/ceftests/command_line_unittest.cc',
'tests/ceftests/cookie_unittest.cc', 'tests/ceftests/cookie_unittest.cc',
'tests/ceftests/cors_unittest.cc',
'tests/ceftests/devtools_message_unittest.cc',
'tests/ceftests/dialog_unittest.cc', 'tests/ceftests/dialog_unittest.cc',
'tests/ceftests/display_unittest.cc', 'tests/ceftests/display_unittest.cc',
'tests/ceftests/dom_unittest.cc', 'tests/ceftests/dom_unittest.cc',
@@ -507,6 +521,11 @@
'tests/ceftests/task_unittest.cc', 'tests/ceftests/task_unittest.cc',
'tests/ceftests/test_handler.cc', 'tests/ceftests/test_handler.cc',
'tests/ceftests/test_handler.h', 'tests/ceftests/test_handler.h',
'tests/ceftests/test_request.cc',
'tests/ceftests/test_request.h',
'tests/ceftests/test_server.cc',
'tests/ceftests/test_server.h',
'tests/ceftests/test_server_unittest.cc',
'tests/ceftests/test_suite.cc', 'tests/ceftests/test_suite.cc',
'tests/ceftests/test_suite.h', 'tests/ceftests/test_suite.h',
'tests/ceftests/test_util.cc', 'tests/ceftests/test_util.cc',
@@ -515,6 +534,7 @@
'tests/ceftests/thread_helper.h', 'tests/ceftests/thread_helper.h',
'tests/ceftests/thread_unittest.cc', 'tests/ceftests/thread_unittest.cc',
'tests/ceftests/tracing_unittest.cc', 'tests/ceftests/tracing_unittest.cc',
'tests/ceftests/track_callback.h',
'tests/ceftests/translator_unittest.cc', 'tests/ceftests/translator_unittest.cc',
'tests/ceftests/urlrequest_unittest.cc', 'tests/ceftests/urlrequest_unittest.cc',
'tests/ceftests/v8_unittest.cc', 'tests/ceftests/v8_unittest.cc',
@@ -554,6 +574,7 @@
'tests/shared/browser/resource_util.h', 'tests/shared/browser/resource_util.h',
'tests/shared/browser/resource_util_mac.mm', 'tests/shared/browser/resource_util_mac.mm',
'tests/shared/browser/resource_util_posix.cc', 'tests/shared/browser/resource_util_posix.cc',
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/client_app_delegates.cc', 'tests/ceftests/client_app_delegates.cc',
'tests/ceftests/cookie_unittest.cc', 'tests/ceftests/cookie_unittest.cc',
'tests/ceftests/dom_unittest.cc', 'tests/ceftests/dom_unittest.cc',
@@ -573,10 +594,15 @@
'tests/ceftests/urlrequest_unittest.cc', 'tests/ceftests/urlrequest_unittest.cc',
'tests/ceftests/test_handler.cc', 'tests/ceftests/test_handler.cc',
'tests/ceftests/test_handler.h', 'tests/ceftests/test_handler.h',
'tests/ceftests/test_request.cc',
'tests/ceftests/test_request.h',
'tests/ceftests/test_server.cc',
'tests/ceftests/test_server.h',
'tests/ceftests/test_suite.cc', 'tests/ceftests/test_suite.cc',
'tests/ceftests/test_suite.h', 'tests/ceftests/test_suite.h',
'tests/ceftests/test_util.cc', 'tests/ceftests/test_util.cc',
'tests/ceftests/test_util.h', 'tests/ceftests/test_util.h',
'tests/ceftests/track_callback.h',
'tests/ceftests/thread_helper.cc', 'tests/ceftests/thread_helper.cc',
'tests/ceftests/thread_helper.h', 'tests/ceftests/thread_helper.h',
'tests/ceftests/thread_unittest.cc', 'tests/ceftests/thread_unittest.cc',

View File

@@ -34,6 +34,7 @@ template("_repack_one_locale") {
"${root_gen_dir}/chrome/generated_resources_${locale}.pak", "${root_gen_dir}/chrome/generated_resources_${locale}.pak",
"${root_gen_dir}/chrome/locale_settings_${locale}.pak", "${root_gen_dir}/chrome/locale_settings_${locale}.pak",
"${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak", "${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak",
"${root_gen_dir}/components/strings/components_chromium_strings_${locale}.pak",
"${root_gen_dir}/components/strings/components_locale_settings_${locale}.pak", "${root_gen_dir}/components/strings/components_locale_settings_${locale}.pak",
"${root_gen_dir}/components/strings/components_strings_${locale}.pak", "${root_gen_dir}/components/strings/components_strings_${locale}.pak",
"${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak", "${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak",
@@ -52,6 +53,7 @@ template("_repack_one_locale") {
"//chrome/app:generated_resources", "//chrome/app:generated_resources",
"//chrome/app/resources:locale_settings", "//chrome/app/resources:locale_settings",
"//chrome/app/resources:platform_locale_settings", "//chrome/app/resources:platform_locale_settings",
"//components/strings:components_chromium_strings",
"//components/strings:components_locale_settings", "//components/strings:components_locale_settings",
"//components/strings:components_strings", "//components/strings:components_strings",
"//extensions/strings", "//extensions/strings",

View File

@@ -25,7 +25,7 @@ macro(PRINT_CEF_CONFIG)
message(STATUS "Binary distribution root: ${_CEF_ROOT}") message(STATUS "Binary distribution root: ${_CEF_ROOT}")
if(OS_MACOSX) if(OS_MAC)
message(STATUS "Base SDK: ${CMAKE_OSX_SYSROOT}") message(STATUS "Base SDK: ${CMAKE_OSX_SYSROOT}")
message(STATUS "Target SDK: ${CEF_TARGET_SDK}") message(STATUS "Target SDK: ${CEF_TARGET_SDK}")
endif() endif()
@@ -75,8 +75,8 @@ macro(APPEND_PLATFORM_SOURCES name_of_list)
if(OS_WINDOWS AND ${name_of_list}_WINDOWS) if(OS_WINDOWS AND ${name_of_list}_WINDOWS)
list(APPEND ${name_of_list} ${${name_of_list}_WINDOWS}) list(APPEND ${name_of_list} ${${name_of_list}_WINDOWS})
endif() endif()
if(OS_MACOSX AND ${name_of_list}_MACOSX) if(OS_MAC AND ${name_of_list}_MAC)
list(APPEND ${name_of_list} ${${name_of_list}_MACOSX}) list(APPEND ${name_of_list} ${${name_of_list}_MAC})
endif() endif()
endmacro() endmacro()
@@ -184,10 +184,10 @@ endif(OS_LINUX)
# Mac OS X macros. # Mac OS X macros.
# #
if(OS_MACOSX) if(OS_MAC)
# Manually process and copy over resource files. # Manually process and copy over resource files.
macro(COPY_MACOSX_RESOURCES resource_list prefix_list target source_dir app_path) macro(COPY_MAC_RESOURCES resource_list prefix_list target source_dir app_path)
foreach(FILENAME ${resource_list}) foreach(FILENAME ${resource_list})
# Remove one or more prefixes from the source paths. # Remove one or more prefixes from the source paths.
set(TARGET_FILENAME "${FILENAME}") set(TARGET_FILENAME "${FILENAME}")
@@ -229,7 +229,7 @@ macro(COPY_MACOSX_RESOURCES resource_list prefix_list target source_dir app_path
endforeach() endforeach()
endmacro() endmacro()
endif(OS_MACOSX) endif(OS_MAC)
# #
@@ -298,7 +298,7 @@ macro(SET_COMMON_TARGET_PROPERTIES target)
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str}) set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
endif() endif()
if(OS_MACOSX) if(OS_MAC)
# Set Xcode target properties. # Set Xcode target properties.
set_target_properties(${target} PROPERTIES set_target_properties(${target} PROPERTIES
XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO

View File

@@ -14,7 +14,8 @@ endif()
# Determine the platform. # Determine the platform.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(OS_MACOSX 1) set(OS_MAC 1)
set(OS_MACOSX 1) # For backwards compatibility.
set(OS_POSIX 1) set(OS_POSIX 1)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(OS_LINUX 1) set(OS_LINUX 1)
@@ -31,7 +32,7 @@ if(NOT DEFINED PROJECT_ARCH)
set(PROJECT_ARCH "x86") set(PROJECT_ARCH "x86")
endif() endif()
if(OS_MACOSX) if(OS_MAC)
# PROJECT_ARCH should be specified on Mac OS X. # PROJECT_ARCH should be specified on Mac OS X.
message(WARNING "No PROJECT_ARCH value specified, using ${PROJECT_ARCH}") message(WARNING "No PROJECT_ARCH value specified, using ${PROJECT_ARCH}")
endif() endif()
@@ -246,7 +247,7 @@ endif()
# Mac OS X configuration. # Mac OS X configuration.
# #
if(OS_MACOSX) if(OS_MAC)
# Platform-specific compiler/linker flags. # Platform-specific compiler/linker flags.
# See also Xcode target properties in cef_macros.cmake. # See also Xcode target properties in cef_macros.cmake.
set(CEF_LIBTYPE SHARED) set(CEF_LIBTYPE SHARED)
@@ -310,7 +311,7 @@ if(OS_MACOSX)
# Find the newest available base SDK. # Find the newest available base SDK.
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
foreach(OS_VERSION 10.11 10.10 10.9) foreach(OS_VERSION 10.15 10.14 10.13 10.12 10.11 10.10)
set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk") 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}") if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}")
set(CMAKE_OSX_SYSROOT ${SDK}) set(CMAKE_OSX_SYSROOT ${SDK})
@@ -318,7 +319,7 @@ if(OS_MACOSX)
endforeach() endforeach()
# Target SDK. # Target SDK.
set(CEF_TARGET_SDK "10.9") set(CEF_TARGET_SDK "10.10")
list(APPEND CEF_COMPILER_FLAGS list(APPEND CEF_COMPILER_FLAGS
-mmacosx-version-min=${CEF_TARGET_SDK} -mmacosx-version-min=${CEF_TARGET_SDK}
) )
@@ -375,25 +376,8 @@ if(OS_WINDOWS)
if(USE_SANDBOX) if(USE_SANDBOX)
# Check if the current MSVC version is compatible with the cef_sandbox.lib # Check if the current MSVC version is compatible with the cef_sandbox.lib
# static library. For a list of all version numbers see # static library. We require VS2015 or newer.
# https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering if(MSVC_VERSION LESS 1900)
list(APPEND supported_msvc_versions
1900 # VS2015 and updates 1, 2, & 3
1910 # VS2017 version 15.1 & 15.2
1911 # VS2017 version 15.3 & 15.4
1912 # VS2017 version 15.5
1913 # VS2017 version 15.6
1914 # VS2017 version 15.7
1915 # VS2017 version 15.8
1916 # VS2017 version 15.9
1920 # VS2019 version 16.0
1921 # VS2019 version 16.1
1922 # VS2019 version 16.2
1923 # VS2019 version 16.3
1924 # VS2019 version 16.4
)
list(FIND supported_msvc_versions ${MSVC_VERSION} _index)
if (${_index} EQUAL -1)
message(WARNING "CEF sandbox is not compatible with the current MSVC version (${MSVC_VERSION})") message(WARNING "CEF sandbox is not compatible with the current MSVC version (${MSVC_VERSION})")
set(USE_SANDBOX OFF) set(USE_SANDBOX OFF)
endif() endif()

View File

@@ -178,9 +178,9 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
// Include our platform specific implementation. // Include our platform specific implementation.
#if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY) #if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY)
#include "include/base/internal/cef_atomicops_x86_msvc.h" #include "include/base/internal/cef_atomicops_x86_msvc.h"
#elif defined(OS_WIN) && defined(__ARM_ARCH_ISA_A64) #elif defined(OS_WIN) && (defined(__ARM_ARCH_ISA_A64) || defined(_M_ARM64))
#include "include/base/internal/cef_atomicops_arm64_msvc.h" #include "include/base/internal/cef_atomicops_arm64_msvc.h"
#elif defined(OS_MACOSX) #elif defined(OS_MAC)
#include "include/base/internal/cef_atomicops_mac.h" #include "include/base/internal/cef_atomicops_mac.h"
#elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY) #elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)
#include "include/base/internal/cef_atomicops_x86_gcc.h" #include "include/base/internal/cef_atomicops_x86_gcc.h"
@@ -194,7 +194,7 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
// On some platforms we need additional declarations to make // On some platforms we need additional declarations to make
// AtomicWord compatible with our other Atomic* types. // AtomicWord compatible with our other Atomic* types.
#if defined(OS_MACOSX) || defined(OS_OPENBSD) #if defined(OS_MAC) || defined(OS_OPENBSD)
#include "include/base/internal/cef_atomicops_atomicword_compat.h" #include "include/base/internal/cef_atomicops_atomicword_compat.h"
#endif #endif

View File

@@ -42,7 +42,7 @@
// //
// On Mac OS X, |long long| is used for 64-bit types for compatibility with // On Mac OS X, |long long| is used for 64-bit types for compatibility with
// <inttypes.h> format macros even in the LP64 model. // <inttypes.h> format macros even in the LP64 model.
#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) #if defined(__LP64__) && !defined(OS_MAC) && !defined(OS_OPENBSD)
typedef long int64; typedef long int64;
typedef unsigned long uint64; typedef unsigned long uint64;
#else #else

View File

@@ -44,6 +44,14 @@
#define OS_WIN 1 #define OS_WIN 1
#endif #endif
#elif defined(__APPLE__) #elif defined(__APPLE__)
// New platform defines after https://crbug.com/1105907.
#ifndef OS_MAC
#define OS_MAC 1
#endif
#ifndef OS_APPLE
#define OS_APPLE 1
#endif
// Old platform defines retained for backwards compatibility.
#ifndef OS_MACOSX #ifndef OS_MACOSX
#define OS_MACOSX 1 #define OS_MACOSX 1
#endif #endif
@@ -57,7 +65,7 @@
// For access to standard POSIXish features, use OS_POSIX instead of a // For access to standard POSIXish features, use OS_POSIX instead of a
// more specific macro. // more specific macro.
#if defined(OS_MACOSX) || defined(OS_LINUX) #if defined(OS_MAC) || defined(OS_LINUX)
#ifndef OS_POSIX #ifndef OS_POSIX
#define OS_POSIX 1 #define OS_POSIX 1
#endif #endif
@@ -95,7 +103,7 @@
#define ARCH_CPU_ARMEL 1 #define ARCH_CPU_ARMEL 1
#define ARCH_CPU_32_BITS 1 #define ARCH_CPU_32_BITS 1
#define ARCH_CPU_LITTLE_ENDIAN 1 #define ARCH_CPU_LITTLE_ENDIAN 1
#elif defined(__aarch64__) #elif defined(__aarch64__) || defined(_M_ARM64)
#define ARCH_CPU_ARM_FAMILY 1 #define ARCH_CPU_ARM_FAMILY 1
#define ARCH_CPU_ARM64 1 #define ARCH_CPU_ARM64 1
#define ARCH_CPU_64_BITS 1 #define ARCH_CPU_64_BITS 1

View File

@@ -136,7 +136,11 @@
#define CEF_INCLUDE_BASE_CEF_LOGGING_H_ #define CEF_INCLUDE_BASE_CEF_LOGGING_H_
#pragma once #pragma once
#if defined(DCHECK) #if defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "base/logging.h"
#include "base/notreached.h"
#elif defined(DCHECK)
// Do nothing if the macros provided by this header already exist. // Do nothing if the macros provided by this header already exist.
// This can happen in cases where Chromium code is used directly by the // This can happen in cases where Chromium code is used directly by the
// client application. When using Chromium code directly always include // client application. When using Chromium code directly always include
@@ -149,10 +153,7 @@
#define DCHECK_IS_ON() true #define DCHECK_IS_ON() true
#endif #endif
#elif defined(USING_CHROMIUM_INCLUDES) #else // !defined(DCHECK)
// When building CEF include the Chromium header directly.
#include "base/logging.h"
#else // !USING_CHROMIUM_INCLUDES
// The following is substantially similar to the Chromium implementation. // The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be // If the Chromium implementation diverges the below implementation should be
// updated to match. // updated to match.

View File

@@ -250,11 +250,11 @@ class WeakPtr : public cef_internal::WeakPtrBase {
T* get() const { return ref_.is_valid() ? ptr_ : NULL; } T* get() const { return ref_.is_valid() ? ptr_ : NULL; }
T& operator*() const { T& operator*() const {
DCHECK(get() != NULL); CHECK(ref_.is_valid());
return *get(); return *get();
} }
T* operator->() const { T* operator->() const {
DCHECK(get() != NULL); CHECK(ref_.is_valid());
return get(); return get();
} }

View File

@@ -0,0 +1,121 @@
// Copyright (c) 2020 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=430877d950508a545d0baa18c8c8c0d2d183fec4$
//
#ifndef CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Implement this structure to handle audio events.
///
typedef struct _cef_audio_handler_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called on the UI thread to allow configuration of audio stream parameters.
// Return true (1) to proceed with audio stream capture, or false (0) to
// cancel it. All members of |params| can optionally be configured here, but
// they are also pre-filled with some sensible defaults.
///
int(CEF_CALLBACK* get_audio_parameters)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
cef_audio_parameters_t* params);
///
// Called on a browser audio capture thread when the browser starts streaming
// audio. OnAudioSteamStopped will always be called after
// OnAudioStreamStarted; both functions may be called multiple times for the
// same browser. |params| contains the audio parameters like sample rate and
// channel layout. |channels| is the number of channels.
///
void(CEF_CALLBACK* on_audio_stream_started)(
struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const cef_audio_parameters_t* params,
int channels);
///
// Called on the audio stream thread when a PCM packet is received for the
// stream. |data| is an array representing the raw PCM data as a floating
// point type, i.e. 4-byte value(s). |frames| is the number of frames in the
// PCM packet. |pts| is the presentation timestamp (in milliseconds since the
// Unix Epoch) and represents the time at which the decompressed packet should
// be presented to the user. Based on |frames| and the |channel_layout| value
// passed to OnAudioStreamStarted you can calculate the size of the |data|
// array in bytes.
///
void(CEF_CALLBACK* on_audio_stream_packet)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const float** data,
int frames,
int64 pts);
///
// Called on the UI thread when the stream has stopped. OnAudioSteamStopped
// will always be called after OnAudioStreamStarted; both functions may be
// called multiple times for the same stream.
///
void(CEF_CALLBACK* on_audio_stream_stopped)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser);
///
// Called on the UI or audio stream thread when an error occurred. During the
// stream creation phase this callback will be called on the UI thread while
// in the capturing phase it will be called on the audio stream thread. The
// stream will be stopped immediately.
///
void(CEF_CALLBACK* on_audio_stream_error)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const cef_string_t* message);
} cef_audio_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=ba4033eaf40a8ee24408b89b78496bf1381e7e6b$ // $hash=6cb00a0fa3631a46903abb3a783f315895511db2$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
@@ -41,10 +41,12 @@
#pragma once #pragma once
#include "include/capi/cef_base_capi.h" #include "include/capi/cef_base_capi.h"
#include "include/capi/cef_devtools_message_observer_capi.h"
#include "include/capi/cef_drag_data_capi.h" #include "include/capi/cef_drag_data_capi.h"
#include "include/capi/cef_frame_capi.h" #include "include/capi/cef_frame_capi.h"
#include "include/capi/cef_image_capi.h" #include "include/capi/cef_image_capi.h"
#include "include/capi/cef_navigation_entry_capi.h" #include "include/capi/cef_navigation_entry_capi.h"
#include "include/capi/cef_registration_capi.h"
#include "include/capi/cef_request_context_capi.h" #include "include/capi/cef_request_context_capi.h"
#ifdef __cplusplus #ifdef __cplusplus
@@ -484,6 +486,71 @@ typedef struct _cef_browser_host_t {
/// ///
int(CEF_CALLBACK* has_dev_tools)(struct _cef_browser_host_t* self); int(CEF_CALLBACK* has_dev_tools)(struct _cef_browser_host_t* self);
///
// Send a function call message over the DevTools protocol. |message| must be
// a UTF8-encoded JSON dictionary that contains "id" (int), "function"
// (string) and "params" (dictionary, optional) values. See the DevTools
// protocol documentation at https://chromedevtools.github.io/devtools-
// protocol/ for details of supported functions and the expected "params"
// dictionary contents. |message| will be copied if necessary. This function
// will return true (1) if called on the UI thread and the message was
// successfully submitted for validation, otherwise false (0). Validation will
// be applied asynchronously and any messages that fail due to formatting
// errors or missing parameters may be discarded without notification. Prefer
// ExecuteDevToolsMethod if a more structured approach to message formatting
// is desired.
//
// Every valid function call will result in an asynchronous function result or
// error message that references the sent message "id". Event messages are
// received while notifications are enabled (for example, between function
// calls for "Page.enable" and "Page.disable"). All received messages will be
// delivered to the observer(s) registered with AddDevToolsMessageObserver.
// See cef_dev_tools_message_observer_t::OnDevToolsMessage documentation for
// details of received message contents.
//
// Usage of the SendDevToolsMessage, ExecuteDevToolsMethod and
// AddDevToolsMessageObserver functions does not require an active DevTools
// front-end or remote-debugging session. Other active DevTools sessions will
// continue to function independently. However, any modification of global
// browser state by one session may not be reflected in the UI of other
// sessions.
//
// Communication with the DevTools front-end (when displayed) can be logged
// for development purposes by passing the `--devtools-protocol-log-
// file=<path>` command-line flag.
///
int(CEF_CALLBACK* send_dev_tools_message)(struct _cef_browser_host_t* self,
const void* message,
size_t message_size);
///
// Execute a function call over the DevTools protocol. This is a more
// structured version of SendDevToolsMessage. |message_id| is an incremental
// number that uniquely identifies the message (pass 0 to have the next number
// assigned automatically based on previous values). |function| is the
// function name. |params| are the function parameters, which may be NULL. See
// the DevTools protocol documentation (linked above) for details of supported
// functions and the expected |params| dictionary contents. This function will
// return the assigned message ID if called on the UI thread and the message
// was successfully submitted for validation, otherwise 0. See the
// SendDevToolsMessage documentation for additional usage information.
///
int(CEF_CALLBACK* execute_dev_tools_method)(
struct _cef_browser_host_t* self,
int message_id,
const cef_string_t* method,
struct _cef_dictionary_value_t* params);
///
// Add an observer for DevTools protocol messages (function results and
// events). The observer will remain registered until the returned
// Registration object is destroyed. See the SendDevToolsMessage documentation
// for additional usage information.
///
struct _cef_registration_t*(CEF_CALLBACK* add_dev_tools_message_observer)(
struct _cef_browser_host_t* self,
struct _cef_dev_tools_message_observer_t* observer);
/// ///
// Retrieve a snapshot of current navigation entries as values sent to the // Retrieve a snapshot of current navigation entries as values sent to the
// specified visitor. If |current_only| is true (1) only the current // specified visitor. If |current_only| is true (1) only the current

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=b15ba2c750f5227b6b40fea59965817ba4431ee0$ // $hash=306236316b35037523ca566068d133755bce48fd$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
@@ -78,17 +78,6 @@ typedef struct _cef_browser_process_handler_t {
struct _cef_browser_process_handler_t* self, struct _cef_browser_process_handler_t* self,
struct _cef_command_line_t* command_line); struct _cef_command_line_t* command_line);
///
// Called on the browser process IO thread after the main thread has been
// created for a new render process. Provides an opportunity to specify extra
// information that will be passed to
// cef_render_process_handler_t::on_render_thread_created() in the render
// process. Do not keep a reference to |extra_info| outside of this function.
///
void(CEF_CALLBACK* on_render_process_thread_created)(
struct _cef_browser_process_handler_t* self,
struct _cef_list_value_t* extra_info);
/// ///
// Return the handler for printing on Linux. If a print handler is not // Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform. // provided then printing will not be supported on the Linux platform.

View File

@@ -33,13 +33,14 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=6a0312765614a697d56e87c8503afba8404bb08b$ // $hash=8d4cb3e0bbf230804c93898daa4a8b2866a2c1ce$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
#pragma once #pragma once
#include "include/capi/cef_audio_handler_capi.h"
#include "include/capi/cef_base_capi.h" #include "include/capi/cef_base_capi.h"
#include "include/capi/cef_context_menu_handler_capi.h" #include "include/capi/cef_context_menu_handler_capi.h"
#include "include/capi/cef_dialog_handler_capi.h" #include "include/capi/cef_dialog_handler_capi.h"
@@ -69,6 +70,12 @@ typedef struct _cef_client_t {
/// ///
cef_base_ref_counted_t base; cef_base_ref_counted_t base;
///
// Return the handler for audio rendering events.
///
struct _cef_audio_handler_t*(CEF_CALLBACK* get_audio_handler)(
struct _cef_client_t* self);
/// ///
// Return the handler for context menus. If no handler is provided the default // Return the handler for context menus. If no handler is provided the default
// implementation will be used. // implementation will be used.

View File

@@ -0,0 +1,147 @@
// Copyright (c) 2020 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=86906c2e971fea7e479738f59bbf85d71ce31953$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_browser_t;
///
// Callback structure for cef_browser_host_t::AddDevToolsMessageObserver. The
// functions of this structure will be called on the browser process UI thread.
///
typedef struct _cef_dev_tools_message_observer_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Method that will be called on receipt of a DevTools protocol message.
// |browser| is the originating browser instance. |message| is a UTF8-encoded
// JSON dictionary representing either a function result or an event.
// |message| is only valid for the scope of this callback and should be copied
// if necessary. Return true (1) if the message was handled or false (0) if
// the message should be further processed and passed to the
// OnDevToolsMethodResult or OnDevToolsEvent functions as appropriate.
//
// Method result dictionaries include an "id" (int) value that identifies the
// orginating function call sent from cef_browser_host_t::SendDevToolsMessage,
// and optionally either a "result" (dictionary) or "error" (dictionary)
// value. The "error" dictionary will contain "code" (int) and "message"
// (string) values. Event dictionaries include a "function" (string) value and
// optionally a "params" (dictionary) value. See the DevTools protocol
// documentation at https://chromedevtools.github.io/devtools-protocol/ for
// details of supported function calls and the expected "result" or "params"
// dictionary contents. JSON dictionaries can be parsed using the CefParseJSON
// function if desired, however be aware of performance considerations when
// parsing large messages (some of which may exceed 1MB in size).
///
int(CEF_CALLBACK* on_dev_tools_message)(
struct _cef_dev_tools_message_observer_t* self,
struct _cef_browser_t* browser,
const void* message,
size_t message_size);
///
// Method that will be called after attempted execution of a DevTools protocol
// function. |browser| is the originating browser instance. |message_id| is
// the "id" value that identifies the originating function call message. If
// the function succeeded |success| will be true (1) and |result| will be the
// UTF8-encoded JSON "result" dictionary value (which may be NULL). If the
// function failed |success| will be false (0) and |result| will be the
// UTF8-encoded JSON "error" dictionary value. |result| is only valid for the
// scope of this callback and should be copied if necessary. See the
// OnDevToolsMessage documentation for additional details on |result|
// contents.
///
void(CEF_CALLBACK* on_dev_tools_method_result)(
struct _cef_dev_tools_message_observer_t* self,
struct _cef_browser_t* browser,
int message_id,
int success,
const void* result,
size_t result_size);
///
// Method that will be called on receipt of a DevTools protocol event.
// |browser| is the originating browser instance. |function| is the "function"
// value. |params| is the UTF8-encoded JSON "params" dictionary value (which
// may be NULL). |params| is only valid for the scope of this callback and
// should be copied if necessary. See the OnDevToolsMessage documentation for
// additional details on |params| contents.
///
void(CEF_CALLBACK* on_dev_tools_event)(
struct _cef_dev_tools_message_observer_t* self,
struct _cef_browser_t* browser,
const cef_string_t* method,
const void* params,
size_t params_size);
///
// Method that will be called when the DevTools agent has attached. |browser|
// is the originating browser instance. This will generally occur in response
// to the first message sent while the agent is detached.
///
void(CEF_CALLBACK* on_dev_tools_agent_attached)(
struct _cef_dev_tools_message_observer_t* self,
struct _cef_browser_t* browser);
///
// Method that will be called when the DevTools agent has detached. |browser|
// is the originating browser instance. Any function results that were pending
// before the agent became detached will not be delivered, and any active
// event subscriptions will be canceled.
///
void(CEF_CALLBACK* on_dev_tools_agent_detached)(
struct _cef_dev_tools_message_observer_t* self,
struct _cef_browser_t* browser);
} cef_dev_tools_message_observer_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_

View File

@@ -0,0 +1,345 @@
// Copyright (c) 2020 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=4f4a0d76efaf87055ebf5e784f5d1b69fafdabc2$
//
#ifndef CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_registration_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_media_observer_t;
struct _cef_media_route_create_callback_t;
struct _cef_media_route_t;
struct _cef_media_sink_device_info_callback_t;
struct _cef_media_sink_t;
struct _cef_media_source_t;
///
// Supports discovery of and communication with media devices on the local
// network via the Cast and DIAL protocols. The functions of this structure may
// be called on any browser process thread unless otherwise indicated.
///
typedef struct _cef_media_router_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Add an observer for MediaRouter events. The observer will remain registered
// until the returned Registration object is destroyed.
///
struct _cef_registration_t*(CEF_CALLBACK* add_observer)(
struct _cef_media_router_t* self,
struct _cef_media_observer_t* observer);
///
// Returns a MediaSource object for the specified media source URN. Supported
// URN schemes include "cast:" and "dial:", and will be already known by the
// client application (e.g. "cast:<appId>?clientId=<clientId>").
///
struct _cef_media_source_t*(CEF_CALLBACK* get_source)(
struct _cef_media_router_t* self,
const cef_string_t* urn);
///
// Trigger an asynchronous call to cef_media_observer_t::OnSinks on all
// registered observers.
///
void(CEF_CALLBACK* notify_current_sinks)(struct _cef_media_router_t* self);
///
// Create a new route between |source| and |sink|. Source and sink must be
// valid, compatible (as reported by cef_media_sink_t::IsCompatibleWith), and
// a route between them must not already exist. |callback| will be executed on
// success or failure. If route creation succeeds it will also trigger an
// asynchronous call to cef_media_observer_t::OnRoutes on all registered
// observers.
///
void(CEF_CALLBACK* create_route)(
struct _cef_media_router_t* self,
struct _cef_media_source_t* source,
struct _cef_media_sink_t* sink,
struct _cef_media_route_create_callback_t* callback);
///
// Trigger an asynchronous call to cef_media_observer_t::OnRoutes on all
// registered observers.
///
void(CEF_CALLBACK* notify_current_routes)(struct _cef_media_router_t* self);
} cef_media_router_t;
///
// Returns the MediaRouter object associated with the global request context.
// Equivalent to calling cef_request_context_t::cef_request_context_get_global_c
// ontext()->get_media_router().
///
CEF_EXPORT cef_media_router_t* cef_media_router_get_global();
///
// Implemented by the client to observe MediaRouter events and registered via
// cef_media_router_t::AddObserver. The functions of this structure will be
// called on the browser process UI thread.
///
typedef struct _cef_media_observer_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// The list of available media sinks has changed or
// cef_media_router_t::NotifyCurrentSinks was called.
///
void(CEF_CALLBACK* on_sinks)(struct _cef_media_observer_t* self,
size_t sinksCount,
struct _cef_media_sink_t* const* sinks);
///
// The list of available media routes has changed or
// cef_media_router_t::NotifyCurrentRoutes was called.
///
void(CEF_CALLBACK* on_routes)(struct _cef_media_observer_t* self,
size_t routesCount,
struct _cef_media_route_t* const* routes);
///
// The connection state of |route| has changed.
///
void(CEF_CALLBACK* on_route_state_changed)(
struct _cef_media_observer_t* self,
struct _cef_media_route_t* route,
cef_media_route_connection_state_t state);
///
// A message was recieved over |route|. |message| is only valid for the scope
// of this callback and should be copied if necessary.
///
void(CEF_CALLBACK* on_route_message_received)(
struct _cef_media_observer_t* self,
struct _cef_media_route_t* route,
const void* message,
size_t message_size);
} cef_media_observer_t;
///
// Represents the route between a media source and sink. Instances of this
// object are created via cef_media_router_t::CreateRoute and retrieved via
// cef_media_observer_t::OnRoutes. Contains the status and metadata of a routing
// operation. The functions of this structure may be called on any browser
// process thread unless otherwise indicated.
///
typedef struct _cef_media_route_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns the ID for this route.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_route_t* self);
///
// Returns the source associated with this route.
///
struct _cef_media_source_t*(CEF_CALLBACK* get_source)(
struct _cef_media_route_t* self);
///
// Returns the sink associated with this route.
///
struct _cef_media_sink_t*(CEF_CALLBACK* get_sink)(
struct _cef_media_route_t* self);
///
// Send a message over this route. |message| will be copied if necessary.
///
void(CEF_CALLBACK* send_route_message)(struct _cef_media_route_t* self,
const void* message,
size_t message_size);
///
// Terminate this route. Will result in an asynchronous call to
// cef_media_observer_t::OnRoutes on all registered observers.
///
void(CEF_CALLBACK* terminate)(struct _cef_media_route_t* self);
} cef_media_route_t;
///
// Callback structure for cef_media_router_t::CreateRoute. The functions of this
// structure will be called on the browser process UI thread.
///
typedef struct _cef_media_route_create_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Method that will be executed when the route creation has finished. |result|
// will be CEF_MRCR_OK if the route creation succeeded. |error| will be a
// description of the error if the route creation failed. |route| is the
// resulting route, or NULL if the route creation failed.
///
void(CEF_CALLBACK* on_media_route_create_finished)(
struct _cef_media_route_create_callback_t* self,
cef_media_route_create_result_t result,
const cef_string_t* error,
struct _cef_media_route_t* route);
} cef_media_route_create_callback_t;
///
// Represents a sink to which media can be routed. Instances of this object are
// retrieved via cef_media_observer_t::OnSinks. The functions of this structure
// may be called on any browser process thread unless otherwise indicated.
///
typedef struct _cef_media_sink_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns the ID for this sink.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_sink_t* self);
///
// Returns the name of this sink.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_media_sink_t* self);
///
// Returns the description of this sink.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_description)(
struct _cef_media_sink_t* self);
///
// Returns the icon type for this sink.
///
cef_media_sink_icon_type_t(CEF_CALLBACK* get_icon_type)(
struct _cef_media_sink_t* self);
///
// Asynchronously retrieves device info.
///
void(CEF_CALLBACK* get_device_info)(
struct _cef_media_sink_t* self,
struct _cef_media_sink_device_info_callback_t* callback);
///
// Returns true (1) if this sink accepts content via Cast.
///
int(CEF_CALLBACK* is_cast_sink)(struct _cef_media_sink_t* self);
///
// Returns true (1) if this sink accepts content via DIAL.
///
int(CEF_CALLBACK* is_dial_sink)(struct _cef_media_sink_t* self);
///
// Returns true (1) if this sink is compatible with |source|.
///
int(CEF_CALLBACK* is_compatible_with)(struct _cef_media_sink_t* self,
struct _cef_media_source_t* source);
} cef_media_sink_t;
///
// Callback structure for cef_media_sink_t::GetDeviceInfo. The functions of this
// structure will be called on the browser process UI thread.
///
typedef struct _cef_media_sink_device_info_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Method that will be executed asyncronously once device information has been
// retrieved.
///
void(CEF_CALLBACK* on_media_sink_device_info)(
struct _cef_media_sink_device_info_callback_t* self,
const struct _cef_media_sink_device_info_t* device_info);
} cef_media_sink_device_info_callback_t;
///
// Represents a source from which media can be routed. Instances of this object
// are retrieved via cef_media_router_t::GetSource. The functions of this
// structure may be called on any browser process thread unless otherwise
// indicated.
///
typedef struct _cef_media_source_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns the ID (media source URN or URL) for this source.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_source_t* self);
///
// Returns true (1) if this source outputs its content via Cast.
///
int(CEF_CALLBACK* is_cast_source)(struct _cef_media_source_t* self);
///
// Returns true (1) if this source outputs its content via DIAL.
///
int(CEF_CALLBACK* is_dial_source)(struct _cef_media_source_t* self);
} cef_media_source_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=3bc4225f43428d8a3a24dcac1830dafac18b0caf$ // $hash=14cf03e02d8ca3416e65f756470afd8185c7bc78$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_
@@ -140,6 +140,16 @@ CEF_EXPORT struct _cef_value_t* cef_parse_json(
const cef_string_t* json_string, const cef_string_t* json_string,
cef_json_parser_options_t options); cef_json_parser_options_t options);
///
// Parses the specified UTF8-encoded |json| buffer of size |json_size| and
// returns a dictionary or list representation. If JSON parsing fails this
// function returns NULL.
///
CEF_EXPORT struct _cef_value_t* cef_parse_json_buffer(
const void* json,
size_t json_size,
cef_json_parser_options_t options);
/// ///
// Parses the specified |json_string| and returns a dictionary or list // Parses the specified |json_string| and returns a dictionary or list
// representation. If JSON parsing fails this function returns NULL and // representation. If JSON parsing fails this function returns NULL and

View File

@@ -0,0 +1,63 @@
// Copyright (c) 2020 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=029e237cf80f94a25453bac5a9b1e0765bb56f37$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Generic callback structure used for managing the lifespan of a registration.
///
typedef struct _cef_registration_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
} cef_registration_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=3630a82a4ea731b43ed4ba468a57c5dfe15f8679$ // $hash=8419eb3eba9dd372b019bd367d4f195433b21c9b$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_
@@ -64,16 +64,6 @@ typedef struct _cef_render_process_handler_t {
/// ///
cef_base_ref_counted_t base; cef_base_ref_counted_t base;
///
// Called after the render process main thread has been created. |extra_info|
// is a read-only value originating from
// cef_browser_process_handler_t::on_render_process_thread_created(). Do not
// keep a reference to |extra_info| outside of this function.
///
void(CEF_CALLBACK* on_render_thread_created)(
struct _cef_render_process_handler_t* self,
struct _cef_list_value_t* extra_info);
/// ///
// Called after WebKit has been initialized. // Called after WebKit has been initialized.
/// ///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=2b01472d9b9a8cc9d1b2e669c91c2849bdb162e9$ // $hash=7ce0953f069204a4dd2037c4a05ac9454c5e66a6$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@@ -44,6 +44,7 @@
#include "include/capi/cef_cookie_capi.h" #include "include/capi/cef_cookie_capi.h"
#include "include/capi/cef_extension_capi.h" #include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_extension_handler_capi.h" #include "include/capi/cef_extension_handler_capi.h"
#include "include/capi/cef_media_router_capi.h"
#include "include/capi/cef_values_capi.h" #include "include/capi/cef_values_capi.h"
#ifdef __cplusplus #ifdef __cplusplus
@@ -353,6 +354,12 @@ typedef struct _cef_request_context_t {
struct _cef_extension_t*(CEF_CALLBACK* get_extension)( struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
struct _cef_request_context_t* self, struct _cef_request_context_t* self,
const cef_string_t* extension_id); const cef_string_t* extension_id);
///
// Returns the MediaRouter object associated with this context.
///
struct _cef_media_router_t*(CEF_CALLBACK* get_media_router)(
struct _cef_request_context_t* self);
} cef_request_context_t; } cef_request_context_t;
/// ///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=a28219cc8c1cb53faacaf236374c3cf2c0c45bef$ // $hash=0167eb1abe614bd6391d273a8085fa3e53e7c217$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_
@@ -253,6 +253,14 @@ typedef struct _cef_request_handler_t {
struct _cef_request_handler_t* self, struct _cef_request_handler_t* self,
struct _cef_browser_t* browser, struct _cef_browser_t* browser,
cef_termination_status_t status); cef_termination_status_t status);
///
// Called on the browser process UI thread when the window.document object of
// the main frame has been created.
///
void(CEF_CALLBACK* on_document_available_in_main_frame)(
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser);
} cef_request_handler_t; } cef_request_handler_t;
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=b9577b495df3990284d4e4a3db2824196175dc91$ // $hash=b0e2b63b467c6d4e990405d948908da3546ea1c7$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_
@@ -41,6 +41,7 @@
#pragma once #pragma once
#include "include/capi/cef_base_capi.h" #include "include/capi/cef_base_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -70,34 +71,25 @@ typedef struct _cef_resource_bundle_t {
int string_id); int string_id);
/// ///
// Retrieves the contents of the specified scale independent |resource_id|. If // Returns a cef_binary_value_t containing the decompressed contents of the
// the value is found then |data| and |data_size| will be populated and this // specified scale independent |resource_id| or NULL if not found. Include
// function will return true (1). If the value is not found then this function // cef_pack_resources.h for a listing of valid resource ID values.
// will return false (0). The returned |data| pointer will remain resident in
// memory and should not be freed. Include cef_pack_resources.h for a listing
// of valid resource ID values.
/// ///
int(CEF_CALLBACK* get_data_resource)(struct _cef_resource_bundle_t* self, struct _cef_binary_value_t*(CEF_CALLBACK* get_data_resource)(
int resource_id, struct _cef_resource_bundle_t* self,
void** data, int resource_id);
size_t* data_size);
/// ///
// Retrieves the contents of the specified |resource_id| nearest the scale // Returns a cef_binary_value_t containing the decompressed contents of the
// factor |scale_factor|. Use a |scale_factor| value of SCALE_FACTOR_NONE for // specified |resource_id| nearest the scale factor |scale_factor| or NULL if
// scale independent resources or call GetDataResource instead. If the value // not found. Use a |scale_factor| value of SCALE_FACTOR_NONE for scale
// is found then |data| and |data_size| will be populated and this function // independent resources or call GetDataResource instead.Include
// will return true (1). If the value is not found then this function will // cef_pack_resources.h for a listing of valid resource ID values.
// return false (0). The returned |data| pointer will remain resident in
// memory and should not be freed. Include cef_pack_resources.h for a listing
// of valid resource ID values.
/// ///
int(CEF_CALLBACK* get_data_resource_for_scale)( struct _cef_binary_value_t*(CEF_CALLBACK* get_data_resource_for_scale)(
struct _cef_resource_bundle_t* self, struct _cef_resource_bundle_t* self,
int resource_id, int resource_id,
cef_scale_factor_t scale_factor, cef_scale_factor_t scale_factor);
void** data,
size_t* data_size);
} cef_resource_bundle_t; } cef_resource_bundle_t;
/// ///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=63d875f5a922dd2c2e1efaaf0ddaa20475f79ef8$ // $hash=75f4f7a9ff628a6ae699a697722caa5d49546784$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_
@@ -115,20 +115,13 @@ typedef struct _cef_urlrequest_t {
// Create a new URL request that is not associated with a specific browser or // Create a new URL request that is not associated with a specific browser or
// frame. Use cef_frame_t::CreateURLRequest instead if you want the request to // frame. Use cef_frame_t::CreateURLRequest instead if you want the request to
// have this association, in which case it may be handled differently (see // have this association, in which case it may be handled differently (see
// documentation on that function). Requests may originate from the both browser // documentation on that function). A request created with this function may
// process and the render process. // only originate from the browser process, and will behave as follows:
//
// For requests originating from the browser process:
// - It may be intercepted by the client via CefResourceRequestHandler or // - It may be intercepted by the client via CefResourceRequestHandler or
// CefSchemeHandlerFactory. // CefSchemeHandlerFactory.
// - POST data may only contain only a single element of type PDE_TYPE_FILE // - POST data may only contain only a single element of type PDE_TYPE_FILE
// or PDE_TYPE_BYTES. // or PDE_TYPE_BYTES.
// - If |request_context| is empty the global request context will be used. // - If |request_context| is empty the global request context will be used.
// For requests originating from the render process:
// - It cannot be intercepted by the client so only http(s) and blob schemes
// are supported.
// - POST data may only contain a single element of type PDE_TYPE_BYTES.
// - The |request_context| parameter must be NULL.
// //
// The |request| object will be marked as read-only after calling this function. // The |request| object will be marked as read-only after calling this function.
/// ///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=422243fda6e1404222aca7bdd4e7b84b961a9626$ // $hash=652ac7a90c6cd10b1cbc6ae99a549c03f36c794e$
// //
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_DISPLAY_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_DISPLAY_CAPI_H_
@@ -50,9 +50,9 @@ extern "C" {
// This structure typically, but not always, corresponds to a physical display // This structure typically, but not always, corresponds to a physical display
// connected to the system. A fake Display may exist on a headless system, or a // connected to the system. A fake Display may exist on a headless system, or a
// Display may correspond to a remote, virtual display. All size and position // Display may correspond to a remote, virtual display. All size and position
// values are in density independent pixels (DIP) unless otherwise indicated. // values are in density independent pixel (DIP) coordinates unless otherwise
// Methods must be called on the browser process UI thread unless otherwise // indicated. Methods must be called on the browser process UI thread unless
// indicated. // otherwise indicated.
/// ///
typedef struct _cef_display_t { typedef struct _cef_display_t {
/// ///
@@ -74,27 +74,28 @@ typedef struct _cef_display_t {
float(CEF_CALLBACK* get_device_scale_factor)(struct _cef_display_t* self); float(CEF_CALLBACK* get_device_scale_factor)(struct _cef_display_t* self);
/// ///
// Convert |point| from density independent pixels (DIP) to pixel coordinates // Convert |point| from DIP coordinates to pixel coordinates using this
// using this Display's device scale factor. // Display's device scale factor.
/// ///
void(CEF_CALLBACK* convert_point_to_pixels)(struct _cef_display_t* self, void(CEF_CALLBACK* convert_point_to_pixels)(struct _cef_display_t* self,
cef_point_t* point); cef_point_t* point);
/// ///
// Convert |point| from pixel coordinates to density independent pixels (DIP) // Convert |point| from pixel coordinates to DIP coordinates using this
// using this Display's device scale factor. // Display's device scale factor.
/// ///
void(CEF_CALLBACK* convert_point_from_pixels)(struct _cef_display_t* self, void(CEF_CALLBACK* convert_point_from_pixels)(struct _cef_display_t* self,
cef_point_t* point); cef_point_t* point);
/// ///
// Returns this Display's bounds. This is the full size of the display. // Returns this Display's bounds in DIP screen coordinates. This is the full
// size of the display.
/// ///
cef_rect_t(CEF_CALLBACK* get_bounds)(struct _cef_display_t* self); cef_rect_t(CEF_CALLBACK* get_bounds)(struct _cef_display_t* self);
/// ///
// Returns this Display's work area. This excludes areas of the display that // Returns this Display's work area in DIP screen coordinates. This excludes
// are occupied for window manager toolbars, etc. // areas of the display that are occupied with window manager toolbars, etc.
/// ///
cef_rect_t(CEF_CALLBACK* get_work_area)(struct _cef_display_t* self); cef_rect_t(CEF_CALLBACK* get_work_area)(struct _cef_display_t* self);
@@ -111,7 +112,7 @@ CEF_EXPORT cef_display_t* cef_display_get_primary();
/// ///
// Returns the Display nearest |point|. Set |input_pixel_coords| to true (1) if // Returns the Display nearest |point|. Set |input_pixel_coords| to true (1) if
// |point| is in pixel coordinates instead of density independent pixels (DIP). // |point| is in pixel screen coordinates instead of DIP screen coordinates.
/// ///
CEF_EXPORT cef_display_t* cef_display_get_nearest_point( CEF_EXPORT cef_display_t* cef_display_get_nearest_point(
const cef_point_t* point, const cef_point_t* point,
@@ -119,8 +120,8 @@ CEF_EXPORT cef_display_t* cef_display_get_nearest_point(
/// ///
// Returns the Display that most closely intersects |bounds|. Set // Returns the Display that most closely intersects |bounds|. Set
// |input_pixel_coords| to true (1) if |bounds| is in pixel coordinates instead // |input_pixel_coords| to true (1) if |bounds| is in pixel screen coordinates
// of density independent pixels (DIP). // instead of DIP screen coordinates.
/// ///
CEF_EXPORT cef_display_t* cef_display_get_matching_bounds( CEF_EXPORT cef_display_t* cef_display_get_matching_bounds(
const cef_rect_t* bounds, const cef_rect_t* bounds,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=71ba0e5714400e2bea3ca564cab4527d95e4b52c$ // $hash=06f1c03ba824052122c6217c1227931f15dadd08$
// //
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_TEXTFIELD_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_TEXTFIELD_CAPI_H_
@@ -219,16 +219,13 @@ typedef struct _cef_textfield_t {
// enabled. See additional comments on execute_command(). // enabled. See additional comments on execute_command().
/// ///
int(CEF_CALLBACK* is_command_enabled)(struct _cef_textfield_t* self, int(CEF_CALLBACK* is_command_enabled)(struct _cef_textfield_t* self,
int command_id); cef_text_field_commands_t command_id);
/// ///
// Performs the action associated with the specified command id. Valid values // Performs the action associated with the specified command id.
// include IDS_APP_UNDO, IDS_APP_REDO, IDS_APP_CUT, IDS_APP_COPY,
// IDS_APP_PASTE, IDS_APP_DELETE, IDS_APP_SELECT_ALL, IDS_DELETE_* and
// IDS_MOVE_*. See include/cef_pack_strings.h for definitions.
/// ///
void(CEF_CALLBACK* execute_command)(struct _cef_textfield_t* self, void(CEF_CALLBACK* execute_command)(struct _cef_textfield_t* self,
int command_id); cef_text_field_commands_t command_id);
/// ///
// Clears Edit history. // Clears Edit history.

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=45b421dfcf8ee7cf61b1991a336bc65d33fbe10a$ // $hash=55be3e44016d9861bb8e9270b52f2bf45c8a53f5$
// //
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_
@@ -176,64 +176,72 @@ typedef struct _cef_view_t {
int id); int id);
/// ///
// Sets the bounds (size and position) of this View. Position is in parent // Sets the bounds (size and position) of this View. |bounds| is in parent
// coordinates. // coordinates, or DIP screen coordinates if there is no parent.
/// ///
void(CEF_CALLBACK* set_bounds)(struct _cef_view_t* self, void(CEF_CALLBACK* set_bounds)(struct _cef_view_t* self,
const cef_rect_t* bounds); const cef_rect_t* bounds);
/// ///
// Returns the bounds (size and position) of this View. Position is in parent // Returns the bounds (size and position) of this View in parent coordinates,
// coordinates. // or DIP screen coordinates if there is no parent.
/// ///
cef_rect_t(CEF_CALLBACK* get_bounds)(struct _cef_view_t* self); cef_rect_t(CEF_CALLBACK* get_bounds)(struct _cef_view_t* self);
/// ///
// Returns the bounds (size and position) of this View. Position is in screen // Returns the bounds (size and position) of this View in DIP screen
// coordinates. // coordinates.
/// ///
cef_rect_t(CEF_CALLBACK* get_bounds_in_screen)(struct _cef_view_t* self); cef_rect_t(CEF_CALLBACK* get_bounds_in_screen)(struct _cef_view_t* self);
/// ///
// Sets the size of this View without changing the position. // Sets the size of this View without changing the position. |size| in parent
// coordinates, or DIP screen coordinates if there is no parent.
/// ///
void(CEF_CALLBACK* set_size)(struct _cef_view_t* self, void(CEF_CALLBACK* set_size)(struct _cef_view_t* self,
const cef_size_t* size); const cef_size_t* size);
/// ///
// Returns the size of this View. // Returns the size of this View in parent coordinates, or DIP screen
// coordinates if there is no parent.
/// ///
cef_size_t(CEF_CALLBACK* get_size)(struct _cef_view_t* self); cef_size_t(CEF_CALLBACK* get_size)(struct _cef_view_t* self);
/// ///
// Sets the position of this View without changing the size. |position| is in // Sets the position of this View without changing the size. |position| is in
// parent coordinates. // parent coordinates, or DIP screen coordinates if there is no parent.
/// ///
void(CEF_CALLBACK* set_position)(struct _cef_view_t* self, void(CEF_CALLBACK* set_position)(struct _cef_view_t* self,
const cef_point_t* position); const cef_point_t* position);
/// ///
// Returns the position of this View. Position is in parent coordinates. // Returns the position of this View. Position is in parent coordinates, or
// DIP screen coordinates if there is no parent.
/// ///
cef_point_t(CEF_CALLBACK* get_position)(struct _cef_view_t* self); cef_point_t(CEF_CALLBACK* get_position)(struct _cef_view_t* self);
/// ///
// Returns the size this View would like to be if enough space is available. // Returns the size this View would like to be if enough space is available.
// Size is in parent coordinates, or DIP screen coordinates if there is no
// parent.
/// ///
cef_size_t(CEF_CALLBACK* get_preferred_size)(struct _cef_view_t* self); cef_size_t(CEF_CALLBACK* get_preferred_size)(struct _cef_view_t* self);
/// ///
// Size this View to its preferred size. // Size this View to its preferred size. Size is in parent coordinates, or DIP
// screen coordinates if there is no parent.
/// ///
void(CEF_CALLBACK* size_to_preferred_size)(struct _cef_view_t* self); void(CEF_CALLBACK* size_to_preferred_size)(struct _cef_view_t* self);
/// ///
// Returns the minimum size for this View. // Returns the minimum size for this View. Size is in parent coordinates, or
// DIP screen coordinates if there is no parent.
/// ///
cef_size_t(CEF_CALLBACK* get_minimum_size)(struct _cef_view_t* self); cef_size_t(CEF_CALLBACK* get_minimum_size)(struct _cef_view_t* self);
/// ///
// Returns the maximum size for this View. // Returns the maximum size for this View. Size is in parent coordinates, or
// DIP screen coordinates if there is no parent.
/// ///
cef_size_t(CEF_CALLBACK* get_maximum_size)(struct _cef_view_t* self); cef_size_t(CEF_CALLBACK* get_maximum_size)(struct _cef_view_t* self);
@@ -327,21 +335,21 @@ typedef struct _cef_view_t {
cef_color_t(CEF_CALLBACK* get_background_color)(struct _cef_view_t* self); cef_color_t(CEF_CALLBACK* get_background_color)(struct _cef_view_t* self);
/// ///
// Convert |point| from this View's coordinate system to that of the screen. // Convert |point| from this View's coordinate system to DIP screen
// This View must belong to a Window when calling this function. Returns true // coordinates. This View must belong to a Window when calling this function.
// (1) if the conversion is successful or false (0) otherwise. Use // Returns true (1) if the conversion is successful or false (0) otherwise.
// cef_display_t::convert_point_to_pixels() after calling this function if // Use cef_display_t::convert_point_to_pixels() after calling this function if
// further conversion to display-specific pixel coordinates is desired. // further conversion to display-specific pixel coordinates is desired.
/// ///
int(CEF_CALLBACK* convert_point_to_screen)(struct _cef_view_t* self, int(CEF_CALLBACK* convert_point_to_screen)(struct _cef_view_t* self,
cef_point_t* point); cef_point_t* point);
/// ///
// Convert |point| to this View's coordinate system from that of the screen. // Convert |point| to this View's coordinate system from DIP screen
// This View must belong to a Window when calling this function. Returns true // coordinates. This View must belong to a Window when calling this function.
// (1) if the conversion is successful or false (0) otherwise. Use // Returns true (1) if the conversion is successful or false (0) otherwise.
// cef_display_t::convert_point_from_pixels() before calling this function if // Use cef_display_t::convert_point_from_pixels() before calling this function
// conversion from display-specific pixel coordinates is necessary. // if conversion from display-specific pixel coordinates is necessary.
/// ///
int(CEF_CALLBACK* convert_point_from_screen)(struct _cef_view_t* self, int(CEF_CALLBACK* convert_point_from_screen)(struct _cef_view_t* self,
cef_point_t* point); cef_point_t* point);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=a0cec778fbaf0b1f5c9b3ef75dc7bbeeba777a44$ // $hash=fee25d300df47c6143b935d0f99d543ea888f55c$
// //
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
@@ -87,6 +87,18 @@ typedef struct _cef_window_delegate_t {
int* is_menu, int* is_menu,
int* can_activate_menu); int* can_activate_menu);
///
// Return the initial bounds for |window| in density independent pixel (DIP)
// coordinates. If this function returns an NULL CefRect then
// get_preferred_size() will be called to retrieve the size, and the window
// will be placed on the screen with origin (0,0). This function can be used
// in combination with cef_view_t::get_bounds_in_screen() to restore the
// previous window bounds.
///
cef_rect_t(CEF_CALLBACK* get_initial_bounds)(
struct _cef_window_delegate_t* self,
struct _cef_window_t* window);
/// ///
// Return true (1) if |window| should be created without a frame or title bar. // Return true (1) if |window| should be created without a frame or title bar.
// The window will be resizable if can_resize() returns true (1). Use // The window will be resizable if can_resize() returns true (1). Use

View File

@@ -29,12 +29,7 @@
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool. If making changes by // This file was generated by the make_api_hash_header.py tool.
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=06d0c1ccfa43926a01cbeb3ec95ff2a001fd0b45$
// //
#ifndef CEF_INCLUDE_API_HASH_H_ #ifndef CEF_INCLUDE_API_HASH_H_
@@ -47,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal // way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash // hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected. // values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "3ad9591f7024619a1e2fd796c7ad51ae3a34abbb" #define CEF_API_HASH_UNIVERSAL "09d3d4f08869644fe3baa7a751de537f3446525b"
#if defined(OS_WIN) #if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "3b8e38ae40c1a930227c6277c39dbc24081ccec1" #define CEF_API_HASH_PLATFORM "3022db6736af26cc38158d38e22f74a51312a5c9"
#elif defined(OS_MACOSX) #elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "4a77f1908fabccdb01a2d3bdbede5ca09fbaa394" #define CEF_API_HASH_PLATFORM "13e2e2451c2320f0d16b35ba53b3295409888dd8"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "434da6be7db70fd90c4265118ac47ace4073c6ae" #define CEF_API_HASH_PLATFORM "d781b815150795b0bce95d72ce967b508c9a04d5"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -35,7 +35,7 @@
#include "include/cef_base.h" #include "include/cef_base.h"
#endif // __cplusplus #endif // __cplusplus
#if defined(OS_MACOSX) && defined(__OBJC__) #if defined(OS_MAC) && defined(__OBJC__)
#ifdef USING_CHROMIUM_INCLUDES #ifdef USING_CHROMIUM_INCLUDES
@@ -105,6 +105,6 @@ class CefScopedSendingEvent {
#endif // __cplusplus #endif // __cplusplus
#endif // defined(OS_MACOSX) && defined(__OBJC__) #endif // defined(OS_MAC) && defined(__OBJC__)
#endif // CEF_INCLUDE_CEF_APPLICATION_MAC_H_ #endif // CEF_INCLUDE_CEF_APPLICATION_MAC_H_

111
include/cef_audio_handler.h Normal file
View File

@@ -0,0 +1,111 @@
// Copyright (c) 2019 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_AUDIO_HANDLER_H_
#define CEF_INCLUDE_CEF_AUDIO_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
///
// Implement this interface to handle audio events.
///
/*--cef(source=client)--*/
class CefAudioHandler : public virtual CefBaseRefCounted {
public:
typedef cef_channel_layout_t ChannelLayout;
///
// Called on the UI thread to allow configuration of audio stream parameters.
// Return true to proceed with audio stream capture, or false to cancel it.
// All members of |params| can optionally be configured here, but they are
// also pre-filled with some sensible defaults.
///
/*--cef()--*/
virtual bool GetAudioParameters(CefRefPtr<CefBrowser> browser,
CefAudioParameters& params) {
return true;
}
///
// Called on a browser audio capture thread when the browser starts
// streaming audio. OnAudioSteamStopped will always be called after
// OnAudioStreamStarted; both methods may be called multiple times
// for the same browser. |params| contains the audio parameters like
// sample rate and channel layout. |channels| is the number of channels.
///
/*--cef()--*/
virtual void OnAudioStreamStarted(CefRefPtr<CefBrowser> browser,
const CefAudioParameters& params,
int channels) = 0;
///
// Called on the audio stream thread when a PCM packet is received for the
// stream. |data| is an array representing the raw PCM data as a floating
// point type, i.e. 4-byte value(s). |frames| is the number of frames in the
// PCM packet. |pts| is the presentation timestamp (in milliseconds since the
// Unix Epoch) and represents the time at which the decompressed packet should
// be presented to the user. Based on |frames| and the |channel_layout| value
// passed to OnAudioStreamStarted you can calculate the size of the |data|
// array in bytes.
///
/*--cef()--*/
virtual void OnAudioStreamPacket(CefRefPtr<CefBrowser> browser,
const float** data,
int frames,
int64 pts) = 0;
///
// Called on the UI thread when the stream has stopped. OnAudioSteamStopped
// will always be called after OnAudioStreamStarted; both methods may be
// called multiple times for the same stream.
///
/*--cef()--*/
virtual void OnAudioStreamStopped(CefRefPtr<CefBrowser> browser) = 0;
///
// Called on the UI or audio stream thread when an error occurred. During the
// stream creation phase this callback will be called on the UI thread while
// in the capturing phase it will be called on the audio stream thread. The
// stream will be stopped immediately.
///
/*--cef()--*/
virtual void OnAudioStreamError(CefRefPtr<CefBrowser> browser,
const CefString& message) = 0;
};
#endif // CEF_INCLUDE_CEF_AUDIO_HANDLER_H_

View File

@@ -40,7 +40,7 @@
#include "include/internal/cef_types_wrappers.h" #include "include/internal/cef_types_wrappers.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "include/internal/cef_win.h" #include "include/internal/cef_win.h"
#elif defined(OS_MACOSX) #elif defined(OS_MAC)
#include "include/internal/cef_mac.h" #include "include/internal/cef_mac.h"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#include "include/internal/cef_linux.h" #include "include/internal/cef_linux.h"

View File

@@ -40,10 +40,12 @@
#include <vector> #include <vector>
#include "include/cef_base.h" #include "include/cef_base.h"
#include "include/cef_devtools_message_observer.h"
#include "include/cef_drag_data.h" #include "include/cef_drag_data.h"
#include "include/cef_frame.h" #include "include/cef_frame.h"
#include "include/cef_image.h" #include "include/cef_image.h"
#include "include/cef_navigation_entry.h" #include "include/cef_navigation_entry.h"
#include "include/cef_registration.h"
#include "include/cef_request_context.h" #include "include/cef_request_context.h"
class CefBrowserHost; class CefBrowserHost;
@@ -517,6 +519,69 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
/*--cef()--*/ /*--cef()--*/
virtual bool HasDevTools() = 0; virtual bool HasDevTools() = 0;
///
// Send a method call message over the DevTools protocol. |message| must be a
// UTF8-encoded JSON dictionary that contains "id" (int), "method" (string)
// and "params" (dictionary, optional) values. See the DevTools protocol
// documentation at https://chromedevtools.github.io/devtools-protocol/ for
// details of supported methods and the expected "params" dictionary contents.
// |message| will be copied if necessary. This method will return true if
// called on the UI thread and the message was successfully submitted for
// validation, otherwise false. Validation will be applied asynchronously and
// any messages that fail due to formatting errors or missing parameters may
// be discarded without notification. Prefer ExecuteDevToolsMethod if a more
// structured approach to message formatting is desired.
//
// Every valid method call will result in an asynchronous method result or
// error message that references the sent message "id". Event messages are
// received while notifications are enabled (for example, between method calls
// for "Page.enable" and "Page.disable"). All received messages will be
// delivered to the observer(s) registered with AddDevToolsMessageObserver.
// See CefDevToolsMessageObserver::OnDevToolsMessage documentation for details
// of received message contents.
//
// Usage of the SendDevToolsMessage, ExecuteDevToolsMethod and
// AddDevToolsMessageObserver methods does not require an active DevTools
// front-end or remote-debugging session. Other active DevTools sessions will
// continue to function independently. However, any modification of global
// browser state by one session may not be reflected in the UI of other
// sessions.
//
// Communication with the DevTools front-end (when displayed) can be logged
// for development purposes by passing the
// `--devtools-protocol-log-file=<path>` command-line flag.
///
/*--cef()--*/
virtual bool SendDevToolsMessage(const void* message,
size_t message_size) = 0;
///
// Execute a method call over the DevTools protocol. This is a more structured
// version of SendDevToolsMessage. |message_id| is an incremental number that
// uniquely identifies the message (pass 0 to have the next number assigned
// automatically based on previous values). |method| is the method name.
// |params| are the method parameters, which may be empty. See the DevTools
// protocol documentation (linked above) for details of supported methods and
// the expected |params| dictionary contents. This method will return the
// assigned message ID if called on the UI thread and the message was
// successfully submitted for validation, otherwise 0. See the
// SendDevToolsMessage documentation for additional usage information.
///
/*--cef(optional_param=params)--*/
virtual int ExecuteDevToolsMethod(int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) = 0;
///
// Add an observer for DevTools protocol messages (method results and events).
// The observer will remain registered until the returned Registration object
// is destroyed. See the SendDevToolsMessage documentation for additional
// usage information.
///
/*--cef()--*/
virtual CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) = 0;
/// ///
// Retrieve a snapshot of current navigation entries as values sent to the // Retrieve a snapshot of current navigation entries as values sent to the
// specified visitor. If |current_only| is true only the current navigation // specified visitor. If |current_only| is true only the current navigation

View File

@@ -68,17 +68,6 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
virtual void OnBeforeChildProcessLaunch( virtual void OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line) {} CefRefPtr<CefCommandLine> command_line) {}
///
// Called on the browser process IO thread after the main thread has been
// created for a new render process. Provides an opportunity to specify extra
// information that will be passed to
// CefRenderProcessHandler::OnRenderThreadCreated() in the render process. Do
// not keep a reference to |extra_info| outside of this method.
///
/*--cef()--*/
virtual void OnRenderProcessThreadCreated(
CefRefPtr<CefListValue> extra_info) {}
/// ///
// Return the handler for printing on Linux. If a print handler is not // Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform. // provided then printing will not be supported on the Linux platform.

View File

@@ -38,6 +38,7 @@
#define CEF_INCLUDE_CEF_CLIENT_H_ #define CEF_INCLUDE_CEF_CLIENT_H_
#pragma once #pragma once
#include "include/cef_audio_handler.h"
#include "include/cef_base.h" #include "include/cef_base.h"
#include "include/cef_context_menu_handler.h" #include "include/cef_context_menu_handler.h"
#include "include/cef_dialog_handler.h" #include "include/cef_dialog_handler.h"
@@ -60,6 +61,12 @@
/*--cef(source=client,no_debugct_check)--*/ /*--cef(source=client,no_debugct_check)--*/
class CefClient : public virtual CefBaseRefCounted { class CefClient : public virtual CefBaseRefCounted {
public: public:
///
// Return the handler for audio rendering events.
///
/*--cef()--*/
virtual CefRefPtr<CefAudioHandler> GetAudioHandler() { return nullptr; }
/// ///
// Return the handler for context menus. If no handler is provided the default // Return the handler for context menus. If no handler is provided the default
// implementation will be used. // implementation will be used.

View File

@@ -0,0 +1,130 @@
// Copyright (c) 2020 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_DEVTOOLS_MESSAGE_OBSERVER_H_
#define CEF_INCLUDE_CEF_DEVTOOLS_MESSAGE_OBSERVER_H_
#pragma once
#include "include/cef_base.h"
class CefBrowser;
///
// Callback interface for CefBrowserHost::AddDevToolsMessageObserver. The
// methods of this class will be called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefDevToolsMessageObserver : public virtual CefBaseRefCounted {
public:
///
// Method that will be called on receipt of a DevTools protocol message.
// |browser| is the originating browser instance. |message| is a UTF8-encoded
// JSON dictionary representing either a method result or an event. |message|
// is only valid for the scope of this callback and should be copied if
// necessary. Return true if the message was handled or false if the message
// should be further processed and passed to the OnDevToolsMethodResult or
// OnDevToolsEvent methods as appropriate.
//
// Method result dictionaries include an "id" (int) value that identifies the
// orginating method call sent from CefBrowserHost::SendDevToolsMessage, and
// optionally either a "result" (dictionary) or "error" (dictionary) value.
// The "error" dictionary will contain "code" (int) and "message" (string)
// values. Event dictionaries include a "method" (string) value and optionally
// a "params" (dictionary) value. See the DevTools protocol documentation at
// https://chromedevtools.github.io/devtools-protocol/ for details of
// supported method calls and the expected "result" or "params" dictionary
// contents. JSON dictionaries can be parsed using the CefParseJSON function
// if desired, however be aware of performance considerations when parsing
// large messages (some of which may exceed 1MB in size).
///
/*--cef()--*/
virtual bool OnDevToolsMessage(CefRefPtr<CefBrowser> browser,
const void* message,
size_t message_size) {
return false;
}
///
// Method that will be called after attempted execution of a DevTools protocol
// method. |browser| is the originating browser instance. |message_id| is the
// "id" value that identifies the originating method call message. If the
// method succeeded |success| will be true and |result| will be the
// UTF8-encoded JSON "result" dictionary value (which may be empty). If the
// method failed |success| will be false and |result| will be the UTF8-encoded
// JSON "error" dictionary value. |result| is only valid for the scope of this
// callback and should be copied if necessary. See the OnDevToolsMessage
// documentation for additional details on |result| contents.
///
/*--cef(optional_param=result)--*/
virtual void OnDevToolsMethodResult(CefRefPtr<CefBrowser> browser,
int message_id,
bool success,
const void* result,
size_t result_size) {}
///
// Method that will be called on receipt of a DevTools protocol event.
// |browser| is the originating browser instance. |method| is the "method"
// value. |params| is the UTF8-encoded JSON "params" dictionary value (which
// may be empty). |params| is only valid for the scope of this callback and
// should be copied if necessary. See the OnDevToolsMessage documentation for
// additional details on |params| contents.
///
/*--cef(optional_param=params)--*/
virtual void OnDevToolsEvent(CefRefPtr<CefBrowser> browser,
const CefString& method,
const void* params,
size_t params_size) {}
///
// Method that will be called when the DevTools agent has attached. |browser|
// is the originating browser instance. This will generally occur in response
// to the first message sent while the agent is detached.
///
/*--cef()--*/
virtual void OnDevToolsAgentAttached(CefRefPtr<CefBrowser> browser) {}
///
// Method that will be called when the DevTools agent has detached. |browser|
// is the originating browser instance. Any method results that were pending
// before the agent became detached will not be delivered, and any active
// event subscriptions will be canceled.
///
/*--cef()--*/
virtual void OnDevToolsAgentDetached(CefRefPtr<CefBrowser> browser) {}
};
#endif // CEF_INCLUDE_CEF_DEVTOOLS_MESSAGE_OBSERVER_H_

320
include/cef_media_router.h Normal file
View File

@@ -0,0 +1,320 @@
// Copyright (c) 2020 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_MEDIA_ROUTER_H_
#define CEF_INCLUDE_CEF_MEDIA_ROUTER_H_
#pragma once
#include <vector>
#include "include/cef_base.h"
#include "include/cef_registration.h"
class CefMediaObserver;
class CefMediaRoute;
class CefMediaRouteCreateCallback;
class CefMediaSink;
class CefMediaSinkDeviceInfoCallback;
class CefMediaSource;
///
// Supports discovery of and communication with media devices on the local
// network via the Cast and DIAL protocols. The methods of this class may be
// called on any browser process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaRouter : public virtual CefBaseRefCounted {
public:
///
// Returns the MediaRouter object associated with the global request context.
// Equivalent to calling
// CefRequestContext::GetGlobalContext()->GetMediaRouter().
///
/*--cef()--*/
static CefRefPtr<CefMediaRouter> GetGlobalMediaRouter();
///
// Add an observer for MediaRouter events. The observer will remain registered
// until the returned Registration object is destroyed.
///
/*--cef()--*/
virtual CefRefPtr<CefRegistration> AddObserver(
CefRefPtr<CefMediaObserver> observer) = 0;
///
// Returns a MediaSource object for the specified media source URN. Supported
// URN schemes include "cast:" and "dial:", and will be already known by the
// client application (e.g. "cast:<appId>?clientId=<clientId>").
///
/*--cef()--*/
virtual CefRefPtr<CefMediaSource> GetSource(const CefString& urn) = 0;
///
// Trigger an asynchronous call to CefMediaObserver::OnSinks on all
// registered observers.
///
/*--cef()--*/
virtual void NotifyCurrentSinks() = 0;
///
// Create a new route between |source| and |sink|. Source and sink must be
// valid, compatible (as reported by CefMediaSink::IsCompatibleWith), and a
// route between them must not already exist. |callback| will be executed
// on success or failure. If route creation succeeds it will also trigger an
// asynchronous call to CefMediaObserver::OnRoutes on all registered
// observers.
///
/*--cef()--*/
virtual void CreateRoute(CefRefPtr<CefMediaSource> source,
CefRefPtr<CefMediaSink> sink,
CefRefPtr<CefMediaRouteCreateCallback> callback) = 0;
///
// Trigger an asynchronous call to CefMediaObserver::OnRoutes on all
// registered observers.
///
/*--cef()--*/
virtual void NotifyCurrentRoutes() = 0;
};
///
// Implemented by the client to observe MediaRouter events and registered via
// CefMediaRouter::AddObserver. The methods of this class will be called on the
// browser process UI thread.
///
/*--cef(source=client)--*/
class CefMediaObserver : public virtual CefBaseRefCounted {
public:
typedef cef_media_route_connection_state_t ConnectionState;
///
// The list of available media sinks has changed or
// CefMediaRouter::NotifyCurrentSinks was called.
///
/*--cef()--*/
virtual void OnSinks(const std::vector<CefRefPtr<CefMediaSink>>& sinks) = 0;
///
// The list of available media routes has changed or
// CefMediaRouter::NotifyCurrentRoutes was called.
///
/*--cef()--*/
virtual void OnRoutes(
const std::vector<CefRefPtr<CefMediaRoute>>& routes) = 0;
///
// The connection state of |route| has changed.
///
/*--cef()--*/
virtual void OnRouteStateChanged(CefRefPtr<CefMediaRoute> route,
ConnectionState state) = 0;
///
// A message was recieved over |route|. |message| is only valid for
// the scope of this callback and should be copied if necessary.
///
/*--cef()--*/
virtual void OnRouteMessageReceived(CefRefPtr<CefMediaRoute> route,
const void* message,
size_t message_size) = 0;
};
///
// Represents the route between a media source and sink. Instances of this
// object are created via CefMediaRouter::CreateRoute and retrieved via
// CefMediaObserver::OnRoutes. Contains the status and metadata of a
// routing operation. The methods of this class may be called on any browser
// process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaRoute : public virtual CefBaseRefCounted {
public:
///
// Returns the ID for this route.
///
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns the source associated with this route.
///
/*--cef()--*/
virtual CefRefPtr<CefMediaSource> GetSource() = 0;
///
// Returns the sink associated with this route.
///
/*--cef()--*/
virtual CefRefPtr<CefMediaSink> GetSink() = 0;
///
// Send a message over this route. |message| will be copied if necessary.
///
/*--cef()--*/
virtual void SendRouteMessage(const void* message, size_t message_size) = 0;
///
// Terminate this route. Will result in an asynchronous call to
// CefMediaObserver::OnRoutes on all registered observers.
///
/*--cef()--*/
virtual void Terminate() = 0;
};
///
// Callback interface for CefMediaRouter::CreateRoute. The methods of this
// class will be called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefMediaRouteCreateCallback : public virtual CefBaseRefCounted {
public:
typedef cef_media_route_create_result_t RouteCreateResult;
///
// Method that will be executed when the route creation has finished. |result|
// will be CEF_MRCR_OK if the route creation succeeded. |error| will be a
// description of the error if the route creation failed. |route| is the
// resulting route, or empty if the route creation failed.
///
/*--cef(optional_param=error,optional_param=route)--*/
virtual void OnMediaRouteCreateFinished(RouteCreateResult result,
const CefString& error,
CefRefPtr<CefMediaRoute> route) = 0;
};
///
// Represents a sink to which media can be routed. Instances of this object are
// retrieved via CefMediaObserver::OnSinks. The methods of this class may
// be called on any browser process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaSink : public virtual CefBaseRefCounted {
public:
typedef cef_media_sink_icon_type_t IconType;
///
// Returns the ID for this sink.
///
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns the name of this sink.
///
/*--cef()--*/
virtual CefString GetName() = 0;
///
// Returns the description of this sink.
///
/*--cef()--*/
virtual CefString GetDescription() = 0;
///
// Returns the icon type for this sink.
///
/*--cef(default_retval=CEF_MSIT_GENERIC)--*/
virtual IconType GetIconType() = 0;
///
// Asynchronously retrieves device info.
///
/*--cef()--*/
virtual void GetDeviceInfo(
CefRefPtr<CefMediaSinkDeviceInfoCallback> callback) = 0;
///
// Returns true if this sink accepts content via Cast.
///
/*--cef()--*/
virtual bool IsCastSink() = 0;
///
// Returns true if this sink accepts content via DIAL.
///
/*--cef()--*/
virtual bool IsDialSink() = 0;
///
// Returns true if this sink is compatible with |source|.
///
/*--cef()--*/
virtual bool IsCompatibleWith(CefRefPtr<CefMediaSource> source) = 0;
};
///
// Callback interface for CefMediaSink::GetDeviceInfo. The methods of this
// class will be called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefMediaSinkDeviceInfoCallback : public virtual CefBaseRefCounted {
public:
///
// Method that will be executed asyncronously once device information has been
// retrieved.
///
/*--cef()--*/
virtual void OnMediaSinkDeviceInfo(
const CefMediaSinkDeviceInfo& device_info) = 0;
};
///
// Represents a source from which media can be routed. Instances of this object
// are retrieved via CefMediaRouter::GetSource. The methods of this class may be
// called on any browser process thread unless otherwise indicated.
///
/*--cef(source=library)--*/
class CefMediaSource : public virtual CefBaseRefCounted {
public:
///
// Returns the ID (media source URN or URL) for this source.
///
/*--cef()--*/
virtual CefString GetId() = 0;
///
// Returns true if this source outputs its content via Cast.
///
/*--cef()--*/
virtual bool IsCastSource() = 0;
///
// Returns true if this source outputs its content via DIAL.
///
/*--cef()--*/
virtual bool IsDialSource() = 0;
};
#endif // CEF_INCLUDE_CEF_MEDIA_ROUTER_H_

View File

@@ -133,6 +133,16 @@ CefString CefURIDecode(const CefString& text,
CefRefPtr<CefValue> CefParseJSON(const CefString& json_string, CefRefPtr<CefValue> CefParseJSON(const CefString& json_string,
cef_json_parser_options_t options); cef_json_parser_options_t options);
///
// Parses the specified UTF8-encoded |json| buffer of size |json_size| and
// returns a dictionary or list representation. If JSON parsing fails this
// method returns NULL.
///
/*--cef(capi_name=cef_parse_json_buffer)--*/
CefRefPtr<CefValue> CefParseJSON(const void* json,
size_t json_size,
cef_json_parser_options_t options);
/// ///
// Parses the specified |json_string| and returns a dictionary or list // Parses the specified |json_string| and returns a dictionary or list
// representation. If JSON parsing fails this method returns NULL and populates // representation. If JSON parsing fails this method returns NULL and populates

View File

@@ -0,0 +1,49 @@
// Copyright (c) 2020 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_REGISTRATION_H_
#define CEF_INCLUDE_CEF_REGISTRATION_H_
#pragma once
#include "include/cef_base.h"
///
// Generic callback interface used for managing the lifespan of a registration.
///
/*--cef(source=library)--*/
class CefRegistration : public virtual CefBaseRefCounted {};
#endif // CEF_INCLUDE_CEF_REGISTRATION_H_

View File

@@ -57,15 +57,6 @@ class CefRenderProcessHandler : public virtual CefBaseRefCounted {
public: public:
typedef cef_navigation_type_t NavigationType; typedef cef_navigation_type_t NavigationType;
///
// Called after the render process main thread has been created. |extra_info|
// is a read-only value originating from
// CefBrowserProcessHandler::OnRenderProcessThreadCreated(). Do not keep a
// reference to |extra_info| outside of this method.
///
/*--cef()--*/
virtual void OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info) {}
/// ///
// Called after WebKit has been initialized. // Called after WebKit has been initialized.
/// ///

View File

@@ -44,6 +44,7 @@
#include "include/cef_cookie.h" #include "include/cef_cookie.h"
#include "include/cef_extension.h" #include "include/cef_extension.h"
#include "include/cef_extension_handler.h" #include "include/cef_extension_handler.h"
#include "include/cef_media_router.h"
#include "include/cef_values.h" #include "include/cef_values.h"
class CefRequestContextHandler; class CefRequestContextHandler;
@@ -361,6 +362,12 @@ class CefRequestContext : public virtual CefBaseRefCounted {
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefExtension> GetExtension( virtual CefRefPtr<CefExtension> GetExtension(
const CefString& extension_id) = 0; const CefString& extension_id) = 0;
///
// Returns the MediaRouter object associated with this context.
///
/*--cef()--*/
virtual CefRefPtr<CefMediaRouter> GetMediaRouter() = 0;
}; };
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_ #endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_

View File

@@ -252,6 +252,13 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
/*--cef()--*/ /*--cef()--*/
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser, virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
TerminationStatus status) {} TerminationStatus status) {}
///
// Called on the browser process UI thread when the window.document object of
// the main frame has been created.
///
/*--cef()--*/
virtual void OnDocumentAvailableInMainFrame(CefRefPtr<CefBrowser> browser) {}
}; };
#endif // CEF_INCLUDE_CEF_REQUEST_HANDLER_H_ #endif // CEF_INCLUDE_CEF_REQUEST_HANDLER_H_

View File

@@ -39,6 +39,7 @@
#pragma once #pragma once
#include "include/cef_base.h" #include "include/cef_base.h"
#include "include/cef_values.h"
/// ///
// Class used for retrieving resources from the resource bundle (*.pak) files // Class used for retrieving resources from the resource bundle (*.pak) files
@@ -67,33 +68,24 @@ class CefResourceBundle : public virtual CefBaseRefCounted {
virtual CefString GetLocalizedString(int string_id) = 0; virtual CefString GetLocalizedString(int string_id) = 0;
/// ///
// Retrieves the contents of the specified scale independent |resource_id|. // Returns a CefBinaryValue containing the decompressed contents of the
// If the value is found then |data| and |data_size| will be populated and // specified scale independent |resource_id| or NULL if not found. Include
// this method will return true. If the value is not found then this method // cef_pack_resources.h for a listing of valid resource ID values.
// will return false. The returned |data| pointer will remain resident in
// memory and should not be freed. Include cef_pack_resources.h for a listing
// of valid resource ID values.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual bool GetDataResource(int resource_id, virtual CefRefPtr<CefBinaryValue> GetDataResource(int resource_id) = 0;
void*& data,
size_t& data_size) = 0;
/// ///
// Retrieves the contents of the specified |resource_id| nearest the scale // Returns a CefBinaryValue containing the decompressed contents of the
// factor |scale_factor|. Use a |scale_factor| value of SCALE_FACTOR_NONE for // specified |resource_id| nearest the scale factor |scale_factor| or NULL if
// scale independent resources or call GetDataResource instead. If the value // not found. Use a |scale_factor| value of SCALE_FACTOR_NONE for scale
// is found then |data| and |data_size| will be populated and this method will // independent resources or call GetDataResource instead.Include
// return true. If the value is not found then this method will return false. // cef_pack_resources.h for a listing of valid resource ID values.
// The returned |data| pointer will remain resident in memory and should not
// be freed. Include cef_pack_resources.h for a listing of valid resource ID
// values.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual bool GetDataResourceForScale(int resource_id, virtual CefRefPtr<CefBinaryValue> GetDataResourceForScale(
ScaleFactor scale_factor, int resource_id,
void*& data, ScaleFactor scale_factor) = 0;
size_t& data_size) = 0;
}; };
#endif // CEF_INCLUDE_CEF_RESOURCE_BUNDLE_H_ #endif // CEF_INCLUDE_CEF_RESOURCE_BUNDLE_H_

View File

@@ -34,7 +34,7 @@
#include "include/base/cef_build.h" #include "include/base/cef_build.h"
#include "include/internal/cef_export.h" #include "include/internal/cef_export.h"
#if defined(OS_MACOSX) #if defined(OS_MAC)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -83,6 +83,6 @@ class CEF_EXPORT CefScopedSandboxContext {
}; };
#endif // __cplusplus #endif // __cplusplus
#endif // defined(OS_MACOSX) #endif // defined(OS_MAC)
#endif // CEF_INCLUDE_CEF_SANDBOX_MAC_H_ #endif // CEF_INCLUDE_CEF_SANDBOX_MAC_H_

View File

@@ -63,20 +63,13 @@ class CefURLRequest : public virtual CefBaseRefCounted {
// Create a new URL request that is not associated with a specific browser or // Create a new URL request that is not associated with a specific browser or
// frame. Use CefFrame::CreateURLRequest instead if you want the request to // frame. Use CefFrame::CreateURLRequest instead if you want the request to
// have this association, in which case it may be handled differently (see // have this association, in which case it may be handled differently (see
// documentation on that method). Requests may originate from the both browser // documentation on that method). A request created with this method may only
// process and the render process. // originate from the browser process, and will behave as follows:
//
// For requests originating from the browser process:
// - It may be intercepted by the client via CefResourceRequestHandler or // - It may be intercepted by the client via CefResourceRequestHandler or
// CefSchemeHandlerFactory. // CefSchemeHandlerFactory.
// - POST data may only contain only a single element of type PDE_TYPE_FILE // - POST data may only contain only a single element of type PDE_TYPE_FILE
// or PDE_TYPE_BYTES. // or PDE_TYPE_BYTES.
// - If |request_context| is empty the global request context will be used. // - If |request_context| is empty the global request context will be used.
// For requests originating from the render process:
// - It cannot be intercepted by the client so only http(s) and blob schemes
// are supported.
// - POST data may only contain a single element of type PDE_TYPE_BYTES.
// - The |request_context| parameter must be NULL.
// //
// The |request| object will be marked as read-only after calling this method. // The |request| object will be marked as read-only after calling this method.
/// ///

View File

@@ -39,7 +39,7 @@
// Bring in platform-specific definitions. // Bring in platform-specific definitions.
#if defined(OS_WIN) #if defined(OS_WIN)
#include "include/internal/cef_types_win.h" #include "include/internal/cef_types_win.h"
#elif defined(OS_MACOSX) #elif defined(OS_MAC)
#include "include/internal/cef_types_mac.h" #include "include/internal/cef_types_mac.h"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#include "include/internal/cef_types_linux.h" #include "include/internal/cef_types_linux.h"
@@ -170,26 +170,35 @@ typedef struct _cef_settings_t {
// will be used. If this value is empty on macOS then a helper executable must // will be used. If this value is empty on macOS then a helper executable must
// exist at "Contents/Frameworks/<app> Helper.app/Contents/MacOS/<app> Helper" // exist at "Contents/Frameworks/<app> Helper.app/Contents/MacOS/<app> Helper"
// in the top-level app bundle. See the comments on CefExecuteProcess() for // in the top-level app bundle. See the comments on CefExecuteProcess() for
// details. Also configurable using the "browser-subprocess-path" command-line // details. If this value is non-empty then it must be an absolute path. Also
// switch. // configurable using the "browser-subprocess-path" command-line switch.
/// ///
cef_string_t browser_subprocess_path; cef_string_t browser_subprocess_path;
/// ///
// The path to the CEF framework directory on macOS. If this value is empty // The path to the CEF framework directory on macOS. If this value is empty
// then the framework must exist at "Contents/Frameworks/Chromium Embedded // then the framework must exist at "Contents/Frameworks/Chromium Embedded
// Framework.framework" in the top-level app bundle. Also configurable using // Framework.framework" in the top-level app bundle. If this value is
// the "framework-dir-path" command-line switch. // non-empty then it must be an absolute path. Also configurable using the
// "framework-dir-path" command-line switch.
/// ///
cef_string_t framework_dir_path; cef_string_t framework_dir_path;
/// ///
// The path to the main bundle on macOS. If this value is empty then it // The path to the main bundle on macOS. If this value is empty then it
// defaults to the top-level app bundle. Also configurable using // defaults to the top-level app bundle. If this value is non-empty then it
// the "main-bundle-path" command-line switch. // must be an absolute path. Also configurable using the "main-bundle-path"
// command-line switch.
/// ///
cef_string_t main_bundle_path; cef_string_t main_bundle_path;
///
// 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;
/// ///
// Set to true (1) to have the browser process message loop run in a separate // Set to true (1) to have the browser process message loop run in a separate
// thread. If false (0) than the CefDoMessageLoopWork() function must be // thread. If false (0) than the CefDoMessageLoopWork() function must be
@@ -227,33 +236,35 @@ typedef struct _cef_settings_t {
/// ///
// The location where data for the global browser cache will be stored on // The location where data for the global browser cache will be stored on
// disk. If non-empty this must be either equal to or a child directory of // disk. If this value is non-empty then it must be an absolute path that is
// CefSettings.root_cache_path. If empty then browsers will be created in // either equal to or a child directory of CefSettings.root_cache_path. If
// "incognito mode" where in-memory caches are used for storage and no data is // this value is empty then browsers will be created in "incognito mode" where
// persisted to disk. HTML5 databases such as localStorage will only persist // in-memory caches are used for storage and no data is persisted to disk.
// across sessions if a cache path is specified. Can be overridden for // HTML5 databases such as localStorage will only persist across sessions if a
// individual CefRequestContext instances via the // cache path is specified. Can be overridden for individual CefRequestContext
// CefRequestContextSettings.cache_path value. // instances via the CefRequestContextSettings.cache_path value.
/// ///
cef_string_t cache_path; cef_string_t cache_path;
/// ///
// The root directory that all CefSettings.cache_path and // The root directory that all CefSettings.cache_path and
// CefRequestContextSettings.cache_path values must have in common. If this // CefRequestContextSettings.cache_path values must have in common. If this
// value is empty and CefSettings.cache_path is non-empty then this value will // value is empty and CefSettings.cache_path is non-empty then it will
// default to the CefSettings.cache_path value. Failure to set this value // default to the CefSettings.cache_path value. If this value is non-empty
// correctly may result in the sandbox blocking read/write access to the // then it must be an absolute path. Failure to set this value correctly may
// cache_path directory. // result in the sandbox blocking read/write access to the cache_path
// directory.
/// ///
cef_string_t root_cache_path; cef_string_t root_cache_path;
/// ///
// The location where user data such as spell checking dictionary files will // The location where user data such as spell checking dictionary files will
// be stored on disk. If empty then the default platform-specific user data // be stored on disk. If this value is empty then the default
// directory will be used ("~/.cef_user_data" directory on Linux, // platform-specific user data directory will be used ("~/.cef_user_data"
// "~/Library/Application Support/CEF/User Data" directory on Mac OS X, // directory on Linux, "~/Library/Application Support/CEF/User Data" directory
// "Local Settings\Application Data\CEF\User Data" directory under the user // on Mac OS X, "Local Settings\Application Data\CEF\User Data" directory
// profile directory on Windows). // under the user profile directory on Windows). If this value is non-empty
// then it must be an absolute path.
/// ///
cef_string_t user_data_path; cef_string_t user_data_path;
@@ -333,16 +344,17 @@ typedef struct _cef_settings_t {
// The fully qualified path for the resources directory. If this value is // The fully qualified path for the resources directory. If this value is
// empty the cef.pak and/or devtools_resources.pak files must be located in // empty the cef.pak and/or devtools_resources.pak files must be located in
// the module directory on Windows/Linux or the app bundle Resources directory // the module directory on Windows/Linux or the app bundle Resources directory
// on Mac OS X. Also configurable using the "resources-dir-path" command-line // on Mac OS X. If this value is non-empty then it must be an absolute path.
// switch. // Also configurable using the "resources-dir-path" command-line switch.
/// ///
cef_string_t resources_dir_path; cef_string_t resources_dir_path;
/// ///
// The fully qualified path for the locales directory. If this value is empty // The fully qualified path for the locales directory. If this value is empty
// the locales directory must be located in the module directory. This value // the locales directory must be located in the module directory. If this
// is ignored on Mac OS X where pack files are always loaded from the app // value is non-empty then it must be an absolute path. This value is ignored
// bundle Resources directory. Also configurable using the "locales-dir-path" // on Mac OS X where pack files are always loaded from the app bundle
// Resources directory. Also configurable using the "locales-dir-path"
// command-line switch. // command-line switch.
/// ///
cef_string_t locales_dir_path; cef_string_t locales_dir_path;
@@ -428,13 +440,13 @@ typedef struct _cef_request_context_settings_t {
/// ///
// The location where cache data for this request context will be stored on // The location where cache data for this request context will be stored on
// disk. If non-empty this must be either equal to or a child directory of // disk. If this value is non-empty then it must be an absolute path that is
// CefSettings.root_cache_path. If empty then browsers will be created in // either equal to or a child directory of CefSettings.root_cache_path. If
// "incognito mode" where in-memory caches are used for storage and no data is // this value is empty then browsers will be created in "incognito mode" where
// persisted to disk. HTML5 databases such as localStorage will only persist // in-memory caches are used for storage and no data is persisted to disk.
// across sessions if a cache path is specified. To share the global browser // HTML5 databases such as localStorage will only persist across sessions if a
// cache and related configuration set this value to match the // cache path is specified. To share the global browser cache and related
// CefSettings.cache_path value. // configuration set this value to match the CefSettings.cache_path value.
/// ///
cef_string_t cache_path; cef_string_t cache_path;
@@ -725,8 +737,32 @@ typedef struct _cef_urlparts_t {
// Query string component (i.e., everything following the '?'). // Query string component (i.e., everything following the '?').
/// ///
cef_string_t query; cef_string_t query;
///
// Fragment (hash) identifier component (i.e., the string following the '#').
///
cef_string_t fragment;
} cef_urlparts_t; } cef_urlparts_t;
///
// Cookie priority values.
///
typedef enum {
CEF_COOKIE_PRIORITY_LOW = -1,
CEF_COOKIE_PRIORITY_MEDIUM = 0,
CEF_COOKIE_PRIORITY_HIGH = 1,
} cef_cookie_priority_t;
///
// Cookie same site values.
///
typedef enum {
CEF_COOKIE_SAME_SITE_UNSPECIFIED,
CEF_COOKIE_SAME_SITE_NO_RESTRICTION,
CEF_COOKIE_SAME_SITE_LAX_MODE,
CEF_COOKIE_SAME_SITE_STRICT_MODE,
} cef_cookie_same_site_t;
/// ///
// Cookie information. // Cookie information.
/// ///
@@ -781,6 +817,16 @@ typedef struct _cef_cookie_t {
/// ///
int has_expires; int has_expires;
cef_time_t expires; cef_time_t expires;
///
// Same site.
///
cef_cookie_same_site_t same_site;
///
// Priority.
///
cef_cookie_priority_t priority;
} cef_cookie_t; } cef_cookie_t;
/// ///
@@ -1433,7 +1479,7 @@ typedef enum {
/// ///
// The main thread in the renderer. Used for all WebKit and V8 interaction. // The main thread in the renderer. Used for all WebKit and V8 interaction.
// Tasks may be posted to this thread after // Tasks may be posted to this thread after
// CefRenderProcessHandler::OnRenderThreadCreated but are not guaranteed to // CefRenderProcessHandler::OnWebKitInitialized but are not guaranteed to
// run before sub-process termination (sub-processes may be killed at any time // run before sub-process termination (sub-processes may be killed at any time
// without warning). // without warning).
/// ///
@@ -1775,6 +1821,7 @@ typedef enum {
EVENTFLAG_IS_KEY_PAD = 1 << 9, EVENTFLAG_IS_KEY_PAD = 1 << 9,
EVENTFLAG_IS_LEFT = 1 << 10, EVENTFLAG_IS_LEFT = 1 << 10,
EVENTFLAG_IS_RIGHT = 1 << 11, EVENTFLAG_IS_RIGHT = 1 << 11,
EVENTFLAG_ALTGR_DOWN = 1 << 12,
} cef_event_flags_t; } cef_event_flags_t;
/// ///
@@ -2232,7 +2279,13 @@ typedef enum {
CT_ZOOMOUT, CT_ZOOMOUT,
CT_GRAB, CT_GRAB,
CT_GRABBING, CT_GRABBING,
CT_MIDDLE_PANNING_VERTICAL,
CT_MIDDLE_PANNING_HORIZONTAL,
CT_CUSTOM, CT_CUSTOM,
CT_DND_NONE,
CT_DND_MOVE,
CT_DND_COPY,
CT_DND_LINK,
} cef_cursor_type_t; } cef_cursor_type_t;
/// ///
@@ -2292,21 +2345,10 @@ typedef enum {
/// ///
UU_URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS = 1 << 3, UU_URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS = 1 << 3,
///
// Unescapes characters that can be used in spoofing attempts (such as LOCK)
// and control characters (such as BiDi control characters and %01). This
// INCLUDES NULLs. This is used for rare cases such as data: URL decoding
// where the result is binary data.
//
// DO NOT use UU_SPOOFING_AND_CONTROL_CHARS if the URL is going to be
// displayed in the UI for security reasons.
///
UU_SPOOFING_AND_CONTROL_CHARS = 1 << 4,
/// ///
// URL queries use "+" for space. This flag controls that replacement. // URL queries use "+" for space. This flag controls that replacement.
/// ///
UU_REPLACE_PLUS_WITH_SPACE = 1 << 5, UU_REPLACE_PLUS_WITH_SPACE = 1 << 4,
} cef_uri_unescape_rule_t; } cef_uri_unescape_rule_t;
/// ///
@@ -2429,13 +2471,13 @@ typedef struct _cef_pdf_print_settings_t {
int scale_factor; int scale_factor;
/// ///
// Margins in millimeters. Only used if |margin_type| is set to // Margins in points. Only used if |margin_type| is set to
// PDF_PRINT_MARGIN_CUSTOM. // PDF_PRINT_MARGIN_CUSTOM.
/// ///
double margin_top; int margin_top;
double margin_right; int margin_right;
double margin_bottom; int margin_bottom;
double margin_left; int margin_left;
/// ///
// Margin type. // Margin type.
@@ -2926,6 +2968,16 @@ typedef enum {
CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED, CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED,
} cef_cdm_registration_error_t; } cef_cdm_registration_error_t;
///
// Composition underline style.
///
typedef enum {
CEF_CUS_SOLID,
CEF_CUS_DOT,
CEF_CUS_DASH,
CEF_CUS_NONE,
} cef_composition_underline_style_t;
/// ///
// Structure representing IME composition underline information. This is a thin // Structure representing IME composition underline information. This is a thin
// wrapper around Blink's WebCompositionUnderline class and should be kept in // wrapper around Blink's WebCompositionUnderline class and should be kept in
@@ -2951,8 +3003,211 @@ typedef struct _cef_composition_underline_t {
// Set to true (1) for thick underline. // Set to true (1) for thick underline.
/// ///
int thick; int thick;
///
// Style.
///
cef_composition_underline_style_t style;
} cef_composition_underline_t; } cef_composition_underline_t;
///
// Enumerates the various representations of the ordering of audio channels.
// Must be kept synchronized with media::ChannelLayout from Chromium.
// See media\base\channel_layout.h
///
typedef enum {
CEF_CHANNEL_LAYOUT_NONE = 0,
CEF_CHANNEL_LAYOUT_UNSUPPORTED = 1,
// Front C
CEF_CHANNEL_LAYOUT_MONO = 2,
// Front L, Front R
CEF_CHANNEL_LAYOUT_STEREO = 3,
// Front L, Front R, Back C
CEF_CHANNEL_LAYOUT_2_1 = 4,
// Front L, Front R, Front C
CEF_CHANNEL_LAYOUT_SURROUND = 5,
// Front L, Front R, Front C, Back C
CEF_CHANNEL_LAYOUT_4_0 = 6,
// Front L, Front R, Side L, Side R
CEF_CHANNEL_LAYOUT_2_2 = 7,
// Front L, Front R, Back L, Back R
CEF_CHANNEL_LAYOUT_QUAD = 8,
// Front L, Front R, Front C, Side L, Side R
CEF_CHANNEL_LAYOUT_5_0 = 9,
// Front L, Front R, Front C, LFE, Side L, Side R
CEF_CHANNEL_LAYOUT_5_1 = 10,
// Front L, Front R, Front C, Back L, Back R
CEF_CHANNEL_LAYOUT_5_0_BACK = 11,
// Front L, Front R, Front C, LFE, Back L, Back R
CEF_CHANNEL_LAYOUT_5_1_BACK = 12,
// Front L, Front R, Front C, Side L, Side R, Back L, Back R
CEF_CHANNEL_LAYOUT_7_0 = 13,
// Front L, Front R, Front C, LFE, Side L, Side R, Back L, Back R
CEF_CHANNEL_LAYOUT_7_1 = 14,
// Front L, Front R, Front C, LFE, Side L, Side R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_7_1_WIDE = 15,
// Stereo L, Stereo R
CEF_CHANNEL_LAYOUT_STEREO_DOWNMIX = 16,
// Stereo L, Stereo R, LFE
CEF_CHANNEL_LAYOUT_2POINT1 = 17,
// Stereo L, Stereo R, Front C, LFE
CEF_CHANNEL_LAYOUT_3_1 = 18,
// Stereo L, Stereo R, Front C, Rear C, LFE
CEF_CHANNEL_LAYOUT_4_1 = 19,
// Stereo L, Stereo R, Front C, Side L, Side R, Back C
CEF_CHANNEL_LAYOUT_6_0 = 20,
// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_6_0_FRONT = 21,
// Stereo L, Stereo R, Front C, Rear L, Rear R, Rear C
CEF_CHANNEL_LAYOUT_HEXAGONAL = 22,
// Stereo L, Stereo R, Front C, LFE, Side L, Side R, Rear Center
CEF_CHANNEL_LAYOUT_6_1 = 23,
// Stereo L, Stereo R, Front C, LFE, Back L, Back R, Rear Center
CEF_CHANNEL_LAYOUT_6_1_BACK = 24,
// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE
CEF_CHANNEL_LAYOUT_6_1_FRONT = 25,
// Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_7_0_FRONT = 26,
// Front L, Front R, Front C, LFE, Back L, Back R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_7_1_WIDE_BACK = 27,
// Front L, Front R, Front C, Side L, Side R, Rear L, Back R, Back C.
CEF_CHANNEL_LAYOUT_OCTAGONAL = 28,
// Channels are not explicitly mapped to speakers.
CEF_CHANNEL_LAYOUT_DISCRETE = 29,
// Front L, Front R, Front C. Front C contains the keyboard mic audio. This
// layout is only intended for input for WebRTC. The Front C channel
// is stripped away in the WebRTC audio input pipeline and never seen outside
// of that.
CEF_CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC = 30,
// Front L, Front R, Side L, Side R, LFE
CEF_CHANNEL_LAYOUT_4_1_QUAD_SIDE = 31,
// Actual channel layout is specified in the bitstream and the actual channel
// count is unknown at Chromium media pipeline level (useful for audio
// pass-through mode).
CEF_CHANNEL_LAYOUT_BITSTREAM = 32,
// Max value, must always equal the largest entry ever logged.
CEF_CHANNEL_LAYOUT_MAX = CEF_CHANNEL_LAYOUT_BITSTREAM
} cef_channel_layout_t;
///
// Structure representing the audio parameters for setting up the audio handler.
///
typedef struct _cef_audio_parameters_t {
///
// Layout of the audio channels
///
cef_channel_layout_t channel_layout;
///
// Sample rate
//
int sample_rate;
///
// Number of frames per buffer
///
int frames_per_buffer;
} cef_audio_parameters_t;
///
// Result codes for CefMediaRouter::CreateRoute. Should be kept in sync with
// Chromium's media_router::RouteRequestResult::ResultCode type.
///
typedef enum {
CEF_MRCR_UNKNOWN_ERROR = 0,
CEF_MRCR_OK = 1,
CEF_MRCR_TIMED_OUT = 2,
CEF_MRCR_ROUTE_NOT_FOUND = 3,
CEF_MRCR_SINK_NOT_FOUND = 4,
CEF_MRCR_INVALID_ORIGIN = 5,
CEF_MRCR_NO_SUPPORTED_PROVIDER = 7,
CEF_MRCR_CANCELLED = 8,
CEF_MRCR_ROUTE_ALREADY_EXISTS = 9,
CEF_MRCR_TOTAL_COUNT = 11 // The total number of values.
} cef_media_route_create_result_t;
///
// Connection state for a MediaRoute object.
///
typedef enum {
CEF_MRCS_UNKNOWN,
CEF_MRCS_CONNECTING,
CEF_MRCS_CONNECTED,
CEF_MRCS_CLOSED,
CEF_MRCS_TERMINATED,
} cef_media_route_connection_state_t;
///
// Icon types for a MediaSink object. Should be kept in sync with Chromium's
// media_router::SinkIconType type.
///
typedef enum {
CEF_MSIT_CAST,
CEF_MSIT_CAST_AUDIO_GROUP,
CEF_MSIT_CAST_AUDIO,
CEF_MSIT_MEETING,
CEF_MSIT_HANGOUT,
CEF_MSIT_EDUCATION,
CEF_MSIT_WIRED_DISPLAY,
CEF_MSIT_GENERIC,
CEF_MSIT_TOTAL_COUNT, // The total number of values.
} cef_media_sink_icon_type_t;
///
// Device information for a MediaSink object.
///
typedef struct _cef_media_sink_device_info_t {
cef_string_t ip_address;
int port;
cef_string_t model_name;
} cef_media_sink_device_info_t;
///
// Represents commands available to TextField.
///
typedef enum {
CEF_TFC_CUT = 1,
CEF_TFC_COPY,
CEF_TFC_PASTE,
CEF_TFC_UNDO,
CEF_TFC_DELETE,
CEF_TFC_SELECT_ALL,
} cef_text_field_commands_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -33,7 +33,7 @@
#include "include/base/cef_build.h" #include "include/base/cef_build.h"
#if defined(OS_MACOSX) #if defined(OS_MAC)
#include "include/internal/cef_string.h" #include "include/internal/cef_string.h"
// Handle types. // Handle types.
@@ -137,6 +137,6 @@ typedef struct _cef_window_info_t {
} }
#endif #endif
#endif // OS_MACOSX #endif // OS_MAC
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_ #endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_

View File

@@ -569,6 +569,7 @@ struct CefSettingsTraits {
&target->framework_dir_path, copy); &target->framework_dir_path, copy);
cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length, cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length,
&target->main_bundle_path, copy); &target->main_bundle_path, copy);
target->chrome_runtime = src->chrome_runtime;
target->multi_threaded_message_loop = src->multi_threaded_message_loop; target->multi_threaded_message_loop = src->multi_threaded_message_loop;
target->external_message_pump = src->external_message_pump; target->external_message_pump = src->external_message_pump;
target->windowless_rendering_enabled = src->windowless_rendering_enabled; target->windowless_rendering_enabled = src->windowless_rendering_enabled;
@@ -743,6 +744,7 @@ struct CefURLPartsTraits {
cef_string_clear(&s->origin); cef_string_clear(&s->origin);
cef_string_clear(&s->path); cef_string_clear(&s->path);
cef_string_clear(&s->query); cef_string_clear(&s->query);
cef_string_clear(&s->fragment);
} }
static inline void set(const struct_type* src, static inline void set(const struct_type* src,
@@ -759,6 +761,8 @@ struct CefURLPartsTraits {
cef_string_set(src->origin.str, src->origin.length, &target->origin, copy); cef_string_set(src->origin.str, src->origin.length, &target->origin, copy);
cef_string_set(src->path.str, src->path.length, &target->path, copy); cef_string_set(src->path.str, src->path.length, &target->path, copy);
cef_string_set(src->query.str, src->query.length, &target->query, copy); cef_string_set(src->query.str, src->query.length, &target->query, copy);
cef_string_set(src->fragment.str, src->fragment.length, &target->fragment,
copy);
} }
}; };
@@ -848,6 +852,8 @@ struct CefCookieTraits {
target->last_access = src->last_access; target->last_access = src->last_access;
target->has_expires = src->has_expires; target->has_expires = src->has_expires;
target->expires = src->expires; target->expires = src->expires;
target->same_site = src->same_site;
target->priority = src->priority;
} }
}; };
@@ -866,10 +872,7 @@ struct CefCursorInfoTraits {
static inline void set(const struct_type* src, static inline void set(const struct_type* src,
struct_type* target, struct_type* target,
bool copy) { bool copy) {
target->hotspot = src->hotspot; *target = *src;
target->image_scale_factor = src->image_scale_factor;
target->buffer = src->buffer;
target->size = src->size;
} }
}; };
@@ -942,23 +945,14 @@ typedef CefStructBase<CefBoxLayoutSettingsTraits> CefBoxLayoutSettings;
struct CefCompositionUnderlineTraits { struct CefCompositionUnderlineTraits {
typedef cef_composition_underline_t struct_type; typedef cef_composition_underline_t struct_type;
static inline void init(struct_type* s) { static inline void init(struct_type* s) {}
s->range.from = 0;
s->range.to = 0;
s->color = 0;
s->background_color = 0;
s->thick = 0;
}
static inline void clear(struct_type* s) {} static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, static inline void set(const struct_type* src,
struct_type* target, struct_type* target,
bool copy) { bool copy) {
target->range = src->range; *target = *src;
target->color = src->color;
target->background_color = src->background_color;
target->thick = src->thick;
} }
}; };
@@ -967,4 +961,49 @@ struct CefCompositionUnderlineTraits {
/// ///
typedef CefStructBase<CefCompositionUnderlineTraits> CefCompositionUnderline; typedef CefStructBase<CefCompositionUnderlineTraits> CefCompositionUnderline;
struct CefAudioParametersTraits {
typedef cef_audio_parameters_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src,
struct_type* target,
bool copy) {
*target = *src;
}
};
///
// Class representing CefAudioParameters settings
///
typedef CefStructBase<CefAudioParametersTraits> CefAudioParameters;
struct CefMediaSinkDeviceInfoTraits {
typedef cef_media_sink_device_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->ip_address);
cef_string_clear(&s->model_name);
}
static inline void set(const struct_type* src,
struct_type* target,
bool copy) {
cef_string_set(src->ip_address.str, src->ip_address.length,
&target->ip_address, copy);
target->port = src->port;
cef_string_set(src->model_name.str, src->model_name.length,
&target->model_name, copy);
}
};
///
// Class representing MediaSink device info.
///
typedef CefStructBase<CefMediaSinkDeviceInfoTraits> CefMediaSinkDeviceInfo;
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_ #endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_

View File

@@ -46,9 +46,9 @@
// This class typically, but not always, corresponds to a physical display // This class typically, but not always, corresponds to a physical display
// connected to the system. A fake Display may exist on a headless system, or a // connected to the system. A fake Display may exist on a headless system, or a
// Display may correspond to a remote, virtual display. All size and position // Display may correspond to a remote, virtual display. All size and position
// values are in density independent pixels (DIP) unless otherwise indicated. // values are in density independent pixel (DIP) coordinates unless otherwise
// Methods must be called on the browser process UI thread unless otherwise // indicated. Methods must be called on the browser process UI thread unless
// indicated. // otherwise indicated.
/// ///
/*--cef(source=library)--*/ /*--cef(source=library)--*/
class CefDisplay : public CefBaseRefCounted { class CefDisplay : public CefBaseRefCounted {
@@ -61,8 +61,7 @@ class CefDisplay : public CefBaseRefCounted {
/// ///
// Returns the Display nearest |point|. Set |input_pixel_coords| to true if // Returns the Display nearest |point|. Set |input_pixel_coords| to true if
// |point| is in pixel coordinates instead of density independent pixels // |point| is in pixel screen coordinates instead of DIP screen coordinates.
// (DIP).
/// ///
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefDisplay> GetDisplayNearestPoint(const CefPoint& point, static CefRefPtr<CefDisplay> GetDisplayNearestPoint(const CefPoint& point,
@@ -70,8 +69,8 @@ class CefDisplay : public CefBaseRefCounted {
/// ///
// Returns the Display that most closely intersects |bounds|. Set // Returns the Display that most closely intersects |bounds|. Set
// |input_pixel_coords| to true if |bounds| is in pixel coordinates instead of // |input_pixel_coords| to true if |bounds| is in pixel screen coordinates
// density independent pixels (DIP). // instead of DIP screen coordinates.
/// ///
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefDisplay> GetDisplayMatchingBounds( static CefRefPtr<CefDisplay> GetDisplayMatchingBounds(
@@ -108,28 +107,29 @@ class CefDisplay : public CefBaseRefCounted {
virtual float GetDeviceScaleFactor() = 0; virtual float GetDeviceScaleFactor() = 0;
/// ///
// Convert |point| from density independent pixels (DIP) to pixel coordinates // Convert |point| from DIP coordinates to pixel coordinates using this
// using this Display's device scale factor. // Display's device scale factor.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void ConvertPointToPixels(CefPoint& point) = 0; virtual void ConvertPointToPixels(CefPoint& point) = 0;
/// ///
// Convert |point| from pixel coordinates to density independent pixels (DIP) // Convert |point| from pixel coordinates to DIP coordinates using this
// using this Display's device scale factor. // Display's device scale factor.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void ConvertPointFromPixels(CefPoint& point) = 0; virtual void ConvertPointFromPixels(CefPoint& point) = 0;
/// ///
// Returns this Display's bounds. This is the full size of the display. // Returns this Display's bounds in DIP screen coordinates. This is the full
// size of the display.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRect GetBounds() = 0; virtual CefRect GetBounds() = 0;
/// ///
// Returns this Display's work area. This excludes areas of the display that // Returns this Display's work area in DIP screen coordinates. This excludes
// are occupied for window manager toolbars, etc. // areas of the display that are occupied with window manager toolbars, etc.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRect GetWorkArea() = 0; virtual CefRect GetWorkArea() = 0;

View File

@@ -224,16 +224,13 @@ class CefTextfield : public CefView {
// enabled. See additional comments on ExecuteCommand(). // enabled. See additional comments on ExecuteCommand().
/// ///
/*--cef()--*/ /*--cef()--*/
virtual bool IsCommandEnabled(int command_id) = 0; virtual bool IsCommandEnabled(cef_text_field_commands_t command_id) = 0;
/// ///
// Performs the action associated with the specified command id. Valid values // Performs the action associated with the specified command id.
// include IDS_APP_UNDO, IDS_APP_REDO, IDS_APP_CUT, IDS_APP_COPY,
// IDS_APP_PASTE, IDS_APP_DELETE, IDS_APP_SELECT_ALL, IDS_DELETE_* and
// IDS_MOVE_*. See include/cef_pack_strings.h for definitions.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void ExecuteCommand(int command_id) = 0; virtual void ExecuteCommand(cef_text_field_commands_t command_id) = 0;
/// ///
// Clears Edit history. // Clears Edit history.

View File

@@ -174,71 +174,79 @@ class CefView : public CefBaseRefCounted {
virtual CefRefPtr<CefView> GetViewForID(int id) = 0; virtual CefRefPtr<CefView> GetViewForID(int id) = 0;
/// ///
// Sets the bounds (size and position) of this View. Position is in parent // Sets the bounds (size and position) of this View. |bounds| is in parent
// coordinates. // coordinates, or DIP screen coordinates if there is no parent.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void SetBounds(const CefRect& bounds) = 0; virtual void SetBounds(const CefRect& bounds) = 0;
/// ///
// Returns the bounds (size and position) of this View. Position is in parent // Returns the bounds (size and position) of this View in parent coordinates,
// coordinates. // or DIP screen coordinates if there is no parent.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRect GetBounds() = 0; virtual CefRect GetBounds() = 0;
/// ///
// Returns the bounds (size and position) of this View. Position is in screen // Returns the bounds (size and position) of this View in DIP screen
// coordinates. // coordinates.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRect GetBoundsInScreen() = 0; virtual CefRect GetBoundsInScreen() = 0;
/// ///
// Sets the size of this View without changing the position. // Sets the size of this View without changing the position. |size| in
// parent coordinates, or DIP screen coordinates if there is no parent.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void SetSize(const CefSize& size) = 0; virtual void SetSize(const CefSize& size) = 0;
/// ///
// Returns the size of this View. // Returns the size of this View in parent coordinates, or DIP screen
// coordinates if there is no parent.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefSize GetSize() = 0; virtual CefSize GetSize() = 0;
/// ///
// Sets the position of this View without changing the size. |position| is in // Sets the position of this View without changing the size. |position| is in
// parent coordinates. // parent coordinates, or DIP screen coordinates if there is no parent.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void SetPosition(const CefPoint& position) = 0; virtual void SetPosition(const CefPoint& position) = 0;
/// ///
// Returns the position of this View. Position is in parent coordinates. // Returns the position of this View. Position is in parent coordinates, or
// DIP screen coordinates if there is no parent.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefPoint GetPosition() = 0; virtual CefPoint GetPosition() = 0;
/// ///
// Returns the size this View would like to be if enough space is available. // Returns the size this View would like to be if enough space is available.
// Size is in parent coordinates, or DIP screen coordinates if there is no
// parent.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefSize GetPreferredSize() = 0; virtual CefSize GetPreferredSize() = 0;
/// ///
// Size this View to its preferred size. // Size this View to its preferred size. Size is in parent coordinates, or
// DIP screen coordinates if there is no parent.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void SizeToPreferredSize() = 0; virtual void SizeToPreferredSize() = 0;
/// ///
// Returns the minimum size for this View. // Returns the minimum size for this View. Size is in parent coordinates, or
// DIP screen coordinates if there is no parent.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefSize GetMinimumSize() = 0; virtual CefSize GetMinimumSize() = 0;
/// ///
// Returns the maximum size for this View. // Returns the maximum size for this View. Size is in parent coordinates, or
// DIP screen coordinates if there is no parent.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefSize GetMaximumSize() = 0; virtual CefSize GetMaximumSize() = 0;
@@ -345,9 +353,9 @@ class CefView : public CefBaseRefCounted {
virtual cef_color_t GetBackgroundColor() = 0; virtual cef_color_t GetBackgroundColor() = 0;
/// ///
// Convert |point| from this View's coordinate system to that of the screen. // Convert |point| from this View's coordinate system to DIP screen
// This View must belong to a Window when calling this method. Returns true // coordinates. This View must belong to a Window when calling this method.
// if the conversion is successful or false otherwise. Use // Returns true if the conversion is successful or false otherwise. Use
// CefDisplay::ConvertPointToPixels() after calling this method if further // CefDisplay::ConvertPointToPixels() after calling this method if further
// conversion to display-specific pixel coordinates is desired. // conversion to display-specific pixel coordinates is desired.
/// ///
@@ -355,9 +363,9 @@ class CefView : public CefBaseRefCounted {
virtual bool ConvertPointToScreen(CefPoint& point) = 0; virtual bool ConvertPointToScreen(CefPoint& point) = 0;
/// ///
// Convert |point| to this View's coordinate system from that of the screen. // Convert |point| to this View's coordinate system from DIP screen
// This View must belong to a Window when calling this method. Returns true if // coordinates. This View must belong to a Window when calling this method.
// the conversion is successful or false otherwise. Use // Returns true if the conversion is successful or false otherwise. Use
// CefDisplay::ConvertPointFromPixels() before calling this method if // CefDisplay::ConvertPointFromPixels() before calling this method if
// conversion from display-specific pixel coordinates is necessary. // conversion from display-specific pixel coordinates is necessary.
/// ///

View File

@@ -78,6 +78,19 @@ class CefWindowDelegate : public CefPanelDelegate {
return nullptr; return nullptr;
} }
///
// Return the initial bounds for |window| in density independent pixel (DIP)
// coordinates. If this method returns an empty CefRect then
// GetPreferredSize() will be called to retrieve the size, and the window will
// be placed on the screen with origin (0,0). This method can be used in
// combination with CefView::GetBoundsInScreen() to restore the previous
// window bounds.
///
/*--cef()--*/
virtual CefRect GetInitialBounds(CefRefPtr<CefWindow> window) {
return CefRect();
}
/// ///
// Return true if |window| should be created without a frame or title bar. The // Return true if |window| should be created without a frame or title bar. The
// window will be resizable if CanResize() returns true. Use // window will be resizable if CanResize() returns true. Use

View File

@@ -89,6 +89,32 @@ struct CefDeleteOnIOThread : public CefDeleteOnThread<TID_IO> {};
struct CefDeleteOnFileThread : public CefDeleteOnThread<TID_FILE> {}; struct CefDeleteOnFileThread : public CefDeleteOnThread<TID_FILE> {};
struct CefDeleteOnRendererThread : public CefDeleteOnThread<TID_RENDERER> {}; struct CefDeleteOnRendererThread : public CefDeleteOnThread<TID_RENDERER> {};
// Same as IMPLEMENT_REFCOUNTING() but using the specified Destructor.
#define IMPLEMENT_REFCOUNTING_EX(ClassName, Destructor) \
public: \
void AddRef() const OVERRIDE { ref_count_.AddRef(); } \
bool Release() const OVERRIDE { \
if (ref_count_.Release()) { \
Destructor::Destruct(this); \
return true; \
} \
return false; \
} \
bool HasOneRef() const OVERRIDE { return ref_count_.HasOneRef(); } \
bool HasAtLeastOneRef() const OVERRIDE { \
return ref_count_.HasAtLeastOneRef(); \
} \
\
private: \
CefRefCount ref_count_
#define IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(ClassName) \
IMPLEMENT_REFCOUNTING_EX(ClassName, CefDeleteOnUIThread)
#define IMPLEMENT_REFCOUNTING_DELETE_ON_IOT(ClassName) \
IMPLEMENT_REFCOUNTING_EX(ClassName, CefDeleteOnIOThread)
/// ///
// Helper class to manage a scoped copy of |argv|. // Helper class to manage a scoped copy of |argv|.
/// ///

View File

@@ -56,7 +56,7 @@ int cef_unload_library();
#ifdef __cplusplus #ifdef __cplusplus
} }
#if defined(OS_MACOSX) #if defined(OS_MAC)
/// ///
// Scoped helper for loading and unloading the CEF framework library at // Scoped helper for loading and unloading the CEF framework library at
@@ -122,7 +122,7 @@ class CefScopedLibraryLoader {
DISALLOW_COPY_AND_ASSIGN(CefScopedLibraryLoader); DISALLOW_COPY_AND_ASSIGN(CefScopedLibraryLoader);
}; };
#endif // defined(OS_MACOSX) #endif // defined(OS_MAC)
#endif // __cplusplus #endif // __cplusplus
#endif // CEF_INCLUDE_WRAPPER_CEF_LIBRARY_LOADER_H_ #endif // CEF_INCLUDE_WRAPPER_CEF_LIBRARY_LOADER_H_

View File

@@ -0,0 +1,456 @@
// 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 "libcef/browser/alloy/alloy_browser_context.h"
#include <map>
#include <utility>
#include "libcef/browser/download_manager_delegate.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/ssl_host_state_delegate.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h"
#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 "chrome/browser/font_family_cache.h"
#include "chrome/browser/media/media_device_id_salt.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#include "chrome/browser/profiles/profile_key.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/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()); }
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.
typedef std::map<const content::BrowserContext*,
std::unique_ptr<visitedlink::VisitedLinkEventListener>>
ListenerMap;
ListenerMap listener_map_;
DISALLOW_COPY_AND_ASSIGN(CefVisitedLinkListener);
};
AlloyBrowserContext::AlloyBrowserContext(
const CefRequestContextSettings& settings)
: CefBrowserContext(settings) {}
AlloyBrowserContext::~AlloyBrowserContext() {
if (resource_context_) {
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
resource_context_.release());
}
}
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_.reset(new 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_.reset(new 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);
media_device_id_salt_ = new MediaDeviceIDSalt(pref_service);
}
void AlloyBrowserContext::Shutdown() {
CefBrowserContext::Shutdown();
// Send notifications to clean up objects associated with this Profile.
MaybeSendDestroyedNotification();
ChromePluginServiceFilter::GetInstance()->UnregisterProfile(this);
// 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());
extension_system()->LoadExtension(base::WrapUnique(value_impl->CopyValue()),
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);
}
bool AlloyBrowserContext::IsPrintPreviewSupported() const {
CEF_REQUIRE_UIT();
if (!extensions::PrintPreviewEnabled())
return false;
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
}
void AlloyBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
visitedlink_master_->AddURLs(urls);
}
content::ResourceContext* AlloyBrowserContext::GetResourceContext() {
if (!resource_context_) {
resource_context_ = std::make_unique<content::ResourceContext>();
}
return resource_context_.get();
}
content::ClientHintsControllerDelegate*
AlloyBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;
}
void AlloyBrowserContext::SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) {
// This method is called for Extension support.
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, std::move(closure));
}
ChromeZoomLevelPrefs* AlloyBrowserContext::GetZoomLevelPrefs() {
return static_cast<ChromeZoomLevelPrefs*>(
GetStoragePartition(this, nullptr)->GetZoomLevelDelegate());
}
scoped_refptr<network::SharedURLLoaderFactory>
AlloyBrowserContext::GetURLLoaderFactory() {
return GetDefaultStoragePartition(this)
->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()));
}
bool AlloyBrowserContext::IsOffTheRecord() const {
// Alloy contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false;
}
content::DownloadManagerDelegate*
AlloyBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_) {
content::DownloadManager* manager =
BrowserContext::GetDownloadManager(this);
download_manager_delegate_.reset(new CefDownloadManagerDelegate(manager));
}
return download_manager_delegate_.get();
}
content::BrowserPluginGuestManager* AlloyBrowserContext::GetGuestManager() {
DCHECK(extensions::ExtensionsEnabled());
return guest_view::GuestViewManager::FromBrowserContext(this);
}
storage::SpecialStoragePolicy* AlloyBrowserContext::GetSpecialStoragePolicy() {
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_.reset(new CefSSLHostStateDelegate());
return ssl_host_state_delegate_.get();
}
content::PermissionControllerDelegate*
AlloyBrowserContext::GetPermissionControllerDelegate() {
return nullptr;
}
content::BackgroundFetchDelegate*
AlloyBrowserContext::GetBackgroundFetchDelegate() {
return nullptr;
}
content::BackgroundSyncController*
AlloyBrowserContext::GetBackgroundSyncController() {
return nullptr;
}
content::BrowsingDataRemoverDelegate*
AlloyBrowserContext::GetBrowsingDataRemoverDelegate() {
return nullptr;
}
std::string AlloyBrowserContext::GetMediaDeviceIDSalt() {
return media_device_id_salt_->GetSalt();
}
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() {
NOTREACHED();
return nullptr;
}
policy::UserCloudPolicyManager*
AlloyBrowserContext::GetUserCloudPolicyManager() {
NOTREACHED();
return nullptr;
}
policy::ProfilePolicyConnector*
AlloyBrowserContext::GetProfilePolicyConnector() {
NOTREACHED();
return nullptr;
}
const policy::ProfilePolicyConnector*
AlloyBrowserContext::GetProfilePolicyConnector() const {
NOTREACHED();
return nullptr;
}
void AlloyBrowserContext::RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) {
// Called when visited links will not or cannot be loaded from disk.
enumerator->OnComplete(true);
}
DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() {
CEF_REQUIRE_UIT();
if (!download_prefs_) {
download_prefs_.reset(new DownloadPrefs(this));
}
return download_prefs_.get();
}

View File

@@ -0,0 +1,150 @@
// 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 "include/cef_request_context_handler.h"
#include "libcef/browser/alloy/chrome_profile_alloy.h"
#include "libcef/browser/browser_context.h"
#include "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 CefDownloadManagerDelegate;
class CefSSLHostStateDelegate;
class CefVisitedLinkListener;
class MediaDeviceIDSalt;
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);
// CefBrowserContext overrides.
content::BrowserContext* AsBrowserContext() override { return this; }
Profile* AsProfile() override { return this; }
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;
bool IsPrintPreviewSupported() const override;
void AddVisitedURLs(const std::vector<GURL>& urls) override;
// content::BrowserContext overrides.
content::ResourceContext* GetResourceContext() override;
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
void SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) override;
base::FilePath GetPath() override;
base::FilePath GetPath() const override;
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath& partition_path) override;
bool IsOffTheRecord() const override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() 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;
std::string GetMediaDeviceIDSalt() 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::ProfilePolicyConnector* GetProfilePolicyConnector() override;
const policy::ProfilePolicyConnector* GetProfilePolicyConnector()
const override;
// Values checked in ProfileNetworkContextService::CreateNetworkContextParams
// when creating the NetworkContext.
bool ShouldRestoreOldSessionCookies() const override {
return ShouldPersistSessionCookies();
}
bool ShouldPersistSessionCookies() const override {
return !!settings_.persist_session_cookies;
}
base::Optional<std::vector<std::string>> GetCookieableSchemes() override {
return cookieable_schemes();
}
// visitedlink::VisitedLinkDelegate methods.
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
// Manages extensions.
extensions::CefExtensionSystem* extension_system() const {
return extension_system_;
}
// Called from DownloadPrefs::FromBrowserContext.
DownloadPrefs* GetDownloadPrefs();
private:
~AlloyBrowserContext() override;
std::unique_ptr<PrefService> pref_service_;
std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
std::unique_ptr<CefDownloadManagerDelegate> 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_.
CefVisitedLinkListener* visitedlink_listener_ = nullptr;
// Owned by the KeyedService system.
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_;
std::unique_ptr<content::ResourceContext> resource_context_;
scoped_refptr<MediaDeviceIDSalt> media_device_id_salt_;
DISALLOW_COPY_AND_ASSIGN(AlloyBrowserContext);
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "libcef/browser/browser_main.h" #include "libcef/browser/alloy/alloy_browser_main.h"
#include <stdint.h> #include <stdint.h>
@@ -10,7 +10,6 @@
#include "libcef/browser/browser_context.h" #include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_context_keyed_service_factories.h" #include "libcef/browser/browser_context_keyed_service_factories.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h" #include "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/extensions/extension_system_factory.h" #include "libcef/browser/extensions/extension_system_factory.h"
@@ -19,12 +18,12 @@
#include "libcef/browser/printing/constrained_window_views_client.h" #include "libcef/browser/printing/constrained_window_views_client.h"
#include "libcef/browser/printing/printing_message_filter.h" #include "libcef/browser/printing/printing_message_filter.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/extensions/extensions_client.h" #include "libcef/common/extensions/extensions_client.h"
#include "libcef/common/extensions/extensions_util.h" #include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net/net_resource_provider.h" #include "libcef/common/net/net_resource_provider.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
@@ -32,11 +31,11 @@
#include "chrome/browser/plugins/plugin_finder.h" #include "chrome/browser/plugins/plugin_finder.h"
#include "components/constrained_window/constrained_window_views.h" #include "components/constrained_window/constrained_window_views.h"
#include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/network_service_instance.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "net/base/net_module.h" #include "net/base/net_module.h"
#include "services/service_manager/embedder/result_codes.h" #include "services/service_manager/embedder/result_codes.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#if defined(USE_AURA) && defined(USE_X11) #if defined(USE_AURA) && defined(USE_X11)
@@ -50,12 +49,15 @@
#include "ui/wm/core/wm_state.h" #include "ui/wm/core/wm_state.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "chrome/browser/chrome_browser_main_win.h"
#include "chrome/browser/win/parental_controls.h"
#include "components/os_crypt/os_crypt.h"
#include "ui/base/cursor/cursor_loader_win.h" #include "ui/base/cursor/cursor_loader_win.h"
#endif #endif
#endif // defined(USE_AURA) #endif // defined(USE_AURA)
#if defined(TOOLKIT_VIEWS) #if defined(TOOLKIT_VIEWS)
#if defined(OS_MACOSX) #if defined(OS_MAC)
#include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_views_delegate.h" #include "chrome/browser/ui/views/chrome_views_delegate.h"
#else #else
@@ -71,20 +73,15 @@
#include "libcef/browser/printing/print_dialog_linux.h" #include "libcef/browser/printing/print_dialog_linux.h"
#endif #endif
#if defined(OS_MACOSX) || defined(OS_WIN) AlloyBrowserMainParts::AlloyBrowserMainParts(
#include "chrome/browser/browser_process.h"
#include "components/os_crypt/os_crypt.h"
#endif
CefBrowserMainParts::CefBrowserMainParts(
const content::MainFunctionParams& parameters) const content::MainFunctionParams& parameters)
: BrowserMainParts(), devtools_delegate_(nullptr) {} : BrowserMainParts(), devtools_delegate_(nullptr) {}
CefBrowserMainParts::~CefBrowserMainParts() { AlloyBrowserMainParts::~AlloyBrowserMainParts() {
constrained_window::SetConstrainedWindowViewsClient(nullptr); constrained_window::SetConstrainedWindowViewsClient(nullptr);
} }
int CefBrowserMainParts::PreEarlyInitialization() { int AlloyBrowserMainParts::PreEarlyInitialization() {
#if defined(USE_AURA) && defined(OS_LINUX) #if defined(USE_AURA) && defined(OS_LINUX)
// TODO(linux): Consider using a real input method or // TODO(linux): Consider using a real input method or
// views::LinuxUI::SetInstance. // views::LinuxUI::SetInstance.
@@ -94,7 +91,7 @@ int CefBrowserMainParts::PreEarlyInitialization() {
return service_manager::RESULT_CODE_NORMAL_EXIT; return service_manager::RESULT_CODE_NORMAL_EXIT;
} }
void CefBrowserMainParts::ToolkitInitialized() { void AlloyBrowserMainParts::ToolkitInitialized() {
SetConstrainedWindowViewsClient(CreateCefConstrainedWindowViewsClient()); SetConstrainedWindowViewsClient(CreateCefConstrainedWindowViewsClient());
#if defined(USE_AURA) #if defined(USE_AURA)
CHECK(aura::Env::GetInstance()); CHECK(aura::Env::GetInstance());
@@ -103,12 +100,12 @@ void CefBrowserMainParts::ToolkitInitialized() {
#if defined(OS_WIN) #if defined(OS_WIN)
ui::CursorLoaderWin::SetCursorResourceModule( ui::CursorLoaderWin::SetCursorResourceModule(
CefContentBrowserClient::Get()->GetResourceDllName()); CefAppManager::Get()->GetResourceDllName());
#endif #endif
#endif // defined(USE_AURA) #endif // defined(USE_AURA)
#if defined(TOOLKIT_VIEWS) #if defined(TOOLKIT_VIEWS)
#if defined(OS_MACOSX) #if defined(OS_MAC)
views_delegate_ = std::make_unique<ChromeViewsDelegate>(); views_delegate_ = std::make_unique<ChromeViewsDelegate>();
layout_provider_ = ChromeLayoutProvider::CreateLayoutProvider(); layout_provider_ = ChromeLayoutProvider::CreateLayoutProvider();
#else #else
@@ -117,20 +114,25 @@ void CefBrowserMainParts::ToolkitInitialized() {
#endif // defined(TOOLKIT_VIEWS) #endif // defined(TOOLKIT_VIEWS)
} }
void CefBrowserMainParts::PreMainMessageLoopStart() { void AlloyBrowserMainParts::PreMainMessageLoopStart() {
#if defined(USE_AURA) && defined(USE_X11) #if defined(USE_AURA) && defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine(); ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif #endif
#if defined(OS_MACOSX) || defined(OS_WIN) #if defined(OS_WIN)
// Initialize the OSCrypt. // Initialize the OSCrypt.
PrefService* local_state = g_browser_process->local_state(); PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state); DCHECK(local_state);
OSCrypt::Init(local_state); bool os_crypt_init = OSCrypt::Init(local_state);
#endif 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 // defined(OS_WIN)
} }
void CefBrowserMainParts::PostMainMessageLoopStart() { void AlloyBrowserMainParts::PostMainMessageLoopStart() {
#if defined(OS_LINUX) #if defined(OS_LINUX)
printing::PrintingContextLinux::SetCreatePrintDialogFunction( printing::PrintingContextLinux::SetCreatePrintDialogFunction(
&CefPrintDialogLinux::CreatePrintDialog); &CefPrintDialogLinux::CreatePrintDialog);
@@ -139,7 +141,7 @@ void CefBrowserMainParts::PostMainMessageLoopStart() {
#endif #endif
} }
int CefBrowserMainParts::PreCreateThreads() { int AlloyBrowserMainParts::PreCreateThreads() {
#if defined(OS_WIN) #if defined(OS_WIN)
PlatformInitialize(); PlatformInitialize();
#endif #endif
@@ -154,13 +156,11 @@ int CefBrowserMainParts::PreCreateThreads() {
return 0; return 0;
} }
void CefBrowserMainParts::PreMainMessageLoopRun() { void AlloyBrowserMainParts::PreMainMessageLoopRun() {
#if defined(USE_AURA) #if defined(USE_AURA)
display::Screen::SetScreenInstance(views::CreateDesktopScreen()); display::Screen::SetScreenInstance(views::CreateDesktopScreen());
#endif #endif
ui::MaterialDesignController::Initialize();
if (extensions::ExtensionsEnabled()) { if (extensions::ExtensionsEnabled()) {
// Initialize extension global objects before creating the global // Initialize extension global objects before creating the global
// BrowserContext. // BrowserContext.
@@ -190,23 +190,29 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()}); base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
CefRequestContextSettings settings; CefRequestContextSettings settings;
CefContext::Get()->PopulateRequestContextSettings(&settings); CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
// Create the global RequestContext. // Create the global RequestContext.
global_request_context_ = global_request_context_ =
CefRequestContextImpl::CreateGlobalRequestContext(settings); CefRequestContextImpl::CreateGlobalRequestContext(settings);
CefBrowserContext* browser_context = static_cast<CefBrowserContext*>( auto browser_context =
global_request_context_->GetBrowserContext()); global_request_context_->GetBrowserContext()->AsBrowserContext();
CefDevToolsManagerDelegate::StartHttpHandler(browser_context); CefDevToolsManagerDelegate::StartHttpHandler(browser_context);
#if defined(OS_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();
#endif
// Triggers initialization of the singleton instance on UI thread. // Triggers initialization of the singleton instance on UI thread.
PluginFinder::GetInstance()->Init(); PluginFinder::GetInstance()->Init();
scheme::RegisterWebUIControllerFactory(); scheme::RegisterWebUIControllerFactory();
} }
void CefBrowserMainParts::PostMainMessageLoopRun() { void AlloyBrowserMainParts::PostMainMessageLoopRun() {
// NOTE: Destroy objects in reverse order of creation. // NOTE: Destroy objects in reverse order of creation.
CefDevToolsManagerDelegate::StopHttpHandler(); CefDevToolsManagerDelegate::StopHttpHandler();
@@ -216,7 +222,7 @@ void CefBrowserMainParts::PostMainMessageLoopRun() {
global_request_context_ = nullptr; global_request_context_ = nullptr;
} }
void CefBrowserMainParts::PostDestroyThreads() { void AlloyBrowserMainParts::PostDestroyThreads() {
if (extensions::ExtensionsEnabled()) { if (extensions::ExtensionsEnabled()) {
extensions::ExtensionsBrowserClient::Set(nullptr); extensions::ExtensionsBrowserClient::Set(nullptr);
extensions_browser_client_.reset(); extensions_browser_client_.reset();
@@ -224,7 +230,7 @@ void CefBrowserMainParts::PostDestroyThreads() {
#if defined(TOOLKIT_VIEWS) #if defined(TOOLKIT_VIEWS)
views_delegate_.reset(); views_delegate_.reset();
#if defined(OS_MACOSX) #if defined(OS_MAC)
layout_provider_.reset(); layout_provider_.reset();
#endif #endif
#endif // defined(TOOLKIT_VIEWS) #endif // defined(TOOLKIT_VIEWS)

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_BROWSER_MAIN_H_ #ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
#define CEF_LIBCEF_BROWSER_BROWSER_MAIN_H_ #define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
#pragma once #pragma once
#include "libcef/browser/request_context_impl.h" #include "libcef/browser/request_context_impl.h"
@@ -32,18 +32,18 @@ class WMState;
#if defined(TOOLKIT_VIEWS) #if defined(TOOLKIT_VIEWS)
namespace views { namespace views {
class ViewsDelegate; class ViewsDelegate;
#if defined(OS_MACOSX) #if defined(OS_MAC)
class LayoutProvider; class LayoutProvider;
#endif #endif
} } // namespace views
#endif // defined(TOOLKIT_VIEWS) #endif // defined(TOOLKIT_VIEWS)
class CefDevToolsDelegate; class CefDevToolsDelegate;
class CefBrowserMainParts : public content::BrowserMainParts { class AlloyBrowserMainParts : public content::BrowserMainParts {
public: public:
explicit CefBrowserMainParts(const content::MainFunctionParams& parameters); explicit AlloyBrowserMainParts(const content::MainFunctionParams& parameters);
~CefBrowserMainParts() override; ~AlloyBrowserMainParts() override;
int PreEarlyInitialization() override; int PreEarlyInitialization() override;
void ToolkitInitialized() override; void ToolkitInitialized() override;
@@ -96,12 +96,12 @@ class CefBrowserMainParts : public content::BrowserMainParts {
#if defined(TOOLKIT_VIEWS) #if defined(TOOLKIT_VIEWS)
std::unique_ptr<views::ViewsDelegate> views_delegate_; std::unique_ptr<views::ViewsDelegate> views_delegate_;
#if defined(OS_MACOSX) #if defined(OS_MAC)
std::unique_ptr<views::LayoutProvider> layout_provider_; std::unique_ptr<views::LayoutProvider> layout_provider_;
#endif #endif
#endif // defined(TOOLKIT_VIEWS) #endif // defined(TOOLKIT_VIEWS)
DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts); DISALLOW_COPY_AND_ASSIGN(AlloyBrowserMainParts);
}; };
#endif // CEF_LIBCEF_BROWSER_BROWSER_MAIN_H_ #endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_

View File

@@ -6,11 +6,11 @@
#include <commctrl.h> #include <commctrl.h>
#include <windows.h> #include <windows.h>
#include "libcef/browser/browser_main.h" #include "libcef/browser/alloy/alloy_browser_main.h"
#include "base/logging.h" #include "base/logging.h"
void CefBrowserMainParts::PlatformInitialize() { void AlloyBrowserMainParts::PlatformInitialize() {
HRESULT res; HRESULT res;
// Initialize common controls. // Initialize common controls.

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_ #ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
#define CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_ #define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
#pragma once #pragma once
#include <string> #include <string>
@@ -18,7 +18,7 @@
#include "content/public/browser/content_browser_client.h" #include "content/public/browser/content_browser_client.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
class CefBrowserMainParts; class AlloyBrowserMainParts;
class CefDevToolsDelegate; class CefDevToolsDelegate;
namespace content { namespace content {
@@ -30,13 +30,10 @@ namespace extensions {
class Extension; class Extension;
} }
class CefContentBrowserClient : public content::ContentBrowserClient { class AlloyContentBrowserClient : public content::ContentBrowserClient {
public: public:
CefContentBrowserClient(); AlloyContentBrowserClient();
~CefContentBrowserClient() override; ~AlloyContentBrowserClient() override;
// Returns the singleton CefContentBrowserClient instance.
static CefContentBrowserClient* Get();
// ContentBrowserClient implementation. // ContentBrowserClient implementation.
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts( std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
@@ -46,6 +43,11 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
const GURL& effective_url) override; const GURL& effective_url) override;
bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context, bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context,
const GURL& effective_site_url) override; const GURL& effective_site_url) override;
void OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
const url::Origin& origin,
bool is_for_isolated_world,
network::mojom::URLLoaderFactoryParams* factory_params) override;
void GetAdditionalWebUISchemes( void GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) override; std::vector<std::string>* additional_schemes) override;
void GetAdditionalViewSourceSchemes( void GetAdditionalViewSourceSchemes(
@@ -59,24 +61,14 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
void BindHostReceiverForRenderer( void BindHostReceiverForRenderer(
content::RenderProcessHost* render_process_host, content::RenderProcessHost* render_process_host,
mojo::GenericPendingReceiver receiver) override; mojo::GenericPendingReceiver receiver) override;
base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
base::StringPiece name) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line, void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override; int child_process_id) override;
void AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) override;
std::string GetApplicationLocale() override; std::string GetApplicationLocale() override;
scoped_refptr<network::SharedURLLoaderFactory> scoped_refptr<network::SharedURLLoaderFactory>
GetSystemSharedURLLoaderFactory() override; GetSystemSharedURLLoaderFactory() override;
network::mojom::NetworkContext* GetSystemNetworkContext() override; network::mojom::NetworkContext* GetSystemNetworkContext() override;
scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext() scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext()
override; override;
void GetQuotaSettings(
content::BrowserContext* context,
content::StoragePartition* partition,
base::OnceCallback<void(base::Optional<storage::QuotaSettings>)> callback)
override;
content::MediaObserver* GetMediaObserver() override; content::MediaObserver* GetMediaObserver() override;
content::SpeechRecognitionManagerDelegate* content::SpeechRecognitionManagerDelegate*
CreateSpeechRecognitionManagerDelegate() override; CreateSpeechRecognitionManagerDelegate() override;
@@ -111,6 +103,9 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
bool* no_javascript_access) override; bool* no_javascript_access) override;
void OverrideWebkitPrefs(content::RenderViewHost* rvh, void OverrideWebkitPrefs(content::RenderViewHost* rvh,
content::WebPreferences* prefs) override; content::WebPreferences* prefs) override;
bool OverrideWebPreferencesAfterNavigation(
content::WebContents* web_contents,
content::WebPreferences* prefs) override;
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override; void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
std::string GetDefaultDownloadName() override; std::string GetDefaultDownloadName() override;
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override; void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
@@ -134,7 +129,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
const wchar_t* GetResourceDllName();
bool PreSpawnRenderer(sandbox::TargetPolicy* policy, bool PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) override; RendererSpawnFlags flags) override;
#endif #endif
@@ -156,6 +150,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
LoginAuthRequiredCallback auth_required_callback) override; LoginAuthRequiredCallback auth_required_callback) override;
void RegisterNonNetworkNavigationURLLoaderFactories( void RegisterNonNetworkNavigationURLLoaderFactories(
int frame_tree_node_id, int frame_tree_node_id,
base::UkmSourceId ukm_source_id,
NonNetworkURLLoaderFactoryMap* factories) override; NonNetworkURLLoaderFactoryMap* factories) override;
void RegisterNonNetworkSubresourceURLLoaderFactories( void RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id, int render_process_id,
@@ -172,13 +167,17 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>* mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
header_client, header_client,
bool* bypass_redirect_checks, bool* bypass_redirect_checks,
bool* disable_secure_dns,
network::mojom::URLLoaderFactoryOverridePtr* factory_override) override; network::mojom::URLLoaderFactoryOverridePtr* factory_override) override;
void OnNetworkServiceCreated( void OnNetworkServiceCreated(
network::mojom::NetworkService* network_service) override; network::mojom::NetworkService* network_service) override;
mojo::Remote<network::mojom::NetworkContext> CreateNetworkContext( void ConfigureNetworkContextParams(
content::BrowserContext* context, content::BrowserContext* context,
bool in_memory, bool in_memory,
const base::FilePath& relative_partition_path) override; const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params)
override;
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override; std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
bool HandleExternalProtocol( bool HandleExternalProtocol(
const GURL& url, const GURL& url,
@@ -202,18 +201,22 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
content::PictureInPictureWindowController* controller) override; content::PictureInPictureWindowController* controller) override;
void RegisterBrowserInterfaceBindersForFrame( void RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map) mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override;
override; base::FilePath GetSandboxedStorageServiceDataDirectory() override;
std::string GetProduct() override; std::string GetProduct() override;
std::string GetChromeProduct() override; std::string GetChromeProduct() override;
std::string GetUserAgent() override; std::string GetUserAgent() override;
blink::UserAgentMetadata GetUserAgentMetadata() override; blink::UserAgentMetadata GetUserAgentMetadata() override;
base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers( base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers(
content::BrowserContext* browser_context) override; content::BrowserContext* browser_context) override;
bool ArePersistentMediaDeviceIDsAllowed(
// Perform browser process registration for the custom scheme. content::BrowserContext* browser_context,
void RegisterCustomScheme(const std::string& scheme); const GURL& scope,
const GURL& site_for_cookies,
const base::Optional<url::Origin>& top_frame_origin) override;
bool ShouldAllowPluginCreation(
const url::Origin& embedder_origin,
const content::PepperPluginInfo& plugin_info) override;
CefRefPtr<CefRequestContextImpl> request_context() const; CefRefPtr<CefRequestContextImpl> request_context() const;
CefDevToolsDelegate* devtools_delegate() const; CefDevToolsDelegate* devtools_delegate() const;
@@ -227,9 +230,9 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
const extensions::Extension* GetExtension( const extensions::Extension* GetExtension(
content::SiteInstance* site_instance); content::SiteInstance* site_instance);
CefBrowserMainParts* browser_main_parts_; AlloyBrowserMainParts* browser_main_parts_ = nullptr;
std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_; std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_;
}; };
#endif // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_ #endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_

View File

@@ -0,0 +1,436 @@
// Copyright 2015 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/browser_platform_delegate_alloy.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/extensions/extension_background_host.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/extensions/extension_view_host.h"
#include "libcef/browser/extensions/extension_web_contents_observer.h"
#include "libcef/browser/printing/print_view_manager.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/logging.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "components/zoom/zoom_controller.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "extensions/browser/process_manager.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
CefBrowserPlatformDelegateAlloy::CefBrowserPlatformDelegateAlloy()
: weak_ptr_factory_(this) {}
content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
CefBrowserHostImpl::CreateParams& create_params,
bool& own_web_contents) {
// Get or create the request context and browser context.
CefRefPtr<CefRequestContextImpl> request_context_impl =
CefRequestContextImpl::GetOrCreateForRequestContext(
create_params.request_context);
CHECK(request_context_impl);
auto cef_browser_context = request_context_impl->GetBrowserContext();
CHECK(cef_browser_context);
auto browser_context = cef_browser_context->AsBrowserContext();
if (!create_params.request_context) {
// Using the global request context.
create_params.request_context = request_context_impl.get();
}
scoped_refptr<content::SiteInstance> site_instance;
if (extensions::ExtensionsEnabled() && !create_params.url.is_empty()) {
if (!create_params.extension) {
// We might be loading an extension app view where the extension URL is
// provided by the client.
create_params.extension =
extensions::GetExtensionForUrl(browser_context, create_params.url);
}
if (create_params.extension) {
if (create_params.extension_host_type == extensions::VIEW_TYPE_INVALID) {
// Default to dialog behavior.
create_params.extension_host_type =
extensions::VIEW_TYPE_EXTENSION_DIALOG;
}
// Extension resources will fail to load if we don't use a SiteInstance
// associated with the extension.
// (AlloyContentBrowserClient::SiteInstanceGotProcess 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(create_params.url);
DCHECK(site_instance);
}
}
content::WebContents::CreateParams wc_create_params(browser_context,
site_instance);
if (IsWindowless()) {
// Create the OSR view for the WebContents.
CreateViewForWebContents(&wc_create_params.view,
&wc_create_params.delegate_view);
}
auto web_contents = content::WebContents::Create(wc_create_params);
CHECK(web_contents);
own_web_contents = true;
return web_contents.release();
}
void CefBrowserPlatformDelegateAlloy::WebContentsCreated(
content::WebContents* web_contents,
bool owned) {
CefBrowserPlatformDelegate::WebContentsCreated(web_contents, owned);
if (owned) {
SetOwnedWebContents(web_contents);
}
}
void CefBrowserPlatformDelegateAlloy::AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
CefRefPtr<CefBrowserHostImpl> owner =
CefBrowserHostImpl::GetBrowserForContents(new_contents.get());
if (owner) {
// Taking ownership of |new_contents|.
static_cast<CefBrowserPlatformDelegateAlloy*>(
owner->platform_delegate_.get())
->SetOwnedWebContents(new_contents.release());
return;
}
if (extension_host_) {
extension_host_->AddNewContents(source, std::move(new_contents), target_url,
disposition, initial_rect, user_gesture,
was_blocked);
}
}
bool CefBrowserPlatformDelegateAlloy::ShouldTransferNavigation(
bool is_main_frame_navigation) {
if (extension_host_) {
return extension_host_->ShouldTransferNavigation(is_main_frame_navigation);
}
return true;
}
void CefBrowserPlatformDelegateAlloy::RenderViewCreated(
content::RenderViewHost* render_view_host) {
// Indicate that the view has an external parent (namely us). This changes the
// default view behavior in some cases (e.g. focus handling on Linux).
if (!IsViewsHosted() && render_view_host->GetWidget()->GetView())
render_view_host->GetWidget()->GetView()->SetHasExternalParent(true);
}
void CefBrowserPlatformDelegateAlloy::RenderViewReady() {
ConfigureAutoResize();
}
void CefBrowserPlatformDelegateAlloy::BrowserCreated(
CefBrowserHostImpl* browser) {
CefBrowserPlatformDelegate::BrowserCreated(browser);
web_contents_->SetDelegate(browser);
PrefsTabHelper::CreateForWebContents(web_contents_);
printing::CefPrintViewManager::CreateForWebContents(web_contents_);
if (extensions::ExtensionsEnabled()) {
extensions::CefExtensionWebContentsObserver::CreateForWebContents(
web_contents_);
// Used by the tabs extension API.
zoom::ZoomController::CreateForWebContents(web_contents_);
}
if (IsPrintPreviewSupported()) {
web_contents_dialog_helper_.reset(
new CefWebContentsDialogHelper(web_contents_, this));
}
}
void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
const extensions::Extension* extension,
const GURL& url,
extensions::ViewType host_type) {
// Should get WebContentsCreated and BrowserCreated calls first.
DCHECK(web_contents_);
DCHECK(browser_);
DCHECK(!extension_host_);
if (host_type == extensions::VIEW_TYPE_EXTENSION_DIALOG ||
host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) {
// Create an extension host that we own.
extension_host_ = new extensions::CefExtensionViewHost(
browser_, extension, web_contents_, url, host_type);
// Trigger load of the extension URL.
extension_host_->CreateRenderViewSoon();
} else if (host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
is_background_host_ = true;
browser_->is_background_host_ = true;
// Create an extension host that will be owned by ProcessManager.
extension_host_ = new extensions::CefExtensionBackgroundHost(
browser_,
base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted,
weak_ptr_factory_.GetWeakPtr()),
extension, web_contents_, url, host_type);
// Load will be triggered by ProcessManager::CreateBackgroundHost.
} else {
NOTREACHED() << " Unsupported extension host type: " << host_type;
}
}
extensions::ExtensionHost* CefBrowserPlatformDelegateAlloy::GetExtensionHost()
const {
return extension_host_;
}
void CefBrowserPlatformDelegateAlloy::BrowserDestroyed(
CefBrowserHostImpl* browser) {
DestroyExtensionHost();
owned_web_contents_.reset();
CefBrowserPlatformDelegate::BrowserDestroyed(browser);
}
void CefBrowserPlatformDelegateAlloy::SendCaptureLostEvent() {
if (!web_contents_)
return;
content::RenderViewHost* host = web_contents_->GetRenderViewHost();
if (!host)
return;
content::RenderWidgetHostImpl* widget =
content::RenderWidgetHostImpl::From(host->GetWidget());
if (widget)
widget->LostCapture();
}
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
void CefBrowserPlatformDelegateAlloy::NotifyMoveOrResizeStarted() {
if (!web_contents_)
return;
// Dismiss any existing popups.
content::RenderViewHost* host = web_contents_->GetRenderViewHost();
if (host)
host->NotifyMoveOrResizeStarted();
}
#endif
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;
}
void CefBrowserPlatformDelegateAlloy::SetAutoResizeEnabled(
bool enabled,
const CefSize& min_size,
const CefSize& max_size) {
if (enabled == auto_resize_enabled_)
return;
auto_resize_enabled_ = enabled;
if (enabled) {
auto_resize_min_ = gfx::Size(min_size.width, min_size.height);
auto_resize_max_ = gfx::Size(max_size.width, max_size.height);
} else {
auto_resize_min_ = auto_resize_max_ = gfx::Size();
}
ConfigureAutoResize();
}
void CefBrowserPlatformDelegateAlloy::ConfigureAutoResize() {
if (!web_contents_ || !web_contents_->GetRenderWidgetHostView()) {
return;
}
if (auto_resize_enabled_) {
web_contents_->GetRenderWidgetHostView()->EnableAutoResize(
auto_resize_min_, auto_resize_max_);
} else {
web_contents_->GetRenderWidgetHostView()->DisableAutoResize(gfx::Size());
}
}
void CefBrowserPlatformDelegateAlloy::SetAccessibilityState(
cef_state_t accessibility_state) {
// Do nothing if state is set to default. It'll be disabled by default and
// controlled by the commmand-line flags "force-renderer-accessibility" and
// "disable-renderer-accessibility".
if (accessibility_state == STATE_DEFAULT)
return;
content::WebContentsImpl* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
if (!web_contents_impl)
return;
ui::AXMode accMode;
// In windowless mode set accessibility to TreeOnly mode. Else native
// accessibility APIs, specific to each platform, are also created.
if (accessibility_state == STATE_ENABLED) {
accMode = IsWindowless() ? ui::kAXModeWebContentsOnly : ui::kAXModeComplete;
}
web_contents_impl->SetAccessibilityMode(accMode);
}
bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const {
auto actionable_contents = GetActionableWebContents();
if (!actionable_contents)
return false;
auto cef_browser_context = CefBrowserContext::FromBrowserContext(
actionable_contents->GetBrowserContext());
if (!cef_browser_context->IsPrintPreviewSupported()) {
return false;
}
// Print preview is not currently supported with OSR.
return !IsWindowless();
}
void CefBrowserPlatformDelegateAlloy::Print() {
auto actionable_contents = GetActionableWebContents();
if (!actionable_contents)
return;
auto rfh = actionable_contents->GetMainFrame();
if (IsPrintPreviewSupported()) {
printing::CefPrintViewManager::FromWebContents(actionable_contents)
->PrintPreviewNow(rfh, false);
} else {
printing::PrintViewManager::FromWebContents(actionable_contents)
->PrintNow(rfh);
}
}
void CefBrowserPlatformDelegateAlloy::PrintToPDF(
const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback) {
content::WebContents* actionable_contents = GetActionableWebContents();
if (!actionable_contents)
return;
printing::CefPrintViewManager::PdfPrintCallback pdf_callback;
if (callback.get()) {
pdf_callback = base::Bind(&CefPdfPrintCallback::OnPdfPrintFinished,
callback.get(), path);
}
printing::CefPrintViewManager::FromWebContents(actionable_contents)
->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path),
settings, pdf_callback);
}
void CefBrowserPlatformDelegateAlloy::Find(int identifier,
const CefString& searchText,
bool forward,
bool matchCase,
bool findNext) {
if (!web_contents_)
return;
// Every find request must have a unique ID and these IDs must strictly
// increase so that newer requests always have greater IDs than older
// requests.
if (identifier <= find_request_id_counter_)
identifier = ++find_request_id_counter_;
else
find_request_id_counter_ = identifier;
auto options = blink::mojom::FindOptions::New();
options->forward = forward;
options->match_case = matchCase;
options->find_next_if_selection_matches = findNext;
web_contents_->Find(identifier, searchText, std::move(options));
}
void CefBrowserPlatformDelegateAlloy::StopFinding(bool clearSelection) {
if (!web_contents_)
return;
content::StopFindAction action =
clearSelection ? content::STOP_FIND_ACTION_CLEAR_SELECTION
: content::STOP_FIND_ACTION_KEEP_SELECTION;
web_contents_->StopFinding(action);
}
base::RepeatingClosure
CefBrowserPlatformDelegateAlloy::GetBoundsChangedCallback() {
if (web_contents_dialog_helper_) {
return web_contents_dialog_helper_->GetBoundsChangedCallback();
}
return base::RepeatingClosure();
}
content::WebContents*
CefBrowserPlatformDelegateAlloy::GetActionableWebContents() const {
if (web_contents_ && extensions::ExtensionsEnabled()) {
content::WebContents* guest_contents =
extensions::GetFullPageGuestForOwnerContents(web_contents_);
if (guest_contents)
return guest_contents;
}
return web_contents_;
}
void CefBrowserPlatformDelegateAlloy::SetOwnedWebContents(
content::WebContents* owned_contents) {
// Should not currently own a WebContents.
CHECK(!owned_web_contents_);
owned_web_contents_.reset(owned_contents);
}
void CefBrowserPlatformDelegateAlloy::DestroyExtensionHost() {
if (!extension_host_)
return;
if (extension_host_->extension_host_type() ==
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
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;
}

View File

@@ -0,0 +1,106 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors.
// Portions 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_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
#define CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/web_contents_dialog_helper.h"
#include "base/memory/weak_ptr.h"
// Implementation of Alloy-based browser functionality.
class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
public:
content::WebContents* CreateWebContents(
CefBrowserHostImpl::CreateParams& create_params,
bool& own_web_contents) override;
void WebContentsCreated(content::WebContents* web_contents,
bool owned) override;
void AddNewContents(content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) override;
bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
void RenderViewReady() override;
void BrowserCreated(CefBrowserHostImpl* browser) override;
void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::ViewType host_type) override;
extensions::ExtensionHost* GetExtensionHost() const override;
void BrowserDestroyed(CefBrowserHostImpl* browser) override;
void SendCaptureLostEvent() override;
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
void NotifyMoveOrResizeStarted() override;
#endif
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) override;
bool IsNeverComposited(content::WebContents* web_contents) override;
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;
void SetAccessibilityState(cef_state_t accessibility_state) override;
bool IsPrintPreviewSupported() const override;
void Print() override;
void PrintToPDF(const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback) override;
void Find(int identifier,
const CefString& searchText,
bool forward,
bool matchCase,
bool findNext) override;
void StopFinding(bool clearSelection) override;
protected:
CefBrowserPlatformDelegateAlloy();
base::RepeatingClosure GetBoundsChangedCallback();
// Returns the WebContents most likely to handle an action. If extensions are
// enabled and this browser has a full-page guest (for example, a full-page
// PDF viewer extension) then the guest's WebContents will be returned.
// Otherwise, the browser's WebContents will be returned.
content::WebContents* GetActionableWebContents() const;
private:
void SetOwnedWebContents(content::WebContents* owned_contents);
void DestroyExtensionHost();
void OnExtensionHostDeleted();
void ConfigureAutoResize();
// Non-nullptr if this object owns the WebContents. Will be nullptr for popup
// browsers between the calls to WebContentsCreated() and AddNewContents(),
// and may never be set if the parent browser is destroyed during popup
// creation.
std::unique_ptr<content::WebContents> owned_web_contents_;
// Used for the print preview dialog.
std::unique_ptr<CefWebContentsDialogHelper> web_contents_dialog_helper_;
// Used to provide unique incremental IDs for each find request.
int find_request_id_counter_ = 0;
// Used when the browser is hosting an extension.
extensions::ExtensionHost* extension_host_ = nullptr;
bool is_background_host_ = false;
// Used with auto-resize.
bool auto_resize_enabled_ = false;
gfx::Size auto_resize_min_;
gfx::Size auto_resize_max_;
base::WeakPtrFactory<CefBrowserPlatformDelegateAlloy> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegateAlloy);
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_

View File

@@ -3,10 +3,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "libcef/browser/chrome_browser_process_stub.h" #include "libcef/browser/alloy/chrome_browser_process_alloy.h"
#include "libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "libcef/browser/browser_context.h" #include "libcef/browser/browser_context.h"
#include "libcef/browser/chrome_profile_manager_stub.h"
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/prefs/browser_prefs.h" #include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
@@ -27,17 +27,17 @@
#include "services/network/public/cpp/network_switches.h" #include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
ChromeBrowserProcessStub::ChromeBrowserProcessStub() ChromeBrowserProcessAlloy::ChromeBrowserProcessAlloy()
: initialized_(false), : initialized_(false),
context_initialized_(false), context_initialized_(false),
shutdown_(false), shutdown_(false),
locale_("en-US") {} locale_("en-US") {}
ChromeBrowserProcessStub::~ChromeBrowserProcessStub() { ChromeBrowserProcessAlloy::~ChromeBrowserProcessAlloy() {
DCHECK((!initialized_ && !context_initialized_) || shutdown_); DCHECK((!initialized_ && !context_initialized_) || shutdown_);
} }
void ChromeBrowserProcessStub::Initialize() { void ChromeBrowserProcessAlloy::Initialize() {
DCHECK(!initialized_); DCHECK(!initialized_);
DCHECK(!context_initialized_); DCHECK(!context_initialized_);
DCHECK(!shutdown_); DCHECK(!shutdown_);
@@ -49,7 +49,7 @@ void ChromeBrowserProcessStub::Initialize() {
initialized_ = true; initialized_ = true;
} }
void ChromeBrowserProcessStub::OnContextInitialized() { void ChromeBrowserProcessAlloy::OnContextInitialized() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
DCHECK(initialized_); DCHECK(initialized_);
DCHECK(!context_initialized_); DCHECK(!context_initialized_);
@@ -57,12 +57,12 @@ void ChromeBrowserProcessStub::OnContextInitialized() {
// Must be created after the NotificationService. // Must be created after the NotificationService.
print_job_manager_.reset(new printing::PrintJobManager()); print_job_manager_.reset(new printing::PrintJobManager());
profile_manager_.reset(new ChromeProfileManagerStub()); profile_manager_.reset(new ChromeProfileManagerAlloy());
event_router_forwarder_ = new extensions::EventRouterForwarder(); event_router_forwarder_ = new extensions::EventRouterForwarder();
context_initialized_ = true; context_initialized_ = true;
} }
void ChromeBrowserProcessStub::Shutdown() { void ChromeBrowserProcessAlloy::CleanupOnUIThread() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
DCHECK(initialized_); DCHECK(initialized_);
DCHECK(context_initialized_); DCHECK(context_initialized_);
@@ -84,8 +84,9 @@ void ChromeBrowserProcessStub::Shutdown() {
// Release any references held by objects associated with a Profile. The // Release any references held by objects associated with a Profile. The
// Profile will be deleted later. // Profile will be deleted later.
for (const auto& profile : CefBrowserContext::GetAll()) { for (const auto& browser_context : CefBrowserContext::GetAll()) {
// Release any references to |local_state_|. // Release any references to |local_state_|.
auto profile = browser_context->AsProfile();
PrefWatcher* pref_watcher = PrefWatcher::Get(profile); PrefWatcher* pref_watcher = PrefWatcher::Get(profile);
if (pref_watcher) if (pref_watcher)
pref_watcher->Shutdown(); pref_watcher->Shutdown();
@@ -107,102 +108,106 @@ void ChromeBrowserProcessStub::Shutdown() {
shutdown_ = true; shutdown_ = true;
} }
void ChromeBrowserProcessStub::EndSession() { void ChromeBrowserProcessAlloy::EndSession() {
NOTREACHED(); NOTREACHED();
} }
void ChromeBrowserProcessStub::FlushLocalStateAndReply( void ChromeBrowserProcessAlloy::FlushLocalStateAndReply(
base::OnceClosure reply) { base::OnceClosure reply) {
NOTREACHED(); NOTREACHED();
} }
metrics_services_manager::MetricsServicesManager* metrics_services_manager::MetricsServicesManager*
ChromeBrowserProcessStub::GetMetricsServicesManager() { ChromeBrowserProcessAlloy::GetMetricsServicesManager() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
metrics::MetricsService* ChromeBrowserProcessStub::metrics_service() { metrics::MetricsService* ChromeBrowserProcessAlloy::metrics_service() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
rappor::RapporServiceImpl* ChromeBrowserProcessStub::rappor_service() { rappor::RapporServiceImpl* ChromeBrowserProcessAlloy::rappor_service() {
// Called from PluginInfoHostImpl::ReportMetrics. // Called from PluginInfoHostImpl::ReportMetrics.
return nullptr; return nullptr;
} }
SystemNetworkContextManager* SystemNetworkContextManager*
ChromeBrowserProcessStub::system_network_context_manager() { ChromeBrowserProcessAlloy::system_network_context_manager() {
DCHECK(SystemNetworkContextManager::GetInstance()); DCHECK(SystemNetworkContextManager::GetInstance());
return SystemNetworkContextManager::GetInstance(); return SystemNetworkContextManager::GetInstance();
} }
network::NetworkQualityTracker* network::NetworkQualityTracker*
ChromeBrowserProcessStub::network_quality_tracker() { ChromeBrowserProcessAlloy::network_quality_tracker() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
WatchDogThread* ChromeBrowserProcessStub::watchdog_thread() { WatchDogThread* ChromeBrowserProcessAlloy::watchdog_thread() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
ProfileManager* ChromeBrowserProcessStub::profile_manager() { ProfileManager* ChromeBrowserProcessAlloy::profile_manager() {
DCHECK(context_initialized_); DCHECK(context_initialized_);
return profile_manager_.get(); return profile_manager_.get();
} }
PrefService* ChromeBrowserProcessStub::local_state() { PrefService* ChromeBrowserProcessAlloy::local_state() {
DCHECK(initialized_); DCHECK(initialized_);
if (!local_state_) { if (!local_state_) {
// Use a location that is shared by all request contexts.
const CefSettings& settings = CefContext::Get()->settings(); const CefSettings& settings = CefContext::Get()->settings();
const base::FilePath& cache_path = const base::FilePath& root_cache_path =
base::FilePath(CefString(&settings.cache_path)); base::FilePath(CefString(&settings.root_cache_path));
// Used for very early NetworkService initialization. // Used for very early NetworkService initialization.
local_state_ = browser_prefs::CreatePrefService( // Always persist preferences for this PrefService if possible because it
nullptr, cache_path, !!settings.persist_user_preferences); // contains the cookie encryption key on Windows.
local_state_ =
browser_prefs::CreatePrefService(nullptr /* profile */, root_cache_path,
true /* persist_user_preferences */);
} }
return local_state_.get(); return local_state_.get();
} }
scoped_refptr<network::SharedURLLoaderFactory> scoped_refptr<network::SharedURLLoaderFactory>
ChromeBrowserProcessStub::shared_url_loader_factory() { ChromeBrowserProcessAlloy::shared_url_loader_factory() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
variations::VariationsService* ChromeBrowserProcessStub::variations_service() { variations::VariationsService* ChromeBrowserProcessAlloy::variations_service() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
BrowserProcessPlatformPart* ChromeBrowserProcessStub::platform_part() { BrowserProcessPlatformPart* ChromeBrowserProcessAlloy::platform_part() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
extensions::EventRouterForwarder* extensions::EventRouterForwarder*
ChromeBrowserProcessStub::extension_event_router_forwarder() { ChromeBrowserProcessAlloy::extension_event_router_forwarder() {
DCHECK(context_initialized_); DCHECK(context_initialized_);
return event_router_forwarder_.get(); return event_router_forwarder_.get();
} }
NotificationUIManager* ChromeBrowserProcessStub::notification_ui_manager() { NotificationUIManager* ChromeBrowserProcessAlloy::notification_ui_manager() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
NotificationPlatformBridge* NotificationPlatformBridge*
ChromeBrowserProcessStub::notification_platform_bridge() { ChromeBrowserProcessAlloy::notification_platform_bridge() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
policy::ChromeBrowserPolicyConnector* policy::ChromeBrowserPolicyConnector*
ChromeBrowserProcessStub::browser_policy_connector() { ChromeBrowserProcessAlloy::browser_policy_connector() {
if (!browser_policy_connector_) { if (!browser_policy_connector_) {
browser_policy_connector_ = browser_policy_connector_ =
std::make_unique<policy::ChromeBrowserPolicyConnector>(); std::make_unique<policy::ChromeBrowserPolicyConnector>();
@@ -210,40 +215,40 @@ ChromeBrowserProcessStub::browser_policy_connector() {
return browser_policy_connector_.get(); return browser_policy_connector_.get();
} }
policy::PolicyService* ChromeBrowserProcessStub::policy_service() { policy::PolicyService* ChromeBrowserProcessAlloy::policy_service() {
return browser_policy_connector()->GetPolicyService(); return browser_policy_connector()->GetPolicyService();
} }
IconManager* ChromeBrowserProcessStub::icon_manager() { IconManager* ChromeBrowserProcessAlloy::icon_manager() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
GpuModeManager* ChromeBrowserProcessStub::gpu_mode_manager() { GpuModeManager* ChromeBrowserProcessAlloy::gpu_mode_manager() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
void ChromeBrowserProcessStub::CreateDevToolsProtocolHandler() { void ChromeBrowserProcessAlloy::CreateDevToolsProtocolHandler() {
NOTREACHED(); NOTREACHED();
} }
void ChromeBrowserProcessStub::CreateDevToolsAutoOpener() { void ChromeBrowserProcessAlloy::CreateDevToolsAutoOpener() {
NOTREACHED(); NOTREACHED();
} }
bool ChromeBrowserProcessStub::IsShuttingDown() { bool ChromeBrowserProcessAlloy::IsShuttingDown() {
NOTREACHED(); NOTREACHED();
return false; return false;
} }
printing::PrintJobManager* ChromeBrowserProcessStub::print_job_manager() { printing::PrintJobManager* ChromeBrowserProcessAlloy::print_job_manager() {
DCHECK(context_initialized_); DCHECK(context_initialized_);
return print_job_manager_.get(); return print_job_manager_.get();
} }
printing::PrintPreviewDialogController* printing::PrintPreviewDialogController*
ChromeBrowserProcessStub::print_preview_dialog_controller() { ChromeBrowserProcessAlloy::print_preview_dialog_controller() {
if (!print_preview_dialog_controller_.get()) { if (!print_preview_dialog_controller_.get()) {
print_preview_dialog_controller_ = print_preview_dialog_controller_ =
new printing::PrintPreviewDialogController(); new printing::PrintPreviewDialogController();
@@ -252,7 +257,7 @@ ChromeBrowserProcessStub::print_preview_dialog_controller() {
} }
printing::BackgroundPrintingManager* printing::BackgroundPrintingManager*
ChromeBrowserProcessStub::background_printing_manager() { ChromeBrowserProcessAlloy::background_printing_manager() {
if (!background_printing_manager_.get()) { if (!background_printing_manager_.get()) {
background_printing_manager_.reset( background_printing_manager_.reset(
new printing::BackgroundPrintingManager()); new printing::BackgroundPrintingManager());
@@ -261,112 +266,120 @@ ChromeBrowserProcessStub::background_printing_manager() {
} }
IntranetRedirectDetector* IntranetRedirectDetector*
ChromeBrowserProcessStub::intranet_redirect_detector() { ChromeBrowserProcessAlloy::intranet_redirect_detector() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
const std::string& ChromeBrowserProcessStub::GetApplicationLocale() { const std::string& ChromeBrowserProcessAlloy::GetApplicationLocale() {
DCHECK(!locale_.empty()); DCHECK(!locale_.empty());
return locale_; return locale_;
} }
void ChromeBrowserProcessStub::SetApplicationLocale(const std::string& locale) { void ChromeBrowserProcessAlloy::SetApplicationLocale(
const std::string& locale) {
locale_ = locale; locale_ = locale;
} }
DownloadStatusUpdater* ChromeBrowserProcessStub::download_status_updater() { DownloadStatusUpdater* ChromeBrowserProcessAlloy::download_status_updater() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
DownloadRequestLimiter* ChromeBrowserProcessStub::download_request_limiter() { DownloadRequestLimiter* ChromeBrowserProcessAlloy::download_request_limiter() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
BackgroundModeManager* ChromeBrowserProcessStub::background_mode_manager() { #if BUILDFLAG(ENABLE_BACKGROUND_MODE)
BackgroundModeManager* ChromeBrowserProcessAlloy::background_mode_manager() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
void ChromeBrowserProcessStub::set_background_mode_manager_for_test( void ChromeBrowserProcessAlloy::set_background_mode_manager_for_test(
std::unique_ptr<BackgroundModeManager> manager) { std::unique_ptr<BackgroundModeManager> manager) {
NOTREACHED(); NOTREACHED();
} }
#endif
StatusTray* ChromeBrowserProcessStub::status_tray() { StatusTray* ChromeBrowserProcessAlloy::status_tray() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
safe_browsing::SafeBrowsingService* safe_browsing::SafeBrowsingService*
ChromeBrowserProcessStub::safe_browsing_service() { ChromeBrowserProcessAlloy::safe_browsing_service() {
return nullptr;
}
safe_browsing::ClientSideDetectionService*
ChromeBrowserProcessStub::safe_browsing_detection_service() {
NOTREACHED();
return nullptr; return nullptr;
} }
subresource_filter::RulesetService* subresource_filter::RulesetService*
ChromeBrowserProcessStub::subresource_filter_ruleset_service() { ChromeBrowserProcessAlloy::subresource_filter_ruleset_service() {
NOTREACHED();
return nullptr;
}
federated_learning::FlocBlocklistService*
ChromeBrowserProcessAlloy::floc_blocklist_service() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
optimization_guide::OptimizationGuideService* optimization_guide::OptimizationGuideService*
ChromeBrowserProcessStub::optimization_guide_service() { ChromeBrowserProcessAlloy::optimization_guide_service() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
StartupData* ChromeBrowserProcessStub::startup_data() { StartupData* ChromeBrowserProcessAlloy::startup_data() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
void ChromeBrowserProcessStub::StartAutoupdateTimer() {} void ChromeBrowserProcessAlloy::StartAutoupdateTimer() {}
#endif #endif
component_updater::ComponentUpdateService* component_updater::ComponentUpdateService*
ChromeBrowserProcessStub::component_updater() { ChromeBrowserProcessAlloy::component_updater() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
MediaFileSystemRegistry* MediaFileSystemRegistry*
ChromeBrowserProcessStub::media_file_system_registry() { ChromeBrowserProcessAlloy::media_file_system_registry() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
WebRtcLogUploader* ChromeBrowserProcessStub::webrtc_log_uploader() { WebRtcLogUploader* ChromeBrowserProcessAlloy::webrtc_log_uploader() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
network_time::NetworkTimeTracker* network_time::NetworkTimeTracker*
ChromeBrowserProcessStub::network_time_tracker() { ChromeBrowserProcessAlloy::network_time_tracker() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
gcm::GCMDriver* ChromeBrowserProcessStub::gcm_driver() { gcm::GCMDriver* ChromeBrowserProcessAlloy::gcm_driver() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
resource_coordinator::TabManager* ChromeBrowserProcessStub::GetTabManager() { resource_coordinator::TabManager* ChromeBrowserProcessAlloy::GetTabManager() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
resource_coordinator::ResourceCoordinatorParts* resource_coordinator::ResourceCoordinatorParts*
ChromeBrowserProcessStub::resource_coordinator_parts() { ChromeBrowserProcessAlloy::resource_coordinator_parts() {
NOTREACHED();
return nullptr;
}
BuildState* ChromeBrowserProcessAlloy::GetBuildState() {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }

View File

@@ -6,8 +6,8 @@
// This file provides a stub implementation of Chrome's BrowserProcess object // 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/. // for use as an interop layer between CEF and files that live in chrome/.
#ifndef CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_ #ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_ #define CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_
#include <memory> #include <memory>
#include <string> #include <string>
@@ -18,7 +18,7 @@
#include "chrome/browser/extensions/event_router_forwarder.h" #include "chrome/browser/extensions/event_router_forwarder.h"
#include "media/media_buildflags.h" #include "media/media_buildflags.h"
class ChromeProfileManagerStub; class ChromeProfileManagerAlloy;
class BackgroundModeManager { class BackgroundModeManager {
public: public:
@@ -29,14 +29,14 @@ class BackgroundModeManager {
DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager);
}; };
class ChromeBrowserProcessStub : public BrowserProcess { class ChromeBrowserProcessAlloy : public BrowserProcess {
public: public:
ChromeBrowserProcessStub(); ChromeBrowserProcessAlloy();
~ChromeBrowserProcessStub() override; ~ChromeBrowserProcessAlloy() override;
void Initialize(); void Initialize();
void OnContextInitialized(); void OnContextInitialized();
void Shutdown(); void CleanupOnUIThread();
// BrowserProcess implementation. // BrowserProcess implementation.
void EndSession() override; void EndSession() override;
@@ -73,15 +73,16 @@ class ChromeBrowserProcessStub : public BrowserProcess {
void SetApplicationLocale(const std::string& locale) override; void SetApplicationLocale(const std::string& locale) override;
DownloadStatusUpdater* download_status_updater() override; DownloadStatusUpdater* download_status_updater() override;
DownloadRequestLimiter* download_request_limiter() override; DownloadRequestLimiter* download_request_limiter() override;
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
BackgroundModeManager* background_mode_manager() override; BackgroundModeManager* background_mode_manager() override;
void set_background_mode_manager_for_test( void set_background_mode_manager_for_test(
std::unique_ptr<BackgroundModeManager> manager) override; std::unique_ptr<BackgroundModeManager> manager) override;
#endif
StatusTray* status_tray() override; StatusTray* status_tray() override;
safe_browsing::SafeBrowsingService* safe_browsing_service() override; safe_browsing::SafeBrowsingService* safe_browsing_service() override;
safe_browsing::ClientSideDetectionService* safe_browsing_detection_service()
override;
subresource_filter::RulesetService* subresource_filter_ruleset_service() subresource_filter::RulesetService* subresource_filter_ruleset_service()
override; override;
federated_learning::FlocBlocklistService* floc_blocklist_service() override;
optimization_guide::OptimizationGuideService* optimization_guide_service() optimization_guide::OptimizationGuideService* optimization_guide_service()
override; override;
StartupData* startup_data() override; StartupData* startup_data() override;
@@ -98,6 +99,7 @@ class ChromeBrowserProcessStub : public BrowserProcess {
resource_coordinator::TabManager* GetTabManager() override; resource_coordinator::TabManager* GetTabManager() override;
resource_coordinator::ResourceCoordinatorParts* resource_coordinator_parts() resource_coordinator::ResourceCoordinatorParts* resource_coordinator_parts()
override; override;
BuildState* GetBuildState() override;
private: private:
bool initialized_; bool initialized_;
@@ -106,7 +108,7 @@ class ChromeBrowserProcessStub : public BrowserProcess {
std::string locale_; std::string locale_;
std::unique_ptr<printing::PrintJobManager> print_job_manager_; std::unique_ptr<printing::PrintJobManager> print_job_manager_;
std::unique_ptr<ChromeProfileManagerStub> profile_manager_; std::unique_ptr<ChromeProfileManagerAlloy> profile_manager_;
scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_; scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
scoped_refptr<printing::PrintPreviewDialogController> scoped_refptr<printing::PrintPreviewDialogController>
print_preview_dialog_controller_; print_preview_dialog_controller_;
@@ -118,7 +120,7 @@ class ChromeBrowserProcessStub : public BrowserProcess {
browser_policy_connector_; browser_policy_connector_;
std::unique_ptr<base::FieldTrialList> field_trial_list_; std::unique_ptr<base::FieldTrialList> field_trial_list_;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProcessStub); DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProcessAlloy);
}; };
#endif // CEF_LIBCEF_BROWSER_CHROME_BROWSER_PROCESS_STUB_H_ #endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_

View File

@@ -0,0 +1,173 @@
// 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 "libcef/browser/alloy/chrome_profile_alloy.h"
#include "base/no_destructor.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();
}
std::string GetVariationsHeader() const override {
return variations::VariationsIdsProvider::GetInstance()
->GetClientDataHeader(false /* is_signed_in */);
}
private:
content::BrowserContext* browser_context_;
};
} // namespace
ChromeProfileAlloy::ChromeProfileAlloy() {}
ChromeProfileAlloy::~ChromeProfileAlloy() {}
bool ChromeProfileAlloy::IsOffTheRecord() {
return false;
}
bool ChromeProfileAlloy::IsOffTheRecord() const {
return false;
}
const Profile::OTRProfileID& ChromeProfileAlloy::GetOTRProfileID() const {
NOTREACHED();
static base::NoDestructor<Profile::OTRProfileID> otr_profile_id(
"ProfileImp::NoOTRProfileID");
return *otr_profile_id;
}
variations::VariationsClient* ChromeProfileAlloy::GetVariationsClient() {
if (!variations_client_)
variations_client_ = std::make_unique<CefVariationsClient>(this);
return variations_client_.get();
}
scoped_refptr<base::SequencedTaskRunner> ChromeProfileAlloy::GetIOTaskRunner() {
NOTREACHED();
return scoped_refptr<base::SequencedTaskRunner>();
}
std::string ChromeProfileAlloy::GetProfileUserName() const {
NOTREACHED();
return std::string();
}
Profile* ChromeProfileAlloy::GetOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) {
NOTREACHED();
return nullptr;
}
std::vector<Profile*> ChromeProfileAlloy::GetAllOffTheRecordProfiles() {
return {};
}
void ChromeProfileAlloy::DestroyOffTheRecordProfile(Profile* otr_profile) {
NOTREACHED();
}
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::IsSupervised() const {
return false;
}
bool ChromeProfileAlloy::IsChild() const {
return false;
}
bool ChromeProfileAlloy::IsLegacySupervised() const {
return false;
}
ExtensionSpecialStoragePolicy*
ChromeProfileAlloy::GetExtensionSpecialStoragePolicy() {
NOTREACHED();
return nullptr;
}
PrefService* ChromeProfileAlloy::GetOffTheRecordPrefs() {
NOTREACHED();
return nullptr;
}
bool ChromeProfileAlloy::IsSameOrParent(Profile* profile) {
NOTREACHED();
return false;
}
base::Time ChromeProfileAlloy::GetStartTime() const {
NOTREACHED();
return base::Time();
}
base::FilePath ChromeProfileAlloy::last_selected_directory() {
NOTREACHED();
return base::FilePath();
}
void ChromeProfileAlloy::set_last_selected_directory(
const base::FilePath& path) {
NOTREACHED();
}
GURL ChromeProfileAlloy::GetHomePage() {
NOTREACHED();
return GURL();
}
bool ChromeProfileAlloy::WasCreatedByVersionOrLater(
const std::string& version) {
NOTREACHED();
return false;
}
void ChromeProfileAlloy::SetExitType(ExitType exit_type) {
NOTREACHED();
}
Profile::ExitType ChromeProfileAlloy::GetLastSessionExitType() const {
NOTREACHED();
return EXIT_NORMAL;
}
base::Time ChromeProfileAlloy::GetCreationTime() const {
NOTREACHED();
return base::Time();
}
void ChromeProfileAlloy::SetCreationTimeForTesting(base::Time creation_time) {
NOTREACHED();
}

View File

@@ -5,29 +5,34 @@
// This class gathers state related to a single user profile. // This class gathers state related to a single user profile.
#ifndef CEF_LIBCEF_BROWSER_CHROME_PROFILE_STUB_H_ #ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_
#define CEF_LIBCEF_BROWSER_CHROME_PROFILE_STUB_H_ #define CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
// This file provides a stub implementation of Chrome's Profile object for use // 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/. // as an interop layer between CEF and files that live in chrome/.
class ChromeProfileStub : public Profile { class ChromeProfileAlloy : public Profile {
public: public:
ChromeProfileStub(); ChromeProfileAlloy();
~ChromeProfileStub() override; ~ChromeProfileAlloy() override;
protected: protected:
// Profile methods. // Profile methods.
bool IsOffTheRecord() override; bool IsOffTheRecord() override;
bool IsOffTheRecord() const override; bool IsOffTheRecord() const override;
const OTRProfileID& GetOTRProfileID() const override;
variations::VariationsClient* GetVariationsClient() override;
scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override; scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override;
std::string GetProfileUserName() const override; std::string GetProfileUserName() const override;
ProfileType GetProfileType() const override; Profile* GetOffTheRecordProfile(
Profile* GetOffTheRecordProfile() override; const Profile::OTRProfileID& otr_profile_id) override;
void DestroyOffTheRecordProfile() override; std::vector<Profile*> GetAllOffTheRecordProfiles() override;
bool HasOffTheRecordProfile() override; void DestroyOffTheRecordProfile(Profile* otr_profile) override;
bool HasOffTheRecordProfile(
const Profile::OTRProfileID& otr_profile_id) override;
bool HasAnyOffTheRecordProfile() override;
Profile* GetOriginalProfile() override; Profile* GetOriginalProfile() override;
const Profile* GetOriginalProfile() const override; const Profile* GetOriginalProfile() const override;
bool IsSupervised() const override; bool IsSupervised() const override;
@@ -35,20 +40,21 @@ class ChromeProfileStub : public Profile {
bool IsLegacySupervised() const override; bool IsLegacySupervised() const override;
ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override; ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
PrefService* GetOffTheRecordPrefs() override; PrefService* GetOffTheRecordPrefs() override;
bool IsSameProfile(Profile* profile) override; bool IsSameOrParent(Profile* profile) override;
base::Time GetStartTime() const override; base::Time GetStartTime() const override;
base::FilePath last_selected_directory() override; base::FilePath last_selected_directory() override;
void set_last_selected_directory(const base::FilePath& path) override; void set_last_selected_directory(const base::FilePath& path) override;
GURL GetHomePage() override; GURL GetHomePage() override;
bool WasCreatedByVersionOrLater(const std::string& version) override; bool WasCreatedByVersionOrLater(const std::string& version) override;
bool IsIndependentOffTheRecordProfile() override;
void SetExitType(ExitType exit_type) override; void SetExitType(ExitType exit_type) override;
ExitType GetLastSessionExitType() override; ExitType GetLastSessionExitType() const override;
base::Time GetCreationTime() const override; base::Time GetCreationTime() const override;
void SetCreationTimeForTesting(base::Time creation_time) override; void SetCreationTimeForTesting(base::Time creation_time) override;
private: private:
DISALLOW_COPY_AND_ASSIGN(ChromeProfileStub); std::unique_ptr<variations::VariationsClient> variations_client_;
DISALLOW_COPY_AND_ASSIGN(ChromeProfileAlloy);
}; };
#endif // CEF_LIBCEF_BROWSER_CHROME_PROFILE_STUB_H_ #endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_

View File

@@ -3,10 +3,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "libcef/browser/chrome_profile_manager_stub.h" #include "libcef/browser/alloy/chrome_profile_manager_alloy.h"
#include "libcef/browser/browser_context.h" #include "libcef/browser/browser_context.h"
#include "libcef/browser/content_browser_client.h" #include "libcef/browser/request_context_impl.h"
#include "libcef/common/app_manager.h"
namespace { namespace {
@@ -21,21 +22,22 @@ namespace {
// Return the main context for now since we don't currently have a good way to // Return the main context for now since we don't currently have a good way to
// determine that. // determine that.
CefBrowserContext* GetActiveBrowserContext() { CefBrowserContext* GetActiveBrowserContext() {
return static_cast<CefBrowserContext*>( auto request_context = static_cast<CefRequestContextImpl*>(
CefContentBrowserClient::Get()->request_context()->GetBrowserContext()); CefAppManager::Get()->GetGlobalRequestContext().get());
return request_context->GetBrowserContext();
} }
} // namespace } // namespace
ChromeProfileManagerStub::ChromeProfileManagerStub() ChromeProfileManagerAlloy::ChromeProfileManagerAlloy()
: ProfileManager(base::FilePath()) {} : ProfileManager(base::FilePath()) {}
ChromeProfileManagerStub::~ChromeProfileManagerStub() {} ChromeProfileManagerAlloy::~ChromeProfileManagerAlloy() {}
Profile* ChromeProfileManagerStub::GetProfile( Profile* ChromeProfileManagerAlloy::GetProfile(
const base::FilePath& profile_dir) { const base::FilePath& profile_dir) {
CefBrowserContext* browser_context = CefBrowserContext* browser_context =
CefBrowserContext::GetForCachePath(profile_dir); CefBrowserContext::FromCachePath(profile_dir);
if (!browser_context) { if (!browser_context) {
// ProfileManager makes assumptions about profile directory paths that do // ProfileManager makes assumptions about profile directory paths that do
// not match CEF usage. For example, the default Chrome profile name is // not match CEF usage. For example, the default Chrome profile name is
@@ -45,19 +47,19 @@ Profile* ChromeProfileManagerStub::GetProfile(
// asking for. // asking for.
browser_context = GetActiveBrowserContext(); browser_context = GetActiveBrowserContext();
} }
return browser_context; return browser_context->AsProfile();
} }
bool ChromeProfileManagerStub::IsValidProfile(const void* profile) { bool ChromeProfileManagerAlloy::IsValidProfile(const void* profile) {
if (!profile) if (!profile)
return false; return false;
return !!CefBrowserContext::GetForContext( return !!CefBrowserContext::FromBrowserContext(
reinterpret_cast<content::BrowserContext*>(const_cast<void*>(profile))); static_cast<const content::BrowserContext*>(profile));
} }
Profile* ChromeProfileManagerStub::GetLastUsedProfile( Profile* ChromeProfileManagerAlloy::GetLastUsedProfile(
const base::FilePath& user_data_dir) { const base::FilePath& user_data_dir) {
// Override this method to avoid having to register prefs::kProfileLastUsed, // Override this method to avoid having to register prefs::kProfileLastUsed,
// usage of which doesn't make sense for CEF. // usage of which doesn't make sense for CEF.
return GetActiveBrowserContext(); return GetActiveBrowserContext()->AsProfile();
} }

View File

@@ -6,22 +6,22 @@
// This file provides a stub implementation of Chrome's ProfileManager object // 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/. // for use as an interop layer between CEF and files that live in chrome/.
#ifndef CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_ #ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_
#define CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_ #define CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
class ChromeProfileManagerStub : public ProfileManager { class ChromeProfileManagerAlloy : public ProfileManager {
public: public:
ChromeProfileManagerStub(); ChromeProfileManagerAlloy();
~ChromeProfileManagerStub() override; ~ChromeProfileManagerAlloy() override;
Profile* GetProfile(const base::FilePath& profile_dir) override; Profile* GetProfile(const base::FilePath& profile_dir) override;
bool IsValidProfile(const void* profile) override; bool IsValidProfile(const void* profile) override;
Profile* GetLastUsedProfile(const base::FilePath& user_data_dir) override; Profile* GetLastUsedProfile(const base::FilePath& user_data_dir) override;
private: private:
DISALLOW_COPY_AND_ASSIGN(ChromeProfileManagerStub); DISALLOW_COPY_AND_ASSIGN(ChromeProfileManagerAlloy);
}; };
#endif // CEF_LIBCEF_BROWSER_CHROME_PROFILE_MANAGER_STUB_H_ #endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_

View File

@@ -0,0 +1,126 @@
// Copyright (c) 2019 The Chromium Embedded Framework Authors.
// Portions 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.
#include "libcef/browser/audio_capturer.h"
#include "libcef/browser/browser_host_impl.h"
#include "components/mirroring/service/captured_audio_input.h"
#include "content/public/browser/audio_loopback_stream_creator.h"
#include "media/audio/audio_input_device.h"
namespace {
media::ChannelLayout TranslateChannelLayout(
cef_channel_layout_t channel_layout) {
// Verify that our enum matches Chromium's values. The enum values match
// between those enums and existing values don't ever change, so it's enough
// to check that there are no new ones added.
static_assert(
static_cast<int>(CEF_CHANNEL_LAYOUT_MAX) ==
static_cast<int>(media::CHANNEL_LAYOUT_MAX),
"cef_channel_layout_t must match the ChannelLayout enum in Chromium");
return static_cast<media::ChannelLayout>(channel_layout);
}
void StreamCreatorHelper(
content::WebContents* source_web_contents,
content::AudioLoopbackStreamCreator* audio_stream_creator,
mojo::PendingRemote<mirroring::mojom::AudioStreamCreatorClient> client,
const media::AudioParameters& params,
uint32_t total_segments) {
audio_stream_creator->CreateLoopbackStream(
source_web_contents, params, total_segments,
base::BindRepeating(
[](mojo::PendingRemote<mirroring::mojom::AudioStreamCreatorClient>
client,
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe) {
mojo::Remote<mirroring::mojom::AudioStreamCreatorClient>
audio_client(std::move(client));
audio_client->StreamCreated(std::move(stream),
std::move(client_receiver),
std::move(data_pipe));
},
base::Passed(&client)));
}
} // namespace
CefAudioCapturer::CefAudioCapturer(const CefAudioParameters& params,
CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefAudioHandler> audio_handler)
: params_(params),
browser_(browser),
audio_handler_(audio_handler),
audio_stream_creator_(content::AudioLoopbackStreamCreator::
CreateInProcessAudioLoopbackStreamCreator()) {
media::AudioParameters audio_params(
media::AudioParameters::AUDIO_PCM_LINEAR,
TranslateChannelLayout(params.channel_layout), params.sample_rate,
params.frames_per_buffer);
if (!audio_params.IsValid()) {
LOG(ERROR) << "Invalid audio parameters";
return;
}
DCHECK(browser_);
DCHECK(audio_handler_);
DCHECK(browser_->web_contents());
channels_ = audio_params.channels();
audio_input_device_ = new media::AudioInputDevice(
std::make_unique<mirroring::CapturedAudioInput>(base::BindRepeating(
&StreamCreatorHelper, base::Unretained(browser_->web_contents()),
base::Unretained(audio_stream_creator_.get()))),
media::AudioInputDevice::kLoopback,
media::AudioInputDevice::DeadStreamDetection::kEnabled);
audio_input_device_->Initialize(audio_params, this);
audio_input_device_->Start();
}
CefAudioCapturer::~CefAudioCapturer() {
StopStream();
}
void CefAudioCapturer::OnCaptureStarted() {
audio_handler_->OnAudioStreamStarted(browser_, params_, channels_);
DCHECK(!capturing_);
capturing_ = true;
}
void CefAudioCapturer::Capture(const media::AudioBus* source,
base::TimeTicks audio_capture_time,
double /*volume*/,
bool /*key_pressed*/) {
const int channels = source->channels();
std::array<const float*, media::CHANNELS_MAX> data;
DCHECK(channels == channels_);
DCHECK(channels <= static_cast<int>(data.size()));
for (int c = 0; c < channels; ++c) {
data[c] = source->channel(c);
}
base::TimeDelta pts = audio_capture_time - base::TimeTicks::UnixEpoch();
audio_handler_->OnAudioStreamPacket(browser_, data.data(), source->frames(),
pts.InMilliseconds());
}
void CefAudioCapturer::OnCaptureError(const std::string& message) {
audio_handler_->OnAudioStreamError(browser_, message);
StopStream();
}
void CefAudioCapturer::StopStream() {
if (audio_input_device_)
audio_input_device_->Stop();
if (capturing_)
audio_handler_->OnAudioStreamStopped(browser_);
audio_input_device_ = nullptr;
capturing_ = false;
}

View File

@@ -0,0 +1,53 @@
// Copyright (c) 2019 The Chromium Embedded Framework Authors.
// Portions 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_AUDIO_CAPTURER_H_
#define CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_
#pragma once
#include "include/internal/cef_ptr.h"
#include "include/internal/cef_types_wrappers.h"
#include "media/base/audio_capturer_source.h"
namespace content {
class AudioLoopbackStreamCreator;
} // namespace content
namespace media {
class AudioInputDevice;
} // namespace media
class CefAudioHandler;
class CefBrowserHostImpl;
class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback {
public:
CefAudioCapturer(const CefAudioParameters& params,
CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefAudioHandler> audio_handler);
~CefAudioCapturer() override;
private:
void OnCaptureStarted() override;
void Capture(const media::AudioBus* audio_source,
base::TimeTicks audio_capture_time,
double volume,
bool key_pressed) override;
void OnCaptureError(const std::string& message) override;
void OnCaptureMuted(bool is_muted) override {}
void StopStream();
CefAudioParameters params_;
CefRefPtr<CefBrowserHostImpl> browser_;
CefRefPtr<CefAudioHandler> audio_handler_;
std::unique_ptr<content::AudioLoopbackStreamCreator> audio_stream_creator_;
scoped_refptr<media::AudioInputDevice> audio_input_device_;
bool capturing_ = false;
int channels_ = 0;
};
#endif // CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_

View File

@@ -7,48 +7,20 @@
#include <map> #include <map>
#include <utility> #include <utility>
#include "libcef/browser/content_browser_client.h" #include "libcef/browser/iothread_state.h"
#include "libcef/browser/context.h" #include "libcef/browser/media_router/media_router_manager.h"
#include "libcef/browser/download_manager_delegate.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/request_context_impl.h" #include "libcef/browser/request_context_impl.h"
#include "libcef/browser/ssl_host_state_delegate.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h" #include "libcef/common/cef_switches.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/command_line.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "chrome/browser/font_family_cache.h" #include "content/public/browser/browser_context.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
#include "chrome/common/pref_names.h"
#include "components/content_settings/core/browser/host_content_settings_map.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/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_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/storage_partition.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 "net/proxy_resolution/proxy_resolution_service.h"
#include "services/network/public/mojom/cors_origin_pattern.mojom.h"
using content::BrowserThread; using content::BrowserThread;
@@ -91,10 +63,10 @@ class ImplManager {
return GetImplPos(impl) != all_.end(); return GetImplPos(impl) != all_.end();
} }
CefBrowserContext* GetImplForIDs(int render_process_id, CefBrowserContext* GetImplFromIDs(int render_process_id,
int render_frame_id, int render_frame_id,
int frame_tree_node_id, int frame_tree_node_id,
bool require_frame_match) { bool require_frame_match) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
for (const auto& context : all_) { for (const auto& context : all_) {
if (context->IsAssociatedContext(render_process_id, render_frame_id, if (context->IsAssociatedContext(render_process_id, render_frame_id,
@@ -106,15 +78,15 @@ class ImplManager {
return nullptr; return nullptr;
} }
CefBrowserContext* GetImplForContext(const content::BrowserContext* context) { CefBrowserContext* GetImplFromBrowserContext(
const content::BrowserContext* context) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (!context) if (!context)
return nullptr; return nullptr;
Vector::iterator it = all_.begin(); for (const auto& bc : all_) {
for (; it != all_.end(); ++it) { if (bc->AsBrowserContext() == context)
if (*it == context) return bc;
return *it;
} }
return nullptr; return nullptr;
} }
@@ -123,11 +95,11 @@ class ImplManager {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
DCHECK(!path.empty()); DCHECK(!path.empty());
DCHECK(IsValidImpl(impl)); DCHECK(IsValidImpl(impl));
DCHECK(GetImplForPath(path) == nullptr); DCHECK(GetImplFromPath(path) == nullptr);
map_.insert(std::make_pair(path, impl)); map_.insert(std::make_pair(path, impl));
} }
CefBrowserContext* GetImplForPath(const base::FilePath& path) { CefBrowserContext* GetImplFromPath(const base::FilePath& path) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
DCHECK(!path.empty()); DCHECK(!path.empty());
PathMap::const_iterator it = map_.find(path); PathMap::const_iterator it = map_.find(path);
@@ -164,68 +136,48 @@ base::LazyInstance<ImplManager>::DestructorAtExit g_manager =
base::LazyInstance<ImplManager>::Leaky g_manager = LAZY_INSTANCE_INITIALIZER; base::LazyInstance<ImplManager>::Leaky g_manager = LAZY_INSTANCE_INITIALIZER;
#endif #endif
CefBrowserContext* GetSelf(base::WeakPtr<CefBrowserContext> self) {
CEF_REQUIRE_UIT();
return self.get();
}
} // namespace } // namespace
// Creates and manages VisitedLinkEventListener objects for each
// CefBrowserContext sharing the same VisitedLinkWriter.
class CefVisitedLinkListener : public visitedlink::VisitedLinkWriter::Listener {
public:
CefVisitedLinkListener() { DCHECK(listener_map_.empty()); }
void CreateListenerForContext(const CefBrowserContext* context) {
CEF_REQUIRE_UIT();
auto listener = std::make_unique<visitedlink::VisitedLinkEventListener>(
const_cast<CefBrowserContext*>(context));
listener_map_.insert(std::make_pair(context, std::move(listener)));
}
void RemoveListenerForContext(const CefBrowserContext* 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 CefBrowserContext to the associated VisitedLinkEventListener.
typedef std::map<const CefBrowserContext*,
std::unique_ptr<visitedlink::VisitedLinkEventListener>>
ListenerMap;
ListenerMap listener_map_;
DISALLOW_COPY_AND_ASSIGN(CefVisitedLinkListener);
};
CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings) CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings)
: settings_(settings) { : settings_(settings), weak_ptr_factory_(this) {
g_manager.Get().AddImpl(this); g_manager.Get().AddImpl(this);
getter_ = base::BindRepeating(GetSelf, weak_ptr_factory_.GetWeakPtr());
} }
CefBrowserContext::~CefBrowserContext() { CefBrowserContext::~CefBrowserContext() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
#if DCHECK_IS_ON()
DCHECK(is_shutdown_);
#endif
if (iothread_state_) {
// Destruction of the CefIOThreadState will trigger destruction of all
// associated network requests.
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
iothread_state_.release());
}
}
void CefBrowserContext::Initialize() {
cache_path_ = base::FilePath(CefString(&settings_.cache_path));
if (!cache_path_.empty())
g_manager.Get().SetImplPath(this, cache_path_);
iothread_state_ = std::make_unique<CefIOThreadState>();
}
void CefBrowserContext::Shutdown() {
CEF_REQUIRE_UIT();
#if DCHECK_IS_ON()
is_shutdown_ = true;
#endif
// No CefRequestContext should be referencing this object any longer. // No CefRequestContext should be referencing this object any longer.
DCHECK(request_context_set_.empty()); DCHECK(request_context_set_.empty());
@@ -233,135 +185,8 @@ CefBrowserContext::~CefBrowserContext() {
// Unregister the context first to avoid re-entrancy during shutdown. // Unregister the context first to avoid re-entrancy during shutdown.
g_manager.Get().RemoveImpl(this, cache_path_); g_manager.Get().RemoveImpl(this, cache_path_);
// Send notifications to clean up objects associated with this Profile. // Destroy objects that may hold references to the MediaRouter.
MaybeSendDestroyedNotification(); media_router_manager_.reset();
ChromePluginServiceFilter::GetInstance()->UnregisterProfile(this);
// Remove any BrowserContextKeyedServiceFactory associations. This must be
// called before the ProxyService owned by CefBrowserContext 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();
if (resource_context_.get()) {
// Destruction of the ResourceContext will trigger destruction of all
// associated network requests.
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
resource_context_.release());
}
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();
if (host_content_settings_map_)
host_content_settings_map_->ShutdownOnUIThread();
// 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 CefBrowserContext::Initialize() {
CefContext* context = CefContext::Get();
cache_path_ = base::FilePath(CefString(&settings_.cache_path));
if (!context->ValidateCachePath(cache_path_)) {
// Reset to in-memory storage.
CefString(&settings_.cache_path).clear();
cache_path_ = base::FilePath();
}
if (!cache_path_.empty())
g_manager.Get().SetImplPath(this, cache_path_);
if (settings_.accept_language_list.length == 0) {
// Use the global language list setting.
CefString(&settings_.accept_language_list) =
CefString(&context->settings().accept_language_list);
}
if (!!settings_.persist_session_cookies) {
set_should_persist_session_cookies(true);
}
key_ = std::make_unique<ProfileKey>(GetPath());
SimpleKeyMap::GetInstance()->Associate(this, key_.get());
// Initialize the PrefService object.
pref_service_ = browser_prefs::CreatePrefService(
this, cache_path_, !!settings_.persist_user_preferences);
content::BrowserContext::Initialize(this, GetPath());
resource_context_.reset(new CefResourceContext(IsOffTheRecord()));
// 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_.reset(new 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_.reset(new PrefProxyConfigTrackerImpl(
GetPrefs(), base::CreateSingleThreadTaskRunner({BrowserThread::IO})));
// 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 CefBrowserContext::AddCefRequestContext(CefRequestContextImpl* context) { void CefBrowserContext::AddCefRequestContext(CefRequestContextImpl* context) {
@@ -373,36 +198,35 @@ void CefBrowserContext::RemoveCefRequestContext(
CefRequestContextImpl* context) { CefRequestContextImpl* context) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (extensions::ExtensionsEnabled()) {
extension_system()->OnRequestContextDeleted(context);
}
request_context_set_.erase(context); request_context_set_.erase(context);
// Delete ourselves when the reference count reaches zero. // Delete ourselves when the reference count reaches zero.
if (request_context_set_.empty()) if (request_context_set_.empty()) {
Shutdown();
delete this; delete this;
}
} }
// static // static
CefBrowserContext* CefBrowserContext::GetForCachePath( CefBrowserContext* CefBrowserContext::FromCachePath(
const base::FilePath& cache_path) { const base::FilePath& cache_path) {
return g_manager.Get().GetImplForPath(cache_path); return g_manager.Get().GetImplFromPath(cache_path);
} }
// static // static
CefBrowserContext* CefBrowserContext::GetForIDs(int render_process_id, CefBrowserContext* CefBrowserContext::FromIDs(int render_process_id,
int render_frame_id, int render_frame_id,
int frame_tree_node_id, int frame_tree_node_id,
bool require_frame_match) { bool require_frame_match) {
return g_manager.Get().GetImplForIDs(render_process_id, render_frame_id, return g_manager.Get().GetImplFromIDs(render_process_id, render_frame_id,
frame_tree_node_id, require_frame_match); frame_tree_node_id,
require_frame_match);
} }
// static // static
CefBrowserContext* CefBrowserContext::GetForContext( CefBrowserContext* CefBrowserContext::FromBrowserContext(
content::BrowserContext* context) { const content::BrowserContext* context) {
return g_manager.Get().GetImplForContext(context); return g_manager.Get().GetImplFromBrowserContext(context);
} }
// static // static
@@ -410,194 +234,6 @@ std::vector<CefBrowserContext*> CefBrowserContext::GetAll() {
return g_manager.Get().GetAllImpl(); return g_manager.Get().GetAllImpl();
} }
content::ResourceContext* CefBrowserContext::GetResourceContext() {
return resource_context_.get();
}
content::ClientHintsControllerDelegate*
CefBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;
}
void CefBrowserContext::SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) {
// This method is called for Extension support.
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, std::move(closure));
}
ChromeZoomLevelPrefs* CefBrowserContext::GetZoomLevelPrefs() {
return static_cast<ChromeZoomLevelPrefs*>(
GetStoragePartition(this, nullptr)->GetZoomLevelDelegate());
}
scoped_refptr<network::SharedURLLoaderFactory>
CefBrowserContext::GetURLLoaderFactory() {
return GetDefaultStoragePartition(this)
->GetURLLoaderFactoryForBrowserProcess();
}
base::FilePath CefBrowserContext::GetPath() {
return cache_path_;
}
base::FilePath CefBrowserContext::GetPath() const {
return cache_path_;
}
std::unique_ptr<content::ZoomLevelDelegate>
CefBrowserContext::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()));
}
bool CefBrowserContext::IsOffTheRecord() const {
// CEF contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false;
}
content::DownloadManagerDelegate*
CefBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_) {
content::DownloadManager* manager =
BrowserContext::GetDownloadManager(this);
download_manager_delegate_.reset(new CefDownloadManagerDelegate(manager));
}
return download_manager_delegate_.get();
}
content::BrowserPluginGuestManager* CefBrowserContext::GetGuestManager() {
DCHECK(extensions::ExtensionsEnabled());
return guest_view::GuestViewManager::FromBrowserContext(this);
}
storage::SpecialStoragePolicy* CefBrowserContext::GetSpecialStoragePolicy() {
return nullptr;
}
content::PushMessagingService* CefBrowserContext::GetPushMessagingService() {
return nullptr;
}
content::StorageNotificationService*
CefBrowserContext::GetStorageNotificationService() {
return nullptr;
}
content::SSLHostStateDelegate* CefBrowserContext::GetSSLHostStateDelegate() {
if (!ssl_host_state_delegate_.get())
ssl_host_state_delegate_.reset(new CefSSLHostStateDelegate());
return ssl_host_state_delegate_.get();
}
content::PermissionControllerDelegate*
CefBrowserContext::GetPermissionControllerDelegate() {
return nullptr;
}
content::BackgroundFetchDelegate*
CefBrowserContext::GetBackgroundFetchDelegate() {
return nullptr;
}
content::BackgroundSyncController*
CefBrowserContext::GetBackgroundSyncController() {
return nullptr;
}
content::BrowsingDataRemoverDelegate*
CefBrowserContext::GetBrowsingDataRemoverDelegate() {
return nullptr;
}
PrefService* CefBrowserContext::GetPrefs() {
return pref_service_.get();
}
const PrefService* CefBrowserContext::GetPrefs() const {
return pref_service_.get();
}
ProfileKey* CefBrowserContext::GetProfileKey() const {
DCHECK(key_);
return key_.get();
}
policy::SchemaRegistryService*
CefBrowserContext::GetPolicySchemaRegistryService() {
NOTREACHED();
return nullptr;
}
policy::UserCloudPolicyManager* CefBrowserContext::GetUserCloudPolicyManager() {
NOTREACHED();
return nullptr;
}
policy::ProfilePolicyConnector* CefBrowserContext::GetProfilePolicyConnector() {
NOTREACHED();
return nullptr;
}
const policy::ProfilePolicyConnector*
CefBrowserContext::GetProfilePolicyConnector() const {
NOTREACHED();
return nullptr;
}
const CefRequestContextSettings& CefBrowserContext::GetSettings() const {
return settings_;
}
HostContentSettingsMap* CefBrowserContext::GetHostContentSettingsMap() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!host_content_settings_map_.get()) {
// The |is_incognito_profile| and |is_guest_profile| arguments are
// intentionally set to false as they otherwise limit the types of values
// that can be stored in the settings map (for example, default values set
// via DefaultProvider::SetWebsiteSetting).
host_content_settings_map_ =
new HostContentSettingsMap(GetPrefs(), false, false, false);
// Change the default plugin policy.
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
const std::string& plugin_policy_str =
command_line->GetSwitchValueASCII(switches::kPluginPolicy);
if (!plugin_policy_str.empty()) {
ContentSetting plugin_policy = CONTENT_SETTING_ALLOW;
if (base::LowerCaseEqualsASCII(plugin_policy_str,
switches::kPluginPolicy_Detect)) {
plugin_policy = CONTENT_SETTING_DETECT_IMPORTANT_CONTENT;
} else if (base::LowerCaseEqualsASCII(plugin_policy_str,
switches::kPluginPolicy_Block)) {
plugin_policy = CONTENT_SETTING_BLOCK;
}
host_content_settings_map_->SetDefaultContentSetting(
ContentSettingsType::PLUGINS, plugin_policy);
}
}
return host_content_settings_map_.get();
}
void CefBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
visitedlink_master_->AddURLs(urls);
}
void CefBrowserContext::RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) {
// Called when visited links will not or cannot be loaded from disk.
enumerator->OnComplete(true);
}
void CefBrowserContext::OnRenderFrameCreated( void CefBrowserContext::OnRenderFrameCreated(
CefRequestContextImpl* request_context, CefRequestContextImpl* request_context,
int render_process_id, int render_process_id,
@@ -618,15 +254,14 @@ void CefBrowserContext::OnRenderFrameCreated(
handler_map_.AddHandler(render_process_id, render_frame_id, handler_map_.AddHandler(render_process_id, render_frame_id,
frame_tree_node_id, handler); frame_tree_node_id, handler);
if (resource_context_) { if (iothread_state_) {
// Using base::Unretained() is safe because both this callback and // Using base::Unretained() is safe because both this callback and
// possible deletion of |resource_context_| will execute on the IO thread, // possible deletion of |iothread_state_| will execute on the IO thread,
// and this callback will be executed first. // and this callback will be executed first.
CEF_POST_TASK(CEF_IOT, CEF_POST_TASK(CEF_IOT, base::Bind(&CefIOThreadState::AddHandler,
base::Bind(&CefResourceContext::AddHandler, base::Unretained(iothread_state_.get()),
base::Unretained(resource_context_.get()), render_process_id, render_frame_id,
render_process_id, render_frame_id, frame_tree_node_id, handler));
frame_tree_node_id, handler));
} }
} }
} }
@@ -657,15 +292,14 @@ void CefBrowserContext::OnRenderFrameDeleted(
handler_map_.RemoveHandler(render_process_id, render_frame_id, handler_map_.RemoveHandler(render_process_id, render_frame_id,
frame_tree_node_id); frame_tree_node_id);
if (resource_context_) { if (iothread_state_) {
// Using base::Unretained() is safe because both this callback and // Using base::Unretained() is safe because both this callback and
// possible deletion of |resource_context_| will execute on the IO thread, // possible deletion of |iothread_state_| will execute on the IO thread,
// and this callback will be executed first. // and this callback will be executed first.
CEF_POST_TASK( CEF_POST_TASK(CEF_IOT, base::Bind(&CefIOThreadState::RemoveHandler,
CEF_IOT, base::Unretained(iothread_state_.get()),
base::Bind(&CefResourceContext::RemoveHandler, render_process_id, render_frame_id,
base::Unretained(resource_context_.get()), frame_tree_node_id));
render_process_id, render_frame_id, frame_tree_node_id));
} }
} }
@@ -767,48 +401,74 @@ void CefBrowserContext::ClearPluginLoadDecision(int render_process_id) {
} }
void CefBrowserContext::RegisterSchemeHandlerFactory( void CefBrowserContext::RegisterSchemeHandlerFactory(
const std::string& scheme_name, const CefString& scheme_name,
const std::string& domain_name, const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory) { CefRefPtr<CefSchemeHandlerFactory> factory) {
if (resource_context_) { if (iothread_state_) {
// Using base::Unretained() is safe because both this callback and possible // Using base::Unretained() is safe because both this callback and possible
// deletion of |resource_context_| will execute on the IO thread, and this // deletion of |iothread_state_| will execute on the IO thread, and this
// callback will be executed first. // callback will be executed first.
CEF_POST_TASK(CEF_IOT, CEF_POST_TASK(CEF_IOT,
base::Bind(&CefResourceContext::RegisterSchemeHandlerFactory, base::Bind(&CefIOThreadState::RegisterSchemeHandlerFactory,
base::Unretained(resource_context_.get()), base::Unretained(iothread_state_.get()),
scheme_name, domain_name, factory)); scheme_name, domain_name, factory));
} }
} }
void CefBrowserContext::ClearSchemeHandlerFactories() { void CefBrowserContext::ClearSchemeHandlerFactories() {
if (resource_context_) { if (iothread_state_) {
// Using base::Unretained() is safe because both this callback and possible // Using base::Unretained() is safe because both this callback and possible
// deletion of |resource_context_| will execute on the IO thread, and this // deletion of |iothread_state_| will execute on the IO thread, and this
// callback will be executed first. // callback will be executed first.
CEF_POST_TASK(CEF_IOT, CEF_POST_TASK(CEF_IOT,
base::Bind(&CefResourceContext::ClearSchemeHandlerFactories, base::Bind(&CefIOThreadState::ClearSchemeHandlerFactories,
base::Unretained(resource_context_.get()))); base::Unretained(iothread_state_.get())));
} }
} }
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() { void CefBrowserContext::LoadExtension(
CEF_REQUIRE_UIT(); const CefString& root_directory,
return GetDefaultStoragePartition(this)->GetNetworkContext(); CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler,
CefRefPtr<CefRequestContext> loader_context) {
NOTIMPLEMENTED();
if (handler)
handler->OnExtensionLoadFailed(ERR_ABORTED);
} }
DownloadPrefs* CefBrowserContext::GetDownloadPrefs() { bool CefBrowserContext::GetExtensions(std::vector<CefString>& extension_ids) {
CEF_REQUIRE_UIT(); NOTIMPLEMENTED();
if (!download_prefs_) { return false;
download_prefs_.reset(new DownloadPrefs(this)); }
}
return download_prefs_.get(); CefRefPtr<CefExtension> CefBrowserContext::GetExtension(
const CefString& extension_id) {
NOTIMPLEMENTED();
return nullptr;
}
bool CefBrowserContext::UnloadExtension(const CefString& extension_id) {
NOTIMPLEMENTED();
return false;
} }
bool CefBrowserContext::IsPrintPreviewSupported() const { bool CefBrowserContext::IsPrintPreviewSupported() const {
CEF_REQUIRE_UIT(); return true;
if (!extensions::PrintPreviewEnabled()) }
return false;
void CefBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {}
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
CEF_REQUIRE_UIT();
auto browser_context = AsBrowserContext();
return browser_context->GetDefaultStoragePartition(browser_context)
->GetNetworkContext();
}
CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
CEF_REQUIRE_UIT();
if (!media_router_manager_) {
media_router_manager_.reset(new CefMediaRouterManager(AsBrowserContext()));
}
return media_router_manager_.get();
} }

View File

@@ -7,21 +7,17 @@
#pragma once #pragma once
#include <set> #include <set>
#include <vector>
#include "include/cef_request_context_handler.h" #include "include/cef_request_context_handler.h"
#include "libcef/browser/chrome_profile_stub.h"
#include "libcef/browser/request_context_handler_map.h" #include "libcef/browser/request_context_handler_map.h"
#include "libcef/browser/resource_context.h"
#include "base/callback.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/download/download_prefs.h" #include "base/optional.h"
#include "chrome/common/plugin.mojom.h" #include "chrome/common/plugin.mojom.h"
#include "components/proxy_config/pref_proxy_config_tracker.h" #include "services/network/public/mojom/network_context.mojom.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "url/origin.h" #include "url/origin.h"
/* /*
@@ -29,31 +25,30 @@
// //
// WC = WebContents // WC = WebContents
// Content API representation of a browser. Created by BHI or the system (for // Content API representation of a browser. Created by BHI or the system (for
// popups) and owned by BHI. Keeps a pointer to BC. // popups) and owned by BHI. Keeps a pointer to the content::BrowserContext.
// //
// BHI = CefBrowserHostImpl // BHI = CefBrowserHostImpl
// Implements the CefBrowser and CefBrowserHost interfaces which are exposed // Implements the CefBrowser and CefBrowserHost interfaces which are exposed
// to clients. References an RCI instance. Owns a WC. Life span is controlled // to clients. References an RCI instance. Owns a WC. Lifespan is controlled
// by client references and CefContentBrowserClient. // by client references and CefBrowserInfoManager (until the browser has
// closed).
// //
// RCI = CefRequestContextImpl // RCI = CefRequestContextImpl
// Implements the CefRequestContext interface which is exposed to clients. // Implements the CefRequestContext interface which is exposed to clients.
// References the isolated BC. // Creates or references a BC. Lifespan is controlled by client references and
// BrowserMainParts (for the global RCI).
// //
// BC = CefBrowserContext // BC = CefBrowserContext
// Entry point from WC when using an isolated RCI. Owns the RC and creates the // Is/owns the content::BrowserContext which is the entry point from WC.
// SPI indirectly. Owned by CefBrowserMainParts for the global context or RCI // Owns the IOTS and creates the SPI indirectly. Potentially shared by
// for non-global contexts. // multiple RCI. Deletes itself when no longer needed by RCI.
// //
// SPI = content::StoragePartitionImpl // SPI = content::StoragePartitionImpl
// Owns storage-related objects like Quota, IndexedDB, Cache, etc. Created by // Owns storage-related objects like Quota, IndexedDB, Cache, etc. Created by
// StoragePartitionImplMap::Get(). Provides access to the URCG. Life span is // StoragePartitionImplMap::Get(). Life span is controlled indirectly by BC.
// controlled indirectly by BC.
// //
// RC = CefResourceContext // IOTS = CefIOThreadState
// Acts as a bridge for resource loading. Network request life span is tied to // Stores state for access on the IO thread. Life span is controlled by BC.
// this object. Must be destroyed before the associated URCG. Life span is
// controlled by BC.
// //
// //
// Relationship diagram: // Relationship diagram:
@@ -61,141 +56,65 @@
// own = ownership (std::unique_ptr) // own = ownership (std::unique_ptr)
// ptr = raw pointer // ptr = raw pointer
// //
// CefBrowserMainParts // BHI -ref-> RCI -ptr-> BC -own-> SPI, IOTS
// | // ^
// own // BHI -own-> WC -ptr--/
// v
// BHI -own-> WC -ptr-> BC -own-> SPI
//
// BHI -ref-> RCI -own-> BC -own-> RC
// //
// //
// How shutdown works: // How shutdown works:
// 1. CefBrowserHostImpl is destroyed on any thread due to browser close, // 1. CefBrowserHostImpl::DestroyBrowser is called on the UI thread after the
// ref release, etc. // browser is closed and deletes the WebContents.
// 1. CefBrowserHostImpl is destroyed on any thread when the last reference
// is released.
// 2. CefRequestContextImpl is destroyed (possibly asynchronously) on the UI // 2. CefRequestContextImpl is destroyed (possibly asynchronously) on the UI
// thread due to CefBrowserHostImpl destruction, ref release, etc. // thread when the last reference is released.
// 3. CefBrowserContext is destroyed on the UI thread due to // 3. CefBrowserContext is destroyed on the UI thread when no longer needed
// CefRequestContextImpl destruction or deletion in // by any CefRequestContextImpl (via RemoveCefRequestContext).
// CefBrowserMainParts::PostMainMessageLoopRun(). // 4. CefIOThreadState is destroyed asynchronously on the IO thread after
// 4. CefResourceContext is destroyed asynchronously on the IO thread due to // the owning CefBrowserContext is destroyed.
// CefBrowserContext destruction. This cancels/destroys any pending
// network requests.
*/ */
class CefDownloadManagerDelegate; namespace content {
class BrowserContext;
}
class CefMediaRouterManager;
class CefRequestContextImpl; class CefRequestContextImpl;
class CefSSLHostStateDelegate; class CefIOThreadState;
class CefVisitedLinkListener; class Profile;
class HostContentSettingsMap;
class PrefService;
namespace extensions { // Main entry point for configuring behavior on a per-RequestContext basis. The
class CefExtensionSystem; // content::BrowserContext represented by this class is passed to
} // WebContents::Create in CefBrowserHostImpl::CreateInternal. Only accessed on
// the UI thread unless otherwise indicated.
namespace visitedlink { class CefBrowserContext {
class VisitedLinkWriter;
}
// Main entry point for configuring behavior on a per-browser basis. An instance
// of this class is passed to WebContents::Create in CefBrowserHostImpl::
// CreateInternal. Only accessed on the UI thread unless otherwise indicated.
class CefBrowserContext : public ChromeProfileStub,
public visitedlink::VisitedLinkDelegate {
public: public:
explicit CefBrowserContext(const CefRequestContextSettings& settings);
// Returns the existing instance, if any, associated with the specified // Returns the existing instance, if any, associated with the specified
// |cache_path|. // |cache_path|.
static CefBrowserContext* GetForCachePath(const base::FilePath& cache_path); static CefBrowserContext* FromCachePath(const base::FilePath& cache_path);
// Returns the existing instance, if any, associated with the specified IDs. // Returns the existing instance, if any, associated with the specified IDs.
// See comments on IsAssociatedContext() for usage. // See comments on IsAssociatedContext() for usage.
static CefBrowserContext* GetForIDs(int render_process_id, static CefBrowserContext* FromIDs(int render_process_id,
int render_frame_id, int render_frame_id,
int frame_tree_node_id, int frame_tree_node_id,
bool require_frame_match); bool require_frame_match);
// Returns the underlying CefBrowserContext if any. // Returns the underlying CefBrowserContext if any.
static CefBrowserContext* GetForContext(content::BrowserContext* context); static CefBrowserContext* FromBrowserContext(
const content::BrowserContext* context);
// Returns all existing CefBrowserContext. // Returns all existing CefBrowserContext.
static std::vector<CefBrowserContext*> GetAll(); static std::vector<CefBrowserContext*> GetAll();
// Must be called immediately after this object is created. // Returns the content and chrome layer representations of the context.
void Initialize(); virtual content::BrowserContext* AsBrowserContext() = 0;
virtual Profile* AsProfile() = 0;
// Track associated CefRequestContextImpl objects. This object will delete // Called from CefRequestContextImpl to track associated objects. This
// itself when the count reaches zero. // object will delete itself when the count reaches zero.
void AddCefRequestContext(CefRequestContextImpl* context); void AddCefRequestContext(CefRequestContextImpl* context);
void RemoveCefRequestContext(CefRequestContextImpl* context); virtual void RemoveCefRequestContext(CefRequestContextImpl* context);
// BrowserContext methods.
content::ResourceContext* GetResourceContext() override;
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
void SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) override;
base::FilePath GetPath() override;
base::FilePath GetPath() const override;
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath& partition_path) override;
bool IsOffTheRecord() const override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() 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;
// Profile methods.
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::ProfilePolicyConnector* GetProfilePolicyConnector() override;
const policy::ProfilePolicyConnector* GetProfilePolicyConnector()
const override;
// Values checked in ProfileNetworkContextService::CreateNetworkContextParams
// when creating the NetworkContext.
bool ShouldRestoreOldSessionCookies() override {
return should_persist_session_cookies_;
}
bool ShouldPersistSessionCookies() override {
return should_persist_session_cookies_;
}
base::Optional<std::vector<std::string>> GetCookieableSchemes() override {
return cookieable_schemes_;
}
// visitedlink::VisitedLinkDelegate methods.
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
// Returns the settings associated with this object. Safe to call from any
// thread.
const CefRequestContextSettings& GetSettings() const;
// Settings for plugins and extensions.
HostContentSettingsMap* GetHostContentSettingsMap();
// Called from CefBrowserHostImpl::DidNavigateAnyFrame to update the table of
// visited links.
void AddVisitedURLs(const std::vector<GURL>& urls);
// Called from CefRequestContextImpl::OnRenderFrameCreated. // Called from CefRequestContextImpl::OnRenderFrameCreated.
void OnRenderFrameCreated(CefRequestContextImpl* request_context, void OnRenderFrameCreated(CefRequestContextImpl* request_context,
@@ -251,70 +170,72 @@ class CefBrowserContext : public ChromeProfileStub,
void ClearPluginLoadDecision(int render_process_id); void ClearPluginLoadDecision(int render_process_id);
// Called from CefRequestContextImpl methods of the same name. // Called from CefRequestContextImpl methods of the same name.
void RegisterSchemeHandlerFactory(const std::string& scheme_name, void RegisterSchemeHandlerFactory(const CefString& scheme_name,
const std::string& domain_name, const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory); CefRefPtr<CefSchemeHandlerFactory> factory);
void ClearSchemeHandlerFactories(); void ClearSchemeHandlerFactories();
// TODO(chrome-runtime): Make these extension methods pure virtual.
virtual void LoadExtension(const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler,
CefRefPtr<CefRequestContext> loader_context);
virtual bool GetExtensions(std::vector<CefString>& extension_ids);
virtual CefRefPtr<CefExtension> GetExtension(const CefString& extension_id);
// Called from CefExtensionImpl::Unload().
virtual bool UnloadExtension(const CefString& extension_id);
// Returns true if this context supports print preview.
virtual bool IsPrintPreviewSupported() const;
// Called from CefBrowserHostImpl::DidNavigateAnyFrame to update the table of
// visited links.
virtual void AddVisitedURLs(const std::vector<GURL>& urls);
network::mojom::NetworkContext* GetNetworkContext(); network::mojom::NetworkContext* GetNetworkContext();
void set_should_persist_session_cookies(bool value) { CefMediaRouterManager* GetMediaRouterManager();
should_persist_session_cookies_ = value;
} using CookieableSchemes = base::Optional<std::vector<std::string>>;
void set_cookieable_schemes( void set_cookieable_schemes(const CookieableSchemes& schemes) {
base::Optional<std::vector<std::string>> schemes) {
cookieable_schemes_ = schemes; cookieable_schemes_ = schemes;
} }
CookieableSchemes cookieable_schemes() const { return cookieable_schemes_; }
CefResourceContext* resource_context() const { // These accessors are safe to call from any thread because the values don't
return resource_context_.get(); // change during this object's lifespan.
} const CefRequestContextSettings& settings() const { return settings_; }
extensions::CefExtensionSystem* extension_system() const { base::FilePath cache_path() const { return cache_path_; }
return extension_system_; CefIOThreadState* iothread_state() const { return iothread_state_.get(); }
}
// Called from DownloadPrefs::FromBrowserContext. // Used to hold a WeakPtr reference to this this object. The Getter returns
DownloadPrefs* GetDownloadPrefs(); // nullptr if this object has already been destroyed.
using Getter = base::RepeatingCallback<CefBrowserContext*()>;
Getter getter() const { return getter_; }
// Returns true if this context supports print preview. protected:
bool IsPrintPreviewSupported() const; explicit CefBrowserContext(const CefRequestContextSettings& settings);
virtual ~CefBrowserContext();
// Will be called immediately after this object is created.
virtual void Initialize();
// Will be called immediately before this object is deleted.
virtual void Shutdown();
// Members initialized during construction or Initialize() are safe to access
// from any thread.
const CefRequestContextSettings settings_;
base::FilePath cache_path_;
private: private:
// Allow deletion via std::unique_ptr(). std::unique_ptr<CefIOThreadState> iothread_state_;
friend std::default_delete<CefBrowserContext>; CookieableSchemes cookieable_schemes_;
std::unique_ptr<CefMediaRouterManager> media_router_manager_;
~CefBrowserContext() override;
// Members initialized during construction are safe to access from any thread.
CefRequestContextSettings settings_;
base::FilePath cache_path_;
// CefRequestContextImpl objects referencing this object. // CefRequestContextImpl objects referencing this object.
std::set<CefRequestContextImpl*> request_context_set_; std::set<CefRequestContextImpl*> request_context_set_;
std::unique_ptr<PrefService> pref_service_;
std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_master_;
// |visitedlink_listener_| is owned by visitedlink_master_.
CefVisitedLinkListener* visitedlink_listener_;
bool should_persist_session_cookies_ = false;
base::Optional<std::vector<std::string>> cookieable_schemes_;
std::unique_ptr<CefResourceContext> resource_context_;
// Owned by the KeyedService system.
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_;
// Map IDs to CefRequestContextHandler objects. // Map IDs to CefRequestContextHandler objects.
CefRequestContextHandlerMap handler_map_; CefRequestContextHandlerMap handler_map_;
@@ -338,6 +259,13 @@ class CefBrowserContext : public ChromeProfileStub,
typedef std::set<int> NodeIdSet; typedef std::set<int> NodeIdSet;
NodeIdSet node_id_set_; NodeIdSet node_id_set_;
#if DCHECK_IS_ON()
bool is_shutdown_ = false;
#endif
Getter getter_;
base::WeakPtrFactory<CefBrowserContext> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserContext); DISALLOW_COPY_AND_ASSIGN(CefBrowserContext);
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -42,15 +42,20 @@ class Extension;
class ExtensionHost; class ExtensionHost;
} // namespace extensions } // namespace extensions
namespace gfx {
class ImageSkia;
}
#if defined(USE_AURA) #if defined(USE_AURA)
namespace views { namespace views {
class Widget; class Widget;
} }
#endif // defined(USE_AURA) #endif // defined(USE_AURA)
class CefAudioCapturer;
class CefBrowserInfo; class CefBrowserInfo;
class CefBrowserPlatformDelegate; class CefBrowserPlatformDelegate;
class CefDevToolsFrontend; class CefDevToolsManager;
class SiteInstance; class SiteInstance;
// Implementation of CefBrowser. // Implementation of CefBrowser.
@@ -191,6 +196,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
const CefPoint& inspect_element_at) override; const CefPoint& inspect_element_at) override;
void CloseDevTools() override; void CloseDevTools() override;
bool HasDevTools() override; bool HasDevTools() override;
bool SendDevToolsMessage(const void* message, size_t message_size) override;
int ExecuteDevToolsMethod(int message_id,
const CefString& method,
CefRefPtr<CefDictionaryValue> params) override;
CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
CefRefPtr<CefDevToolsMessageObserver> observer) override;
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor, void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
bool current_only) override; bool current_only) override;
void SetMouseCursorChangeDisabled(bool disabled) override; void SetMouseCursorChangeDisabled(bool disabled) override;
@@ -274,9 +285,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Returns true if this browser is views-hosted. // Returns true if this browser is views-hosted.
bool IsViewsHosted() const; bool IsViewsHosted() const;
// Returns true if this browser supports print preview.
bool IsPrintPreviewSupported() const;
// Returns true if this browser supports picture-in-picture. // Returns true if this browser supports picture-in-picture.
bool IsPictureInPictureSupported() const; bool IsPictureInPictureSupported() const;
@@ -343,27 +351,20 @@ class CefBrowserHostImpl : public CefBrowserHost,
} }
// Accessors that must be called on the UI thread. // Accessors that must be called on the UI thread.
content::BrowserContext* GetBrowserContext(); content::BrowserContext* GetBrowserContext() const;
extensions::ExtensionHost* extension_host() const { return extension_host_; } extensions::ExtensionHost* GetExtensionHost() const;
void OnSetFocus(cef_focus_source_t source); void OnSetFocus(cef_focus_source_t source);
// Run the file chooser dialog specified by |params|. Only a single dialog may // Run the file chooser dialog specified by |params|. Only a single dialog may
// be pending at any given time. |callback| will be executed asynchronously // be pending at any given time. |callback| will be executed asynchronously
// after the dialog is dismissed or if another dialog is already pending. // after the dialog is dismissed or if another dialog is already pending.
void RunFileChooser( void RunFileChooser(const CefFileDialogRunner::FileChooserParams& params,
const CefFileDialogRunner::FileChooserParams& params, CefFileDialogRunner::RunFileChooserCallback callback);
const CefFileDialogRunner::RunFileChooserCallback& callback);
bool HandleContextMenu(content::WebContents* web_contents, bool HandleContextMenu(content::WebContents* web_contents,
const content::ContextMenuParams& params); const content::ContextMenuParams& params);
// Returns the WebContents most likely to handle an action. If extensions are
// enabled and this browser has a full-page guest (for example, a full-page
// PDF viewer extension) then the guest's WebContents will be returned.
// Otherwise, the browser's WebContents will be returned.
content::WebContents* GetActionableWebContents() const;
enum DestructionState { enum DestructionState {
DESTRUCTION_STATE_NONE = 0, DESTRUCTION_STATE_NONE = 0,
DESTRUCTION_STATE_PENDING, DESTRUCTION_STATE_PENDING,
@@ -379,6 +380,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool ShouldTransferNavigation(bool is_main_frame_navigation) override; bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
void AddNewContents(content::WebContents* source, void AddNewContents(content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents, std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const gfx::Rect& initial_rect, const gfx::Rect& initial_rect,
bool user_gesture, bool user_gesture,
@@ -397,7 +399,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool proceed, bool proceed,
bool* proceed_to_fire_unload) override; bool* proceed_to_fire_unload) override;
bool TakeFocus(content::WebContents* source, bool reverse) override; bool TakeFocus(content::WebContents* source, bool reverse) override;
bool HandleContextMenu(content::RenderFrameHost* render_frame_host, bool HandleContextMenu(content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params) override; const content::ContextMenuParams& params) override;
content::KeyboardEventProcessingResult PreHandleKeyboardEvent( content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
@@ -429,12 +430,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::JavaScriptDialogManager* GetJavaScriptDialogManager( content::JavaScriptDialogManager* GetJavaScriptDialogManager(
content::WebContents* source) override; content::WebContents* source) override;
void RunFileChooser(content::RenderFrameHost* render_frame_host, void RunFileChooser(content::RenderFrameHost* render_frame_host,
std::unique_ptr<content::FileSelectListener> listener, scoped_refptr<content::FileSelectListener> listener,
const blink::mojom::FileChooserParams& params) override; const blink::mojom::FileChooserParams& params) override;
bool EmbedsFullscreenWidget() override; bool EmbedsFullscreenWidget() override;
void EnterFullscreenModeForTab( void EnterFullscreenModeForTab(
content::WebContents* web_contents, content::RenderFrameHost* requesting_frame,
const GURL& origin,
const blink::mojom::FullscreenOptions& options) override; const blink::mojom::FullscreenOptions& options) override;
void ExitFullscreenModeForTab(content::WebContents* web_contents) override; void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
bool IsFullscreenForTabOrPending( bool IsFullscreenForTabOrPending(
@@ -458,7 +458,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host, bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const GURL& security_origin, const GURL& security_origin,
blink::mojom::MediaStreamType type) override; blink::mojom::MediaStreamType type) override;
bool IsNeverVisible(content::WebContents* web_contents) override; bool IsNeverComposited(content::WebContents* web_contents) override;
content::PictureInPictureResult EnterPictureInPicture( content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents, content::WebContents* web_contents,
const viz::SurfaceId& surface_id, const viz::SurfaceId& surface_id,
@@ -481,14 +481,14 @@ class CefBrowserHostImpl : public CefBrowserHost,
void DocumentAvailableInMainFrame() override; void DocumentAvailableInMainFrame() override;
void DidFailLoad(content::RenderFrameHost* render_frame_host, void DidFailLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url, const GURL& validated_url,
int error_code, int error_code) override;
const base::string16& error_description) override;
void TitleWasSet(content::NavigationEntry* entry) override; void TitleWasSet(content::NavigationEntry* entry) override;
void PluginCrashed(const base::FilePath& plugin_path, void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override; base::ProcessId plugin_pid) override;
void DidUpdateFaviconURL( void DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& candidates) override; content::RenderFrameHost* render_frame_host,
bool OnMessageReceived(const IPC::Message& message) override; const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
void OnAudioStateChanged(bool audible) override;
bool OnMessageReceived(const IPC::Message& message, bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override; content::RenderFrameHost* render_frame_host) override;
void OnFrameFocused(content::RenderFrameHost* render_frame_host) override; void OnFrameFocused(content::RenderFrameHost* render_frame_host) override;
@@ -497,9 +497,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
void AccessibilityLocationChangesReceived( void AccessibilityLocationChangesReceived(
const std::vector<content::AXLocationChangeNotificationDetails>& locData) const std::vector<content::AXLocationChangeNotificationDetails>& locData)
override; override;
void OnWebContentsFocused( void OnWebContentsFocused(
content::RenderWidgetHost* render_widget_host) override; content::RenderWidgetHost* render_widget_host) override;
void WebContentsDestroyed() override;
// Manage observer objects. The observer must either outlive this object or // Manage observer objects. The observer must either outlive this object or
// remove itself before destruction. These methods can only be called on the // remove itself before destruction. These methods can only be called on the
@@ -507,6 +507,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
void AddObserver(Observer* observer); void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer); void RemoveObserver(Observer* observer);
bool HasObserver(Observer* observer) const; bool HasObserver(Observer* observer) const;
class NavigationLock final { class NavigationLock final {
private: private:
friend class CefBrowserHostImpl; friend class CefBrowserHostImpl;
@@ -522,7 +523,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
std::unique_ptr<NavigationLock> CreateNavigationLock(); std::unique_ptr<NavigationLock> CreateNavigationLock();
private: private:
class DevToolsWebContentsObserver; friend class CefBrowserPlatformDelegateAlloy;
static CefRefPtr<CefBrowserHostImpl> CreateInternal( static CefRefPtr<CefBrowserHostImpl> CreateInternal(
const CefBrowserSettings& settings, const CefBrowserSettings& settings,
@@ -551,20 +552,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate, std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension); CefRefPtr<CefExtension> extension);
void set_owned_web_contents(content::WebContents* owned_contents);
// Give the platform delegate an opportunity to create the host window. // Give the platform delegate an opportunity to create the host window.
bool CreateHostWindow(); bool CreateHostWindow();
// Create/delete the host for extensions.
void CreateExtensionHost(const extensions::Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
extensions::ViewType host_type);
void DestroyExtensionHost();
void OnExtensionHostDeleted();
// Returns true if navigation actions are currently locked. // Returns true if navigation actions are currently locked.
bool navigation_locked() const; bool navigation_locked() const;
// Action to be executed once the navigation lock is released. // Action to be executed once the navigation lock is released.
@@ -580,12 +570,15 @@ class CefBrowserHostImpl : public CefBrowserHost,
void OnFullscreenModeChange(bool fullscreen); void OnFullscreenModeChange(bool fullscreen);
void OnTitleChange(const base::string16& title); void OnTitleChange(const base::string16& title);
void OnDevToolsWebContentsDestroyed();
// Create the CefFileDialogManager if it doesn't already exist. // Create the CefFileDialogManager if it doesn't already exist.
void EnsureFileDialogManager(); void EnsureFileDialogManager();
void ConfigureAutoResize(); void StartAudioCapturer();
void OnRecentlyAudibleTimerFired();
bool EnsureDevToolsManager();
void InitializeDevToolsRegistrationOnUIThread(
CefRefPtr<CefRegistration> registration);
CefBrowserSettings settings_; CefBrowserSettings settings_;
CefRefPtr<CefClient> client_; CefRefPtr<CefClient> client_;
@@ -595,28 +588,24 @@ class CefBrowserHostImpl : public CefBrowserHost,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate_; std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate_;
const bool is_windowless_; const bool is_windowless_;
const bool is_views_hosted_; const bool is_views_hosted_;
CefWindowHandle host_window_handle_; CefWindowHandle host_window_handle_ = kNullWindowHandle;
CefRefPtr<CefExtension> extension_;
// Non-nullptr if this object owns the WebContents. Will be nullptr for popup bool is_background_host_ = false;
// browsers between the calls to WebContentsCreated() and AddNewContents(),
// and may never be set if the parent browser is destroyed during popup
// creation.
std::unique_ptr<content::WebContents> owned_web_contents_;
// Volatile state information. All access must be protected by the state lock. // Volatile state information. All access must be protected by the state lock.
base::Lock state_lock_; base::Lock state_lock_;
bool is_loading_; bool is_loading_ = false;
bool can_go_back_; bool can_go_back_ = false;
bool can_go_forward_; bool can_go_forward_ = false;
bool has_document_; bool has_document_ = false;
bool is_fullscreen_; bool is_fullscreen_ = false;
// The currently focused frame, or nullptr if the main frame is focused. // The currently focused frame, or nullptr if the main frame is focused.
CefRefPtr<CefFrameHostImpl> focused_frame_; CefRefPtr<CefFrameHostImpl> focused_frame_;
// Represents the current browser destruction state. Only accessed on the UI // Represents the current browser destruction state. Only accessed on the UI
// thread. // thread.
DestructionState destruction_state_; DestructionState destruction_state_ = DESTRUCTION_STATE_NONE;
// Navigation will not occur while |navigation_lock_count_| > 0. // Navigation will not occur while |navigation_lock_count_| > 0.
// |pending_navigation_action_| will be executed when the lock is released. // |pending_navigation_action_| will be executed when the lock is released.
@@ -626,18 +615,18 @@ class CefBrowserHostImpl : public CefBrowserHost,
// True if the OS window hosting the browser has been destroyed. Only accessed // True if the OS window hosting the browser has been destroyed. Only accessed
// on the UI thread. // on the UI thread.
bool window_destroyed_; bool window_destroyed_ = false;
// True if currently in the OnSetFocus callback. Only accessed on the UI // True if currently in the OnSetFocus callback. Only accessed on the UI
// thread. // thread.
bool is_in_onsetfocus_; bool is_in_onsetfocus_ = false;
// True if the focus is currently on an editable field on the page. Only // True if the focus is currently on an editable field on the page. Only
// accessed on the UI thread. // accessed on the UI thread.
bool focus_on_editable_field_; bool focus_on_editable_field_ = false;
// True if mouse cursor change is disabled. // True if mouse cursor change is disabled.
bool mouse_cursor_change_disabled_; bool mouse_cursor_change_disabled_ = false;
// Used for managing notification subscriptions. // Used for managing notification subscriptions.
std::unique_ptr<content::NotificationRegistrar> registrar_; std::unique_ptr<content::NotificationRegistrar> registrar_;
@@ -651,28 +640,19 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Used for creating and managing context menus. // Used for creating and managing context menus.
std::unique_ptr<CefMenuManager> menu_manager_; std::unique_ptr<CefMenuManager> menu_manager_;
// Track the lifespan of the frontend WebContents associated with this // Used for creating and managing DevTools instances.
// browser. std::unique_ptr<CefDevToolsManager> devtools_manager_;
std::unique_ptr<DevToolsWebContentsObserver> devtools_observer_;
// CefDevToolsFrontend will delete itself when the frontend WebContents is
// destroyed.
CefDevToolsFrontend* devtools_frontend_;
// Observers that want to be notified of changes to this object. // Observers that want to be notified of changes to this object.
base::ObserverList<Observer>::Unchecked observers_; base::ObserverList<Observer>::Unchecked observers_;
// Used to provide unique incremental IDs for each find request. // Used for capturing audio for CefAudioHandler.
int find_request_id_counter_ = 0; std::unique_ptr<CefAudioCapturer> audio_capturer_;
// Used when the browser is hosting an extension. // Timer for determining when "recently audible" transitions to false. This
extensions::ExtensionHost* extension_host_ = nullptr; // starts running when a tab stops being audible, and is canceled if it starts
CefRefPtr<CefExtension> extension_; // being audible again before it fires.
bool is_background_host_ = false; base::OneShotTimer recently_audible_timer_;
// Used with auto-resize.
bool auto_resize_enabled_ = false;
gfx::Size auto_resize_min_;
gfx::Size auto_resize_max_;
IMPLEMENT_REFCOUNTING(CefBrowserHostImpl); IMPLEMENT_REFCOUNTING(CefBrowserHostImpl);
DISALLOW_COPY_AND_ASSIGN(CefBrowserHostImpl); DISALLOW_COPY_AND_ASSIGN(CefBrowserHostImpl);

View File

@@ -22,6 +22,8 @@
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/child_process_host.h" #include "content/public/common/child_process_host.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
namespace { namespace {
@@ -115,26 +117,13 @@ bool CefBrowserInfoManager::CanCreateWindow(
bool* no_javascript_access) { bool* no_javascript_access) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
bool is_guest_view = false; content::OpenURLParams params(target_url, referrer, disposition,
CefRefPtr<CefBrowserHostImpl> browser = ui::PAGE_TRANSITION_LINK,
extensions::GetOwnerBrowserForHost(opener, &is_guest_view); /*is_renderer_initiated=*/true);
DCHECK(browser.get()); params.user_gesture = user_gesture;
if (!browser.get()) {
// Cancel the popup.
return false;
}
if (is_guest_view) {
content::OpenURLParams params(target_url, referrer, disposition,
ui::PAGE_TRANSITION_LINK, true);
params.user_gesture = user_gesture;
// Pass navigation to the owner browser.
CEF_POST_TASK(
CEF_UIT,
base::Bind(base::IgnoreResult(&CefBrowserHostImpl::OpenURLFromTab),
browser.get(), nullptr, params));
CefRefPtr<CefBrowserHostImpl> browser;
if (!MaybeAllowNavigation(opener, params, browser) || !browser) {
// Cancel the popup. // Cancel the popup.
return false; return false;
} }
@@ -168,7 +157,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
CefPopupFeatures cef_features; CefPopupFeatures cef_features;
TranslatePopupFeatures(features, cef_features); TranslatePopupFeatures(features, cef_features);
#if (defined(OS_WIN) || defined(OS_MACOSX)) #if (defined(OS_WIN) || defined(OS_MAC))
// Default to the size from the popup features. // Default to the size from the popup features.
if (cef_features.xSet) if (cef_features.xSet)
window_info->x = cef_features.x; window_info->x = cef_features.x;
@@ -369,6 +358,38 @@ CefBrowserInfoManager::GetBrowserInfoForFrameRoute(int render_process_id,
return GetBrowserInfo(render_process_id, render_routing_id, is_guest_view); return GetBrowserInfo(render_process_id, render_routing_id, is_guest_view);
} }
bool CefBrowserInfoManager::MaybeAllowNavigation(
content::RenderFrameHost* opener,
const content::OpenURLParams& params,
CefRefPtr<CefBrowserHostImpl>& browser_out) const {
CEF_REQUIRE_UIT();
bool is_guest_view = false;
CefRefPtr<CefBrowserHostImpl> browser =
extensions::GetOwnerBrowserForHost(opener, &is_guest_view);
if (!browser) {
// Print preview uses a modal dialog where we don't own the WebContents.
// Allow that navigation to proceed.
return true;
}
if (is_guest_view && !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. All other navigations
// are passed to the owner browser.
CEF_POST_TASK(
CEF_UIT,
base::Bind(base::IgnoreResult(&CefBrowserHostImpl::OpenURLFromTab),
browser.get(), nullptr, params));
return false;
}
browser_out = browser;
return true;
}
scoped_refptr<CefBrowserInfo> scoped_refptr<CefBrowserInfo>
CefBrowserInfoManager::GetBrowserInfoForFrameTreeNode(int frame_tree_node_id, CefBrowserInfoManager::GetBrowserInfoForFrameTreeNode(int frame_tree_node_id,
bool* is_guest_view) { bool* is_guest_view) {

View File

@@ -25,6 +25,7 @@ struct WebWindowFeatures;
} }
namespace content { namespace content {
struct OpenURLParams;
struct Referrer; struct Referrer;
class RenderFrameHost; class RenderFrameHost;
class RenderViewHostDelegateView; class RenderViewHostDelegateView;
@@ -63,7 +64,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
bool is_windowless, bool is_windowless,
CefRefPtr<CefDictionaryValue> extra_info); CefRefPtr<CefDictionaryValue> extra_info);
// Called from CefContentBrowserClient::CanCreateWindow. See comments on // Called from AlloyContentBrowserClient::CanCreateWindow. See comments on
// PendingPopup for more information. // PendingPopup for more information.
bool CanCreateWindow(content::RenderFrameHost* opener, bool CanCreateWindow(content::RenderFrameHost* opener,
const GURL& target_url, const GURL& target_url,
@@ -138,12 +139,19 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
typedef std::list<scoped_refptr<CefBrowserInfo>> BrowserInfoList; typedef std::list<scoped_refptr<CefBrowserInfo>> BrowserInfoList;
BrowserInfoList GetBrowserInfoList(); BrowserInfoList GetBrowserInfoList();
// Returns true if the navigation should be allowed to proceed, or false if
// the navigation will instead be sent via OpenURLFromTab. If allowed,
// |browser| will be set to the target browser if any.
bool MaybeAllowNavigation(content::RenderFrameHost* opener,
const content::OpenURLParams& params,
CefRefPtr<CefBrowserHostImpl>& browser) const;
private: private:
// RenderProcessHostObserver methods: // RenderProcessHostObserver methods:
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
// Store state information about pending popups. Call order is: // Store state information about pending popups. Call order is:
// - CefContentBrowserClient::CanCreateWindow (UIT) // - AlloyContentBrowserClient::CanCreateWindow (UIT)
// Provides an opportunity to cancel the popup (calls OnBeforePopup) and // Provides an opportunity to cancel the popup (calls OnBeforePopup) and
// creates the new platform delegate for the popup. If the popup owner is // creates the new platform delegate for the popup. If the popup owner is
// an extension guest view then the popup is canceled and // an extension guest view then the popup is canceled and

View File

@@ -7,8 +7,8 @@
#include "libcef/browser/browser_info_manager.h" #include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/origin_whitelist_impl.h" #include "libcef/browser/origin_whitelist_impl.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/cef_messages.h" #include "libcef/common/cef_messages.h"
#include "libcef/common/content_client.h"
#include "libcef/common/values_impl.h" #include "libcef/common/values_impl.h"
#include "base/bind.h" #include "base/bind.h"
@@ -42,18 +42,6 @@ bool CefBrowserMessageFilter::OnMessageReceived(const IPC::Message& message) {
void CefBrowserMessageFilter::OnGetNewRenderThreadInfo( void CefBrowserMessageFilter::OnGetNewRenderThreadInfo(
CefProcessHostMsg_GetNewRenderThreadInfo_Params* params) { CefProcessHostMsg_GetNewRenderThreadInfo_Params* params) {
GetCrossOriginWhitelistEntries(&params->cross_origin_whitelist_entries); GetCrossOriginWhitelistEntries(&params->cross_origin_whitelist_entries);
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> handler =
app->GetBrowserProcessHandler();
if (handler.get()) {
CefRefPtr<CefListValueImpl> listValuePtr(
new CefListValueImpl(&params->extra_info, false, false));
handler->OnRenderProcessThreadCreated(listValuePtr.get());
listValuePtr->Detach(nullptr);
}
}
} }
void CefBrowserMessageFilter::OnGetNewBrowserInfo(int render_frame_routing_id, void CefBrowserMessageFilter::OnGetNewBrowserInfo(int render_frame_routing_id,

View File

@@ -3,14 +3,13 @@
// be found in the LICENSE file. // be found in the LICENSE file.
#include "libcef/browser/browser_message_loop.h" #include "libcef/browser/browser_message_loop.h"
#include "libcef/browser/context.h" #include "libcef/common/app_manager.h"
#include "libcef/common/content_client.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/message_loop/message_pump.h" #include "base/message_loop/message_pump.h"
#include "base/message_loop/message_pump_for_ui.h" #include "base/message_loop/message_pump_for_ui.h"
#if defined(OS_MACOSX) #if defined(OS_MAC)
#include "base/mac/scoped_nsautorelease_pool.h" #include "base/mac/scoped_nsautorelease_pool.h"
#include "base/message_loop/message_pump_mac.h" #include "base/message_loop/message_pump_mac.h"
#endif #endif
@@ -30,15 +29,21 @@ class MessagePumpExternal : public base::MessagePumpForUI {
void Run(Delegate* delegate) override { void Run(Delegate* delegate) override {
base::TimeTicks start = base::TimeTicks::Now(); base::TimeTicks start = base::TimeTicks::Now();
while (true) { while (true) {
#if defined(OS_MACOSX) #if defined(OS_MAC)
base::mac::ScopedNSAutoreleasePool autorelease_pool; base::mac::ScopedNSAutoreleasePool autorelease_pool;
#endif #endif
const bool has_more_work = DirectRunWork(delegate); base::TimeTicks next_run_time; // is_null()
const bool has_more_work = DirectRunWork(delegate, &next_run_time);
if (!has_more_work) if (!has_more_work)
break; break;
const base::TimeDelta& delta = base::TimeTicks::Now() - start; if (next_run_time.is_null()) {
// We have more work that should run immediately.
next_run_time = base::TimeTicks::Now();
}
const base::TimeDelta& delta = next_run_time - start;
if (delta.InSecondsF() > max_time_slice_) if (delta.InSecondsF() > max_time_slice_)
break; break;
} }
@@ -54,26 +59,33 @@ class MessagePumpExternal : public base::MessagePumpForUI {
} }
private: private:
bool DirectRunWork(Delegate* delegate) { static bool DirectRunWork(Delegate* delegate,
bool did_work = false; base::TimeTicks* next_run_time) {
bool did_delayed_work = false; bool more_immediate_work = false;
bool did_idle_work = false; bool more_idle_work = false;
bool more_delayed_work = false;
// Perform work & delayed work. Delegate::NextWorkInfo next_work_info = delegate->DoWork();
// If no work was found, then perform idle work.
did_work = delegate->DoWork(); // is_immediate() returns true if the next task is ready right away.
more_immediate_work = next_work_info.is_immediate();
// We are using an external timer, so we don't have any action based on the if (!more_immediate_work) {
// returned next delayed work time. // Check the next PendingTask's |delayed_run_time|.
base::TimeTicks next_time; // is_max() returns true if there are no more immediate nor delayed tasks.
did_delayed_work = delegate->DoDelayedWork(&next_time); more_delayed_work = !next_work_info.delayed_run_time.is_max();
if (more_delayed_work) {
if (!did_work && !did_delayed_work) { // The only remaining work that we know about is the PendingTask.
did_idle_work = delegate->DoIdleWork(); // Consider the run time for that task in the time slice calculation.
*next_run_time = next_work_info.delayed_run_time;
}
} }
return did_work || did_delayed_work || did_idle_work; if (!more_immediate_work && !more_delayed_work) {
// DoIdleWork() returns true if idle work was all done.
more_idle_work = !delegate->DoIdleWork();
}
return more_immediate_work || more_idle_work || more_delayed_work;
} }
const float max_time_slice_; const float max_time_slice_;
@@ -81,7 +93,7 @@ class MessagePumpExternal : public base::MessagePumpForUI {
}; };
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() { CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
CefRefPtr<CefApp> app = CefContentClient::Get()->application(); CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
if (app) if (app)
return app->GetBrowserProcessHandler(); return app->GetBrowserProcessHandler();
return nullptr; return nullptr;
@@ -96,7 +108,7 @@ std::unique_ptr<base::MessagePump> MessagePumpFactoryForUI() {
return std::make_unique<MessagePumpExternal>(0.01f, handler); return std::make_unique<MessagePumpExternal>(0.01f, handler);
} }
#if defined(OS_MACOSX) #if defined(OS_MAC)
return base::MessagePumpMac::Create(); return base::MessagePumpMac::Create();
#else #else
return std::make_unique<base::MessagePumpForUI>(); return std::make_unique<base::MessagePumpForUI>();
@@ -105,9 +117,6 @@ std::unique_ptr<base::MessagePump> MessagePumpFactoryForUI() {
} // namespace } // namespace
void InitMessagePumpFactoryForUI() { void InitExternalMessagePumpFactoryForUI() {
const CefSettings& settings = CefContext::Get()->settings(); base::MessagePump::OverrideMessagePumpForUIFactory(MessagePumpFactoryForUI);
if (settings.external_message_pump) {
base::MessagePump::OverrideMessagePumpForUIFactory(MessagePumpFactoryForUI);
}
} }

View File

@@ -5,6 +5,6 @@
#ifndef CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_ #ifndef CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_
#define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_ #define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_
void InitMessagePumpFactoryForUI(); void InitExternalMessagePumpFactoryForUI();
#endif // CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_ #endif // CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_

View File

@@ -5,16 +5,10 @@
#include "libcef/browser/browser_platform_delegate.h" #include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/browser_host_impl.h" #include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/osr/browser_platform_delegate_osr.h"
#include "libcef/browser/web_contents_dialog_helper.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() {} CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() = default;
CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() { CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() {
DCHECK(!browser_); DCHECK(!browser_);
@@ -27,25 +21,62 @@ void CefBrowserPlatformDelegate::CreateViewForWebContents(
} }
void CefBrowserPlatformDelegate::WebContentsCreated( void CefBrowserPlatformDelegate::WebContentsCreated(
content::WebContents* web_contents) {} content::WebContents* web_contents,
bool owned) {
// We should not have a browser at this point.
DCHECK(!browser_);
void CefBrowserPlatformDelegate::RenderViewCreated( DCHECK(!web_contents_);
content::RenderViewHost* render_view_host) { web_contents_ = web_contents;
// Indicate that the view has an external parent (namely us). This changes the
// default view behavior in some cases (e.g. focus handling on Linux).
if (!IsViewsHosted() && render_view_host->GetWidget()->GetView())
render_view_host->GetWidget()->GetView()->SetHasExternalParent(true);
} }
void CefBrowserPlatformDelegate::AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
NOTREACHED();
}
void CefBrowserPlatformDelegate::WebContentsDestroyed(
content::WebContents* web_contents) {
DCHECK(web_contents_ && web_contents_ == web_contents);
web_contents_ = nullptr;
}
bool CefBrowserPlatformDelegate::ShouldTransferNavigation(
bool is_main_frame_navigation) {
return true;
}
void CefBrowserPlatformDelegate::RenderViewCreated(
content::RenderViewHost* render_view_host) {}
void CefBrowserPlatformDelegate::RenderViewReady() {}
void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostImpl* browser) { void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostImpl* browser) {
// We should have an associated WebContents at this point.
DCHECK(web_contents_);
DCHECK(!browser_); DCHECK(!browser_);
DCHECK(browser); DCHECK(browser);
browser_ = browser; browser_ = browser;
}
if (browser_->IsPrintPreviewSupported()) { void CefBrowserPlatformDelegate::CreateExtensionHost(
web_contents_dialog_helper_.reset( const extensions::Extension* extension,
new CefWebContentsDialogHelper(browser_->web_contents(), this)); const GURL& url,
} extensions::ViewType host_type) {
NOTREACHED();
}
extensions::ExtensionHost* CefBrowserPlatformDelegate::GetExtensionHost()
const {
NOTREACHED();
return nullptr;
} }
void CefBrowserPlatformDelegate::NotifyBrowserCreated() {} void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
@@ -53,6 +84,9 @@ void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {} void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostImpl* browser) { void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostImpl* browser) {
// WebContentsDestroyed should already be called.
DCHECK(!web_contents_);
DCHECK(browser_ && browser_ == browser); DCHECK(browser_ && browser_ == browser);
browser_ = nullptr; browser_ = nullptr;
} }
@@ -90,30 +124,35 @@ void CefBrowserPlatformDelegate::PopupBrowserCreated(
bool is_devtools) {} bool is_devtools) {}
void CefBrowserPlatformDelegate::SendCaptureLostEvent() { void CefBrowserPlatformDelegate::SendCaptureLostEvent() {
content::RenderWidgetHostImpl* widget = content::RenderWidgetHostImpl::From( NOTIMPLEMENTED();
browser_->web_contents()->GetRenderViewHost()->GetWidget());
if (widget)
widget->LostCapture();
} }
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX)) #if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() { void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {}
// Dismiss any existing popups.
content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost();
if (host)
host->NotifyMoveOrResizeStarted();
}
void CefBrowserPlatformDelegate::SizeTo(int width, int height) {} void CefBrowserPlatformDelegate::SizeTo(int width, int height) {}
#endif #endif
bool CefBrowserPlatformDelegate::PreHandleGestureEvent(
content::WebContents* source,
const blink::WebGestureEvent& event) {
return false;
}
bool CefBrowserPlatformDelegate::IsNeverComposited(
content::WebContents* web_contents) {
return false;
}
std::unique_ptr<CefFileDialogRunner> std::unique_ptr<CefFileDialogRunner>
CefBrowserPlatformDelegate::CreateFileDialogRunner() { CefBrowserPlatformDelegate::CreateFileDialogRunner() {
NOTIMPLEMENTED();
return nullptr; return nullptr;
} }
std::unique_ptr<CefJavaScriptDialogRunner> std::unique_ptr<CefJavaScriptDialogRunner>
CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() { CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() {
NOTIMPLEMENTED();
return nullptr; return nullptr;
} }
@@ -228,12 +267,42 @@ gfx::Size CefBrowserPlatformDelegate::GetMaximumDialogSize() {
return gfx::Size(); return gfx::Size();
} }
base::RepeatingClosure CefBrowserPlatformDelegate::GetBoundsChangedCallback() { void CefBrowserPlatformDelegate::SetAutoResizeEnabled(bool enabled,
if (web_contents_dialog_helper_) { const CefSize& min_size,
return web_contents_dialog_helper_->GetBoundsChangedCallback(); const CefSize& max_size) {
} NOTIMPLEMENTED();
}
return base::RepeatingClosure(); void CefBrowserPlatformDelegate::SetAccessibilityState(
cef_state_t accessibility_state) {
NOTIMPLEMENTED();
}
bool CefBrowserPlatformDelegate::IsPrintPreviewSupported() const {
return true;
}
void CefBrowserPlatformDelegate::Print() {
NOTIMPLEMENTED();
}
void CefBrowserPlatformDelegate::PrintToPDF(
const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback) {
NOTIMPLEMENTED();
}
void CefBrowserPlatformDelegate::Find(int identifier,
const CefString& searchText,
bool forward,
bool matchCase,
bool findNext) {
NOTIMPLEMENTED();
}
void CefBrowserPlatformDelegate::StopFinding(bool clearSelection) {
NOTIMPLEMENTED();
} }
// static // static

View File

@@ -32,17 +32,19 @@ class RenderViewHostDelegateView;
class WebContentsView; class WebContentsView;
} // namespace content } // namespace content
namespace extensions {
class ExtensionHost;
}
#if defined(USE_AURA) #if defined(USE_AURA)
namespace views { namespace views {
class Widget; class Widget;
} }
#endif #endif
class CefBrowserInfo;
class CefFileDialogRunner; class CefFileDialogRunner;
class CefJavaScriptDialogRunner; class CefJavaScriptDialogRunner;
class CefMenuRunner; class CefMenuRunner;
class CefWebContentsDialogHelper;
// Provides platform-specific implementations of browser functionality. All // Provides platform-specific implementations of browser functionality. All
// methods are called on the browser process UI thread unless otherwise // methods are called on the browser process UI thread unless otherwise
@@ -54,6 +56,13 @@ class CefBrowserPlatformDelegate {
static std::unique_ptr<CefBrowserPlatformDelegate> Create( static std::unique_ptr<CefBrowserPlatformDelegate> Create(
CefBrowserHostImpl::CreateParams& create_params); CefBrowserHostImpl::CreateParams& create_params);
// Called from CefBrowserHostImpl::Create.
// Wait for the call to WebContentsCreated(owned=true) before taking ownership
// of the resulting WebContents object.
virtual content::WebContents* CreateWebContents(
CefBrowserHostImpl::CreateParams& create_params,
bool& own_web_contents) = 0;
// Called to create the view objects for a new WebContents. Will only be // Called to create the view objects for a new WebContents. Will only be
// called a single time per instance. May be called on multiple threads. Only // called a single time per instance. May be called on multiple threads. Only
// used with windowless rendering. // used with windowless rendering.
@@ -61,18 +70,52 @@ class CefBrowserPlatformDelegate {
content::WebContentsView** view, content::WebContentsView** view,
content::RenderViewHostDelegateView** delegate_view); content::RenderViewHostDelegateView** delegate_view);
// Called after the WebContents for the browser is created. Will only be // Called after the WebContents for a browser has been created. |owned| will
// called a single time per instance. // be true if |web_contents| was created via CreateWebContents() and we should
virtual void WebContentsCreated(content::WebContents* web_contents); // take ownership. This will also be called for popup WebContents created
// indirectly by Chromium. Will only be called a single time per instance.
virtual void WebContentsCreated(content::WebContents* web_contents,
bool owned);
// Called when Chromium is ready to hand over ownership of a popup
// WebContents. WebContentsCreated(owned=false) will be called first for
// |new_contents|. Will only be called a single time per instance. See also
// the WebContentsDelegate documentation.
virtual void AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked);
// Called when the WebContents is destroyed. This will be called before
// BrowserDestroyed(). Will only be called a single time per instance.
virtual void WebContentsDestroyed(content::WebContents* web_contents);
// See WebContentsDelegate documentation.
virtual bool ShouldTransferNavigation(bool is_main_frame_navigation);
// Called after the RenderViewHost is created. // Called after the RenderViewHost is created.
virtual void RenderViewCreated(content::RenderViewHost* render_view_host); virtual void RenderViewCreated(content::RenderViewHost* render_view_host);
// See WebContentsObserver documentation.
virtual void RenderViewReady();
// Called after the owning CefBrowserHostImpl is created. Will only be called // Called after the owning CefBrowserHostImpl is created. Will only be called
// a single time per instance. Do not send any client notifications from this // a single time per instance. Do not send any client notifications from this
// method. // method.
virtual void BrowserCreated(CefBrowserHostImpl* browser); virtual void BrowserCreated(CefBrowserHostImpl* browser);
// Called from CefBrowserHostImpl::Create.
virtual void CreateExtensionHost(const extensions::Extension* extension,
const GURL& url,
extensions::ViewType host_type);
// Returns the current extension host.
virtual extensions::ExtensionHost* GetExtensionHost() const;
// Send any notifications related to browser creation. Called after // Send any notifications related to browser creation. Called after
// BrowserCreated(). // BrowserCreated().
virtual void NotifyBrowserCreated(); virtual void NotifyBrowserCreated();
@@ -141,11 +184,8 @@ class CefBrowserPlatformDelegate {
// enable transparency. // enable transparency.
virtual SkColor GetBackgroundColor() const = 0; virtual SkColor GetBackgroundColor() const = 0;
virtual bool CanUseSharedTexture() const = 0;
virtual bool CanUseExternalBeginFrame() const = 0;
// Notify the window that it was resized. // Notify the window that it was resized.
virtual void SynchronizeVisualProperties() = 0; virtual void WasResized() = 0;
// Send input events. // Send input events.
virtual void SendKeyEvent(const CefKeyEvent& event) = 0; virtual void SendKeyEvent(const CefKeyEvent& event) = 0;
@@ -167,7 +207,7 @@ class CefBrowserPlatformDelegate {
// Send capture lost event. // Send capture lost event.
virtual void SendCaptureLostEvent(); virtual void SendCaptureLostEvent();
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX)) #if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
// The window hosting the browser is about to be moved or resized. Only used // The window hosting the browser is about to be moved or resized. Only used
// on Windows and Linux. // on Windows and Linux.
virtual void NotifyMoveOrResizeStarted(); virtual void NotifyMoveOrResizeStarted();
@@ -189,6 +229,13 @@ class CefBrowserPlatformDelegate {
virtual bool HandleKeyboardEvent( virtual bool HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) = 0; const content::NativeWebKeyboardEvent& event) = 0;
// See WebContentsDelegate documentation.
virtual bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event);
// See WebContentsDelegate documentation.
virtual bool IsNeverComposited(content::WebContents* web_contents);
// Invoke platform specific handling for the external protocol. // Invoke platform specific handling for the external protocol.
static void HandleExternalProtocol(const GURL& url); static void HandleExternalProtocol(const GURL& url);
@@ -224,6 +271,7 @@ class CefBrowserPlatformDelegate {
// Invalidate the view. Only used with windowless rendering. // Invalidate the view. Only used with windowless rendering.
virtual void Invalidate(cef_paint_element_type_t type); virtual void Invalidate(cef_paint_element_type_t type);
// Send the external begin frame message. Only used with windowless rendering.
virtual void SendExternalBeginFrame(); virtual void SendExternalBeginFrame();
// Set the windowless frame rate. Only used with windowless rendering. // Set the windowless frame rate. Only used with windowless rendering.
@@ -267,6 +315,23 @@ class CefBrowserPlatformDelegate {
virtual gfx::Point GetDialogPosition(const gfx::Size& size); virtual gfx::Point GetDialogPosition(const gfx::Size& size);
virtual gfx::Size GetMaximumDialogSize(); virtual gfx::Size GetMaximumDialogSize();
// See CefBrowserHost documentation.
virtual void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size);
virtual void SetAccessibilityState(cef_state_t accessibility_state);
virtual bool IsPrintPreviewSupported() const;
virtual void Print();
virtual void PrintToPDF(const CefString& path,
const CefPdfPrintSettings& settings,
CefRefPtr<CefPdfPrintCallback> callback);
virtual void Find(int identifier,
const CefString& searchText,
bool forward,
bool matchCase,
bool findNext);
virtual void StopFinding(bool clearSelection);
protected: protected:
// Allow deletion via scoped_ptr only. // Allow deletion via scoped_ptr only.
friend std::default_delete<CefBrowserPlatformDelegate>; friend std::default_delete<CefBrowserPlatformDelegate>;
@@ -274,15 +339,11 @@ class CefBrowserPlatformDelegate {
CefBrowserPlatformDelegate(); CefBrowserPlatformDelegate();
virtual ~CefBrowserPlatformDelegate(); virtual ~CefBrowserPlatformDelegate();
base::RepeatingClosure GetBoundsChangedCallback();
static int TranslateWebEventModifiers(uint32 cef_modifiers); static int TranslateWebEventModifiers(uint32 cef_modifiers);
CefBrowserHostImpl* browser_ = nullptr; // Not owned by this object. // Not owned by this object.
content::WebContents* web_contents_ = nullptr;
private: CefBrowserHostImpl* browser_ = nullptr;
// Used for the print preview dialog.
std::unique_ptr<CefWebContentsDialogHelper> web_contents_dialog_helper_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegate); DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegate);
}; };

View File

@@ -11,12 +11,14 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
#include "libcef/browser/extensions/browser_platform_delegate_background.h" #include "libcef/browser/extensions/browser_platform_delegate_background.h"
#include "libcef/features/runtime_checks.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "libcef/browser/native/browser_platform_delegate_native_win.h" #include "libcef/browser/native/browser_platform_delegate_native_win.h"
#include "libcef/browser/osr/browser_platform_delegate_osr_win.h" #include "libcef/browser/osr/browser_platform_delegate_osr_win.h"
#elif defined(OS_MACOSX) #elif defined(OS_MAC)
#include "libcef/browser/native/browser_platform_delegate_native_mac.h" #include "libcef/browser/native/browser_platform_delegate_native_mac.h"
#include "libcef/browser/osr/browser_platform_delegate_osr_mac.h" #include "libcef/browser/osr/browser_platform_delegate_osr_mac.h"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
@@ -34,33 +36,32 @@ namespace {
std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate( std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
const CefWindowInfo& window_info, const CefWindowInfo& window_info,
SkColor background_color, SkColor background_color) {
bool use_shared_texture,
bool use_external_begin_frame) {
#if defined(OS_WIN) #if defined(OS_WIN)
return std::make_unique<CefBrowserPlatformDelegateNativeWin>( return std::make_unique<CefBrowserPlatformDelegateNativeWin>(
window_info, background_color, use_shared_texture, window_info, background_color);
use_external_begin_frame); #elif defined(OS_MAC)
#elif defined(OS_MACOSX)
return std::make_unique<CefBrowserPlatformDelegateNativeMac>( return std::make_unique<CefBrowserPlatformDelegateNativeMac>(
window_info, background_color); window_info, background_color);
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
return std::make_unique<CefBrowserPlatformDelegateNativeLinux>( return std::make_unique<CefBrowserPlatformDelegateNativeLinux>(
window_info, background_color, use_external_begin_frame); window_info, background_color);
#endif #endif
} }
std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate( std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate) { std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate,
bool use_shared_texture,
bool use_external_begin_frame) {
#if defined(OS_WIN) #if defined(OS_WIN)
return std::make_unique<CefBrowserPlatformDelegateOsrWin>( return std::make_unique<CefBrowserPlatformDelegateOsrWin>(
std::move(native_delegate)); std::move(native_delegate), use_shared_texture, use_external_begin_frame);
#elif defined(OS_MACOSX) #elif defined(OS_MAC)
return std::make_unique<CefBrowserPlatformDelegateOsrMac>( return std::make_unique<CefBrowserPlatformDelegateOsrMac>(
std::move(native_delegate)); std::move(native_delegate));
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
return std::make_unique<CefBrowserPlatformDelegateOsrLinux>( return std::make_unique<CefBrowserPlatformDelegateOsrLinux>(
std::move(native_delegate)); std::move(native_delegate), use_external_begin_frame);
#endif #endif
} }
@@ -76,31 +77,34 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
const SkColor background_color = CefContext::Get()->GetBackgroundColor( const SkColor background_color = CefContext::Get()->GetBackgroundColor(
&create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED); &create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED);
bool use_shared_texture = false; if (cef::IsChromeRuntimeEnabled()) {
bool use_external_begin_frame = false; return std::make_unique<CefBrowserPlatformDelegateChrome>(background_color);
if (is_windowless) {
use_shared_texture = create_params.window_info &&
create_params.window_info->shared_texture_enabled;
use_external_begin_frame =
create_params.window_info &&
create_params.window_info->external_begin_frame_enabled;
} }
if (create_params.window_info) { if (create_params.window_info) {
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate = std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(*create_params.window_info.get(), background_color, CreateNativeDelegate(*create_params.window_info.get(),
use_shared_texture, use_external_begin_frame); background_color);
if (is_windowless) if (is_windowless) {
return CreateOSRDelegate(std::move(native_delegate)); REQUIRE_ALLOY_RUNTIME();
const bool use_shared_texture =
create_params.window_info &&
create_params.window_info->shared_texture_enabled;
const bool use_external_begin_frame =
create_params.window_info &&
create_params.window_info->external_begin_frame_enabled;
return CreateOSRDelegate(std::move(native_delegate), use_shared_texture,
use_external_begin_frame);
}
return std::move(native_delegate); return std::move(native_delegate);
} else if (create_params.extension_host_type == } else if (create_params.extension_host_type ==
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
// Creating a background extension host without a window. // Creating a background extension host without a window.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate = std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo(), background_color, CreateNativeDelegate(CefWindowInfo(), background_color);
use_shared_texture, use_external_begin_frame);
return std::make_unique<CefBrowserPlatformDelegateBackground>( return std::make_unique<CefBrowserPlatformDelegateBackground>(
std::move(native_delegate)); std::move(native_delegate));
} }
@@ -108,8 +112,7 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
else { else {
// CefWindowInfo is not used in this case. // CefWindowInfo is not used in this case.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate = std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo(), background_color, CreateNativeDelegate(CefWindowInfo(), background_color);
use_shared_texture, use_external_begin_frame);
return std::make_unique<CefBrowserPlatformDelegateViews>( return std::make_unique<CefBrowserPlatformDelegateViews>(
std::move(native_delegate), std::move(native_delegate),
static_cast<CefBrowserViewImpl*>(create_params.browser_view.get())); static_cast<CefBrowserViewImpl*>(create_params.browser_view.get()));

View File

@@ -11,16 +11,16 @@ namespace browser_util {
bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event, bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event,
CefKeyEvent& cef_event) { CefKeyEvent& cef_event) {
switch (event.GetType()) { switch (event.GetType()) {
case blink::WebKeyboardEvent::kRawKeyDown: case blink::WebKeyboardEvent::Type::kRawKeyDown:
cef_event.type = KEYEVENT_RAWKEYDOWN; cef_event.type = KEYEVENT_RAWKEYDOWN;
break; break;
case blink::WebKeyboardEvent::kKeyDown: case blink::WebKeyboardEvent::Type::kKeyDown:
cef_event.type = KEYEVENT_KEYDOWN; cef_event.type = KEYEVENT_KEYDOWN;
break; break;
case blink::WebKeyboardEvent::kKeyUp: case blink::WebKeyboardEvent::Type::kKeyUp:
cef_event.type = KEYEVENT_KEYUP; cef_event.type = KEYEVENT_KEYUP;
break; break;
case blink::WebKeyboardEvent::kChar: case blink::WebKeyboardEvent::Type::kChar:
cef_event.type = KEYEVENT_CHAR; cef_event.type = KEYEVENT_CHAR;
break; break;
default: default:

View File

@@ -0,0 +1,138 @@
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
#include "base/logging.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
CefBrowserPlatformDelegateChrome::CefBrowserPlatformDelegateChrome(
SkColor background_color)
: background_color_(background_color) {}
content::WebContents* CefBrowserPlatformDelegateChrome::CreateWebContents(
CefBrowserHostImpl::CreateParams& create_params,
bool& own_web_contents) {
// Get or create the request context and profile.
CefRefPtr<CefRequestContextImpl> request_context_impl =
CefRequestContextImpl::GetOrCreateForRequestContext(
create_params.request_context);
CHECK(request_context_impl);
auto cef_browser_context = request_context_impl->GetBrowserContext();
CHECK(cef_browser_context);
auto profile = cef_browser_context->AsProfile();
if (!create_params.request_context) {
// Using the global request context.
create_params.request_context = request_context_impl.get();
}
// Create a Browser.
Browser::CreateParams params =
Browser::CreateParams(profile, /*user_gesture=*/false);
chrome_browser_ = new Browser(params);
chrome::AddTabAt(chrome_browser_, create_params.url, /*idx=*/-1,
/*foreground=*/true);
auto web_contents =
chrome_browser_->tab_strip_model()->GetActiveWebContents();
CHECK(web_contents);
own_web_contents = false;
return web_contents;
}
void CefBrowserPlatformDelegateChrome::WebContentsDestroyed(
content::WebContents* web_contents) {
CefBrowserPlatformDelegate::WebContentsDestroyed(web_contents);
// TODO(chrome-runtime): Find a better way to be notified of Browser
// destruction.
browser_->WindowDestroyed();
}
void CefBrowserPlatformDelegateChrome::BrowserDestroyed(
CefBrowserHostImpl* browser) {
CefBrowserPlatformDelegate::BrowserDestroyed(browser);
// Release the reference added in CreateHostWindow.
browser->Release();
}
bool CefBrowserPlatformDelegateChrome::CreateHostWindow() {
// Keep a reference to the CEF browser.
browser_->AddRef();
chrome_browser_->window()->Show();
return true;
}
void CefBrowserPlatformDelegateChrome::CloseHostWindow() {}
CefWindowHandle CefBrowserPlatformDelegateChrome::GetHostWindowHandle() const {
return kNullWindowHandle;
}
SkColor CefBrowserPlatformDelegateChrome::GetBackgroundColor() const {
return background_color_;
}
void CefBrowserPlatformDelegateChrome::WasResized() {}
void CefBrowserPlatformDelegateChrome::SendKeyEvent(const CefKeyEvent& event) {}
void CefBrowserPlatformDelegateChrome::SendMouseClickEvent(
const CefMouseEvent& event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) {}
void CefBrowserPlatformDelegateChrome::SendMouseMoveEvent(
const CefMouseEvent& event,
bool mouseLeave) {}
void CefBrowserPlatformDelegateChrome::SendMouseWheelEvent(
const CefMouseEvent& event,
int deltaX,
int deltaY) {}
void CefBrowserPlatformDelegateChrome::SendTouchEvent(
const CefTouchEvent& event) {}
void CefBrowserPlatformDelegateChrome::SendFocusEvent(bool setFocus) {}
gfx::Point CefBrowserPlatformDelegateChrome::GetScreenPoint(
const gfx::Point& view) const {
return view;
}
void CefBrowserPlatformDelegateChrome::ViewText(const std::string& text) {}
bool CefBrowserPlatformDelegateChrome::HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
return false;
}
CefEventHandle CefBrowserPlatformDelegateChrome::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const {
return kNullEventHandle;
}
std::unique_ptr<CefMenuRunner>
CefBrowserPlatformDelegateChrome::CreateMenuRunner() {
NOTIMPLEMENTED();
return nullptr;
}
bool CefBrowserPlatformDelegateChrome::IsWindowless() const {
return false;
}
bool CefBrowserPlatformDelegateChrome::IsViewsHosted() const {
return false;
}

View File

@@ -0,0 +1,55 @@
// Copyright 2020 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_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_
#include "libcef/browser/browser_platform_delegate.h"
class Browser;
// Implementation of Chrome-based browser functionality.
class CefBrowserPlatformDelegateChrome : public CefBrowserPlatformDelegate {
public:
explicit CefBrowserPlatformDelegateChrome(SkColor background_color);
// CefBrowserPlatformDelegate overrides.
content::WebContents* CreateWebContents(
CefBrowserHostImpl::CreateParams& create_params,
bool& own_web_contents) override;
void WebContentsDestroyed(content::WebContents* web_contents) override;
void BrowserDestroyed(CefBrowserHostImpl* browser) override;
bool CreateHostWindow() override;
void CloseHostWindow() override;
CefWindowHandle GetHostWindowHandle() const override;
SkColor GetBackgroundColor() const override;
void WasResized() override;
void SendKeyEvent(const CefKeyEvent& event) override;
void SendMouseClickEvent(const CefMouseEvent& event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) override;
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
void SendMouseWheelEvent(const CefMouseEvent& event,
int deltaX,
int deltaY) override;
void SendTouchEvent(const CefTouchEvent& event) override;
void SendFocusEvent(bool setFocus) override;
gfx::Point GetScreenPoint(const gfx::Point& view) const override;
void ViewText(const std::string& text) override;
bool HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override;
CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override;
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
bool IsWindowless() const override;
bool IsViewsHosted() const override;
private:
const SkColor background_color_;
Browser* chrome_browser_;
};
#endif // CEF_LIBCEF_BROWSER_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_

View File

@@ -0,0 +1,36 @@
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/chrome/chrome_browser_context.h"
#include "chrome/browser/profiles/profile_manager.h"
ChromeBrowserContext::ChromeBrowserContext(
const CefRequestContextSettings& settings)
: CefBrowserContext(settings) {}
ChromeBrowserContext::~ChromeBrowserContext() = default;
content::BrowserContext* ChromeBrowserContext::AsBrowserContext() {
return profile_;
}
Profile* ChromeBrowserContext::AsProfile() {
return profile_;
}
void ChromeBrowserContext::Initialize() {
CefBrowserContext::Initialize();
// TODO(chrome-runtime): ProfileManager can create new profiles relative to
// the user-data-dir, but it should be done asynchronously.
// The global ProfileManager instance can be retrieved via
// |g_browser_process->profile_manager()|.
profile_ = ProfileManager::GetLastUsedProfileAllowedByPolicy();
}
void ChromeBrowserContext::Shutdown() {
CefBrowserContext::Shutdown();
profile_ = nullptr;
}

View File

@@ -0,0 +1,31 @@
// Copyright 2020 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_CHROME_CHROME_BROWSER_CONTEXT_H_
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_
#pragma once
#include "libcef/browser/browser_context.h"
// See CefBrowserContext documentation for usage. Only accessed on the UI thread
// unless otherwise indicated.
class ChromeBrowserContext : public CefBrowserContext {
public:
explicit ChromeBrowserContext(const CefRequestContextSettings& settings);
// CefBrowserContext overrides.
content::BrowserContext* AsBrowserContext() override;
Profile* AsProfile() override;
void Initialize() override;
void Shutdown() override;
private:
~ChromeBrowserContext() override;
Profile* profile_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserContext);
};
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_

View File

@@ -0,0 +1,34 @@
// Copyright 2019 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 "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
#include "libcef/browser/context.h"
#include "base/task/post_task.h"
ChromeBrowserMainExtraPartsCef::ChromeBrowserMainExtraPartsCef() = default;
ChromeBrowserMainExtraPartsCef::~ChromeBrowserMainExtraPartsCef() = default;
void ChromeBrowserMainExtraPartsCef::PostProfileInit() {
CefRequestContextSettings settings;
CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
// Create the global RequestContext.
global_request_context_ =
CefRequestContextImpl::CreateGlobalRequestContext(settings);
}
void ChromeBrowserMainExtraPartsCef::PostMainMessageLoopRun() {
background_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_visible_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
user_blocking_task_runner_ = base::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
}

View File

@@ -0,0 +1,54 @@
// Copyright 2019 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_CHROME_CHROME_BROWSER_MAIN_EXTRA_PARTS_CEF_H_
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_MAIN_EXTRA_PARTS_CEF_H_
#include <memory>
#include "libcef/browser/request_context_impl.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
// Wrapper that owns and initialize the browser memory-related extra parts.
class ChromeBrowserMainExtraPartsCef : public ChromeBrowserMainExtraParts {
public:
ChromeBrowserMainExtraPartsCef();
~ChromeBrowserMainExtraPartsCef() override;
CefRefPtr<CefRequestContextImpl> request_context() const {
return global_request_context_;
}
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:
// ChromeBrowserMainExtraParts overrides.
void PostProfileInit() override;
void PostMainMessageLoopRun() override;
CefRefPtr<CefRequestContextImpl> global_request_context_;
// 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).
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner_;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsCef);
};
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_MAIN_EXTRA_PARTS_CEF_H_

View File

@@ -0,0 +1,69 @@
// Copyright 2020 The Chromium Embedded Framework Authors.
// Portions copyright 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 "libcef/browser/chrome/chrome_content_browser_client_cef.h"
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
#include "libcef/common/cef_switches.h"
#include "base/command_line.h"
#include "base/path_service.h"
#include "chrome/browser/chrome_browser_main.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
ChromeContentBrowserClientCef::ChromeContentBrowserClientCef(
StartupData* startup_data)
: ChromeContentBrowserClient(startup_data) {}
ChromeContentBrowserClientCef::~ChromeContentBrowserClientCef() = default;
std::unique_ptr<content::BrowserMainParts>
ChromeContentBrowserClientCef::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
auto main_parts =
ChromeContentBrowserClient::CreateBrowserMainParts(parameters);
browser_main_parts_ = new ChromeBrowserMainExtraPartsCef;
static_cast<ChromeBrowserMainParts*>(main_parts.get())
->AddParts(
base::WrapUnique<ChromeBrowserMainExtraParts>(browser_main_parts_));
return main_parts;
}
void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
base::CommandLine* command_line,
int child_process_id) {
ChromeContentBrowserClient::AppendExtraCommandLineSwitches(command_line,
child_process_id);
// Necessary to launch sub-processes in the correct mode.
command_line->AppendSwitch(switches::kEnableChromeRuntime);
// Necessary to populate DIR_USER_DATA in sub-processes.
// See resource_util.cc GetUserDataPath.
base::FilePath user_data_dir;
if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
}
}
CefRefPtr<CefRequestContextImpl>
ChromeContentBrowserClientCef::request_context() const {
return browser_main_parts_->request_context();
}
scoped_refptr<base::SingleThreadTaskRunner>
ChromeContentBrowserClientCef::background_task_runner() const {
return browser_main_parts_->background_task_runner();
}
scoped_refptr<base::SingleThreadTaskRunner>
ChromeContentBrowserClientCef::user_visible_task_runner() const {
return browser_main_parts_->user_visible_task_runner();
}
scoped_refptr<base::SingleThreadTaskRunner>
ChromeContentBrowserClientCef::user_blocking_task_runner() const {
return browser_main_parts_->user_blocking_task_runner();
}

View File

@@ -0,0 +1,42 @@
// Copyright 2020 The Chromium Embedded Framework Authors.
// Portions copyright 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_CHROME_CHROME_CONTENT_BROWSER_CLIENT_CEF_
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTENT_BROWSER_CLIENT_CEF_
#include <memory>
#include "libcef/browser/request_context_impl.h"
#include "base/macros.h"
#include "chrome/browser/chrome_content_browser_client.h"
class ChromeBrowserMainExtraPartsCef;
// CEF override of ChromeContentBrowserClient
class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
public:
explicit ChromeContentBrowserClientCef(StartupData* startup_data = nullptr);
~ChromeContentBrowserClientCef() override;
// ChromeContentBrowserClient overrides.
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
const content::MainFunctionParams& parameters) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override;
CefRefPtr<CefRequestContextImpl> request_context() 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:
ChromeBrowserMainExtraPartsCef* browser_main_parts_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClientCef);
};
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTENT_BROWSER_CLIENT_CEF_

View File

@@ -5,11 +5,11 @@
#include "build/build_config.h" #include "build/build_config.h"
#if defined(OS_MACOSX) #if defined(OS_MAC)
#include "chrome/app/chrome_crash_reporter_client.h" #include "chrome/app/chrome_crash_reporter_client.h"
// Required due to https://crrev.com/1c9f89a06f // Required due to https://crrev.com/1c9f89a06f
void ChromeCrashReporterClient::Create() {} void ChromeCrashReporterClient::Create() {}
#endif // defined(OS_MACOSX) #endif // defined(OS_MAC)

View File

@@ -1,131 +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 "libcef/browser/chrome_profile_stub.h"
#include "content/public/browser/resource_context.h"
#include "net/url_request/url_request_context.h"
ChromeProfileStub::ChromeProfileStub() {}
ChromeProfileStub::~ChromeProfileStub() {}
bool ChromeProfileStub::IsOffTheRecord() {
return false;
}
bool ChromeProfileStub::IsOffTheRecord() const {
return false;
}
scoped_refptr<base::SequencedTaskRunner> ChromeProfileStub::GetIOTaskRunner() {
NOTREACHED();
return scoped_refptr<base::SequencedTaskRunner>();
}
std::string ChromeProfileStub::GetProfileUserName() const {
NOTREACHED();
return std::string();
}
Profile::ProfileType ChromeProfileStub::GetProfileType() const {
return REGULAR_PROFILE;
}
Profile* ChromeProfileStub::GetOffTheRecordProfile() {
NOTREACHED();
return nullptr;
}
void ChromeProfileStub::DestroyOffTheRecordProfile() {
NOTREACHED();
}
bool ChromeProfileStub::HasOffTheRecordProfile() {
return false;
}
Profile* ChromeProfileStub::GetOriginalProfile() {
return this;
}
const Profile* ChromeProfileStub::GetOriginalProfile() const {
return this;
}
bool ChromeProfileStub::IsSupervised() const {
return false;
}
bool ChromeProfileStub::IsChild() const {
return false;
}
bool ChromeProfileStub::IsLegacySupervised() const {
return false;
}
ExtensionSpecialStoragePolicy*
ChromeProfileStub::GetExtensionSpecialStoragePolicy() {
NOTREACHED();
return nullptr;
}
PrefService* ChromeProfileStub::GetOffTheRecordPrefs() {
NOTREACHED();
return nullptr;
}
bool ChromeProfileStub::IsSameProfile(Profile* profile) {
NOTREACHED();
return false;
}
base::Time ChromeProfileStub::GetStartTime() const {
NOTREACHED();
return base::Time();
}
base::FilePath ChromeProfileStub::last_selected_directory() {
NOTREACHED();
return base::FilePath();
}
void ChromeProfileStub::set_last_selected_directory(
const base::FilePath& path) {
NOTREACHED();
}
GURL ChromeProfileStub::GetHomePage() {
NOTREACHED();
return GURL();
}
bool ChromeProfileStub::WasCreatedByVersionOrLater(const std::string& version) {
NOTREACHED();
return false;
}
bool ChromeProfileStub::IsIndependentOffTheRecordProfile() {
return false;
}
void ChromeProfileStub::SetExitType(ExitType exit_type) {
NOTREACHED();
}
Profile::ExitType ChromeProfileStub::GetLastSessionExitType() {
NOTREACHED();
return EXIT_NORMAL;
}
base::Time ChromeProfileStub::GetCreationTime() const {
NOTREACHED();
return base::Time();
}
void ChromeProfileStub::SetCreationTimeForTesting(base::Time creation_time) {
NOTREACHED();
}

View File

@@ -3,48 +3,26 @@
// be found in the LICENSE file. // be found in the LICENSE file.
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h" #include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_main.h"
#include "libcef/browser/chrome_browser_process_stub.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "libcef/browser/trace_subscriber.h" #include "libcef/browser/trace_subscriber.h"
#include "libcef/common/cef_switches.h" #include "libcef/common/cef_switches.h"
#include "libcef/common/main_delegate.h"
#include "libcef/common/widevine_loader.h"
#include "libcef/renderer/content_renderer_client.h"
#include "base/base_switches.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h"
#include "base/debug/debugger.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/synchronization/waitable_event.h" #include "base/task/current_thread.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "components/network_session_configurator/common/network_switches.h" #include "components/network_session_configurator/common/network_switches.h"
#include "content/app/content_service_manager_main_delegate.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h"
#include "services/service_manager/embedder/main.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/chrome_elf/chrome_elf_main.h" #include "chrome/chrome_elf/chrome_elf_main.h"
#include "chrome/install_static/initialize_from_primary_module.h" #include "chrome/install_static/initialize_from_primary_module.h"
#include "components/crash/content/app/crashpad.h"
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#endif
#if defined(OS_MACOSX) || defined(OS_WIN)
#include "components/crash/content/app/crash_switches.h"
#include "third_party/crashpad/crashpad/handler/handler_main.h"
#endif #endif
namespace { namespace {
@@ -95,54 +73,6 @@ void InitCrashReporter() {
} }
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
#if defined(OS_MACOSX) || defined(OS_WIN)
// Based on components/crash/content/app/run_as_crashpad_handler_win.cc
// Remove the "--type=crashpad-handler" command-line flag that will otherwise
// confuse the crashpad handler.
// Chrome uses an embedded crashpad handler on Windows only and imports this
// function via the existing "run_as_crashpad_handler" target defined in
// components/crash/content/app/BUILD.gn. CEF uses an embedded handler on both
// Windows and macOS so we define the function here instead of using the
// existing target (because we can't use that target on macOS).
int RunAsCrashpadHandler(const base::CommandLine& command_line) {
base::CommandLine::StringVector argv = command_line.argv();
const base::CommandLine::StringType process_type =
FILE_PATH_LITERAL("--type=");
argv.erase(
std::remove_if(argv.begin(), argv.end(),
[&process_type](const base::CommandLine::StringType& str) {
return base::StartsWith(str, process_type,
base::CompareCase::SENSITIVE) ||
(!str.empty() && str[0] == L'/');
}),
argv.end());
#if defined(OS_MACOSX)
// HandlerMain on macOS uses the system version of getopt_long which expects
// the first argument to be the program name.
argv.insert(argv.begin(), command_line.GetProgram().value());
#endif
std::unique_ptr<char*[]> argv_as_utf8(new char*[argv.size() + 1]);
std::vector<std::string> storage;
storage.reserve(argv.size());
for (size_t i = 0; i < argv.size(); ++i) {
#if defined(OS_WIN)
storage.push_back(base::UTF16ToUTF8(argv[i]));
#else
storage.push_back(argv[i]);
#endif
argv_as_utf8[i] = &storage[i][0];
}
argv_as_utf8[argv.size()] = nullptr;
argv.clear();
return crashpad::HandlerMain(static_cast<int>(storage.size()),
argv_as_utf8.get(), nullptr);
}
#endif // defined(OS_MACOSX) || defined(OS_WIN)
bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) { bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) {
// Windowed browser colors must be fully opaque. // Windowed browser colors must be fully opaque.
if (!is_windowless && CefColorGetA(cef_in) != SK_AlphaOPAQUE) if (!is_windowless && CefColorGetA(cef_in) != SK_AlphaOPAQUE)
@@ -160,6 +90,85 @@ bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) {
return true; return true;
} }
// Convert |path_str| to a normalized FilePath.
base::FilePath NormalizePath(const cef_string_t& path_str,
const char* name,
bool* has_error = nullptr) {
if (has_error)
*has_error = false;
base::FilePath path = base::FilePath(CefString(&path_str));
if (path.EndsWithSeparator()) {
// Remove the trailing separator because it will interfere with future
// equality checks.
path = path.StripTrailingSeparators();
}
if (!path.empty() && !path.IsAbsolute()) {
LOG(ERROR) << "The " << name << " directory (" << path.value()
<< ") is not an absolute path. Defaulting to empty.";
if (has_error)
*has_error = true;
path = base::FilePath();
}
return path;
}
void SetPath(cef_string_t& path_str, const base::FilePath& path) {
#if defined(OS_WIN)
CefString(&path_str).FromWString(path.value());
#else
CefString(&path_str).FromString(path.value());
#endif
}
// Convert |path_str| to a normalized FilePath and update the |path_str| value.
base::FilePath NormalizePathAndSet(cef_string_t& path_str, const char* name) {
const base::FilePath& path = NormalizePath(path_str, name);
SetPath(path_str, path);
return path;
}
// Verify that |cache_path| is valid and create it if necessary.
bool ValidateCachePath(const base::FilePath& cache_path,
const base::FilePath& root_cache_path) {
if (cache_path.empty())
return true;
if (!root_cache_path.empty() && root_cache_path != cache_path &&
!root_cache_path.IsParent(cache_path)) {
LOG(ERROR) << "The cache_path directory (" << cache_path.value()
<< ") is not a child of the root_cache_path directory ("
<< root_cache_path.value() << ")";
return false;
}
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (!base::DirectoryExists(cache_path) &&
!base::CreateDirectory(cache_path)) {
LOG(ERROR) << "The cache_path directory (" << cache_path.value()
<< ") could not be created.";
return false;
}
return true;
}
// Like NormalizePathAndSet but with additional checks specific to the
// cache_path value.
base::FilePath NormalizeCachePathAndSet(cef_string_t& path_str,
const base::FilePath& root_cache_path) {
bool has_error = false;
base::FilePath path = NormalizePath(path_str, "cache_path", &has_error);
if (has_error || !ValidateCachePath(path, root_cache_path)) {
LOG(ERROR) << "The cache_path is invalid. Defaulting to in-memory storage.";
path = base::FilePath();
}
SetPath(path_str, path);
return path;
}
} // namespace } // namespace
int CefExecuteProcess(const CefMainArgs& args, int CefExecuteProcess(const CefMainArgs& args,
@@ -173,52 +182,8 @@ int CefExecuteProcess(const CefMainArgs& args,
InitCrashReporter(); InitCrashReporter();
#endif #endif
base::CommandLine command_line(base::CommandLine::NO_PROGRAM); return CefMainRunner::RunAsHelperProcess(args, application,
#if defined(OS_WIN) windows_sandbox_info);
command_line.ParseFromString(::GetCommandLineW());
#else
command_line.InitFromArgv(args.argc, args.argv);
#endif
// Wait for the debugger as early in process initialization as possible.
if (command_line.HasSwitch(switches::kWaitForDebugger))
base::debug::WaitForDebugger(60, true);
// If no process type is specified then it represents the browser process and
// we do nothing.
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
if (process_type.empty())
return -1;
#if defined(OS_MACOSX) || defined(OS_WIN)
if (process_type == crash_reporter::switches::kCrashpadHandler)
return RunAsCrashpadHandler(command_line);
#endif
CefMainDelegate main_delegate(application);
// Execute the secondary process.
#if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (windows_sandbox_info == nullptr) {
content::InitializeSandboxInfo(&sandbox_info);
windows_sandbox_info = &sandbox_info;
}
content::ContentMainParams params(&main_delegate);
params.instance = args.instance;
params.sandbox_info =
static_cast<sandbox::SandboxInterfaceInfo*>(windows_sandbox_info);
return content::ContentMain(params);
#else
content::ContentMainParams params(&main_delegate);
params.argc = args.argc;
params.argv = const_cast<const char**>(args.argv);
return content::ContentMain(params);
#endif
} }
bool CefInitialize(const CefMainArgs& args, bool CefInitialize(const CefMainArgs& args,
@@ -242,8 +207,6 @@ bool CefInitialize(const CefMainArgs& args,
return false; return false;
} }
g_browser_process = new ChromeBrowserProcessStub();
// Create the new global context object. // Create the new global context object.
g_context = new CefContext(); g_context = new CefContext();
@@ -303,8 +266,7 @@ void CefRunMessageLoop() {
return; return;
} }
base::RunLoop run_loop; g_context->RunMessageLoop();
run_loop.Run();
} }
void CefQuitMessageLoop() { void CefQuitMessageLoop() {
@@ -320,8 +282,7 @@ void CefQuitMessageLoop() {
return; return;
} }
// Quit the CefBrowserMessageLoop. g_context->QuitMessageLoop();
base::RunLoop::QuitCurrentWhenIdleDeprecated();
} }
void CefSetOSModalLoop(bool osModalLoop) { void CefSetOSModalLoop(bool osModalLoop) {
@@ -333,7 +294,7 @@ void CefSetOSModalLoop(bool osModalLoop) {
} }
if (CEF_CURRENTLY_ON_UIT()) if (CEF_CURRENTLY_ON_UIT())
base::MessageLoopCurrent::Get()->set_os_modal_loop(osModalLoop); base::CurrentThread::Get()->set_os_modal_loop(osModalLoop);
else else
CEF_POST_TASK(CEF_UIT, base::Bind(CefSetOSModalLoop, osModalLoop)); CEF_POST_TASK(CEF_UIT, base::Bind(CefSetOSModalLoop, osModalLoop));
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
@@ -357,6 +318,7 @@ bool CefContext::Initialize(const CefMainArgs& args,
void* windows_sandbox_info) { void* windows_sandbox_info) {
init_thread_id_ = base::PlatformThread::CurrentId(); init_thread_id_ = base::PlatformThread::CurrentId();
settings_ = settings; settings_ = settings;
application_ = application;
#if !(defined(OS_WIN) || defined(OS_LINUX)) #if !(defined(OS_WIN) || defined(OS_LINUX))
if (settings.multi_threaded_message_loop) { if (settings.multi_threaded_message_loop) {
@@ -370,91 +332,46 @@ bool CefContext::Initialize(const CefMainArgs& args,
SignalChromeElf(); SignalChromeElf();
#endif #endif
base::FilePath cache_path = base::FilePath(CefString(&settings_.cache_path));
if (!ValidateCachePath(cache_path)) {
// Reset to in-memory storage.
CefString(&settings_.cache_path).clear();
cache_path = base::FilePath();
}
const base::FilePath& root_cache_path = const base::FilePath& root_cache_path =
base::FilePath(CefString(&settings_.root_cache_path)); NormalizePathAndSet(settings_.root_cache_path, "root_cache_path");
const base::FilePath& cache_path =
NormalizeCachePathAndSet(settings_.cache_path, root_cache_path);
if (root_cache_path.empty() && !cache_path.empty()) { if (root_cache_path.empty() && !cache_path.empty()) {
CefString(&settings_.root_cache_path) = CefString(&settings_.cache_path); CefString(&settings_.root_cache_path) = cache_path.value();
} }
main_delegate_.reset(new CefMainDelegate(application)); // All other paths that need to be normalized.
NormalizePathAndSet(settings_.browser_subprocess_path,
"browser_subprocess_path");
NormalizePathAndSet(settings_.framework_dir_path, "framework_dir_path");
NormalizePathAndSet(settings_.main_bundle_path, "main_bundle_path");
NormalizePathAndSet(settings_.user_data_path, "user_data_path");
NormalizePathAndSet(settings_.resources_dir_path, "resources_dir_path");
NormalizePathAndSet(settings_.locales_dir_path, "locales_dir_path");
browser_info_manager_.reset(new CefBrowserInfoManager); browser_info_manager_.reset(new CefBrowserInfoManager);
int exit_code; main_runner_.reset(new CefMainRunner(settings_.multi_threaded_message_loop,
settings_.external_message_pump));
return main_runner_->Initialize(
&settings_, application, args, windows_sandbox_info, &initialized_,
base::BindOnce(&CefContext::OnContextInitialized,
base::Unretained(this)));
}
// Initialize the content runner. void CefContext::RunMessageLoop() {
content::ContentMainParams params(main_delegate_.get()); // Must always be called on the same thread as Initialize.
#if defined(OS_WIN) DCHECK(OnInitThread());
sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (windows_sandbox_info == nullptr) {
content::InitializeSandboxInfo(&sandbox_info);
windows_sandbox_info = &sandbox_info;
settings_.no_sandbox = true;
}
params.instance = args.instance; // Blocks until QuitMessageLoop() is called.
params.sandbox_info = main_runner_->RunMessageLoop();
static_cast<sandbox::SandboxInterfaceInfo*>(windows_sandbox_info); }
#else
params.argc = args.argc;
params.argv = const_cast<const char**>(args.argv);
#endif
sm_main_delegate_.reset( void CefContext::QuitMessageLoop() {
new content::ContentServiceManagerMainDelegate(params)); // Must always be called on the same thread as Initialize.
sm_main_params_.reset( DCHECK(OnInitThread());
new service_manager::MainParams(sm_main_delegate_.get()));
#if defined(OS_POSIX) && !defined(OS_ANDROID) main_runner_->QuitMessageLoop();
sm_main_params_->argc = params.argc;
sm_main_params_->argv = params.argv;
#endif
exit_code = service_manager::MainInitialize(*sm_main_params_);
DCHECK_LT(exit_code, 0);
if (exit_code >= 0)
return false;
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Initialize();
if (settings.multi_threaded_message_loop) {
base::WaitableEvent uithread_startup_event(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
if (!main_delegate_->CreateUIThread(base::BindOnce(
[](CefContext* context, base::WaitableEvent* event) {
service_manager::MainRun(*context->sm_main_params_);
event->Signal();
},
base::Unretained(this),
base::Unretained(&uithread_startup_event)))) {
return false;
}
initialized_ = true;
// We need to wait until service_manager::MainRun has finished.
uithread_startup_event.Wait();
} else {
initialized_ = true;
service_manager::MainRun(*sm_main_params_);
}
if (CEF_CURRENTLY_ON_UIT()) {
OnContextInitialized();
} else {
// Continue initialization on the UI thread.
CEF_POST_TASK(CEF_UIT, base::Bind(&CefContext::OnContextInitialized,
base::Unretained(this)));
}
return true;
} }
void CefContext::Shutdown() { void CefContext::Shutdown() {
@@ -463,28 +380,9 @@ void CefContext::Shutdown() {
shutting_down_ = true; shutting_down_ = true;
if (settings_.multi_threaded_message_loop) { main_runner_->Shutdown(
// Events that will be used to signal when shutdown is complete. Start in base::BindOnce(&CefContext::ShutdownOnUIThread, base::Unretained(this)),
// non-signaled mode so that the event will block. base::BindOnce(&CefContext::FinalizeShutdown, base::Unretained(this)));
base::WaitableEvent uithread_shutdown_event(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
// Finish shutdown on the UI thread.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefContext::FinishShutdownOnUIThread,
base::Unretained(this), &uithread_shutdown_event));
/// Block until UI thread shutdown is complete.
uithread_shutdown_event.Wait();
FinalizeShutdown();
} else {
// Finish shutdown on the current thread, which should be the UI thread.
FinishShutdownOnUIThread(nullptr);
FinalizeShutdown();
}
} }
bool CefContext::OnInitThread() { bool CefContext::OnInitThread() {
@@ -519,11 +417,14 @@ CefTraceSubscriber* CefContext::GetTraceSubscriber() {
return trace_subscriber_.get(); return trace_subscriber_.get();
} }
void CefContext::PopulateRequestContextSettings( void CefContext::PopulateGlobalRequestContextSettings(
CefRequestContextSettings* settings) { CefRequestContextSettings* settings) {
CefRefPtr<CefCommandLine> command_line = CefRefPtr<CefCommandLine> command_line =
CefCommandLine::GetGlobalCommandLine(); CefCommandLine::GetGlobalCommandLine();
// This value was already normalized in Initialize.
CefString(&settings->cache_path) = CefString(&settings_.cache_path); CefString(&settings->cache_path) = CefString(&settings_.cache_path);
settings->persist_session_cookies = settings->persist_session_cookies =
settings_.persist_session_cookies || settings_.persist_session_cookies ||
command_line->HasSwitch(switches::kPersistSessionCookies); command_line->HasSwitch(switches::kPersistSessionCookies);
@@ -537,29 +438,17 @@ void CefContext::PopulateRequestContextSettings(
CefString(&settings_.accept_language_list); CefString(&settings_.accept_language_list);
} }
bool CefContext::ValidateCachePath(const base::FilePath& cache_path) { void CefContext::NormalizeRequestContextSettings(
if (cache_path.empty()) CefRequestContextSettings* settings) {
return true; // The |root_cache_path| value was already normalized in Initialize.
const base::FilePath& root_cache_path = CefString(&settings_.root_cache_path);
NormalizeCachePathAndSet(settings->cache_path, root_cache_path);
const base::FilePath& root_cache_path = if (settings->accept_language_list.length == 0) {
base::FilePath(CefString(&settings_.root_cache_path)); // Use the global language list setting.
if (!root_cache_path.empty() && root_cache_path != cache_path && CefString(&settings->accept_language_list) =
!root_cache_path.IsParent(cache_path)) { CefString(&settings_.accept_language_list);
LOG(ERROR) << "The cache_path directory (" << cache_path.value()
<< ") is not a child of the root_cache_path directory ("
<< root_cache_path.value() << ")";
return false;
} }
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (!base::DirectoryExists(cache_path) &&
!base::CreateDirectory(cache_path)) {
LOG(ERROR) << "The cache_path directory (" << cache_path.value()
<< ") could not be created.";
return false;
}
return true;
} }
void CefContext::AddObserver(Observer* observer) { void CefContext::AddObserver(Observer* observer) {
@@ -580,25 +469,16 @@ bool CefContext::HasObserver(Observer* observer) const {
void CefContext::OnContextInitialized() { void CefContext::OnContextInitialized() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
static_cast<ChromeBrowserProcessStub*>(g_browser_process)
->OnContextInitialized();
#if BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
CefWidevineLoader::GetInstance()->OnContextInitialized();
#endif
// Notify the handler. // Notify the handler.
CefRefPtr<CefApp> app = CefContentClient::Get()->application(); if (application_) {
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> handler = CefRefPtr<CefBrowserProcessHandler> handler =
app->GetBrowserProcessHandler(); application_->GetBrowserProcessHandler();
if (handler.get()) if (handler)
handler->OnContextInitialized(); handler->OnContextInitialized();
} }
} }
void CefContext::FinishShutdownOnUIThread( void CefContext::ShutdownOnUIThread() {
base::WaitableEvent* uithread_shutdown_event) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
browser_info_manager_->DestroyAllBrowsers(); browser_info_manager_->DestroyAllBrowsers();
@@ -608,34 +488,9 @@ void CefContext::FinishShutdownOnUIThread(
if (trace_subscriber_.get()) if (trace_subscriber_.get())
trace_subscriber_.reset(nullptr); trace_subscriber_.reset(nullptr);
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Shutdown();
ui::ResourceBundle::GetSharedInstance().CleanupOnUIThread();
sm_main_delegate_->ShutdownOnUIThread();
if (uithread_shutdown_event)
uithread_shutdown_event->Signal();
} }
void CefContext::FinalizeShutdown() { void CefContext::FinalizeShutdown() {
if (content::RenderProcessHost::run_renderer_in_process()) {
// Blocks until RenderProcess cleanup is complete.
CefContentRendererClient::Get()->RunSingleProcessCleanup();
}
// Shut down the browser runner or UI thread.
main_delegate_->ShutdownBrowser();
// Shut down the content runner.
service_manager::MainShutdown(*sm_main_params_);
browser_info_manager_.reset(nullptr); browser_info_manager_.reset(nullptr);
sm_main_params_.reset(nullptr); application_ = nullptr;
sm_main_delegate_.reset(nullptr);
main_delegate_.reset(nullptr);
delete g_browser_process;
g_browser_process = nullptr;
} }

View File

@@ -11,26 +11,14 @@
#include <string> #include <string>
#include "include/cef_app.h" #include "include/cef_app.h"
#include "libcef/browser/main_runner.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/threading/platform_thread.h" #include "base/threading/platform_thread.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
namespace base {
class WaitableEvent;
}
namespace content {
class ContentServiceManagerMainDelegate;
}
namespace service_manager {
struct MainParams;
}
class CefBrowserHostImpl; class CefBrowserHostImpl;
class CefBrowserInfoManager; class CefBrowserInfoManager;
class CefMainDelegate;
class CefTraceSubscriber; class CefTraceSubscriber;
class CefContext { class CefContext {
@@ -59,6 +47,8 @@ class CefContext {
const CefSettings& settings, const CefSettings& settings,
CefRefPtr<CefApp> application, CefRefPtr<CefApp> application,
void* windows_sandbox_info); void* windows_sandbox_info);
void RunMessageLoop();
void QuitMessageLoop();
void Shutdown(); void Shutdown();
// Returns true if the current thread is the initialization thread. // Returns true if the current thread is the initialization thread.
@@ -87,10 +77,11 @@ class CefContext {
// Populate request context settings for the global system context based on // Populate request context settings for the global system context based on
// CefSettings and command-line flags. // CefSettings and command-line flags.
void PopulateRequestContextSettings(CefRequestContextSettings* settings); void PopulateGlobalRequestContextSettings(
CefRequestContextSettings* settings);
// Verify that |cache_path| is valid and create it if necessary. // Normalize and validate request context settings for user-created contexts.
bool ValidateCachePath(const base::FilePath& cache_path); void NormalizeRequestContextSettings(CefRequestContextSettings* settings);
// Manage observer objects. The observer must either outlive this object or // Manage observer objects. The observer must either outlive this object or
// remove itself before destruction. These methods can only be called on the // remove itself before destruction. These methods can only be called on the
@@ -104,7 +95,7 @@ class CefContext {
// Performs shutdown actions that need to occur on the UI thread before any // Performs shutdown actions that need to occur on the UI thread before any
// threads are destroyed. // threads are destroyed.
void FinishShutdownOnUIThread(base::WaitableEvent* uithread_shutdown_event); void ShutdownOnUIThread();
// Destroys the main runner and related objects. // Destroys the main runner and related objects.
void FinalizeShutdown(); void FinalizeShutdown();
@@ -117,10 +108,9 @@ class CefContext {
base::PlatformThreadId init_thread_id_; base::PlatformThreadId init_thread_id_;
CefSettings settings_; CefSettings settings_;
CefRefPtr<CefApp> application_;
std::unique_ptr<CefMainDelegate> main_delegate_; std::unique_ptr<CefMainRunner> main_runner_;
std::unique_ptr<content::ContentServiceManagerMainDelegate> sm_main_delegate_;
std::unique_ptr<service_manager::MainParams> sm_main_params_;
std::unique_ptr<CefTraceSubscriber> trace_subscriber_; std::unique_ptr<CefTraceSubscriber> trace_subscriber_;
std::unique_ptr<CefBrowserInfoManager> browser_info_manager_; std::unique_ptr<CefBrowserInfoManager> browser_info_manager_;

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