2012-04-03 03:34:16 +02:00
|
|
|
// 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.
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
|
2012-04-03 03:34:16 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
#include "include/cef_request_context_handler.h"
|
2017-05-04 23:53:27 +02:00
|
|
|
#include "libcef/browser/request_context_impl.h"
|
2013-09-03 18:43:31 +02:00
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
#include "base/memory/ref_counted.h"
|
2016-01-06 20:20:54 +01:00
|
|
|
#include "build/build_config.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/browser/content_browser_client.h"
|
2015-03-04 02:15:50 +01:00
|
|
|
#include "third_party/skia/include/core/SkColor.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
class AlloyBrowserMainParts;
|
2013-09-03 18:43:31 +02:00
|
|
|
class CefDevToolsDelegate;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
namespace content {
|
|
|
|
class SiteInstance;
|
2017-07-27 01:19:27 +02:00
|
|
|
} // namespace content
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2017-02-14 23:27:19 +01:00
|
|
|
namespace extensions {
|
|
|
|
class Extension;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient();
|
|
|
|
~AlloyContentBrowserClient() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
// ContentBrowserClient implementation.
|
2019-07-16 19:59:21 +02:00
|
|
|
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
|
2022-05-19 12:28:44 +02:00
|
|
|
bool is_integration_test) override;
|
2019-10-01 15:55:16 +02:00
|
|
|
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
|
2015-07-16 23:40:01 +02:00
|
|
|
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
|
2021-11-23 21:28:12 +01:00
|
|
|
const GURL& site_url) override;
|
|
|
|
bool ShouldUseSpareRenderProcessHost(content::BrowserContext* browser_context,
|
|
|
|
const GURL& site_url) override;
|
2019-10-01 15:55:16 +02:00
|
|
|
bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context,
|
|
|
|
const GURL& effective_site_url) override;
|
2021-11-23 21:28:12 +01:00
|
|
|
bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
|
|
|
|
base::StringPiece scheme,
|
|
|
|
bool is_embedded_origin_secure) override;
|
|
|
|
bool ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
|
|
|
|
base::StringPiece scheme,
|
|
|
|
bool is_embedded_origin_secure) override;
|
2020-04-22 22:21:08 +02:00
|
|
|
void OverrideURLLoaderFactoryParams(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const url::Origin& origin,
|
|
|
|
bool is_for_isolated_world,
|
|
|
|
network::mojom::URLLoaderFactoryParams* factory_params) override;
|
2019-04-30 22:45:13 +02:00
|
|
|
void GetAdditionalWebUISchemes(
|
|
|
|
std::vector<std::string>* additional_schemes) override;
|
|
|
|
void GetAdditionalViewSourceSchemes(
|
|
|
|
std::vector<std::string>* additional_schemes) override;
|
2022-04-15 21:55:23 +02:00
|
|
|
std::unique_ptr<ui::SelectFilePolicy> CreateSelectFilePolicy(
|
|
|
|
content::WebContents* web_contents) override;
|
2019-04-30 22:45:13 +02:00
|
|
|
void GetAdditionalAllowedSchemesForFileSystem(
|
|
|
|
std::vector<std::string>* additional_allowed_schemes) override;
|
|
|
|
bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
bool IsHandledURL(const GURL& url) override;
|
2016-07-20 20:03:38 +02:00
|
|
|
void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
|
|
|
|
void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
|
2019-10-01 15:55:16 +02:00
|
|
|
void BindHostReceiverForRenderer(
|
|
|
|
content::RenderProcessHost* render_process_host,
|
|
|
|
mojo::GenericPendingReceiver receiver) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
2017-05-17 11:29:28 +02:00
|
|
|
int child_process_id) override;
|
2018-07-09 22:10:03 +02:00
|
|
|
std::string GetApplicationLocale() override;
|
2019-03-21 01:23:23 +01:00
|
|
|
scoped_refptr<network::SharedURLLoaderFactory>
|
|
|
|
GetSystemSharedURLLoaderFactory() override;
|
|
|
|
network::mojom::NetworkContext* GetSystemNetworkContext() override;
|
2019-06-05 16:15:45 +02:00
|
|
|
scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext()
|
|
|
|
override;
|
2014-11-12 20:25:15 +01:00
|
|
|
content::MediaObserver* GetMediaObserver() override;
|
|
|
|
content::SpeechRecognitionManagerDelegate*
|
2017-05-17 11:29:28 +02:00
|
|
|
CreateSpeechRecognitionManagerDelegate() override;
|
2018-11-03 02:15:09 +01:00
|
|
|
content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings(
|
|
|
|
content::BrowserContext* context) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void AllowCertificateError(
|
2015-12-09 17:10:16 +01:00
|
|
|
content::WebContents* web_contents,
|
2013-04-04 19:50:35 +02:00
|
|
|
int cert_error,
|
|
|
|
const net::SSLInfo& ssl_info,
|
|
|
|
const GURL& request_url,
|
2019-07-16 19:59:21 +02:00
|
|
|
bool is_main_frame_request,
|
2013-04-04 19:50:35 +02:00
|
|
|
bool strict_enforcement,
|
2020-02-10 18:10:17 +01:00
|
|
|
base::OnceCallback<void(content::CertificateRequestResultType)> callback)
|
|
|
|
override;
|
2019-09-04 17:13:32 +02:00
|
|
|
base::OnceClosure SelectClientCertificate(
|
2015-05-19 19:55:58 +02:00
|
|
|
content::WebContents* web_contents,
|
|
|
|
net::SSLCertRequestInfo* cert_request_info,
|
2017-07-27 01:19:27 +02:00
|
|
|
net::ClientCertIdentityList client_certs,
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
2017-05-31 17:33:30 +02:00
|
|
|
bool CanCreateWindow(content::RenderFrameHost* opener,
|
2017-01-23 18:36:54 +01:00
|
|
|
const GURL& opener_url,
|
2014-11-12 20:25:15 +01:00
|
|
|
const GURL& opener_top_level_frame_url,
|
2019-01-17 10:56:52 +01:00
|
|
|
const url::Origin& source_origin,
|
2017-03-03 23:37:23 +01:00
|
|
|
content::mojom::WindowContainerType container_type,
|
2014-11-12 20:25:15 +01:00
|
|
|
const GURL& target_url,
|
|
|
|
const content::Referrer& referrer,
|
2016-08-31 13:25:56 +02:00
|
|
|
const std::string& frame_name,
|
2014-11-12 20:25:15 +01:00
|
|
|
WindowOpenDisposition disposition,
|
2017-03-03 23:37:23 +01:00
|
|
|
const blink::mojom::WindowFeatures& features,
|
2014-11-12 20:25:15 +01:00
|
|
|
bool user_gesture,
|
|
|
|
bool opener_suppressed,
|
|
|
|
bool* no_javascript_access) override;
|
2021-03-04 23:36:57 +01:00
|
|
|
void OverrideWebkitPrefs(content::WebContents* web_contents,
|
2020-10-08 21:54:42 +02:00
|
|
|
blink::web_pref::WebPreferences* prefs) override;
|
2020-09-15 18:34:22 +02:00
|
|
|
bool OverrideWebPreferencesAfterNavigation(
|
|
|
|
content::WebContents* web_contents,
|
2020-10-08 21:54:42 +02:00
|
|
|
blink::web_pref::WebPreferences* prefs) override;
|
2017-05-17 11:29:28 +02:00
|
|
|
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
std::string GetDefaultDownloadName() override;
|
2015-03-25 22:22:47 +01:00
|
|
|
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
2021-04-21 00:52:34 +02:00
|
|
|
std::unique_ptr<content::DevToolsManagerDelegate>
|
|
|
|
CreateDevToolsManagerDelegate() override;
|
2022-01-25 21:26:51 +01:00
|
|
|
void RegisterAssociatedInterfaceBindersForRenderFrameHost(
|
|
|
|
content::RenderFrameHost& render_frame_host,
|
|
|
|
blink::AssociatedInterfaceRegistry& associated_registry) override;
|
2017-01-23 18:36:54 +01:00
|
|
|
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
|
|
|
CreateThrottlesForNavigation(
|
2015-10-09 17:23:12 +02:00
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2019-10-01 15:55:16 +02:00
|
|
|
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
|
2019-05-01 21:09:59 +02:00
|
|
|
CreateURLLoaderThrottles(
|
|
|
|
const network::ResourceRequest& request,
|
2019-10-01 15:55:16 +02:00
|
|
|
content::BrowserContext* browser_context,
|
2019-05-01 21:09:59 +02:00
|
|
|
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
|
|
|
|
content::NavigationUIData* navigation_ui_data,
|
|
|
|
int frame_tree_node_id) override;
|
2021-11-23 21:28:12 +01:00
|
|
|
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
|
|
|
|
WillCreateURLLoaderRequestInterceptors(
|
|
|
|
content::NavigationUIData* navigation_ui_data,
|
|
|
|
int frame_tree_node_id,
|
|
|
|
const scoped_refptr<network::SharedURLLoaderFactory>&
|
|
|
|
network_loader_factory) override;
|
2012-11-21 01:40:15 +01:00
|
|
|
|
2022-03-15 20:42:15 +01:00
|
|
|
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
2014-11-12 20:25:15 +01:00
|
|
|
void GetAdditionalMappedFilesForChildProcess(
|
2014-04-04 18:50:38 +02:00
|
|
|
const base::CommandLine& command_line,
|
2013-11-21 23:43:36 +01:00
|
|
|
int child_process_id,
|
2017-09-06 23:40:58 +02:00
|
|
|
content::PosixFileDescriptorInfo* mappings) override;
|
2013-11-21 23:43:36 +01:00
|
|
|
#endif
|
|
|
|
|
2017-07-27 01:19:27 +02:00
|
|
|
void ExposeInterfacesToRenderer(
|
|
|
|
service_manager::BinderRegistry* registry,
|
2017-12-07 22:44:24 +01:00
|
|
|
blink::AssociatedInterfaceRegistry* associated_registry,
|
2017-07-27 01:19:27 +02:00
|
|
|
content::RenderProcessHost* render_process_host) override;
|
2018-03-20 21:15:08 +01:00
|
|
|
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
|
2020-02-10 18:10:17 +01:00
|
|
|
content::BrowserContext* browser_context) override;
|
2019-07-12 22:44:43 +02:00
|
|
|
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;
|
2018-04-19 17:44:42 +02:00
|
|
|
void RegisterNonNetworkNavigationURLLoaderFactories(
|
2018-05-21 14:54:08 +02:00
|
|
|
int frame_tree_node_id,
|
2020-12-02 23:31:49 +01:00
|
|
|
ukm::SourceIdObj ukm_source_id,
|
2018-04-19 17:44:42 +02:00
|
|
|
NonNetworkURLLoaderFactoryMap* factories) override;
|
|
|
|
void RegisterNonNetworkSubresourceURLLoaderFactories(
|
2018-05-21 14:54:08 +02:00
|
|
|
int render_process_id,
|
|
|
|
int render_frame_id,
|
2022-01-25 21:26:51 +01:00
|
|
|
const absl::optional<url::Origin>& request_initiator_origin,
|
2018-04-19 17:44:42 +02:00
|
|
|
NonNetworkURLLoaderFactoryMap* factories) override;
|
|
|
|
bool WillCreateURLLoaderFactory(
|
2018-06-08 18:53:10 +02:00
|
|
|
content::BrowserContext* browser_context,
|
2018-04-19 17:44:42 +02:00
|
|
|
content::RenderFrameHost* frame,
|
2018-12-26 16:12:11 +01:00
|
|
|
int render_process_id,
|
2019-10-01 15:55:16 +02:00
|
|
|
URLLoaderFactoryType type,
|
2018-10-02 14:14:11 +02:00
|
|
|
const url::Origin& request_initiator,
|
2021-06-04 03:34:56 +02:00
|
|
|
absl::optional<int64_t> navigation_id,
|
2020-12-02 23:31:49 +01:00
|
|
|
ukm::SourceIdObj ukm_source_id,
|
2019-09-04 17:13:32 +02:00
|
|
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
2019-10-01 15:55:16 +02:00
|
|
|
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
|
|
|
header_client,
|
2020-02-10 18:10:17 +01:00
|
|
|
bool* bypass_redirect_checks,
|
2020-03-04 01:29:39 +01:00
|
|
|
bool* disable_secure_dns,
|
2020-02-10 18:10:17 +01:00
|
|
|
network::mojom::URLLoaderFactoryOverridePtr* factory_override) override;
|
2019-03-21 01:23:23 +01:00
|
|
|
void OnNetworkServiceCreated(
|
|
|
|
network::mojom::NetworkService* network_service) override;
|
2021-10-19 00:17:16 +02:00
|
|
|
bool ConfigureNetworkContextParams(
|
2019-03-21 01:23:23 +01:00
|
|
|
content::BrowserContext* context,
|
|
|
|
bool in_memory,
|
2020-06-09 19:48:00 +02:00
|
|
|
const base::FilePath& relative_partition_path,
|
|
|
|
network::mojom::NetworkContextParams* network_context_params,
|
2021-03-04 23:36:57 +01:00
|
|
|
cert_verifier::mojom::CertVerifierCreationParams*
|
|
|
|
cert_verifier_creation_params) override;
|
2019-03-21 01:23:23 +01:00
|
|
|
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
|
2018-04-19 17:44:42 +02:00
|
|
|
bool HandleExternalProtocol(
|
|
|
|
const GURL& url,
|
2021-07-23 18:40:13 +02:00
|
|
|
content::WebContents::Getter web_contents_getter,
|
2021-04-21 00:52:34 +02:00
|
|
|
int frame_tree_node_id,
|
2018-04-19 17:44:42 +02:00
|
|
|
content::NavigationUIData* navigation_data,
|
2022-03-26 02:12:30 +01:00
|
|
|
bool is_primary_main_frame,
|
|
|
|
bool is_in_fenced_frame_tree,
|
2021-10-19 00:17:16 +02:00
|
|
|
network::mojom::WebSandboxFlags sandbox_flags,
|
2018-04-19 17:44:42 +02:00
|
|
|
ui::PageTransition page_transition,
|
2018-11-30 23:21:07 +01:00
|
|
|
bool has_user_gesture,
|
2021-06-04 03:34:56 +02:00
|
|
|
const absl::optional<url::Origin>& initiating_origin,
|
2022-01-25 21:26:51 +01:00
|
|
|
content::RenderFrameHost* initiator_document,
|
2020-02-10 18:10:17 +01:00
|
|
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
|
|
|
|
override;
|
2019-04-24 04:50:25 +02:00
|
|
|
bool HandleExternalProtocol(
|
2019-10-01 15:55:16 +02:00
|
|
|
content::WebContents::Getter web_contents_getter,
|
2019-04-24 04:50:25 +02:00
|
|
|
int frame_tree_node_id,
|
|
|
|
content::NavigationUIData* navigation_data,
|
2022-03-26 02:12:30 +01:00
|
|
|
bool is_primary_main_frame,
|
|
|
|
bool is_in_fenced_frame_tree,
|
2021-10-19 00:17:16 +02:00
|
|
|
network::mojom::WebSandboxFlags sandbox_flags,
|
2019-04-24 04:50:25 +02:00
|
|
|
const network::ResourceRequest& request,
|
2022-01-25 21:26:51 +01:00
|
|
|
const absl::optional<url::Origin>& initiating_origin,
|
|
|
|
content::RenderFrameHost* initiator_document,
|
2020-02-10 18:10:17 +01:00
|
|
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
|
|
|
|
override;
|
2022-02-21 23:23:40 +01:00
|
|
|
std::unique_ptr<content::VideoOverlayWindow>
|
|
|
|
CreateWindowForVideoPictureInPicture(
|
|
|
|
content::VideoPictureInPictureWindowController* controller) override;
|
|
|
|
std::unique_ptr<content::DocumentOverlayWindow>
|
|
|
|
CreateWindowForDocumentPictureInPicture(
|
|
|
|
content::DocumentPictureInPictureWindowController* controller) override;
|
2020-02-10 18:10:17 +01:00
|
|
|
void RegisterBrowserInterfaceBindersForFrame(
|
|
|
|
content::RenderFrameHost* render_frame_host,
|
2020-06-09 19:48:00 +02:00
|
|
|
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override;
|
2020-03-30 22:13:42 +02:00
|
|
|
base::FilePath GetSandboxedStorageServiceDataDirectory() override;
|
2019-09-04 17:13:32 +02:00
|
|
|
std::string GetProduct() override;
|
|
|
|
std::string GetChromeProduct() override;
|
|
|
|
std::string GetUserAgent() override;
|
2022-02-21 23:23:40 +01:00
|
|
|
std::string GetFullUserAgent() override;
|
2021-09-20 11:06:23 +02:00
|
|
|
std::string GetReducedUserAgent() override;
|
2022-05-27 11:03:31 +02:00
|
|
|
std::unique_ptr<content::WebContentsViewDelegate> GetWebContentsViewDelegate(
|
|
|
|
content::WebContents* web_contents) override;
|
2019-09-04 17:13:32 +02:00
|
|
|
blink::UserAgentMetadata GetUserAgentMetadata() override;
|
2019-07-24 23:12:00 +02:00
|
|
|
base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers(
|
2019-10-01 15:55:16 +02:00
|
|
|
content::BrowserContext* browser_context) override;
|
2020-09-14 22:26:31 +02:00
|
|
|
bool ArePersistentMediaDeviceIDsAllowed(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const GURL& scope,
|
2021-09-20 11:06:23 +02:00
|
|
|
const net::SiteForCookies& site_for_cookies,
|
2021-06-04 03:34:56 +02:00
|
|
|
const absl::optional<url::Origin>& top_frame_origin) override;
|
2022-02-02 20:45:53 +01:00
|
|
|
void OnWebContentsCreated(content::WebContents* web_contents) override;
|
2021-11-23 21:28:12 +01:00
|
|
|
bool IsFindInPageDisabledForOrigin(const url::Origin& origin) override;
|
2018-04-19 17:44:42 +02:00
|
|
|
|
2017-05-04 23:53:27 +02:00
|
|
|
CefRefPtr<CefRequestContextImpl> request_context() const;
|
2013-09-03 18:43:31 +02:00
|
|
|
CefDevToolsDelegate* devtools_delegate() const;
|
2013-02-23 01:43:28 +01:00
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const;
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const;
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner() const;
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
private:
|
2016-07-20 20:03:38 +02:00
|
|
|
// Returns the extension or app associated with |site_instance| or NULL.
|
|
|
|
const extensions::Extension* GetExtension(
|
|
|
|
content::SiteInstance* site_instance);
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyBrowserMainParts* browser_main_parts_ = nullptr;
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
|