Compare commits

...

150 Commits
3683 ... 3809

Author SHA1 Message Date
Marshall Greenblatt
f19c584555 Windows: cmake: Add additional cef_sandbox link dependencies (fixes issue #2754) 2019-08-30 11:42:03 -04:00
Marshall Greenblatt
c6d4d854fc Revert "Windows: Add boringssl to cef_sandbox to fix VS2017 link error (fixes issue #2743)"
This reverts commit 2cf916e6d5.

This change causes linker errors with third-party projects using VS2019 that also link openssl.

cef_sandbox.lib(err.obj) : error LNK2005: _ERR_get_error already defined in websockets.lib(mbedtls-client.obj)
cef_sandbox.lib(err.obj) : error LNK2005: _ERR_error_string already defined in websockets.lib(ssl_lib.obj)
cef_sandbox.lib(err.obj) : error LNK2005: _ERR_error_string_n already defined in websockets.lib(ssl_lib.obj)
cef_sandbox.lib(err.obj) : error LNK2005: _ERR_free_strings already defined in websockets.lib(ssl_lib.obj)
2019-08-29 14:46:26 -04:00
Marshall Greenblatt
dc028ce5ef Update to Chromium version 76.0.3809.132 2019-08-28 15:07:28 -04:00
Marshall Greenblatt
20d771a9b8 Fix folder upload with input type=file webkitdirectory (fixes issue #2751) 2019-08-26 15:50:06 -04:00
Marshall Greenblatt
2cf916e6d5 Windows: Add boringssl to cef_sandbox to fix VS2017 link error (fixes issue #2743) 2019-08-06 17:19:03 -04:00
Marshall Greenblatt
e067612e55 macOS: Create multiple Helper app bundles (fixes issue #2737) 2019-08-06 15:28:24 -04:00
Riku Palomäki
8600e3902d Fix gclient_util after depot_tools changes (fixes issue #2736) 2019-08-05 14:03:08 -04:00
Dmitry Azaraev
c345089a8a Fix missing marshaling for CefSettings::root_cache_path member (fixes issue #2740) 2019-08-05 14:03:01 -04:00
Marshall Greenblatt
d8a577c0f1 Update to Chromium version 76.0.3809.87 2019-07-31 17:05:17 -04:00
Marshall Greenblatt
e7c2287181 Fix crash on DevTools remote debugging of WebWorkers (fixes issue #2605) 2019-07-26 09:49:00 -04:00
Marshall Greenblatt
d98abbb792 Remove unused GetCompositor method and fix macOS compile error (see issue #2575) 2019-07-26 09:29:17 -04:00
Marshall Greenblatt
a5c0af3554 Fix missing cookie after redirect response with filter (fixes issue #2689, see issue #2622) 2019-07-25 17:01:33 -04:00
Marshall Greenblatt
f84547cd34 Fix option for persisting session cookies (fixes issue #2720, see issue #2622) 2019-07-25 15:28:27 -04:00
Marshall Greenblatt
6b04492610 Fix C compile error due to unintentional C++ include (fixes issue #2728) 2019-07-25 13:35:28 -04:00
Marshall Greenblatt
52501f158c macOS: Fix alert dialog display (fixes issue #2726) 2019-07-25 12:35:27 -04:00
Rob Sussman
ffb9266853 macOS: Support configuration of the main bundle path (fixes issue #2729) 2019-07-25 12:35:18 -04:00
Dmitry Azaraev
cd8efe748c Fix typo in documentation for CefResourceHandler::Skip 2019-07-25 12:35:09 -04:00
Marshall Greenblatt
2c7943b121 Fix PDF load in <embed> and <object> tags (fixes issue #2727, see issue #2622) 2019-07-24 17:14:25 -04:00
Marshall Greenblatt
6223f1bcb4 Fix crash on shutdown with PDF viewer and multi-threaded message loop (fixes issue #2709, see issue #2622)
Requests from the PDF viewer are not associated with a CefBrowser. Consequently,
the InterceptedRequestHandler for those requests will register as an observer of
CefContext destruction. When the browser is closed the InterceptedRequestHandler
is destroyed and an async task is posted to remove/delete the observer on the UI
thread. If CefShutdown is then called the task may execute after shutdown has
started, in which case CONTEXT_STATE_VALID() will return false. We still need to
remove the observer in this case to avoid a use-after-free in
FinishShutdownOnUIThread.
2019-07-23 15:28:42 -04:00
Dmitry Azaraev
f8e6d11f35 Fix typo in documentation for cef_settings_t::cache_path. 2019-07-23 15:28:36 -04:00
Marshall Greenblatt
c8ee94c593 Fix crash when extensions are disabled (fixes issue #2708, see issue #2622) 2019-07-23 12:28:28 -04:00
Marshall Greenblatt
7c91b9ffd0 Fix crash when showing views context menu 2019-07-23 09:43:28 -04:00
Marshall Greenblatt
763dfe6116 Update to Chromium version 76.0.3809.62 2019-07-16 21:01:31 -04:00
Masako Toda
99c27f57b1 Fix redirect of requests with credentials mode 'include' (fixes issue #2699, see issue #2622).
Modifying the URL in OnBeforeResourceLoad causes an internal redirect response.
In cases where the request is cross-origin and credentials mode is 'include'
the redirect response must include the "Access-Control-Allow-Credentials"
header, otherwise the request will be blocked.
2019-07-16 17:43:44 -04:00
Riku Palomäki
367c6eb704 Fix dangling pointers in CefAudioMirrorDestination (fixes issue #2713). 2019-07-16 21:42:39 +00:00
Isaac Devine
1086495096 Fix race with multi-threaded message loop (fixes issue #2668).
Remove the local thread object in favor of setting the ui_thread_ field
directly. This avoids the race between ui_thread_.swap(thread) and
CefUIThread::InitializeBrowserRunner.
2019-07-16 21:42:35 +00:00
Alexander Guettler
17ec55a3b3 Fix dangling pointers in CefScopedArgArray (fixes issue #2704). 2019-07-16 21:42:20 +00:00
Marshall Greenblatt
3f1ebebde5 Add support for GetAuthCredentials (fixes issue #2718, see issue #2622).
When NetworkService is enabled requests created using CefFrame::CreateURLRequest
will call CefRequestHandler::GetAuthCredentials for the associated browser after
calling CefURLRequestClient::GetAuthCredentials if that call returns false.
2019-07-16 16:33:08 -04:00
Alexander Guettler
ac2cc54e13 Add initial Viz implementation for OSR (see issue #2575).
The old shared surface implementation has been removed and will need to be
re-implemented using the Viz code path.
2019-07-16 16:33:08 -04:00
Petra Öhlin
cc0db5f166 Update to Chromium version 76.0.3809.0 (#665002)
OSR tests will be fixed by a follow-up merge of Viz support (see issue #2575).
2019-07-16 15:34:16 -04:00
Marshall Greenblatt
5892ffc382 Remove POST data after redirect to GET (see issue #2707, see issue #2622).
For 303 redirects all request methods except HEAD are converted to GET as per
the latest http draft. For historical reasons the draft also allows POST
requests to be converted to GETs when following 301/302 redirects. Most major
browsers do this and so shall we. When a request is converted to GET any POST
data should also be removed.

Use 307 redirects instead if you want the request to be repeated using the same
method and POST data.
2019-07-11 16:56:51 -04:00
Marshall Greenblatt
45329d05a5 Fix cross-origin redirect from OnBeforeResourceLoad (fixes issue #2695, see issue #2622).
Modifying the URL in OnBeforeResourceLoad causes an internal redirect response.
In cases where the request is cross-origin (containing a non-null "Origin"
header) the redirect response must include the "Access-Control-Allow-Origin"
header, otherwise the request will be blocked.

This change also fixes a problem where existing request headers would be
discarded if the request was modified in OnBeforeResourceLoad.
2019-06-25 16:54:42 -04:00
Marshall Greenblatt
02a6b3bb38 Fix loading of http(s) sub-resources from custom scheme initiator (fixes issue #2685, see issue #2622).
Determine external request status based on the current URL instead of the
request initiator.
2019-06-25 10:50:33 -04:00
Marshall Greenblatt
732a307c75 Fix CefFrame::GetIdentifier value in the render process (fixes issue #2687, see issue #2498) 2019-06-19 16:55:31 +02:00
Marshall Greenblatt
b03a419c6b Fix crash if a pending request is continued after deletion (see issue #2622).
This is a speculative fix for a crash where the pending ResourceRequest appears
to be invalid after the request is continued from SetInitialized.
2019-06-19 15:49:08 +02:00
Marshall Greenblatt
ba08c21517 Fix crashes when a request is aborted during initialization (see issue #2622).
Initialization of request objects requires asynchronous hops between the UI and
IO threads. In some cases the browser may be destroyed, the mojo connection may
be aborted, or the ProxyURLLoaderFactory object may be deleted while
initialization is still in progress. This change fixes crashes and adds unit
tests that try to reproduce these conditions.

To test: Run `ceftests --gtest_repeat=50
              --gtest_filter=ResourceRequestHandlerTest.Basic*Abort*`
2019-06-18 16:21:04 +02:00
Marshall Greenblatt
81064faac3 Fix crash in ProxyURLLoaderFactory::MaybeDestroySelf (see issue #2622).
This is a speculative fix for a crash where |on_disconnect_| appears to be null
in ProxyURLLoaderFactory::MaybeDestroySelf. The hypothesis here is that
OnURLLoaderClientError is being called while the proxy object is still in-flight
to ResourceContextData::AddProxy (e.g. before SetDisconnectCallback has been
called for the proxy object). Additonally, this change protects against
MaybeDestroySelf attempting to execute |on_disconnect_| multiple times.
2019-06-14 18:52:31 +02:00
David Sowa
f0c82200ba Add ARM64 build and binary distribution support (see issue #1990)
Adds a new `--arm64-build` option to automate-git.py and make_distrib.py.
2019-06-13 11:52:32 +02:00
Marshall Greenblatt
c3c3af34fd Fix inclusion of cookies with restarted requests (fixes issue #2672, see issue #2622) 2019-06-12 17:19:09 +02:00
Marshall Greenblatt
dd04583dcb macOS: Don't disable custom libc++ for cef_sandbox build (see issue #2677) 2019-06-12 12:02:50 +02:00
Marshall Greenblatt
0b7c0be29a Use FrameTreeNodeId to find delay loaded iframes for OnBeforeBrowse (fixes issue #2675, see issue #2498) 2019-06-12 11:48:57 +02:00
Marshall Greenblatt
d277dcd5d7 Windows: cmake: Add newer VS versions 2019-06-11 18:12:29 +02:00
Marshall Greenblatt
939e9f40b5 Windows: Disable custom libc++ for cef_sandbox build (fixes issue #2677) 2019-06-11 18:12:23 +02:00
Marshall Greenblatt
6546556a14 Add NetworkService support for DevTools source maps (fixes issue #2671, see issue #2622) 2019-06-06 18:37:45 +02:00
Marshall Greenblatt
6193d8c554 Update to Chromium version 75.0.3770.0 (#652427) 2019-06-06 18:37:45 +02:00
Marshall Greenblatt
ab6fd322d1 Fix crash when loading a file:// URL (fixes issue #2670) 2019-06-05 16:32:24 +02:00
Cristian Amarie
7e742f6e1f Add SSL_CONNECTION_VERSION_TLS1_3 to cef_ssl_version_t (fixes issue #2669) 2019-06-03 08:55:36 +00:00
Marshall Greenblatt
fa5268fa2d Fix issues with request callbacks during browser shutdown (see issue #2622).
The behavior has changed as follows with NetworkService enabled:
- All pending and in-progress requests will now be aborted when the CEF context
  or associated browser is destroyed. The OnResourceLoadComplete callback will
  now also be called in this case for in-progress requests that have a handler.
- The CefResourceHandler::Cancel method will now always be called when resource
  handling is complete, irrespective of whether handling completed successfully.
- Request callbacks that arrive after the OnBeforeClose callback for the
  associated browser (which may happen for in-progress requests that are aborted
  on browser destruction) will now always have a non-nullptr CefBrowser
  parameter.
- Allow empty parameters to CefRequest and CefResponse methods where it makes
  sense (e.g. resetting default response state, or clearing a referrer value).
- Fixed a reference loop that was keeping CefResourceHandler objects from being
  destroyed if they were holding a callback reference (from ProcessRequest,
  ReadResponse, etc.) during CEF context or associated browser destruction.
- Fixed an issue where the main frame was not detached on browser destruction
  which could cause a crash due to RFH use-after-free (see issue #2498).

To test: All unit tests pass as expected.
2019-06-01 15:51:33 +03:00
Marshall Greenblatt
fd80e5c653 Fix assertions when shutting down with pending requests (see issue #2622).
This change avoids the starting of new requests during shutdown.
2019-05-29 20:01:12 +03:00
Marshall Greenblatt
2814054863 Linux: Fix crash when closing a browser with pending requests (see issue #2622).
This change fixes an issue where the cancel_callback for a pending request
might already have been executed when the OnBrowserDestroyed notification is
received.
2019-05-29 09:43:29 -07:00
Marshall Greenblatt
241941a44a Move message routing from CefBrowser to CefFrame (see issue #2498).
This change moves the SendProcessMessage method from CefBrowser to CefFrame and
adds CefBrowser parameters to OnProcessMessageReceived and
OnDraggableRegionsChanged.

The internal implementation has changed as follows:
- Frame IDs are now a 64-bit combination of the 32-bit render_process_id and
  render_routing_id values that uniquely identify a RenderFrameHost (RFH).
- CefFrameHostImpl objects are now managed by CefBrowserInfo with life span tied
  to RFH expectations. Specifically, a CefFrameHostImpl object representing a
  sub-frame will be created when a RenderFrame is created in the renderer
  process and detached when the associated RenderFrame is deleted or the
  renderer process in which it runs has died.
- The CefFrameHostImpl object representing the main frame will always be valid
  but the underlying RFH (and associated frame ID) may change over time as a
  result of cross-origin navigations. Despite these changes calling LoadURL on
  the main frame object in the browser process will always navigate as expected.
- Speculative RFHs, which may be created as a result of a cross-origin
  navigation and discarded if that navigation is not committed, are now handled
  correctly (e.g. ignored in most cases until they're committed).
- It is less likely, but still possible, to receive a CefFrame object with an
  invalid frame ID (ID < 0). This can happen in cases where a RFH has not yet
  been created for a sub-frame. For example, when OnBeforeBrowse is called
  before initiating navigation in a previously nonexisting sub-frame.

To test: All tests pass with NetworkService enabled and disabled.
2019-05-29 17:44:56 +03:00
Marshall Greenblatt
35295d2e27 Fix evaluation of "Cache-Control: no-cache, no-store" header value (see issue #2283)
Choose the stricter "no-cache" behavior which implies the "no-store" behavior.
2019-05-21 17:51:43 +03:00
Marshall Greenblatt
6011d45e38 Enable NetworkService by default (see issue #2622).
The NetworkService can still be disabled for a limited time by specifying the
`--disable-features=NetworkService` command-line flag.
2019-05-20 19:42:44 +03:00
Marshall Greenblatt
9ddb013875 Add NetworkService support for response filtering (see issue #2622).
To test: ResourceRequestHandlerTest.Filter* tests pass with NetworkService
enabled.
2019-05-20 14:39:37 +03:00
Marshall Greenblatt
e5c7fd1c55 Add NetworkService support for CefLoadCRLSetsFile (fixes issue #2497, see issue #2622). 2019-05-18 21:30:06 +03:00
Marshall Greenblatt
99eebd00c4 Add NetworkService support for more CefRequestContext methods (see issue #2622).
This adds support for the CloseAllConnections and ResolveHost methods.

To test: RequestContextTest.Close* and RequestContextTest.Resolve* tests pass
with NetworkService enabled.
2019-05-18 20:48:03 +03:00
Marshall Greenblatt
bddf2a311b Fix NetworkService ServerTest.* failures and test name typo (see issue #2622).
Always return ERR_NONE and the response body if a CefURLRequest completes
successfully, including for non-2xx status codes. This matches the behavior of
the old network stack.

To test: ServerTest.* tests pass with NetworkService enabled.
2019-05-18 17:54:02 +03:00
Marshall Greenblatt
9a30f05f80 macOS: Fix compile errors 2019-05-18 15:23:17 +03:00
Marshall Greenblatt
2ea173a254 Cancel NetworkService requests when the browser is destroyed (see issue #2622).
Pending requests that are associated with a browser will be canceled when that
browser is destroyed. Pending requests that are not associated with a browser
(e.g. created using CefURLRequest::Create), and that use the global context, may
still be pending when CefShutdown is called. For this reason the
no_debugct_check attribute has been added for CefResourceRequestHandler and
CefCookieAccessFilter interfaces.

To test: Load a YouTube video or other long-loading content in cefclient and
close the application. No assertions trigger for leaked CefFrame objects.
2019-05-18 12:40:45 +03:00
Marshall Greenblatt
ba0e1b5719 Add NetworkService support for CefURLRequest (see issue #2622).
Requests created using CefURLRequest::Create are not associated with a
browser/frame. When originating from the render process these requests cannot be
intercepted and consequently only http(s) and blob requests are supported. To
work around this limitation a new CefFrame::CreateURLRequest method has been
added that allows the request to be associated with that browser/frame for
interception purposes.

This change also fixes an issue with the NetworkService implementation where
redirected requests could result in two parallel requests being sent to the
target server.

To test: URLRequestTest.* tests pass with NetworkService enabled.
2019-05-17 21:42:25 +03:00
Chris Dziemborowicz
f9b042c375 Fix version calculation for older commits on a release branch (fixes issue #2659) 2019-05-15 14:35:41 +00:00
Marshall Greenblatt
c7701b8a61 Windows: Add arch-specific versions of d3dcompiler_47.dll (see issue #2656)
This fixes an issue where the 64-bit version of d3dcompiler_47.dll would be
included with 32-bit binary distributions.
2019-05-15 14:36:58 +03:00
Andrei Kurushin
03c1c21fd3 Fix crash when setting an invalid cookie (fixes issue #2657) 2019-05-08 18:12:21 +00:00
cef-ms
473c29a70d Add |extra_info| parameter for browser creation (fixes issue #1088)
The optional |extra_info| parameter provides an opportunity to specify extra
information specific to the created browser that will be passed to
CefRenderProcessHandler::OnBrowserCreated() in the render process.
2019-05-08 12:31:46 -04:00
Chris Dziemborowicz
ad4ce5f441 Fix |options| argument usage in GetJSONWriterOptions (fixes issue #2647) 2019-05-08 15:10:19 +00:00
Marshall Greenblatt
ef06407da6 Windows: Remove d3dcompiler_43.dll
The d3dcompiler_43.dll file was only required on Windows XP, which is no longer
supported.
2019-05-07 15:25:25 -04:00
Marshall Greenblatt
bbabccf9aa Windows: Add d3dcompiler_47.dll version 10.0.17134.12
This change adds the d3dcompiler_47.dll version that was included with Windows
SDK 10.0.17134. The newer version of this file included with Windows SDK
10.0.17763 adds a dependency on the Universal C Runtime (api-ms-win-crt-*.dll)
which might not be installed on Windows 7 (requires KB2999226).
2019-05-07 15:25:25 -04:00
Ananyo Maiti
3827f817c7 Support override of client id for file scanning (fixes issue #2368). 2019-05-07 16:22:16 +00:00
Marshall Greenblatt
8b400331c7 Support disabling of cookie load/save via SetSupportedSchemes (see issue #2622).
With this change the CefCookieManager::SetSupportedSchemes method can be used
to disable all loading and saving of cookies for the associated request context.
This matches functionality that was previously available via GetBlockingManager.

This change also fixes a bug where Set-Cookie headers returned for a request
handled via CefSchemeHandlerFactory would be ignored if there was not also a
CefResourceRequestHandler returned for the request.

To test: All CookieTest.* tests pass.
2019-05-02 18:33:10 -04:00
Marshall Greenblatt
cef882616b Fix NetworkService cache directory structure (see issue #2622).
To test: When running `cefclient --cache-path=c:\temp\cache` with NetworkService
enabled the the cache directory structure should be "C:\temp\cache\Cache"
instead of "C:\temp\cache\cache\Cache".
2019-05-02 14:51:02 -04:00
Marshall Greenblatt
4592cba19f Fix command-line override of the User-Agent product component (see issue #2622).
When the NetworkService is enabled the U-A string is configured via
SystemNetworkContextManager::CreateDefaultNetworkContextParams, which calls
chrome_content_browser_client.cc GetUserAgent(). This change modifies the Chrome
implementation to match CEF, so that the U-A product component can still be
overridden via the `--product-version` command-line flag.

To test: Verify that chrome://version, navigator.userAgent (JS executed from
DevTools console) and network requests (headers shown in DevTools Network tab)
show the expected User-Agent value in the following cases:
- Running `cefclient --enable-network-service --user-agent="<value>"`
- Running `cefclient --enable-network-service --product-version="<value>"`
2019-05-02 14:06:54 -04:00
Marshall Greenblatt
b1018ad64b Fix SystemNetworkContextManager initialization timing (see issue #2622). 2019-05-02 13:33:44 -04:00
Marshall Greenblatt
5ce52bd775 Add NetworkService support for extensions and downloads (see issue #2622).
To test:
- All tests pass with NetworkService disabled. DownloadTest.*, ExtensionTest.*
  and PluginTest.* tests pass with NetworkService enabled.
- The PDF extension displays a file, and the download and print buttons work.
2019-05-01 17:10:52 -04:00
Marshall Greenblatt
0193a3fe54 Fix NetworkService expectations for NavigationTest.Redirect* tests (see issue #2622). 2019-04-30 17:54:17 -04:00
Marshall Greenblatt
fb0133cd4b Fix NetworkService expectations for FrameTest.*Nav tests (see issue #2622). 2019-04-30 17:33:40 -04:00
Marshall Greenblatt
370cc028cb Add NetworkService support for chrome and chrome-devtools schemes (see issue #2622).
Known behavior changes:
- Unsupported chrome hosts no longer redirect to chrome://version.

To test: All tests pass with NetworkService disabled. WebUITest.* and V8Test.*
tests pass with NetworkService enabled.
2019-04-30 17:16:42 -04:00
Marshall Greenblatt
9fd6c8a1ee Mac: Fix build error and NetworkService startup assertion (see issue #2622).
Fixes FATAL:os_crypt_mac.mm(103)] Check failed: g_key_creation_util
2019-04-29 11:33:04 -04:00
Marshall Greenblatt
4e089766a5 Fix NetworkService startup assertion with multi-threaded message loop (see issue #2622).
When using multi-threaded message loop mode the PrefService needs to be created
on the UI thread.

To test: Run `cefclient --enable-network-service --multi-threaded-message-loop`.
The application should start successfully.
2019-04-26 17:17:26 -04:00
Marshall Greenblatt
cc80175e89 Linux: Fix NetworkService startup assertion in FeatureList::InitializeInstance (see issue #2622). 2019-04-26 13:22:07 -07:00
Marshall Greenblatt
8a4f4bff9b Fix NetworkService load hang with default request handling (see issue #2622).
This change fixes a load hang when no custom handlers (CefResourceRequestHandler
or registered scheme handler) are found for a request.

To test: Run `cefsimple --enable-network-service` and all requests load. Test
expectations are unchanged.
2019-04-26 14:22:44 -04:00
Marshall Greenblatt
2ace33f8b7 Move cookie load/save callbacks to CefCookieAccessFilter (see issue #2622).
This change allows the NetworkService to handle cookie load/save in cases where
cookies will not be filtered (CefResourceRequestHandler::GetCookieAccessFilter
returns null) and the request will be handled by the default network loader.
This represents a minor performance improvement by reducing the volume of cross-
process messaging in the default (no filtering or custom handing) case. Cookie
load/save still needs to be routed through the browser process if a filter is
returned, or if a CefResourceHandler is used for the request.

To test: Test expectations are unchanged.
2019-04-26 13:02:58 -04:00
Marshall Greenblatt
edd9efd1b3 Fix compile error due to missing override (fixes issue #2652) 2019-04-25 14:23:24 -04:00
Marshall Greenblatt
8f240861e3 Implement NetworkService request interception/handling (see issue #2622).
Implementation notes:
- Chromium change: CookieMonster::SetCookieableSchemes needs to be called
  immediately after the CookieMonster is created in NetworkContext::
  ApplyContextParamsToBuilder. Add a Profile::GetCookieableSchemes method and
  NetworkContextParams.cookieable_schemes member (set from
  ProfileNetworkContextService::CreateNetworkContextParams) to support that.
- Chromium change: Add a ContentBrowserClient::HandleExternalProtocol variant
  that exposes additional NetworkService request information.
- GetResourceResponseFilter is not yet implemented.

API changes:
- Resource-related callbacks have been moved from CefRequestHandler to a new
  CefResourceRequestHandler interface which is returned via the
  GetResourceRequestHandler method. If the CefRequestHandler declines to handle
  a resource it can optionally be handled by the CefRequestContextHandler, if
  any, associated with the loading context.
- The OnProtocolExecution callback has been moved from CefRequestHandler to
  CefResourceRequestHandler and will be called if a custom scheme request is
  unhandled.
- Cookie send/save permission callbacks have been moved from CefRequestHandler
  and CefResourceHandler to CefResourceRequestHandler.
- New methods added to CefResourceHandler that better match NetworkService
  execution sequence expectations. The old methods are now deprecated.
- New methods added to CefRequest and CefResponse.

Known behavior changes with the NetworkService implementation:
- Modifying the |new_url| parameter in OnResourceRedirect will no longer result
  in the method being called an additional time (likely a bug in the old
  implementation).
- Modifying the request URL in OnResourceResponse would previously cause a
  redirect. This behavior is now deprecated because the NetworkService does not
  support this functionality when using default network loaders. Temporary
  support has been added in combination with CefResourceHandler usage only.
- Other changes to the request object in OnResourceResponse will now cause the
  request to be restarted. This means that OnBeforeResourceLoad, etc, will be
  called an additional time with the new request information.
- CefResponse::GetMimeType will now be empty for non-200 responses.
- Requests using custom schemes can now be handled via CefResourceRequestHandler
  with the same callback behavior as builtin schemes.
- Redirects of custom scheme requests will now be followed as expected.
- Default handling of builtin schemes can now be disabled by setting
  |disable_default_handling| to true in GetResourceRequestHandler.
- Unhandled requests (custom scheme or builtin scheme with default handling
  disabled) will fail with an CefResponse::GetError value of
  ERR_UNKNOWN_URL_SCHEME.
- The CefSchemeHandlerFactory::Create callback will now include cookie headers.

To test:
- Run `cefclient --enable-network-service`. All resources should load
  successfully (this tests the transparent proxy capability).
- All tests pass with NetworkService disabled.
- The following tests pass with NetworkService enabled:
  - CookieTest.*
  - FrameTest.* (excluding .*Nav)
  - NavigationTest.* (excluding .Redirect*)
  - RequestHandlerTest.*
  - RequestContextTest.Basic*
  - RequestContextTest.Popup*
  - RequestTest.*
  - ResourceManagerTest.*
  - ResourceRequestHandlerTest.* (excluding .Filter*)
  - SchemeHandlerTest.*
  - StreamResourceHandlerTest.*
2019-04-23 22:53:28 -04:00
Jesper Papmehl-Dufay
019611c764 macOS: Add support for building clients with ARC enabled (fixes issue #2623).
Under ARC (Automatic Reference Counting), assigning to an Objective-C
pointer has different semantics than assigning to a void* pointer.
This makes it dangerous to treat the same memory address as an
Objective-C pointer in some cases and as a "regular C pointer" in
other cases.

This change removes the conditional type defines and instead uses
void* everywhere. Explicit type casting in combination with ARC
annotations makes it safe to get typed Objective-C pointers from the
void* pointers.

This change enables ARC by default in the CEF binary distribution CMake
configuration for the cefclient and cefsimple sample applications. It can be
disabled by adding `-DOPTION_USE_ARC=Off` to the CMake command line.

ARC is not supported when building Chromium due to the substantial
number of changes that would be required in the Chromium code base.
2019-04-23 17:17:56 +00:00
santosh mahto
491253fa03 Linux: Add support for ozone builds (fixes issue #2296).
Ozone builds can run with different platform backends (Wayland, X11, etc). Usage of the Views framework is required, and the cefclient sample application is not supported.

Example usage:

$ export GN_DEFINES="use_ozone=true"
$ cd /path/to/chromium/src/cef
$ ./cef_create_projects.sh
$ cd /path/to/chromium/src
$ ninja -C out/Release_GN_x64 cefsimple
$ ./out/Release_GN_x64/cefsimple --use-views --ozone-platform=wayland

Binary distributions can be created by passing the `--ozone` flag to make_distrib.py.
2019-04-23 17:00:14 +00:00
Marshall Greenblatt
07863c0d46 Use net/base/net_error_list.h to populate the cef_errorcode_t enum (fixes issue #2650) 2019-04-16 12:07:33 -04:00
Daniel Nitsche
879911b721 Update to Chromium version 75.0.3749.0 (#645082) 2019-04-16 14:38:48 +00:00
Riku Palomäki
1beec23065 Fix assert failure when hiding the OSR widget (fixes issue #2631) 2019-04-15 17:25:30 +00:00
Orfeas Zafeiris
5623338662 Fix OSR use_external_begin_frame support and update VSync setters (fixes issue #2618) 2019-04-15 16:57:33 +00:00
Marshall Greenblatt
941d53ebfd Fix CHECK on startup when running with --trace-startup=mojom (see issue #2622). 2019-03-27 14:44:11 -04:00
Marshall Greenblatt
9ce29e8ec5 Fix crash on shutdown with extensions enabled (see issue #2622).
We don't support the WebRequestAPI yet, so we shouldn't be creating any objects
for it.

To test: Run `cefclient --enable-network-service` and then close the app.
2019-03-27 14:43:54 -04:00
Marshall Greenblatt
aa42db6e25 automate-git: Fix .gclient file format for updated depot_tools (fixes issue #2639) 2019-03-27 13:03:52 -04:00
Petra Öhlin
04e2728dc2 Mac: cefclient:: Add C++ implementation of BrowserWindowOsrMac::UpdateAccessibilityLocation
This fixes an build break that was introduced by commit af349ad (see issue #2604).
2019-03-26 14:13:55 +00:00
Marshall Greenblatt
b949d86c40 Move CookieManager callbacks to the UI thread (see issue #2622).
The Chromium content layer (which also exposes the NetworkService interface)
generally runs on the UI thread. Previous use of the IO thread for CookieManager
callbacks is an implementation detail of the old network stack that shouldn't be
exposed to clients.

To test: Run ceftests. They should pass as expected.
2019-03-25 15:36:08 -04:00
Marshall Greenblatt
85c34c4dcf Add CookieManagerImpl for NetworkService (see issue #2622).
To test: Run `ceftests --gtest_filter=CookieTest.*:-CookieTest.GetCookieManager*
                       --enable-network-service`

There should be no functional change when running without the NetworkService
enabled.

Known issues:
- CefCookieManager::SetSupportedSchemes is not yet implemented.
2019-03-25 15:35:59 -04:00
Marshall Greenblatt
b65f336f81 Enforce cache_path requirements for NetworkService (see issue #2622).
This change adds a new CefSettings.root_cache_path value that must be either
equal to or a parent directory of all CefSettings.cache_path and
CefRequestContextSettings.cache_path values. The sandbox may block read/write
access from the NetworkService to directories that do not meet this requirement.

To test: Run cefclient with a combination of the following flags:

--cache-path=c:\temp\cache
  Cache data should be persisted to the specified directory.

--request-context-per-browser
  A separate numbered cache directory should be created underneath the
  cache-path directory for each new browser instance.

--enable-network-service --disable-extensions
  Same tests, but with NetworkService enabled.

Known issues:
- When NetworkService is enabled a C:\temp\cache\cache\Cache directory is
  created (should be C:\temp\cache\Cache).
2019-03-24 16:47:00 -04:00
Marshall Greenblatt
9b43d265c3 Remove Chromium patches that are no longer required (see issue #2622). 2019-03-24 16:45:07 -04:00
Marshall Greenblatt
ea27dff338 Move the frame/handler association to CefResourceContext (see issue #2622).
A CefBrowserHostImpl is created using a CefRequestContextImpl that may have a
CefRequestContextHandler. Multiple CefRequestContextImpl may share the same
underlying CefBrowserContext which owns a CefResourceContext. IO-thread
callbacks from Chromium are often associated with a CefResourceContext and the
target frame is identified using render_process_id/render_frame_id routing IDs.

This change forwards frame create/delete notifications from CefBrowserHostImpl
(or CefMimeHandlerViewGuestDelegate) to CefResourceContext so that it can
properly resolve the association from routing ID to Handler when queried from
CefPluginServiceFilter::IsPluginAvailable.

To test: Verify that all ceftests pass with NetworkService disabled.
2019-03-24 16:45:07 -04:00
Marshall Greenblatt
a23e845244 Remove methods that modify cookie storage at runtime (see issue #2622).
This change removes cookie and request handler functionality that will not
supported by the NetworkService. Specifically, it is no longer possible to
change cookie storage locations at runime by returning a different
CefCookieManager for an already initialized CefRequestContext. After this change
you will need to use a separate CefRequestContext when creating a CefBrowser if
you require separate cookie storage.

The following methods have been removed:
- CefCookieManager::CreateManager
- CefCookieManager::GetBlockingManager
- CefCookieManager::SetStoragePath
- CefRequestContextHandler::GetCookieManager

The following methods have been renamed:
- CefRequestContext::GetDefaultCookieManager to GetCookieManager.

This change substantially simplifies the network implementation in CEF because
it is no longer necessary to proxy objects that are normally owned by Chromium.
Chromium patches that are no longer necessary will be removed as a follow-up
commit.

To test: Verify that `ceftests --gtest_filter=-PluginTest.*` pass with
NetworkService disabled. Plugin tests will be fixed in a follow-up commit.
2019-03-24 16:45:06 -04:00
Marshall Greenblatt
6b2c1fe969 Add initial NetworkService support (see issue #2622).
This change adds an --enable-network-service command-line flag to run with
NetworkService enabled.

To test: Run `cefclient --enable-network-service --disable-extensions`. The
application should start, load a website and exit without crashing.
Network-related handlers (for cookies, schemes, requests, etc) and extensions
are not expected to work yet.

There should be no functional change when running without the NetworkService
enabled.
2019-03-24 16:43:56 -04:00
Andrei Kurushin
af349ade33 cefclient: OSR accessibility enhancements (see issue #2604)
- Implement multi-tree support (e.g. page with iframes contains several trees)
- Implement OnAccessibilityLocationChange support
- Add scroll offset calculation
- Fix new Chromium tree layout parsing
- Fix uninitialized OsrAXNode::offset_container_id_
- Fix Windows non ascii AxName, AxValue, AxDescription representation
2019-03-21 16:56:06 +00:00
Marshall Greenblatt
b3468451f5 Linux: Load additional binaries from DIR_ASSETS (fixes issue #1936)
This adds *.pak, locales/*.pak , chrome-sandbox, libGLESv2.so, libEGL.so and
swiftshader/*.so to the list of binaries that will be loaded from the libcef.so
directory instead of the executable directory by default.
2019-03-20 14:14:49 -04:00
Marshall Greenblatt
48f7c67587 cefbuilds: Encode plus signs in filenames (see issue #2596) 2019-03-20 09:59:28 -04:00
Riku Palomäki
e5568118ac Don't create cache directories in incognito mode (fixes issue #2289) 2019-03-18 17:22:52 -04:00
Riku Palomäki
a48e072076 Linux: Add OSR use_external_begin_frame support (see issue #1006) 2019-03-18 21:07:02 +00:00
Riku Palomäki
531df6eaba Fix frozen OSR rendering after resize (fixes issue #2627) 2019-03-18 21:04:21 +00:00
Riku Palomäki
64ad8c32f2 Make sure to call OnLoadingStateChange when navigation state changes (fixes issue #2624) 2019-03-18 21:03:36 +00:00
Riku Palomäki
d8845b88f4 Fix OSR PDF viewer rendering on initial page load (fixes issue #2598) 2019-03-18 21:02:37 +00:00
Marshall Greenblatt
e7d8dd5ef7 Enable new version number format by default (see issue #2596)
To continue using the old format set the CEF_OLD_VERSION_FORMAT=1 environment
variable before building.
2019-03-18 16:55:23 -04:00
Chris Dziemborowicz
1b9bc33bcf Mac: Fix undefined C++ symbols in cef_sandbox.a (see issue #2629)
This change updates make_distrib.py to link in all of libc++ and libc++abi from the Chromium build when generating cef_sandbox.a. This increases the size of the release build of cef_sandbox.a from about 0.5 MB to about 2.0 MB, but it ensures that no C++ symbols are imported by the archive.

Linking cef_sandbox.a with an incompatible C++ library prior to this change could cause undefined behavior in the resulting binary.

To make sure that we do not regress this fix, this change also updates make_distrib.py to verify that no C++ symbols are imported by cef_sandbox.a after it is generated (in a way similar to the way we verify that cef_sandbox.a exports the correct symbols).
2019-03-16 17:12:19 +00:00
Marshall Greenblatt
a4f0b4c5fb Linux: cmake: Add xi dependency for cefclient (see issue #1059) 2019-03-15 13:41:48 -04:00
Marshall Greenblatt
872f25dcc6 cefbuilds: Add support for new version number format (see issue #2596) 2019-03-15 13:16:50 -04:00
Marshall Greenblatt
2a40650926 Compute all version numbers using cef_version.py (see issue #2596)
The version format can now be controlled by setting the CEF_OLD_VERSION_FORMAT
environment variable. The old format is currently the default.
2019-03-15 13:16:43 -04:00
Marshall Greenblatt
a76f40eb83 Add cef_api_hash.h generated by the translator tool (see issue #2596)
This splits out the API hashes from the cef_version.h file which is generated at
build time. Changes to the cef_api_hash.h file are committed to the repo and
represent potentially breaking API changes. This commit history will be used to
calculate the version number.
2019-03-14 12:44:24 -04:00
Alexander Guettler
725ed88529 Update to Chromium version 74.0.3729.0 (#638880)
- Windows: 10.0.17763.0 SDK is now required.
- Mac: 10.13 SDK is now required.
- Removed CefRequestContext::ResolveHostCached which is no longer supported by Chromium.
2019-03-13 21:27:37 +00:00
Mike Wiedenbauer
58e1149c71 Add ability to capture audio output to buffer (issue #2381) 2019-03-07 17:09:54 -05:00
Riku Palomäki
7b5d30e9a9 Add pen support for OSR (issue #1059) 2019-03-07 22:06:54 +00:00
Felix Bruns
4cbcb4615a Add 'UR_FLAG_DISABLE_CACHE' and support for equivalent 'Cache-Control: no-store' (issue #2283) 2019-03-07 22:05:36 +00:00
Riku Palomäki
602c163127 Linux: Override DIR_ASSETS with libcef directory (issue #1936) 2019-03-07 22:04:32 +00:00
Riku Palomäki
feffedbae9 Fix a crash when resizing an OSR browser window (issue #2614) 2019-03-07 22:03:35 +00:00
Riku Palomäki
18ef4f72c7 Fix OSR crash when display DPI changes (issue #2600). 2019-02-27 19:44:31 +00:00
Branko Čibej
34db87563e Linux: Add support for setting the initial window title (issue #2204). 2019-02-27 19:18:16 +00:00
Branko Čibej
658bf2834a Linux: Add support for the Chrome command-line option --touch-devices (issue #2205). 2019-02-27 19:17:21 +00:00
Riku Palomäki
7f1453b294 Linux: Fix cefclient when using component build and tcmalloc.
Link to libbase.so to fix FATAL:content_main_runner_impl.cc(731)]
Check failed: base::allocator::IsAllocatorInitialized().
2019-02-27 19:16:35 +00:00
Riku Palomäki
5f615a95bc Add multi-touch support for OSR (issue #1059) 2019-02-26 11:51:33 -05:00
Marshall Greenblatt
9ba28dd730 Remove V8Test.ContextInvalid which always fails (issue #2435) 2019-02-26 11:50:55 -05:00
Riku Palomäki
379fb8d39e Add CefRenderHandler::OnVirtualKeyboardRequested (issue #2607) 2019-02-26 16:49:41 +00:00
Alexander Guettler
c72d57aa60 Replace AddCustomScheme bool arguments with int using bit flags 2019-02-26 16:45:12 +00:00
Mike Wiedenbauer
ba8b4e8b9d Add support for muting audio in the browser (issue #1806) 2019-02-26 16:44:17 +00:00
Riku Palomäki
8d1453fd24 Fix crash if CefAuthCallback outlives the matching URLRequest (issue #2612) 2019-02-26 16:42:22 +00:00
Marshall Greenblatt
3cf50ed942 Trigger CEF Save As dialog from chrome://net-export (issue #2613) 2019-02-25 13:26:38 -05:00
Marshall Greenblatt
5a1c642431 Update to Chromium version 74.0.3706.0 (#632463) 2019-02-25 12:09:54 -05:00
Marshall Greenblatt
6bfb5ab33b Remove old approach for debugging leaked wrapper object references (issue #2593) 2019-02-14 17:08:44 -05:00
Marshall Greenblatt
3fe062a5b6 Implement new approach for debugging leaked wrapper object references (issue #2593) 2019-02-14 17:08:43 -05:00
Marshall Greenblatt
176e14d451 Add missing header include (issue #1614) 2019-02-14 17:08:42 -05:00
Marshall Greenblatt
feb99571d2 Windows: Use scoped_ptr for VS2015 compatibility (issue #2594) 2019-02-14 17:08:42 -05:00
Marshall Greenblatt
d5be6e3afb Fix extra newline in CEF logging output (issue #1649) 2019-02-13 17:46:58 -05:00
Marshall Greenblatt
359a5b7cb5 Fix undefined reference to `operator<<(std::ostream&, wchar_t const*)' (issue #2553) 2019-02-13 17:46:58 -05:00
Marshall Greenblatt
406e347d6f Linux: Use existing keycodes_x_export.h file (issue #2587) 2019-02-13 17:46:57 -05:00
Riku Palomäki
b5d76b499c Linux: Fixed component build failure due to undefined KeySym functions (issue #2587) 2019-02-13 14:23:10 -05:00
Marshall Greenblatt
7aae02e411 Enable iterator debugging (_ITERATOR_DEBUG_LEVEL=2) for official cef_sandbox Debug builds (issue #2592) 2019-02-13 14:11:54 -05:00
Marshall Greenblatt
8bc348d615 Windows: cefclient: Fix compile error with ATL disabled 2019-02-13 12:43:55 -05:00
Marshall Greenblatt
4c730e8935 Add DevTools save dialog support (issue #1614) 2019-02-12 15:31:52 -05:00
Marshall Greenblatt
0e461b7f5c Move DevTools sources to browser/devtools 2019-02-12 13:43:44 -05:00
Marshall Greenblatt
d73fc464c9 Remove unnecessary DCHECK(!dialog_running_) on browser destruction (issue #2589) 2019-02-11 17:50:03 -05:00
Marshall Greenblatt
f85816f0c7 Windows: Fix focus assignment after dismissing JS dialogs (issue #2584) 2019-02-11 17:26:12 -05:00
Marshall Greenblatt
b8eaec0db2 Windows: Use WS_EX_NOACTIVATE to control initial window activation (issue #1856) 2019-02-07 16:38:26 -05:00
Tyler Johnson
84a5749f9f Squelch attribute warnings from the GNU compiler (issue #2552) 2019-02-06 20:48:09 +00:00
Alexander Guettler
a72e00a7b9 Add option to enable fetch support for custom schemes (issue #2579) 2019-02-04 22:31:31 +00:00
Marshall Greenblatt
667d190547 Fix TracingTest failures (issue #2583) 2019-02-04 16:36:13 -05:00
1146 changed files with 46224 additions and 22917 deletions

2
.gitignore vendored
View File

@@ -46,4 +46,6 @@ Thumbs.db
/binary_distrib
/docs
# CEF generated files
/include/cef_config.h
/include/cef_version.h
.ccls-cache/

297
BUILD.gn
View File

@@ -100,13 +100,12 @@ import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni")
import("//cef/cef_repack_locales.gni")
import("//chrome/common/features.gni")
import("//content/public/app/mac_helpers.gni")
import("//extensions/buildflags/buildflags.gni")
import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni")
import("//services/catalog/public/tools/catalog.gni")
import("//services/service_manager/public/service_manifest.gni")
import("//third_party/icu/config.gni")
import("//third_party/widevine/cdm/widevine.gni")
import("//tools/grit/repack.gni")
@@ -168,45 +167,14 @@ if (is_mac) {
#
if (is_mac) {
cef_commit_number = exec_script(
"//cef/tools/commit_number.py",
[ rebase_path("//cef", root_build_dir) ],
"trim string", [])
cef_version_file = "//cef/VERSION.in"
# The tweak_info_plist.py script requires a version number with 4 parts. CEF
# uses a version number with 3 parts so just set the last part to 0.
cef_plist_version = exec_script(
"//build/util/version.py",
[
"-f",
rebase_path(cef_version_file, root_build_dir),
"-f",
rebase_path(chrome_version_file, root_build_dir),
"-t",
"@CEF_MAJOR@.@BUILD@.${cef_commit_number}.0",
],
"trim string",
[ cef_version_file, chrome_version_file ])
"//cef/tools/cef_version.py", [ "plist" ], "trim string", [])
# Need to be creative to match dylib version formatting requirements.
cef_dylib_version = exec_script(
"//build/util/version.py",
[
"-f",
rebase_path(cef_version_file, root_build_dir),
"-f",
rebase_path(chrome_version_file, root_build_dir),
"-t",
"@CEF_MAJOR@${cef_commit_number}.@BUILD_HI@.@BUILD_LO@",
"-e",
"BUILD_HI=int(BUILD)/256",
"-e",
"BUILD_LO=int(BUILD)%256",
],
"trim string",
[ cef_version_file, chrome_version_file ])
"//cef/tools/cef_version.py", [ "dylib" ], "trim string", [])
}
# Read file lists from gypi files. The gypi_to_gn.py script does not support
@@ -229,10 +197,13 @@ gypi_paths2 = exec_script("//cef/tools/gypi_to_gn.py",
group("cef") {
testonly = true
deps = [
":cefclient",
":cefsimple",
":ceftests",
]
if (!is_linux || use_x11) {
deps += [ ":cefclient" ]
}
}
@@ -285,14 +256,14 @@ if (is_win) {
static_library("libcef_static") {
sources = gypi_paths2.includes_common +
gypi_paths.autogen_cpp_includes + [
"libcef/browser/audio_mirror_destination.cc",
"libcef/browser/audio_mirror_destination.h",
"libcef/browser/audio_push_sink.cc",
"libcef/browser/audio_push_sink.h",
"libcef/browser/browser_context.cc",
"libcef/browser/browser_context.h",
"libcef/browser/browser_context_impl.cc",
"libcef/browser/browser_context_impl.h",
"libcef/browser/browser_context_keyed_service_factories.cc",
"libcef/browser/browser_context_keyed_service_factories.h",
"libcef/browser/browser_context_proxy.cc",
"libcef/browser/browser_context_proxy.h",
"libcef/browser/browser_host_impl.cc",
"libcef/browser/browser_host_impl.h",
"libcef/browser/browser_info.cc",
@@ -308,8 +279,6 @@ static_library("libcef_static") {
"libcef/browser/browser_platform_delegate.cc",
"libcef/browser/browser_platform_delegate.h",
"libcef/browser/browser_platform_delegate_create.cc",
"libcef/browser/browser_urlrequest_impl.cc",
"libcef/browser/browser_urlrequest_impl.h",
"libcef/browser/browser_util.cc",
"libcef/browser/browser_util.h",
"libcef/browser/chrome_browser_process_stub.cc",
@@ -325,12 +294,12 @@ static_library("libcef_static") {
"libcef/browser/context.h",
"libcef/browser/context_menu_params_impl.cc",
"libcef/browser/context_menu_params_impl.h",
"libcef/browser/cookie_manager_impl.cc",
"libcef/browser/cookie_manager_impl.h",
"libcef/browser/devtools_frontend.cc",
"libcef/browser/devtools_frontend.h",
"libcef/browser/devtools_manager_delegate.cc",
"libcef/browser/devtools_manager_delegate.h",
"libcef/browser/devtools/devtools_file_manager.cc",
"libcef/browser/devtools/devtools_file_manager.h",
"libcef/browser/devtools/devtools_frontend.cc",
"libcef/browser/devtools/devtools_frontend.h",
"libcef/browser/devtools/devtools_manager_delegate.cc",
"libcef/browser/devtools/devtools_manager_delegate.h",
"libcef/browser/download_item_impl.cc",
"libcef/browser/download_item_impl.h",
"libcef/browser/download_manager_delegate.cc",
@@ -402,12 +371,12 @@ static_library("libcef_static") {
"libcef/browser/navigate_params.h",
"libcef/browser/navigation_entry_impl.cc",
"libcef/browser/navigation_entry_impl.h",
"libcef/browser/net/browser_urlrequest_old_impl.cc",
"libcef/browser/net/browser_urlrequest_old_impl.h",
"libcef/browser/net/chrome_scheme_handler.cc",
"libcef/browser/net/chrome_scheme_handler.h",
"libcef/browser/net/cookie_store_proxy.cc",
"libcef/browser/net/cookie_store_proxy.h",
"libcef/browser/net/cookie_store_source.cc",
"libcef/browser/net/cookie_store_source.h",
"libcef/browser/net/cookie_manager_old_impl.cc",
"libcef/browser/net/cookie_manager_old_impl.h",
"libcef/browser/net/crlset_file_util_impl.cc",
"libcef/browser/net/devtools_scheme_handler.cc",
"libcef/browser/net/devtools_scheme_handler.h",
@@ -425,32 +394,52 @@ static_library("libcef_static") {
"libcef/browser/net/source_stream.h",
"libcef/browser/net/url_request_context.cc",
"libcef/browser/net/url_request_context.h",
"libcef/browser/net/url_request_context_getter.cc",
"libcef/browser/net/url_request_context_getter.h",
"libcef/browser/net/url_request_context_getter_impl.cc",
"libcef/browser/net/url_request_context_getter_impl.h",
"libcef/browser/net/url_request_context_getter_proxy.cc",
"libcef/browser/net/url_request_context_getter_proxy.h",
"libcef/browser/net/url_request_context_impl.h",
"libcef/browser/net/url_request_context_proxy.cc",
"libcef/browser/net/url_request_context_proxy.h",
"libcef/browser/net/url_request_interceptor.cc",
"libcef/browser/net/url_request_interceptor.h",
"libcef/browser/net/url_request_manager.cc",
"libcef/browser/net/url_request_manager.h",
"libcef/browser/net/url_request_user_data.cc",
"libcef/browser/net/url_request_user_data.h",
"libcef/browser/net_service/browser_urlrequest_impl.cc",
"libcef/browser/net_service/browser_urlrequest_impl.h",
"libcef/browser/net_service/cookie_helper.cc",
"libcef/browser/net_service/cookie_helper.h",
"libcef/browser/net_service/cookie_manager_impl.cc",
"libcef/browser/net_service/cookie_manager_impl.h",
"libcef/browser/net_service/login_delegate.cc",
"libcef/browser/net_service/login_delegate.h",
"libcef/browser/net_service/proxy_url_loader_factory.cc",
"libcef/browser/net_service/proxy_url_loader_factory.h",
"libcef/browser/net_service/resource_handler_wrapper.cc",
"libcef/browser/net_service/resource_handler_wrapper.h",
"libcef/browser/net_service/resource_request_handler_wrapper.cc",
"libcef/browser/net_service/resource_request_handler_wrapper.h",
"libcef/browser/net_service/response_filter_wrapper.cc",
"libcef/browser/net_service/response_filter_wrapper.h",
"libcef/browser/net_service/stream_reader_url_loader.cc",
"libcef/browser/net_service/stream_reader_url_loader.h",
"libcef/browser/net_service/url_loader_factory_getter.cc",
"libcef/browser/net_service/url_loader_factory_getter.h",
"libcef/browser/origin_whitelist_impl.cc",
"libcef/browser/origin_whitelist_impl.h",
"libcef/browser/osr/browser_platform_delegate_osr.cc",
"libcef/browser/osr/browser_platform_delegate_osr.h",
"libcef/browser/osr/host_display_client_osr.cc",
"libcef/browser/osr/host_display_client_osr.h",
"libcef/browser/osr/motion_event_osr.cc",
"libcef/browser/osr/motion_event_osr.h",
"libcef/browser/osr/osr_accessibility_util.cc",
"libcef/browser/osr/osr_accessibility_util.h",
"libcef/browser/osr/osr_util.cc",
"libcef/browser/osr/osr_util.h",
"libcef/browser/osr/render_widget_host_view_osr.cc",
"libcef/browser/osr/render_widget_host_view_osr.h",
"libcef/browser/osr/software_output_device_osr.cc",
"libcef/browser/osr/software_output_device_osr.h",
"libcef/browser/osr/synthetic_gesture_target_osr.cc",
"libcef/browser/osr/synthetic_gesture_target_osr.h",
"libcef/browser/osr/video_consumer_osr.cc",
"libcef/browser/osr/video_consumer_osr.h",
"libcef/browser/osr/web_contents_view_osr.cc",
"libcef/browser/osr/web_contents_view_osr.h",
"libcef/browser/path_util_impl.cc",
@@ -488,8 +477,6 @@ static_library("libcef_static") {
"libcef/browser/ssl_info_impl.h",
"libcef/browser/ssl_status_impl.cc",
"libcef/browser/ssl_status_impl.h",
"libcef/browser/storage_partition_proxy.cc",
"libcef/browser/storage_partition_proxy.h",
"libcef/browser/stream_impl.cc",
"libcef/browser/stream_impl.h",
"libcef/browser/trace_impl.cc",
@@ -532,6 +519,8 @@ static_library("libcef_static") {
"libcef/common/extensions/extensions_util.cc",
"libcef/common/extensions/extensions_util.h",
"libcef/common/file_util_impl.cc",
"libcef/common/frame_util.cc",
"libcef/common/frame_util.h",
"libcef/common/json_impl.cc",
"libcef/common/main_delegate.cc",
"libcef/common/main_delegate.h",
@@ -545,6 +534,10 @@ static_library("libcef_static") {
"libcef/common/net/upload_data.h",
"libcef/common/net/upload_element.cc",
"libcef/common/net/upload_element.h",
"libcef/common/net_service/net_service_util.cc",
"libcef/common/net_service/net_service_util.h",
"libcef/common/net_service/util.cc",
"libcef/common/net_service/util.h",
"libcef/common/parser_impl.cc",
"libcef/common/process_message_impl.cc",
"libcef/common/process_message_impl.h",
@@ -608,6 +601,8 @@ static_library("libcef_static") {
"libcef/renderer/render_urlrequest_impl.cc",
"libcef/renderer/render_urlrequest_impl.h",
"libcef/renderer/thread_util.h",
"libcef/renderer/url_loader_throttle_provider_impl.cc",
"libcef/renderer/url_loader_throttle_provider_impl.h",
"libcef/renderer/v8_impl.cc",
"libcef/renderer/v8_impl.h",
"libcef/utility/content_utility_client.cc",
@@ -683,7 +678,6 @@ static_library("libcef_static") {
"//components/printing/renderer",
"//components/proxy_config",
"//components/safe_browsing/db:test_database_manager",
"//components/services/pdf_compositor:pdf_compositor_manifest",
"//components/services/pdf_compositor/public/cpp:factory",
"//components/services/pdf_compositor/public/interfaces",
"//components/tracing",
@@ -724,7 +718,6 @@ static_library("libcef_static") {
"//services/network/public/cpp",
"//services/service_manager/embedder",
"//services/service_manager/public/cpp",
"//services/service_manager/runner/common",
"//skia",
"//storage/browser",
"//third_party/blink/public:blink",
@@ -777,7 +770,7 @@ static_library("libcef_static") {
deps += [
"//chrome/install_static:secondary_module",
"//chrome_elf",
"//chrome/chrome_elf",
]
if (is_component_build) {
@@ -806,14 +799,25 @@ static_library("libcef_static") {
"libcef/browser/osr/render_widget_host_view_osr_linux.cc",
"libcef/browser/printing/print_dialog_linux.cc",
"libcef/browser/printing/print_dialog_linux.h",
"libcef/browser/native/window_x11.cc",
"libcef/browser/native/window_x11.h",
]
if (use_x11) {
sources += [
"libcef/browser/native/window_x11.cc",
"libcef/browser/native/window_x11.h",
]
}
deps += [
"//build/config/freetype",
"//third_party/fontconfig",
]
if (is_linux && !use_x11) {
deps += [
"//third_party/angle:libEGL",
]
}
}
if (is_mac) {
@@ -828,7 +832,6 @@ static_library("libcef_static") {
"libcef/browser/native/menu_runner_mac.mm",
"libcef/browser/osr/browser_platform_delegate_osr_mac.h",
"libcef/browser/osr/browser_platform_delegate_osr_mac.mm",
"libcef/browser/osr/render_widget_host_view_osr_mac.mm",
"libcef/common/util_mac.h",
"libcef/common/util_mac.mm",
]
@@ -931,6 +934,15 @@ static_library("libcef_static") {
"//ui/aura/test/ui_controls_factory_aura.h",
]
if (is_linux && !use_x11) {
sources += [
"//ui/aura/test/mus/window_tree_client_test_api.h",
"//ui/aura/test/mus/window_tree_client_test_api.cc",
"//ui/aura/test/ui_controls_factory_ozone.cc",
"//ui/events/test/events_test_utils.cc"
]
}
deps += [
"//ui/aura",
"//ui/events",
@@ -968,16 +980,23 @@ static_library("libcef_static") {
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/aura_test_utils.cc",
"//ui/aura/test/aura_test_utils.h",
"//ui/aura/test/ui_controls_factory_aurax11.cc",
"//ui/aura/test/x11_event_sender.cc",
"//ui/aura/test/x11_event_sender.h",
# Part of //ui/events:test_support which is testingonly.
"//ui/events/test/platform_event_waiter.cc",
"//ui/events/test/platform_event_waiter.h",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
"//ui/views/test/ui_controls_factory_desktop_aurax11.h",
]
if (use_x11) {
sources += [
# Support for UI input events.
# 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.h",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
"//ui/views/test/ui_controls_factory_desktop_aurax11.h",
]
}
}
} else {
sources += [
@@ -1132,10 +1151,10 @@ source_set("cef_content_utility_overlay_manifest") {
]
}
source_set("cef_packaged_service_manifests") {
source_set("builtin_service_manifests") {
sources = [
"libcef/common/service_manifests/cef_packaged_service_manifests.cc",
"libcef/common/service_manifests/cef_packaged_service_manifests.h",
"libcef/common/service_manifests/builtin_service_manifests.cc",
"libcef/common/service_manifests/builtin_service_manifests.h",
]
configs += [
@@ -1145,13 +1164,13 @@ source_set("cef_packaged_service_manifests") {
deps = [
"//base",
"//chrome/common:mojo_bindings",
"//chrome/services/printing:manifest",
"//components/services/pdf_compositor:pdf_compositor_manifest",
"//chrome/services/printing/public/cpp:manifest",
"//components/services/pdf_compositor/public/cpp:manifest",
"//components/spellcheck/common:interfaces",
"//components/startup_metric_utils/common:interfaces",
"//extensions/buildflags",
"//printing/buildflags",
"//services/proxy_resolver:proxy_resolver_manifest",
"//services/proxy_resolver/public/cpp:manifest",
"//services/service_manager/public/cpp",
]
}
@@ -1180,7 +1199,7 @@ source_set("cef_service_manifests") {
":cef_content_gpu_overlay_manifest",
":cef_content_renderer_overlay_manifest",
":cef_content_utility_overlay_manifest",
":cef_packaged_service_manifests",
":builtin_service_manifests",
":cef_renderer_manifest",
]
}
@@ -1685,32 +1704,60 @@ if (is_mac) {
]
}
mac_app_bundle("${app_name}_helper_app") {
testonly = app_testonly
output_name = app_helper_name
template("cef_helper_app") {
mac_app_bundle(target_name) {
assert(defined(invoker.helper_sources))
assert(defined(invoker.helper_name_suffix))
assert(defined(invoker.helper_bundle_id_suffix))
sources = invoker.helper_sources
testonly = app_testonly
output_name = app_helper_name + invoker.helper_name_suffix
deps = [
":cef_make_headers",
":cef_sandbox",
":libcef_dll_wrapper",
]
if (defined(invoker.helper_deps)) {
deps += invoker.helper_deps
sources = invoker.helper_sources
extra_substitutions = [
"BUNDLE_ID_SUFFIX=${invoker.helper_bundle_id_suffix}",
]
deps = [
":cef_make_headers",
":cef_sandbox",
":libcef_dll_wrapper",
]
if (defined(invoker.helper_deps)) {
deps += invoker.helper_deps
}
ldflags = [
# The helper is in $app_name.app/Contents/Frameworks/$app_name Helper.app/Contents/MacOS/
# so set rpath up to the base.
"-rpath",
"@executable_path/../../../../../..",
]
info_plist_target = ":${app_name}_helper_plist"
if (defined(invoker.helper_defines)) {
defines = invoker.helper_defines
}
}
}
ldflags = [
# The helper is in $app_name.app/Contents/Frameworks/$app_name Helper.app/Contents/MacOS/
# so set rpath up to the base.
"-rpath",
"@executable_path/../../../../../..",
]
foreach(helper_params, content_mac_helpers) {
_helper_target = helper_params[0]
_helper_bundle_id = helper_params[1]
_helper_suffix = helper_params[2]
cef_helper_app("${app_name}_helper_app_${_helper_target}") {
helper_sources = invoker.helper_sources
if (defined(invoker.helper_deps)) {
helper_deps = invoker.helper_deps
}
if (defined(invoker.helper_defines)) {
helper_defines = invoker.helper_defines
}
info_plist_target = ":${app_name}_helper_plist"
if (defined(invoker.helper_defines)) {
defines = invoker.helper_defines
helper_name_suffix = _helper_suffix
helper_bundle_id_suffix = _helper_bundle_id
}
}
@@ -1718,14 +1765,19 @@ if (is_mac) {
testonly = app_testonly
sources = [
"$root_out_dir/$cef_framework_name.framework",
"$root_out_dir/$app_helper_name.app",
]
public_deps = [
":cef_framework",
":${app_name}_helper_app",
]
foreach(helper_params, content_mac_helpers) {
sources += [
"$root_out_dir/${app_helper_name}${helper_params[2]}.app",
]
public_deps += [ ":${app_name}_helper_app_${helper_params[0]}" ]
}
outputs = [
"{{bundle_contents_dir}}/Frameworks/{{source_file_part}}",
]
@@ -1989,12 +2041,19 @@ if (is_mac) {
# The cefclient target depends on packages that are not available in the
# default sysroot environment.
if (is_linux && !use_sysroot) {
pkg_config("glib") {
packages = [
"glib-2.0",
]
}
pkg_config("gtk") {
packages = [
"gmodule-2.0",
"gtk+-2.0",
"gthread-2.0",
"gtk+-unix-print-2.0",
"xi",
]
}
@@ -2091,7 +2150,13 @@ if (is_mac) {
]
}
if (!is_component_build) {
if (is_component_build) {
if (use_allocator=="tcmalloc") {
# Link to base to initialize tcmalloc allocator shims, otherwise
# base::allocator::IsAllocatorInitialized check fails
deps += [ "//base" ]
}
} else {
# Set rpath to find our own libfreetype even in a non-component build.
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
@@ -2141,9 +2206,11 @@ if (is_mac) {
sources += gypi_paths2.includes_linux +
gypi_paths2.cefsimple_sources_linux
libs = [
"X11",
]
if (use_x11) {
libs = [
"X11",
]
}
if (!is_component_build) {
# Set rpath to find our own libfreetype even in a non-component build.
@@ -2200,9 +2267,15 @@ if (is_mac) {
sources += gypi_paths2.shared_sources_linux +
gypi_paths2.ceftests_sources_linux
libs = [
"X11",
]
if (use_x11) {
libs = [
"X11",
]
} else {
if (!use_sysroot) {
configs += [ ":glib" ]
}
}
deps += [
":copy_ceftests_files",

View File

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

View File

@@ -61,15 +61,5 @@
],
# Patterns that should not be found in the chromium/src directory after
# applying patch files.
'patterns': [
{
# New instances of this static_cast are added to the Chromium sources with
# some regularity. If unfixed they will result in runtime crashes.
'pattern': 'static_cast<StoragePartitionImpl\*>(',
'exclude_matches': '^(.+?)test(.+?):',
'message': 'New instances in non-test files should be converted to ' +\
'call StoragePartition methods.' +\
'\nSee storage_partition_1973.patch.',
},
],
'patterns': [],
}

View File

@@ -200,11 +200,14 @@ add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)
# Comes from the <target>/CMakeLists.txt file in the current directory.
# TODO: Change these lines to match your project target when you copy this file.
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
add_subdirectory(tests/cefclient)
add_subdirectory(tests/cefsimple)
add_subdirectory(tests/gtest)
add_subdirectory(tests/ceftests)
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/cefclient")
add_subdirectory(tests/cefclient)
endif()
# Display configuration settings.
PRINT_CEF_CONFIG()

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=ebb10ec8232ea37044d01a4522248b5055f5c1fc$
# $hash=a8e80ae73a0d30776c2e6aaceaf9dbd4031f6c74$
#
{
@@ -16,6 +16,7 @@
'autogen_cpp_includes': [
'include/cef_accessibility_handler.h',
'include/cef_app.h',
'include/cef_audio_handler.h',
'include/cef_auth_callback.h',
'include/cef_browser.h',
'include/cef_browser_process_handler.h',
@@ -56,12 +57,14 @@
'include/cef_render_handler.h',
'include/cef_render_process_handler.h',
'include/cef_request.h',
'include/cef_request_callback.h',
'include/cef_request_context.h',
'include/cef_request_context_handler.h',
'include/cef_request_handler.h',
'include/cef_resource_bundle.h',
'include/cef_resource_bundle_handler.h',
'include/cef_resource_handler.h',
'include/cef_resource_request_handler.h',
'include/cef_response.h',
'include/cef_response_filter.h',
'include/cef_scheme.h',
@@ -107,6 +110,7 @@
'autogen_capi_includes': [
'include/capi/cef_accessibility_handler_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_browser_capi.h',
'include/capi/cef_browser_process_handler_capi.h',
@@ -147,12 +151,14 @@
'include/capi/cef_render_handler_capi.h',
'include/capi/cef_render_process_handler_capi.h',
'include/capi/cef_request_capi.h',
'include/capi/cef_request_callback_capi.h',
'include/capi/cef_request_context_capi.h',
'include/capi/cef_request_context_handler_capi.h',
'include/capi/cef_request_handler_capi.h',
'include/capi/cef_resource_bundle_capi.h',
'include/capi/cef_resource_bundle_handler_capi.h',
'include/capi/cef_resource_handler_capi.h',
'include/capi/cef_resource_request_handler_capi.h',
'include/capi/cef_response_capi.h',
'include/capi/cef_response_filter_capi.h',
'include/capi/cef_scheme_capi.h',
@@ -200,6 +206,8 @@
'libcef_dll/ctocpp/accessibility_handler_ctocpp.h',
'libcef_dll/ctocpp/app_ctocpp.cc',
'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.h',
'libcef_dll/cpptoc/before_download_callback_cpptoc.cc',
@@ -234,6 +242,8 @@
'libcef_dll/ctocpp/context_menu_handler_ctocpp.h',
'libcef_dll/cpptoc/context_menu_params_cpptoc.cc',
'libcef_dll/cpptoc/context_menu_params_cpptoc.h',
'libcef_dll/ctocpp/cookie_access_filter_ctocpp.cc',
'libcef_dll/ctocpp/cookie_access_filter_ctocpp.h',
'libcef_dll/cpptoc/cookie_manager_cpptoc.cc',
'libcef_dll/cpptoc/cookie_manager_cpptoc.h',
'libcef_dll/ctocpp/cookie_visitor_ctocpp.cc',
@@ -362,6 +372,12 @@
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h',
'libcef_dll/ctocpp/resource_handler_ctocpp.cc',
'libcef_dll/ctocpp/resource_handler_ctocpp.h',
'libcef_dll/cpptoc/resource_read_callback_cpptoc.cc',
'libcef_dll/cpptoc/resource_read_callback_cpptoc.h',
'libcef_dll/ctocpp/resource_request_handler_ctocpp.cc',
'libcef_dll/ctocpp/resource_request_handler_ctocpp.h',
'libcef_dll/cpptoc/resource_skip_callback_cpptoc.cc',
'libcef_dll/cpptoc/resource_skip_callback_cpptoc.h',
'libcef_dll/cpptoc/response_cpptoc.cc',
'libcef_dll/cpptoc/response_cpptoc.h',
'libcef_dll/ctocpp/response_filter_ctocpp.cc',
@@ -482,6 +498,8 @@
'libcef_dll/cpptoc/accessibility_handler_cpptoc.h',
'libcef_dll/cpptoc/app_cpptoc.cc',
'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.h',
'libcef_dll/ctocpp/before_download_callback_ctocpp.cc',
@@ -516,6 +534,8 @@
'libcef_dll/cpptoc/context_menu_handler_cpptoc.h',
'libcef_dll/ctocpp/context_menu_params_ctocpp.cc',
'libcef_dll/ctocpp/context_menu_params_ctocpp.h',
'libcef_dll/cpptoc/cookie_access_filter_cpptoc.cc',
'libcef_dll/cpptoc/cookie_access_filter_cpptoc.h',
'libcef_dll/ctocpp/cookie_manager_ctocpp.cc',
'libcef_dll/ctocpp/cookie_manager_ctocpp.h',
'libcef_dll/cpptoc/cookie_visitor_cpptoc.cc',
@@ -644,6 +664,12 @@
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h',
'libcef_dll/cpptoc/resource_handler_cpptoc.cc',
'libcef_dll/cpptoc/resource_handler_cpptoc.h',
'libcef_dll/ctocpp/resource_read_callback_ctocpp.cc',
'libcef_dll/ctocpp/resource_read_callback_ctocpp.h',
'libcef_dll/cpptoc/resource_request_handler_cpptoc.cc',
'libcef_dll/cpptoc/resource_request_handler_cpptoc.h',
'libcef_dll/ctocpp/resource_skip_callback_ctocpp.cc',
'libcef_dll/ctocpp/resource_skip_callback_ctocpp.h',
'libcef_dll/ctocpp/response_ctocpp.cc',
'libcef_dll/ctocpp/response_ctocpp.h',
'libcef_dll/cpptoc/response_filter_cpptoc.cc',

View File

@@ -34,7 +34,9 @@
'include/base/internal/cef_lock_impl.h',
'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h',
'include/base/internal/cef_thread_checker_impl.h',
'include/cef_api_hash.h',
'include/cef_base.h',
'include/cef_config.h',
'include/cef_version.h',
'include/internal/cef_export.h',
'include/internal/cef_logging_internal.h',
@@ -86,6 +88,7 @@
'includes_linux': [
'include/base/internal/cef_atomicops_atomicword_compat.h',
'include/base/internal/cef_atomicops_arm_gcc.h',
'include/base/internal/cef_atomicops_arm64_gcc.h',
'include/base/internal/cef_atomicops_x86_gcc.h',
'include/internal/cef_linux.h',
'include/internal/cef_types_linux.h',
@@ -103,6 +106,8 @@
'libcef_dll/libcef_dll2.cc',
'libcef_dll/ptr_util.h',
'libcef_dll/resource.h',
'libcef_dll/shutdown_checker.cc',
'libcef_dll/shutdown_checker.h',
'libcef_dll/transfer_util.cc',
'libcef_dll/transfer_util.h',
'libcef_dll/wrapper_types.h',
@@ -130,6 +135,8 @@
'libcef_dll/ctocpp/ctocpp_ref_counted.h',
'libcef_dll/ctocpp/ctocpp_scoped.h',
'libcef_dll/ptr_util.h',
'libcef_dll/shutdown_checker.cc',
'libcef_dll/shutdown_checker.h',
'libcef_dll/transfer_util.cc',
'libcef_dll/transfer_util.h',
'libcef_dll/wrapper_types.h',
@@ -443,6 +450,7 @@
'tests/cefsimple/simple_handler_linux.cc',
],
'ceftests_sources_common': [
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/browser_info_map_unittest.cc',
'tests/ceftests/command_line_unittest.cc',
'tests/ceftests/cookie_unittest.cc',
@@ -480,6 +488,7 @@
'tests/ceftests/request_unittest.cc',
'tests/ceftests/resource.h',
'tests/ceftests/resource_manager_unittest.cc',
'tests/ceftests/resource_request_handler_unittest.cc',
'tests/ceftests/routing_test_handler.cc',
'tests/ceftests/routing_test_handler.h',
'tests/ceftests/run_all_unittests.cc',
@@ -538,6 +547,7 @@
'tests/shared/browser/resource_util.h',
'tests/shared/browser/resource_util_mac.mm',
'tests/shared/browser/resource_util_posix.cc',
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/client_app_delegates.cc',
'tests/ceftests/cookie_unittest.cc',
'tests/ceftests/dom_unittest.cc',
@@ -549,6 +559,7 @@
'tests/ceftests/process_message_unittest.cc',
'tests/ceftests/request_handler_unittest.cc',
'tests/ceftests/request_unittest.cc',
'tests/ceftests/resource_request_handler_unittest.cc',
'tests/ceftests/routing_test_handler.cc',
'tests/ceftests/routing_test_handler.h',
'tests/ceftests/scheme_handler_unittest.cc',

View File

@@ -169,6 +169,12 @@ if(OS_LINUX)
)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
list(APPEND CEF_CXX_COMPILER_FLAGS
-Wno-attributes # The cfi-icall attribute is not supported by the GNU C++ compiler
)
endif()
if(PROJECT_ARCH STREQUAL "x86_64")
# 64-bit architecture.
list(APPEND CEF_COMPILER_FLAGS
@@ -340,6 +346,15 @@ if(OS_MACOSX)
set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.a")
set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.a")
endif()
# CEF Helper app suffixes.
# Format is "<name suffix>:<target suffix>:<plist suffix>".
set(CEF_HELPER_APP_SUFFIXES
"::"
" (GPU):_gpu:.gpu"
" (Plugin):_plugin:.plugin"
" (Renderer):_renderer:.renderer"
)
endif()
@@ -368,6 +383,9 @@ if(OS_WINDOWS)
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 # VS2018 version 16.1
)
list(FIND supported_msvc_versions ${MSVC_VERSION} _index)
if (${_index} EQUAL -1)
@@ -453,7 +471,6 @@ if(OS_WINDOWS)
# List of CEF binary files.
set(CEF_BINARY_FILES
chrome_elf.dll
d3dcompiler_43.dll
d3dcompiler_47.dll
libcef.dll
libEGL.dll
@@ -484,7 +501,10 @@ if(OS_WINDOWS)
# Libraries required by cef_sandbox.lib.
set(CEF_SANDBOX_STANDARD_LIBS
dbghelp.lib
PowrProf.lib
Propsys.lib
psapi.lib
SetupAPI.lib
version.lib
wbemuuid.lib
winmm.lib

View File

@@ -182,6 +182,8 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
#include "include/base/internal/cef_atomicops_mac.h"
#elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)
#include "include/base/internal/cef_atomicops_x86_gcc.h"
#elif defined(COMPILER_GCC) && defined(__ARM_ARCH_ISA_A64)
#include "include/base/internal/cef_atomicops_arm64_gcc.h"
#elif defined(COMPILER_GCC) && defined(__ARM_ARCH)
#include "include/base/internal/cef_atomicops_arm_gcc.h"
#else

View File

@@ -0,0 +1,335 @@
// Copyright (c) 2012 Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Do not include this header file directly. Use base/cef_atomicops.h
// instead.
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM64_GCC_H_
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM64_GCC_H_
namespace base {
namespace subtle {
inline void MemoryBarrier() {
__asm__ __volatile__ ("dmb ish" ::: "memory"); // NOLINT
}
// NoBarrier versions of the operation include "memory" in the clobber list.
// This is not required for direct usage of the NoBarrier versions of the
// operations. However this is required for correctness when they are used as
// part of the Acquire or Release versions, to ensure that nothing from outside
// the call is reordered between the operation and the memory barrier. This does
// not change the code generated, so has no or minimal impact on the
// NoBarrier operations.
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
Atomic32 prev;
int32_t temp;
__asm__ __volatile__ ( // NOLINT
"0: \n\t"
"ldxr %w[prev], %[ptr] \n\t" // Load the previous value.
"cmp %w[prev], %w[old_value] \n\t"
"bne 1f \n\t"
"stxr %w[temp], %w[new_value], %[ptr] \n\t" // Try to store the new value.
"cbnz %w[temp], 0b \n\t" // Retry if it did not work.
"1: \n\t"
: [prev]"=&r" (prev),
[temp]"=&r" (temp),
[ptr]"+Q" (*ptr)
: [old_value]"IJr" (old_value),
[new_value]"r" (new_value)
: "cc", "memory"
); // NOLINT
return prev;
}
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
Atomic32 new_value) {
Atomic32 result;
int32_t temp;
__asm__ __volatile__ ( // NOLINT
"0: \n\t"
"ldxr %w[result], %[ptr] \n\t" // Load the previous value.
"stxr %w[temp], %w[new_value], %[ptr] \n\t" // Try to store the new value.
"cbnz %w[temp], 0b \n\t" // Retry if it did not work.
: [result]"=&r" (result),
[temp]"=&r" (temp),
[ptr]"+Q" (*ptr)
: [new_value]"r" (new_value)
: "memory"
); // NOLINT
return result;
}
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment) {
Atomic32 result;
int32_t temp;
__asm__ __volatile__ ( // NOLINT
"0: \n\t"
"ldxr %w[result], %[ptr] \n\t" // Load the previous value.
"add %w[result], %w[result], %w[increment]\n\t"
"stxr %w[temp], %w[result], %[ptr] \n\t" // Try to store the result.
"cbnz %w[temp], 0b \n\t" // Retry on failure.
: [result]"=&r" (result),
[temp]"=&r" (temp),
[ptr]"+Q" (*ptr)
: [increment]"IJr" (increment)
: "memory"
); // NOLINT
return result;
}
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment) {
Atomic32 result;
MemoryBarrier();
result = NoBarrier_AtomicIncrement(ptr, increment);
MemoryBarrier();
return result;
}
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
Atomic32 prev;
prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
MemoryBarrier();
return prev;
}
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
Atomic32 prev;
MemoryBarrier();
prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
return prev;
}
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
}
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
MemoryBarrier();
}
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
__asm__ __volatile__ ( // NOLINT
"stlr %w[value], %[ptr] \n\t"
: [ptr]"=Q" (*ptr)
: [value]"r" (value)
: "memory"
); // NOLINT
}
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
return *ptr;
}
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
Atomic32 value;
__asm__ __volatile__ ( // NOLINT
"ldar %w[value], %[ptr] \n\t"
: [value]"=r" (value)
: [ptr]"Q" (*ptr)
: "memory"
); // NOLINT
return value;
}
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
MemoryBarrier();
return *ptr;
}
// 64-bit versions of the operations.
// See the 32-bit versions for comments.
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
Atomic64 prev;
int32_t temp;
__asm__ __volatile__ ( // NOLINT
"0: \n\t"
"ldxr %[prev], %[ptr] \n\t"
"cmp %[prev], %[old_value] \n\t"
"bne 1f \n\t"
"stxr %w[temp], %[new_value], %[ptr] \n\t"
"cbnz %w[temp], 0b \n\t"
"1: \n\t"
: [prev]"=&r" (prev),
[temp]"=&r" (temp),
[ptr]"+Q" (*ptr)
: [old_value]"IJr" (old_value),
[new_value]"r" (new_value)
: "cc", "memory"
); // NOLINT
return prev;
}
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
Atomic64 new_value) {
Atomic64 result;
int32_t temp;
__asm__ __volatile__ ( // NOLINT
"0: \n\t"
"ldxr %[result], %[ptr] \n\t"
"stxr %w[temp], %[new_value], %[ptr] \n\t"
"cbnz %w[temp], 0b \n\t"
: [result]"=&r" (result),
[temp]"=&r" (temp),
[ptr]"+Q" (*ptr)
: [new_value]"r" (new_value)
: "memory"
); // NOLINT
return result;
}
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
Atomic64 increment) {
Atomic64 result;
int32_t temp;
__asm__ __volatile__ ( // NOLINT
"0: \n\t"
"ldxr %[result], %[ptr] \n\t"
"add %[result], %[result], %[increment] \n\t"
"stxr %w[temp], %[result], %[ptr] \n\t"
"cbnz %w[temp], 0b \n\t"
: [result]"=&r" (result),
[temp]"=&r" (temp),
[ptr]"+Q" (*ptr)
: [increment]"IJr" (increment)
: "memory"
); // NOLINT
return result;
}
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
Atomic64 increment) {
Atomic64 result;
MemoryBarrier();
result = NoBarrier_AtomicIncrement(ptr, increment);
MemoryBarrier();
return result;
}
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
Atomic64 prev;
prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
MemoryBarrier();
return prev;
}
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
Atomic64 prev;
MemoryBarrier();
prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
return prev;
}
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
*ptr = value;
}
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
*ptr = value;
MemoryBarrier();
}
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
__asm__ __volatile__ ( // NOLINT
"stlr %x[value], %[ptr] \n\t"
: [ptr]"=Q" (*ptr)
: [value]"r" (value)
: "memory"
); // NOLINT
}
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
return *ptr;
}
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
Atomic64 value;
__asm__ __volatile__ ( // NOLINT
"ldar %x[value], %[ptr] \n\t"
: [value]"=r" (value)
: [ptr]"Q" (*ptr)
: "memory"
); // NOLINT
return value;
}
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
MemoryBarrier();
return *ptr;
}
} } // namespace base::subtle
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM64_GCC_H_

View File

@@ -0,0 +1,8 @@
// Copyright (c) 2019 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 net error codes from the Chromium source location. When creating a
// CEF binary distribution this file will be replaced with the Chromium version.
#include "net/base/net_error_list.h"

View File

@@ -0,0 +1,110 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// 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=0385a38b6761c5dec07bb89a95a007ad3c11bea6$
//
#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 All functions will be called
// on the UI thread
///
typedef struct _cef_audio_handler_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called when the stream identified by |audio_stream_id| has started.
// |audio_stream_id| will uniquely identify the stream across all future
// cef_audio_handler_t callbacks. OnAudioSteamStopped will always be called
// after OnAudioStreamStarted; both functions may be called multiple times for
// the same stream. |channels| is the number of channels, |channel_layout| is
// the layout of the channels and |sample_rate| is the stream sample rate.
// |frames_per_buffer| is the maximum number of frames that will occur in the
// PCM packet passed to OnAudioStreamPacket.
///
void(CEF_CALLBACK* on_audio_stream_started)(
struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
int audio_stream_id,
int channels,
cef_channel_layout_t channel_layout,
int sample_rate,
int frames_per_buffer);
///
// Called when a PCM packet is received for the stream identified by
// |audio_stream_id|. |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,
int audio_stream_id,
const float** data,
int frames,
int64 pts);
///
// Called when the stream identified by |audio_stream_id| 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,
int audio_stream_id);
} 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
// more information.
//
// $hash=faac9d17d7efae3a72c4cc44474071027596c843$
// $hash=623d324a1ef5637353ae74761fdc04eac4d99716$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
@@ -45,7 +45,6 @@
#include "include/capi/cef_frame_capi.h"
#include "include/capi/cef_image_capi.h"
#include "include/capi/cef_navigation_entry_capi.h"
#include "include/capi/cef_process_message_capi.h"
#include "include/capi/cef_request_context_capi.h"
#ifdef __cplusplus
@@ -179,15 +178,6 @@ typedef struct _cef_browser_t {
///
void(CEF_CALLBACK* get_frame_names)(struct _cef_browser_t* self,
cef_string_list_t names);
///
// Send a message to the specified |target_process|. Returns true (1) if the
// message was sent successfully.
///
int(CEF_CALLBACK* send_process_message)(
struct _cef_browser_t* self,
cef_process_id_t target_process,
struct _cef_process_message_t* message);
} cef_browser_t;
///
@@ -617,6 +607,12 @@ typedef struct _cef_browser_host_t {
int deltaX,
int deltaY);
///
// Send a touch event to the browser for a windowless browser.
///
void(CEF_CALLBACK* send_touch_event)(struct _cef_browser_host_t* self,
const struct _cef_touch_event_t* event);
///
// Send a focus event to the browser.
///
@@ -844,6 +840,18 @@ typedef struct _cef_browser_host_t {
// cef_request_tContext::LoadExtension for details.
///
int(CEF_CALLBACK* is_background_host)(struct _cef_browser_host_t* self);
///
// Set whether the browser's audio is muted.
///
void(CEF_CALLBACK* set_audio_muted)(struct _cef_browser_host_t* self,
int mute);
///
// Returns true (1) if the browser's audio is muted. This function can only
// be called on the UI thread.
///
int(CEF_CALLBACK* is_audio_muted)(struct _cef_browser_host_t* self);
} cef_browser_host_t;
///
@@ -851,25 +859,33 @@ typedef struct _cef_browser_host_t {
// |windowInfo|. All values will be copied internally and the actual window will
// be created on the UI thread. If |request_context| is NULL the global request
// context will be used. This function can be called on any browser process
// thread and will not block.
// thread and will not block. The optional |extra_info| parameter provides an
// opportunity to specify extra information specific to the created browser that
// will be passed to cef_render_process_handler_t::on_browser_created() in the
// render process.
///
CEF_EXPORT int cef_browser_host_create_browser(
const cef_window_info_t* windowInfo,
struct _cef_client_t* client,
const cef_string_t* url,
const struct _cef_browser_settings_t* settings,
struct _cef_dictionary_value_t* extra_info,
struct _cef_request_context_t* request_context);
///
// Create a new browser window using the window parameters specified by
// |windowInfo|. If |request_context| is NULL the global request context will be
// used. This function can only be called on the browser process UI thread.
// used. This function can only be called on the browser process UI thread. The
// optional |extra_info| parameter provides an opportunity to specify extra
// information specific to the created browser that will be passed to
// cef_render_process_handler_t::on_browser_created() in the render process.
///
CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync(
const cef_window_info_t* windowInfo,
struct _cef_client_t* client,
const cef_string_t* url,
const struct _cef_browser_settings_t* settings,
struct _cef_dictionary_value_t* extra_info,
struct _cef_request_context_t* request_context);
#ifdef __cplusplus

View File

@@ -33,13 +33,14 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=318ad8428256c2ef980f2f594ace2469001e59bd$
// $hash=c8b6ce6786bb8369c3d9bb9e932a115fb379b145$
//
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
#pragma once
#include "include/capi/cef_audio_handler_capi.h"
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_context_menu_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;
///
// 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
// implementation will be used.
@@ -159,6 +166,7 @@ typedef struct _cef_client_t {
int(CEF_CALLBACK* on_process_message_received)(
struct _cef_client_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
cef_process_id_t source_process,
struct _cef_process_message_t* message);
} cef_client_t;

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=8e5c27c998b6aabcaf43a4cc7f97064d49eaf8b9$
// $hash=ef1fc4ab41a3fc6046a8754ce1a64bc2732332e6$
//
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
@@ -62,18 +62,22 @@ typedef struct _cef_cookie_manager_t {
cef_base_ref_counted_t base;
///
// Set the schemes supported by this manager. The default schemes ("http",
// "https", "ws" and "wss") will always be supported. If |callback| is non-
// NULL it will be executed asnychronously on the IO thread after the change
// has been applied. Must be called before any cookies are accessed.
// Set the schemes supported by this manager. If |include_defaults| is true
// (1) the default schemes ("http", "https", "ws" and "wss") will also be
// supported. Calling this function with an NULL |schemes| value and
// |include_defaults| set to false (0) will disable all loading and saving of
// cookies for this manager. If |callback| is non-NULL it will be executed
// asnychronously on the UI thread after the change has been applied. Must be
// called before any cookies are accessed.
///
void(CEF_CALLBACK* set_supported_schemes)(
struct _cef_cookie_manager_t* self,
cef_string_list_t schemes,
int include_defaults,
struct _cef_completion_callback_t* callback);
///
// Visit all cookies on the IO thread. The returned cookies are ordered by
// Visit all cookies on the UI thread. The returned cookies are ordered by
// longest path, then by earliest creation date. Returns false (0) if cookies
// cannot be accessed.
///
@@ -81,7 +85,7 @@ typedef struct _cef_cookie_manager_t {
struct _cef_cookie_visitor_t* visitor);
///
// Visit a subset of cookies on the IO thread. The results are filtered by the
// Visit a subset of cookies on the UI thread. The results are filtered by the
// given url scheme, host, domain and path. If |includeHttpOnly| is true (1)
// HTTP-only cookies will also be included in the results. The returned
// cookies are ordered by longest path, then by earliest creation date.
@@ -98,7 +102,7 @@ typedef struct _cef_cookie_manager_t {
// check for disallowed characters (e.g. the ';' character is disallowed
// within the cookie value attribute) and fail without setting the cookie if
// such characters are found. If |callback| is non-NULL it will be executed
// asnychronously on the IO thread after the cookie has been set. Returns
// asnychronously on the UI thread after the cookie has been set. Returns
// false (0) if an invalid URL is specified or if cookies cannot be accessed.
///
int(CEF_CALLBACK* set_cookie)(struct _cef_cookie_manager_t* self,
@@ -112,7 +116,7 @@ typedef struct _cef_cookie_manager_t {
// both will be deleted. If only |url| is specified all host cookies (but not
// domain cookies) irrespective of path will be deleted. If |url| is NULL all
// cookies for all hosts and domains will be deleted. If |callback| is non-
// NULL it will be executed asnychronously on the IO thread after the cookies
// NULL it will be executed asnychronously on the UI thread after the cookies
// have been deleted. Returns false (0) if a non-NULL invalid URL is specified
// or if cookies cannot be accessed. Cookies can alternately be deleted using
// the Visit*Cookies() functions.
@@ -123,25 +127,9 @@ typedef struct _cef_cookie_manager_t {
const cef_string_t* cookie_name,
struct _cef_delete_cookies_callback_t* callback);
///
// Sets the directory path that will be used for storing cookie data. If
// |path| is NULL data will be stored in memory only. Otherwise, data will be
// stored at the specified |path|. To persist session cookies (cookies without
// an expiry date or validity interval) set |persist_session_cookies| to true
// (1). Session cookies are generally intended to be transient and most Web
// browsers do not persist them. If |callback| is non-NULL it will be executed
// asnychronously on the IO thread after the manager's storage has been
// initialized. Returns false (0) if cookies cannot be accessed.
///
int(CEF_CALLBACK* set_storage_path)(
struct _cef_cookie_manager_t* self,
const cef_string_t* path,
int persist_session_cookies,
struct _cef_completion_callback_t* callback);
///
// Flush the backing store (if any) to disk. If |callback| is non-NULL it will
// be executed asnychronously on the IO thread after the flush is complete.
// be executed asnychronously on the UI thread after the flush is complete.
// Returns false (0) if cookies cannot be accessed.
///
int(CEF_CALLBACK* flush_store)(struct _cef_cookie_manager_t* self,
@@ -151,41 +139,17 @@ typedef struct _cef_cookie_manager_t {
///
// Returns the global cookie manager. By default data will be stored at
// CefSettings.cache_path if specified or in memory otherwise. If |callback| is
// non-NULL it will be executed asnychronously on the IO thread after the
// non-NULL it will be executed asnychronously on the UI thread after the
// manager's storage has been initialized. Using this function is equivalent to
// calling cef_request_tContext::cef_request_context_get_global_context()->get_d
// efault_cookie_manager().
// calling cef_request_tContext::cef_request_context_get_global_context()->GetDe
// faultCookieManager().
///
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
struct _cef_completion_callback_t* callback);
///
// Returns a cookie manager that neither stores nor retrieves cookies. All usage
// of cookies will be blocked including cookies accessed via the network
// (request/response headers), via JavaScript (document.cookie), and via
// cef_cookie_manager_t functions. No cookies will be displayed in DevTools. If
// you wish to only block cookies sent via the network use the
// cef_request_tHandler CanGetCookies and CanSetCookie functions instead.
///
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_blocking_manager();
///
// Creates a new cookie manager. If |path| is NULL data will be stored in memory
// only. Otherwise, data will be stored at the specified |path|. To persist
// session cookies (cookies without an expiry date or validity interval) set
// |persist_session_cookies| to true (1). Session cookies are generally intended
// to be transient and most Web browsers do not persist them. If |callback| is
// non-NULL it will be executed asnychronously on the IO thread after the
// manager's storage has been initialized.
///
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager(
const cef_string_t* path,
int persist_session_cookies,
struct _cef_completion_callback_t* callback);
///
// Structure to implement for visiting cookie values. The functions of this
// structure will always be called on the IO thread.
// structure will always be called on the UI thread.
///
typedef struct _cef_cookie_visitor_t {
///
@@ -237,7 +201,7 @@ typedef struct _cef_delete_cookies_callback_t {
///
// Method that will be called upon completion. |num_deleted| will be the
// number of cookies that were deleted or -1 if unknown.
// number of cookies that were deleted.
///
void(CEF_CALLBACK* on_complete)(struct _cef_delete_cookies_callback_t* self,
int num_deleted);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=22ebb1d811a4e0a834eb115859d797c72a5c4ca3$
// $hash=5c7eb1cee72dcb8b7657007b3f9db64680ea8c4d$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_
@@ -43,6 +43,7 @@
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#include "include/capi/cef_drag_data_capi.h"
#include "include/capi/cef_frame_capi.h"
#ifdef __cplusplus
extern "C" {
@@ -79,6 +80,7 @@ typedef struct _cef_drag_handler_t {
void(CEF_CALLBACK* on_draggable_regions_changed)(
struct _cef_drag_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
size_t regionsCount,
cef_draggable_region_t const* regions);
} cef_drag_handler_t;

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=d3fcf9a928adb588443a52d82a48c188a67d3231$
// $hash=6bef924a259845dbf03e9cf5084ff7feb2771034$
//
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
@@ -42,6 +42,7 @@
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_dom_capi.h"
#include "include/capi/cef_process_message_capi.h"
#include "include/capi/cef_request_capi.h"
#include "include/capi/cef_stream_capi.h"
#include "include/capi/cef_string_visitor_capi.h"
@@ -51,6 +52,8 @@ extern "C" {
#endif
struct _cef_browser_t;
struct _cef_urlrequest_client_t;
struct _cef_urlrequest_t;
struct _cef_v8context_t;
///
@@ -215,6 +218,44 @@ typedef struct _cef_frame_t {
///
void(CEF_CALLBACK* visit_dom)(struct _cef_frame_t* self,
struct _cef_domvisitor_t* visitor);
///
// Create a new URL request that will be treated as originating from this
// frame and the associated browser. This request may be intercepted by the
// client via cef_resource_request_handler_t or cef_scheme_handler_factory_t.
// Use cef_urlrequest_t::Create instead if you do not want the request to have
// this association, in which case it may be handled differently (see
// documentation on that function). Requests may originate from both the
// browser process and the render process.
//
// For requests originating from the browser process:
// - POST data may only contain a single element of type PDE_TYPE_FILE or
// PDE_TYPE_BYTES.
// For requests originating from the render process:
// - POST data may only contain a single element of type PDE_TYPE_BYTES.
// - If the response contains Content-Disposition or Mime-Type header values
// that would not normally be rendered then the response may receive
// special handling inside the browser (for example, via the file download
// code path instead of the URL request code path).
//
// The |request| object will be marked as read-only after calling this
// function.
///
struct _cef_urlrequest_t*(CEF_CALLBACK* create_urlrequest)(
struct _cef_frame_t* self,
struct _cef_request_t* request,
struct _cef_urlrequest_client_t* client);
///
// Send a message to the specified |target_process|. Message delivery is not
// guaranteed in all cases (for example, if the browser is closing,
// navigating, or if the target process crashes). Send an ACK message back
// from the target process if confirmation is required.
///
void(CEF_CALLBACK* send_process_message)(
struct _cef_frame_t* self,
cef_process_id_t target_process,
struct _cef_process_message_t* message);
} cef_frame_t;
#ifdef __cplusplus

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=a1648c803a6d72e004e523cd4c02530702635d1e$
// $hash=85d9f30e93e1c3759213074cc5876f848cf4b012$
//
#ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
@@ -80,7 +80,10 @@ typedef struct _cef_life_span_handler_t {
// modifications to |windowInfo| will be ignored if the parent browser is
// wrapped in a cef_browser_view_t. Popup browser creation will be canceled if
// the parent browser is destroyed before the popup browser creation completes
// (indicated by a call to OnAfterCreated for the popup browser).
// (indicated by a call to OnAfterCreated for the popup browser). The
// |extra_info| parameter provides an opportunity to specify extra information
// specific to the created popup browser that will be passed to
// cef_render_process_handler_t::on_browser_created() in the render process.
///
int(CEF_CALLBACK* on_before_popup)(
struct _cef_life_span_handler_t* self,
@@ -94,6 +97,7 @@ typedef struct _cef_life_span_handler_t {
struct _cef_window_info_t* windowInfo,
struct _cef_client_t** client,
struct _cef_browser_settings_t* settings,
struct _cef_dictionary_value_t** extra_info,
int* no_javascript_access);
///
@@ -198,9 +202,13 @@ typedef struct _cef_life_span_handler_t {
///
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any functions on the browser
// object after this callback returns. This callback will be the last
// notification that references |browser|. See do_close() documentation for
// additional usage information.
// object (other than GetIdentifier or IsSame) after this callback returns.
// This callback will be the last notification that references |browser| on
// the UI thread. Any in-progress network requests associated with |browser|
// will be aborted when the browser is destroyed, and
// cef_resource_request_handler_t callbacks related to those requests may
// still arrive on the IO thread after this function is called. See do_close()
// documentation for additional usage information.
///
void(CEF_CALLBACK* on_before_close)(struct _cef_life_span_handler_t* self,
struct _cef_browser_t* browser);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=cf5dc6f6d2c64d5dc706edd5adc5cf6c7c752750$
// $hash=0640490eead86e5631e8db67f3a0de8b43c10640$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_
@@ -231,6 +231,17 @@ typedef struct _cef_render_handler_t {
struct _cef_browser_t* browser,
const cef_string_t* selected_text,
const cef_range_t* selected_range);
///
// Called when an on-screen keyboard should be shown or hidden for the
// specified |browser|. |input_mode| specifies what kind of keyboard should be
// opened. If |input_mode| is CEF_TEXT_INPUT_MODE_NONE, any existing keyboard
// for this browser should be hidden.
///
void(CEF_CALLBACK* on_virtual_keyboard_requested)(
struct _cef_render_handler_t* self,
struct _cef_browser_t* browser,
cef_text_input_mode_t input_mode);
} cef_render_handler_t;
#ifdef __cplusplus

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=63544b02e263d0aeb2f6553bf40c52bcf72d9f0b$
// $hash=6c6efd722dda7480a5449ef31f1d6d9a16fd3465$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_
@@ -83,11 +83,16 @@ typedef struct _cef_render_process_handler_t {
///
// Called after a browser has been created. When browsing cross-origin a new
// browser will be created before the old browser with the same identifier is
// destroyed.
// destroyed. |extra_info| is a read-only value originating from
// cef_browser_host_t::cef_browser_host_create_browser(),
// cef_browser_host_t::cef_browser_host_create_browser_sync(),
// cef_life_span_handler_t::on_before_popup() or
// cef_browser_view_t::cef_browser_view_create().
///
void(CEF_CALLBACK* on_browser_created)(
struct _cef_render_process_handler_t* self,
struct _cef_browser_t* browser);
struct _cef_browser_t* browser,
struct _cef_dictionary_value_t* extra_info);
///
// Called before a browser is destroyed.
@@ -161,6 +166,7 @@ typedef struct _cef_render_process_handler_t {
int(CEF_CALLBACK* on_process_message_received)(
struct _cef_render_process_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
cef_process_id_t source_process,
struct _cef_process_message_t* message);
} cef_render_process_handler_t;

View File

@@ -0,0 +1,74 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// 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=2602018f3322a2d983a02421cf55e0dc0a1357e9$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CALLBACK_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_REQUEST_CALLBACK_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Callback structure used for asynchronous continuation of url requests.
///
typedef struct _cef_request_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Continue the url request. If |allow| is true (1) the request will be
// continued. Otherwise, the request will be canceled.
///
void(CEF_CALLBACK* cont)(struct _cef_request_callback_t* self, int allow);
///
// Cancel the url request.
///
void(CEF_CALLBACK* cancel)(struct _cef_request_callback_t* self);
} cef_request_callback_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_REQUEST_CALLBACK_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=580e0e91bf4052f0e996dc42f63079ca1a6390cf$
// $hash=3a1ab8264989d7f68504dc60ad6dc52c31d323a4$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CAPI_H_
@@ -136,6 +136,27 @@ typedef struct _cef_request_t {
void(CEF_CALLBACK* set_header_map)(struct _cef_request_t* self,
cef_string_multimap_t headerMap);
///
// Returns the first header value for |name| or an NULL string if not found.
// Will not return the Referer value if any. Use GetHeaderMap instead if
// |name| might have multiple values.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_header_by_name)(
struct _cef_request_t* self,
const cef_string_t* name);
///
// Set the header |name| to |value|. If |overwrite| is true (1) any existing
// values will be replaced with the new value. If |overwrite| is false (0) any
// existing values will not be overwritten. The Referer value cannot be set
// using this function.
///
void(CEF_CALLBACK* set_header_by_name)(struct _cef_request_t* self,
const cef_string_t* name,
const cef_string_t* value,
int overwrite);
///
// Set all values at one time.
///
@@ -189,8 +210,8 @@ typedef struct _cef_request_t {
///
// Returns the globally unique identifier for this request or 0 if not
// specified. Can be used by cef_request_tHandler implementations in the
// browser process to track a single request across multiple callbacks.
// specified. Can be used by cef_resource_request_handler_t implementations in
// the browser process to track a single request across multiple callbacks.
///
uint64(CEF_CALLBACK* get_identifier)(struct _cef_request_t* self);
} cef_request_t;

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=cd2b70b906b9f07923d69d9ec0b32488125b0af3$
// $hash=fdfce3e4e33a1d4e1170497d2a476f0837994060$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@@ -44,13 +44,13 @@
#include "include/capi/cef_cookie_capi.h"
#include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/capi/cef_request_context_handler_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_request_context_handler_t;
struct _cef_scheme_handler_factory_t;
///
@@ -130,14 +130,11 @@ typedef struct _cef_request_context_t {
struct _cef_request_context_t* self);
///
// Returns the default cookie manager for this object. This will be the global
// cookie manager if this object is the global request context. Otherwise,
// this will be the default cookie manager used when this request context does
// not receive a value via cef_request_tContextHandler::get_cookie_manager().
// If |callback| is non-NULL it will be executed asnychronously on the IO
// thread after the manager's storage has been initialized.
// Returns the cookie manager for this object. If |callback| is non-NULL it
// will be executed asnychronously on the IO thread after the manager's
// storage has been initialized.
///
struct _cef_cookie_manager_t*(CEF_CALLBACK* get_default_cookie_manager)(
struct _cef_cookie_manager_t*(CEF_CALLBACK* get_cookie_manager)(
struct _cef_request_context_t* self,
struct _cef_completion_callback_t* callback);
@@ -241,6 +238,15 @@ typedef struct _cef_request_context_t {
struct _cef_request_context_t* self,
struct _cef_completion_callback_t* callback);
///
// Clears all HTTP authentication credentials that were added as part of
// handling GetAuthCredentials. If |callback| is non-NULL it will be executed
// on the UI thread after completion.
///
void(CEF_CALLBACK* clear_http_auth_credentials)(
struct _cef_request_context_t* self,
struct _cef_completion_callback_t* callback);
///
// Clears all active and idle connections that Chromium currently has. This is
// only recommended if you have released all other CEF objects but don't yet
@@ -259,17 +265,6 @@ typedef struct _cef_request_context_t {
const cef_string_t* origin,
struct _cef_resolve_callback_t* callback);
///
// Attempts to resolve |origin| to a list of associated IP addresses using
// cached data. |resolved_ips| will be populated with the list of resolved IP
// addresses or NULL if no cached data is available. Returns ERR_NONE on
// success. This function must be called on the browser process IO thread.
///
cef_errorcode_t(CEF_CALLBACK* resolve_host_cached)(
struct _cef_request_context_t* self,
const cef_string_t* origin,
cef_string_list_t resolved_ips);
///
// Load an extension.
//

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=03c829d89f0b5b7ab12634fa2f11c4903cd8edb2$
// $hash=d3a339e3f85077d971e5814eb5a164a87c647810$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_HANDLER_CAPI_H_
@@ -41,15 +41,16 @@
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_cookie_capi.h"
#include "include/capi/cef_browser_capi.h"
#include "include/capi/cef_frame_capi.h"
#include "include/capi/cef_request_capi.h"
#include "include/capi/cef_resource_request_handler_capi.h"
#include "include/capi/cef_web_plugin_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_request_context_t;
///
// Implement this structure to provide handler implementations. The handler
// instance will not be released until all objects related to the context have
@@ -69,14 +70,6 @@ typedef struct _cef_request_context_handler_t {
struct _cef_request_context_handler_t* self,
struct _cef_request_context_t* request_context);
///
// Called on the browser process IO thread to retrieve the cookie manager. If
// this function returns NULL the default cookie manager retrievable via
// cef_request_tContext::get_default_cookie_manager() will be used.
///
struct _cef_cookie_manager_t*(CEF_CALLBACK* get_cookie_manager)(
struct _cef_request_context_handler_t* self);
///
// Called on multiple browser process threads before a plugin instance is
// loaded. |mime_type| is the mime type of the plugin that will be loaded.
@@ -104,6 +97,35 @@ typedef struct _cef_request_context_handler_t {
const cef_string_t* top_origin_url,
struct _cef_web_plugin_info_t* plugin_info,
cef_plugin_policy_t* plugin_policy);
///
// Called on the browser process IO thread before a resource request is
// initiated. The |browser| and |frame| values represent the source of the
// request, and may be NULL for requests originating from service workers or
// cef_urlrequest_t. |request| represents the request contents and cannot be
// modified in this callback. |is_navigation| will be true (1) if the resource
// request is a navigation. |is_download| will be true (1) if the resource
// request is a download. |request_initiator| is the origin (scheme + domain)
// of the page that initiated the request. Set |disable_default_handling| to
// true (1) to disable default handling of the request, in which case it will
// need to be handled via cef_resource_request_handler_t::GetResourceHandler
// or it will be canceled. To allow the resource load to proceed with default
// handling return NULL. To specify a handler for the resource return a
// cef_resource_request_handler_t object. This function will not be called if
// the client associated with |browser| returns a non-NULL value from
// cef_request_tHandler::GetResourceRequestHandler for the same request
// (identified by cef_request_t::GetIdentifier).
///
struct _cef_resource_request_handler_t*(
CEF_CALLBACK* get_resource_request_handler)(
struct _cef_request_context_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
int is_navigation,
int is_download,
const cef_string_t* request_initiator,
int* disable_default_handling);
} cef_request_context_handler_t;
#ifdef __cplusplus

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=64631c0b1776a951da838f8b08a4c71ef33a15cc$
// $hash=d9c4e8591ee39bd9d8c1714c0ca2417a7d2a38ea$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_
@@ -44,10 +44,9 @@
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#include "include/capi/cef_frame_capi.h"
#include "include/capi/cef_request_callback_capi.h"
#include "include/capi/cef_request_capi.h"
#include "include/capi/cef_resource_handler_capi.h"
#include "include/capi/cef_response_capi.h"
#include "include/capi/cef_response_filter_capi.h"
#include "include/capi/cef_resource_request_handler_capi.h"
#include "include/capi/cef_ssl_info_capi.h"
#include "include/capi/cef_x509_certificate_capi.h"
@@ -55,27 +54,6 @@
extern "C" {
#endif
///
// Callback structure used for asynchronous continuation of url requests.
///
typedef struct _cef_request_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Continue the url request. If |allow| is true (1) the request will be
// continued. Otherwise, the request will be canceled.
///
void(CEF_CALLBACK* cont)(struct _cef_request_callback_t* self, int allow);
///
// Cancel the url request.
///
void(CEF_CALLBACK* cancel)(struct _cef_request_callback_t* self);
} cef_request_callback_t;
///
// Callback structure used to select a client certificate for authentication.
///
@@ -148,92 +126,39 @@ typedef struct _cef_request_handler_t {
int user_gesture);
///
// Called on the IO thread before a resource request is loaded. The |request|
// object may be modified. Return RV_CONTINUE to continue the request
// immediately. Return RV_CONTINUE_ASYNC and call cef_request_tCallback::
// cont() at a later time to continue or cancel the request asynchronously.
// Return RV_CANCEL to cancel the request immediately.
//
// Called on the browser process IO thread before a resource request is
// initiated. The |browser| and |frame| values represent the source of the
// request. |request| represents the request contents and cannot be modified
// in this callback. |is_navigation| will be true (1) if the resource request
// is a navigation. |is_download| will be true (1) if the resource request is
// a download. |request_initiator| is the origin (scheme + domain) of the page
// that initiated the request. Set |disable_default_handling| to true (1) to
// disable default handling of the request, in which case it will need to be
// handled via cef_resource_request_handler_t::GetResourceHandler or it will
// be canceled. To allow the resource load to proceed with default handling
// return NULL. To specify a handler for the resource return a
// cef_resource_request_handler_t object. If this callback returns NULL the
// same function will be called on the associated cef_request_tContextHandler,
// if any.
///
cef_return_value_t(CEF_CALLBACK* on_before_resource_load)(
struct _cef_resource_request_handler_t*(
CEF_CALLBACK* get_resource_request_handler)(
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_request_callback_t* callback);
///
// Called on the IO thread before a resource is loaded. To allow the resource
// to load normally return NULL. To specify a handler for the resource return
// a cef_resource_handler_t object. The |request| object should not be
// modified in this callback.
///
struct _cef_resource_handler_t*(CEF_CALLBACK* get_resource_handler)(
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request);
///
// Called on the IO thread when a resource load is redirected. The |request|
// parameter will contain the old URL and other request-related information.
// The |response| parameter will contain the response that resulted in the
// redirect. The |new_url| parameter will contain the new URL and can be
// changed if desired. The |request| object cannot be modified in this
// callback.
///
void(CEF_CALLBACK* on_resource_redirect)(struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_response_t* response,
cef_string_t* new_url);
///
// Called on the IO thread when a resource response is received. To allow the
// resource to load normally return false (0). To redirect or retry the
// resource modify |request| (url, headers or post body) and return true (1).
// The |response| object cannot be modified in this callback.
///
int(CEF_CALLBACK* on_resource_response)(struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_response_t* response);
///
// Called on the IO thread to optionally filter resource response content.
// |request| and |response| represent the request and response respectively
// and cannot be modified in this callback.
///
struct _cef_response_filter_t*(CEF_CALLBACK* get_resource_response_filter)(
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_response_t* response);
///
// Called on the IO thread when a resource load has completed. |request| and
// |response| represent the request and response respectively and cannot be
// modified in this callback. |status| indicates the load completion status.
// |received_content_length| is the number of response bytes actually read.
///
void(CEF_CALLBACK* on_resource_load_complete)(
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_response_t* response,
cef_urlrequest_status_t status,
int64 received_content_length);
int is_navigation,
int is_download,
const cef_string_t* request_initiator,
int* disable_default_handling);
///
// Called on the IO thread when the browser needs credentials from the user.
// |isProxy| indicates whether the host is a proxy server. |host| contains the
// hostname and |port| contains the port number. |realm| is the realm of the
// challenge and may be NULL. |scheme| is the authentication scheme used, such
// as "basic" or "digest", and will be NULL if the source of the request is an
// |origin_url| is the origin making this authentication request. |isProxy|
// indicates whether the host is a proxy server. |host| contains the hostname
// and |port| contains the port number. |realm| is the realm of the challenge
// and may be NULL. |scheme| is the authentication scheme used, such as
// "basic" or "digest", and will be NULL if the source of the request is an
// FTP server. Return true (1) to continue the request and call
// cef_auth_callback_t::cont() either in this function or at a later time when
// the authentication information is available. Return false (0) to cancel the
@@ -242,7 +167,7 @@ typedef struct _cef_request_handler_t {
int(CEF_CALLBACK* get_auth_credentials)(
struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
const cef_string_t* origin_url,
int isProxy,
const cef_string_t* host,
int port,
@@ -250,29 +175,6 @@ typedef struct _cef_request_handler_t {
const cef_string_t* scheme,
struct _cef_auth_callback_t* callback);
///
// Called on the IO thread before sending a network request with a "Cookie"
// request header. Return true (1) to allow cookies to be included in the
// network request or false (0) to block cookies. The |request| object should
// not be modified in this callback.
///
int(CEF_CALLBACK* can_get_cookies)(struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request);
///
// Called on the IO thread when receiving a network request with a "Set-
// Cookie" response header value represented by |cookie|. Return true (1) to
// allow the cookie to be stored or false (0) to block the cookie. The
// |request| object should not be modified in this callback.
///
int(CEF_CALLBACK* can_set_cookie)(struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
const struct _cef_cookie_t* cookie);
///
// Called on the IO thread when JavaScript requests a specific storage quota
// size via the webkitStorageInfo.requestQuota function. |origin_url| is the
@@ -288,18 +190,6 @@ typedef struct _cef_request_handler_t {
int64 new_size,
struct _cef_request_callback_t* callback);
///
// Called on the UI thread to handle requests for URLs with an unknown
// protocol component. Set |allow_os_execution| to true (1) to attempt
// execution via the registered OS protocol handler, if any. SECURITY WARNING:
// YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR
// OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
///
void(CEF_CALLBACK* on_protocol_execution)(struct _cef_request_handler_t* self,
struct _cef_browser_t* browser,
const cef_string_t* url,
int* allow_os_execution);
///
// Called on the UI thread to handle requests for URLs with an invalid SSL
// certificate. Return true (1) and call cef_request_tCallback::cont() either

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=706e3ebbdb4e3b01f3f3bb18eb85c1897c8b5ade$
// $hash=8c6ffeab9c9183cc5f77929839643767ce5c5c2f$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_HANDLER_CAPI_H_
@@ -51,9 +51,48 @@
extern "C" {
#endif
///
// Callback for asynchronous continuation of cef_resource_handler_t::skip().
///
typedef struct _cef_resource_skip_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Callback for asynchronous continuation of skip(). If |bytes_skipped| > 0
// then either skip() will be called again until the requested number of bytes
// have been skipped or the request will proceed. If |bytes_skipped| <= 0 the
// request will fail with ERR_REQUEST_RANGE_NOT_SATISFIABLE.
///
void(CEF_CALLBACK* cont)(struct _cef_resource_skip_callback_t* self,
int64 bytes_skipped);
} cef_resource_skip_callback_t;
///
// Callback for asynchronous continuation of cef_resource_handler_t::read().
///
typedef struct _cef_resource_read_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Callback for asynchronous continuation of read(). If |bytes_read| == 0 the
// response will be considered complete. If |bytes_read| > 0 then read() will
// be called again until the request is complete (based on either the result
// or the expected content length). If |bytes_read| < 0 then the request will
// fail and the |bytes_read| value will be treated as the error code.
///
void(CEF_CALLBACK* cont)(struct _cef_resource_read_callback_t* self,
int bytes_read);
} cef_resource_read_callback_t;
///
// Structure used to implement a custom request handler structure. The functions
// of this structure will always be called on the IO thread.
// of this structure will be called on the IO thread unless otherwise indicated.
///
typedef struct _cef_resource_handler_t {
///
@@ -61,12 +100,29 @@ typedef struct _cef_resource_handler_t {
///
cef_base_ref_counted_t base;
///
// Open the response stream. To handle the request immediately set
// |handle_request| to true (1) and return true (1). To decide at a later time
// set |handle_request| to false (0), return true (1), and execute |callback|
// to continue or cancel the request. To cancel the request immediately set
// |handle_request| to true (1) and return false (0). This function will be
// called in sequence but not from a dedicated thread. For backwards
// compatibility set |handle_request| to false (0) and return false (0) and
// the ProcessRequest function will be called.
///
int(CEF_CALLBACK* open)(struct _cef_resource_handler_t* self,
struct _cef_request_t* request,
int* handle_request,
struct _cef_callback_t* callback);
///
// Begin processing the request. To handle the request return true (1) and
// call cef_callback_t::cont() once the response header information is
// available (cef_callback_t::cont() can also be called from inside this
// function if header information is available immediately). To cancel the
// request return false (0).
//
// WARNING: This function is deprecated. Use Open instead.
///
int(CEF_CALLBACK* process_request)(struct _cef_resource_handler_t* self,
struct _cef_request_t* request,
@@ -92,12 +148,47 @@ typedef struct _cef_resource_handler_t {
int64* response_length,
cef_string_t* redirectUrl);
///
// Skip response data when requested by a Range header. Skip over and discard
// |bytes_to_skip| bytes of response data. If data is available immediately
// set |bytes_skipped| to the number of bytes skipped and return true (1). To
// read the data at a later time set |bytes_skipped| to 0, return true (1) and
// execute |callback| when the data is available. To indicate failure set
// |bytes_skipped| to < 0 (e.g. -2 for ERR_FAILED) and return false (0). This
// function will be called in sequence but not from a dedicated thread.
///
int(CEF_CALLBACK* skip)(struct _cef_resource_handler_t* self,
int64 bytes_to_skip,
int64* bytes_skipped,
struct _cef_resource_skip_callback_t* callback);
///
// Read response data. If data is available immediately copy up to
// |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of
// bytes copied, and return true (1). To read the data at a later time keep a
// pointer to |data_out|, set |bytes_read| to 0, return true (1) and execute
// |callback| when the data is available (|data_out| will remain valid until
// the callback is executed). To indicate response completion set |bytes_read|
// to 0 and return false (0). To indicate failure set |bytes_read| to < 0
// (e.g. -2 for ERR_FAILED) and return false (0). This function will be called
// in sequence but not from a dedicated thread. For backwards compatibility
// set |bytes_read| to -1 and return false (0) and the ReadResponse function
// will be called.
///
int(CEF_CALLBACK* read)(struct _cef_resource_handler_t* self,
void* data_out,
int bytes_to_read,
int* bytes_read,
struct _cef_resource_read_callback_t* callback);
///
// Read response data. If data is available immediately copy up to
// |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of
// bytes copied, and return true (1). To read the data at a later time set
// |bytes_read| to 0, return true (1) and call cef_callback_t::cont() when the
// data is available. To indicate response completion return false (0).
//
// WARNING: This function is deprecated. Use Skip and Read instead.
///
int(CEF_CALLBACK* read_response)(struct _cef_resource_handler_t* self,
void* data_out,
@@ -105,21 +196,6 @@ typedef struct _cef_resource_handler_t {
int* bytes_read,
struct _cef_callback_t* callback);
///
// Return true (1) if the specified cookie can be sent with the request or
// false (0) otherwise. If false (0) is returned for any cookie then no
// cookies will be sent with the request.
///
int(CEF_CALLBACK* can_get_cookie)(struct _cef_resource_handler_t* self,
const struct _cef_cookie_t* cookie);
///
// Return true (1) if the specified cookie returned with the response can be
// set or false (0) otherwise.
///
int(CEF_CALLBACK* can_set_cookie)(struct _cef_resource_handler_t* self,
const struct _cef_cookie_t* cookie);
///
// Request processing has been canceled.
///

View File

@@ -0,0 +1,254 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// 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=adb3ca1e315a28efed7b2305c8aceb9c5eafdc66$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_REQUEST_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_RESOURCE_REQUEST_HANDLER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#include "include/capi/cef_frame_capi.h"
#include "include/capi/cef_request_callback_capi.h"
#include "include/capi/cef_request_capi.h"
#include "include/capi/cef_resource_handler_capi.h"
#include "include/capi/cef_response_capi.h"
#include "include/capi/cef_response_filter_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_cookie_access_filter_t;
///
// Implement this structure to handle events related to browser requests. The
// functions of this structure will be called on the IO thread unless otherwise
// indicated.
///
typedef struct _cef_resource_request_handler_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called on the IO thread before a resource request is loaded. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or cef_urlrequest_t. To
// optionally filter cookies for the request return a
// cef_cookie_access_filter_t object. The |request| object cannot not be
// modified in this callback.
///
struct _cef_cookie_access_filter_t*(CEF_CALLBACK* get_cookie_access_filter)(
struct _cef_resource_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request);
///
// Called on the IO thread before a resource request is loaded. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or cef_urlrequest_t. To redirect
// or change the resource load optionally modify |request|. Modification of
// the request URL will be treated as a redirect. Return RV_CONTINUE to
// continue the request immediately. Return RV_CONTINUE_ASYNC and call
// cef_request_tCallback:: cont() at a later time to continue or cancel the
// request asynchronously. Return RV_CANCEL to cancel the request immediately.
//
///
cef_return_value_t(CEF_CALLBACK* on_before_resource_load)(
struct _cef_resource_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_request_callback_t* callback);
///
// Called on the IO thread before a resource is loaded. The |browser| and
// |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or cef_urlrequest_t. To allow the
// resource to load using the default network loader return NULL. To specify a
// handler for the resource return a cef_resource_handler_t object. The
// |request| object cannot not be modified in this callback.
///
struct _cef_resource_handler_t*(CEF_CALLBACK* get_resource_handler)(
struct _cef_resource_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request);
///
// Called on the IO thread when a resource load is redirected. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or cef_urlrequest_t. The
// |request| parameter will contain the old URL and other request-related
// information. The |response| parameter will contain the response that
// resulted in the redirect. The |new_url| parameter will contain the new URL
// and can be changed if desired. The |request| and |response| objects cannot
// be modified in this callback.
///
void(CEF_CALLBACK* on_resource_redirect)(
struct _cef_resource_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_response_t* response,
cef_string_t* new_url);
///
// Called on the IO thread when a resource response is received. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or cef_urlrequest_t. To allow the
// resource load to proceed without modification return false (0). To redirect
// or retry the resource load optionally modify |request| and return true (1).
// Modification of the request URL will be treated as a redirect. Requests
// handled using the default network loader cannot be redirected in this
// callback. The |response| object cannot be modified in this callback.
//
// WARNING: Redirecting using this function is deprecated. Use
// OnBeforeResourceLoad or GetResourceHandler to perform redirects.
///
int(CEF_CALLBACK* on_resource_response)(
struct _cef_resource_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_response_t* response);
///
// Called on the IO thread to optionally filter resource response content. The
// |browser| and |frame| values represent the source of the request, and may
// be NULL for requests originating from service workers or cef_urlrequest_t.
// |request| and |response| represent the request and response respectively
// and cannot be modified in this callback.
///
struct _cef_response_filter_t*(CEF_CALLBACK* get_resource_response_filter)(
struct _cef_resource_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_response_t* response);
///
// Called on the IO thread when a resource load has completed. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or cef_urlrequest_t. |request|
// and |response| represent the request and response respectively and cannot
// be modified in this callback. |status| indicates the load completion
// status. |received_content_length| is the number of response bytes actually
// read. This function will be called for all requests, including requests
// that are aborted due to CEF shutdown or destruction of the associated
// browser. In cases where the associated browser is destroyed this callback
// may arrive after the cef_life_span_handler_t::OnBeforeClose callback for
// that browser. The cef_frame_t::IsValid function can be used to test for
// this situation, and care should be taken not to call |browser| or |frame|
// functions that modify state (like LoadURL, SendProcessMessage, etc.) if the
// frame is invalid.
///
void(CEF_CALLBACK* on_resource_load_complete)(
struct _cef_resource_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_response_t* response,
cef_urlrequest_status_t status,
int64 received_content_length);
///
// Called on the IO thread to handle requests for URLs with an unknown
// protocol component. The |browser| and |frame| values represent the source
// of the request, and may be NULL for requests originating from service
// workers or cef_urlrequest_t. |request| cannot be modified in this callback.
// Set |allow_os_execution| to true (1) to attempt execution via the
// registered OS protocol handler, if any. SECURITY WARNING: YOU SHOULD USE
// THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR OTHER URL
// ANALYSIS BEFORE ALLOWING OS EXECUTION.
///
void(CEF_CALLBACK* on_protocol_execution)(
struct _cef_resource_request_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
int* allow_os_execution);
} cef_resource_request_handler_t;
///
// Implement this structure to filter cookies that may be sent or received from
// resource requests. The functions of this structure will be called on the IO
// thread unless otherwise indicated.
///
typedef struct _cef_cookie_access_filter_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called on the IO thread before a resource request is sent. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or cef_urlrequest_t. |request|
// cannot be modified in this callback. Return true (1) if the specified
// cookie can be sent with the request or false (0) otherwise.
///
int(CEF_CALLBACK* can_send_cookie)(struct _cef_cookie_access_filter_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
const struct _cef_cookie_t* cookie);
///
// Called on the IO thread after a resource response is received. The
// |browser| and |frame| values represent the source of the request, and may
// be NULL for requests originating from service workers or cef_urlrequest_t.
// |request| cannot be modified in this callback. Return true (1) if the
// specified cookie returned with the response can be saved or false (0)
// otherwise.
///
int(CEF_CALLBACK* can_save_cookie)(struct _cef_cookie_access_filter_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
struct _cef_request_t* request,
struct _cef_response_t* response,
const struct _cef_cookie_t* cookie);
} cef_cookie_access_filter_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_RESOURCE_REQUEST_HANDLER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=0c99415ddb1bf7d10135545c7b0ccfb7eec2264d$
// $hash=cc5ec5ca76adb568adb08c3b58fb3289a94b2ecd$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RESPONSE_CAPI_H_
@@ -109,6 +109,19 @@ typedef struct _cef_response_t {
void(CEF_CALLBACK* set_mime_type)(struct _cef_response_t* self,
const cef_string_t* mimeType);
///
// Get the response charset.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_charset)(
struct _cef_response_t* self);
///
// Set the response charset.
///
void(CEF_CALLBACK* set_charset)(struct _cef_response_t* self,
const cef_string_t* charset);
///
// Get the value for the specified response header field.
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=f83c72ec43f10f19eba82d9d3c284cc436cdbd23$
// $hash=bf5c2a51aa80e831382bfe08e8dd5ec6331f0fdc$
//
#ifndef CEF_INCLUDE_CAPI_CEF_SCHEME_CAPI_H_
@@ -66,56 +66,7 @@ typedef struct _cef_scheme_registrar_t {
// Register a custom scheme. This function should not be called for the built-
// in HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes.
//
// If |is_standard| is true (1) the scheme will be treated as a standard
// scheme. Standard schemes are subject to URL canonicalization and parsing
// rules as defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1
// available at http://www.ietf.org/rfc/rfc1738.txt
//
// In particular, the syntax for standard scheme URLs must be of the form:
// <pre>
// [scheme]://[username]:[password]@[host]:[port]/[url-path]
// </pre> Standard scheme URLs must have a host component that is a fully
// qualified domain name as defined in Section 3.5 of RFC 1034 [13] and
// Section 2.1 of RFC 1123. These URLs will be canonicalized to
// "scheme://host/path" in the simplest case and
// "scheme://username:password@host:port/path" in the most explicit case. For
// example, "scheme:host/path" and "scheme:///host/path" will both be
// canonicalized to "scheme://host/path". The origin of a standard scheme URL
// is the combination of scheme, host and port (i.e., "scheme://host:port" in
// the most explicit case).
//
// For non-standard scheme URLs only the "scheme:" component is parsed and
// canonicalized. The remainder of the URL will be passed to the handler as-
// is. For example, "scheme:///some%20text" will remain the same. Non-standard
// scheme URLs cannot be used as a target for form submission.
//
// If |is_local| is true (1) the scheme will be treated with the same security
// rules as those applied to "file" URLs. Normal pages cannot link to or
// access local URLs. Also, by default, local URLs can only perform
// XMLHttpRequest calls to the same URL (origin + path) that originated the
// request. To allow XMLHttpRequest calls from a local URL to other URLs with
// the same origin set the CefSettings.file_access_from_file_urls_allowed
// value to true (1). To allow XMLHttpRequest calls from a local URL to all
// origins set the CefSettings.universal_access_from_file_urls_allowed value
// to true (1).
//
// If |is_display_isolated| is true (1) the scheme can only be displayed from
// other content hosted with the same scheme. For example, pages in other
// origins cannot create iframes or hyperlinks to URLs with the scheme. For
// schemes that must be accessible from other schemes set this value to false
// (0), set |is_cors_enabled| to true (1), and use CORS "Access-Control-Allow-
// Origin" headers to further restrict access.
//
// If |is_secure| is true (1) the scheme will be treated with the same
// security rules as those applied to "https" URLs. For example, loading this
// scheme from other secure schemes will not trigger mixed content warnings.
//
// If |is_cors_enabled| is true (1) the scheme can be sent CORS requests. This
// value should be true (1) in most cases where |is_standard| is true (1).
//
// If |is_csp_bypassing| is true (1) the scheme can bypass Content-Security-
// Policy (CSP) checks. This value should be false (0) in most cases where
// |is_standard| is true (1).
// See cef_scheme_options_t for possible values for |options|.
//
// This function may be called on any thread. It should only be called once
// per unique |scheme_name| value. If |scheme_name| is already registered or
@@ -123,12 +74,7 @@ typedef struct _cef_scheme_registrar_t {
///
int(CEF_CALLBACK* add_custom_scheme)(struct _cef_scheme_registrar_t* self,
const cef_string_t* scheme_name,
int is_standard,
int is_local,
int is_display_isolated,
int is_secure,
int is_cors_enabled,
int is_csp_bypassing);
int options);
} cef_scheme_registrar_t;
///
@@ -148,7 +94,7 @@ typedef struct _cef_scheme_handler_factory_t {
// will be the browser window and frame respectively that originated the
// request or NULL if the request did not originate from a browser window (for
// example, if the request came from cef_urlrequest_t). The |request| object
// passed to this function will not contain cookie data.
// passed to this function cannot be modified.
///
struct _cef_resource_handler_t*(CEF_CALLBACK* create)(
struct _cef_scheme_handler_factory_t* self,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=fa6b1185c566277ff593e7e537dff2b8085d1f3a$
// $hash=77ac3a2aaea32b649185a58e4c2bbb13b7fe0540$
//
#ifndef CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_
@@ -112,19 +112,25 @@ typedef struct _cef_urlrequest_t {
} cef_urlrequest_t;
///
// Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request
// functions are supported. Multiple post data elements are not supported and
// elements of type PDE_TYPE_FILE are only supported for requests originating
// from the browser process. Requests originating from the render process will
// receive the same handling as requests originating from Web content -- if the
// response contains Content-Disposition or Mime-Type header values that would
// not normally be rendered then the response may receive special handling
// inside the browser (for example, via the file download code path instead of
// the URL request code path). The |request| object will be marked as read-only
// after calling this function. In the browser process if |request_context| is
// NULL the global request context will be used. In the render process
// |request_context| must be NULL and the context associated with the current
// renderer process' browser will be used.
// 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
// have this association, in which case it may be handled differently (see
// documentation on that function). Requests may originate from the both browser
// process and the render process.
//
// For requests originating from the browser process:
// - It may be intercepted by the client via CefResourceRequestHandler or
// CefSchemeHandlerFactory.
// - POST data may only contain only a single element of type PDE_TYPE_FILE
// or PDE_TYPE_BYTES.
// - 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.
///
CEF_EXPORT cef_urlrequest_t* cef_urlrequest_create(
struct _cef_request_t* request,
@@ -187,9 +193,11 @@ typedef struct _cef_urlrequest_client_t {
// |isProxy| indicates whether the host is a proxy server. |host| contains the
// hostname and |port| contains the port number. Return true (1) to continue
// the request and call cef_auth_callback_t::cont() when the authentication
// information is available. Return false (0) to cancel the request. This
// function will only be called for requests initiated from the browser
// process.
// information is available. If the request has an associated browser/frame
// then returning false (0) will result in a call to GetAuthCredentials on the
// cef_request_tHandler associated with that browser, if any. Otherwise,
// returning false (0) will cancel the request immediately. This function will
// only be called for requests initiated from the browser process.
///
int(CEF_CALLBACK* get_auth_credentials)(
struct _cef_urlrequest_client_t* self,

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=c499099d6f628e58d2eed207537817758161af5d$
// $hash=400746f8fac7fa3dba7ee889c10ae6ca22b93fe1$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
@@ -80,12 +80,16 @@ typedef struct _cef_browser_view_t {
///
// Create a new BrowserView. The underlying cef_browser_t will not be created
// until this view is added to the views hierarchy.
// until this view is added to the views hierarchy. The optional |extra_info|
// parameter provides an opportunity to specify extra information specific to
// the created browser that will be passed to
// cef_render_process_handler_t::on_browser_created() in the render process.
///
CEF_EXPORT cef_browser_view_t* cef_browser_view_create(
struct _cef_client_t* client,
const cef_string_t* url,
const struct _cef_browser_settings_t* settings,
struct _cef_dictionary_value_t* extra_info,
struct _cef_request_context_t* request_context,
struct _cef_browser_view_delegate_t* delegate);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=81babf6211a1e99886028bfc4fb9107ef7517c1f$
// $hash=973d3f764a42f1bf255b52dcd1041aaba1f1475b$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_LABEL_BUTTON_CAPI_H_
@@ -148,16 +148,11 @@ typedef struct _cef_label_button_t {
///
// Create a new LabelButton. A |delegate| must be provided to handle the button
// click. |text| will be shown on the LabelButton and used as the default
// accessible name. If |with_frame| is true (1) the button will have a visible
// frame at all times, center alignment, additional padding and a default
// minimum size of 70x33 DIP. If |with_frame| is false (0) the button will only
// have a visible frame on hover/press, left alignment, less padding and no
// default minimum size.
// accessible name.
///
CEF_EXPORT cef_label_button_t* cef_label_button_create(
struct _cef_button_delegate_t* delegate,
const cef_string_t* text,
int with_frame);
const cef_string_t* text);
#ifdef __cplusplus
}

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=f375009823015557083997f5a1c2033739de9c22$
// $hash=889104f0418508aaa66ed8808b627fdd6652102c$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_MENU_BUTTON_CAPI_H_
@@ -89,8 +89,7 @@ typedef struct _cef_menu_button_t {
///
CEF_EXPORT cef_menu_button_t* cef_menu_button_create(
struct _cef_menu_button_delegate_t* delegate,
const cef_string_t* text,
int with_frame);
const cef_string_t* text);
#ifdef __cplusplus
}

76
include/cef_api_hash.h Normal file
View File

@@ -0,0 +1,76 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// 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=23774ff0da7e40bab8244ff4b661b1d9fed24107$
//
#ifndef CEF_INCLUDE_API_HASH_H_
#define CEF_INCLUDE_API_HASH_H_
#include "include/internal/cef_export.h"
// The API hash is created by analyzing CEF header files for C API type
// definitions. The hash value will change when header files are modified in a
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "d04fc15ff27c5a8ee71fee4a88383e5c4bbb7b10"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "031426ad8eb80ee32fcf3605837cff8d3bbae3a4"
#elif defined(OS_MACOSX)
#define CEF_API_HASH_PLATFORM "47422c9703f7c32013642707b976d299c72f42cb"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "d333fdd7eee13c06f58e586513061ce121121e0b"
#endif
#ifdef __cplusplus
extern "C" {
#endif
///
// Returns CEF API hashes for the libcef library. The returned string is owned
// by the library and should not be freed. The |entry| parameter describes which
// hash value will be returned:
// 0 - CEF_API_HASH_PLATFORM
// 1 - CEF_API_HASH_UNIVERSAL
// 2 - CEF_COMMIT_HASH (from cef_version.h)
///
CEF_EXPORT const char* cef_api_hash(int entry);
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_API_HASH_H_

View File

@@ -0,0 +1,98 @@
// Copyright (c) 2018 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
// All methods will be called on the UI thread
///
/*--cef(source=client)--*/
class CefAudioHandler : public virtual CefBaseRefCounted {
public:
typedef cef_channel_layout_t ChannelLayout;
///
// Called when the stream identified by |audio_stream_id| has started.
// |audio_stream_id| will uniquely identify the stream across all future
// CefAudioHandler callbacks. OnAudioSteamStopped will always be called after
// OnAudioStreamStarted; both methods may be called multiple times for the
// same stream. |channels| is the number of channels, |channel_layout| is the
// layout of the channels and |sample_rate| is the stream sample rate.
// |frames_per_buffer| is the maximum number of frames that will occur in the
// PCM packet passed to OnAudioStreamPacket.
///
/*--cef()--*/
virtual void OnAudioStreamStarted(CefRefPtr<CefBrowser> browser,
int audio_stream_id,
int channels,
ChannelLayout channel_layout,
int sample_rate,
int frames_per_buffer) = 0;
///
// Called when a PCM packet is received for the stream identified by
// |audio_stream_id|. |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,
int audio_stream_id,
const float** data,
int frames,
int64 pts) = 0;
///
// Called when the stream identified by |audio_stream_id| 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,
int audio_stream_id) = 0;
};
#endif // CEF_INCLUDE_CEF_AUDIO_HANDLER_H_

View File

@@ -139,7 +139,7 @@ class CefRefCount {
} \
\
private: \
CefRefCount ref_count_;
CefRefCount ref_count_
///
// Macro that provides a locking implementation. Use the Lock() and Unlock()

View File

@@ -44,7 +44,6 @@
#include "include/cef_frame.h"
#include "include/cef_image.h"
#include "include/cef_navigation_entry.h"
#include "include/cef_process_message.h"
#include "include/cef_request_context.h"
class CefBrowserHost;
@@ -181,14 +180,6 @@ class CefBrowser : public virtual CefBaseRefCounted {
///
/*--cef()--*/
virtual void GetFrameNames(std::vector<CefString>& names) = 0;
///
// Send a message to the specified |target_process|. Returns true if the
// message was sent successfully.
///
/*--cef()--*/
virtual bool SendProcessMessage(CefProcessId target_process,
CefRefPtr<CefProcessMessage> message) = 0;
};
///
@@ -286,29 +277,37 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
// |windowInfo|. All values will be copied internally and the actual window
// will be created on the UI thread. If |request_context| is empty the
// global request context will be used. This method can be called on any
// browser process thread and will not block.
// browser process thread and will not block. The optional |extra_info|
// parameter provides an opportunity to specify extra information specific
// to the created browser that will be passed to
// CefRenderProcessHandler::OnBrowserCreated() in the render process.
///
/*--cef(optional_param=client,optional_param=url,
optional_param=request_context)--*/
optional_param=request_context,optional_param=extra_info)--*/
static bool CreateBrowser(const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefString& url,
const CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue> extra_info,
CefRefPtr<CefRequestContext> request_context);
///
// Create a new browser window using the window parameters specified by
// |windowInfo|. If |request_context| is empty the global request context
// will be used. This method can only be called on the browser process UI
// thread.
// thread. The optional |extra_info| parameter provides an opportunity to
// specify extra information specific to the created browser that will be
// passed to CefRenderProcessHandler::OnBrowserCreated() in the render
// process.
///
/*--cef(optional_param=client,optional_param=url,
optional_param=request_context)--*/
optional_param=request_context,optional_param=extra_info)--*/
static CefRefPtr<CefBrowser> CreateBrowserSync(
const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefString& url,
const CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue> extra_info,
CefRefPtr<CefRequestContext> request_context);
///
@@ -638,6 +637,12 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
int deltaX,
int deltaY) = 0;
///
// Send a touch event to the browser for a windowless browser.
///
/*--cef()--*/
virtual void SendTouchEvent(const CefTouchEvent& event) = 0;
///
// Send a focus event to the browser.
///
@@ -865,6 +870,19 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
///
/*--cef()--*/
virtual bool IsBackgroundHost() = 0;
///
// Set whether the browser's audio is muted.
///
/*--cef()--*/
virtual void SetAudioMuted(bool mute) = 0;
///
// Returns true if the browser's audio is muted. This method can only be
// called on the UI thread.
///
/*--cef()--*/
virtual bool IsAudioMuted() = 0;
};
#endif // CEF_INCLUDE_CEF_BROWSER_H_

View File

@@ -47,7 +47,7 @@
// Class used to implement browser process callbacks. The methods of this class
// will be called on the browser process main thread unless otherwise indicated.
///
/*--cef(source=client)--*/
/*--cef(source=client,no_debugct_check)--*/
class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
public:
///

View File

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

View File

@@ -56,7 +56,7 @@ class CefCookieManager : public virtual CefBaseRefCounted {
///
// Returns the global cookie manager. By default data will be stored at
// CefSettings.cache_path if specified or in memory otherwise. If |callback|
// is non-NULL it will be executed asnychronously on the IO thread after the
// is non-NULL it will be executed asnychronously on the UI thread after the
// manager's storage has been initialized. Using this method is equivalent to
// calling CefRequestContext::GetGlobalContext()->GetDefaultCookieManager().
///
@@ -65,44 +65,22 @@ class CefCookieManager : public virtual CefBaseRefCounted {
CefRefPtr<CefCompletionCallback> callback);
///
// Returns a cookie manager that neither stores nor retrieves cookies. All
// usage of cookies will be blocked including cookies accessed via the network
// (request/response headers), via JavaScript (document.cookie), and via
// CefCookieManager methods. No cookies will be displayed in DevTools. If you
// wish to only block cookies sent via the network use the CefRequestHandler
// CanGetCookies and CanSetCookie methods instead.
///
/*--cef()--*/
static CefRefPtr<CefCookieManager> GetBlockingManager();
///
// Creates a new cookie manager. If |path| is empty data will be stored in
// memory only. Otherwise, data will be stored at the specified |path|. To
// persist session cookies (cookies without an expiry date or validity
// interval) set |persist_session_cookies| to true. Session cookies are
// generally intended to be transient and most Web browsers do not persist
// them. If |callback| is non-NULL it will be executed asnychronously on the
// IO thread after the manager's storage has been initialized.
///
/*--cef(optional_param=path,optional_param=callback)--*/
static CefRefPtr<CefCookieManager> CreateManager(
const CefString& path,
bool persist_session_cookies,
CefRefPtr<CefCompletionCallback> callback);
///
// Set the schemes supported by this manager. The default schemes ("http",
// "https", "ws" and "wss") will always be supported. If |callback| is non-
// NULL it will be executed asnychronously on the IO thread after the change
// has been applied. Must be called before any cookies are accessed.
// Set the schemes supported by this manager. If |include_defaults| is true
// the default schemes ("http", "https", "ws" and "wss") will also be
// supported. Calling this method with an empty |schemes| value and
// |include_defaults| set to false will disable all loading and saving of
// cookies for this manager. If |callback| is non-NULL it will be executed
// asnychronously on the UI thread after the change has been applied. Must be
// called before any cookies are accessed.
///
/*--cef(optional_param=callback)--*/
virtual void SetSupportedSchemes(
const std::vector<CefString>& schemes,
bool include_defaults,
CefRefPtr<CefCompletionCallback> callback) = 0;
///
// Visit all cookies on the IO thread. The returned cookies are ordered by
// Visit all cookies on the UI thread. The returned cookies are ordered by
// longest path, then by earliest creation date. Returns false if cookies
// cannot be accessed.
///
@@ -110,7 +88,7 @@ class CefCookieManager : public virtual CefBaseRefCounted {
virtual bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) = 0;
///
// Visit a subset of cookies on the IO thread. The results are filtered by the
// Visit a subset of cookies on the UI thread. The results are filtered by the
// given url scheme, host, domain and path. If |includeHttpOnly| is true
// HTTP-only cookies will also be included in the results. The returned
// cookies are ordered by longest path, then by earliest creation date.
@@ -127,7 +105,7 @@ class CefCookieManager : public virtual CefBaseRefCounted {
// check for disallowed characters (e.g. the ';' character is disallowed
// within the cookie value attribute) and fail without setting the cookie if
// such characters are found. If |callback| is non-NULL it will be executed
// asnychronously on the IO thread after the cookie has been set. Returns
// asnychronously on the UI thread after the cookie has been set. Returns
// false if an invalid URL is specified or if cookies cannot be accessed.
///
/*--cef(optional_param=callback)--*/
@@ -141,7 +119,7 @@ class CefCookieManager : public virtual CefBaseRefCounted {
// both will be deleted. If only |url| is specified all host cookies (but not
// domain cookies) irrespective of path will be deleted. If |url| is empty all
// cookies for all hosts and domains will be deleted. If |callback| is
// non-NULL it will be executed asnychronously on the IO thread after the
// non-NULL it will be executed asnychronously on the UI thread after the
// cookies have been deleted. Returns false if a non-empty invalid URL is
// specified or if cookies cannot be accessed. Cookies can alternately be
// deleted using the Visit*Cookies() methods.
@@ -152,24 +130,9 @@ class CefCookieManager : public virtual CefBaseRefCounted {
const CefString& cookie_name,
CefRefPtr<CefDeleteCookiesCallback> callback) = 0;
///
// Sets the directory path that will be used for storing cookie data. If
// |path| is empty data will be stored in memory only. Otherwise, data will be
// stored at the specified |path|. To persist session cookies (cookies without
// an expiry date or validity interval) set |persist_session_cookies| to true.
// Session cookies are generally intended to be transient and most Web
// browsers do not persist them. If |callback| is non-NULL it will be executed
// asnychronously on the IO thread after the manager's storage has been
// initialized. Returns false if cookies cannot be accessed.
///
/*--cef(optional_param=path,optional_param=callback)--*/
virtual bool SetStoragePath(const CefString& path,
bool persist_session_cookies,
CefRefPtr<CefCompletionCallback> callback) = 0;
///
// Flush the backing store (if any) to disk. If |callback| is non-NULL it will
// be executed asnychronously on the IO thread after the flush is complete.
// be executed asnychronously on the UI thread after the flush is complete.
// Returns false if cookies cannot be accessed.
///
/*--cef(optional_param=callback)--*/
@@ -178,7 +141,7 @@ class CefCookieManager : public virtual CefBaseRefCounted {
///
// Interface to implement for visiting cookie values. The methods of this class
// will always be called on the IO thread.
// will always be called on the UI thread.
///
/*--cef(source=client)--*/
class CefCookieVisitor : public virtual CefBaseRefCounted {
@@ -221,7 +184,7 @@ class CefDeleteCookiesCallback : public virtual CefBaseRefCounted {
public:
///
// Method that will be called upon completion. |num_deleted| will be the
// number of cookies that were deleted or -1 if unknown.
// number of cookies that were deleted.
///
/*--cef()--*/
virtual void OnComplete(int num_deleted) = 0;

View File

@@ -41,6 +41,7 @@
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "include/cef_drag_data.h"
#include "include/cef_frame.h"
///
// Implement this interface to handle events related to dragging. The methods of
@@ -74,6 +75,7 @@ class CefDragHandler : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual void OnDraggableRegionsChanged(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::vector<CefDraggableRegion>& regions) {}
};

View File

@@ -40,11 +40,14 @@
#include "include/cef_base.h"
#include "include/cef_dom.h"
#include "include/cef_process_message.h"
#include "include/cef_request.h"
#include "include/cef_stream.h"
#include "include/cef_string_visitor.h"
class CefBrowser;
class CefURLRequest;
class CefURLRequestClient;
class CefV8Context;
///
@@ -220,6 +223,42 @@ class CefFrame : public virtual CefBaseRefCounted {
///
/*--cef()--*/
virtual void VisitDOM(CefRefPtr<CefDOMVisitor> visitor) = 0;
///
// Create a new URL request that will be treated as originating from this
// frame and the associated browser. This request may be intercepted by the
// client via CefResourceRequestHandler or CefSchemeHandlerFactory. Use
// CefURLRequest::Create instead if you do not want the request to have this
// association, in which case it may be handled differently (see documentation
// on that method). Requests may originate from both the browser process and
// the render process.
//
// For requests originating from the browser process:
// - POST data may only contain a single element of type PDE_TYPE_FILE or
// PDE_TYPE_BYTES.
// For requests originating from the render process:
// - POST data may only contain a single element of type PDE_TYPE_BYTES.
// - If the response contains Content-Disposition or Mime-Type header values
// that would not normally be rendered then the response may receive
// special handling inside the browser (for example, via the file download
// code path instead of the URL request code path).
//
// The |request| object will be marked as read-only after calling this method.
///
/*--cef()--*/
virtual CefRefPtr<CefURLRequest> CreateURLRequest(
CefRefPtr<CefRequest> request,
CefRefPtr<CefURLRequestClient> client) = 0;
///
// Send a message to the specified |target_process|. Message delivery is not
// guaranteed in all cases (for example, if the browser is closing,
// navigating, or if the target process crashes). Send an ACK message back
// from the target process if confirmation is required.
///
/*--cef()--*/
virtual void SendProcessMessage(CefProcessId target_process,
CefRefPtr<CefProcessMessage> message) = 0;
};
#endif // CEF_INCLUDE_CEF_FRAME_H_

View File

@@ -73,7 +73,10 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
// |windowInfo| will be ignored if the parent browser is wrapped in a
// CefBrowserView. Popup browser creation will be canceled if the parent
// browser is destroyed before the popup browser creation completes (indicated
// by a call to OnAfterCreated for the popup browser).
// by a call to OnAfterCreated for the popup browser). The |extra_info|
// parameter provides an opportunity to specify extra information specific
// to the created popup browser that will be passed to
// CefRenderProcessHandler::OnBrowserCreated() in the render process.
///
/*--cef(optional_param=target_url,optional_param=target_frame_name)--*/
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
@@ -86,6 +89,7 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue>& extra_info,
bool* no_javascript_access) {
return false;
}
@@ -191,9 +195,13 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
///
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any methods on the browser
// object after this callback returns. This callback will be the last
// notification that references |browser|. See DoClose() documentation for
// additional usage information.
// object (other than GetIdentifier or IsSame) after this callback returns.
// This callback will be the last notification that references |browser| on
// the UI thread. Any in-progress network requests associated with |browser|
// will be aborted when the browser is destroyed, and
// CefResourceRequestHandler callbacks related to those requests may still
// arrive on the IO thread after this method is called. See DoClose()
// documentation for additional usage information.
///
/*--cef()--*/
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) {}

View File

@@ -57,6 +57,7 @@ class CefRenderHandler : public virtual CefBaseRefCounted {
typedef cef_drag_operations_mask_t DragOperationsMask;
typedef cef_paint_element_type_t PaintElementType;
typedef std::vector<CefRect> RectList;
typedef cef_text_input_mode_t TextInputMode;
///
// Return the handler for accessibility notifications. If no handler is
@@ -231,6 +232,16 @@ class CefRenderHandler : public virtual CefBaseRefCounted {
virtual void OnTextSelectionChanged(CefRefPtr<CefBrowser> browser,
const CefString& selected_text,
const CefRange& selected_range) {}
///
// Called when an on-screen keyboard should be shown or hidden for the
// specified |browser|. |input_mode| specifies what kind of keyboard
// should be opened. If |input_mode| is CEF_TEXT_INPUT_MODE_NONE, any
// existing keyboard for this browser should be hidden.
///
/*--cef()--*/
virtual void OnVirtualKeyboardRequested(CefRefPtr<CefBrowser> browser,
TextInputMode input_mode) {}
};
#endif // CEF_INCLUDE_CEF_RENDER_HANDLER_H_

View File

@@ -52,7 +52,7 @@
// will be called on the render process main thread (TID_RENDERER) unless
// otherwise indicated.
///
/*--cef(source=client)--*/
/*--cef(source=client,no_debugct_check)--*/
class CefRenderProcessHandler : public virtual CefBaseRefCounted {
public:
typedef cef_navigation_type_t NavigationType;
@@ -75,10 +75,13 @@ class CefRenderProcessHandler : public virtual CefBaseRefCounted {
///
// Called after a browser has been created. When browsing cross-origin a new
// browser will be created before the old browser with the same identifier is
// destroyed.
// destroyed. |extra_info| is a read-only value originating from
// CefBrowserHost::CreateBrowser(), CefBrowserHost::CreateBrowserSync(),
// CefLifeSpanHandler::OnBeforePopup() or CefBrowserView::CreateBrowserView().
///
/*--cef()--*/
virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser) {}
virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDictionaryValue> extra_info) {}
///
// Called before a browser is destroyed.
@@ -145,6 +148,7 @@ class CefRenderProcessHandler : public virtual CefBaseRefCounted {
///
/*--cef()--*/
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) {
return false;

View File

@@ -99,7 +99,7 @@ class CefRequest : public virtual CefBaseRefCounted {
// fully qualified with an HTTP or HTTPS scheme component. Any username,
// password or ref component will be removed.
///
/*--cef()--*/
/*--cef(optional_param=referrer_url)--*/
virtual void SetReferrer(const CefString& referrer_url,
ReferrerPolicy policy) = 0;
@@ -140,6 +140,25 @@ class CefRequest : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual void SetHeaderMap(const HeaderMap& headerMap) = 0;
///
// Returns the first header value for |name| or an empty string if not found.
// Will not return the Referer value if any. Use GetHeaderMap instead if
// |name| might have multiple values.
///
/*--cef()--*/
virtual CefString GetHeaderByName(const CefString& name) = 0;
///
// Set the header |name| to |value|. If |overwrite| is true any existing
// values will be replaced with the new value. If |overwrite| is false any
// existing values will not be overwritten. The Referer value cannot be set
// using this method.
///
/*--cef(optional_param=value)--*/
virtual void SetHeaderByName(const CefString& name,
const CefString& value,
bool overwrite) = 0;
///
// Set all values at one time.
///
@@ -174,7 +193,7 @@ class CefRequest : public virtual CefBaseRefCounted {
// Set the URL to the first party for cookies used in combination with
// CefURLRequest.
///
/*--cef()--*/
/*--cef(optional_param=url)--*/
virtual void SetFirstPartyForCookies(const CefString& url) = 0;
///
@@ -194,8 +213,8 @@ class CefRequest : public virtual CefBaseRefCounted {
///
// Returns the globally unique identifier for this request or 0 if not
// specified. Can be used by CefRequestHandler implementations in the browser
// process to track a single request across multiple callbacks.
// specified. Can be used by CefResourceRequestHandler implementations in the
// browser process to track a single request across multiple callbacks.
///
/*--cef()--*/
virtual uint64 GetIdentifier() = 0;

View File

@@ -0,0 +1,63 @@
// Copyright (c) 2011 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_REQUEST_CALLBACK_H_
#define CEF_INCLUDE_CEF_REQUEST_CALLBACK_H_
#pragma once
#include "include/cef_base.h"
///
// Callback interface used for asynchronous continuation of url requests.
///
/*--cef(source=library)--*/
class CefRequestCallback : public virtual CefBaseRefCounted {
public:
///
// Continue the url request. If |allow| is true the request will be continued.
// Otherwise, the request will be canceled.
///
/*--cef(capi_name=cont)--*/
virtual void Continue(bool allow) = 0;
///
// Cancel the url request.
///
/*--cef()--*/
virtual void Cancel() = 0;
};
#endif // CEF_INCLUDE_CEF_REQUEST_CALLBACK_H_

View File

@@ -44,9 +44,9 @@
#include "include/cef_cookie.h"
#include "include/cef_extension.h"
#include "include/cef_extension_handler.h"
#include "include/cef_request_context_handler.h"
#include "include/cef_values.h"
class CefRequestContextHandler;
class CefSchemeHandlerFactory;
///
@@ -144,15 +144,12 @@ class CefRequestContext : public virtual CefBaseRefCounted {
virtual CefString GetCachePath() = 0;
///
// Returns the default cookie manager for this object. This will be the global
// cookie manager if this object is the global request context. Otherwise,
// this will be the default cookie manager used when this request context does
// not receive a value via CefRequestContextHandler::GetCookieManager(). If
// |callback| is non-NULL it will be executed asnychronously on the IO thread
// after the manager's storage has been initialized.
// Returns the cookie manager for this object. If |callback| is non-NULL it
// will be executed asnychronously on the IO thread after the manager's
// storage has been initialized.
///
/*--cef(optional_param=callback)--*/
virtual CefRefPtr<CefCookieManager> GetDefaultCookieManager(
virtual CefRefPtr<CefCookieManager> GetCookieManager(
CefRefPtr<CefCompletionCallback> callback) = 0;
///
@@ -252,6 +249,15 @@ class CefRequestContext : public virtual CefBaseRefCounted {
virtual void ClearCertificateExceptions(
CefRefPtr<CefCompletionCallback> callback) = 0;
///
// Clears all HTTP authentication credentials that were added as part of
// handling GetAuthCredentials. If |callback| is non-NULL it will be executed
// on the UI thread after completion.
///
/*--cef(optional_param=callback)--*/
virtual void ClearHttpAuthCredentials(
CefRefPtr<CefCompletionCallback> callback) = 0;
///
// Clears all active and idle connections that Chromium currently has.
// This is only recommended if you have released all other CEF objects but
@@ -270,17 +276,6 @@ class CefRequestContext : public virtual CefBaseRefCounted {
virtual void ResolveHost(const CefString& origin,
CefRefPtr<CefResolveCallback> callback) = 0;
///
// Attempts to resolve |origin| to a list of associated IP addresses using
// cached data. |resolved_ips| will be populated with the list of resolved IP
// addresses or empty if no cached data is available. Returns ERR_NONE on
// success. This method must be called on the browser process IO thread.
///
/*--cef(default_retval=ERR_FAILED)--*/
virtual cef_errorcode_t ResolveHostCached(
const CefString& origin,
std::vector<CefString>& resolved_ips) = 0;
///
// Load an extension.
//

View File

@@ -39,11 +39,12 @@
#pragma once
#include "include/cef_base.h"
#include "include/cef_cookie.h"
#include "include/cef_browser.h"
#include "include/cef_frame.h"
#include "include/cef_request.h"
#include "include/cef_resource_request_handler.h"
#include "include/cef_web_plugin.h"
class CefRequestContext;
///
// Implement this interface to provide handler implementations. The handler
// instance will not be released until all objects related to the context have
@@ -62,14 +63,6 @@ class CefRequestContextHandler : public virtual CefBaseRefCounted {
virtual void OnRequestContextInitialized(
CefRefPtr<CefRequestContext> request_context) {}
///
// Called on the browser process IO thread to retrieve the cookie manager. If
// this method returns NULL the default cookie manager retrievable via
// CefRequestContext::GetDefaultCookieManager() will be used.
///
/*--cef()--*/
virtual CefRefPtr<CefCookieManager> GetCookieManager() { return NULL; }
///
// Called on multiple browser process threads before a plugin instance is
// loaded. |mime_type| is the mime type of the plugin that will be loaded.
@@ -97,6 +90,37 @@ class CefRequestContextHandler : public virtual CefBaseRefCounted {
PluginPolicy* plugin_policy) {
return false;
}
///
// Called on the browser process IO thread before a resource request is
// initiated. The |browser| and |frame| values represent the source of the
// request, and may be NULL for requests originating from service workers or
// CefURLRequest. |request| represents the request contents and cannot be
// modified in this callback. |is_navigation| will be true if the resource
// request is a navigation. |is_download| will be true if the resource request
// is a download. |request_initiator| is the origin (scheme + domain) of the
// page that initiated the request. Set |disable_default_handling| to true to
// disable default handling of the request, in which case it will need to be
// handled via CefResourceRequestHandler::GetResourceHandler or it will be
// canceled. To allow the resource load to proceed with default handling
// return NULL. To specify a handler for the resource return a
// CefResourceRequestHandler object. This method will not be called if the
// client associated with |browser| returns a non-NULL value from
// CefRequestHandler::GetResourceRequestHandler for the same request
// (identified by CefRequest::GetIdentifier).
///
/*--cef(optional_param=browser,optional_param=frame,
optional_param=request_initiator)--*/
virtual CefRefPtr<CefResourceRequestHandler> GetResourceRequestHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
bool is_navigation,
bool is_download,
const CefString& request_initiator,
bool& disable_default_handling) {
return NULL;
}
};
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_HANDLER_H_

View File

@@ -45,32 +45,11 @@
#include "include/cef_browser.h"
#include "include/cef_frame.h"
#include "include/cef_request.h"
#include "include/cef_resource_handler.h"
#include "include/cef_response.h"
#include "include/cef_response_filter.h"
#include "include/cef_request_callback.h"
#include "include/cef_resource_request_handler.h"
#include "include/cef_ssl_info.h"
#include "include/cef_x509_certificate.h"
///
// Callback interface used for asynchronous continuation of url requests.
///
/*--cef(source=library)--*/
class CefRequestCallback : public virtual CefBaseRefCounted {
public:
///
// Continue the url request. If |allow| is true the request will be continued.
// Otherwise, the request will be canceled.
///
/*--cef(capi_name=cont)--*/
virtual void Continue(bool allow) = 0;
///
// Cancel the url request.
///
/*--cef()--*/
virtual void Cancel() = 0;
};
///
// Callback interface used to select a client certificate for authentication.
///
@@ -92,9 +71,7 @@ class CefSelectClientCertificateCallback : public virtual CefBaseRefCounted {
/*--cef(source=client)--*/
class CefRequestHandler : public virtual CefBaseRefCounted {
public:
typedef cef_return_value_t ReturnValue;
typedef cef_termination_status_t TerminationStatus;
typedef cef_urlrequest_status_t URLRequestStatus;
typedef cef_window_open_disposition_t WindowOpenDisposition;
typedef std::vector<CefRefPtr<CefX509Certificate>> X509CertificateList;
@@ -145,107 +122,47 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
}
///
// Called on the IO thread before a resource request is loaded. The |request|
// object may be modified. Return RV_CONTINUE to continue the request
// immediately. Return RV_CONTINUE_ASYNC and call CefRequestCallback::
// Continue() at a later time to continue or cancel the request
// asynchronously. Return RV_CANCEL to cancel the request immediately.
//
// Called on the browser process IO thread before a resource request is
// initiated. The |browser| and |frame| values represent the source of the
// request. |request| represents the request contents and cannot be modified
// in this callback. |is_navigation| will be true if the resource request is a
// navigation. |is_download| will be true if the resource request is a
// download. |request_initiator| is the origin (scheme + domain) of the page
// that initiated the request. Set |disable_default_handling| to true to
// disable default handling of the request, in which case it will need to be
// handled via CefResourceRequestHandler::GetResourceHandler or it will be
// canceled. To allow the resource load to proceed with default handling
// return NULL. To specify a handler for the resource return a
// CefResourceRequestHandler object. If this callback returns NULL the same
// method will be called on the associated CefRequestContextHandler, if any.
///
/*--cef(default_retval=RV_CONTINUE)--*/
virtual ReturnValue OnBeforeResourceLoad(
/*--cef(optional_param=request_initiator)--*/
virtual CefRefPtr<CefResourceRequestHandler> GetResourceRequestHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefRequestCallback> callback) {
return RV_CONTINUE;
}
///
// Called on the IO thread before a resource is loaded. To allow the resource
// to load normally return NULL. To specify a handler for the resource return
// a CefResourceHandler object. The |request| object should not be modified in
// this callback.
///
/*--cef()--*/
virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {
bool is_navigation,
bool is_download,
const CefString& request_initiator,
bool& disable_default_handling) {
return NULL;
}
///
// Called on the IO thread when a resource load is redirected. The |request|
// parameter will contain the old URL and other request-related information.
// The |response| parameter will contain the response that resulted in the
// redirect. The |new_url| parameter will contain the new URL and can be
// changed if desired. The |request| object cannot be modified in this
// callback.
///
/*--cef()--*/
virtual void OnResourceRedirect(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response,
CefString& new_url) {}
///
// Called on the IO thread when a resource response is received. To allow the
// resource to load normally return false. To redirect or retry the resource
// modify |request| (url, headers or post body) and return true. The
// |response| object cannot be modified in this callback.
///
/*--cef()--*/
virtual bool OnResourceResponse(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response) {
return false;
}
///
// Called on the IO thread to optionally filter resource response content.
// |request| and |response| represent the request and response respectively
// and cannot be modified in this callback.
///
/*--cef()--*/
virtual CefRefPtr<CefResponseFilter> GetResourceResponseFilter(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response) {
return NULL;
}
///
// Called on the IO thread when a resource load has completed. |request| and
// |response| represent the request and response respectively and cannot be
// modified in this callback. |status| indicates the load completion status.
// |received_content_length| is the number of response bytes actually read.
///
/*--cef()--*/
virtual void OnResourceLoadComplete(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response,
URLRequestStatus status,
int64 received_content_length) {}
///
// Called on the IO thread when the browser needs credentials from the user.
// |isProxy| indicates whether the host is a proxy server. |host| contains the
// hostname and |port| contains the port number. |realm| is the realm of the
// challenge and may be empty. |scheme| is the authentication scheme used,
// such as "basic" or "digest", and will be empty if the source of the request
// is an FTP server. Return true to continue the request and call
// |origin_url| is the origin making this authentication request. |isProxy|
// indicates whether the host is a proxy server. |host| contains the hostname
// and |port| contains the port number. |realm| is the realm of the challenge
// and may be empty. |scheme| is the authentication scheme used, such as
// "basic" or "digest", and will be empty if the source of the request is an
// FTP server. Return true to continue the request and call
// CefAuthCallback::Continue() either in this method or at a later time when
// the authentication information is available. Return false to cancel the
// request immediately.
///
/*--cef(optional_param=realm,optional_param=scheme)--*/
virtual bool GetAuthCredentials(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& origin_url,
bool isProxy,
const CefString& host,
int port,
@@ -255,33 +172,6 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
return false;
}
///
// Called on the IO thread before sending a network request with a "Cookie"
// request header. Return true to allow cookies to be included in the network
// request or false to block cookies. The |request| object should not be
// modified in this callback.
///
/*--cef()--*/
virtual bool CanGetCookies(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {
return true;
}
///
// Called on the IO thread when receiving a network request with a
// "Set-Cookie" response header value represented by |cookie|. Return true to
// allow the cookie to be stored or false to block the cookie. The |request|
// object should not be modified in this callback.
///
/*--cef()--*/
virtual bool CanSetCookie(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
const CefCookie& cookie) {
return true;
}
///
// Called on the IO thread when JavaScript requests a specific storage quota
// size via the webkitStorageInfo.requestQuota function. |origin_url| is the
@@ -298,18 +188,6 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
return false;
}
///
// Called on the UI thread to handle requests for URLs with an unknown
// protocol component. Set |allow_os_execution| to true to attempt execution
// via the registered OS protocol handler, if any.
// SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED
// ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
///
/*--cef()--*/
virtual void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
const CefString& url,
bool& allow_os_execution) {}
///
// Called on the UI thread to handle requests for URLs with an invalid
// SSL certificate. Return true and call CefRequestCallback::Continue() either

View File

@@ -45,23 +45,79 @@
#include "include/cef_request.h"
#include "include/cef_response.h"
///
// Callback for asynchronous continuation of CefResourceHandler::Skip().
///
/*--cef(source=library)--*/
class CefResourceSkipCallback : public virtual CefBaseRefCounted {
public:
///
// Callback for asynchronous continuation of Skip(). If |bytes_skipped| > 0
// then either Skip() will be called again until the requested number of
// bytes have been skipped or the request will proceed. If |bytes_skipped|
// <= 0 the request will fail with ERR_REQUEST_RANGE_NOT_SATISFIABLE.
///
/*--cef(capi_name=cont)--*/
virtual void Continue(int64 bytes_skipped) = 0;
};
///
// Callback for asynchronous continuation of CefResourceHandler::Read().
///
/*--cef(source=library)--*/
class CefResourceReadCallback : public virtual CefBaseRefCounted {
public:
///
// Callback for asynchronous continuation of Read(). If |bytes_read| == 0
// the response will be considered complete. If |bytes_read| > 0 then Read()
// will be called again until the request is complete (based on either the
// result or the expected content length). If |bytes_read| < 0 then the
// request will fail and the |bytes_read| value will be treated as the error
// code.
///
/*--cef(capi_name=cont)--*/
virtual void Continue(int bytes_read) = 0;
};
///
// Class used to implement a custom request handler interface. The methods of
// this class will always be called on the IO thread.
// this class will be called on the IO thread unless otherwise indicated.
///
/*--cef(source=client)--*/
class CefResourceHandler : public virtual CefBaseRefCounted {
public:
///
// Open the response stream. To handle the request immediately set
// |handle_request| to true and return true. To decide at a later time set
// |handle_request| to false, return true, and execute |callback| to continue
// or cancel the request. To cancel the request immediately set
// |handle_request| to true and return false. This method will be called in
// sequence but not from a dedicated thread. For backwards compatibility set
// |handle_request| to false and return false and the ProcessRequest method
// will be called.
///
/*--cef()--*/
virtual bool Open(CefRefPtr<CefRequest> request,
bool& handle_request,
CefRefPtr<CefCallback> callback) {
handle_request = false;
return false;
}
///
// Begin processing the request. To handle the request return true and call
// CefCallback::Continue() once the response header information is available
// (CefCallback::Continue() can also be called from inside this method if
// header information is available immediately). To cancel the request return
// false.
//
// WARNING: This method is deprecated. Use Open instead.
///
/*--cef()--*/
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
CefRefPtr<CefCallback> callback) = 0;
CefRefPtr<CefCallback> callback) {
return false;
}
///
// Retrieve response header information. If the response length is not known
@@ -83,33 +139,62 @@ class CefResourceHandler : public virtual CefBaseRefCounted {
int64& response_length,
CefString& redirectUrl) = 0;
///
// Skip response data when requested by a Range header. Skip over and discard
// |bytes_to_skip| bytes of response data. If data is available immediately
// set |bytes_skipped| to the number of bytes skipped and return true. To
// read the data at a later time set |bytes_skipped| to 0, return true and
// execute |callback| when the data is available. To indicate failure set
// |bytes_skipped| to < 0 (e.g. -2 for ERR_FAILED) and return false. This
// method will be called in sequence but not from a dedicated thread.
///
/*--cef()--*/
virtual bool Skip(int64 bytes_to_skip,
int64& bytes_skipped,
CefRefPtr<CefResourceSkipCallback> callback) {
bytes_skipped = -2;
return false;
}
///
// Read response data. If data is available immediately copy up to
// |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of
// bytes copied, and return true. To read the data at a later time keep a
// pointer to |data_out|, set |bytes_read| to 0, return true and execute
// |callback| when the data is available (|data_out| will remain valid until
// the callback is executed). To indicate response completion set |bytes_read|
// to 0 and return false. To indicate failure set |bytes_read| to < 0 (e.g. -2
// for ERR_FAILED) and return false. This method will be called in sequence
// but not from a dedicated thread. For backwards compatibility set
// |bytes_read| to -1 and return false and the ReadResponse method will be
// called.
///
/*--cef()--*/
virtual bool Read(void* data_out,
int bytes_to_read,
int& bytes_read,
CefRefPtr<CefResourceReadCallback> callback) {
bytes_read = -1;
return false;
}
///
// Read response data. If data is available immediately copy up to
// |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of
// bytes copied, and return true. To read the data at a later time set
// |bytes_read| to 0, return true and call CefCallback::Continue() when the
// data is available. To indicate response completion return false.
//
// WARNING: This method is deprecated. Use Skip and Read instead.
///
/*--cef()--*/
virtual bool ReadResponse(void* data_out,
int bytes_to_read,
int& bytes_read,
CefRefPtr<CefCallback> callback) = 0;
///
// Return true if the specified cookie can be sent with the request or false
// otherwise. If false is returned for any cookie then no cookies will be sent
// with the request.
///
/*--cef()--*/
virtual bool CanGetCookie(const CefCookie& cookie) { return true; }
///
// Return true if the specified cookie returned with the response can be set
// or false otherwise.
///
/*--cef()--*/
virtual bool CanSetCookie(const CefCookie& cookie) { return true; }
CefRefPtr<CefCallback> callback) {
bytes_read = -2;
return false;
}
///
// Request processing has been canceled.

View File

@@ -0,0 +1,249 @@
// Copyright (c) 2011 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_RESOURCE_REQUEST_HANDLER_H_
#define CEF_INCLUDE_CEF_RESOURCE_REQUEST_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "include/cef_frame.h"
#include "include/cef_request.h"
#include "include/cef_request_callback.h"
#include "include/cef_resource_handler.h"
#include "include/cef_response.h"
#include "include/cef_response_filter.h"
class CefCookieAccessFilter;
///
// Implement this interface to handle events related to browser requests. The
// methods of this class will be called on the IO thread unless otherwise
// indicated.
///
/*--cef(source=client,no_debugct_check)--*/
class CefResourceRequestHandler : public virtual CefBaseRefCounted {
public:
typedef cef_return_value_t ReturnValue;
typedef cef_urlrequest_status_t URLRequestStatus;
///
// Called on the IO thread before a resource request is loaded. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or CefURLRequest. To optionally
// filter cookies for the request return a CefCookieAccessFilter object. The
// |request| object cannot not be modified in this callback.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual CefRefPtr<CefCookieAccessFilter> GetCookieAccessFilter(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {
return NULL;
}
///
// Called on the IO thread before a resource request is loaded. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or CefURLRequest. To redirect or
// change the resource load optionally modify |request|. Modification of the
// request URL will be treated as a redirect. Return RV_CONTINUE to continue
// the request immediately. Return RV_CONTINUE_ASYNC and call
// CefRequestCallback:: Continue() at a later time to continue or cancel the
// request asynchronously. Return RV_CANCEL to cancel the request immediately.
//
///
/*--cef(optional_param=browser,optional_param=frame,
default_retval=RV_CONTINUE)--*/
virtual ReturnValue OnBeforeResourceLoad(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefRequestCallback> callback) {
return RV_CONTINUE;
}
///
// Called on the IO thread before a resource is loaded. The |browser| and
// |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or CefURLRequest. To allow the
// resource to load using the default network loader return NULL. To specify a
// handler for the resource return a CefResourceHandler object. The |request|
// object cannot not be modified in this callback.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {
return NULL;
}
///
// Called on the IO thread when a resource load is redirected. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or CefURLRequest. The |request|
// parameter will contain the old URL and other request-related information.
// The |response| parameter will contain the response that resulted in the
// redirect. The |new_url| parameter will contain the new URL and can be
// changed if desired. The |request| and |response| objects cannot be modified
// in this callback.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual void OnResourceRedirect(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response,
CefString& new_url) {}
///
// Called on the IO thread when a resource response is received. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or CefURLRequest. To allow the
// resource load to proceed without modification return false. To redirect or
// retry the resource load optionally modify |request| and return true.
// Modification of the request URL will be treated as a redirect. Requests
// handled using the default network loader cannot be redirected in this
// callback. The |response| object cannot be modified in this callback.
//
// WARNING: Redirecting using this method is deprecated. Use
// OnBeforeResourceLoad or GetResourceHandler to perform redirects.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual bool OnResourceResponse(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response) {
return false;
}
///
// Called on the IO thread to optionally filter resource response content. The
// |browser| and |frame| values represent the source of the request, and may
// be NULL for requests originating from service workers or CefURLRequest.
// |request| and |response| represent the request and response respectively
// and cannot be modified in this callback.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual CefRefPtr<CefResponseFilter> GetResourceResponseFilter(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response) {
return NULL;
}
///
// Called on the IO thread when a resource load has completed. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or CefURLRequest. |request| and
// |response| represent the request and response respectively and cannot be
// modified in this callback. |status| indicates the load completion status.
// |received_content_length| is the number of response bytes actually read.
// This method will be called for all requests, including requests that are
// aborted due to CEF shutdown or destruction of the associated browser. In
// cases where the associated browser is destroyed this callback may arrive
// after the CefLifeSpanHandler::OnBeforeClose callback for that browser. The
// CefFrame::IsValid method can be used to test for this situation, and care
// should be taken not to call |browser| or |frame| methods that modify state
// (like LoadURL, SendProcessMessage, etc.) if the frame is invalid.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual void OnResourceLoadComplete(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response,
URLRequestStatus status,
int64 received_content_length) {}
///
// Called on the IO thread to handle requests for URLs with an unknown
// protocol component. The |browser| and |frame| values represent the source
// of the request, and may be NULL for requests originating from service
// workers or CefURLRequest. |request| cannot be modified in this callback.
// Set |allow_os_execution| to true to attempt execution via the registered OS
// protocol handler, if any.
// SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED
// ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
bool& allow_os_execution) {}
};
///
// Implement this interface to filter cookies that may be sent or received from
// resource requests. The methods of this class will be called on the IO thread
// unless otherwise indicated.
///
/*--cef(source=client,no_debugct_check)--*/
class CefCookieAccessFilter : public virtual CefBaseRefCounted {
public:
///
// Called on the IO thread before a resource request is sent. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or CefURLRequest. |request|
// cannot be modified in this callback. Return true if the specified cookie
// can be sent with the request or false otherwise.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual bool CanSendCookie(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
const CefCookie& cookie) {
return true;
}
///
// Called on the IO thread after a resource response is received. The
// |browser| and |frame| values represent the source of the request, and may
// be NULL for requests originating from service workers or CefURLRequest.
// |request| cannot be modified in this callback. Return true if the specified
// cookie returned with the response can be saved or false otherwise.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual bool CanSaveCookie(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response,
const CefCookie& cookie) {
return true;
}
};
#endif // CEF_INCLUDE_CEF_RESOURCE_REQUEST_HANDLER_H_

View File

@@ -96,7 +96,7 @@ class CefResponse : public virtual CefBaseRefCounted {
///
// Set the response status text.
///
/*--cef()--*/
/*--cef(optional_param=statusText)--*/
virtual void SetStatusText(const CefString& statusText) = 0;
///
@@ -108,9 +108,21 @@ class CefResponse : public virtual CefBaseRefCounted {
///
// Set the response mime type.
///
/*--cef()--*/
/*--cef(optional_param=mimeType)--*/
virtual void SetMimeType(const CefString& mimeType) = 0;
///
// Get the response charset.
///
/*--cef()--*/
virtual CefString GetCharset() = 0;
///
// Set the response charset.
///
/*--cef(optional_param=charset)--*/
virtual void SetCharset(const CefString& charset) = 0;
///
// Get the value for the specified response header field.
///
@@ -138,7 +150,7 @@ class CefResponse : public virtual CefBaseRefCounted {
///
// Set the resolved URL after redirects or changed as a result of HSTS.
///
/*--cef()--*/
/*--cef(optional_param=url)--*/
virtual void SetURL(const CefString& url) = 0;
};

View File

@@ -86,76 +86,21 @@ class CefSchemeRegistrar : public CefBaseScoped {
// Register a custom scheme. This method should not be called for the built-in
// HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes.
//
// If |is_standard| is true the scheme will be treated as a standard scheme.
// Standard schemes are subject to URL canonicalization and parsing rules as
// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 available
// at http://www.ietf.org/rfc/rfc1738.txt
//
// In particular, the syntax for standard scheme URLs must be of the form:
// <pre>
// [scheme]://[username]:[password]@[host]:[port]/[url-path]
// </pre>
// Standard scheme URLs must have a host component that is a fully qualified
// domain name as defined in Section 3.5 of RFC 1034 [13] and Section 2.1 of
// RFC 1123. These URLs will be canonicalized to "scheme://host/path" in the
// simplest case and "scheme://username:password@host:port/path" in the most
// explicit case. For example, "scheme:host/path" and "scheme:///host/path"
// will both be canonicalized to "scheme://host/path". The origin of a
// standard scheme URL is the combination of scheme, host and port (i.e.,
// "scheme://host:port" in the most explicit case).
//
// For non-standard scheme URLs only the "scheme:" component is parsed and
// canonicalized. The remainder of the URL will be passed to the handler
// as-is. For example, "scheme:///some%20text" will remain the same.
// Non-standard scheme URLs cannot be used as a target for form submission.
//
// If |is_local| is true the scheme will be treated with the same security
// rules as those applied to "file" URLs. Normal pages cannot link to or
// access local URLs. Also, by default, local URLs can only perform
// XMLHttpRequest calls to the same URL (origin + path) that originated the
// request. To allow XMLHttpRequest calls from a local URL to other URLs with
// the same origin set the CefSettings.file_access_from_file_urls_allowed
// value to true. To allow XMLHttpRequest calls from a local URL to all
// origins set the CefSettings.universal_access_from_file_urls_allowed value
// to true.
//
// If |is_display_isolated| is true the scheme can only be displayed from
// other content hosted with the same scheme. For example, pages in other
// origins cannot create iframes or hyperlinks to URLs with the scheme. For
// schemes that must be accessible from other schemes set this value to false,
// set |is_cors_enabled| to true, and use CORS "Access-Control-Allow-Origin"
// headers to further restrict access.
//
// If |is_secure| is true the scheme will be treated with the same security
// rules as those applied to "https" URLs. For example, loading this scheme
// from other secure schemes will not trigger mixed content warnings.
//
// If |is_cors_enabled| is true the scheme can be sent CORS requests. This
// value should be true in most cases where |is_standard| is true.
//
// If |is_csp_bypassing| is true the scheme can bypass Content-Security-Policy
// (CSP) checks. This value should be false in most cases where |is_standard|
// is true.
// See cef_scheme_options_t for possible values for |options|.
//
// This function may be called on any thread. It should only be called once
// per unique |scheme_name| value. If |scheme_name| is already registered or
// if an error occurs this method will return false.
///
/*--cef()--*/
virtual bool AddCustomScheme(const CefString& scheme_name,
bool is_standard,
bool is_local,
bool is_display_isolated,
bool is_secure,
bool is_cors_enabled,
bool is_csp_bypassing) = 0;
virtual bool AddCustomScheme(const CefString& scheme_name, int options) = 0;
};
///
// Class that creates CefResourceHandler instances for handling scheme requests.
// The methods of this class will always be called on the IO thread.
///
/*--cef(source=client)--*/
/*--cef(source=client,no_debugct_check)--*/
class CefSchemeHandlerFactory : public virtual CefBaseRefCounted {
public:
///
@@ -164,7 +109,7 @@ class CefSchemeHandlerFactory : public virtual CefBaseRefCounted {
// will be the browser window and frame respectively that originated the
// request or NULL if the request did not originate from a browser window
// (for example, if the request came from CefURLRequest). The |request| object
// passed to this method will not contain cookie data.
// passed to this method cannot be modified.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual CefRefPtr<CefResourceHandler> Create(

View File

@@ -49,7 +49,7 @@ typedef cef_thread_id_t CefThreadId;
// the target thread. For this reason be cautious when performing work in the
// task object destructor.
///
/*--cef(source=client)--*/
/*--cef(source=client,no_debugct_check)--*/
class CefTask : public virtual CefBaseRefCounted {
public:
///

View File

@@ -60,19 +60,25 @@ class CefURLRequest : public virtual CefBaseRefCounted {
typedef cef_errorcode_t ErrorCode;
///
// Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request
// methods are supported. Multiple post data elements are not supported and
// elements of type PDE_TYPE_FILE are only supported for requests originating
// from the browser process. Requests originating from the render process will
// receive the same handling as requests originating from Web content -- if
// the response contains Content-Disposition or Mime-Type header values that
// would not normally be rendered then the response may receive special
// handling inside the browser (for example, via the file download code path
// instead of the URL request code path). The |request| object will be marked
// as read-only after calling this method. In the browser process if
// |request_context| is empty the global request context will be used. In the
// render process |request_context| must be empty and the context associated
// with the current renderer process' browser will be used.
// 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
// have this association, in which case it may be handled differently (see
// documentation on that method). Requests may originate from the both browser
// process and the render process.
//
// For requests originating from the browser process:
// - It may be intercepted by the client via CefResourceRequestHandler or
// CefSchemeHandlerFactory.
// - POST data may only contain only a single element of type PDE_TYPE_FILE
// or PDE_TYPE_BYTES.
// - 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.
///
/*--cef(optional_param=request_context)--*/
static CefRefPtr<CefURLRequest> Create(
@@ -180,8 +186,11 @@ class CefURLRequestClient : public virtual CefBaseRefCounted {
// |isProxy| indicates whether the host is a proxy server. |host| contains the
// hostname and |port| contains the port number. Return true to continue the
// request and call CefAuthCallback::Continue() when the authentication
// information is available. Return false to cancel the request. This method
// will only be called for requests initiated from the browser process.
// information is available. If the request has an associated browser/frame
// then returning false will result in a call to GetAuthCredentials on the
// CefRequestHandler associated with that browser, if any. Otherwise,
// returning false will cancel the request immediately. This method will only
// be called for requests initiated from the browser process.
///
/*--cef(optional_param=realm)--*/
virtual bool GetAuthCredentials(bool isProxy,

View File

@@ -120,7 +120,7 @@ bool CefRegisterExtension(const CefString& extension_name,
// A task runner for posting tasks on the associated thread can be retrieved via
// the CefV8Context::GetTaskRunner() method.
///
/*--cef(source=library)--*/
/*--cef(source=library,no_debugct_check)--*/
class CefV8Context : public virtual CefBaseRefCounted {
public:
///
@@ -224,7 +224,7 @@ typedef std::vector<CefRefPtr<CefV8Value>> CefV8ValueList;
// Interface that should be implemented to handle V8 function calls. The methods
// of this class will be called on the thread associated with the V8 function.
///
/*--cef(source=client)--*/
/*--cef(source=client,no_debugct_check)--*/
class CefV8Handler : public virtual CefBaseRefCounted {
public:
///
@@ -247,7 +247,7 @@ class CefV8Handler : public virtual CefBaseRefCounted {
// identifiers are registered by calling CefV8Value::SetValue(). The methods
// of this class will be called on the thread associated with the V8 accessor.
///
/*--cef(source=client)--*/
/*--cef(source=client,no_debugct_check)--*/
class CefV8Accessor : public virtual CefBaseRefCounted {
public:
///
@@ -285,7 +285,7 @@ class CefV8Accessor : public virtual CefBaseRefCounted {
// handlers (with first argument of type int) are called when object is indexed
// by integer.
///
/*--cef(source=client)--*/
/*--cef(source=client,no_debugct_check)--*/
class CefV8Interceptor : public virtual CefBaseRefCounted {
public:
///
@@ -349,7 +349,7 @@ class CefV8Interceptor : public virtual CefBaseRefCounted {
// Class representing a V8 exception. The methods of this class may be called on
// any render process thread.
///
/*--cef(source=library)--*/
/*--cef(source=library,no_debugct_check)--*/
class CefV8Exception : public virtual CefBaseRefCounted {
public:
///
@@ -410,7 +410,7 @@ class CefV8Exception : public virtual CefBaseRefCounted {
///
// Callback interface that is passed to CefV8Value::CreateArrayBuffer.
///
/*--cef(source=client)--*/
/*--cef(source=client,no_debugct_check)--*/
class CefV8ArrayBufferReleaseCallback : public virtual CefBaseRefCounted {
public:
///
@@ -429,7 +429,7 @@ class CefV8ArrayBufferReleaseCallback : public virtual CefBaseRefCounted {
// A task runner for posting tasks on the associated thread can be retrieved via
// the CefV8Context::GetTaskRunner() method.
///
/*--cef(source=library)--*/
/*--cef(source=library,no_debugct_check)--*/
class CefV8Value : public virtual CefBaseRefCounted {
public:
typedef cef_v8_accesscontrol_t AccessControl;
@@ -938,7 +938,7 @@ class CefV8StackTrace : public virtual CefBaseRefCounted {
// threads. A task runner for posting tasks on the associated thread can be
// retrieved via the CefV8Context::GetTaskRunner() method.
///
/*--cef(source=library)--*/
/*--cef(source=library,no_debugct_check)--*/
class CefV8StackFrame : public virtual CefBaseRefCounted {
public:
///

View File

@@ -71,11 +71,16 @@ struct CefWindowInfoTraits {
typedef cef_window_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->window_name);
}
static inline void set(const struct_type* src,
struct_type* target,
bool copy) {
cef_string_set(src->window_name.str, src->window_name.length,
&target->window_name, copy);
target->x = src->x;
target->y = src->y;
target->width = src->width;

View File

@@ -183,6 +183,13 @@ typedef struct _cef_settings_t {
///
cef_string_t framework_dir_path;
///
// 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
// the "main-bundle-path" command-line switch.
///
cef_string_t main_bundle_path;
///
// 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
@@ -219,15 +226,27 @@ typedef struct _cef_settings_t {
int command_line_args_disabled;
///
// The location where cache data will be stored on disk. If empty then
// browsers will be created in "incognito mode" where in-memory caches are
// used for storage and no data is persisted to disk. HTML5 databases such as
// localStorage will only persist across sessions if a cache path is
// specified. Can be overridden for individual CefRequestContext instances via
// the CefRequestContextSettings.cache_path value.
// 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
// CefSettings.root_cache_path. If empty then browsers will be created in
// "incognito mode" where in-memory caches are used for storage and no data is
// persisted to disk. HTML5 databases such as localStorage will only persist
// across sessions if a cache path is specified. Can be overridden for
// individual CefRequestContext instances via the
// CefRequestContextSettings.cache_path value.
///
cef_string_t cache_path;
///
// The root directory that all CefSettings.cache_path and
// CefRequestContextSettings.cache_path values must have in common. If this
// value is empty and CefSettings.cache_path is non-empty then this value will
// default to the CefSettings.cache_path value. Failure to set this value
// correctly may result in the sandbox blocking read/write access to the
// cache_path directory.
///
cef_string_t root_cache_path;
///
// 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
@@ -400,6 +419,14 @@ typedef struct _cef_settings_t {
// CefRequestContextSettings.accept_language_list value.
///
cef_string_t accept_language_list;
///
// GUID string used for identifying the application. This is passed to the
// system AV function for scanning downloaded files. By default, the GUID
// will be an empty string and the file will be treated as an untrusted
// file when the GUID is empty.
///
cef_string_t application_client_id_for_file_scanning;
} cef_settings_t;
///
@@ -413,12 +440,14 @@ typedef struct _cef_request_context_settings_t {
size_t size;
///
// The location where cache data will be stored on disk. If empty then
// browsers will be created in "incognito mode" where in-memory caches are
// used for storage and no data is persisted to disk. HTML5 databases such as
// localStorage will only persist across sessions if a cache path is
// specified. To share the global browser cache and related configuration set
// this value to match the CefSettings.cache_path value.
// 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
// CefSettings.root_cache_path. If empty then browsers will be created in
// "incognito mode" where in-memory caches are used for storage and no data is
// persisted to disk. HTML5 databases such as localStorage will only persist
// across sessions if a cache path is specified. To share the global browser
// cache and related configuration set this value to match the
// CefSettings.cache_path value.
///
cef_string_t cache_path;
@@ -866,66 +895,16 @@ typedef enum {
} cef_storage_type_t;
///
// Supported error code values. See net\base\net_error_list.h for complete
// descriptions of the error codes.
// Supported error code values.
///
typedef enum {
// No error.
ERR_NONE = 0,
ERR_FAILED = -2,
ERR_ABORTED = -3,
ERR_INVALID_ARGUMENT = -4,
ERR_INVALID_HANDLE = -5,
ERR_FILE_NOT_FOUND = -6,
ERR_TIMED_OUT = -7,
ERR_FILE_TOO_BIG = -8,
ERR_UNEXPECTED = -9,
ERR_ACCESS_DENIED = -10,
ERR_NOT_IMPLEMENTED = -11,
ERR_CONNECTION_CLOSED = -100,
ERR_CONNECTION_RESET = -101,
ERR_CONNECTION_REFUSED = -102,
ERR_CONNECTION_ABORTED = -103,
ERR_CONNECTION_FAILED = -104,
ERR_NAME_NOT_RESOLVED = -105,
ERR_INTERNET_DISCONNECTED = -106,
ERR_SSL_PROTOCOL_ERROR = -107,
ERR_ADDRESS_INVALID = -108,
ERR_ADDRESS_UNREACHABLE = -109,
ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110,
ERR_TUNNEL_CONNECTION_FAILED = -111,
ERR_NO_SSL_VERSIONS_ENABLED = -112,
ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113,
ERR_SSL_RENEGOTIATION_REQUESTED = -114,
ERR_CERT_COMMON_NAME_INVALID = -200,
ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID,
ERR_CERT_DATE_INVALID = -201,
ERR_CERT_AUTHORITY_INVALID = -202,
ERR_CERT_CONTAINS_ERRORS = -203,
ERR_CERT_NO_REVOCATION_MECHANISM = -204,
ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205,
ERR_CERT_REVOKED = -206,
ERR_CERT_INVALID = -207,
ERR_CERT_WEAK_SIGNATURE_ALGORITHM = -208,
// -209 is available: was ERR_CERT_NOT_IN_DNS.
ERR_CERT_NON_UNIQUE_NAME = -210,
ERR_CERT_WEAK_KEY = -211,
ERR_CERT_NAME_CONSTRAINT_VIOLATION = -212,
ERR_CERT_VALIDITY_TOO_LONG = -213,
ERR_CERT_END = ERR_CERT_VALIDITY_TOO_LONG,
ERR_INVALID_URL = -300,
ERR_DISALLOWED_URL_SCHEME = -301,
ERR_UNKNOWN_URL_SCHEME = -302,
ERR_TOO_MANY_REDIRECTS = -310,
ERR_UNSAFE_REDIRECT = -311,
ERR_UNSAFE_PORT = -312,
ERR_INVALID_RESPONSE = -320,
ERR_INVALID_CHUNKED_ENCODING = -321,
ERR_METHOD_NOT_SUPPORTED = -322,
ERR_UNEXPECTED_PROXY_AUTH = -323,
ERR_EMPTY_RESPONSE = -324,
ERR_RESPONSE_HEADERS_TOO_BIG = -325,
ERR_CACHE_MISS = -400,
ERR_INSECURE_RESPONSE = -501,
#define NET_ERROR(label, value) ERR_ ## label = value,
#include "include/base/internal/cef_net_error_list.h"
#undef NET_ERROR
} cef_errorcode_t;
///
@@ -994,6 +973,25 @@ typedef enum {
DRAG_OPERATION_EVERY = UINT_MAX
} cef_drag_operations_mask_t;
///
// Input mode of a virtual keyboard. These constants match their equivalents
// in Chromium's text_input_mode.h and should not be renumbered.
// See https://html.spec.whatwg.org/#input-modalities:-the-inputmode-attribute
///
typedef enum {
CEF_TEXT_INPUT_MODE_DEFAULT,
CEF_TEXT_INPUT_MODE_NONE,
CEF_TEXT_INPUT_MODE_TEXT,
CEF_TEXT_INPUT_MODE_TEL,
CEF_TEXT_INPUT_MODE_URL,
CEF_TEXT_INPUT_MODE_EMAIL,
CEF_TEXT_INPUT_MODE_NUMERIC,
CEF_TEXT_INPUT_MODE_DECIMAL,
CEF_TEXT_INPUT_MODE_SEARCH,
CEF_TEXT_INPUT_MODE_MAX = CEF_TEXT_INPUT_MODE_SEARCH,
} cef_text_input_mode_t;
///
// V8 access control values.
///
@@ -1242,38 +1240,47 @@ typedef enum {
// If set the request will fail if it cannot be served from the cache (or some
// equivalent local store). Setting this value is equivalent to specifying the
// "Cache-Control: only-if-cached" request header. Setting this value in
// combination with UR_FLAG_SKIP_CACHE will cause the request to fail.
// combination with UR_FLAG_SKIP_CACHE or UR_FLAG_DISABLE_CACHE will cause the
// request to fail.
///
UR_FLAG_ONLY_FROM_CACHE = 1 << 1,
///
// If set the cache will not be used at all. Setting this value is equivalent
// to specifying the "Cache-Control: no-store" request header. Setting this
// value in combination with UR_FLAG_ONLY_FROM_CACHE will cause the request to
// fail.
///
UR_FLAG_DISABLE_CACHE = 1 << 2,
///
// If set user name, password, and cookies may be sent with the request, and
// cookies may be saved from the response.
///
UR_FLAG_ALLOW_STORED_CREDENTIALS = 1 << 2,
UR_FLAG_ALLOW_STORED_CREDENTIALS = 1 << 3,
///
// If set upload progress events will be generated when a request has a body.
///
UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 << 3,
UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 << 4,
///
// If set the CefURLRequestClient::OnDownloadData method will not be called.
///
UR_FLAG_NO_DOWNLOAD_DATA = 1 << 4,
UR_FLAG_NO_DOWNLOAD_DATA = 1 << 5,
///
// If set 5XX redirect errors will be propagated to the observer instead of
// automatically re-tried. This currently only applies for requests
// originated in the browser process.
///
UR_FLAG_NO_RETRY_ON_5XX = 1 << 5,
UR_FLAG_NO_RETRY_ON_5XX = 1 << 6,
///
// If set 3XX responses will cause the fetch to halt immediately rather than
// continue through the redirect.
///
UR_FLAG_STOP_ON_REDIRECT = 1 << 6,
UR_FLAG_STOP_ON_REDIRECT = 1 << 7,
} cef_urlrequest_flags_t;
///
@@ -1677,6 +1684,90 @@ typedef struct _cef_mouse_event_t {
uint32 modifiers;
} cef_mouse_event_t;
///
// Touch points states types.
///
typedef enum {
CEF_TET_RELEASED = 0,
CEF_TET_PRESSED,
CEF_TET_MOVED,
CEF_TET_CANCELLED
} cef_touch_event_type_t;
///
// The device type that caused the event.
///
typedef enum {
CEF_POINTER_TYPE_TOUCH = 0,
CEF_POINTER_TYPE_MOUSE,
CEF_POINTER_TYPE_PEN,
CEF_POINTER_TYPE_ERASER,
CEF_POINTER_TYPE_UNKNOWN
} cef_pointer_type_t;
///
// Structure representing touch event information.
///
typedef struct _cef_touch_event_t {
///
// Id of a touch point. Must be unique per touch, can be any number except -1.
// Note that a maximum of 16 concurrent touches will be tracked; touches
// beyond that will be ignored.
///
int id;
///
// X coordinate relative to the left side of the view.
///
float x;
///
// Y coordinate relative to the top side of the view.
///
float y;
///
// X radius in pixels. Set to 0 if not applicable.
///
float radius_x;
///
// Y radius in pixels. Set to 0 if not applicable.
///
float radius_y;
///
// Rotation angle in radians. Set to 0 if not applicable.
///
float rotation_angle;
///
// The normalized pressure of the pointer input in the range of [0,1].
// Set to 0 if not applicable.
///
float pressure;
///
// The state of the touch point. Touches begin with one CEF_TET_PRESSED event
// followed by zero or more CEF_TET_MOVED events and finally one
// CEF_TET_RELEASED or CEF_TET_CANCELLED event. Events not respecting this
// order will be ignored.
///
cef_touch_event_type_t type;
///
// Bit flags describing any pressed modifier keys. See
// cef_event_flags_t for values.
///
uint32 modifiers;
///
// The device type that caused the event.
///
cef_pointer_type_t pointer_type;
} cef_touch_event_t;
///
// Paint element types.
///
@@ -2733,7 +2824,7 @@ typedef enum {
SSL_CONNECTION_VERSION_TLS1 = 3,
SSL_CONNECTION_VERSION_TLS1_1 = 4,
SSL_CONNECTION_VERSION_TLS1_2 = 5,
// Reserve 6 for TLS 1.3.
SSL_CONNECTION_VERSION_TLS1_3 = 6,
SSL_CONNECTION_VERSION_QUIC = 7,
} cef_ssl_version_t;
@@ -2745,6 +2836,90 @@ typedef enum {
SSL_CONTENT_RAN_INSECURE_CONTENT = 1 << 1,
} cef_ssl_content_status_t;
//
// Configuration options for registering a custom scheme.
// These values are used when calling AddCustomScheme.
//
typedef enum {
CEF_SCHEME_OPTION_NONE = 0,
///
// If CEF_SCHEME_OPTION_STANDARD is set the scheme will be treated as a
// standard scheme. Standard schemes are subject to URL canonicalization and
// parsing rules as defined in the Common Internet Scheme Syntax RFC 1738
// Section 3.1 available at http://www.ietf.org/rfc/rfc1738.txt
//
// In particular, the syntax for standard scheme URLs must be of the form:
// <pre>
// [scheme]://[username]:[password]@[host]:[port]/[url-path]
// </pre> Standard scheme URLs must have a host component that is a fully
// qualified domain name as defined in Section 3.5 of RFC 1034 [13] and
// Section 2.1 of RFC 1123. These URLs will be canonicalized to
// "scheme://host/path" in the simplest case and
// "scheme://username:password@host:port/path" in the most explicit case. For
// example, "scheme:host/path" and "scheme:///host/path" will both be
// canonicalized to "scheme://host/path". The origin of a standard scheme URL
// is the combination of scheme, host and port (i.e., "scheme://host:port" in
// the most explicit case).
//
// For non-standard scheme URLs only the "scheme:" component is parsed and
// canonicalized. The remainder of the URL will be passed to the handler as-
// is. For example, "scheme:///some%20text" will remain the same. Non-standard
// scheme URLs cannot be used as a target for form submission.
///
CEF_SCHEME_OPTION_STANDARD = 1 << 0,
///
// If CEF_SCHEME_OPTION_LOCAL is set the scheme will be treated with the same
// security rules as those applied to "file" URLs. Normal pages cannot link to
// or access local URLs. Also, by default, local URLs can only perform
// XMLHttpRequest calls to the same URL (origin + path) that originated the
// request. To allow XMLHttpRequest calls from a local URL to other URLs with
// the same origin set the CefSettings.file_access_from_file_urls_allowed
// value to true (1). To allow XMLHttpRequest calls from a local URL to all
// origins set the CefSettings.universal_access_from_file_urls_allowed value
// to true (1).
///
CEF_SCHEME_OPTION_LOCAL = 1 << 1,
///
// If CEF_SCHEME_OPTION_DISPLAY_ISOLATED is set the scheme can only be
// displayed from other content hosted with the same scheme. For example,
// pages in other origins cannot create iframes or hyperlinks to URLs with the
// scheme. For schemes that must be accessible from other schemes don't set
// this, set CEF_SCHEME_OPTION_CORS_ENABLED, and use CORS
// "Access-Control-Allow-Origin" headers to further restrict access.
///
CEF_SCHEME_OPTION_DISPLAY_ISOLATED = 1 << 2,
///
// If CEF_SCHEME_OPTION_SECURE is set the scheme will be treated with the same
// security rules as those applied to "https" URLs. For example, loading this
// scheme from other secure schemes will not trigger mixed content warnings.
///
CEF_SCHEME_OPTION_SECURE = 1 << 3,
///
// If CEF_SCHEME_OPTION_CORS_ENABLED is set the scheme can be sent CORS
// requests. This value should be set in most cases where
// CEF_SCHEME_OPTION_STANDARD is set.
///
CEF_SCHEME_OPTION_CORS_ENABLED = 1 << 4,
///
// If CEF_SCHEME_OPTION_CSP_BYPASSING is set the scheme can bypass Content-
// Security-Policy (CSP) checks. This value should not be set in most cases
// where CEF_SCHEME_OPTION_STANDARD is set.
///
CEF_SCHEME_OPTION_CSP_BYPASSING = 1 << 5,
///
// If CEF_SCHEME_OPTION_FETCH_ENABLED is set the scheme can perform Fetch API
// requests.
///
CEF_SCHEME_OPTION_FETCH_ENABLED = 1 << 6,
} cef_scheme_options_t;
///
// Error codes for CDM registration. See cef_web_plugin.h for details.
///
@@ -2797,6 +2972,117 @@ typedef struct _cef_composition_underline_t {
int thick;
} cef_composition_underline_t;
///
// Enumerates the various representations of the ordering of audio channels.
// Logged to UMA, so never reuse a value, always add new/greater ones!
// 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;
#ifdef __cplusplus
}
#endif

View File

@@ -32,18 +32,27 @@
#pragma once
#include "include/base/cef_build.h"
#include "include/cef_config.h"
#if defined(OS_LINUX)
#if defined(CEF_X11)
typedef union _XEvent XEvent;
typedef struct _XDisplay XDisplay;
#endif
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
// Handle types.
#if defined(CEF_X11)
#define cef_cursor_handle_t unsigned long
#define cef_event_handle_t XEvent*
#else
#define cef_cursor_handle_t void*
#define cef_event_handle_t void*
#endif
#define cef_window_handle_t unsigned long
#define kNullCursorHandle 0
@@ -58,7 +67,9 @@ extern "C" {
// Return the singleton X11 display shared with Chromium. The display is not
// thread-safe and must only be accessed on the browser process UI thread.
///
#if defined(CEF_X11)
CEF_EXPORT XDisplay* cef_get_xdisplay();
#endif
///
// Structure representing CefExecuteProcess arguments.
@@ -72,6 +83,16 @@ typedef struct _cef_main_args_t {
// Class representing window information.
///
typedef struct _cef_window_info_t {
///
// The initial title of the window, to be set when the window is created.
// Some layout managers (e.g., Compiz) can look at the window title
// in order to decide where to place the window when it is
// created. When this attribute is not empty, the window title will
// be set before the window is mapped to the dispay. Otherwise the
// title will be initially empty.
///
cef_string_t window_name;
unsigned int x;
unsigned int y;
unsigned int width;

View File

@@ -37,29 +37,37 @@
#include "include/internal/cef_string.h"
// Handle types.
#ifdef __cplusplus
#ifdef __OBJC__
@class NSCursor;
@class NSEvent;
@class NSView;
#else
class NSCursor;
class NSEvent;
struct NSView;
#endif
#define cef_cursor_handle_t NSCursor*
#define cef_event_handle_t NSEvent*
#define cef_window_handle_t NSView*
#else
// Actually NSCursor*
#define cef_cursor_handle_t void*
// Acutally NSEvent*
#define cef_event_handle_t void*
// Actually NSView*
#define cef_window_handle_t void*
#endif
#define kNullCursorHandle NULL
#define kNullEventHandle NULL
#define kNullWindowHandle NULL
#ifdef __OBJC__
#if __has_feature(objc_arc)
#define CAST_CEF_CURSOR_HANDLE_TO_NSCURSOR(handle) ((__bridge NSCursor*)handle)
#define CAST_CEF_EVENT_HANDLE_TO_NSEVENT(handle) ((__bridge NSEvent*)handle)
#define CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle) ((__bridge NSView*)handle)
#define CAST_NSCURSOR_TO_CEF_CURSOR_HANDLE(cursor) ((__bridge void*)cursor)
#define CAST_NSEVENT_TO_CEF_EVENT_HANDLE(event) ((__bridge void*)event)
#define CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(view) ((__bridge void*)view)
#else // __has_feature(objc_arc)
#define CAST_CEF_CURSOR_HANDLE_TO_NSCURSOR(handle) ((NSCursor*)handle)
#define CAST_CEF_EVENT_HANDLE_TO_NSEVENT(handle) ((NSEvent*)handle)
#define CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle) ((NSView*)handle)
#define CAST_NSCURSOR_TO_CEF_CURSOR_HANDLE(cursor) ((void*)cursor)
#define CAST_NSEVENT_TO_CEF_EVENT_HANDLE(event) ((void*)event)
#define CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(view) ((void*)view)
#endif // __has_feature(objc_arc)
#endif // __OBJC__
#ifdef __cplusplus
extern "C" {
#endif

View File

@@ -481,6 +481,25 @@ struct CefMouseEventTraits {
///
typedef CefStructBase<CefMouseEventTraits> CefMouseEvent;
struct CefTouchEventTraits {
typedef cef_touch_event_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 a touch event.
///
typedef CefStructBase<CefTouchEventTraits> CefTouchEvent;
struct CefPopupFeaturesTraits {
typedef cef_popup_features_t struct_type;
@@ -524,7 +543,9 @@ struct CefSettingsTraits {
static inline void clear(struct_type* s) {
cef_string_clear(&s->browser_subprocess_path);
cef_string_clear(&s->framework_dir_path);
cef_string_clear(&s->main_bundle_path);
cef_string_clear(&s->cache_path);
cef_string_clear(&s->root_cache_path);
cef_string_clear(&s->user_data_path);
cef_string_clear(&s->user_agent);
cef_string_clear(&s->product_version);
@@ -534,6 +555,7 @@ struct CefSettingsTraits {
cef_string_clear(&s->resources_dir_path);
cef_string_clear(&s->locales_dir_path);
cef_string_clear(&s->accept_language_list);
cef_string_clear(&s->application_client_id_for_file_scanning);
}
static inline void set(const struct_type* src,
@@ -545,6 +567,8 @@ struct CefSettingsTraits {
&target->browser_subprocess_path, copy);
cef_string_set(src->framework_dir_path.str, src->framework_dir_path.length,
&target->framework_dir_path, copy);
cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length,
&target->main_bundle_path, copy);
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
target->external_message_pump = src->external_message_pump;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
@@ -552,6 +576,8 @@ struct CefSettingsTraits {
cef_string_set(src->cache_path.str, src->cache_path.length,
&target->cache_path, copy);
cef_string_set(src->root_cache_path.str, src->root_cache_path.length,
&target->root_cache_path, copy);
cef_string_set(src->user_data_path.str, src->user_data_path.length,
&target->user_data_path, copy);
target->persist_session_cookies = src->persist_session_cookies;
@@ -584,6 +610,9 @@ struct CefSettingsTraits {
cef_string_set(src->accept_language_list.str,
src->accept_language_list.length,
&target->accept_language_list, copy);
cef_string_set(src->application_client_id_for_file_scanning.str,
src->application_client_id_for_file_scanning.length,
&target->application_client_id_for_file_scanning, copy);
}
};

View File

@@ -51,14 +51,19 @@ class CefBrowserView : public CefView {
public:
///
// Create a new BrowserView. The underlying CefBrowser will not be created
// until this view is added to the views hierarchy.
// until this view is added to the views hierarchy. The optional |extra_info|
// parameter provides an opportunity to specify extra information specific
// to the created browser that will be passed to
// CefRenderProcessHandler::OnBrowserCreated() in the render process.
///
/*--cef(optional_param=client,optional_param=url,
optional_param=request_context,optional_param=delegate)--*/
optional_param=request_context,optional_param=delegate,
optional_param=extra_info)--*/
static CefRefPtr<CefBrowserView> CreateBrowserView(
CefRefPtr<CefClient> client,
const CefString& url,
const CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue> extra_info,
CefRefPtr<CefRequestContext> request_context,
CefRefPtr<CefBrowserViewDelegate> delegate);

View File

@@ -59,7 +59,7 @@ class CefButtonDelegate : public CefViewDelegate {
// Called when the state of |button| changes.
///
/*--cef()--*/
virtual void OnButtonStateChanged(CefRefPtr<CefButton> button){};
virtual void OnButtonStateChanged(CefRefPtr<CefButton> button) {}
};
#endif // CEF_INCLUDE_VIEWS_CEF_BUTTON_DELEGATE_H_

View File

@@ -54,17 +54,12 @@ class CefLabelButton : public CefButton {
///
// Create a new LabelButton. A |delegate| must be provided to handle the
// button click. |text| will be shown on the LabelButton and used as the
// default accessible name. If |with_frame| is true the button will have a
// visible frame at all times, center alignment, additional padding and a
// default minimum size of 70x33 DIP. If |with_frame| is false the button will
// only have a visible frame on hover/press, left alignment, less padding and
// no default minimum size.
// default accessible name.
///
/*--cef(optional_param=text)--*/
static CefRefPtr<CefLabelButton> CreateLabelButton(
CefRefPtr<CefButtonDelegate> delegate,
const CefString& text,
bool with_frame);
const CefString& text);
///
// Returns this LabelButton as a MenuButton or NULL if this is not a

View File

@@ -63,8 +63,7 @@ class CefMenuButton : public CefLabelButton {
/*--cef(optional_param=text)--*/
static CefRefPtr<CefMenuButton> CreateMenuButton(
CefRefPtr<CefMenuButtonDelegate> delegate,
const CefString& text,
bool with_frame);
const CefString& text);
///
// Show a menu with contents |menu_model|. |screen_point| specifies the menu

View File

@@ -97,8 +97,9 @@ class CefScopedArgArray {
CefScopedArgArray(int argc, char* argv[]) {
// argv should have (argc + 1) elements, the last one always being NULL.
array_ = new char*[argc + 1];
values_.resize(argc);
for (int i = 0; i < argc; ++i) {
values_.push_back(argv[i]);
values_[i] = argv[i];
array_[i] = const_cast<char*>(values_[i].c_str());
}
array_[argc] = NULL;

View File

@@ -360,6 +360,7 @@ class CefMessageRouterBrowserSide
///
virtual bool OnProcessMessageReceived(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) = 0;
@@ -415,6 +416,7 @@ class CefMessageRouterRendererSide
///
virtual bool OnProcessMessageReceived(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) = 0;

View File

@@ -0,0 +1,107 @@
// Copyright (c) 2018 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_mirror_destination.h"
#include "libcef/browser/audio_push_sink.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "media/base/bind_to_current_loop.h"
CefAudioMirrorDestination::CefAudioMirrorDestination(
CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefAudioHandler> cef_audio_handler,
content::AudioMirroringManager* mirroring_manager)
: browser_(browser),
cef_audio_handler_(cef_audio_handler),
mirroring_manager_(mirroring_manager) {
DCHECK(mirroring_manager_);
thread_checker_.DetachFromThread();
}
void CefAudioMirrorDestination::Start() {
DCHECK(thread_checker_.CalledOnValidThread());
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&content::AudioMirroringManager::StartMirroring,
base::Unretained(mirroring_manager_),
base::RetainedRef(this)));
}
void CefAudioMirrorDestination::Stop() {
DCHECK(thread_checker_.CalledOnValidThread());
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&content::AudioMirroringManager::StopMirroring,
base::Unretained(mirroring_manager_),
base::RetainedRef(this)));
}
// Asynchronously query whether this MirroringDestination wants to consume
// audio sourced from each of the |candidates|. |results_callback| is run
// to indicate which of them (or none) should have audio routed to this
// MirroringDestination. The second parameter of |results_callback|
// indicates whether the MirroringDestination wants either: 1) exclusive
// access to a diverted audio flow versus 2) a duplicate copy of the audio
// flow. |results_callback| must be run on the same thread as the one that
// called QueryForMatches().
void CefAudioMirrorDestination::QueryForMatches(
const std::set<content::GlobalFrameRoutingId>& candidates,
MatchesCallback results_callback) {
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&CefAudioMirrorDestination::QueryForMatchesOnUIThread,
base::RetainedRef(this), candidates,
media::BindToCurrentLoop(std::move(results_callback))));
}
void CefAudioMirrorDestination::QueryForMatchesOnUIThread(
const std::set<content::GlobalFrameRoutingId>& candidates,
MatchesCallback results_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
std::set<content::GlobalFrameRoutingId> matches;
for (auto& candidate : candidates) {
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForFrameRoute(candidate.child_id,
candidate.frame_routing_id);
if (browser == browser_) {
matches.insert(candidate);
}
}
std::move(results_callback).Run(matches, true);
}
// Create a consumer of audio data in the format specified by |params|, and
// connect it as an input to mirroring. This is used to provide
// MirroringDestination with exclusive access to pull the audio flow from
// the source. When Close() is called on the returned AudioOutputStream, the
// input is disconnected and the object becomes invalid.
media::AudioOutputStream* CefAudioMirrorDestination::AddInput(
const media::AudioParameters& params) {
// TODO Check and add usage on CEF
return nullptr;
}
// Create a consumer of audio data in the format specified by |params|, and
// connect it as an input to mirroring. This is used to provide
// MirroringDestination with duplicate audio data, which is pushed from the
// main audio flow. When Close() is called on the returned AudioPushSink,
// the input is disconnected and the object becomes invalid.
media::AudioPushSink* CefAudioMirrorDestination::AddPushInput(
const media::AudioParameters& params) {
return new CefAudioPushSink(
params, browser_, cef_audio_handler_,
base::Bind(&CefAudioMirrorDestination::ReleasePushInput,
base::RetainedRef(this)));
}
void CefAudioMirrorDestination::ReleasePushInput(CefAudioPushSink* sink) {
delete sink;
}

View File

@@ -0,0 +1,83 @@
// Copyright (c) 2018 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_MIRROR_DESTINATION_H_
#define CEF_LIBCEF_BROWSER_AUDIO_MIRROR_DESTINATION_H_
#pragma once
#include "include/cef_audio_handler.h"
#include "include/cef_base.h"
#include "libcef/browser/browser_host_impl.h"
#include "base/callback.h"
#include "base/threading/thread_checker.h"
#include "content/browser/media/capture/audio_mirroring_manager.h"
#include "media/audio/audio_io.h"
#include "media/base/audio_converter.h"
#include "media/base/audio_parameters.h"
class CefAudioPushSink;
class CefBrowserHostImpl;
class CefAudioMirrorDestination
: public base::RefCountedThreadSafe<CefAudioMirrorDestination>,
public content::AudioMirroringManager::MirroringDestination {
public:
CefAudioMirrorDestination(CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefAudioHandler> cef_audio_handler,
content::AudioMirroringManager* mirroring_manager);
// Start mirroring. This needs to be triggered on the IO thread.
void Start();
// Stop mirroring. This needs to be triggered on the IO thread.
void Stop();
// Asynchronously query whether this MirroringDestination wants to consume
// audio sourced from each of the |candidates|. |results_callback| is run
// to indicate which of them (or none) should have audio routed to this
// MirroringDestination. The second parameter of |results_callback|
// indicates whether the MirroringDestination wants either: 1) exclusive
// access to a diverted audio flow versus 2) a duplicate copy of the audio
// flow. |results_callback| must be run on the same thread as the one that
// called QueryForMatches().
void QueryForMatches(
const std::set<content::GlobalFrameRoutingId>& candidates,
MatchesCallback results_callback) override;
// Create a consumer of audio data in the format specified by |params|, and
// connect it as an input to mirroring. This is used to provide
// MirroringDestination with exclusive access to pull the audio flow from
// the source. When Close() is called on the returned AudioOutputStream, the
// input is disconnected and the object becomes invalid.
media::AudioOutputStream* AddInput(
const media::AudioParameters& params) override;
// Create a consumer of audio data in the format specified by |params|, and
// connect it as an input to mirroring. This is used to provide
// MirroringDestination with duplicate audio data, which is pushed from the
// main audio flow. When Close() is called on the returned AudioPushSink,
// the input is disconnected and the object becomes invalid.
media::AudioPushSink* AddPushInput(
const media::AudioParameters& params) override;
private:
friend class base::RefCountedThreadSafe<CefAudioMirrorDestination>;
~CefAudioMirrorDestination() override = default;
void QueryForMatchesOnUIThread(
const std::set<content::GlobalFrameRoutingId>& candidates,
MatchesCallback results_callback);
void ReleasePushInput(CefAudioPushSink* sink);
CefRefPtr<CefBrowserHostImpl> browser_;
CefRefPtr<CefAudioHandler> cef_audio_handler_;
content::AudioMirroringManager* mirroring_manager_;
base::ThreadChecker thread_checker_;
};
#endif // CEF_LIBCEF_BROWSER_AUDIO_MIRROR_DESTINATION_H_

View File

@@ -0,0 +1,172 @@
// Copyright (c) 2018 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_push_sink.h"
#include "libcef/browser/thread_util.h"
#include "base/bind.h"
#include "base/logging.h"
#include "media/base/audio_sample_types.h"
#include "media/base/data_buffer.h"
using namespace media;
namespace {
cef_channel_layout_t TranslateChannelLayout(ChannelLayout channel) {
switch (channel) {
case CHANNEL_LAYOUT_UNSUPPORTED:
return CEF_CHANNEL_LAYOUT_UNSUPPORTED;
case CHANNEL_LAYOUT_MONO:
return CEF_CHANNEL_LAYOUT_MONO;
case CHANNEL_LAYOUT_STEREO:
return CEF_CHANNEL_LAYOUT_STEREO;
case CHANNEL_LAYOUT_2_1:
return CEF_CHANNEL_LAYOUT_2_1;
case CHANNEL_LAYOUT_SURROUND:
return CEF_CHANNEL_LAYOUT_SURROUND;
case CHANNEL_LAYOUT_4_0:
return CEF_CHANNEL_LAYOUT_4_0;
case CHANNEL_LAYOUT_2_2:
return CEF_CHANNEL_LAYOUT_2_2;
case CHANNEL_LAYOUT_QUAD:
return CEF_CHANNEL_LAYOUT_QUAD;
case CHANNEL_LAYOUT_5_0:
return CEF_CHANNEL_LAYOUT_5_0;
case CHANNEL_LAYOUT_5_1:
return CEF_CHANNEL_LAYOUT_5_1;
case CHANNEL_LAYOUT_5_0_BACK:
return CEF_CHANNEL_LAYOUT_5_0_BACK;
case CHANNEL_LAYOUT_5_1_BACK:
return CEF_CHANNEL_LAYOUT_5_1_BACK;
case CHANNEL_LAYOUT_7_0:
return CEF_CHANNEL_LAYOUT_7_0;
case CHANNEL_LAYOUT_7_1:
return CEF_CHANNEL_LAYOUT_7_1;
case CHANNEL_LAYOUT_7_1_WIDE:
return CEF_CHANNEL_LAYOUT_7_1_WIDE;
case CHANNEL_LAYOUT_STEREO_DOWNMIX:
return CEF_CHANNEL_LAYOUT_STEREO_DOWNMIX;
case CHANNEL_LAYOUT_2POINT1:
return CEF_CHANNEL_LAYOUT_2POINT1;
case CHANNEL_LAYOUT_3_1:
return CEF_CHANNEL_LAYOUT_3_1;
case CHANNEL_LAYOUT_4_1:
return CEF_CHANNEL_LAYOUT_4_1;
case CHANNEL_LAYOUT_6_0:
return CEF_CHANNEL_LAYOUT_6_0;
case CHANNEL_LAYOUT_6_0_FRONT:
return CEF_CHANNEL_LAYOUT_6_0_FRONT;
case CHANNEL_LAYOUT_HEXAGONAL:
return CEF_CHANNEL_LAYOUT_HEXAGONAL;
case CHANNEL_LAYOUT_6_1:
return CEF_CHANNEL_LAYOUT_6_1;
case CHANNEL_LAYOUT_6_1_BACK:
return CEF_CHANNEL_LAYOUT_6_1_BACK;
case CHANNEL_LAYOUT_6_1_FRONT:
return CEF_CHANNEL_LAYOUT_6_1_FRONT;
case CHANNEL_LAYOUT_7_0_FRONT:
return CEF_CHANNEL_LAYOUT_7_0_FRONT;
case CHANNEL_LAYOUT_7_1_WIDE_BACK:
return CEF_CHANNEL_LAYOUT_7_1_WIDE_BACK;
case CHANNEL_LAYOUT_OCTAGONAL:
return CEF_CHANNEL_LAYOUT_OCTAGONAL;
case CHANNEL_LAYOUT_DISCRETE:
return CEF_CHANNEL_LAYOUT_DISCRETE;
case CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC:
return CEF_CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC;
case CHANNEL_LAYOUT_4_1_QUAD_SIDE:
return CEF_CHANNEL_LAYOUT_4_1_QUAD_SIDE;
case CHANNEL_LAYOUT_BITSTREAM:
return CEF_CHANNEL_LAYOUT_BITSTREAM;
case CHANNEL_LAYOUT_NONE:
return CEF_CHANNEL_LAYOUT_NONE;
}
return CEF_CHANNEL_LAYOUT_NONE;
}
} // namespace
int CefAudioPushSink::audio_stream_id = 0;
CefAudioPushSink::CefAudioPushSink(const AudioParameters& params,
CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefAudioHandler> cef_audio_handler,
const CloseCallback& callback)
: params_(params),
browser_(browser),
cef_audio_handler_(cef_audio_handler),
close_callback_(callback),
stop_stream_(false),
audio_stream_id_(++audio_stream_id) {
// Verify that our enum matches Chromium's values.
static_assert(
static_cast<int>(CEF_CHANNEL_LAYOUT_MAX) ==
static_cast<int>(CHANNEL_LAYOUT_MAX),
"cef_channel_layout_t must match the ChannelLayout enum in Chromium");
DCHECK(params_.IsValid());
DCHECK(browser);
DCHECK(cef_audio_handler);
// VAOS can be constructed on any thread, but will DCHECK that all
// AudioOutputStream methods are called from the same thread.
thread_checker_.DetachFromThread();
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&CefAudioPushSink::InitOnUIThread,
base::Unretained(this)));
}
CefAudioPushSink::~CefAudioPushSink() = default;
void CefAudioPushSink::InitOnUIThread() {
DCHECK(thread_checker_.CalledOnValidThread());
cef_audio_handler_->OnAudioStreamStarted(
browser_.get(), audio_stream_id_, params_.channels(),
TranslateChannelLayout(params_.channel_layout()), params_.sample_rate(),
params_.frames_per_buffer());
}
void CefAudioPushSink::OnData(std::unique_ptr<media::AudioBus> source,
base::TimeTicks reference_time) {
// early exit if stream already stopped
if (stop_stream_)
return;
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefAudioPushSink::OnData,
base::Unretained(this),
std::move(source), reference_time));
return;
}
const int channels = source->channels();
std::vector<const float*> data(channels);
for (int c = 0; c < channels; ++c) {
data[c] = source->channel(c);
}
// Add the packet to the buffer.
base::TimeDelta pts = reference_time - base::TimeTicks::UnixEpoch();
cef_audio_handler_->OnAudioStreamPacket(browser_.get(), audio_stream_id_,
data.data(), source->frames(),
pts.InMilliseconds());
}
void CefAudioPushSink::Close() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefAudioPushSink::Close,
base::Unretained(this)));
return;
}
if (!stop_stream_) {
stop_stream_ = true;
cef_audio_handler_->OnAudioStreamStopped(browser_.get(), audio_stream_id_);
if (!close_callback_.is_null()) {
std::move(close_callback_).Run(this);
}
}
}

View File

@@ -0,0 +1,54 @@
// Copyright (c) 2018 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_PUSH_SINK_H_
#define CEF_LIBCEF_BROWSER_AUDIO_PUSH_SINK_H_
#pragma once
#include "include/cef_audio_handler.h"
#include "include/cef_base.h"
#include "libcef/browser/browser_host_impl.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_checker.h"
#include "media/audio/audio_io.h"
#include "media/base/audio_converter.h"
#include "media/base/audio_parameters.h"
#include "media/base/channel_layout.h"
class CefAudioPushSink : public media::AudioPushSink {
public:
typedef base::Callback<void(CefAudioPushSink* sink)> CloseCallback;
CefAudioPushSink(const media::AudioParameters& params,
CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefAudioHandler> cef_audio_handler,
const CloseCallback& callback);
virtual ~CefAudioPushSink();
void OnData(std::unique_ptr<media::AudioBus> source,
base::TimeTicks reference_time) override;
void Close() override;
private:
void InitOnUIThread();
const media::AudioParameters params_;
CefRefPtr<CefBrowserHostImpl> browser_;
CefRefPtr<CefAudioHandler> cef_audio_handler_;
CloseCallback close_callback_;
base::ThreadChecker thread_checker_;
bool stop_stream_;
int audio_stream_id_;
static int audio_stream_id;
DISALLOW_COPY_AND_ASSIGN(CefAudioPushSink);
};
#endif // CEF_LIBCEF_BROWSER_AUDIO_PUSH_SINK_H_

View File

@@ -1,35 +1,306 @@
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// 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/browser_context.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_util.h"
#include <map>
#include <utility>
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.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/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 "libcef/common/net_service/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/plugins/chrome_plugin_service_filter.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.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_master.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/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"
CefBrowserContext::CefBrowserContext(bool is_proxy)
: is_proxy_(is_proxy), extension_system_(NULL) {}
using content::BrowserThread;
namespace {
// Manages the global list of Impl instances.
class ImplManager {
public:
typedef std::vector<CefBrowserContext*> Vector;
ImplManager() {}
~ImplManager() {
DCHECK(all_.empty());
DCHECK(map_.empty());
}
void AddImpl(CefBrowserContext* impl) {
CEF_REQUIRE_UIT();
DCHECK(!IsValidImpl(impl));
all_.push_back(impl);
}
void RemoveImpl(CefBrowserContext* impl, const base::FilePath& path) {
CEF_REQUIRE_UIT();
Vector::iterator it = GetImplPos(impl);
DCHECK(it != all_.end());
all_.erase(it);
if (!path.empty()) {
PathMap::iterator it = map_.find(path);
DCHECK(it != map_.end());
if (it != map_.end())
map_.erase(it);
}
}
bool IsValidImpl(const CefBrowserContext* impl) {
CEF_REQUIRE_UIT();
return GetImplPos(impl) != all_.end();
}
CefBrowserContext* GetImplForContext(const content::BrowserContext* context) {
CEF_REQUIRE_UIT();
if (!context)
return NULL;
Vector::iterator it = all_.begin();
for (; it != all_.end(); ++it) {
if (*it == context)
return *it;
}
return NULL;
}
void SetImplPath(CefBrowserContext* impl, const base::FilePath& path) {
CEF_REQUIRE_UIT();
DCHECK(!path.empty());
DCHECK(IsValidImpl(impl));
DCHECK(GetImplForPath(path) == NULL);
map_.insert(std::make_pair(path, impl));
}
CefBrowserContext* GetImplForPath(const base::FilePath& path) {
CEF_REQUIRE_UIT();
DCHECK(!path.empty());
PathMap::const_iterator it = map_.find(path);
if (it != map_.end())
return it->second;
return NULL;
}
const Vector GetAllImpl() const { return all_; }
private:
Vector::iterator GetImplPos(const CefBrowserContext* impl) {
Vector::iterator it = all_.begin();
for (; it != all_.end(); ++it) {
if (*it == impl)
return it;
}
return all_.end();
}
typedef std::map<base::FilePath, CefBrowserContext*> PathMap;
PathMap map_;
Vector all_;
DISALLOW_COPY_AND_ASSIGN(ImplManager);
};
#if DCHECK_IS_ON()
// Because of DCHECK()s in the object destructor.
base::LazyInstance<ImplManager>::DestructorAtExit g_manager =
LAZY_INSTANCE_INITIALIZER;
#else
base::LazyInstance<ImplManager>::Leaky g_manager = LAZY_INSTANCE_INITIALIZER;
#endif
} // namespace
// Creates and manages VisitedLinkEventListener objects for each
// CefBrowserContext sharing the same VisitedLinkMaster.
class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::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::VisitedLinkMaster::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)
: settings_(settings) {
g_manager.Get().AddImpl(this);
}
CefBrowserContext::~CefBrowserContext() {
// Should be cleared in Shutdown().
DCHECK(!resource_context_.get());
CEF_REQUIRE_UIT();
// No CefRequestContext should be referencing this object any longer.
DCHECK(request_context_set_.empty());
// Unregister the context first to avoid re-entrancy during shutdown.
g_manager.Get().RemoveImpl(this, cache_path_);
// Send notifications to clean up objects associated with this Profile.
MaybeSendDestroyedNotification();
ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
resource_context_.get());
// 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 URLRequests.
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, NULL);
pref_proxy_config_tracker_->DetachFromPrefService();
if (url_request_getter_)
url_request_getter_->ShutdownOnUIThread();
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(NULL);
}
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(), GetHandler()));
resource_context_.reset(new CefResourceContext(IsOffTheRecord()));
// This must be called before creating any services to avoid hitting
// DependencyManager::AssertContextWasntDestroyed when creating/destroying
@@ -41,15 +312,9 @@ void CefBrowserContext::Initialize() {
if (extensions_enabled) {
// Create the custom ExtensionSystem first because other KeyedServices
// depend on it.
// The same CefExtensionSystem instance is shared by CefBrowserContextImpl
// and CefBrowserContextProxy objects.
extension_system_ = static_cast<extensions::CefExtensionSystem*>(
extensions::ExtensionSystem::Get(this));
if (is_proxy_) {
DCHECK(extension_system_->initialized());
} else {
extension_system_->InitForRegularProfile(true);
}
extension_system_->InitForRegularProfile(true);
resource_context_->set_extensions_info_map(extension_system_->info_map());
// Make sure the ProcessManager is created so that it receives extension
@@ -57,52 +322,81 @@ void CefBrowserContext::Initialize() {
// background/event pages.
extensions::ProcessManager::Get(this);
}
}
void CefBrowserContext::PostInitialize() {
// 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::VisitedLinkMaster(
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::CreateSingleThreadTaskRunnerWithTraits({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);
const bool extensions_enabled = extensions::ExtensionsEnabled();
if (extensions_enabled && !is_proxy_)
if (extensions_enabled)
extension_system_->Init();
ChromePluginServiceFilter::GetInstance()->RegisterResourceContext(
this, resource_context_.get());
if (!net_service::IsEnabled()) {
// Create the CefURLRequestContextGetter via an indirect call to
// CreateRequestContext. Triggers a call to CefURLRequestContextGetter::
// GetURLRequestContext() on the IO thread which creates the
// CefURLRequestContext.
GetRequestContext();
DCHECK(url_request_getter_.get());
}
}
void CefBrowserContext::Shutdown() {
void CefBrowserContext::AddCefRequestContext(CefRequestContextImpl* context) {
CEF_REQUIRE_UIT();
request_context_set_.insert(context);
}
void CefBrowserContext::RemoveCefRequestContext(
CefRequestContextImpl* context) {
CEF_REQUIRE_UIT();
// Send notifications to clean up objects associated with this Profile.
MaybeSendDestroyedNotification();
ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
resource_context_.get());
// Remove any BrowserContextKeyedServiceFactory associations. This must be
// called before the ProxyService owned by CefBrowserContextImpl is destroyed.
BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
this);
if (!is_proxy_) {
// 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 (extensions::ExtensionsEnabled()) {
extension_system()->OnRequestContextDeleted(context);
}
if (resource_context_.get()) {
// Destruction of the ResourceContext will trigger destruction of all
// associated URLRequests.
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
resource_context_.release());
}
request_context_set_.erase(context);
// Delete ourselves when the reference count reaches zero.
if (request_context_set_.empty())
delete this;
}
// static
CefBrowserContext* CefBrowserContext::GetForCachePath(
const base::FilePath& cache_path) {
return g_manager.Get().GetImplForPath(cache_path);
}
// static
CefBrowserContext* CefBrowserContext::GetForContext(
content::BrowserContext* context) {
return g_manager.Get().GetImplForContext(context);
}
// static
std::vector<CefBrowserContext*> CefBrowserContext::GetAll() {
return g_manager.Get().GetAllImpl();
}
content::ResourceContext* CefBrowserContext::GetResourceContext() {
@@ -116,6 +410,7 @@ CefBrowserContext::GetClientHintsControllerDelegate() {
net::URLRequestContextGetter* CefBrowserContext::GetRequestContext() {
CEF_REQUIRE_UIT();
DCHECK(!net_service::IsEnabled());
return GetDefaultStoragePartition(this)->GetURLRequestContext();
}
@@ -150,11 +445,250 @@ CefBrowserContext::GetURLLoaderFactory() {
->GetURLLoaderFactoryForBrowserProcess();
}
void CefBrowserContext::OnRenderFrameDeleted(int render_process_id,
int render_frame_id,
bool is_main_frame,
bool is_guest_view) {
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 NULL;
}
content::PushMessagingService* CefBrowserContext::GetPushMessagingService() {
return NULL;
}
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;
}
net::URLRequestContextGetter* CefBrowserContext::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
CEF_REQUIRE_UIT();
DCHECK(!net_service::IsEnabled());
DCHECK(!url_request_getter_.get());
auto io_thread_runner =
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO});
// Initialize the proxy configuration service.
// TODO(cef): Determine if we can use the Chrome/Mojo implementation from
// https://crrev.com/d0d0d050
std::unique_ptr<net::ProxyConfigService> base_service(
net::ProxyResolutionService::CreateSystemProxyConfigService(
io_thread_runner));
std::unique_ptr<net::ProxyConfigService> proxy_config_service(
pref_proxy_config_tracker_->CreateTrackingProxyConfigService(
std::move(base_service)));
if (extensions::ExtensionsEnabled()) {
// Handle only chrome-extension:// requests. CEF does not support
// chrome-extension-resource:// requests (it does not store shared extension
// data in its installation directory).
extensions::InfoMap* extension_info_map = extension_system()->info_map();
(*protocol_handlers)[extensions::kExtensionScheme] =
extensions::CreateExtensionProtocolHandler(IsOffTheRecord(),
extension_info_map);
}
url_request_getter_ = new CefURLRequestContextGetter(
settings_, GetPrefs(), io_thread_runner, protocol_handlers,
std::move(proxy_config_service), std::move(request_interceptors));
return url_request_getter_.get();
}
net::URLRequestContextGetter*
CefBrowserContext::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
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(
CONTENT_SETTINGS_TYPE_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(
CefRequestContextImpl* request_context,
int render_process_id,
int render_frame_id,
int frame_tree_node_id,
bool is_main_frame,
bool is_guest_view) {
CEF_REQUIRE_UIT();
DCHECK_GE(render_process_id, 0);
DCHECK_GE(render_frame_id, 0);
DCHECK_GE(frame_tree_node_id, 0);
CefRefPtr<CefRequestContextHandler> handler = request_context->GetHandler();
if (handler && resource_context_) {
DCHECK_GE(render_process_id, 0);
// Using base::Unretained() is safe because both this callback and possible
// deletion of |resource_context_| will execute on the IO thread, and this
// callback will be executed first.
CEF_POST_TASK(CEF_IOT, base::Bind(&CefResourceContext::AddHandler,
base::Unretained(resource_context_.get()),
render_process_id, render_frame_id,
frame_tree_node_id, handler));
}
}
void CefBrowserContext::OnRenderFrameDeleted(
CefRequestContextImpl* request_context,
int render_process_id,
int render_frame_id,
int frame_tree_node_id,
bool is_main_frame,
bool is_guest_view) {
CEF_REQUIRE_UIT();
DCHECK_GE(render_process_id, 0);
DCHECK_GE(render_frame_id, 0);
DCHECK_GE(frame_tree_node_id, 0);
CefRefPtr<CefRequestContextHandler> handler = request_context->GetHandler();
if (handler && resource_context_) {
DCHECK_GE(render_process_id, 0);
// Using base::Unretained() is safe because both this callback and possible
// deletion of |resource_context_| will execute on the IO thread, and this
// callback will be executed first.
CEF_POST_TASK(CEF_IOT, base::Bind(&CefResourceContext::RemoveHandler,
base::Unretained(resource_context_.get()),
render_process_id, render_frame_id,
frame_tree_node_id));
}
if (resource_context_ && is_main_frame) {
DCHECK_GE(render_process_id, 0);
// Using base::Unretained() is safe because both this callback and possible
@@ -178,3 +712,35 @@ void CefBrowserContext::OnPurgePluginListCache() {
base::Unretained(resource_context_.get()), -1));
}
}
void CefBrowserContext::RegisterSchemeHandlerFactory(
const std::string& scheme_name,
const std::string& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory) {
if (resource_context_) {
// Using base::Unretained() is safe because both this callback and possible
// deletion of |resource_context_| will execute on the IO thread, and this
// callback will be executed first.
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefResourceContext::RegisterSchemeHandlerFactory,
base::Unretained(resource_context_.get()),
scheme_name, domain_name, factory));
}
}
void CefBrowserContext::ClearSchemeHandlerFactories() {
if (resource_context_) {
// Using base::Unretained() is safe because both this callback and possible
// deletion of |resource_context_| will execute on the IO thread, and this
// callback will be executed first.
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefResourceContext::ClearSchemeHandlerFactories,
base::Unretained(resource_context_.get())));
}
}
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
CEF_REQUIRE_UIT();
DCHECK(net_service::IsEnabled());
return GetDefaultStoragePartition(this)->GetNetworkContext();
}

View File

@@ -1,16 +1,20 @@
// Copyright (c) 2013 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.
// 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_BROWSER_CONTEXT_H_
#define CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_H_
#ifndef CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_IMPL_H_
#define CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_IMPL_H_
#pragma once
#include "include/cef_request_context_handler.h"
#include "libcef/browser/chrome_profile_stub.h"
#include "libcef/browser/net/url_request_context_getter_impl.h"
#include "libcef/browser/net/url_request_context_getter.h"
#include "libcef/browser/resource_context.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "components/proxy_config/pref_proxy_config_tracker.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"
@@ -20,7 +24,7 @@
//
// WC = WebContents
// Content API representation of a browser. Created by BHI or the system (for
// popups) and owned by BHI. Keeps a pointer to BCI/BCP.
// popups) and owned by BHI. Keeps a pointer to BC.
//
// BHI = CefBrowserHostImpl
// Implements the CefBrowser and CefBrowserHost interfaces which are exposed
@@ -29,56 +33,32 @@
//
// RCI = CefRequestContextImpl
// Implements the CefRequestContext interface which is exposed to clients.
// References the isolated BCI or creates a new BCP.
// References the isolated BC.
//
// BCI = CefBrowserContextImpl
// BC = CefBrowserContext
// Entry point from WC when using an isolated RCI. Owns the RC and creates the
// SPI indirectly. Owned by CefBrowserMainParts for the global context or RCI
// for non-global contexts.
//
// BCP = CefBrowserContextProxy
// Entry point from WC when using a custom RCI. Owns the RC and creates the
// URCGP and SPP. Owned by RCI.
//
// SPI = content::StoragePartitionImpl
// Owns storage-related objects like Quota, IndexedDB, Cache, etc. Created by
// StoragePartitionImplMap::Get(). Provides access to the URCGI. Life span is
// controlled indirectly by BCI.
//
// SPP = CefStoragePartitionProxy
// Forwards requests for storage-related objects to SPI. Created by
// GetStoragePartitionFromConfig() calling BCI::GetStoragePartitionProxy().
// Provides access to the URCGP. Life span is controlled by BCP.
// StoragePartitionImplMap::Get(). Provides access to the URCG. Life span is
// controlled indirectly by BC.
//
// RC = CefResourceContext
// Acts as a bridge for resource loading. URLRequest life span is tied to this
// object. Must be destroyed before the associated URCGI/URCGP. Life span is
// controlled by BCI/BCP.
// object. Must be destroyed before the associated URCG. Life span is
// controlled by BC.
//
// URCGI = CefURLRequestContextGetterImpl
// Creates and owns the URCI. Created by StoragePartitionImplMap::Get()
// calling BCI::CreateRequestContext(). Life span is controlled by RC and (for
// URCG = CefURLRequestContextGetter
// Creates and owns the URC. Created by StoragePartitionImplMap::Get()
// calling BC::CreateRequestContext(). Life span is controlled by RC and (for
// the global context) CefBrowserMainParts, and SPI.
//
// URCGP = CefURLRequestContextGetterProxy
// Creates and owns the URCP. Created by GetStoragePartitionFromConfig()
// calling BCI::GetStoragePartitionProxy(). Life span is controlled by RC and
// SPP.
//
// URCI = CefURLRequestContextImpl
// URC = CefURLRequestContext
// Owns various network-related objects including the isolated cookie manager.
// Owns URLRequest objects which must be destroyed first. Life span is
// controlled by URCGI.
//
// URCP = CefURLRequestContextProxy
// Creates the CSP and forwards requests to the objects owned by URCI. Owns
// URLRequest objects which must be destroyed first. Life span is controlled
// by URCGP.
//
// CSP = CefCookieStoreProxy
// Gives the CefCookieManager instance retrieved via CefRequestContextHandler
// an opportunity to handle cookie requests. Otherwise forwards requests via
// URCI to the isolated cookie manager. Life span is controlled by URCP.
// controlled by URCG.
//
//
// Relationship diagram:
@@ -86,17 +66,13 @@
// own = ownership (std::unique_ptr)
// ptr = raw pointer
//
// CefBrowserMainParts----\ isolated cookie manager, etc.
// | \ ^
// own ref ref/own
// v v |
// /---> BCI -own-> SPI -ref-> URCGI --own-> URCI <-ptr-- CSP
// / ^ ^ ^ ^
// ptr ptr ptr ref /
// / | | | /
// BHI -own-> WC -ptr-> BCP -own-> SPP -ref-> URCGP -own-> URCP --ref-/
// CefBrowserMainParts--\ isolated cookie manager, etc.
// | \ ^
// own ref ref/own
// v v |
// BHI -own-> WC -ptr-> BC -own-> SPI -ref-> URCG --own-> URC
//
// BHI -ref-> RCI -own-> BCI/BCP -own-> RC -ref-> URCGI/URCGP
// BHI -ref-> RCI -own-> BC -own-> RC -ref-> URCG
//
//
// How shutdown works:
@@ -104,21 +80,24 @@
// ref release, etc.
// 2. CefRequestContextImpl is destroyed (possibly asynchronously) on the UI
// thread due to CefBrowserHostImpl destruction, ref release, etc.
// 3. CefBrowserContext* is destroyed on the UI thread due to
// CefRequestContextImpl destruction (*Impl, *Proxy) or deletion in
// CefBrowserMainParts::PostMainMessageLoopRun() (*Impl).
// 3. CefBrowserContext is destroyed on the UI thread due to
// CefRequestContextImpl destruction or deletion in
// CefBrowserMainParts::PostMainMessageLoopRun().
// 4. CefResourceContext is destroyed asynchronously on the IO thread due to
// CefBrowserContext* destruction. This cancels/destroys any pending
// CefBrowserContext destruction. This cancels/destroys any pending
// URLRequests.
// 5. CefURLRequestContextGetter* is destroyed asynchronously on the IO thread
// due to CefResourceContext destruction (*Impl, *Proxy) or ref release in
// CefBrowserMainParts::PostMainMessageLoopRun() (*Impl). This may be delayed
// if other network-related objects still have a reference to it.
// 6. CefURLRequestContext* is destroyed on the IO thread due to
// CefURLRequestContextGetter* destruction.
// 5. CefURLRequestContextGetter is destroyed asynchronously on the IO thread
// due to CefResourceContext destruction (or ref release in
// CefBrowserMainParts::PostMainMessageLoopRun. This may be delayed if other
// network-related objects still have a reference to it.
// 6. CefURLRequestContext is destroyed on the IO thread due to
// CefURLRequestContextGetter destruction.
*/
class CefDownloadManagerDelegate;
class CefRequestContextImpl;
class CefSSLHostStateDelegate;
class CefVisitedLinkListener;
class HostContentSettingsMap;
class PrefService;
@@ -126,15 +105,35 @@ namespace extensions {
class CefExtensionSystem;
}
namespace visitedlink {
class VisitedLinkMaster;
}
// 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 {
class CefBrowserContext : public ChromeProfileStub,
public visitedlink::VisitedLinkDelegate {
public:
explicit CefBrowserContext(bool is_proxy);
explicit CefBrowserContext(const CefRequestContextSettings& settings);
// Returns the existing instance, if any, associated with the specified
// |cache_path|.
static CefBrowserContext* GetForCachePath(const base::FilePath& cache_path);
// Returns the underlying CefBrowserContext if any.
static CefBrowserContext* GetForContext(content::BrowserContext* context);
// Returns all existing CefBrowserContext.
static std::vector<CefBrowserContext*> GetAll();
// Must be called immediately after this object is created.
virtual void Initialize();
void Initialize();
// Track associated CefRequestContextImpl objects. This object will delete
// itself when the count reaches zero.
void AddCefRequestContext(CefRequestContextImpl* context);
void RemoveCefRequestContext(CefRequestContextImpl* context);
// BrowserContext methods.
content::ResourceContext* GetResourceContext() override;
@@ -150,37 +149,82 @@ class CefBrowserContext : public ChromeProfileStub {
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) 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::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::PermissionControllerDelegate* GetPermissionControllerDelegate()
override;
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
content::BackgroundSyncController* GetBackgroundSyncController() override;
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()
override;
net::URLRequestContextGetter* CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) 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;
// Returns a RequestContext associated with this object. If this object is a
// *Proxy then it will return the single associated proxy RequestContext. If
// this object is an *Impl then it will return the first non-proxy
// RequestContext, if one exists, otherwise the first proxy RequestContext.
virtual CefRequestContextImpl* GetCefRequestContext() const = 0;
// 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.
virtual const CefRequestContextSettings& GetSettings() const = 0;
// Returns the handler associated with this object. Safe to call from any
// thread.
virtual CefRefPtr<CefRequestContextHandler> GetHandler() const = 0;
const CefRequestContextSettings& GetSettings() const;
// Settings for plugins and extensions.
virtual HostContentSettingsMap* GetHostContentSettingsMap() = 0;
HostContentSettingsMap* GetHostContentSettingsMap();
// Called from CefBrowserHostImpl::DidNavigateAnyFrame to update the table of
// visited links.
virtual void AddVisitedURLs(const std::vector<GURL>& urls) = 0;
void AddVisitedURLs(const std::vector<GURL>& urls);
// Called from CefBrowserHostImpl::RenderFrameDeleted or
// CefMimeHandlerViewGuestDelegate::OnGuestDetached when a render frame is
// deleted.
void OnRenderFrameDeleted(int render_process_id,
// Called from CefRequestContextImpl::OnRenderFrameCreated.
void OnRenderFrameCreated(CefRequestContextImpl* request_context,
int render_process_id,
int render_frame_id,
int frame_tree_node_id,
bool is_main_frame,
bool is_guest_view);
// Called from CefRequestContextImpl::OnRenderFrameDeleted.
void OnRenderFrameDeleted(CefRequestContextImpl* request_context,
int render_process_id,
int render_frame_id,
int frame_tree_node_id,
bool is_main_frame,
bool is_guest_view);
@@ -188,6 +232,22 @@ class CefBrowserContext : public ChromeProfileStub {
// plugin list cache should be purged.
void OnPurgePluginListCache();
// Called from CefRequestContextImpl methods of the same name.
void RegisterSchemeHandlerFactory(const std::string& scheme_name,
const std::string& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory);
void ClearSchemeHandlerFactories();
network::mojom::NetworkContext* GetNetworkContext();
void set_should_persist_session_cookies(bool value) {
should_persist_session_cookies_ = value;
}
void set_cookieable_schemes(
base::Optional<std::vector<std::string>> schemes) {
cookieable_schemes_ = schemes;
}
CefResourceContext* resource_context() const {
return resource_context_.get();
}
@@ -195,27 +255,47 @@ class CefBrowserContext : public ChromeProfileStub {
return extension_system_;
}
bool is_proxy() const { return is_proxy_; }
protected:
~CefBrowserContext() override;
// Must be called after all services have been initialized.
void PostInitialize();
// Must be called before the child object destructor has completed.
void Shutdown();
// Guaranteed to exist once this object has been initialized.
scoped_refptr<CefURLRequestContextGetter> request_context_getter() const {
return url_request_getter_;
}
private:
// True if this CefBrowserContext is a CefBrowserContextProxy.
const bool is_proxy_;
// Allow deletion via std::unique_ptr().
friend std::default_delete<CefBrowserContext>;
~CefBrowserContext() override;
// Members initialized during construction are safe to access from any thread.
CefRequestContextSettings settings_;
base::FilePath cache_path_;
// CefRequestContextImpl objects referencing this object.
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_;
scoped_refptr<CefURLRequestContextGetter> url_request_getter_;
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
std::unique_ptr<visitedlink::VisitedLinkMaster> 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_;
extensions::CefExtensionSystem* extension_system_ = nullptr;
// The key to index KeyedService instances created by
// SimpleKeyedServiceFactory.
std::unique_ptr<ProfileKey> key_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserContext);
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_H_
#endif // CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_IMPL_H_

View File

@@ -1,554 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/browser_context_impl.h"
#include <map>
#include <utility>
#include "libcef/browser/browser_context_proxy.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.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/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 "base/threading/thread_restrictions.h"
#include "chrome/browser/font_family_cache.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/visitedlink/browser/visitedlink_event_listener.h"
#include "components/visitedlink/browser/visitedlink_master.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/storage_partition.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/common/constants.h"
#include "net/proxy_resolution/proxy_config_service.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
using content::BrowserThread;
namespace {
// Manages the global list of Impl instances.
class ImplManager {
public:
typedef std::vector<CefBrowserContextImpl*> Vector;
ImplManager() {}
~ImplManager() {
DCHECK(all_.empty());
DCHECK(map_.empty());
}
void AddImpl(CefBrowserContextImpl* impl) {
CEF_REQUIRE_UIT();
DCHECK(!IsValidImpl(impl));
all_.push_back(impl);
}
void RemoveImpl(CefBrowserContextImpl* impl, const base::FilePath& path) {
CEF_REQUIRE_UIT();
Vector::iterator it = GetImplPos(impl);
DCHECK(it != all_.end());
all_.erase(it);
if (!path.empty()) {
PathMap::iterator it = map_.find(path);
DCHECK(it != map_.end());
if (it != map_.end())
map_.erase(it);
}
}
bool IsValidImpl(const CefBrowserContextImpl* impl) {
CEF_REQUIRE_UIT();
return GetImplPos(impl) != all_.end();
}
CefBrowserContextImpl* GetImplForContext(
const content::BrowserContext* context) {
CEF_REQUIRE_UIT();
if (!context)
return NULL;
const CefBrowserContext* cef_context =
static_cast<const CefBrowserContext*>(context);
const CefBrowserContextImpl* cef_context_impl = nullptr;
if (cef_context->is_proxy()) {
cef_context_impl =
static_cast<const CefBrowserContextProxy*>(cef_context)->parent();
} else {
cef_context_impl = static_cast<const CefBrowserContextImpl*>(cef_context);
}
Vector::iterator it = all_.begin();
for (; it != all_.end(); ++it) {
if (*it == cef_context_impl)
return *it;
}
return NULL;
}
void SetImplPath(CefBrowserContextImpl* impl, const base::FilePath& path) {
CEF_REQUIRE_UIT();
DCHECK(!path.empty());
DCHECK(IsValidImpl(impl));
DCHECK(GetImplForPath(path) == NULL);
map_.insert(std::make_pair(path, impl));
}
CefBrowserContextImpl* GetImplForPath(const base::FilePath& path) {
CEF_REQUIRE_UIT();
DCHECK(!path.empty());
PathMap::const_iterator it = map_.find(path);
if (it != map_.end())
return it->second;
return NULL;
}
const Vector GetAllImpl() const { return all_; }
private:
Vector::iterator GetImplPos(const CefBrowserContextImpl* impl) {
Vector::iterator it = all_.begin();
for (; it != all_.end(); ++it) {
if (*it == impl)
return it;
}
return all_.end();
}
typedef std::map<base::FilePath, CefBrowserContextImpl*> PathMap;
PathMap map_;
Vector all_;
DISALLOW_COPY_AND_ASSIGN(ImplManager);
};
#if DCHECK_IS_ON()
// Because of DCHECK()s in the object destructor.
base::LazyInstance<ImplManager>::DestructorAtExit g_manager =
LAZY_INSTANCE_INITIALIZER;
#else
base::LazyInstance<ImplManager>::Leaky g_manager = LAZY_INSTANCE_INITIALIZER;
#endif
} // namespace
// Creates and manages VisitedLinkEventListener objects for each
// CefBrowserContext sharing the same VisitedLinkMaster.
class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::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::VisitedLinkMaster::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);
};
CefBrowserContextImpl::CefBrowserContextImpl(
const CefRequestContextSettings& settings)
: CefBrowserContext(false), settings_(settings) {
g_manager.Get().AddImpl(this);
}
CefBrowserContextImpl::~CefBrowserContextImpl() {
CEF_REQUIRE_UIT();
// No CefRequestContextImpl should be referencing this object any longer.
DCHECK(request_context_set_.empty());
// Unregister the context first to avoid re-entrancy during shutdown.
g_manager.Get().RemoveImpl(this, cache_path_);
Shutdown();
visitedlink_listener_->RemoveListenerForContext(this);
// The FontFamilyCache references the ProxyService so delete it before the
// ProxyService is deleted.
SetUserData(&kFontFamilyCacheKey, NULL);
pref_proxy_config_tracker_->DetachFromPrefService();
if (url_request_getter_)
url_request_getter_->ShutdownOnUIThread();
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(NULL);
}
void CefBrowserContextImpl::Initialize() {
cache_path_ = base::FilePath(CefString(&settings_.cache_path));
if (!cache_path_.empty()) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (!base::DirectoryExists(cache_path_) &&
!base::CreateDirectory(cache_path_)) {
LOG(ERROR) << "The cache_path directory could not be created: "
<< cache_path_.value();
cache_path_ = base::FilePath();
CefString(&settings_.cache_path).clear();
}
}
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(&CefContext::Get()->settings().accept_language_list);
}
// Initialize the PrefService object.
pref_service_ = browser_prefs::CreatePrefService(
this, cache_path_, !!settings_.persist_user_preferences);
CefBrowserContext::Initialize();
// 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::VisitedLinkMaster(
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::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO})));
CefBrowserContext::PostInitialize();
// Create the CefURLRequestContextGetterImpl via an indirect call to
// CreateRequestContext. Triggers a call to CefURLRequestContextGetterImpl::
// GetURLRequestContext() on the IO thread which creates the
// CefURLRequestContextImpl.
GetRequestContext();
DCHECK(url_request_getter_.get());
// Create the StoragePartitionImplMap and StoragePartitionImpl for this
// object. This must be done before the first WebContents is created using a
// CefBrowserContextProxy of this object, otherwise the StoragePartitionProxy
// will not be created (in that case
// CefBrowserContextProxy::CreateRequestContext will be called, which is
// incorrect).
GetDefaultStoragePartition(this);
}
void CefBrowserContextImpl::AddProxy(const CefBrowserContextProxy* proxy) {
CEF_REQUIRE_UIT();
visitedlink_listener_->CreateListenerForContext(proxy);
}
void CefBrowserContextImpl::RemoveProxy(const CefBrowserContextProxy* proxy) {
CEF_REQUIRE_UIT();
visitedlink_listener_->RemoveListenerForContext(proxy);
}
void CefBrowserContextImpl::AddCefRequestContext(
CefRequestContextImpl* context) {
CEF_REQUIRE_UIT();
request_context_set_.insert(context);
}
void CefBrowserContextImpl::RemoveCefRequestContext(
CefRequestContextImpl* context) {
CEF_REQUIRE_UIT();
if (extensions::ExtensionsEnabled()) {
extension_system()->OnRequestContextDeleted(context);
}
request_context_set_.erase(context);
// Delete ourselves when the reference count reaches zero.
if (request_context_set_.empty())
delete this;
}
CefRequestContextImpl* CefBrowserContextImpl::GetCefRequestContext(
bool impl_only) const {
CEF_REQUIRE_UIT();
// First try to find a non-proxy RequestContext.
for (CefRequestContextImpl* impl : request_context_set_) {
if (!impl->GetHandler())
return impl;
}
if (impl_only)
return nullptr;
return *request_context_set_.begin();
}
// static
CefBrowserContextImpl* CefBrowserContextImpl::GetForCachePath(
const base::FilePath& cache_path) {
return g_manager.Get().GetImplForPath(cache_path);
}
// static
CefBrowserContextImpl* CefBrowserContextImpl::GetForContext(
content::BrowserContext* context) {
return g_manager.Get().GetImplForContext(context);
}
// static
std::vector<CefBrowserContextImpl*> CefBrowserContextImpl::GetAll() {
return g_manager.Get().GetAllImpl();
}
base::FilePath CefBrowserContextImpl::GetPath() const {
return cache_path_;
}
std::unique_ptr<content::ZoomLevelDelegate>
CefBrowserContextImpl::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 CefBrowserContextImpl::IsOffTheRecord() const {
// CEF contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false;
}
content::DownloadManagerDelegate*
CefBrowserContextImpl::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* CefBrowserContextImpl::GetGuestManager() {
DCHECK(extensions::ExtensionsEnabled());
return guest_view::GuestViewManager::FromBrowserContext(this);
}
storage::SpecialStoragePolicy*
CefBrowserContextImpl::GetSpecialStoragePolicy() {
return NULL;
}
content::PushMessagingService*
CefBrowserContextImpl::GetPushMessagingService() {
return NULL;
}
content::SSLHostStateDelegate*
CefBrowserContextImpl::GetSSLHostStateDelegate() {
if (!ssl_host_state_delegate_.get())
ssl_host_state_delegate_.reset(new CefSSLHostStateDelegate());
return ssl_host_state_delegate_.get();
}
content::PermissionControllerDelegate*
CefBrowserContextImpl::GetPermissionControllerDelegate() {
return nullptr;
}
content::BackgroundFetchDelegate*
CefBrowserContextImpl::GetBackgroundFetchDelegate() {
return nullptr;
}
content::BackgroundSyncController*
CefBrowserContextImpl::GetBackgroundSyncController() {
return nullptr;
}
content::BrowsingDataRemoverDelegate*
CefBrowserContextImpl::GetBrowsingDataRemoverDelegate() {
return nullptr;
}
net::URLRequestContextGetter* CefBrowserContextImpl::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
CEF_REQUIRE_UIT();
DCHECK(!url_request_getter_.get());
auto io_thread_runner =
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO});
// Initialize the proxy configuration service.
// TODO(cef): Determine if we can use the Chrome/Mojo implementation from
// https://crrev.com/d0d0d050
std::unique_ptr<net::ProxyConfigService> base_service(
net::ProxyResolutionService::CreateSystemProxyConfigService(
io_thread_runner));
std::unique_ptr<net::ProxyConfigService> proxy_config_service(
pref_proxy_config_tracker_->CreateTrackingProxyConfigService(
std::move(base_service)));
if (extensions::ExtensionsEnabled()) {
// Handle only chrome-extension:// requests. CEF does not support
// chrome-extension-resource:// requests (it does not store shared extension
// data in its installation directory).
extensions::InfoMap* extension_info_map = extension_system()->info_map();
(*protocol_handlers)[extensions::kExtensionScheme] =
extensions::CreateExtensionProtocolHandler(IsOffTheRecord(),
extension_info_map);
}
url_request_getter_ = new CefURLRequestContextGetterImpl(
settings_, GetPrefs(), io_thread_runner, protocol_handlers,
std::move(proxy_config_service), std::move(request_interceptors));
return url_request_getter_.get();
}
net::URLRequestContextGetter*
CefBrowserContextImpl::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
return nullptr;
}
content::StoragePartition* CefBrowserContextImpl::GetStoragePartitionProxy(
content::BrowserContext* browser_context,
content::StoragePartition* partition_impl) {
CefBrowserContextProxy* proxy =
static_cast<CefBrowserContextProxy*>(browser_context);
return proxy->GetOrCreateStoragePartitionProxy(partition_impl);
}
PrefService* CefBrowserContextImpl::GetPrefs() {
return pref_service_.get();
}
const PrefService* CefBrowserContextImpl::GetPrefs() const {
return pref_service_.get();
}
CefRequestContextImpl* CefBrowserContextImpl::GetCefRequestContext() const {
return GetCefRequestContext(false);
}
const CefRequestContextSettings& CefBrowserContextImpl::GetSettings() const {
return settings_;
}
CefRefPtr<CefRequestContextHandler> CefBrowserContextImpl::GetHandler() const {
return NULL;
}
HostContentSettingsMap* CefBrowserContextImpl::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, 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(
CONTENT_SETTINGS_TYPE_PLUGINS, plugin_policy);
}
}
return host_content_settings_map_.get();
}
void CefBrowserContextImpl::AddVisitedURLs(const std::vector<GURL>& urls) {
visitedlink_master_->AddURLs(urls);
}
void CefBrowserContextImpl::RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) {
// Called when visited links will not or cannot be loaded from disk.
enumerator->OnComplete(true);
}

View File

@@ -1,134 +0,0 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_IMPL_H_
#define CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_IMPL_H_
#pragma once
#include "libcef/browser/browser_context.h"
#include "libcef/browser/net/url_request_context_getter_impl.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "components/proxy_config/pref_proxy_config_tracker.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
class CefBrowserContextProxy;
class CefDownloadManagerDelegate;
class CefSSLHostStateDelegate;
class CefVisitedLinkListener;
namespace visitedlink {
class VisitedLinkMaster;
}
// Isolated BrowserContext implementation. Life span is controlled by
// CefBrowserMainParts for the global context and CefRequestContextImpl
// for non-global contexts. Only accessed on the UI thread unless otherwise
// indicated. See browser_context.h for an object relationship diagram.
class CefBrowserContextImpl : public CefBrowserContext,
public visitedlink::VisitedLinkDelegate {
public:
explicit CefBrowserContextImpl(const CefRequestContextSettings& settings);
// Returns the existing instance, if any, associated with the specified
// |cache_path|.
static CefBrowserContextImpl* GetForCachePath(
const base::FilePath& cache_path);
// Returns the underlying CefBrowserContextImpl if any.
static CefBrowserContextImpl* GetForContext(content::BrowserContext* context);
// Returns all existing CefBrowserContextImpl.
static std::vector<CefBrowserContextImpl*> GetAll();
// Must be called immediately after this object is created.
void Initialize() override;
// Track associated CefBrowserContextProxy objects.
void AddProxy(const CefBrowserContextProxy* proxy);
void RemoveProxy(const CefBrowserContextProxy* proxy);
// Track associated CefRequestContextImpl objects. This object will delete
// itself when the count reaches zero.
void AddCefRequestContext(CefRequestContextImpl* context);
void RemoveCefRequestContext(CefRequestContextImpl* context);
CefRequestContextImpl* GetCefRequestContext(bool impl_only) const;
// BrowserContext methods.
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::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::PermissionControllerDelegate* GetPermissionControllerDelegate()
override;
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
content::BackgroundSyncController* GetBackgroundSyncController() override;
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()
override;
net::URLRequestContextGetter* CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
content::StoragePartition* GetStoragePartitionProxy(
content::BrowserContext* browser_context,
content::StoragePartition* partition_impl) override;
// Profile methods.
PrefService* GetPrefs() override;
const PrefService* GetPrefs() const override;
// CefBrowserContext methods.
CefRequestContextImpl* GetCefRequestContext() const override;
const CefRequestContextSettings& GetSettings() const override;
CefRefPtr<CefRequestContextHandler> GetHandler() const override;
HostContentSettingsMap* GetHostContentSettingsMap() override;
void AddVisitedURLs(const std::vector<GURL>& urls) override;
// visitedlink::VisitedLinkDelegate methods.
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
// Guaranteed to exist once this object has been initialized.
scoped_refptr<CefURLRequestContextGetterImpl> request_context_getter() const {
return url_request_getter_;
}
private:
// Allow deletion via std::unique_ptr().
friend std::default_delete<CefBrowserContextImpl>;
~CefBrowserContextImpl() override;
// Members initialized during construction are safe to access from any thread.
CefRequestContextSettings settings_;
base::FilePath cache_path_;
// CefRequestContextImpl objects referencing this object.
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_;
scoped_refptr<CefURLRequestContextGetterImpl> url_request_getter_;
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
std::unique_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
// |visitedlink_listener_| is owned by visitedlink_master_.
CefVisitedLinkListener* visitedlink_listener_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserContextImpl);
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_IMPL_H_

View File

@@ -1,256 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/browser_context_proxy.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/download_manager_delegate.h"
#include "libcef/browser/net/url_request_context_getter_proxy.h"
#include "libcef/browser/storage_partition_proxy.h"
#include "libcef/browser/thread_util.h"
#include "base/logging.h"
#include "chrome/browser/font_family_cache.h"
#include "components/guest_view/common/guest_view_constants.h"
#include "components/visitedlink/browser/visitedlink_master.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/browser/resource_context_impl.h"
#include "content/browser/streams/stream_context.h"
#include "content/browser/webui/url_data_manager.h"
#include "content/public/browser/storage_partition.h"
#include "services/service_manager/public/cpp/service.h"
namespace {
bool ShouldProxyUserData(const void* key) {
// If this value is not proxied then multiple StoragePartitionImpl objects
// will be created and filesystem API access will fail, among other things.
if (key == content::BrowserContext::GetStoragePartitionMapUserDataKey())
return true;
// If these values are not proxied then blob data fails to load for the PDF
// extension.
// See also the call to InitializeResourceContext().
if (key == content::ChromeBlobStorageContext::GetUserDataKey() ||
key == content::StreamContext::GetUserDataKey()) {
return true;
}
// If this value is not proxied then CefBrowserContextImpl::GetGuestManager()
// returns NULL.
// See also CefExtensionsAPIClient::CreateGuestViewManagerDelegate.
if (key == guest_view::kGuestViewManagerKeyName)
return true;
// If this value is not proxied then there will be a use-after-free while
// destroying the FontFamilyCache because it will try to access the
// ProxyService owned by CefBrowserContextImpl (which has already been freed).
if (key == kFontFamilyCacheKey)
return true;
// If this value is not proxied WebUI will fail to load.
if (key == content::URLDataManager::GetUserDataKey())
return true;
return false;
}
} // namespace
CefBrowserContextProxy::CefBrowserContextProxy(
CefRequestContextImpl* const request_context,
CefRefPtr<CefRequestContextHandler> handler,
CefBrowserContextImpl* parent)
: CefBrowserContext(true),
request_context_(request_context),
handler_(handler),
parent_(parent) {
DCHECK(handler_.get());
DCHECK(parent_);
parent_->AddProxy(this);
}
CefBrowserContextProxy::~CefBrowserContextProxy() {
CEF_REQUIRE_UIT();
Shutdown();
parent_->RemoveProxy(this);
}
void CefBrowserContextProxy::Initialize() {
CefBrowserContext::Initialize();
// This object's CefResourceContext needs to proxy some UserData requests to
// the parent object's CefResourceContext.
resource_context()->set_parent(parent_->resource_context());
CefBrowserContext::PostInitialize();
}
base::SupportsUserData::Data* CefBrowserContextProxy::GetUserData(
const void* key) const {
if (ShouldProxyUserData(key))
return parent_->GetUserData(key);
return BrowserContext::GetUserData(key);
}
void CefBrowserContextProxy::SetUserData(const void* key,
std::unique_ptr<Data> data) {
if (ShouldProxyUserData(key))
parent_->SetUserData(key, std::move(data));
else
BrowserContext::SetUserData(key, std::move(data));
}
void CefBrowserContextProxy::RemoveUserData(const void* key) {
if (ShouldProxyUserData(key))
parent_->RemoveUserData(key);
else
BrowserContext::RemoveUserData(key);
}
base::FilePath CefBrowserContextProxy::GetPath() const {
return parent_->GetPath();
}
std::unique_ptr<content::ZoomLevelDelegate>
CefBrowserContextProxy::CreateZoomLevelDelegate(
const base::FilePath& partition_path) {
return parent_->CreateZoomLevelDelegate(partition_path);
}
bool CefBrowserContextProxy::IsOffTheRecord() const {
return parent_->IsOffTheRecord();
}
content::DownloadManagerDelegate*
CefBrowserContextProxy::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* CefBrowserContextProxy::GetGuestManager() {
return parent_->GetGuestManager();
}
storage::SpecialStoragePolicy*
CefBrowserContextProxy::GetSpecialStoragePolicy() {
return parent_->GetSpecialStoragePolicy();
}
content::PushMessagingService*
CefBrowserContextProxy::GetPushMessagingService() {
return parent_->GetPushMessagingService();
}
content::SSLHostStateDelegate*
CefBrowserContextProxy::GetSSLHostStateDelegate() {
return parent_->GetSSLHostStateDelegate();
}
content::ClientHintsControllerDelegate*
CefBrowserContextProxy::GetClientHintsControllerDelegate() {
return parent_->GetClientHintsControllerDelegate();
}
content::PermissionControllerDelegate*
CefBrowserContextProxy::GetPermissionControllerDelegate() {
return parent_->GetPermissionControllerDelegate();
}
content::BackgroundFetchDelegate*
CefBrowserContextProxy::GetBackgroundFetchDelegate() {
return parent_->GetBackgroundFetchDelegate();
}
content::BackgroundSyncController*
CefBrowserContextProxy::GetBackgroundSyncController() {
return parent_->GetBackgroundSyncController();
}
content::BrowsingDataRemoverDelegate*
CefBrowserContextProxy::GetBrowsingDataRemoverDelegate() {
return parent_->GetBrowsingDataRemoverDelegate();
}
net::URLRequestContextGetter* CefBrowserContextProxy::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
// CefBrowserContextImpl::GetOrCreateStoragePartitionProxy is called instead
// of this method.
NOTREACHED();
return nullptr;
}
net::URLRequestContextGetter*
CefBrowserContextProxy::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
return nullptr;
}
std::unique_ptr<service_manager::Service>
CefBrowserContextProxy::HandleServiceRequest(
const std::string& service_name,
service_manager::mojom::ServiceRequest request) {
return parent_->HandleServiceRequest(service_name, std::move(request));
}
PrefService* CefBrowserContextProxy::GetPrefs() {
return parent_->GetPrefs();
}
const PrefService* CefBrowserContextProxy::GetPrefs() const {
return parent_->GetPrefs();
}
CefRequestContextImpl* CefBrowserContextProxy::GetCefRequestContext() const {
return request_context_;
}
const CefRequestContextSettings& CefBrowserContextProxy::GetSettings() const {
return parent_->GetSettings();
}
CefRefPtr<CefRequestContextHandler> CefBrowserContextProxy::GetHandler() const {
return handler_;
}
HostContentSettingsMap* CefBrowserContextProxy::GetHostContentSettingsMap() {
return parent_->GetHostContentSettingsMap();
}
void CefBrowserContextProxy::AddVisitedURLs(const std::vector<GURL>& urls) {
parent_->AddVisitedURLs(urls);
}
content::StoragePartition*
CefBrowserContextProxy::GetOrCreateStoragePartitionProxy(
content::StoragePartition* partition_impl) {
CEF_REQUIRE_UIT();
if (!storage_partition_proxy_) {
scoped_refptr<CefURLRequestContextGetterProxy> url_request_getter =
new CefURLRequestContextGetterProxy(handler_,
parent_->request_context_getter());
storage_partition_proxy_.reset(
new CefStoragePartitionProxy(partition_impl, url_request_getter.get()));
// Associates UserData keys with the ResourceContext.
// Called from StoragePartitionImplMap::Get() for CefBrowserContextImpl.
content::InitializeResourceContext(this);
}
// There should only be one CefStoragePartitionProxy for this
// CefBrowserContextProxy.
DCHECK_EQ(storage_partition_proxy_->parent(), partition_impl);
return storage_partition_proxy_.get();
}

View File

@@ -1,100 +0,0 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_PROXY_H_
#define CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_PROXY_H_
#pragma once
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_context_impl.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
class CefDownloadManagerDelegate;
class CefStoragePartitionProxy;
// BrowserContext implementation for a particular CefRequestContext. Life span
// is controlled by CefRequestContextImpl. Only accessed on the UI thread. See
// browser_context.h for an object relationship diagram.
class CefBrowserContextProxy : public CefBrowserContext {
public:
CefBrowserContextProxy(CefRequestContextImpl* const request_context,
CefRefPtr<CefRequestContextHandler> handler,
CefBrowserContextImpl* parent);
// Must be called immediately after this object is created.
void Initialize() override;
// SupportsUserData methods.
Data* GetUserData(const void* key) const override;
void SetUserData(const void* key, std::unique_ptr<Data> data) override;
void RemoveUserData(const void* key) override;
// BrowserContext methods.
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::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
content::PermissionControllerDelegate* GetPermissionControllerDelegate()
override;
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
content::BackgroundSyncController* GetBackgroundSyncController() override;
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()
override;
net::URLRequestContextGetter* CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
std::unique_ptr<service_manager::Service> HandleServiceRequest(
const std::string& service_name,
service_manager::mojom::ServiceRequest request) override;
// Profile methods.
PrefService* GetPrefs() override;
const PrefService* GetPrefs() const override;
// CefBrowserContext methods.
CefRequestContextImpl* GetCefRequestContext() const override;
const CefRequestContextSettings& GetSettings() const override;
CefRefPtr<CefRequestContextHandler> GetHandler() const override;
HostContentSettingsMap* GetHostContentSettingsMap() override;
void AddVisitedURLs(const std::vector<GURL>& urls) override;
content::StoragePartition* GetOrCreateStoragePartitionProxy(
content::StoragePartition* partition_impl);
CefBrowserContextImpl* parent() const { return parent_; }
private:
// Allow deletion via std::unique_ptr() only.
friend std::default_delete<CefBrowserContextProxy>;
~CefBrowserContextProxy() override;
// Guaranteed to outlive this object.
CefRequestContextImpl* const request_context_;
// Members initialized during construction are safe to access from any thread.
CefRefPtr<CefRequestContextHandler> handler_;
CefBrowserContextImpl* parent_; // Guaranteed to outlive this object.
std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<CefStoragePartitionProxy> storage_partition_proxy_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserContextProxy);
};
#endif // CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_PROXY_H_

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,6 @@
#pragma once
#include <map>
#include <queue>
#include <string>
#include <vector>
@@ -16,12 +15,13 @@
#include "include/cef_client.h"
#include "include/cef_frame.h"
#include "include/views/cef_browser_view.h"
#include "libcef/browser/audio_mirror_destination.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/file_dialog_manager.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/javascript_dialog_manager.h"
#include "libcef/browser/menu_manager.h"
#include "libcef/common/response_manager.h"
#include "libcef/browser/request_context_impl.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
@@ -43,23 +43,16 @@ class Extension;
class ExtensionHost;
} // namespace extensions
namespace net {
class URLRequest;
}
#if defined(USE_AURA)
namespace views {
class Widget;
}
#endif // defined(USE_AURA)
struct Cef_DraggableRegion_Params;
struct Cef_Request_Params;
struct Cef_Response_Params;
class CefAudioMirrorDestination;
class CefBrowserInfo;
class CefBrowserPlatformDelegate;
class CefDevToolsFrontend;
struct CefNavigateParams;
class SiteInstance;
// Implementation of CefBrowser.
@@ -132,6 +125,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
// request context will be used.
CefRefPtr<CefRequestContext> request_context;
CefRefPtr<CefDictionaryValue> extra_info;
// Used when explicitly creating the browser as an extension host via
// ProcessManager::CreateBackgroundHost.
const extensions::Extension* extension = nullptr;
@@ -150,14 +145,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Returns the browser associated with the specified WebContents.
static CefRefPtr<CefBrowserHostImpl> GetBrowserForContents(
const content::WebContents* contents);
// Returns the browser associated with the specified URLRequest.
static CefRefPtr<CefBrowserHostImpl> GetBrowserForRequest(
const net::URLRequest* request);
// Returns the browser associated with the specified FrameTreeNode.
// Returns the browser associated with the specified FrameTreeNode ID.
static CefRefPtr<CefBrowserHostImpl> GetBrowserForFrameTreeNode(
int frame_tree_node_id);
// Returns the browser associated with the specified frame routing IDs.
static CefRefPtr<CefBrowserHostImpl> GetBrowserForFrame(
static CefRefPtr<CefBrowserHostImpl> GetBrowserForFrameRoute(
int render_process_id,
int render_routing_id);
@@ -222,6 +214,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
void SendMouseWheelEvent(const CefMouseEvent& event,
int deltaX,
int deltaY) override;
void SendTouchEvent(const CefTouchEvent& event) override;
void SendFocusEvent(bool setFocus) override;
void SendCaptureLostEvent() override;
void NotifyMoveOrResizeStarted() override;
@@ -245,6 +238,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
void DragTargetDrop(const CefMouseEvent& event) override;
void DragSourceSystemDragEnded() override;
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
void SetAudioMuted(bool mute) override;
bool IsAudioMuted() override;
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
void SetAccessibilityState(cef_state_t accessibility_state) override;
void SetAutoResizeEnabled(bool enabled,
@@ -274,8 +269,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
size_t GetFrameCount() override;
void GetFrameIdentifiers(std::vector<int64>& identifiers) override;
void GetFrameNames(std::vector<CefString>& names) override;
bool SendProcessMessage(CefProcessId target_process,
CefRefPtr<CefProcessMessage> message) override;
// Returns true if windowless rendering is enabled.
bool IsWindowless() const;
@@ -303,49 +296,27 @@ class CefBrowserHostImpl : public CefBrowserHost,
CefRefPtr<CefBrowserView> GetBrowserView() const;
#endif
// Returns the frame associated with the specified URLRequest.
CefRefPtr<CefFrame> GetFrameForRequest(const net::URLRequest* request);
// Returns the frame associated with the specified RenderFrameHost.
CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host);
// Navigate as specified by the |params| argument.
void Navigate(const CefNavigateParams& params);
// Returns the frame associated with the specified FrameTreeNode ID.
CefRefPtr<CefFrame> GetFrameForFrameTreeNode(int frame_tree_node_id);
// Load the specified request.
void LoadRequest(int64 frame_id, CefRefPtr<CefRequest> request);
// Load the specified URL in the main frame.
void LoadMainFrameURL(const std::string& url,
const content::Referrer& referrer,
ui::PageTransition transition,
const std::string& extra_headers);
// Load the specified URL.
void LoadURL(int64 frame_id,
const std::string& url,
const content::Referrer& referrer,
ui::PageTransition transition,
const std::string& extra_headers);
// Load the specified string.
void LoadString(int64 frame_id,
const std::string& string,
const std::string& url);
// Send a command to the renderer for execution.
void SendCommand(int64 frame_id,
const std::string& command,
CefRefPtr<CefResponseManager::Handler> responseHandler);
// Send code to the renderer for execution.
void SendCode(int64 frame_id,
bool is_javascript,
const std::string& code,
const std::string& script_url,
int script_start_line,
CefRefPtr<CefResponseManager::Handler> responseHandler);
void ExecuteJavaScriptWithUserGestureForTests(int64 frame_id,
const CefString& javascript);
// Called from CefFrameHostImpl.
void OnFrameFocused(CefRefPtr<CefFrameHostImpl> frame);
void OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
const GURL& validated_url,
int http_status_code);
// Open the specified text in the default text editor.
void ViewText(const std::string& text);
// Handler for URLs involving external protocols.
void HandleExternalProtocol(const GURL& url);
// Convert from view coordinates to screen coordinates. Potential display
// scaling will be applied to the result.
gfx::Point GetScreenPoint(const gfx::Point& view) const;
@@ -364,6 +335,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
CefRefPtr<CefClient> client() const { return client_; }
scoped_refptr<CefBrowserInfo> browser_info() const { return browser_info_; }
int browser_id() const;
CefRefPtr<CefRequestContextImpl> request_context() const {
return request_context_;
}
// Accessors that must be called on the UI thread.
content::BrowserContext* GetBrowserContext();
@@ -413,7 +387,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
void CloseContents(content::WebContents* source) override;
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
bool DidAddMessageToConsole(content::WebContents* source,
int32_t level,
blink::mojom::ConsoleMessageLevel log_level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
@@ -421,7 +395,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool proceed,
bool* proceed_to_fire_unload) override;
bool TakeFocus(content::WebContents* source, bool reverse) override;
bool HandleContextMenu(const content::ContextMenuParams& params) override;
bool HandleContextMenu(content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params) override;
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
@@ -487,7 +463,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
content::RenderFrameHost* new_host) override;
void FrameDeleted(content::RenderFrameHost* render_frame_host) override;
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
void RenderViewReady() override;
@@ -524,6 +500,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
void RemoveObserver(Observer* observer);
bool HasObserver(Observer* observer) const;
bool StartAudioMirroring();
bool StopAudioMirroring();
class NavigationLock final {
private:
friend class CefBrowserHostImpl;
@@ -549,25 +528,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<CefBrowserHostImpl> opener,
bool is_devtools_popup,
CefRefPtr<CefRequestContext> request_context,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension);
// content::WebContentsObserver::OnMessageReceived() message handlers.
void OnFrameIdentified(int64 frame_id,
int64 parent_frame_id,
base::string16 name);
void OnFrameFocused(content::RenderFrameHost* render_frame_host);
void OnDidFinishLoad(int64 frame_id,
const GURL& validated_url,
bool is_main_frame,
int http_status_code);
void OnUpdateDraggableRegions(
const std::vector<Cef_DraggableRegion_Params>& regions);
void OnRequest(const Cef_Request_Params& params);
void OnResponse(const Cef_Response_Params& params);
void OnResponseAck(int request_id);
// content::NotificationObserver methods.
void Observe(int type,
const content::NotificationSource& source,
@@ -579,7 +543,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::WebContents* web_contents,
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<CefBrowserHostImpl> opener,
CefRefPtr<CefRequestContext> request_context,
CefRefPtr<CefRequestContextImpl> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension);
@@ -602,42 +566,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Action to be executed once the navigation lock is released.
void set_pending_navigation_action(base::OnceClosure action);
// Update or create a frame object. |frame_id| (renderer routing id) will be
// >= 0 if the frame currently exists in the renderer process. |frame_id| will
// be < 0 for the main frame if it has not yet navigated for the first time,
// or for sub-frames if PlzNavigate is enabled and the sub-frame does not yet
// have a renderer process representation. |frame_tree_node_id| will be
// kUnspecifiedFrameTreeNodeId for calls that originate from the renderer
// process (meaning that |frame_id| should be >= 0); kUnusedFrameTreeNodeId
// if PlzNavigate is disabled; or >= 0 otherwise. |parent_frame_id| will be
// CefFrameHostImpl::kUnspecifiedFrameId if unknown. In cases where |frame_id|
// is < 0 either the existing main frame object or a pending object will be
// returned depending on current state. If |is_main_frame_state_flaky| is true
// then the value of |is_main_frame| cannot be relied on.
CefRefPtr<CefFrame> GetOrCreateFrame(int64 frame_id,
int frame_tree_node_id,
int64 parent_frame_id,
bool is_main_frame,
bool is_main_frame_state_flaky,
base::string16 frame_name,
const GURL& frame_url);
// Returns a pending frame object. If the main frame has not yet navigated for
// the first time then |frame_tree_node_id| will be kMainFrameTreeNodeId and a
// single pending object will be returned. Otherwise, this method will be
// called with a |frame_tree_node_id| value >= 0 when PlzNavigate is enabled
// and there will then be one pending object for each frame that does not yet
// have a renderer process representation. |parent_frame_id| will be
// CefFrameHostImpl::kUnspecifiedFrameId if unknown. |created| will be set to
// true if |created| is non-nullptr and the frame object was created.
CefRefPtr<CefFrameHostImpl> GetOrCreatePendingFrame(int frame_tree_node_id,
int64 parent_frame_id,
bool* created);
// Remove the references to all frames and mark them as detached.
void DetachAllFrames();
void OnAddressChange(CefRefPtr<CefFrame> frame, const GURL& url);
void OnAddressChange(const GURL& url);
void OnLoadStart(CefRefPtr<CefFrame> frame,
ui::PageTransition transition_type);
void OnLoadError(CefRefPtr<CefFrame> frame, const GURL& url, int error_code);
@@ -654,16 +583,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
void ConfigureAutoResize();
// Send a message to the RenderViewHost associated with this browser.
// TODO(cef): With the introduction of OOPIFs, WebContents can span multiple
// processes. Messages should be sent to specific RenderFrameHosts instead.
bool Send(IPC::Message* message);
CefBrowserSettings settings_;
CefRefPtr<CefClient> client_;
scoped_refptr<CefBrowserInfo> browser_info_;
CefWindowHandle opener_;
CefRefPtr<CefRequestContext> request_context_;
CefRefPtr<CefRequestContextImpl> request_context_;
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate_;
const bool is_windowless_;
const bool is_views_hosted_;
@@ -683,26 +607,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool has_document_;
bool is_fullscreen_;
// Messages we queue while waiting for the RenderView to be ready. We queue
// them here instead of in the RenderProcessHost to ensure that they're sent
// after the CefRenderViewObserver has been created on the renderer side.
std::queue<IPC::Message*> queued_messages_;
bool queue_messages_;
// Map of frame tree node id to CefFrameHostImpl. These are frames that do not
// yet have a renderer process representation.
typedef std::map<int, CefRefPtr<CefFrameHostImpl>> FrameTreeNodeIdMap;
FrameTreeNodeIdMap pending_frames_;
// Map of unique frame id (renderer routing id) to CefFrameHostImpl. These are
// frames that do have a renderer process representation.
typedef std::map<int64, CefRefPtr<CefFrameHostImpl>> FrameIdMap;
FrameIdMap frames_;
// The unique frame id currently identified as the main frame.
int64 main_frame_id_;
// The unique frame id currently identified as the focused frame.
int64 focused_frame_id_;
// The currently focused frame, or nullptr if the main frame is focused.
CefRefPtr<CefFrameHostImpl> focused_frame_;
// Represents the current browser destruction state. Only accessed on the UI
// thread.
@@ -732,9 +638,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Used for managing notification subscriptions.
std::unique_ptr<content::NotificationRegistrar> registrar_;
// Manages response registrations.
std::unique_ptr<CefResponseManager> response_manager_;
// Used for creating and managing file dialogs.
std::unique_ptr<CefFileDialogManager> file_dialog_manager_;
@@ -762,6 +665,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
CefRefPtr<CefExtension> extension_;
bool is_background_host_ = false;
// Used to mirror audio streams
scoped_refptr<CefAudioMirrorDestination> audio_mirror_destination_;
// Used with auto-resize.
bool auto_resize_enabled_ = false;
gfx::Size auto_resize_min_;

View File

@@ -6,140 +6,364 @@
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/values_impl.h"
#include "base/logging.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/public/browser/render_process_host.h"
#include "ipc/ipc_message.h"
// CefBrowserInfo::RenderIDManager
CefBrowserInfo::RenderIDManager::RenderIDManager(base::Lock* lock)
: lock_(lock) {
DCHECK(lock);
}
void CefBrowserInfo::RenderIDManager::add_render_frame_id(
int render_process_id,
int render_routing_id) {
DCHECK_GT(render_process_id, 0);
DCHECK_GT(render_routing_id, 0);
base::AutoLock lock_scope(*lock_);
if (!render_frame_id_set_.empty()) {
RenderIdSet::const_iterator it = render_frame_id_set_.find(
std::make_pair(render_process_id, render_routing_id));
DCHECK(it == render_frame_id_set_.end());
if (it != render_frame_id_set_.end())
return;
CefBrowserInfo::FrameInfo::~FrameInfo() {
if (frame_ && !is_main_frame_) {
// Disassociate sub-frames from the browser.
frame_->Detach();
}
render_frame_id_set_.insert(
std::make_pair(render_process_id, render_routing_id));
}
void CefBrowserInfo::RenderIDManager::remove_render_frame_id(
int render_process_id,
int render_routing_id) {
DCHECK_GT(render_process_id, 0);
DCHECK_GT(render_routing_id, 0);
base::AutoLock lock_scope(*lock_);
DCHECK(!render_frame_id_set_.empty());
if (render_frame_id_set_.empty())
return;
bool erased = render_frame_id_set_.erase(
std::make_pair(render_process_id, render_routing_id)) != 0;
DCHECK(erased);
}
bool CefBrowserInfo::RenderIDManager::is_render_frame_id_match(
int render_process_id,
int render_routing_id) const {
base::AutoLock lock_scope(*lock_);
if (render_frame_id_set_.empty())
return false;
RenderIdSet::const_iterator it = render_frame_id_set_.find(
std::make_pair(render_process_id, render_routing_id));
return (it != render_frame_id_set_.end());
}
// CefBrowserInfo::FrameTreeNodeIDManager
CefBrowserInfo::FrameTreeNodeIDManager::FrameTreeNodeIDManager(base::Lock* lock)
: lock_(lock) {
DCHECK(lock);
}
void CefBrowserInfo::FrameTreeNodeIDManager::add_frame_tree_node_id(
int frame_tree_node_id) {
DCHECK_GE(frame_tree_node_id, 0);
base::AutoLock lock_scope(*lock_);
if (!frame_tree_node_id_set_.empty()) {
FrameTreeNodeIdSet::const_iterator it =
frame_tree_node_id_set_.find(frame_tree_node_id);
DCHECK(it == frame_tree_node_id_set_.end());
if (it != frame_tree_node_id_set_.end())
return;
}
frame_tree_node_id_set_.insert(frame_tree_node_id);
}
void CefBrowserInfo::FrameTreeNodeIDManager::remove_frame_tree_node_id(
int frame_tree_node_id) {
DCHECK_GE(frame_tree_node_id, 0);
base::AutoLock lock_scope(*lock_);
DCHECK(!frame_tree_node_id_set_.empty());
if (frame_tree_node_id_set_.empty())
return;
bool erased = frame_tree_node_id_set_.erase(frame_tree_node_id) != 0;
DCHECK(erased);
}
bool CefBrowserInfo::FrameTreeNodeIDManager::is_frame_tree_node_id_match(
int frame_tree_node_id) const {
base::AutoLock lock_scope(*lock_);
if (frame_tree_node_id_set_.empty())
return false;
FrameTreeNodeIdSet::const_iterator it =
frame_tree_node_id_set_.find(frame_tree_node_id);
return (it != frame_tree_node_id_set_.end());
}
// CefBrowserInfo
CefBrowserInfo::CefBrowserInfo(int browser_id, bool is_popup)
CefBrowserInfo::CefBrowserInfo(int browser_id,
bool is_popup,
bool is_windowless,
CefRefPtr<CefDictionaryValue> extra_info)
: browser_id_(browser_id),
is_popup_(is_popup),
is_windowless_(false),
render_id_manager_(&lock_),
guest_render_id_manager_(&lock_),
frame_tree_node_id_manager_(&lock_) {
is_windowless_(is_windowless),
extra_info_(extra_info) {
DCHECK_GT(browser_id, 0);
}
CefBrowserInfo::~CefBrowserInfo() {}
void CefBrowserInfo::set_windowless(bool windowless) {
is_windowless_ = windowless;
}
CefRefPtr<CefBrowserHostImpl> CefBrowserInfo::browser() const {
base::AutoLock lock_scope(lock_);
return browser_;
}
void CefBrowserInfo::set_browser(CefRefPtr<CefBrowserHostImpl> browser) {
void CefBrowserInfo::SetBrowser(CefRefPtr<CefBrowserHostImpl> browser) {
base::AutoLock lock_scope(lock_);
browser_ = browser;
if (!browser) {
RemoveAllFrames();
}
}
void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
bool is_guest_view) {
CEF_REQUIRE_UIT();
const auto frame_id = CefFrameHostImpl::MakeFrameId(host);
const int frame_tree_node_id = host->GetFrameTreeNodeId();
const bool is_main_frame = (host->GetParent() == nullptr);
// A speculative RFH will be created in response to a browser-initiated
// cross-origin navigation (e.g. via LoadURL) and eventually either discarded
// or swapped in based on whether the navigation is committed. We'll create a
// frame object for the speculative RFH so that it can be found by
// frame/routing ID. However, we won't replace the main frame with a
// speculative RFH until after it's swapped in, and we'll generally prefer to
// return a non-speculative RFH for the same node ID if one exists.
const bool is_speculative = (static_cast<content::RenderFrameHostImpl*>(host)
->frame_tree_node()
->render_manager()
->current_frame_host() != host);
base::AutoLock lock_scope(lock_);
DCHECK(browser_);
const auto it = frame_id_map_.find(frame_id);
if (it != frame_id_map_.end()) {
auto info = it->second;
#if DCHECK_IS_ON()
// Check that the frame info hasn't changed unexpectedly.
DCHECK_EQ(info->frame_id_, frame_id);
DCHECK_EQ(info->frame_tree_node_id_, frame_tree_node_id);
DCHECK_EQ(info->is_guest_view_, is_guest_view);
DCHECK_EQ(info->is_main_frame_, is_main_frame);
#endif
if (!info->is_guest_view_ && info->is_speculative_ && !is_speculative) {
// Upgrade the frame info from speculative to non-speculative.
if (info->is_main_frame_) {
if (main_frame_) {
// Update the existing main frame object.
main_frame_->SetRenderFrameHost(host);
info->frame_ = main_frame_;
} else {
// Set the main frame object.
main_frame_ = info->frame_;
}
}
info->is_speculative_ = false;
MaybeUpdateFrameTreeNodeIdMap(info);
}
return;
}
auto frame_info = new FrameInfo;
frame_info->host_ = host;
frame_info->frame_id_ = frame_id;
frame_info->frame_tree_node_id_ = frame_tree_node_id;
frame_info->is_guest_view_ = is_guest_view;
frame_info->is_main_frame_ = is_main_frame;
frame_info->is_speculative_ = is_speculative;
// Guest views don't get their own CefBrowser or CefFrame objects.
if (!is_guest_view) {
if (is_main_frame && main_frame_ && !is_speculative) {
// Update the existing main frame object.
main_frame_->SetRenderFrameHost(host);
frame_info->frame_ = main_frame_;
} else {
// Create a new frame object.
frame_info->frame_ = new CefFrameHostImpl(this, host);
if (is_main_frame && !is_speculative) {
main_frame_ = frame_info->frame_;
}
}
#if DCHECK_IS_ON()
// Check that the frame info hasn't changed unexpectedly.
DCHECK_EQ(frame_id, frame_info->frame_->GetIdentifier());
DCHECK_EQ(frame_info->is_main_frame_, frame_info->frame_->IsMain());
#endif
}
browser_->request_context()->OnRenderFrameCreated(
host->GetProcess()->GetID(), host->GetRoutingID(), frame_tree_node_id,
is_main_frame, is_guest_view);
// Populate the lookup maps.
frame_id_map_.insert(std::make_pair(frame_id, frame_info));
MaybeUpdateFrameTreeNodeIdMap(frame_info);
// And finally set the ownership.
frame_info_set_.insert(base::WrapUnique(frame_info));
}
void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
CEF_REQUIRE_UIT();
base::AutoLock lock_scope(lock_);
const auto frame_id = CefFrameHostImpl::MakeFrameId(host);
auto it = frame_id_map_.find(frame_id);
DCHECK(it != frame_id_map_.end());
auto frame_info = it->second;
browser_->request_context()->OnRenderFrameDeleted(
host->GetProcess()->GetID(), host->GetRoutingID(),
frame_info->frame_tree_node_id_, frame_info->is_main_frame_,
frame_info->is_guest_view_);
// Remove from the lookup maps.
frame_id_map_.erase(it);
// A new RFH with the same node ID may be added before the old RFH is deleted,
// or this might be a speculative RFH. Therefore only delete the map entry if
// it's currently pointing to the to-be-deleted frame info object.
if (frame_tree_node_id_map_.find(frame_info->frame_tree_node_id_)->second ==
frame_info) {
frame_tree_node_id_map_.erase(frame_info->frame_tree_node_id_);
}
// And finally delete the frame info.
auto it2 = frame_info_set_.find(frame_info);
frame_info_set_.erase(it2);
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetMainFrame() {
base::AutoLock lock_scope(lock_);
DCHECK(browser_);
if (!main_frame_) {
// Create a temporary object that will eventually be updated with real
// routing information.
main_frame_ =
new CefFrameHostImpl(this, true, CefFrameHostImpl::kInvalidFrameId);
}
return main_frame_;
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::CreateTempSubFrame(
int64_t parent_frame_id) {
CefRefPtr<CefFrameHostImpl> parent = GetFrameForId(parent_frame_id);
if (!parent)
parent = GetMainFrame();
return new CefFrameHostImpl(this, false, parent->GetIdentifier());
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForHost(
const content::RenderFrameHost* host,
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
if (!host)
return nullptr;
return GetFrameForId(CefFrameHostImpl::MakeFrameId(host), is_guest_view);
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForRoute(
int32_t render_process_id,
int32_t render_routing_id,
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
if (render_process_id < 0 || render_routing_id < 0)
return nullptr;
return GetFrameForId(
CefFrameHostImpl::MakeFrameId(render_process_id, render_routing_id),
is_guest_view);
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForId(
int64_t frame_id,
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
if (frame_id < 0)
return nullptr;
base::AutoLock lock_scope(lock_);
const auto it = frame_id_map_.find(frame_id);
if (it != frame_id_map_.end()) {
const auto info = it->second;
if (info->is_guest_view_) {
if (is_guest_view)
*is_guest_view = true;
return nullptr;
}
if (info->is_speculative_) {
if (info->is_main_frame_ && main_frame_) {
// Always prefer the non-speculative main frame.
return main_frame_;
} else {
// Always prefer an existing non-speculative frame for the same node ID.
bool is_guest_view_tmp;
auto frame = GetFrameForFrameTreeNodeInternal(info->frame_tree_node_id_,
&is_guest_view_tmp);
if (is_guest_view_tmp) {
if (is_guest_view)
*is_guest_view = true;
return nullptr;
}
if (frame)
return frame;
}
LOG(WARNING) << "Returning a speculative frame for frame id " << frame_id;
}
DCHECK(info->frame_);
return info->frame_;
}
return nullptr;
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForFrameTreeNode(
int frame_tree_node_id,
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
if (frame_tree_node_id < 0)
return nullptr;
base::AutoLock lock_scope(lock_);
return GetFrameForFrameTreeNodeInternal(frame_tree_node_id, is_guest_view);
}
CefBrowserInfo::FrameHostList CefBrowserInfo::GetAllFrames() const {
base::AutoLock lock_scope(lock_);
FrameHostList frames;
for (const auto& info : frame_info_set_) {
if (info->frame_ && !info->is_speculative_)
frames.insert(info->frame_);
}
return frames;
}
void CefBrowserInfo::MaybeUpdateFrameTreeNodeIdMap(FrameInfo* info) {
lock_.AssertAcquired();
auto it = frame_tree_node_id_map_.find(info->frame_tree_node_id_);
const bool has_entry = (it != frame_tree_node_id_map_.end());
if (has_entry && it->second == info) {
// Already mapping to |info|.
return;
}
// Don't replace an existing node ID entry with a speculative RFH, but do
// add an entry if one doesn't already exist.
if (!info->is_speculative_ || !has_entry) {
// A new RFH with the same node ID may be added before the old RFH is
// deleted. To avoid duplicate entries in the map remove the old entry, if
// any, before adding the new entry.
if (has_entry)
frame_tree_node_id_map_.erase(it);
frame_tree_node_id_map_.insert(
std::make_pair(info->frame_tree_node_id_, info));
}
}
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForFrameTreeNodeInternal(
int frame_tree_node_id,
bool* is_guest_view) const {
if (is_guest_view)
*is_guest_view = false;
lock_.AssertAcquired();
const auto it = frame_tree_node_id_map_.find(frame_tree_node_id);
if (it != frame_tree_node_id_map_.end()) {
const auto info = it->second;
LOG_IF(WARNING, info->is_speculative_)
<< "Returning a speculative frame for node id " << frame_tree_node_id;
if (info->is_guest_view_) {
if (is_guest_view)
*is_guest_view = true;
return nullptr;
}
DCHECK(info->frame_);
return info->frame_;
}
return nullptr;
}
void CefBrowserInfo::RemoveAllFrames() {
lock_.AssertAcquired();
// Clear the lookup maps.
frame_id_map_.clear();
frame_tree_node_id_map_.clear();
// Explicitly Detach main frames.
for (auto& info : frame_info_set_) {
if (info->frame_ && info->is_main_frame_)
info->frame_->Detach();
}
if (main_frame_) {
main_frame_->Detach();
main_frame_ = nullptr;
}
// And finally delete the frame info.
frame_info_set_.clear();
}

View File

@@ -7,128 +7,172 @@
#pragma once
#include <set>
#include <unordered_map>
#include "include/internal/cef_ptr.h"
#include "libcef/common/values_impl.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "base/values.h"
namespace content {
class RenderFrameHost;
}
class CefBrowserHostImpl;
class CefFrameHostImpl;
// CefBrowserInfo is used to associate a browser ID and render view/process
// IDs with a particular CefBrowserHostImpl. Render view/process IDs may change
// during the lifetime of a single CefBrowserHostImpl.
//
// CefBrowserInfo objects are managed by CefContentBrowserClient and should not
// be created directly.
// CefBrowserInfo objects are managed by CefBrowserInfoManager and should not be
// created directly.
class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
public:
class RenderIDManager {
public:
explicit RenderIDManager(base::Lock* lock);
CefBrowserInfo(int browser_id,
bool is_popup,
bool is_windowless,
CefRefPtr<CefDictionaryValue> extra_info);
// Adds an ID pair if it doesn't already exist.
void add_render_frame_id(int render_process_id, int render_routing_id);
// Remove an ID pair if it exists.
void remove_render_frame_id(int render_process_id, int render_routing_id);
// Returns true if this browser matches the specified ID pair.
bool is_render_frame_id_match(int render_process_id,
int render_routing_id) const;
private:
typedef std::set<std::pair<int, int>> RenderIdSet;
// Access to |render_frame_id_set_| must be protected by |lock_|.
mutable base::Lock* lock_;
// Set of mapped (process_id, routing_id) pairs. Keeping this set is
// necessary for the following reasons:
// 1. When navigating cross-origin the new (pending) RenderFrameHost will be
// created before the old (current) RenderFrameHost is destroyed.
// 2. When canceling and asynchronously continuing navigation of the same
// URL a new RenderFrameHost may be created for the first (canceled)
// navigation and then destroyed as a result of the second (allowed)
// navigation.
// 3. Out-of-process iframes have their own render IDs which must also be
// associated with the host browser.
RenderIdSet render_frame_id_set_;
};
class FrameTreeNodeIDManager {
public:
explicit FrameTreeNodeIDManager(base::Lock* lock);
// Adds an ID if it doesn't already exist.
void add_frame_tree_node_id(int frame_tree_node_id);
// Remove an ID if it exists.
void remove_frame_tree_node_id(int frame_tree_node_id);
// Returns true if this browser matches the specified ID.
bool is_frame_tree_node_id_match(int frame_tree_node_id) const;
private:
typedef std::set<int> FrameTreeNodeIdSet;
// Access to |request_id_set_| must be protected by |lock_|.
mutable base::Lock* lock_;
// Set of mapped frame_tree_node_id values. Keeping this set is necessary
// because, when navigating the main frame, a new (pre-commit) URLRequest
// will be created before the RenderFrameHost. Consequently we can't rely
// on ResourceRequestInfo::GetRenderFrameForRequest returning a valid frame
// ID. See https://crbug.com/776884 for background.
FrameTreeNodeIdSet frame_tree_node_id_set_;
};
CefBrowserInfo(int browser_id, bool is_popup);
int browser_id() const { return browser_id_; };
int browser_id() const { return browser_id_; }
bool is_popup() const { return is_popup_; }
bool is_windowless() const { return is_windowless_; }
CefRefPtr<CefDictionaryValue> extra_info() const { return extra_info_; }
void set_windowless(bool windowless);
// Returns the render ID manager for this browser.
RenderIDManager* render_id_manager() { return &render_id_manager_; }
// Returns the render ID manager for guest views owned by this browser.
RenderIDManager* guest_render_id_manager() {
return &guest_render_id_manager_;
}
// Returns the frame tree node ID manager for this browser.
FrameTreeNodeIDManager* frame_tree_node_id_manager() {
return &frame_tree_node_id_manager_;
}
// May return NULL if the browser has not yet been created or if the browser
// has been destroyed.
CefRefPtr<CefBrowserHostImpl> browser() const;
void set_browser(CefRefPtr<CefBrowserHostImpl> browser);
// Set or clear the browser. Called from the CefBrowserHostImpl constructor
// (to set) and DestroyBrowser (to clear).
void SetBrowser(CefRefPtr<CefBrowserHostImpl> browser);
// Ensure that a frame record exists for |host|. Called for the main frame
// when the RenderView is created, or for a sub-frame when the associated
// RenderFrame is created in the renderer process.
// Called from CefBrowserHostImpl::RenderFrameCreated (is_guest_view = false)
// or CefMimeHandlerViewGuestDelegate::OnGuestAttached (is_guest_view = true).
void MaybeCreateFrame(content::RenderFrameHost* host, bool is_guest_view);
// Remove the frame record for |host|. Called for the main frame when the
// RenderView is destroyed, or for a sub-frame when the associated RenderFrame
// is destroyed in the renderer process.
// Called from CefBrowserHostImpl::FrameDeleted or
// CefMimeHandlerViewGuestDelegate::OnGuestDetached.
void RemoveFrame(content::RenderFrameHost* host);
// Returns the main frame object. This object will remain valid until the
// browser is destroyed even though the indentifier may change with cross-
// origin navigations. Furthermore, calling LoadURL on this object will always
// behave as expected because the call is routed through the browser's
// NavigationController.
CefRefPtr<CefFrameHostImpl> GetMainFrame();
// Creates a temporary sub-frame object for situations during navigation or
// resource loading where a RFH does not yet exist. If |parent_frame_id|
// is invalid the current main frame will be specified as the parent.
// Temporary frame objects are not tracked but will be implicitly detached
// on browser destruction.
CefRefPtr<CefFrameHostImpl> CreateTempSubFrame(int64_t parent_frame_id);
// Returns the frame object matching the specified host or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
// because we don't create frame objects for guest views. If |is_guest_view|
// is non-nullptr it will be set to true in this case. Must be called on the
// UI thread.
CefRefPtr<CefFrameHostImpl> GetFrameForHost(
const content::RenderFrameHost* host,
bool* is_guest_view = nullptr) const;
// Returns the frame object matching the specified IDs or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
// because we don't create frame objects for guest views. If |is_guest_view|
// is non-nullptr it will be set to true in this case. Safe to call from any
// thread.
CefRefPtr<CefFrameHostImpl> GetFrameForRoute(
int32_t render_process_id,
int32_t render_routing_id,
bool* is_guest_view = nullptr) const;
// Returns the frame object matching the specified ID or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
// because we don't create frame objects for guest views. If |is_guest_view|
// is non-nullptr it will be set to true in this case. Safe to call from any
// thread.
CefRefPtr<CefFrameHostImpl> GetFrameForId(
int64_t frame_id,
bool* is_guest_view = nullptr) const;
// Returns the frame object matching the specified ID or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found
// because we don't create frame objects for guest views. If |is_guest_view|
// is non-nullptr it will be set to true in this case. Safe to call from any
// thread.
CefRefPtr<CefFrameHostImpl> GetFrameForFrameTreeNode(
int frame_tree_node_id,
bool* is_guest_view = nullptr) const;
// Returns all non-speculative frame objects that currently exist. Guest views
// will be excluded because they don't have a frame object. Safe to call from
// any thread.
typedef std::set<CefRefPtr<CefFrameHostImpl>> FrameHostList;
FrameHostList GetAllFrames() const;
private:
friend class base::RefCountedThreadSafe<CefBrowserInfo>;
~CefBrowserInfo();
virtual ~CefBrowserInfo();
struct FrameInfo {
~FrameInfo();
content::RenderFrameHost* host_;
int64_t frame_id_; // Combination of render_process_id + render_routing_id.
int frame_tree_node_id_;
bool is_guest_view_;
bool is_main_frame_;
bool is_speculative_;
CefRefPtr<CefFrameHostImpl> frame_;
};
void MaybeUpdateFrameTreeNodeIdMap(FrameInfo* info);
CefRefPtr<CefFrameHostImpl> GetFrameForFrameTreeNodeInternal(
int frame_tree_node_id,
bool* is_guest_view = nullptr) const;
void RemoveAllFrames();
int browser_id_;
bool is_popup_;
bool is_windowless_;
CefRefPtr<CefDictionaryValue> extra_info_;
mutable base::Lock lock_;
// The below members must be protected by |lock_|.
RenderIDManager render_id_manager_;
RenderIDManager guest_render_id_manager_;
FrameTreeNodeIDManager frame_tree_node_id_manager_;
// May be NULL if the browser has not yet been created or if the browser has
// been destroyed.
CefRefPtr<CefBrowserHostImpl> browser_;
// Owner of FrameInfo structs.
typedef std::set<std::unique_ptr<FrameInfo>, base::UniquePtrComparator>
FrameInfoSet;
FrameInfoSet frame_info_set_;
// Map a frame ID (e.g. MakeFrameId(process_id, routing_id)) to one frame.
typedef std::unordered_map<int64_t, FrameInfo*> FrameIDMap;
FrameIDMap frame_id_map_;
// Map a frame_tree_node_id to one frame.
typedef std::unordered_map<int, FrameInfo*> FrameTreeNodeIDMap;
FrameTreeNodeIDMap frame_tree_node_id_map_;
// The current main frame.
CefRefPtr<CefFrameHostImpl> main_frame_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserInfo);
};

View File

@@ -12,6 +12,7 @@
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/values_impl.h"
#include "base/logging.h"
#include "content/common/view_messages.h"
@@ -60,50 +61,37 @@ CefBrowserInfoManager* CefBrowserInfoManager::GetInstance() {
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreateBrowserInfo(
bool is_popup,
bool is_windowless) {
bool is_windowless,
CefRefPtr<CefDictionaryValue> extra_info) {
base::AutoLock lock_scope(browser_info_lock_);
scoped_refptr<CefBrowserInfo> browser_info =
new CefBrowserInfo(++next_browser_id_, is_popup);
scoped_refptr<CefBrowserInfo> browser_info = new CefBrowserInfo(
++next_browser_id_, is_popup, is_windowless, extra_info);
browser_info_list_.push_back(browser_info);
if (is_windowless)
browser_info->set_windowless(true);
return browser_info;
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
content::WebContents* new_contents,
bool is_windowless) {
bool is_windowless,
CefRefPtr<CefDictionaryValue> extra_info) {
base::AutoLock lock_scope(browser_info_lock_);
content::RenderFrameHost* frame_host = new_contents->GetMainFrame();
auto frame_host = new_contents->GetMainFrame();
const int render_process_id = frame_host->GetProcess()->GetID();
const int render_frame_routing_id = frame_host->GetRoutingID();
const auto frame_id = CefFrameHostImpl::MakeFrameId(frame_host);
scoped_refptr<CefBrowserInfo> browser_info =
new CefBrowserInfo(++next_browser_id_, true);
browser_info->render_id_manager()->add_render_frame_id(
render_process_id, render_frame_routing_id);
new CefBrowserInfo(++next_browser_id_, true, is_windowless, extra_info);
browser_info_list_.push_back(browser_info);
if (is_windowless)
browser_info->set_windowless(true);
// Continue any pending NewBrowserInfo requests.
PendingNewBrowserInfoList::iterator it =
pending_new_browser_info_list_.begin();
for (; it != pending_new_browser_info_list_.end(); ++it) {
PendingNewBrowserInfo* info = it->get();
if (info->render_process_id == render_process_id &&
info->render_frame_routing_id == render_frame_routing_id) {
SendNewBrowserInfoResponse(render_process_id, browser_info, false,
info->reply_msg);
pending_new_browser_info_list_.erase(it);
break;
}
auto it = pending_new_browser_info_map_.find(frame_id);
if (it != pending_new_browser_info_map_.end()) {
SendNewBrowserInfoResponse(render_process_id, browser_info, false,
it->second->reply_msg);
pending_new_browser_info_map_.erase(it);
}
return browser_info;
@@ -156,8 +144,8 @@ bool CefBrowserInfoManager::CanCreateWindow(
auto pending_popup = std::make_unique<CefBrowserInfoManager::PendingPopup>();
pending_popup->step = CefBrowserInfoManager::PendingPopup::CAN_CREATE_WINDOW;
pending_popup->opener_process_id = opener->GetProcess()->GetID();
pending_popup->opener_frame_id = opener->GetRoutingID();
pending_popup->opener_render_process_id = opener->GetProcess()->GetID();
pending_popup->opener_render_routing_id = opener->GetRoutingID();
pending_popup->target_url = target_url;
pending_popup->target_frame_name = frame_name;
@@ -168,8 +156,8 @@ bool CefBrowserInfoManager::CanCreateWindow(
if (client.get()) {
CefRefPtr<CefLifeSpanHandler> handler = client->GetLifeSpanHandler();
if (handler.get()) {
CefRefPtr<CefFrame> frame =
browser->GetFrame(pending_popup->opener_frame_id);
CefRefPtr<CefFrame> opener_frame = browser->GetFrameForHost(opener);
DCHECK(opener_frame);
CefPopupFeatures cef_features;
TranslatePopupFeatures(features, cef_features);
@@ -187,11 +175,12 @@ bool CefBrowserInfoManager::CanCreateWindow(
#endif
allow = !handler->OnBeforePopup(
browser.get(), frame, pending_popup->target_url.spec(),
browser.get(), opener_frame, pending_popup->target_url.spec(),
pending_popup->target_frame_name,
static_cast<cef_window_open_disposition_t>(disposition), user_gesture,
cef_features, *window_info, pending_popup->client,
pending_popup->settings, no_javascript_access);
pending_popup->settings, pending_popup->extra_info,
no_javascript_access);
}
}
@@ -203,6 +192,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
create_params.settings = pending_popup->settings;
create_params.client = pending_popup->client;
create_params.extra_info = pending_popup->extra_info;
pending_popup->platform_delegate =
CefBrowserPlatformDelegate::Create(create_params);
@@ -224,14 +214,14 @@ bool CefBrowserInfoManager::CanCreateWindow(
void CefBrowserInfoManager::GetCustomWebContentsView(
const GURL& target_url,
int opener_render_process_id,
int opener_render_frame_id,
int opener_render_routing_id,
content::WebContentsView** view,
content::RenderViewHostDelegateView** delegate_view) {
CEF_REQUIRE_UIT();
std::unique_ptr<CefBrowserInfoManager::PendingPopup> pending_popup =
PopPendingPopup(CefBrowserInfoManager::PendingPopup::CAN_CREATE_WINDOW,
opener_render_process_id, opener_render_frame_id,
opener_render_process_id, opener_render_routing_id,
target_url);
DCHECK(pending_popup.get());
DCHECK(pending_popup->platform_delegate.get());
@@ -249,37 +239,39 @@ void CefBrowserInfoManager::GetCustomWebContentsView(
void CefBrowserInfoManager::WebContentsCreated(
const GURL& target_url,
int opener_render_process_id,
int opener_render_frame_id,
int opener_render_routing_id,
CefBrowserSettings& settings,
CefRefPtr<CefClient>& client,
std::unique_ptr<CefBrowserPlatformDelegate>& platform_delegate) {
std::unique_ptr<CefBrowserPlatformDelegate>& platform_delegate,
CefRefPtr<CefDictionaryValue>& extra_info) {
CEF_REQUIRE_UIT();
std::unique_ptr<CefBrowserInfoManager::PendingPopup> pending_popup =
PopPendingPopup(
CefBrowserInfoManager::PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW,
opener_render_process_id, opener_render_frame_id, target_url);
opener_render_process_id, opener_render_routing_id, target_url);
DCHECK(pending_popup.get());
DCHECK(pending_popup->platform_delegate.get());
settings = pending_popup->settings;
client = pending_popup->client;
platform_delegate = std::move(pending_popup->platform_delegate);
extra_info = pending_popup->extra_info;
}
void CefBrowserInfoManager::OnGetNewBrowserInfo(int render_process_id,
int render_frame_routing_id,
int render_routing_id,
IPC::Message* reply_msg) {
DCHECK_NE(render_process_id, content::ChildProcessHost::kInvalidUniqueID);
DCHECK_GT(render_frame_routing_id, 0);
DCHECK_GT(render_routing_id, 0);
DCHECK(reply_msg);
base::AutoLock lock_scope(browser_info_lock_);
bool is_guest_view = false;
scoped_refptr<CefBrowserInfo> browser_info = GetBrowserInfo(
render_process_id, render_frame_routing_id, &is_guest_view);
scoped_refptr<CefBrowserInfo> browser_info =
GetBrowserInfo(render_process_id, render_routing_id, &is_guest_view);
if (browser_info.get()) {
// Send the response immediately.
@@ -288,27 +280,20 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(int render_process_id,
return;
}
#if DCHECK_IS_ON()
const auto frame_id =
CefFrameHostImpl::MakeFrameId(render_process_id, render_routing_id);
// Verify that no request for the same route is currently queued.
{
PendingNewBrowserInfoList::const_iterator it =
pending_new_browser_info_list_.begin();
for (; it != pending_new_browser_info_list_.end(); ++it) {
PendingNewBrowserInfo* info = it->get();
if (info->render_process_id == render_process_id &&
info->render_frame_routing_id == render_frame_routing_id) {
NOTREACHED();
}
}
}
#endif
DCHECK(pending_new_browser_info_map_.find(frame_id) ==
pending_new_browser_info_map_.end());
// Queue the request.
std::unique_ptr<PendingNewBrowserInfo> pending(new PendingNewBrowserInfo());
pending->render_process_id = render_process_id;
pending->render_frame_routing_id = render_frame_routing_id;
pending->render_routing_id = render_routing_id;
pending->reply_msg = reply_msg;
pending_new_browser_info_list_.push_back(std::move(pending));
pending_new_browser_info_map_.insert(
std::make_pair(frame_id, std::move(pending)));
}
void CefBrowserInfoManager::RemoveBrowserInfo(
@@ -356,26 +341,32 @@ void CefBrowserInfoManager::DestroyAllBrowsers() {
#endif
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoForFrame(
int render_process_id,
int render_routing_id,
bool* is_guest_view) {
scoped_refptr<CefBrowserInfo>
CefBrowserInfoManager::GetBrowserInfoForFrameRoute(int render_process_id,
int render_routing_id,
bool* is_guest_view) {
base::AutoLock lock_scope(browser_info_lock_);
return GetBrowserInfo(render_process_id, render_routing_id, is_guest_view);
}
scoped_refptr<CefBrowserInfo>
CefBrowserInfoManager::GetBrowserInfoForFrameTreeNode(int frame_tree_node_id) {
CefBrowserInfoManager::GetBrowserInfoForFrameTreeNode(int frame_tree_node_id,
bool* is_guest_view) {
if (is_guest_view)
*is_guest_view = false;
if (frame_tree_node_id < 0)
return nullptr;
base::AutoLock lock_scope(browser_info_lock_);
BrowserInfoList::const_iterator it = browser_info_list_.begin();
for (; it != browser_info_list_.end(); ++it) {
const scoped_refptr<CefBrowserInfo>& browser_info = *it;
if (browser_info->frame_tree_node_id_manager()->is_frame_tree_node_id_match(
frame_tree_node_id)) {
for (const auto& browser_info : browser_info_list_) {
bool is_guest_view_tmp;
auto frame = browser_info->GetFrameForFrameTreeNode(frame_tree_node_id,
&is_guest_view_tmp);
if (frame || is_guest_view_tmp) {
if (is_guest_view)
*is_guest_view = is_guest_view_tmp;
return browser_info;
}
}
@@ -383,9 +374,12 @@ CefBrowserInfoManager::GetBrowserInfoForFrameTreeNode(int frame_tree_node_id) {
return nullptr;
}
void CefBrowserInfoManager::GetBrowserInfoList(BrowserInfoList& list) {
CefBrowserInfoManager::BrowserInfoList
CefBrowserInfoManager::GetBrowserInfoList() {
base::AutoLock lock_scope(browser_info_lock_);
list = browser_info_list_;
BrowserInfoList copy;
copy.assign(browser_info_list_.begin(), browser_info_list_.end());
return copy;
}
void CefBrowserInfoManager::RenderProcessHostDestroyed(
@@ -399,12 +393,12 @@ void CefBrowserInfoManager::RenderProcessHostDestroyed(
{
base::AutoLock lock_scope(browser_info_lock_);
PendingNewBrowserInfoList::iterator it =
pending_new_browser_info_list_.begin();
while (it != pending_new_browser_info_list_.end()) {
PendingNewBrowserInfo* info = it->get();
PendingNewBrowserInfoMap::iterator it =
pending_new_browser_info_map_.begin();
while (it != pending_new_browser_info_map_.end()) {
auto info = it->second.get();
if (info->render_process_id == render_process_id)
it = pending_new_browser_info_list_.erase(it);
it = pending_new_browser_info_map_.erase(it);
else
++it;
}
@@ -415,7 +409,7 @@ void CefBrowserInfoManager::RenderProcessHostDestroyed(
PendingPopupList::iterator it = pending_popup_list_.begin();
while (it != pending_popup_list_.end()) {
PendingPopup* popup = it->get();
if (popup->opener_process_id == render_process_id) {
if (popup->opener_render_process_id == render_process_id) {
it = pending_popup_list_.erase(it);
} else {
++it;
@@ -432,18 +426,19 @@ void CefBrowserInfoManager::PushPendingPopup(
std::unique_ptr<CefBrowserInfoManager::PendingPopup>
CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step step,
int opener_process_id,
int opener_frame_id,
int opener_render_process_id,
int opener_render_routing_id,
const GURL& target_url) {
CEF_REQUIRE_UIT();
DCHECK_GT(opener_process_id, 0);
DCHECK_GT(opener_frame_id, 0);
DCHECK_GT(opener_render_process_id, 0);
DCHECK_GT(opener_render_routing_id, 0);
PendingPopupList::iterator it = pending_popup_list_.begin();
for (; it != pending_popup_list_.end(); ++it) {
PendingPopup* popup = it->get();
if (popup->step == step && popup->opener_process_id == opener_process_id &&
popup->opener_frame_id == opener_frame_id &&
if (popup->step == step &&
popup->opener_render_process_id == opener_render_process_id &&
popup->opener_render_routing_id == opener_render_routing_id &&
popup->target_url == target_url) {
// Transfer ownership of the pointer.
it->release();
@@ -456,29 +451,24 @@ CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step step,
}
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
int render_frame_process_id,
int render_frame_routing_id,
int render_process_id,
int render_routing_id,
bool* is_guest_view) {
browser_info_lock_.AssertAcquired();
if (is_guest_view)
*is_guest_view = false;
if (render_frame_process_id < 0 || render_frame_routing_id < 0)
if (render_process_id < 0 || render_routing_id < 0)
return nullptr;
BrowserInfoList::const_iterator it = browser_info_list_.begin();
for (; it != browser_info_list_.end(); ++it) {
const scoped_refptr<CefBrowserInfo>& browser_info = *it;
if (browser_info->render_id_manager()->is_render_frame_id_match(
render_frame_process_id, render_frame_routing_id)) {
return browser_info;
}
if (extensions::ExtensionsEnabled() &&
browser_info->guest_render_id_manager()->is_render_frame_id_match(
render_frame_process_id, render_frame_routing_id)) {
for (const auto& browser_info : browser_info_list_) {
bool is_guest_view_tmp;
auto frame = browser_info->GetFrameForRoute(
render_process_id, render_routing_id, &is_guest_view_tmp);
if (frame || is_guest_view_tmp) {
if (is_guest_view)
*is_guest_view = true;
*is_guest_view = is_guest_view_tmp;
return browser_info;
}
}
@@ -513,6 +503,14 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
params.is_popup = browser_info->is_popup();
params.is_guest_view = is_guest_view;
auto extra_info = browser_info->extra_info();
if (extra_info) {
auto extra_info_impl =
static_cast<CefDictionaryValueImpl*>(extra_info.get());
auto extra_info_value = extra_info_impl->CopyValue();
extra_info_value->Swap(&params.extra_info);
}
CefProcessHostMsg_GetNewBrowserInfo::WriteReplyParams(reply_msg, params);
host->Send(reply_msg);
}

View File

@@ -8,7 +8,7 @@
#include "include/cef_client.h"
#include <list>
#include <map>
#include <memory>
#include <vector>
@@ -16,7 +16,7 @@
#include "base/synchronization/lock.h"
#include "content/public/browser/render_process_host_observer.h"
#include "third_party/blink/public/web/window_features.mojom.h"
#include "third_party/blink/public/mojom/window_features/window_features.mojom.h"
#include "ui/base/window_open_disposition.h"
#include "url/gurl.h"
@@ -49,8 +49,10 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Called from CefBrowserHostImpl::Create when a new browser is being created
// directly. In this case |is_popup| will be true only for DevTools browsers.
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(bool is_popup,
bool is_windowless);
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(
bool is_popup,
bool is_windowless,
CefRefPtr<CefDictionaryValue> extra_info);
// Called from CefBrowserHostImpl::WebContentsCreated when a new browser is
// being created for a traditional popup (e.g. window.open() or targeted
@@ -58,7 +60,8 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// response will be sent when this method is called.
scoped_refptr<CefBrowserInfo> CreatePopupBrowserInfo(
content::WebContents* new_contents,
bool is_windowless);
bool is_windowless,
CefRefPtr<CefDictionaryValue> extra_info);
// Called from CefContentBrowserClient::CanCreateWindow. See comments on
// PendingPopup for more information.
@@ -77,7 +80,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
void GetCustomWebContentsView(
const GURL& target_url,
int opener_render_process_id,
int opener_render_frame_id,
int opener_render_routing_id,
content::WebContentsView** view,
content::RenderViewHostDelegateView** delegate_view);
@@ -86,10 +89,11 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
void WebContentsCreated(
const GURL& target_url,
int opener_render_process_id,
int opener_render_frame_id,
int opener_render_routing_id,
CefBrowserSettings& settings,
CefRefPtr<CefClient>& client,
std::unique_ptr<CefBrowserPlatformDelegate>& platform_delegate);
std::unique_ptr<CefBrowserPlatformDelegate>& platform_delegate,
CefRefPtr<CefDictionaryValue>& extra_info);
// Called from CefBrowserMessageFilter::OnGetNewBrowserInfo for delivering
// browser info to the renderer process. If the browser info already exists
@@ -99,7 +103,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// already exist for traditional popup browsers depending on timing. See
// comments on PendingPopup for more information.
void OnGetNewBrowserInfo(int render_process_id,
int render_frame_routing_id,
int render_routing_id,
IPC::Message* reply_msg);
// Called from CefBrowserHostImpl::DestroyBrowser() when a browser is
@@ -109,27 +113,30 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Called from CefContext::FinishShutdownOnUIThread() to destroy all browsers.
void DestroyAllBrowsers();
// Retrieves the CefBrowserInfo matching the specified IDs or an empty
// pointer if no match is found. It is allowed to add new callers of this
// method but consider using CefBrowserHostImpl::GetBrowserForFrame()
// or extensions::GetOwnerBrowserForFrame() instead.
// |is_guest_view| will be set to true if the IDs match a guest view
// associated with the returned browser info instead of the browser itself.
scoped_refptr<CefBrowserInfo> GetBrowserInfoForFrame(int render_process_id,
int render_routing_id,
bool* is_guest_view);
// Returns the CefBrowserInfo matching the specified IDs or nullptr if no
// match is found. It is allowed to add new callers of this method but
// consider using CefBrowserHostImpl::GetBrowserForFrameRoute() or
// extensions::GetOwnerBrowserForFrameRoute() instead. If |is_guest_view| is
// non-nullptr it will be set to true if the IDs match a guest view associated
// with the returned browser info instead of the browser itself.
scoped_refptr<CefBrowserInfo> GetBrowserInfoForFrameRoute(
int render_process_id,
int render_routing_id,
bool* is_guest_view = nullptr);
// Retrieves the CefBrowserInfo matching the specified ID or an empty
// pointer if no match is found. It is allowed to add new callers of this
// method but consider using CefBrowserHostImpl::GetBrowserForRequest()
// instead since we generally use this mapping for URLRequests on the IO
// thread.
// Returns the CefBrowserInfo matching the specified ID or nullptr if no match
// is found. It is allowed to add new callers of this method but consider
// using CefBrowserHostImpl::GetBrowserForFrameTreeNode() instead. If
// |is_guest_view| is non-nullptr it will be set to true if the IDs match a
// guest view associated with the returned browser info instead of the browser
// itself.
scoped_refptr<CefBrowserInfo> GetBrowserInfoForFrameTreeNode(
int frame_tree_node_id);
int frame_tree_node_id,
bool* is_guest_view = nullptr);
// Retrieves all existing CefBrowserInfo objects.
// Returns all existing CefBrowserInfo objects.
typedef std::list<scoped_refptr<CefBrowserInfo>> BrowserInfoList;
void GetBrowserInfoList(BrowserInfoList& list);
BrowserInfoList GetBrowserInfoList();
private:
// RenderProcessHostObserver methods:
@@ -160,14 +167,15 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Initial state from ViewHostMsg_CreateWindow.
// |target_url| will be empty if a popup is created via window.open() and
// never navigated. For example: javascript:window.open();
int opener_process_id;
int opener_frame_id;
int opener_render_process_id;
int opener_render_routing_id;
GURL target_url;
std::string target_frame_name;
// Values specified by OnBeforePopup.
CefBrowserSettings settings;
CefRefPtr<CefClient> client;
CefRefPtr<CefDictionaryValue> extra_info;
// Platform delegate specific to the new popup.
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate;
@@ -177,13 +185,13 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
void PushPendingPopup(std::unique_ptr<PendingPopup> popup);
std::unique_ptr<PendingPopup> PopPendingPopup(PendingPopup::Step step,
int opener_process_id,
int opener_frame_id,
int opener_routing_id,
const GURL& target_url);
// Retrieves the BrowserInfo matching the specified IDs. If both sets are
// valid then this method makes sure both sets have been registered.
scoped_refptr<CefBrowserInfo> GetBrowserInfo(int render_frame_process_id,
int render_frame_routing_id,
scoped_refptr<CefBrowserInfo> GetBrowserInfo(int render_process_id,
int render_routing_id,
bool* is_guest_view);
// Send the response for a pending OnGetNewBrowserInfo request.
@@ -196,7 +204,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Pending request for OnGetNewBrowserInfo.
struct PendingNewBrowserInfo {
int render_process_id;
int render_frame_routing_id;
int render_routing_id;
IPC::Message* reply_msg;
};
@@ -207,9 +215,10 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
BrowserInfoList browser_info_list_;
int next_browser_id_;
using PendingNewBrowserInfoList =
std::vector<std::unique_ptr<PendingNewBrowserInfo>>;
PendingNewBrowserInfoList pending_new_browser_info_list_;
// Map of frame ID to info.
using PendingNewBrowserInfoMap =
std::map<int64_t, std::unique_ptr<PendingNewBrowserInfo>>;
PendingNewBrowserInfoMap pending_new_browser_info_map_;
// Only accessed on the UI thread.
using PendingPopupList = std::vector<std::unique_ptr<PendingPopup>>;

View File

@@ -8,11 +8,11 @@
#include <string>
#include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/browser_context.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/devtools_manager_delegate.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/extensions/extension_system_factory.h"
#include "libcef/browser/extensions/extensions_browser_client.h"
#include "libcef/browser/net/chrome_scheme_handler.h"
@@ -21,12 +21,15 @@
#include "libcef/common/extensions/extensions_client.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net/net_resource_provider.h"
#include "libcef/common/net_service/util.h"
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "content/public/browser/gpu_data_manager.h"
#include "extensions/browser/extension_system.h"
@@ -36,6 +39,10 @@
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#if defined(USE_AURA) && defined(USE_X11)
#include "ui/events/devices/x11/touch_factory_x11.h"
#endif
#if defined(USE_AURA)
#include "ui/aura/env.h"
#include "ui/display/screen.h"
@@ -49,13 +56,18 @@
#endif // defined(USE_AURA)
#if defined(USE_AURA) && defined(OS_LINUX)
#include "ui/base/ime/input_method_initializer.h"
#include "ui/base/ime/init/input_method_initializer.h"
#endif
#if defined(OS_LINUX)
#include "libcef/browser/printing/print_dialog_linux.h"
#endif
#if defined(OS_MACOSX)
#include "chrome/browser/browser_process.h"
#include "components/os_crypt/os_crypt.h"
#endif
CefBrowserMainParts::CefBrowserMainParts(
const content::MainFunctionParams& parameters)
: BrowserMainParts(), devtools_delegate_(NULL) {}
@@ -107,6 +119,19 @@ void CefBrowserMainParts::ToolkitInitialized() {
}
void CefBrowserMainParts::PreMainMessageLoopStart() {
#if defined(USE_AURA) && defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif
#if defined(OS_MACOSX)
if (net_service::IsEnabled()) {
// Initialize the OSCrypt.
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);
OSCrypt::Init(local_state);
}
#endif
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreMainMessageLoopStart();
}
@@ -130,9 +155,13 @@ int CefBrowserMainParts::PreCreateThreads() {
net::NetModule::SetResourceProvider(&NetResourceProvider);
// Initialize the GpuDataManager before IO access restrictions are applied and
// Initialize these objects before IO access restrictions are applied and
// before the IO thread is started.
content::GpuDataManager::GetInstance();
if (net_service::IsEnabled()) {
SystemNetworkContextManager::CreateInstance(
g_browser_process->local_state());
}
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreCreateThreads();
@@ -190,7 +219,7 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
// Create the global RequestContext.
global_request_context_ =
CefRequestContextImpl::CreateGlobalRequestContext(settings);
CefBrowserContextImpl* browser_context = static_cast<CefBrowserContextImpl*>(
CefBrowserContext* browser_context = static_cast<CefBrowserContext*>(
global_request_context_->GetBrowserContext());
PostProfileInit();

View File

@@ -6,7 +6,7 @@
#define CEF_LIBCEF_BROWSER_BROWSER_MAIN_H_
#pragma once
#include "libcef/browser/net/url_request_context_getter_impl.h"
#include "libcef/browser/net/url_request_context_getter.h"
#include "libcef/browser/request_context_impl.h"
#include "base/macros.h"

View File

@@ -7,11 +7,16 @@
#include "libcef/common/content_client.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_pump.h"
#include "base/message_loop/message_pump_for_ui.h"
#if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/message_loop/message_pump_mac.h"
#endif
#include "content/public/browser/browser_thread.h"
namespace {
// MessagePump implementation that delegates to OnScheduleMessagePumpWork() for
@@ -82,23 +87,27 @@ CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
return nullptr;
}
std::unique_ptr<base::MessagePump> CreatePump() {
const CefSettings& settings = CefContext::Get()->settings();
if (settings.external_message_pump) {
std::unique_ptr<base::MessagePump> MessagePumpFactoryForUI() {
if (!content::BrowserThread::IsThreadInitialized(
content::BrowserThread::UI) ||
content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
CefRefPtr<CefBrowserProcessHandler> handler = GetBrowserProcessHandler();
if (handler)
return base::WrapUnique(new MessagePumpExternal(0.01f, handler));
return std::make_unique<MessagePumpExternal>(0.01f, handler);
}
return base::MessageLoop::CreateMessagePumpForType(
base::MessageLoop::TYPE_UI);
#if defined(OS_MACOSX)
return base::MessagePumpMac::Create();
#else
return std::make_unique<base::MessagePumpForUI>();
#endif
}
} // namespace
CefBrowserMessageLoop::CefBrowserMessageLoop()
: base::MessageLoopForUI(CreatePump()) {
BindToCurrentThread();
void InitMessagePumpFactoryForUI() {
const CefSettings& settings = CefContext::Get()->settings();
if (settings.external_message_pump) {
base::MessagePump::OverrideMessagePumpForUIFactory(MessagePumpFactoryForUI);
}
}
CefBrowserMessageLoop::~CefBrowserMessageLoop() {}

View File

@@ -4,21 +4,7 @@
#ifndef CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_
#define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_
#pragma once
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
// Class used to process events on the current message loop.
class CefBrowserMessageLoop : public base::MessageLoopForUI {
typedef base::MessageLoopForUI inherited;
public:
CefBrowserMessageLoop();
~CefBrowserMessageLoop() override;
private:
DISALLOW_COPY_AND_ASSIGN(CefBrowserMessageLoop);
};
void InitMessagePumpFactoryForUI();
#endif // CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_

View File

@@ -22,6 +22,7 @@ namespace blink {
class WebMouseEvent;
class WebMouseWheelEvent;
class WebInputEvent;
class WebTouchEvent;
} // namespace blink
namespace content {
@@ -150,6 +151,9 @@ class CefBrowserPlatformDelegate {
virtual void SendMouseEvent(const blink::WebMouseEvent& event) = 0;
virtual void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event) = 0;
// Send touch events.
virtual void SendTouchEvent(const CefTouchEvent& event) = 0;
// Send focus event. The browser's WebContents may be NULL when this method is
// called.
virtual void SendFocusEvent(bool setFocus) = 0;
@@ -180,7 +184,7 @@ class CefBrowserPlatformDelegate {
const content::NativeWebKeyboardEvent& event) = 0;
// Invoke platform specific handling for the external protocol.
virtual void HandleExternalProtocol(const GURL& url) = 0;
static void HandleExternalProtocol(const GURL& url);
// Translate CEF events to Chromium/Blink events.
virtual void TranslateKeyEvent(content::NativeWebKeyboardEvent& result,

View File

@@ -46,7 +46,7 @@ std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
window_info, background_color);
#elif defined(OS_LINUX)
return std::make_unique<CefBrowserPlatformDelegateNativeLinux>(
window_info, background_color);
window_info, background_color, use_external_begin_frame);
#endif
}

View File

@@ -5,17 +5,25 @@
#include "libcef/browser/chrome_browser_process_stub.h"
#include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/chrome_profile_manager_stub.h"
#include "libcef/browser/context.h"
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/net_service/util.h"
#include "base/command_line.h"
#include "chrome/browser/net/chrome_net_log_helper.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/ui/prefs/pref_watcher.h"
#include "components/net_log/chrome_net_log.h"
#include "components/net_log/net_export_file_writer.h"
#include "components/prefs/pref_service.h"
#include "content/browser/startup_helper.h"
#include "content/public/common/content_switches.h"
#include "net/log/net_log_capture_mode.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
@@ -23,14 +31,10 @@ ChromeBrowserProcessStub::ChromeBrowserProcessStub()
: initialized_(false),
context_initialized_(false),
shutdown_(false),
locale_("en-US") {
chrome::SetBrowserContextIncognitoHelper(this);
}
locale_("en-US") {}
ChromeBrowserProcessStub::~ChromeBrowserProcessStub() {
DCHECK((!initialized_ && !context_initialized_) || shutdown_);
g_browser_process = NULL;
chrome::SetBrowserContextIncognitoHelper(nullptr);
}
void ChromeBrowserProcessStub::Initialize() {
@@ -38,6 +42,9 @@ void ChromeBrowserProcessStub::Initialize() {
DCHECK(!context_initialized_);
DCHECK(!shutdown_);
// Initialize this early before any code tries to check feature flags.
content::SetUpFieldTrialsAndFeatureList();
initialized_ = true;
}
@@ -70,16 +77,31 @@ void ChromeBrowserProcessStub::Shutdown() {
profile_manager_.reset();
event_router_forwarder_ = nullptr;
if (net_service::IsEnabled() && SystemNetworkContextManager::GetInstance()) {
SystemNetworkContextManager::DeleteInstance();
}
// Release any references to |local_state_| that are held by objects
// associated with a Profile. The Profile will be deleted later.
for (const auto& profile : CefBrowserContext::GetAll()) {
PrefWatcher* pref_watcher = PrefWatcher::Get(profile);
if (pref_watcher)
pref_watcher->Shutdown();
}
local_state_.reset();
browser_policy_connector_.reset();
shutdown_ = true;
}
void ChromeBrowserProcessStub::ResourceDispatcherHostCreated() {
NOTREACHED();
};
}
void ChromeBrowserProcessStub::EndSession() {
NOTREACHED();
};
}
void ChromeBrowserProcessStub::FlushLocalStateAndReply(
base::OnceClosure reply) {
@@ -108,8 +130,8 @@ IOThread* ChromeBrowserProcessStub::io_thread() {
SystemNetworkContextManager*
ChromeBrowserProcessStub::system_network_context_manager() {
NOTREACHED();
return NULL;
DCHECK(SystemNetworkContextManager::GetInstance());
return SystemNetworkContextManager::GetInstance();
}
net_log::NetExportFileWriter*
@@ -137,9 +159,17 @@ ProfileManager* ChromeBrowserProcessStub::profile_manager() {
}
PrefService* ChromeBrowserProcessStub::local_state() {
DCHECK(context_initialized_);
return profile_manager_->GetLastUsedProfile(profile_manager_->user_data_dir())
->GetPrefs();
DCHECK(initialized_);
if (!local_state_) {
const CefSettings& settings = CefContext::Get()->settings();
const base::FilePath& cache_path =
base::FilePath(CefString(&settings.cache_path));
// Used for very early NetworkService initialization.
local_state_ = browser_prefs::CreatePrefService(
nullptr, cache_path, !!settings.persist_user_preferences);
}
return local_state_.get();
}
net::URLRequestContextGetter*
@@ -183,13 +213,15 @@ ChromeBrowserProcessStub::notification_platform_bridge() {
policy::ChromeBrowserPolicyConnector*
ChromeBrowserProcessStub::browser_policy_connector() {
NOTREACHED();
return NULL;
if (!browser_policy_connector_) {
browser_policy_connector_ =
std::make_unique<policy::ChromeBrowserPolicyConnector>();
}
return browser_policy_connector_.get();
}
policy::PolicyService* ChromeBrowserProcessStub::policy_service() {
NOTREACHED();
return NULL;
return browser_policy_connector()->GetPolicyService();
}
IconManager* ChromeBrowserProcessStub::icon_manager() {
@@ -295,6 +327,11 @@ ChromeBrowserProcessStub::optimization_guide_service() {
return NULL;
}
StartupData* ChromeBrowserProcessStub::startup_data() {
NOTREACHED();
return NULL;
}
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
void ChromeBrowserProcessStub::StartAutoupdateTimer() {}
#endif
@@ -308,7 +345,8 @@ net_log::ChromeNetLog* ChromeBrowserProcessStub::net_log() {
if (command_line.HasSwitch(network::switches::kLogNetLog)) {
net_log_->StartWritingToFile(
command_line.GetSwitchValuePath(network::switches::kLogNetLog),
GetNetCaptureModeFromCommandLine(command_line),
net::GetNetCaptureModeFromCommandLine(command_line,
network::switches::kLogNetLog),
command_line.GetCommandLineString(), std::string());
}
}
@@ -371,15 +409,3 @@ ChromeBrowserProcessStub::pref_service_factory() const {
NOTREACHED();
return NULL;
}
content::BrowserContext*
ChromeBrowserProcessStub::GetBrowserContextRedirectedInIncognito(
content::BrowserContext* context) {
return CefBrowserContextImpl::GetForContext(context);
}
content::BrowserContext*
ChromeBrowserProcessStub::GetBrowserContextOwnInstanceInIncognito(
content::BrowserContext* context) {
return GetBrowserContextRedirectedInIncognito(context);
}

View File

@@ -15,7 +15,6 @@
#include "base/compiler_specific.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "media/media_buildflags.h"
class ChromeProfileManagerStub;
@@ -29,8 +28,7 @@ class BackgroundModeManager {
DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager);
};
class ChromeBrowserProcessStub : public BrowserProcess,
public chrome::BrowserContextIncognitoHelper {
class ChromeBrowserProcessStub : public BrowserProcess {
public:
ChromeBrowserProcessStub();
~ChromeBrowserProcessStub() override;
@@ -89,6 +87,7 @@ class ChromeBrowserProcessStub : public BrowserProcess,
override;
optimization_guide::OptimizationGuideService* optimization_guide_service()
override;
StartupData* startup_data() override;
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
void StartAutoupdateTimer() override;
@@ -109,12 +108,6 @@ class ChromeBrowserProcessStub : public BrowserProcess,
override;
prefs::InProcessPrefServiceFactory* pref_service_factory() const override;
// BrowserContextIncognitoHelper implementation.
content::BrowserContext* GetBrowserContextRedirectedInIncognito(
content::BrowserContext* context) override;
content::BrowserContext* GetBrowserContextOwnInstanceInIncognito(
content::BrowserContext* context) override;
private:
bool initialized_;
bool context_initialized_;
@@ -126,6 +119,10 @@ class ChromeBrowserProcessStub : public BrowserProcess,
scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
std::unique_ptr<net_log::ChromeNetLog> net_log_;
std::unique_ptr<net_log::NetExportFileWriter> net_export_file_writer_;
std::unique_ptr<PrefService> local_state_;
// Must be destroyed after |local_state_|.
std::unique_ptr<policy::ChromeBrowserPolicyConnector>
browser_policy_connector_;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProcessStub);
};

View File

@@ -5,7 +5,7 @@
#include "libcef/browser/chrome_profile_manager_stub.h"
#include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/content_browser_client.h"
namespace {
@@ -20,8 +20,8 @@ namespace {
// context for the currently active browser (e.g. the browser with input focus).
// Return the main context for now since we don't currently have a good way to
// determine that.
CefBrowserContextImpl* GetActiveBrowserContext() {
return static_cast<CefBrowserContextImpl*>(
CefBrowserContext* GetActiveBrowserContext() {
return static_cast<CefBrowserContext*>(
CefContentBrowserClient::Get()->request_context()->GetBrowserContext());
}
@@ -34,8 +34,8 @@ ChromeProfileManagerStub::~ChromeProfileManagerStub() {}
Profile* ChromeProfileManagerStub::GetProfile(
const base::FilePath& profile_dir) {
CefBrowserContextImpl* browser_context =
CefBrowserContextImpl::GetForCachePath(profile_dir);
CefBrowserContext* browser_context =
CefBrowserContext::GetForCachePath(profile_dir);
if (!browser_context) {
// ProfileManager makes assumptions about profile directory paths that do
// not match CEF usage. For example, the default Chrome profile name is
@@ -51,7 +51,7 @@ Profile* ChromeProfileManagerStub::GetProfile(
bool ChromeProfileManagerStub::IsValidProfile(const void* profile) {
if (!profile)
return false;
return !!CefBrowserContextImpl::GetForContext(
return !!CefBrowserContext::GetForContext(
reinterpret_cast<content::BrowserContext*>(const_cast<void*>(profile)));
}

View File

@@ -8,7 +8,7 @@
#include <utility>
#include "include/cef_version.h"
#include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h"
@@ -16,10 +16,15 @@
#include "libcef/browser/browser_message_filter.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools_manager_delegate.h"
#include "libcef/browser/devtools/devtools_manager_delegate.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/extensions/extension_web_contents_observer.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/net/chrome_scheme_handler.h"
#include "libcef/browser/net/net_util.h"
#include "libcef/browser/net_service/login_delegate.h"
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
#include "libcef/browser/plugins/plugin_service_filter.h"
#include "libcef/browser/prefs/renderer_prefs.h"
#include "libcef/browser/printing/printing_message_filter.h"
@@ -34,12 +39,13 @@
#include "libcef/common/content_client.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net/scheme_registration.h"
#include "libcef/common/net_service/util.h"
#include "libcef/common/request_impl.h"
#include "libcef/common/service_manifests/builtin_service_manifests.h"
#include "libcef/common/service_manifests/cef_content_browser_overlay_manifest.h"
#include "libcef/common/service_manifests/cef_content_gpu_overlay_manifest.h"
#include "libcef/common/service_manifests/cef_content_renderer_overlay_manifest.h"
#include "libcef/common/service_manifests/cef_content_utility_overlay_manifest.h"
#include "libcef/common/service_manifests/cef_packaged_service_manifests.h"
#include "libcef/common/service_manifests/cef_renderer_manifest.h"
#include "base/base_switches.h"
@@ -48,20 +54,32 @@
#include "base/json/json_reader.h"
#include "base/path_service.h"
#include "base/stl_util.h"
#include "base/threading/thread_restrictions.h"
#include "cef/grit/cef_resources.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/chrome_service.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/plugins/plugin_info_host_impl.h"
#include "chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.h"
#include "chrome/browser/plugins/plugin_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/constants.mojom.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/services/printing/printing_service.h"
#include "chrome/services/printing/public/mojom/constants.mojom.h"
#include "components/navigation_interception/intercept_navigation_throttle.h"
#include "components/navigation_interception/navigation_params.h"
#include "components/services/heap_profiling/heap_profiling_service.h"
#include "components/services/heap_profiling/public/mojom/constants.mojom.h"
#include "components/services/pdf_compositor/public/cpp/pdf_compositor_service_factory.h"
#include "components/services/pdf_compositor/public/interfaces/pdf_compositor.mojom.h"
#include "components/version_info/version_info.h"
#include "content/browser/frame_host/navigation_handle_impl.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/plugin_service_impl.h"
@@ -80,12 +98,13 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_ui_url_loader_factory.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/service_names.mojom.h"
#include "content/public/common/storage_quota_params.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/user_agent.h"
#include "content/public/common/web_preferences.h"
#include "extensions/browser/api/web_request/web_request_api.h"
#include "extensions/browser/extension_message_filter.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/extension_registry.h"
@@ -95,8 +114,13 @@
#include "extensions/browser/io_thread_extension_message_filter.h"
#include "extensions/common/constants.h"
#include "extensions/common/switches.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/auth.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "ppapi/host/ppapi_host.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/proxy_resolver/proxy_resolver_service.h"
#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
#include "services/service_manager/embedder/switches.h"
#include "services/service_manager/public/mojom/connector.mojom.h"
#include "services/service_manager/sandbox/switches.h"
@@ -320,8 +344,8 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext {
bool handled = false;
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForFrame(render_process_id,
params.render_frame_id);
CefBrowserHostImpl::GetBrowserForFrameRoute(render_process_id,
params.render_frame_id);
if (browser.get()) {
CefRefPtr<CefClient> client = browser->GetClient();
if (client.get()) {
@@ -413,8 +437,9 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
// |is_main_frame| argument once this problem is fixed.
bool NavigationOnUIThread(
bool is_main_frame,
int64 frame_id,
int64 parent_frame_id,
int64_t frame_id,
int64_t parent_frame_id,
int frame_tree_node_id,
content::WebContents* source,
const navigation_interception::NavigationParams& params) {
CEF_REQUIRE_UIT();
@@ -433,13 +458,14 @@ bool NavigationOnUIThread(
frame = browser->GetMainFrame();
} else if (frame_id >= 0) {
frame = browser->GetFrame(frame_id);
DCHECK(frame);
} else {
}
if (!frame && frame_tree_node_id >= 0) {
frame = browser->GetFrameForFrameTreeNode(frame_tree_node_id);
}
if (!frame) {
// Create a temporary frame object for navigation of sub-frames that
// don't yet exist.
frame = new CefFrameHostImpl(
browser.get(), CefFrameHostImpl::kInvalidFrameId, false,
CefString(), CefString(), parent_frame_id);
frame = browser->browser_info()->CreateTempSubFrame(parent_frame_id);
}
CefRefPtr<CefRequestImpl> request = new CefRequestImpl();
@@ -461,6 +487,30 @@ bool NavigationOnUIThread(
return ignore_navigation;
}
const extensions::ExtensionSet* GetEnabledExtensions(
content::BrowserContext* context) {
auto registry = extensions::ExtensionRegistry::Get(context);
return &registry->enabled_extensions();
}
const extensions::ExtensionSet* GetEnabledExtensions(
content::ResourceContext* context) {
auto cef_context = static_cast<CefResourceContext*>(context);
if (!cef_context)
return nullptr;
return &cef_context->GetExtensionInfoMap()->extensions();
}
const extensions::ExtensionSet* GetEnabledExtensions(
content::BrowserOrResourceContext context) {
if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
return GetEnabledExtensions(context.ToBrowserContext());
}
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
return GetEnabledExtensions(context.ToResourceContext());
}
} // namespace
CefContentBrowserClient::CefContentBrowserClient() : browser_main_parts_(NULL) {
@@ -479,12 +529,13 @@ CefContentBrowserClient* CefContentBrowserClient::Get() {
CefContentClient::Get()->browser());
}
content::BrowserMainParts* CefContentBrowserClient::CreateBrowserMainParts(
std::unique_ptr<content::BrowserMainParts>
CefContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
browser_main_parts_ = new CefBrowserMainParts(parameters);
browser_main_parts_->AddParts(
ChromeService::GetInstance()->CreateExtraParts());
return browser_main_parts_;
return base::WrapUnique(browser_main_parts_);
}
void CefContentBrowserClient::RenderProcessWillLaunch(
@@ -513,16 +564,16 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
host->Send(
new CefProcessMsg_SetIsIncognitoProcess(profile->IsOffTheRecord()));
service_manager::mojom::ServicePtr service;
service_manager::mojom::ServicePtrInfo service;
*service_request = mojo::MakeRequest(&service);
service_manager::mojom::PIDReceiverPtr pid_receiver;
service_manager::Identity renderer_identity = host->GetChildIdentity();
mojo::Remote<service_manager::mojom::ProcessMetadata> metadata;
ChromeService::GetInstance()->connector()->RegisterServiceInstance(
service_manager::Identity(chrome::mojom::kRendererServiceName,
renderer_identity.instance_group(),
renderer_identity.instance_id(),
base::Token::CreateRandom()),
std::move(service), mojo::MakeRequest(&pid_receiver));
std::move(service), metadata.BindNewPipeAndPassReceiver());
}
bool CefContentBrowserClient::ShouldUseProcessPerSite(
@@ -552,6 +603,47 @@ bool CefContentBrowserClient::ShouldUseProcessPerSite(
return true;
}
// Based on
// ChromeContentBrowserClientExtensionsPart::DoesSiteRequireDedicatedProcess.
bool CefContentBrowserClient::DoesSiteRequireDedicatedProcess(
content::BrowserOrResourceContext browser_or_resource_context,
const GURL& effective_site_url) {
if (!extensions::ExtensionsEnabled())
return false;
auto extension = GetEnabledExtensions(browser_or_resource_context)
->GetExtensionOrAppByURL(effective_site_url);
// Isolate all extensions.
return extension != nullptr;
}
void CefContentBrowserClient::GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) {
// Any schemes listed here are treated as WebUI schemes but do not get WebUI
// bindings. Also, view-source is allowed for these schemes. WebUI schemes
// will not be passed to HandleExternalProtocol.
}
void CefContentBrowserClient::GetAdditionalViewSourceSchemes(
std::vector<std::string>* additional_schemes) {
GetAdditionalWebUISchemes(additional_schemes);
additional_schemes->push_back(extensions::kExtensionScheme);
}
void CefContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* additional_allowed_schemes) {
ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
additional_allowed_schemes);
additional_allowed_schemes->push_back(content::kChromeDevToolsScheme);
additional_allowed_schemes->push_back(content::kChromeUIScheme);
}
bool CefContentBrowserClient::IsWebUIAllowedToMakeNetworkRequests(
const url::Origin& origin) {
return scheme::IsWebUIAllowedToMakeNetworkRequests(origin);
}
bool CefContentBrowserClient::IsHandledURL(const GURL& url) {
if (!url.is_valid())
return false;
@@ -620,23 +712,41 @@ void CefContentBrowserClient::SiteInstanceDeleting(
site_instance->GetId()));
}
void CefContentBrowserClient::RegisterIOThreadServiceHandlers(
content::ServiceManagerConnection* connection) {
// For spell checking.
connection->AddServiceRequestHandler(
chrome::mojom::kServiceName,
ChromeService::GetInstance()->CreateChromeServiceRequestHandler());
void CefContentBrowserClient::RunServiceInstance(
const service_manager::Identity& identity,
mojo::PendingReceiver<service_manager::mojom::Service>* receiver) {
const std::string& service_name = identity.name();
if (service_name == printing::mojom::kServiceName) {
service_manager::Service::RunAsyncUntilTermination(
printing::CreatePdfCompositorService(std::move(*receiver)));
return;
}
if (service_name == printing::mojom::kChromePrintingServiceName) {
service_manager::Service::RunAsyncUntilTermination(
std::make_unique<printing::PrintingService>(std::move(*receiver)));
return;
}
if (service_name == proxy_resolver::mojom::kProxyResolverServiceName) {
service_manager::Service::RunAsyncUntilTermination(
std::make_unique<proxy_resolver::ProxyResolverService>(
std::move(*receiver)));
return;
}
}
void CefContentBrowserClient::RegisterOutOfProcessServices(
OutOfProcessServiceMap* services) {
(*services)[printing::mojom::kServiceName] =
base::BindRepeating(&base::ASCIIToUTF16, "PDF Compositor Service");
(*services)[printing::mojom::kChromePrintingServiceName] =
base::BindRepeating(&base::ASCIIToUTF16, "Printing Service");
(*services)[proxy_resolver::mojom::kProxyResolverServiceName] =
base::BindRepeating(&l10n_util::GetStringUTF16,
IDS_UTILITY_PROCESS_PROXY_RESOLVER_NAME);
void CefContentBrowserClient::RunServiceInstanceOnIOThread(
const service_manager::Identity& identity,
mojo::PendingReceiver<service_manager::mojom::Service>* receiver) {
if (identity.name() == chrome::mojom::kServiceName) {
ChromeService::GetInstance()->CreateChromeServiceRequestHandler().Run(
std::move(*receiver));
return;
}
if (identity.name() == heap_profiling::mojom::kServiceName) {
heap_profiling::HeapProfilingService::GetServiceFactory().Run(
std::move(*receiver));
return;
}
}
base::Optional<service_manager::Manifest>
@@ -645,10 +755,6 @@ CefContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
return GetCefContentBrowserOverlayManifest();
} else if (name == content::mojom::kGpuServiceName) {
return GetCefContentGpuOverlayManifest();
} else if (name == content::mojom::kPackagedServicesServiceName) {
service_manager::Manifest overlay;
overlay.packaged_services = GetCefPackagedServiceManifests();
return overlay;
} else if (name == content::mojom::kRendererServiceName) {
return GetCefContentRendererOverlayManifest();
} else if (name == content::mojom::kUtilityServiceName) {
@@ -660,14 +766,9 @@ CefContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
std::vector<service_manager::Manifest>
CefContentBrowserClient::GetExtraServiceManifests() {
return std::vector<service_manager::Manifest>{GetCefRendererManifest()};
}
bool CefContentBrowserClient::IsSameBrowserContext(
content::BrowserContext* context1,
content::BrowserContext* context2) {
return CefBrowserContextImpl::GetForContext(context1) ==
CefBrowserContextImpl::GetForContext(context2);
auto manifests = GetBuiltinServiceManifests();
manifests.push_back(GetCefRendererManifest());
return manifests;
}
void CefContentBrowserClient::AppendExtraCommandLineSwitches(
@@ -682,6 +783,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kDisablePackLoading,
#if defined(OS_MACOSX)
switches::kFrameworkDirPath,
switches::kMainBundlePath,
#endif
switches::kLocalesDirPath,
switches::kLogFile,
@@ -711,7 +813,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kPpapiFlashPath,
switches::kPpapiFlashVersion,
switches::kUncaughtExceptionStackSize,
switches::kUnsafelyTreatInsecureOriginAsSecure,
network::switches::kUnsafelyTreatInsecureOriginAsSecure,
};
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
base::size(kSwitchNames));
@@ -810,7 +912,27 @@ std::string CefContentBrowserClient::GetApplicationLocale() {
return g_browser_process->GetApplicationLocale();
}
content::QuotaPermissionContext*
scoped_refptr<network::SharedURLLoaderFactory>
CefContentBrowserClient::GetSystemSharedURLLoaderFactory() {
DCHECK(
content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ||
!content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI));
if (!SystemNetworkContextManager::GetInstance())
return nullptr;
return SystemNetworkContextManager::GetInstance()
->GetSharedURLLoaderFactory();
}
network::mojom::NetworkContext*
CefContentBrowserClient::GetSystemNetworkContext() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(SystemNetworkContextManager::GetInstance());
return SystemNetworkContextManager::GetInstance()->GetContext();
}
scoped_refptr<content::QuotaPermissionContext>
CefContentBrowserClient::CreateQuotaPermissionContext() {
return new CefQuotaPermissionContext();
}
@@ -821,7 +943,8 @@ void CefContentBrowserClient::GetQuotaSettings(
storage::OptionalQuotaSettingsCallback callback) {
const base::FilePath& cache_path = partition->GetPath();
storage::GetNominalDynamicSettings(
cache_path, cache_path.empty() /* is_incognito */, std::move(callback));
cache_path, cache_path.empty() /* is_incognito */,
storage::GetDefaultDiskInfoHelper(), std::move(callback));
}
content::MediaObserver* CefContentBrowserClient::GetMediaObserver() {
@@ -854,14 +977,14 @@ void CefContentBrowserClient::AllowCertificateError(
int cert_error,
const net::SSLInfo& ssl_info,
const GURL& request_url,
content::ResourceType resource_type,
bool is_main_frame_request,
bool strict_enforcement,
bool expired_previous_decision,
const base::Callback<void(content::CertificateRequestResultType)>&
callback) {
CEF_REQUIRE_UIT();
if (resource_type != content::ResourceType::RESOURCE_TYPE_MAIN_FRAME) {
if (!is_main_frame_request) {
// A sub-resource has a certificate error. The user doesn't really
// have a context for making the right decision, so block the request
// hard.
@@ -1006,34 +1129,50 @@ CefContentBrowserClient::CreateThrottlesForNavigation(
const bool is_main_frame = navigation_handle->IsInMainFrame();
int64 parent_frame_id = CefFrameHostImpl::kUnspecifiedFrameId;
if (!is_main_frame) {
// Identify the RenderFrameHost that originated the navigation.
content::RenderFrameHost* parent_frame_host =
navigation_handle->GetParentFrame();
DCHECK(parent_frame_host);
if (parent_frame_host)
parent_frame_id = parent_frame_host->GetRoutingID();
if (parent_frame_id < 0)
parent_frame_id = CefFrameHostImpl::kUnspecifiedFrameId;
}
// Identify the RenderFrameHost that originated the navigation.
const int64_t parent_frame_id =
!is_main_frame
? CefFrameHostImpl::MakeFrameId(navigation_handle->GetParentFrame())
: CefFrameHostImpl::kInvalidFrameId;
int64 frame_id = CefFrameHostImpl::kInvalidFrameId;
if (!is_main_frame && navigation_handle->HasCommitted()) {
frame_id = navigation_handle->GetRenderFrameHost()->GetRoutingID();
if (frame_id < 0)
frame_id = CefFrameHostImpl::kInvalidFrameId;
}
const int64_t frame_id = !is_main_frame && navigation_handle->HasCommitted()
? CefFrameHostImpl::MakeFrameId(
navigation_handle->GetRenderFrameHost())
: CefFrameHostImpl::kInvalidFrameId;
// Must use SynchronyMode::kSync to ensure that OnBeforeBrowse is always
// called before OnBeforeResourceLoad.
std::unique_ptr<content::NavigationThrottle> throttle =
std::make_unique<navigation_interception::InterceptNavigationThrottle>(
navigation_handle, base::Bind(&NavigationOnUIThread, is_main_frame,
frame_id, parent_frame_id));
navigation_handle,
base::Bind(&NavigationOnUIThread, is_main_frame, frame_id,
parent_frame_id, navigation_handle->GetFrameTreeNodeId()),
navigation_interception::SynchronyMode::kSync);
throttles.push_back(std::move(throttle));
return throttles;
}
std::vector<std::unique_ptr<content::URLLoaderThrottle>>
CefContentBrowserClient::CreateURLLoaderThrottles(
const network::ResourceRequest& request,
content::ResourceContext* resource_context,
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id) {
CEF_REQUIRE_IOT();
std::vector<std::unique_ptr<content::URLLoaderThrottle>> result;
if (net_service::IsEnabled()) {
// Used to substitute View ID for PDF contents when using the PDF plugin.
result.push_back(
std::make_unique<PluginResponseInterceptorURLLoaderThrottle>(
resource_context, request.resource_type, frame_tree_node_id));
}
return result;
}
#if defined(OS_LINUX)
void CefContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
const base::CommandLine& command_line,
@@ -1087,6 +1226,21 @@ CefContentBrowserClient::CreateClientCertStore(
->CreateClientCertStore();
}
std::unique_ptr<content::LoginDelegate>
CefContentBrowserClient::CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
const content::GlobalRequestID& request_id,
bool is_request_for_main_frame,
const GURL& url,
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback) {
return std::make_unique<net_service::LoginDelegate>(
auth_info, web_contents, request_id, url,
std::move(auth_required_callback));
}
void CefContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
int frame_tree_node_id,
NonNetworkURLLoaderFactoryMap* factories) {
@@ -1113,6 +1267,43 @@ void CefContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
render_frame_id);
if (factory)
factories->emplace(extensions::kExtensionScheme, std::move(factory));
content::RenderFrameHost* frame_host =
content::RenderFrameHost::FromID(render_process_id, render_frame_id);
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(frame_host);
if (!web_contents)
return;
extensions::CefExtensionWebContentsObserver* web_observer =
extensions::CefExtensionWebContentsObserver::FromWebContents(
web_contents);
// There is nothing to do if no CefExtensionWebContentsObserver is attached
// to the |web_contents|.
if (!web_observer)
return;
const extensions::Extension* extension =
web_observer->GetExtensionFromFrame(frame_host, false);
if (!extension)
return;
std::vector<std::string> allowed_webui_hosts;
// Support for chrome:// scheme if appropriate.
if ((extension->is_extension() || extension->is_platform_app()) &&
extensions::Manifest::IsComponentLocation(extension->location())) {
// Components of chrome that are implemented as extensions or platform apps
// are allowed to use chrome://resources/ and chrome://theme/ URLs.
allowed_webui_hosts.emplace_back(content::kChromeUIResourcesHost);
allowed_webui_hosts.emplace_back(chrome::kChromeUIThemeHost);
}
if (!allowed_webui_hosts.empty()) {
factories->emplace(
content::kChromeUIScheme,
content::CreateWebUIURLLoader(frame_host, content::kChromeUIScheme,
std::move(allowed_webui_hosts)));
}
}
bool CefContentBrowserClient::WillCreateURLLoaderFactory(
@@ -1120,22 +1311,67 @@ bool CefContentBrowserClient::WillCreateURLLoaderFactory(
content::RenderFrameHost* frame,
int render_process_id,
bool is_navigation,
bool is_download,
const url::Origin& request_initiator,
network::mojom::URLLoaderFactoryRequest* factory_request,
network::mojom::TrustedURLLoaderHeaderClientPtrInfo* header_client,
bool* bypass_redirect_checks) {
if (!extensions::ExtensionsEnabled())
if (!net_service::IsEnabled())
return false;
auto* web_request_api =
extensions::BrowserContextKeyedAPIFactory<extensions::WebRequestAPI>::Get(
browser_context);
bool use_proxy = web_request_api->MaybeProxyURLLoaderFactory(
browser_context, frame, render_process_id, is_navigation, factory_request,
header_client);
if (bypass_redirect_checks)
*bypass_redirect_checks = use_proxy;
return use_proxy;
auto request_handler = net_service::CreateInterceptedRequestHandler(
browser_context, frame, render_process_id, is_navigation, is_download,
request_initiator);
net_service::ProxyURLLoaderFactory::CreateProxy(
browser_context, factory_request, header_client,
std::move(request_handler));
return true;
}
void CefContentBrowserClient::OnNetworkServiceCreated(
network::mojom::NetworkService* network_service) {
if (!net_service::IsEnabled())
return;
DCHECK(g_browser_process);
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);
// Need to set up global NetworkService state before anything else uses it.
DCHECK(SystemNetworkContextManager::GetInstance());
SystemNetworkContextManager::GetInstance()->OnNetworkServiceCreated(
network_service);
}
network::mojom::NetworkContextPtr CefContentBrowserClient::CreateNetworkContext(
content::BrowserContext* context,
bool in_memory,
const base::FilePath& relative_partition_path) {
Profile* profile = Profile::FromBrowserContext(context);
return profile->CreateNetworkContext(in_memory, relative_partition_path);
}
// The sandbox may block read/write access from the NetworkService to
// directories that are not returned by this method.
std::vector<base::FilePath>
CefContentBrowserClient::GetNetworkContextsParentDirectory() {
base::FilePath user_data_path;
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_path);
DCHECK(!user_data_path.empty());
// The CefContext::ValidateCachePath method enforces the requirement that all
// cache_path values be either equal to or a child of root_cache_path.
const base::FilePath& root_cache_path =
base::FilePath(CefString(&CefContext::Get()->settings().root_cache_path));
// root_cache_path may sometimes be empty or a child of user_data_path, so
// only return the one path in that case.
if (root_cache_path.empty() || user_data_path.IsParent(root_cache_path)) {
return {user_data_path};
}
return {user_data_path, root_cache_path};
}
bool CefContentBrowserClient::HandleExternalProtocol(
@@ -1146,39 +1382,76 @@ bool CefContentBrowserClient::HandleExternalProtocol(
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const std::string& method,
const net::HttpRequestHeaders& headers) {
CEF_POST_TASK(
CEF_UIT,
base::Bind(
base::IgnoreResult(
&CefContentBrowserClient::HandleExternalProtocolOnUIThread),
url, web_contents_getter));
network::mojom::URLLoaderFactoryRequest* factory_request,
network::mojom::URLLoaderFactory*& out_factory) {
if (net_service::IsEnabled()) {
// Call the other HandleExternalProtocol variant.
return false;
}
CefRefPtr<CefRequestImpl> requestPtr = new CefRequestImpl();
requestPtr->SetURL(url.spec());
requestPtr->SetReadOnly(true);
net_util::HandleExternalProtocol(requestPtr, web_contents_getter);
return false;
}
std::string CefContentBrowserClient::GetProduct() const {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kProductVersion))
return command_line->GetSwitchValueASCII(switches::kProductVersion);
bool CefContentBrowserClient::HandleExternalProtocol(
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
const network::ResourceRequest& request,
network::mojom::URLLoaderFactoryRequest* factory_request,
network::mojom::URLLoaderFactory*& out_factory) {
DCHECK(net_service::IsEnabled());
// CefBrowserPlatformDelegate::HandleExternalProtocol may be called if
// nothing handles the request.
auto request_handler = net_service::CreateInterceptedRequestHandler(
web_contents_getter, frame_tree_node_id, request);
out_factory = net_service::ProxyURLLoaderFactory::CreateProxy(
web_contents_getter, factory_request, std::move(request_handler));
return true;
}
return GetChromeProduct();
std::string CefContentBrowserClient::GetProduct() const {
// Match the logic in chrome_content_browser_client.cc GetProduct() which
// will be called when the NetworkService is enabled.
return ::GetProduct();
}
std::string CefContentBrowserClient::GetChromeProduct() const {
return base::StringPrintf("Chrome/%d.%d.%d.%d", CHROME_VERSION_MAJOR,
CHROME_VERSION_MINOR, CHROME_VERSION_BUILD,
CHROME_VERSION_PATCH);
return version_info::GetProductNameAndVersionForUserAgent();
}
std::string CefContentBrowserClient::GetUserAgent() const {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kUserAgent))
return command_line->GetSwitchValueASCII(switches::kUserAgent);
// Match the logic in chrome_content_browser_client.cc GetUserAgent() which
// will be called when the NetworkService is enabled.
return ::GetUserAgent();
}
return content::BuildUserAgentFromProduct(GetProduct());
blink::UserAgentMetadata CefContentBrowserClient::GetUserAgentMetadata() const {
blink::UserAgentMetadata metadata;
metadata.brand = version_info::GetProductName();
metadata.full_version = version_info::GetVersionNumber();
metadata.platform = version_info::GetOSType();
// TODO(mkwst): Poke at BuildUserAgentFromProduct to split out these pieces.
metadata.architecture = "";
metadata.model = "";
return metadata;
}
base::flat_set<std::string>
CefContentBrowserClient::GetPluginMimeTypesWithExternalHandlers(
content::ResourceContext* resource_context) {
base::flat_set<std::string> mime_types;
auto map = PluginUtils::GetMimeTypeToExtensionIdMap(resource_context);
for (const auto& pair : map)
mime_types.insert(pair.first);
return mime_types;
}
void CefContentBrowserClient::RegisterCustomScheme(const std::string& scheme) {
@@ -1224,18 +1497,3 @@ const extensions::Extension* CefContentBrowserClient::GetExtension(
return registry->enabled_extensions().GetExtensionOrAppByURL(
site_instance->GetSiteURL());
}
// static
void CefContentBrowserClient::HandleExternalProtocolOnUIThread(
const GURL& url,
const content::ResourceRequestInfo::WebContentsGetter&
web_contents_getter) {
CEF_REQUIRE_UIT();
content::WebContents* web_contents = web_contents_getter.Run();
if (web_contents) {
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForContents(web_contents);
if (browser.get())
browser->HandleExternalProtocol(url);
}
}

View File

@@ -10,7 +10,7 @@
#include <utility>
#include "include/cef_request_context_handler.h"
#include "libcef/browser/net/url_request_context_getter_impl.h"
#include "libcef/browser/net/url_request_context_getter.h"
#include "libcef/browser/request_context_impl.h"
#include "base/macros.h"
@@ -41,24 +41,37 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
static CefContentBrowserClient* Get();
// ContentBrowserClient implementation.
content::BrowserMainParts* CreateBrowserMainParts(
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
const content::MainFunctionParams& parameters) override;
void RenderProcessWillLaunch(
content::RenderProcessHost* host,
service_manager::mojom::ServiceRequest* service_request) override;
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
const GURL& effective_url) override;
bool DoesSiteRequireDedicatedProcess(
content::BrowserOrResourceContext browser_or_resource_contexts,
const GURL& effective_site_url) override;
void GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) override;
void GetAdditionalViewSourceSchemes(
std::vector<std::string>* additional_schemes) override;
void GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* additional_allowed_schemes) override;
bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) override;
bool IsHandledURL(const GURL& url) override;
void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
void RegisterIOThreadServiceHandlers(
content::ServiceManagerConnection* connection) override;
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
void RunServiceInstance(
const service_manager::Identity& identity,
mojo::PendingReceiver<service_manager::mojom::Service>* receiver)
override;
void RunServiceInstanceOnIOThread(
const service_manager::Identity& identity,
mojo::PendingReceiver<service_manager::mojom::Service>* receiver)
override;
base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
base::StringPiece name) override;
std::vector<service_manager::Manifest> GetExtraServiceManifests() override;
bool IsSameBrowserContext(content::BrowserContext* context1,
content::BrowserContext* context2) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override;
void AdjustUtilityServiceProcessCommandLine(
@@ -66,7 +79,11 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
base::CommandLine* command_line) override;
bool ShouldEnableStrictSiteIsolation() override;
std::string GetApplicationLocale() override;
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
scoped_refptr<network::SharedURLLoaderFactory>
GetSystemSharedURLLoaderFactory() override;
network::mojom::NetworkContext* GetSystemNetworkContext() override;
scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext()
override;
void GetQuotaSettings(
content::BrowserContext* context,
content::StoragePartition* partition,
@@ -81,7 +98,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
int cert_error,
const net::SSLInfo& ssl_info,
const GURL& request_url,
content::ResourceType resource_type,
bool is_main_frame_request,
bool strict_enforcement,
bool expired_previous_decision,
const base::Callback<void(content::CertificateRequestResultType)>&
@@ -114,6 +131,13 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
std::vector<std::unique_ptr<content::NavigationThrottle>>
CreateThrottlesForNavigation(
content::NavigationHandle* navigation_handle) override;
std::vector<std::unique_ptr<content::URLLoaderThrottle>>
CreateURLLoaderThrottles(
const network::ResourceRequest& request,
content::ResourceContext* resource_context,
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id) override;
#if defined(OS_LINUX)
void GetAdditionalMappedFilesForChildProcess(
@@ -131,10 +155,17 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* render_process_host) override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
content::ResourceContext* resource_context) override;
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
const content::GlobalRequestID& request_id,
bool is_request_for_main_frame,
const GURL& url,
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback) override;
void RegisterNonNetworkNavigationURLLoaderFactories(
int frame_tree_node_id,
NonNetworkURLLoaderFactoryMap* factories) override;
@@ -147,11 +178,18 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
content::RenderFrameHost* frame,
int render_process_id,
bool is_navigation,
bool is_download,
const url::Origin& request_initiator,
network::mojom::URLLoaderFactoryRequest* factory_request,
network::mojom::TrustedURLLoaderHeaderClientPtrInfo* header_client,
bool* bypass_redirect_checks) override;
void OnNetworkServiceCreated(
network::mojom::NetworkService* network_service) override;
network::mojom::NetworkContextPtr CreateNetworkContext(
content::BrowserContext* context,
bool in_memory,
const base::FilePath& relative_partition_path) override;
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
bool HandleExternalProtocol(
const GURL& url,
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
@@ -160,11 +198,21 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const std::string& method,
const net::HttpRequestHeaders& headers) override;
network::mojom::URLLoaderFactoryRequest* factory_request,
network::mojom::URLLoaderFactory*& out_factory) override;
bool HandleExternalProtocol(
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
int frame_tree_node_id,
content::NavigationUIData* navigation_data,
const network::ResourceRequest& request,
network::mojom::URLLoaderFactoryRequest* factory_request,
network::mojom::URLLoaderFactory*& out_factory) override;
std::string GetProduct() const override;
std::string GetChromeProduct() const override;
std::string GetUserAgent() const override;
blink::UserAgentMetadata GetUserAgentMetadata() const override;
base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers(
content::ResourceContext* resource_context) override;
// Perform browser process registration for the custom scheme.
void RegisterCustomScheme(const std::string& scheme);
@@ -181,11 +229,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
const extensions::Extension* GetExtension(
content::SiteInstance* site_instance);
static void HandleExternalProtocolOnUIThread(
const GURL& url,
const content::ResourceRequestInfo::WebContentsGetter&
web_contents_getter);
CefBrowserMainParts* browser_main_parts_;
std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_;

View File

@@ -22,9 +22,9 @@
#include "base/files/file_util.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread_restrictions.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "content/app/content_service_manager_main_delegate.h"
#include "content/browser/startup_helper.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
@@ -35,8 +35,8 @@
#if defined(OS_WIN)
#include "base/strings/utf_string_conversions.h"
#include "chrome/chrome_elf/chrome_elf_main.h"
#include "chrome/install_static/initialize_from_primary_module.h"
#include "chrome_elf/chrome_elf_main.h"
#include "components/crash/content/app/crashpad.h"
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
@@ -370,6 +370,18 @@ bool CefContext::Initialize(const CefMainArgs& args,
SignalChromeElf();
#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 =
base::FilePath(CefString(&settings_.root_cache_path));
if (root_cache_path.empty() && !cache_path.empty()) {
CefString(&settings_.root_cache_path) = CefString(&settings_.cache_path);
}
main_delegate_.reset(new CefMainDelegate(application));
browser_info_manager_.reset(new CefBrowserInfoManager);
@@ -415,26 +427,17 @@ bool CefContext::Initialize(const CefMainArgs& args,
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
// This is required because creating a base::Thread as starting it will
// check some feature flags this will cause a CHECK failure later when this
// gets called by some call down the line of service_manager::MainRun.
content::SetUpFieldTrialsAndFeatureList();
if (!main_delegate_->CreateUIThread()) {
return false;
}
initialized_ = true;
// Can't use CEF_POST_TASK here yet, because the TaskRunner is not yet set.
main_delegate_->ui_thread()->task_runner()->PostTask(
FROM_HERE,
base::BindOnce(
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)));
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();
@@ -537,6 +540,46 @@ void CefContext::PopulateRequestContextSettings(
CefString(&settings_.accept_language_list);
}
bool CefContext::ValidateCachePath(const base::FilePath& cache_path) {
if (cache_path.empty())
return true;
const base::FilePath& root_cache_path =
base::FilePath(CefString(&settings_.root_cache_path));
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;
}
void CefContext::AddObserver(Observer* observer) {
CEF_REQUIRE_UIT();
observers_.AddObserver(observer);
}
void CefContext::RemoveObserver(Observer* observer) {
CEF_REQUIRE_UIT();
observers_.RemoveObserver(observer);
}
bool CefContext::HasObserver(Observer* observer) const {
CEF_REQUIRE_UIT();
return observers_.HasObserver(observer);
}
void CefContext::OnContextInitialized() {
CEF_REQUIRE_UIT();
@@ -563,6 +606,9 @@ void CefContext::FinishShutdownOnUIThread(
browser_info_manager_->DestroyAllBrowsers();
for (auto& observer : observers_)
observer.OnContextDestroyed();
if (trace_subscriber_.get())
trace_subscriber_.reset(NULL);
@@ -590,4 +636,7 @@ void CefContext::FinalizeShutdown() {
sm_main_params_.reset(NULL);
sm_main_delegate_.reset(NULL);
main_delegate_.reset(NULL);
delete g_browser_process;
g_browser_process = NULL;
}

View File

@@ -12,6 +12,7 @@
#include "include/cef_app.h"
#include "base/observer_list.h"
#include "base/threading/platform_thread.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -36,6 +37,17 @@ class CefContext {
public:
typedef std::list<CefRefPtr<CefBrowserHostImpl>> BrowserList;
// Interface to implement for observers that wish to be informed of changes
// to the context. All methods will be called on the UI thread.
class Observer {
public:
// Called before the context is destroyed.
virtual void OnContextDestroyed() = 0;
protected:
virtual ~Observer() {}
};
CefContext();
~CefContext();
@@ -73,10 +85,20 @@ class CefContext {
CefTraceSubscriber* GetTraceSubscriber();
// Populate the request context settings based on CefSettings and command-
// line flags.
// Populate request context settings for the global system context based on
// CefSettings and command-line flags.
void PopulateRequestContextSettings(CefRequestContextSettings* settings);
// Verify that |cache_path| is valid and create it if necessary.
bool ValidateCachePath(const base::FilePath& cache_path);
// Manage observer objects. The observer must either outlive this object or
// remove itself before destruction. These methods can only be called on the
// UI thread.
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
bool HasObserver(Observer* observer) const;
private:
void OnContextInitialized();
@@ -101,6 +123,9 @@ class CefContext {
std::unique_ptr<service_manager::MainParams> sm_main_params_;
std::unique_ptr<CefTraceSubscriber> trace_subscriber_;
std::unique_ptr<CefBrowserInfoManager> browser_info_manager_;
// Observers that want to be notified of changes to this object.
base::ObserverList<Observer>::Unchecked observers_;
};
// Helper macro that returns true if the global context is in a valid state.

View File

@@ -1,648 +0,0 @@
// Copyright (c) 2012 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/cookie_manager_impl.h"
#include <set>
#include <string>
#include <vector>
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/browser/net/cookie_store_source.h"
#include "libcef/browser/net/network_delegate.h"
#include "libcef/common/task_runner_impl.h"
#include "libcef/common/time_util.h"
#include "base/bind.h"
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/browser_process.h"
#include "components/net_log/chrome_net_log.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "net/cookies/cookie_util.h"
#include "net/cookies/parsed_cookie.h"
#include "net/url_request/url_request_context.h"
#include "url/gurl.h"
using content::BrowserThread;
namespace {
// Callback class for visiting cookies.
class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
public:
explicit VisitCookiesCallback(
const CefCookieManagerImpl::CookieStoreGetter& cookie_store_getter,
CefRefPtr<CefCookieVisitor> visitor)
: cookie_store_getter_(cookie_store_getter), visitor_(visitor) {}
void Run(const net::CookieList& list) {
CEF_REQUIRE_IOT();
int total = list.size(), count = 0;
net::CookieList::const_iterator it = list.begin();
for (; it != list.end(); ++it, ++count) {
CefCookie cookie;
const net::CanonicalCookie& cc = *(it);
CefCookieManagerImpl::GetCefCookie(cc, cookie);
bool deleteCookie = false;
bool keepLooping = visitor_->Visit(cookie, count, total, deleteCookie);
if (deleteCookie) {
net::CookieStore* cookie_store = cookie_store_getter_.Run();
if (cookie_store) {
cookie_store->DeleteCanonicalCookieAsync(
cc, net::CookieMonster::DeleteCallback());
}
}
if (!keepLooping)
break;
}
}
private:
friend class base::RefCounted<VisitCookiesCallback>;
~VisitCookiesCallback() {}
CefCookieManagerImpl::CookieStoreGetter cookie_store_getter_;
CefRefPtr<CefCookieVisitor> visitor_;
};
// Methods extracted from net/cookies/cookie_store.cc
// Determine the cookie domain to use for setting the specified cookie.
bool GetCookieDomain(const GURL& url,
const net::ParsedCookie& pc,
std::string* result) {
std::string domain_string;
if (pc.HasDomain())
domain_string = pc.Domain();
return net::cookie_util::GetCookieDomainWithString(url, domain_string,
result);
}
// Always execute the callback asynchronously.
void RunAsyncCompletionOnIOThread(CefRefPtr<CefCompletionCallback> callback) {
if (!callback.get())
return;
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefCompletionCallback::OnComplete, callback.get()));
}
// Always execute the callback asynchronously.
void DeleteCookiesCallbackImpl(CefRefPtr<CefDeleteCookiesCallback> callback,
uint32_t num_deleted) {
if (!callback.get())
return;
CEF_POST_TASK(CEF_IOT, base::Bind(&CefDeleteCookiesCallback::OnComplete,
callback.get(), num_deleted));
}
// Always execute the callback asynchronously.
void SetCookieCallbackImpl(CefRefPtr<CefSetCookieCallback> callback,
bool success) {
if (!callback.get())
return;
CEF_POST_TASK(CEF_IOT, base::Bind(&CefSetCookieCallback::OnComplete,
callback.get(), success));
}
net::CookieStore* GetExistingCookieStoreHelper(
base::WeakPtr<CefCookieManagerImpl> cookie_manager) {
if (cookie_manager.get())
return cookie_manager->GetExistingCookieStore();
return nullptr;
}
} // namespace
CefCookieManagerImpl::CefCookieManagerImpl(bool is_blocking)
: is_blocking_(is_blocking), weak_ptr_factory_(this) {}
CefCookieManagerImpl::~CefCookieManagerImpl() {
CEF_REQUIRE_IOT();
}
void CefCookieManagerImpl::Initialize(
CefRefPtr<CefRequestContextImpl> request_context,
const CefString& path,
bool persist_session_cookies,
CefRefPtr<CefCompletionCallback> callback) {
CHECK(!is_blocking_);
if (request_context.get()) {
request_context_ = request_context;
request_context_->GetRequestContextImpl(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
base::Bind(&CefCookieManagerImpl::InitWithContext, this, callback));
} else {
SetStoragePath(path, persist_session_cookies, callback);
}
}
void CefCookieManagerImpl::GetCookieStore(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
const CookieStoreCallback& callback) {
if (!task_runner.get())
task_runner = CefTaskRunnerImpl::GetCurrentTaskRunner();
if (!CEF_CURRENTLY_ON_IOT()) {
CEF_POST_TASK(CEF_IOT, base::Bind(&CefCookieManagerImpl::GetCookieStore,
this, task_runner, callback));
return;
}
if (HasContext()) {
RunMethodWithContext(
base::Bind(&CefCookieManagerImpl::GetCookieStoreWithContext, this,
task_runner, callback));
return;
}
DCHECK(is_blocking_ || cookie_source_);
// Binding ref-counted |this| to CookieStoreGetter may result in
// heap-use-after-free if (a) the CookieStoreGetter contains the last
// CefCookieManagerImpl reference and (b) that reference is released during
// execution of a CookieMonster callback (which then results in the
// CookieManager being deleted). Use WeakPtr instead of |this| so that, in
// that case, the CookieStoreGetter will return nullptr instead of keeping
// the CefCookieManagerImpl alive (see issue #1882).
const CookieStoreGetter& cookie_store_getter =
base::Bind(GetExistingCookieStoreHelper, weak_ptr_factory_.GetWeakPtr());
if (task_runner->BelongsToCurrentThread()) {
// Execute the callback immediately.
callback.Run(cookie_store_getter);
} else {
// Execute the callback on the target thread.
task_runner->PostTask(FROM_HERE, base::Bind(callback, cookie_store_getter));
}
}
net::CookieStore* CefCookieManagerImpl::GetExistingCookieStore() {
CEF_REQUIRE_IOT();
if (cookie_source_) {
return cookie_source_->GetCookieStore();
} else if (request_context_impl_.get()) {
net::CookieStore* cookie_store =
request_context_impl_->GetExistingCookieStore();
DCHECK(cookie_store);
return cookie_store;
}
DCHECK(is_blocking_);
if (!is_blocking_)
LOG(ERROR) << "Cookie store does not exist";
return nullptr;
}
void CefCookieManagerImpl::SetSupportedSchemes(
const std::vector<CefString>& schemes,
CefRefPtr<CefCompletionCallback> callback) {
if (!CEF_CURRENTLY_ON_IOT()) {
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefCookieManagerImpl::SetSupportedSchemes, this,
schemes, callback));
return;
}
std::vector<std::string> scheme_set;
std::vector<CefString>::const_iterator it = schemes.begin();
for (; it != schemes.end(); ++it)
scheme_set.push_back(*it);
SetSupportedSchemesInternal(scheme_set, callback);
}
bool CefCookieManagerImpl::VisitAllCookies(
CefRefPtr<CefCookieVisitor> visitor) {
GetCookieStore(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
base::Bind(&CefCookieManagerImpl::VisitAllCookiesInternal, this,
visitor));
return true;
}
bool CefCookieManagerImpl::VisitUrlCookies(
const CefString& url,
bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor) {
GetCookieStore(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
base::Bind(&CefCookieManagerImpl::VisitUrlCookiesInternal, this, url,
includeHttpOnly, visitor));
return true;
}
bool CefCookieManagerImpl::SetCookie(const CefString& url,
const CefCookie& cookie,
CefRefPtr<CefSetCookieCallback> callback) {
GURL gurl = GURL(url.ToString());
if (!gurl.is_valid())
return false;
GetCookieStore(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
base::Bind(&CefCookieManagerImpl::SetCookieInternal, this, gurl, cookie,
callback));
return true;
}
bool CefCookieManagerImpl::DeleteCookies(
const CefString& url,
const CefString& cookie_name,
CefRefPtr<CefDeleteCookiesCallback> callback) {
// Empty URLs are allowed but not invalid URLs.
GURL gurl = GURL(url.ToString());
if (!gurl.is_empty() && !gurl.is_valid())
return false;
GetCookieStore(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
base::Bind(&CefCookieManagerImpl::DeleteCookiesInternal, this, gurl,
cookie_name, callback));
return true;
}
bool CefCookieManagerImpl::SetStoragePath(
const CefString& path,
bool persist_session_cookies,
CefRefPtr<CefCompletionCallback> callback) {
if (!CEF_CURRENTLY_ON_IOT()) {
CEF_POST_TASK(
CEF_IOT,
base::Bind(base::IgnoreResult(&CefCookieManagerImpl::SetStoragePath),
this, path, persist_session_cookies, callback));
return true;
}
if (HasContext()) {
RunMethodWithContext(
base::Bind(&CefCookieManagerImpl::SetStoragePathWithContext, this, path,
persist_session_cookies, callback));
return true;
}
base::FilePath new_path;
if (!path.empty())
new_path = base::FilePath(path);
if (!cookie_source_) {
cookie_source_.reset(new CefCookieStoreOwnerSource());
}
cookie_source_->SetCookieStoragePath(new_path, persist_session_cookies,
g_browser_process->net_log());
RunAsyncCompletionOnIOThread(callback);
return true;
}
bool CefCookieManagerImpl::FlushStore(
CefRefPtr<CefCompletionCallback> callback) {
GetCookieStore(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
base::Bind(&CefCookieManagerImpl::FlushStoreInternal, this, callback));
return true;
}
// static
bool CefCookieManagerImpl::GetCefCookie(const net::CanonicalCookie& cc,
CefCookie& cookie) {
CefString(&cookie.name).FromString(cc.Name());
CefString(&cookie.value).FromString(cc.Value());
CefString(&cookie.domain).FromString(cc.Domain());
CefString(&cookie.path).FromString(cc.Path());
cookie.secure = cc.IsSecure();
cookie.httponly = cc.IsHttpOnly();
cef_time_from_basetime(cc.CreationDate(), cookie.creation);
cef_time_from_basetime(cc.LastAccessDate(), cookie.last_access);
cookie.has_expires = cc.IsPersistent();
if (cookie.has_expires)
cef_time_from_basetime(cc.ExpiryDate(), cookie.expires);
return true;
}
// static
bool CefCookieManagerImpl::GetCefCookie(const GURL& url,
const std::string& cookie_line,
CefCookie& cookie) {
// Parse the cookie.
net::ParsedCookie pc(cookie_line);
if (!pc.IsValid())
return false;
std::string cookie_domain;
if (!GetCookieDomain(url, pc, &cookie_domain))
return false;
std::string path_string;
if (pc.HasPath())
path_string = pc.Path();
std::string cookie_path =
net::CanonicalCookie::CanonPathWithString(url, path_string);
base::Time creation_time = base::Time::Now();
base::Time cookie_expires =
net::CanonicalCookie::CanonExpiration(pc, creation_time, creation_time);
CefString(&cookie.name).FromString(pc.Name());
CefString(&cookie.value).FromString(pc.Value());
CefString(&cookie.domain).FromString(cookie_domain);
CefString(&cookie.path).FromString(cookie_path);
cookie.secure = pc.IsSecure();
cookie.httponly = pc.IsHttpOnly();
cef_time_from_basetime(creation_time, cookie.creation);
cef_time_from_basetime(creation_time, cookie.last_access);
cookie.has_expires = !cookie_expires.is_null();
if (cookie.has_expires)
cef_time_from_basetime(cookie_expires, cookie.expires);
return true;
}
// static
void CefCookieManagerImpl::SetCookieMonsterSchemes(
net::CookieMonster* cookie_monster,
const std::vector<std::string>& schemes) {
CEF_REQUIRE_IOT();
std::vector<std::string> all_schemes = schemes;
// Add default schemes that should always support cookies.
all_schemes.push_back("http");
all_schemes.push_back("https");
all_schemes.push_back("ws");
all_schemes.push_back("wss");
cookie_monster->SetCookieableSchemes(all_schemes);
}
bool CefCookieManagerImpl::HasContext() {
CEF_REQUIRE_IOT();
return (request_context_impl_.get() || request_context_.get());
}
void CefCookieManagerImpl::RunMethodWithContext(
const CefRequestContextImpl::RequestContextCallback& method) {
CEF_REQUIRE_IOT();
if (request_context_impl_.get()) {
method.Run(request_context_impl_);
} else if (request_context_.get()) {
// Try again after the request context is initialized.
request_context_->GetRequestContextImpl(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
method);
} else {
NOTREACHED();
}
}
void CefCookieManagerImpl::InitWithContext(
CefRefPtr<CefCompletionCallback> callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context) {
CEF_REQUIRE_IOT();
DCHECK(!request_context_impl_.get());
request_context_impl_ = request_context;
// Clear the CefRequestContextImpl reference here to avoid a potential
// reference loop between CefRequestContextImpl (which has a reference to
// CefRequestContextHandler), CefRequestContextHandler (which may keep a
// reference to this object) and this object.
request_context_ = NULL;
RunAsyncCompletionOnIOThread(callback);
}
void CefCookieManagerImpl::SetStoragePathWithContext(
const CefString& path,
bool persist_session_cookies,
CefRefPtr<CefCompletionCallback> callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context) {
CEF_REQUIRE_IOT();
base::FilePath new_path;
if (!path.empty())
new_path = base::FilePath(path);
request_context->SetCookieStoragePath(new_path, persist_session_cookies);
RunAsyncCompletionOnIOThread(callback);
}
void CefCookieManagerImpl::SetSupportedSchemesWithContext(
const std::vector<std::string>& schemes,
CefRefPtr<CefCompletionCallback> callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context) {
CEF_REQUIRE_IOT();
request_context->SetCookieSupportedSchemes(schemes);
RunAsyncCompletionOnIOThread(callback);
}
void CefCookieManagerImpl::GetCookieStoreWithContext(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
const CookieStoreCallback& callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context) {
CEF_REQUIRE_IOT();
DCHECK(request_context->GetExistingCookieStore());
const CookieStoreGetter& cookie_store_getter = base::Bind(
&CefURLRequestContextGetterImpl::GetExistingCookieStore, request_context);
if (task_runner->BelongsToCurrentThread()) {
// Execute the callback immediately.
callback.Run(cookie_store_getter);
} else {
// Execute the callback on the target thread.
task_runner->PostTask(FROM_HERE, base::Bind(callback, cookie_store_getter));
}
}
void CefCookieManagerImpl::SetSupportedSchemesInternal(
const std::vector<std::string>& schemes,
CefRefPtr<CefCompletionCallback> callback) {
CEF_REQUIRE_IOT();
if (HasContext()) {
RunMethodWithContext(
base::Bind(&CefCookieManagerImpl::SetSupportedSchemesWithContext, this,
schemes, callback));
return;
}
DCHECK(is_blocking_ || cookie_source_);
if (cookie_source_) {
cookie_source_->SetCookieSupportedSchemes(schemes);
}
RunAsyncCompletionOnIOThread(callback);
}
void CefCookieManagerImpl::VisitAllCookiesInternal(
CefRefPtr<CefCookieVisitor> visitor,
const CookieStoreGetter& cookie_store_getter) {
CEF_REQUIRE_IOT();
net::CookieStore* cookie_store = cookie_store_getter.Run();
if (!cookie_store)
return;
scoped_refptr<VisitCookiesCallback> callback(
new VisitCookiesCallback(cookie_store_getter, visitor));
cookie_store->GetAllCookiesAsync(
base::Bind(&VisitCookiesCallback::Run, callback.get()));
}
void CefCookieManagerImpl::VisitUrlCookiesInternal(
const CefString& url,
bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor,
const CookieStoreGetter& cookie_store_getter) {
CEF_REQUIRE_IOT();
net::CookieStore* cookie_store = cookie_store_getter.Run();
if (!cookie_store)
return;
net::CookieOptions options;
if (includeHttpOnly)
options.set_include_httponly();
scoped_refptr<VisitCookiesCallback> callback(
new VisitCookiesCallback(cookie_store_getter, visitor));
GURL gurl = GURL(url.ToString());
cookie_store->GetCookieListWithOptionsAsync(
gurl, options, base::Bind(&VisitCookiesCallback::Run, callback.get()));
}
void CefCookieManagerImpl::SetCookieInternal(
const GURL& url,
const CefCookie& cookie,
CefRefPtr<CefSetCookieCallback> callback,
const CookieStoreGetter& cookie_store_getter) {
CEF_REQUIRE_IOT();
net::CookieStore* cookie_store = cookie_store_getter.Run();
if (!cookie_store) {
if (callback.get()) {
CEF_POST_TASK(CEF_IOT, base::Bind(&CefSetCookieCallback::OnComplete,
callback.get(), false));
}
return;
}
std::string name = CefString(&cookie.name).ToString();
std::string value = CefString(&cookie.value).ToString();
std::string domain = CefString(&cookie.domain).ToString();
std::string path = CefString(&cookie.path).ToString();
base::Time expiration_time;
if (cookie.has_expires)
cef_time_to_basetime(cookie.expires, expiration_time);
cookie_store->SetCanonicalCookieAsync(
net::CanonicalCookie::CreateSanitizedCookie(
url, name, value, domain, path,
base::Time(), // Creation time.
expiration_time,
base::Time(), // Last access time.
cookie.secure ? true : false, cookie.httponly ? true : false,
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT),
cookie.secure ? true : false, cookie.httponly ? true : false,
base::Bind(SetCookieCallbackImpl, callback));
}
void CefCookieManagerImpl::DeleteCookiesInternal(
const GURL& url,
const CefString& cookie_name,
CefRefPtr<CefDeleteCookiesCallback> callback,
const CookieStoreGetter& cookie_store_getter) {
CEF_REQUIRE_IOT();
net::CookieStore* cookie_store = cookie_store_getter.Run();
if (!cookie_store) {
if (callback.get()) {
CEF_POST_TASK(CEF_IOT, base::Bind(&CefDeleteCookiesCallback::OnComplete,
callback.get(), 0));
}
return;
}
if (url.is_empty()) {
// Delete all cookies.
cookie_store->DeleteAllAsync(
base::Bind(DeleteCookiesCallbackImpl, callback));
} else if (cookie_name.empty()) {
// Delete all matching host cookies.
net::CookieDeletionInfo delete_info;
delete_info.host = url.host();
cookie_store->DeleteAllMatchingInfoAsync(
delete_info, base::Bind(DeleteCookiesCallbackImpl, callback));
} else {
// Delete all matching host and domain cookies.
cookie_store->DeleteCookieAsync(
url, cookie_name, base::Bind(DeleteCookiesCallbackImpl, callback, -1));
}
}
void CefCookieManagerImpl::FlushStoreInternal(
CefRefPtr<CefCompletionCallback> callback,
const CookieStoreGetter& cookie_store_getter) {
CEF_REQUIRE_IOT();
net::CookieStore* cookie_store = cookie_store_getter.Run();
if (!cookie_store) {
RunAsyncCompletionOnIOThread(callback);
return;
}
cookie_store->FlushStore(base::Bind(RunAsyncCompletionOnIOThread, callback));
}
// CefCookieManager methods ----------------------------------------------------
// static
CefRefPtr<CefCookieManager> CefCookieManager::GetGlobalManager(
CefRefPtr<CefCompletionCallback> callback) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return NULL;
}
return CefRequestContext::GetGlobalContext()->GetDefaultCookieManager(
callback);
}
// static
CefRefPtr<CefCookieManager> CefCookieManager::GetBlockingManager() {
return new CefCookieManagerImpl(true);
}
// static
CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
const CefString& path,
bool persist_session_cookies,
CefRefPtr<CefCompletionCallback> callback) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return NULL;
}
CefRefPtr<CefCookieManagerImpl> cookie_manager =
new CefCookieManagerImpl(false);
cookie_manager->Initialize(NULL, path, persist_session_cookies, callback);
return cookie_manager.get();
}

View File

@@ -0,0 +1,203 @@
// Copyright 2019 The Chromium Embedded Framework Authors. Portions copyright
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "libcef/browser/devtools/devtools_file_manager.h"
#include "libcef/browser/browser_host_impl.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/value_conversions.h"
#include "base/values.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/web_contents.h"
namespace {
base::LazyInstance<base::FilePath>::Leaky g_last_save_path =
LAZY_INSTANCE_INITIALIZER;
void WriteToFile(const base::FilePath& path, const std::string& content) {
DCHECK(!path.empty());
base::WriteFile(path, content.c_str(), content.length());
}
void AppendToFile(const base::FilePath& path, const std::string& content) {
DCHECK(!path.empty());
base::AppendToFile(path, content.c_str(), content.size());
}
} // namespace
CefDevToolsFileManager::CefDevToolsFileManager(CefBrowserHostImpl* browser_impl,
PrefService* prefs)
: browser_impl_(browser_impl),
prefs_(prefs),
file_task_runner_(
base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()})),
weak_factory_(this) {}
void CefDevToolsFileManager::SaveToFile(const std::string& url,
const std::string& content,
bool save_as) {
Save(url, content, save_as,
base::Bind(&CefDevToolsFileManager::FileSavedAs,
weak_factory_.GetWeakPtr(), url),
base::Bind(&CefDevToolsFileManager::CanceledFileSaveAs,
weak_factory_.GetWeakPtr(), url));
}
void CefDevToolsFileManager::AppendToFile(const std::string& url,
const std::string& content) {
Append(url, content,
base::Bind(&CefDevToolsFileManager::AppendedTo,
weak_factory_.GetWeakPtr(), url));
}
void CefDevToolsFileManager::Save(const std::string& url,
const std::string& content,
bool save_as,
const SaveCallback& saveCallback,
const CancelCallback& cancelCallback) {
auto it = saved_files_.find(url);
if (it != saved_files_.end() && !save_as) {
SaveAsFileSelected(url, content, saveCallback, it->second);
return;
}
const base::DictionaryValue* file_map =
prefs_->GetDictionary(prefs::kDevToolsEditedFiles);
base::FilePath initial_path;
const base::Value* path_value;
if (file_map->Get(base::MD5String(url), &path_value)) {
// Ignore base::GetValueAsFilePath() failure since we handle empty
// |initial_path| below.
ignore_result(base::GetValueAsFilePath(*path_value, &initial_path));
}
if (initial_path.empty()) {
GURL gurl(url);
std::string suggested_file_name =
gurl.is_valid() ? gurl.ExtractFileName() : url;
if (suggested_file_name.length() > 64)
suggested_file_name = suggested_file_name.substr(0, 64);
if (!g_last_save_path.Pointer()->empty()) {
initial_path = g_last_save_path.Pointer()->DirName().AppendASCII(
suggested_file_name);
} else {
// Use the temp directory. It may be an empty value.
base::PathService::Get(base::DIR_TEMP, &initial_path);
initial_path = initial_path.AppendASCII(suggested_file_name);
}
}
CefFileDialogRunner::FileChooserParams params;
params.mode = blink::mojom::FileChooserParams::Mode::kSave;
if (!initial_path.empty()) {
params.default_file_name = initial_path;
if (!initial_path.Extension().empty()) {
params.accept_types.push_back(CefString(initial_path.Extension()));
}
}
browser_impl_->RunFileChooser(
params, base::Bind(&CefDevToolsFileManager::SaveAsDialogDismissed,
weak_factory_.GetWeakPtr(), url, content, saveCallback,
cancelCallback));
}
void CefDevToolsFileManager::SaveAsDialogDismissed(
const std::string& url,
const std::string& content,
const SaveCallback& saveCallback,
const CancelCallback& cancelCallback,
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths) {
if (file_paths.size() == 1) {
SaveAsFileSelected(url, content, saveCallback, file_paths[0]);
} else {
cancelCallback.Run();
}
}
void CefDevToolsFileManager::SaveAsFileSelected(const std::string& url,
const std::string& content,
const SaveCallback& callback,
const base::FilePath& path) {
*g_last_save_path.Pointer() = path;
saved_files_[url] = path;
DictionaryPrefUpdate update(prefs_, prefs::kDevToolsEditedFiles);
base::DictionaryValue* files_map = update.Get();
files_map->SetKey(base::MD5String(url), base::CreateFilePathValue(path));
std::string file_system_path = path.AsUTF8Unsafe();
callback.Run(file_system_path);
file_task_runner_->PostTask(FROM_HERE,
base::BindOnce(&::WriteToFile, path, content));
}
void CefDevToolsFileManager::FileSavedAs(const std::string& url,
const std::string& file_system_path) {
base::Value url_value(url);
base::Value file_system_path_value(file_system_path);
CallClientFunction("DevToolsAPI.savedURL", &url_value,
&file_system_path_value, NULL);
}
void CefDevToolsFileManager::CanceledFileSaveAs(const std::string& url) {
base::Value url_value(url);
CallClientFunction("DevToolsAPI.canceledSaveURL", &url_value, NULL, NULL);
}
void CefDevToolsFileManager::Append(const std::string& url,
const std::string& content,
const AppendCallback& callback) {
auto it = saved_files_.find(url);
if (it == saved_files_.end())
return;
callback.Run();
file_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&::AppendToFile, it->second, content));
}
void CefDevToolsFileManager::AppendedTo(const std::string& url) {
base::Value url_value(url);
CallClientFunction("DevToolsAPI.appendedToURL", &url_value, NULL, NULL);
}
void CefDevToolsFileManager::CallClientFunction(
const std::string& function_name,
const base::Value* arg1,
const base::Value* arg2,
const base::Value* arg3) {
std::string javascript = function_name + "(";
if (arg1) {
std::string json;
base::JSONWriter::Write(*arg1, &json);
javascript.append(json);
if (arg2) {
base::JSONWriter::Write(*arg2, &json);
javascript.append(", ").append(json);
if (arg3) {
base::JSONWriter::Write(*arg3, &json);
javascript.append(", ").append(json);
}
}
}
javascript.append(");");
browser_impl_->web_contents()->GetMainFrame()->ExecuteJavaScript(
base::UTF8ToUTF16(javascript), base::NullCallback());
}

View File

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

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