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::Type resource_type
,
102 bool strict_enforcement
,
103 const base::Callback
<void(bool)>& callback
,
104 content::CertificateRequestResultType
* result
) OVERRIDE
;
105 virtual void SelectClientCertificate(
106 int render_process_id
,
108 const net::HttpNetworkSession
* network_session
,
109 net::SSLCertRequestInfo
* cert_request_info
,
110 const base::Callback
<void(net::X509Certificate
*)>& callback
) OVERRIDE
;
111 virtual blink::WebNotificationPresenter::Permission
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 content::DesktopNotificationDelegate
* delegate
,
120 base::Closure
* cancel_callback
) OVERRIDE
;
121 virtual void RequestGeolocationPermission(
122 content::WebContents
* web_contents
,
124 const GURL
& requesting_frame
,
126 base::Callback
<void(bool)> result_callback
,
127 base::Closure
* cancel_callback
) OVERRIDE
;
128 virtual void RequestMidiSysExPermission(
129 content::WebContents
* web_contents
,
131 const GURL
& requesting_frame
,
133 base::Callback
<void(bool)> result_callback
,
134 base::Closure
* cancel_callback
) OVERRIDE
;
135 virtual void RequestProtectedMediaIdentifierPermission(
136 content::WebContents
* web_contents
,
138 base::Callback
<void(bool)> result_callback
,
139 base::Closure
* cancel_callback
) OVERRIDE
;
140 virtual bool CanCreateWindow(const GURL
& opener_url
,
141 const GURL
& opener_top_level_frame_url
,
142 const GURL
& source_origin
,
143 WindowContainerType container_type
,
144 const GURL
& target_url
,
145 const content::Referrer
& referrer
,
146 WindowOpenDisposition disposition
,
147 const blink::WebWindowFeatures
& features
,
149 bool opener_suppressed
,
150 content::ResourceContext
* context
,
151 int render_process_id
,
153 bool* no_javascript_access
) OVERRIDE
;
154 virtual std::string
GetWorkerProcessTitle(
156 content::ResourceContext
* context
) 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 UpdateInspectorSetting(content::RenderViewHost
* rvh
,
162 const std::string
& key
,
163 const std::string
& value
) OVERRIDE
;
164 virtual void ClearCache(content::RenderViewHost
* rvh
) OVERRIDE
;
165 virtual void ClearCookies(content::RenderViewHost
* rvh
) OVERRIDE
;
166 virtual base::FilePath
GetDefaultDownloadDirectory() OVERRIDE
;
167 virtual std::string
GetDefaultDownloadName() OVERRIDE
;
168 virtual void DidCreatePpapiPlugin(
169 content::BrowserPpapiHost
* browser_host
) OVERRIDE
;
170 virtual bool AllowPepperSocketAPI(
171 content::BrowserContext
* browser_context
,
174 const content::SocketPermissionRequest
* params
) OVERRIDE
;
175 virtual void OverrideWebkitPrefs(content::RenderViewHost
* rvh
,
177 content::WebPreferences
* web_prefs
) OVERRIDE
;
178 #if defined(VIDEO_HOLE)
179 virtual content::ExternalVideoSurfaceContainer
*
180 OverrideCreateExternalVideoSurfaceContainer(
181 content::WebContents
* web_contents
) OVERRIDE
;
185 // Android WebView currently has a single global (non-off-the-record) browser
187 scoped_ptr
<AwBrowserContext
> browser_context_
;
188 scoped_ptr
<AwWebPreferencesPopulater
> preferences_populater_
;
190 JniDependencyFactory
* native_factory_
;
192 DISALLOW_COPY_AND_ASSIGN(AwContentBrowserClient
);
195 } // namespace android_webview
197 #endif // ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_