2012-04-03 01:34:16 +00: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.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
|
2013-09-03 16:43:31 +00:00
|
|
|
#include "include/cef_request_context_handler.h"
|
2015-11-25 21:53:12 -05:00
|
|
|
#include "libcef/browser/net/url_request_context_getter_impl.h"
|
2017-05-04 17:53:27 -04:00
|
|
|
#include "libcef/browser/request_context_impl.h"
|
2013-09-03 16:43:31 +00:00
|
|
|
|
2016-01-06 14:20:54 -05:00
|
|
|
#include "base/macros.h"
|
2012-12-30 11:17:49 +00:00
|
|
|
#include "base/memory/ref_counted.h"
|
2016-01-06 14:20:54 -05:00
|
|
|
#include "build/build_config.h"
|
2012-04-03 01:34:16 +00:00
|
|
|
#include "content/public/browser/content_browser_client.h"
|
2015-03-04 01:15:50 +00:00
|
|
|
#include "third_party/skia/include/core/SkColor.h"
|
2012-04-03 01:34:16 +00:00
|
|
|
|
|
|
|
class CefBrowserMainParts;
|
2013-09-03 16:43:31 +00:00
|
|
|
class CefDevToolsDelegate;
|
2012-06-25 21:21:27 +00:00
|
|
|
class CefResourceDispatcherHostDelegate;
|
2012-04-03 01:34:16 +00:00
|
|
|
|
|
|
|
namespace content {
|
2015-09-25 14:59:30 +03:00
|
|
|
class PluginServiceFilter;
|
2012-04-03 01:34:16 +00:00
|
|
|
class SiteInstance;
|
2017-07-26 19:19:27 -04:00
|
|
|
} // namespace content
|
2012-04-03 01:34:16 +00:00
|
|
|
|
2017-02-14 17:27:19 -05:00
|
|
|
namespace extensions {
|
|
|
|
class Extension;
|
|
|
|
}
|
|
|
|
|
2012-04-03 01:34:16 +00:00
|
|
|
class CefContentBrowserClient : public content::ContentBrowserClient {
|
|
|
|
public:
|
|
|
|
CefContentBrowserClient();
|
2014-11-12 19:25:15 +00:00
|
|
|
~CefContentBrowserClient() override;
|
2012-04-03 01:34:16 +00:00
|
|
|
|
2012-11-20 20:08:36 +00:00
|
|
|
// Returns the singleton CefContentBrowserClient instance.
|
|
|
|
static CefContentBrowserClient* Get();
|
|
|
|
|
2013-09-03 16:43:31 +00:00
|
|
|
// ContentBrowserClient implementation.
|
2014-11-12 19:25:15 +00:00
|
|
|
content::BrowserMainParts* CreateBrowserMainParts(
|
|
|
|
const content::MainFunctionParams& parameters) override;
|
2018-03-20 16:15:08 -04:00
|
|
|
void RenderProcessWillLaunch(
|
|
|
|
content::RenderProcessHost* host,
|
|
|
|
service_manager::mojom::ServiceRequest* service_request) override;
|
2015-07-16 17:40:01 -04:00
|
|
|
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
|
|
|
|
const GURL& effective_url) override;
|
2014-11-12 19:25:15 +00:00
|
|
|
bool IsHandledURL(const GURL& url) override;
|
2016-07-20 14:03:38 -04:00
|
|
|
void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
|
|
|
|
void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
|
2019-01-17 10:56:52 +01:00
|
|
|
void RegisterIOThreadServiceHandlers(
|
2018-06-01 15:16:26 -04:00
|
|
|
content::ServiceManagerConnection* connection) override;
|
2017-05-31 17:33:30 +02:00
|
|
|
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
|
2019-01-17 10:56:52 +01:00
|
|
|
base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
|
2017-01-23 12:36:54 -05:00
|
|
|
base::StringPiece name) override;
|
2017-05-31 17:33:30 +02:00
|
|
|
std::vector<ServiceManifestInfo> GetExtraServiceManifests() override;
|
2017-08-03 18:55:19 -04:00
|
|
|
bool IsSameBrowserContext(content::BrowserContext* context1,
|
|
|
|
content::BrowserContext* context2) override;
|
2014-11-12 19:25:15 +00:00
|
|
|
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
2017-05-17 11:29:28 +02:00
|
|
|
int child_process_id) override;
|
2018-09-04 11:43:21 +02:00
|
|
|
bool ShouldEnableStrictSiteIsolation() override;
|
2018-07-09 16:10:03 -04:00
|
|
|
std::string GetApplicationLocale() override;
|
2017-05-17 11:29:28 +02:00
|
|
|
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
|
2017-04-27 14:59:31 -04:00
|
|
|
void GetQuotaSettings(
|
|
|
|
content::BrowserContext* context,
|
|
|
|
content::StoragePartition* partition,
|
2017-07-26 19:19:27 -04:00
|
|
|
storage::OptionalQuotaSettingsCallback callback) override;
|
2014-11-12 19:25:15 +00:00
|
|
|
content::MediaObserver* GetMediaObserver() override;
|
|
|
|
content::SpeechRecognitionManagerDelegate*
|
2017-05-17 11:29:28 +02:00
|
|
|
CreateSpeechRecognitionManagerDelegate() override;
|
2018-11-02 21:15:09 -04:00
|
|
|
content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings(
|
|
|
|
content::BrowserContext* context) override;
|
2014-11-12 19:25:15 +00:00
|
|
|
void AllowCertificateError(
|
2015-12-09 11:10:16 -05:00
|
|
|
content::WebContents* web_contents,
|
2013-04-04 17:50:35 +00:00
|
|
|
int cert_error,
|
|
|
|
const net::SSLInfo& ssl_info,
|
|
|
|
const GURL& request_url,
|
2014-09-04 17:53:40 +00:00
|
|
|
content::ResourceType resource_type,
|
2013-04-04 17:50:35 +00:00
|
|
|
bool strict_enforcement,
|
2014-09-04 17:53:40 +00:00
|
|
|
bool expired_previous_decision,
|
2017-05-17 11:29:28 +02:00
|
|
|
const base::Callback<void(content::CertificateRequestResultType)>&
|
|
|
|
callback) override;
|
2015-05-19 13:55:58 -04:00
|
|
|
void SelectClientCertificate(
|
|
|
|
content::WebContents* web_contents,
|
|
|
|
net::SSLCertRequestInfo* cert_request_info,
|
2017-07-26 19:19:27 -04:00
|
|
|
net::ClientCertIdentityList client_certs,
|
2016-04-27 16:38:52 -04:00
|
|
|
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
2017-05-31 17:33:30 +02:00
|
|
|
bool CanCreateWindow(content::RenderFrameHost* opener,
|
2017-01-23 12:36:54 -05:00
|
|
|
const GURL& opener_url,
|
2014-11-12 19:25:15 +00:00
|
|
|
const GURL& opener_top_level_frame_url,
|
2019-01-17 10:56:52 +01:00
|
|
|
const url::Origin& source_origin,
|
2017-03-03 17:37:23 -05:00
|
|
|
content::mojom::WindowContainerType container_type,
|
2014-11-12 19:25:15 +00:00
|
|
|
const GURL& target_url,
|
|
|
|
const content::Referrer& referrer,
|
2016-08-31 14:25:56 +03:00
|
|
|
const std::string& frame_name,
|
2014-11-12 19:25:15 +00:00
|
|
|
WindowOpenDisposition disposition,
|
2017-03-03 17:37:23 -05:00
|
|
|
const blink::mojom::WindowFeatures& features,
|
2014-11-12 19:25:15 +00:00
|
|
|
bool user_gesture,
|
|
|
|
bool opener_suppressed,
|
|
|
|
bool* no_javascript_access) override;
|
|
|
|
void ResourceDispatcherHostCreated() override;
|
|
|
|
void OverrideWebkitPrefs(content::RenderViewHost* rvh,
|
|
|
|
content::WebPreferences* prefs) override;
|
2017-05-17 11:29:28 +02:00
|
|
|
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
|
2014-11-12 19:25:15 +00:00
|
|
|
std::string GetDefaultDownloadName() override;
|
2015-03-25 17:22:47 -04:00
|
|
|
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
2017-05-17 11:29:28 +02:00
|
|
|
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
2017-01-23 12:36:54 -05:00
|
|
|
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
|
|
|
CreateThrottlesForNavigation(
|
2015-10-09 11:23:12 -04:00
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2012-11-21 00:40:15 +00:00
|
|
|
|
2017-12-07 16:44:24 -05:00
|
|
|
#if defined(OS_LINUX)
|
2014-11-12 19:25:15 +00:00
|
|
|
void GetAdditionalMappedFilesForChildProcess(
|
2014-04-04 16:50:38 +00:00
|
|
|
const base::CommandLine& command_line,
|
2013-11-21 22:43:36 +00:00
|
|
|
int child_process_id,
|
2017-09-06 17:40:58 -04:00
|
|
|
content::PosixFileDescriptorInfo* mappings) override;
|
2013-11-21 22:43:36 +00:00
|
|
|
#endif
|
|
|
|
|
2012-09-10 22:19:19 +00:00
|
|
|
#if defined(OS_WIN)
|
2016-11-23 15:54:29 -05:00
|
|
|
const wchar_t* GetResourceDllName();
|
2015-12-09 11:10:16 -05:00
|
|
|
bool PreSpawnRenderer(sandbox::TargetPolicy* policy) override;
|
2012-09-10 22:19:19 +00:00
|
|
|
#endif
|
2012-04-03 01:34:16 +00:00
|
|
|
|
2017-07-26 19:19:27 -04:00
|
|
|
void ExposeInterfacesToRenderer(
|
|
|
|
service_manager::BinderRegistry* registry,
|
2017-12-07 16:44:24 -05:00
|
|
|
blink::AssociatedInterfaceRegistry* associated_registry,
|
2017-07-26 19:19:27 -04:00
|
|
|
content::RenderProcessHost* render_process_host) override;
|
|
|
|
|
2018-03-20 16:15:08 -04:00
|
|
|
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
|
|
|
|
content::ResourceContext* resource_context) override;
|
|
|
|
|
2018-04-19 11:44:42 -04:00
|
|
|
void RegisterNonNetworkNavigationURLLoaderFactories(
|
2018-05-21 15:54:08 +03:00
|
|
|
int frame_tree_node_id,
|
2018-04-19 11:44:42 -04:00
|
|
|
NonNetworkURLLoaderFactoryMap* factories) override;
|
|
|
|
void RegisterNonNetworkSubresourceURLLoaderFactories(
|
2018-05-21 15:54:08 +03:00
|
|
|
int render_process_id,
|
|
|
|
int render_frame_id,
|
2018-04-19 11:44:42 -04:00
|
|
|
NonNetworkURLLoaderFactoryMap* factories) override;
|
|
|
|
bool WillCreateURLLoaderFactory(
|
2018-06-08 12:53:10 -04:00
|
|
|
content::BrowserContext* browser_context,
|
2018-04-19 11:44:42 -04:00
|
|
|
content::RenderFrameHost* frame,
|
2018-12-26 17:12:11 +02:00
|
|
|
int render_process_id,
|
2018-04-19 11:44:42 -04:00
|
|
|
bool is_navigation,
|
2018-10-02 15:14:11 +03:00
|
|
|
const url::Origin& request_initiator,
|
|
|
|
network::mojom::URLLoaderFactoryRequest* factory_request,
|
2018-12-26 17:12:11 +02:00
|
|
|
network::mojom::TrustedURLLoaderHeaderClientPtrInfo* header_client,
|
2018-10-02 15:14:11 +03:00
|
|
|
bool* bypass_redirect_checks) override;
|
2018-04-19 11:44:42 -04:00
|
|
|
|
|
|
|
bool HandleExternalProtocol(
|
|
|
|
const GURL& url,
|
|
|
|
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
|
|
|
|
int child_id,
|
|
|
|
content::NavigationUIData* navigation_data,
|
|
|
|
bool is_main_frame,
|
|
|
|
ui::PageTransition page_transition,
|
2018-11-30 17:21:07 -05:00
|
|
|
bool has_user_gesture,
|
|
|
|
const std::string& method,
|
|
|
|
const net::HttpRequestHeaders& headers) override;
|
2019-01-17 10:56:52 +01:00
|
|
|
std::string GetProduct() const override;
|
|
|
|
std::string GetChromeProduct() const override;
|
|
|
|
std::string GetUserAgent() const override;
|
2018-04-19 11:44:42 -04:00
|
|
|
|
2013-06-04 23:37:26 +00:00
|
|
|
// Perform browser process registration for the custom scheme.
|
|
|
|
void RegisterCustomScheme(const std::string& scheme);
|
2013-06-04 17:41:37 +00:00
|
|
|
|
2017-05-04 17:53:27 -04:00
|
|
|
CefRefPtr<CefRequestContextImpl> request_context() const;
|
2013-09-03 16:43:31 +00:00
|
|
|
CefDevToolsDelegate* devtools_delegate() const;
|
2013-02-23 00:43:28 +00:00
|
|
|
|
2018-03-20 16:15:08 -04: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 16:43:31 +00:00
|
|
|
private:
|
2016-07-20 14:03:38 -04:00
|
|
|
// Returns the extension or app associated with |site_instance| or NULL.
|
|
|
|
const extensions::Extension* GetExtension(
|
|
|
|
content::SiteInstance* site_instance);
|
|
|
|
|
2018-04-19 11:44:42 -04:00
|
|
|
static void HandleExternalProtocolOnUIThread(
|
|
|
|
const GURL& url,
|
|
|
|
const content::ResourceRequestInfo::WebContentsGetter&
|
|
|
|
web_contents_getter);
|
|
|
|
|
2012-04-03 01:34:16 +00:00
|
|
|
CefBrowserMainParts* browser_main_parts_;
|
|
|
|
|
2016-04-27 16:38:52 -04:00
|
|
|
std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_;
|
|
|
|
std::unique_ptr<CefResourceDispatcherHostDelegate>
|
2012-06-25 21:21:27 +00:00
|
|
|
resource_dispatcher_host_delegate_;
|
2012-04-03 01:34:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
|