blob: dc47b33efa16379cbad6f4addcc04e1764613d63 [file] [log] [blame]
[email protected]f81fa202012-10-25 23:32:281// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
fanjinsongdb647e042017-06-09 20:26:455#ifndef ANDROID_WEBVIEW_BROWSER_AW_CONTENT_BROWSER_CLIENT_H_
6#define ANDROID_WEBVIEW_BROWSER_AW_CONTENT_BROWSER_CLIENT_H_
[email protected]f81fa202012-10-25 23:32:287
avide7d5c22015-12-20 05:48:448#include <stddef.h>
9
dcheng08daa072016-04-01 01:47:2110#include <memory>
11
[email protected]f81fa202012-10-25 23:32:2812#include "base/compiler_specific.h"
avide7d5c22015-12-20 05:48:4413#include "base/macros.h"
Yuzhu Shen7a6f47e2017-08-09 06:03:5114#include "base/memory/ref_counted.h"
[email protected]6bd30072013-02-08 18:17:1115#include "content/public/browser/content_browser_client.h"
Ben Goodger6a695c012017-06-20 20:21:2016#include "services/service_manager/public/cpp/binder_registry.h"
17
18namespace content {
19class RenderFrameHost;
20}
[email protected]f81fa202012-10-25 23:32:2821
John Abd-El-Malek3d318642017-12-20 15:21:3622namespace net {
23class NetLog;
24}
25
Yuzhu Shen7a6f47e2017-08-09 06:03:5126namespace safe_browsing {
27class UrlCheckerDelegate;
28}
29
[email protected]f81fa202012-10-25 23:32:2830namespace android_webview {
31
[email protected]2a3a0592013-02-22 18:53:0432class AwBrowserContext;
[email protected]2a3a0592013-02-22 18:53:0433
[email protected]f81fa202012-10-25 23:32:2834class AwContentBrowserClient : public content::ContentBrowserClient {
35 public:
[email protected]eabbfb12013-04-05 23:28:3536 // This is what AwContentBrowserClient::GetAcceptLangs uses.
37 static std::string GetAcceptLangsImpl();
38
[email protected]14a2df0d2013-06-14 23:40:3239 // Deprecated: use AwBrowserContext::GetDefault() instead.
[email protected]eabbfb12013-04-05 23:28:3540 static AwBrowserContext* GetAwBrowserContext();
[email protected]ce507cb2012-12-11 23:42:2241
fanjinsong2ad97e62017-06-10 23:42:2142 AwContentBrowserClient();
dcheng996c125c2015-02-04 02:25:4943 ~AwContentBrowserClient() override;
[email protected]f81fa202012-10-25 23:32:2844
ben5be0b9132016-08-03 00:17:1845 // Allows AwBrowserMainParts to initialize a BrowserContext at the right
46 // moment during startup. AwContentBrowserClient owns the result.
47 AwBrowserContext* InitBrowserContext();
48
dcheng996c125c2015-02-04 02:25:4949 content::BrowserMainParts* CreateBrowserMainParts(
mostynbd731a4912014-10-07 13:36:1150 const content::MainFunctionParams& parameters) override;
dcheng996c125c2015-02-04 02:25:4951 content::WebContentsViewDelegate* GetWebContentsViewDelegate(
mostynbd731a4912014-10-07 13:36:1152 content::WebContents* web_contents) override;
Ben Goodger16331302018-01-23 00:43:2153 void RenderProcessWillLaunch(
54 content::RenderProcessHost* host,
55 service_manager::mojom::ServiceRequest* service_request) override;
mnaganovb58eaaa2015-08-13 16:33:3256 bool IsHandledURL(const GURL& url) override;
dcheng996c125c2015-02-04 02:25:4957 void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
58 int child_process_id) override;
59 std::string GetApplicationLocale() override;
60 std::string GetAcceptLangs(content::BrowserContext* context) override;
61 const gfx::ImageSkia* GetDefaultFavicon() override;
62 bool AllowAppCache(const GURL& manifest_url,
63 const GURL& first_party,
64 content::ResourceContext* context) override;
65 bool AllowGetCookie(const GURL& url,
66 const GURL& first_party,
67 const net::CookieList& cookie_list,
68 content::ResourceContext* context,
69 int render_process_id,
70 int render_frame_id) override;
71 bool AllowSetCookie(const GURL& url,
72 const GURL& first_party,
Victor Costan9ab2fe12017-11-16 20:53:3773 const net::CanonicalCookie& cookie,
dcheng996c125c2015-02-04 02:25:4974 content::ResourceContext* context,
75 int render_process_id,
76 int render_frame_id,
jww79aceda2015-12-07 01:56:3477 const net::CookieOptions& options) override;
dcheng996c125c2015-02-04 02:25:4978 void AllowWorkerFileSystem(
[email protected]f81fa202012-10-25 23:32:2879 const GURL& url,
80 content::ResourceContext* context,
dcheng996c125c2015-02-04 02:25:4981 const std::vector<std::pair<int, int>>& render_frames,
mostynbd731a4912014-10-07 13:36:1182 base::Callback<void(bool)> callback) override;
dcheng996c125c2015-02-04 02:25:4983 bool AllowWorkerIndexedDB(
[email protected]f81fa202012-10-25 23:32:2884 const GURL& url,
[email protected]865eb542013-12-19 22:44:4985 const base::string16& name,
[email protected]f81fa202012-10-25 23:32:2886 content::ResourceContext* context,
dcheng996c125c2015-02-04 02:25:4987 const std::vector<std::pair<int, int>>& render_frames) override;
88 content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
michaeln10e5fc352017-02-07 02:07:5889 void GetQuotaSettings(
90 content::BrowserContext* context,
91 content::StoragePartition* partition,
taptede6d878e2017-06-24 01:53:4592 storage::OptionalQuotaSettingsCallback callback) override;
dcheng996c125c2015-02-04 02:25:4993 void AllowCertificateError(
clamy0d32d6d2015-11-24 11:16:2694 content::WebContents* web_contents,
[email protected]f81fa202012-10-25 23:32:2895 int cert_error,
96 const net::SSLInfo& ssl_info,
97 const GURL& request_url,
[email protected]6c1e05212014-07-31 00:59:4098 content::ResourceType resource_type,
[email protected]f81fa202012-10-25 23:32:2899 bool strict_enforcement,
[email protected]83c13fe2014-08-15 04:49:10100 bool expired_previous_decision,
estark719dde52016-08-09 03:14:27101 const base::Callback<void(content::CertificateRequestResultType)>&
102 callback) override;
dcheng996c125c2015-02-04 02:25:49103 void SelectClientCertificate(
davidben3b8455ae72015-03-11 19:42:19104 content::WebContents* web_contents,
[email protected]55bcca92013-10-25 04:14:54105 net::SSLCertRequestInfo* cert_request_info,
mattm436ccfe2017-06-19 20:24:08106 net::ClientCertIdentityList client_certs,
dcheng08daa072016-04-01 01:47:21107 std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
csharrison95f01e922017-04-24 18:52:35108 bool CanCreateWindow(content::RenderFrameHost* opener,
nick5ae4d2d2017-01-06 01:18:35109 const GURL& opener_url,
dcheng996c125c2015-02-04 02:25:49110 const GURL& opener_top_level_frame_url,
111 const GURL& source_origin,
scottmgde42fb92017-02-10 17:56:03112 content::mojom::WindowContainerType container_type,
dcheng996c125c2015-02-04 02:25:49113 const GURL& target_url,
114 const content::Referrer& referrer,
jochen67b271b2016-08-03 13:50:21115 const std::string& frame_name,
dcheng996c125c2015-02-04 02:25:49116 WindowOpenDisposition disposition,
scottmg8e6c6082017-02-13 23:15:48117 const blink::mojom::WindowFeatures& features,
dcheng996c125c2015-02-04 02:25:49118 bool user_gesture,
119 bool opener_suppressed,
dcheng996c125c2015-02-04 02:25:49120 bool* no_javascript_access) override;
121 void ResourceDispatcherHostCreated() override;
122 net::NetLog* GetNetLog() override;
dcheng996c125c2015-02-04 02:25:49123 base::FilePath GetDefaultDownloadDirectory() override;
124 std::string GetDefaultDownloadName() override;
125 void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
126 bool AllowPepperSocketAPI(
[email protected]157cc902012-11-02 06:31:58127 content::BrowserContext* browser_context,
128 const GURL& url,
[email protected]dda54822013-06-15 01:26:39129 bool private_api,
mostynbd731a4912014-10-07 13:36:11130 const content::SocketPermissionRequest* params) override;
adrian.belgund54465ba2016-05-18 10:03:58131 bool IsPepperVpnProviderAPIAllowed(content::BrowserContext* browser_context,
132 const GURL& url) override;
benjhaydene2136942016-07-20 17:44:09133 content::TracingDelegate* GetTracingDelegate() override;
mnaganovdb95992b2015-08-24 15:41:15134 void GetAdditionalMappedFilesForChildProcess(
135 const base::CommandLine& command_line,
136 int child_process_id,
brettw3c98c7d32017-07-25 01:44:20137 content::PosixFileDescriptorInfo* mappings) override;
dcheng996c125c2015-02-04 02:25:49138 void OverrideWebkitPrefs(content::RenderViewHost* rvh,
dcheng996c125c2015-02-04 02:25:49139 content::WebPreferences* web_prefs) override;
avid6d88b912017-01-13 00:16:00140 std::vector<std::unique_ptr<content::NavigationThrottle>>
141 CreateThrottlesForNavigation(
clamy40c9e142015-09-29 11:18:47142 content::NavigationHandle* navigation_handle) override;
pfeldman10628762016-09-08 07:59:26143 content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
ben275a5652016-10-28 16:55:50144 std::unique_ptr<base::Value> GetServiceManifestOverlay(
sammc2b0375b2016-12-22 01:26:17145 base::StringPiece name) override;
Ben Goodger6a695c012017-06-20 20:21:20146 void BindInterfaceRequestFromFrame(
147 content::RenderFrameHost* render_frame_host,
Ben Goodger6a695c012017-06-20 20:21:20148 const std::string& interface_name,
149 mojo::ScopedMessagePipeHandle interface_pipe) override;
Yuzhu Shen7a6f47e2017-08-09 06:03:51150 void ExposeInterfacesToRenderer(
151 service_manager::BinderRegistry* registry,
Sam McNally52e50282017-11-29 00:54:02152 blink::AssociatedInterfaceRegistry* associated_registry,
Yuzhu Shen7a6f47e2017-08-09 06:03:51153 content::RenderProcessHost* render_process_host) override;
154 std::vector<std::unique_ptr<content::URLLoaderThrottle>>
155 CreateURLLoaderThrottles(
John Abd-El-Malekeb1a5382018-01-05 16:58:00156 const base::Callback<content::WebContents*()>& wc_getter,
157 content::NavigationUIData* navigation_ui_data) override;
John Abd-El-Malek16602432017-09-27 02:46:09158 bool ShouldOverrideUrlLoading(int frame_tree_node_id,
159 bool browser_initiated,
160 const GURL& gurl,
161 const std::string& request_method,
162 bool has_user_gesture,
163 bool is_redirect,
164 bool is_main_frame,
165 ui::PageTransition transition) override;
Pengchengeaf5ae22018-01-18 01:57:17166 bool ShouldCreateTaskScheduler() override;
167
168 static void DisableCreatingTaskScheduler();
[email protected]ce507cb2012-12-11 23:42:22169
[email protected]f81fa202012-10-25 23:32:28170 private:
Yuzhu Shen7a6f47e2017-08-09 06:03:51171 safe_browsing::UrlCheckerDelegate* GetSafeBrowsingUrlCheckerDelegate();
172
John Abd-El-Malek3d318642017-12-20 15:21:36173 std::unique_ptr<net::NetLog> net_log_;
174
[email protected]f81fa202012-10-25 23:32:28175 // Android WebView currently has a single global (non-off-the-record) browser
176 // context.
dcheng08daa072016-04-01 01:47:21177 std::unique_ptr<AwBrowserContext> browser_context_;
[email protected]f81fa202012-10-25 23:32:28178
Ben Goodger21ada1e2017-07-19 14:53:01179 service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>
Ben Goodger6a695c012017-06-20 20:21:20180 frame_interfaces_;
181
Yuzhu Shen7a6f47e2017-08-09 06:03:51182 scoped_refptr<safe_browsing::UrlCheckerDelegate>
183 safe_browsing_url_checker_delegate_;
184
[email protected]f81fa202012-10-25 23:32:28185 DISALLOW_COPY_AND_ASSIGN(AwContentBrowserClient);
186};
187
188} // namespace android_webview
189
fanjinsongdb647e042017-06-09 20:26:45190#endif // ANDROID_WEBVIEW_BROWSER_AW_CONTENT_BROWSER_CLIENT_H_