1 // 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.
5 #ifndef ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_
6 #define ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_
8 #include "android_webview/browser/aw_web_preferences_populater.h"
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/content_browser_client.h"
14 namespace android_webview
{
16 class AwBrowserContext
;
17 class JniDependencyFactory
;
19 class AwContentBrowserClient
: public content::ContentBrowserClient
{
21 // This is what AwContentBrowserClient::GetAcceptLangs uses.
22 static std::string
GetAcceptLangsImpl();
24 // Deprecated: use AwBrowserContext::GetDefault() instead.
25 static AwBrowserContext
* GetAwBrowserContext();
27 AwContentBrowserClient(JniDependencyFactory
* native_factory
);
28 virtual ~AwContentBrowserClient();
30 // Overriden methods from ContentBrowserClient.
31 virtual void AddCertificate(net::CertificateMimeType cert_type
,
32 const void* cert_data
,
34 int render_process_id
,
35 int render_frame_id
) override
;
36 virtual content::BrowserMainParts
* CreateBrowserMainParts(
37 const content::MainFunctionParams
& parameters
) override
;
38 virtual content::WebContentsViewDelegate
* GetWebContentsViewDelegate(
39 content::WebContents
* web_contents
) override
;
40 virtual void RenderProcessWillLaunch(
41 content::RenderProcessHost
* host
) override
;
42 virtual net::URLRequestContextGetter
* CreateRequestContext(
43 content::BrowserContext
* browser_context
,
44 content::ProtocolHandlerMap
* protocol_handlers
,
45 content::URLRequestInterceptorScopedVector request_interceptors
) override
;
46 virtual net::URLRequestContextGetter
* CreateRequestContextForStoragePartition(
47 content::BrowserContext
* browser_context
,
48 const base::FilePath
& partition_path
,
50 content::ProtocolHandlerMap
* protocol_handlers
,
51 content::URLRequestInterceptorScopedVector request_interceptors
) override
;
52 virtual std::string
GetCanonicalEncodingNameByAliasName(
53 const std::string
& alias_name
) override
;
54 virtual void AppendExtraCommandLineSwitches(base::CommandLine
* command_line
,
55 int child_process_id
) override
;
56 virtual std::string
GetApplicationLocale() override
;
57 virtual std::string
GetAcceptLangs(content::BrowserContext
* context
) override
;
58 virtual const gfx::ImageSkia
* GetDefaultFavicon() override
;
59 virtual bool AllowAppCache(const GURL
& manifest_url
,
60 const GURL
& first_party
,
61 content::ResourceContext
* context
) override
;
62 virtual bool AllowGetCookie(const GURL
& url
,
63 const GURL
& first_party
,
64 const net::CookieList
& cookie_list
,
65 content::ResourceContext
* context
,
66 int render_process_id
,
67 int render_frame_id
) override
;
68 virtual bool AllowSetCookie(const GURL
& url
,
69 const GURL
& first_party
,
70 const std::string
& cookie_line
,
71 content::ResourceContext
* context
,
72 int render_process_id
,
74 net::CookieOptions
* options
) override
;
75 virtual bool AllowWorkerDatabase(
77 const base::string16
& name
,
78 const base::string16
& display_name
,
79 unsigned long estimated_size
,
80 content::ResourceContext
* context
,
81 const std::vector
<std::pair
<int, int> >& render_frames
) override
;
82 virtual void AllowWorkerFileSystem(
84 content::ResourceContext
* context
,
85 const std::vector
<std::pair
<int, int> >& render_frames
,
86 base::Callback
<void(bool)> callback
) override
;
87 virtual bool AllowWorkerIndexedDB(
89 const base::string16
& name
,
90 content::ResourceContext
* context
,
91 const std::vector
<std::pair
<int, int> >& render_frames
) override
;
92 virtual content::QuotaPermissionContext
*
93 CreateQuotaPermissionContext() override
;
94 virtual void AllowCertificateError(
95 int render_process_id
,
98 const net::SSLInfo
& ssl_info
,
99 const GURL
& request_url
,
100 content::ResourceType resource_type
,
102 bool strict_enforcement
,
103 bool expired_previous_decision
,
104 const base::Callback
<void(bool)>& callback
,
105 content::CertificateRequestResultType
* result
) override
;
106 virtual void SelectClientCertificate(
107 int render_process_id
,
109 net::SSLCertRequestInfo
* cert_request_info
,
110 const base::Callback
<void(net::X509Certificate
*)>& callback
) override
;
111 virtual blink::WebNotificationPermission
112 CheckDesktopNotificationPermission(
113 const GURL
& source_url
,
114 content::ResourceContext
* context
,
115 int render_process_id
) override
;
116 virtual void ShowDesktopNotification(
117 const content::ShowDesktopNotificationHostMsgParams
& params
,
118 content::RenderFrameHost
* render_frame_host
,
119 scoped_ptr
<content::DesktopNotificationDelegate
> delegate
,
120 base::Closure
* cancel_callback
) override
;
121 virtual void RequestGeolocationPermission(
122 content::WebContents
* web_contents
,
124 const GURL
& requesting_frame
,
126 const base::Callback
<void(bool)>& result_callback
) override
;
127 virtual void CancelGeolocationPermissionRequest(
128 content::WebContents
* web_contents
,
130 const GURL
& requesting_frame
) override
;
131 virtual void RequestMidiSysExPermission(
132 content::WebContents
* web_contents
,
134 const GURL
& requesting_frame
,
136 base::Callback
<void(bool)> result_callback
,
137 base::Closure
* cancel_callback
) override
;
138 virtual void RequestProtectedMediaIdentifierPermission(
139 content::WebContents
* web_contents
,
141 base::Callback
<void(bool)> result_callback
,
142 base::Closure
* cancel_callback
) override
;
143 virtual bool CanCreateWindow(const GURL
& opener_url
,
144 const GURL
& opener_top_level_frame_url
,
145 const GURL
& source_origin
,
146 WindowContainerType container_type
,
147 const GURL
& target_url
,
148 const content::Referrer
& referrer
,
149 WindowOpenDisposition disposition
,
150 const blink::WebWindowFeatures
& features
,
152 bool opener_suppressed
,
153 content::ResourceContext
* context
,
154 int render_process_id
,
156 bool* no_javascript_access
) override
;
157 virtual void ResourceDispatcherHostCreated() override
;
158 virtual net::NetLog
* GetNetLog() override
;
159 virtual content::AccessTokenStore
* CreateAccessTokenStore() override
;
160 virtual bool IsFastShutdownPossible() override
;
161 virtual void ClearCache(content::RenderViewHost
* rvh
) override
;
162 virtual void ClearCookies(content::RenderViewHost
* rvh
) override
;
163 virtual base::FilePath
GetDefaultDownloadDirectory() override
;
164 virtual std::string
GetDefaultDownloadName() override
;
165 virtual void DidCreatePpapiPlugin(
166 content::BrowserPpapiHost
* browser_host
) override
;
167 virtual bool AllowPepperSocketAPI(
168 content::BrowserContext
* browser_context
,
171 const content::SocketPermissionRequest
* params
) override
;
172 virtual void OverrideWebkitPrefs(content::RenderViewHost
* rvh
,
174 content::WebPreferences
* web_prefs
) override
;
175 #if defined(VIDEO_HOLE)
176 virtual content::ExternalVideoSurfaceContainer
*
177 OverrideCreateExternalVideoSurfaceContainer(
178 content::WebContents
* web_contents
) override
;
180 virtual content::DevToolsManagerDelegate
*
181 GetDevToolsManagerDelegate() override
;
184 // Android WebView currently has a single global (non-off-the-record) browser
186 scoped_ptr
<AwBrowserContext
> browser_context_
;
187 scoped_ptr
<AwWebPreferencesPopulater
> preferences_populater_
;
189 JniDependencyFactory
* native_factory_
;
191 DISALLOW_COPY_AND_ASSIGN(AwContentBrowserClient
);
194 } // namespace android_webview
196 #endif // ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_