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 const net::HttpNetworkSession* network_session,
110 net::SSLCertRequestInfo* cert_request_info,
111 const base::Callback<void(net::X509Certificate*)>& callback) OVERRIDE;
112 virtual blink::WebNotificationPermission
113 CheckDesktopNotificationPermission(
114 const GURL& source_url,
115 content::ResourceContext* context,
116 int render_process_id) OVERRIDE;
117 virtual void ShowDesktopNotification(
118 const content::ShowDesktopNotificationHostMsgParams& params,
119 content::RenderFrameHost* render_frame_host,
120 scoped_ptr<content::DesktopNotificationDelegate> delegate,
121 base::Closure* cancel_callback) OVERRIDE;
122 virtual void RequestGeolocationPermission(
123 content::WebContents* web_contents,
125 const GURL& requesting_frame,
127 base::Callback<void(bool)> result_callback,
128 base::Closure* cancel_callback) OVERRIDE;
129 virtual void RequestMidiSysExPermission(
130 content::WebContents* web_contents,
132 const GURL& requesting_frame,
134 base::Callback<void(bool)> result_callback,
135 base::Closure* cancel_callback) OVERRIDE;
136 virtual void RequestProtectedMediaIdentifierPermission(
137 content::WebContents* web_contents,
139 base::Callback<void(bool)> result_callback,
140 base::Closure* cancel_callback) OVERRIDE;
141 virtual bool CanCreateWindow(const GURL& opener_url,
142 const GURL& opener_top_level_frame_url,
143 const GURL& source_origin,
144 WindowContainerType container_type,
145 const GURL& target_url,
146 const content::Referrer& referrer,
147 WindowOpenDisposition disposition,
148 const blink::WebWindowFeatures& features,
150 bool opener_suppressed,
151 content::ResourceContext* context,
152 int render_process_id,
154 bool* no_javascript_access) OVERRIDE;
155 virtual void ResourceDispatcherHostCreated() OVERRIDE;
156 virtual net::NetLog* GetNetLog() OVERRIDE;
157 virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
158 virtual bool IsFastShutdownPossible() OVERRIDE;
159 virtual void ClearCache(content::RenderViewHost* rvh) OVERRIDE;
160 virtual void ClearCookies(content::RenderViewHost* rvh) OVERRIDE;
161 virtual base::FilePath GetDefaultDownloadDirectory() OVERRIDE;
162 virtual std::string GetDefaultDownloadName() OVERRIDE;
163 virtual void DidCreatePpapiPlugin(
164 content::BrowserPpapiHost* browser_host) OVERRIDE;
165 virtual bool AllowPepperSocketAPI(
166 content::BrowserContext* browser_context,
169 const content::SocketPermissionRequest* params) OVERRIDE;
170 virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
172 content::WebPreferences* web_prefs) OVERRIDE;
173 #if defined(VIDEO_HOLE)
174 virtual content::ExternalVideoSurfaceContainer*
175 OverrideCreateExternalVideoSurfaceContainer(
176 content::WebContents* web_contents) OVERRIDE;
178 virtual content::DevToolsManagerDelegate*
179 GetDevToolsManagerDelegate() OVERRIDE;
182 // Android WebView currently has a single global (non-off-the-record) browser
184 scoped_ptr<AwBrowserContext> browser_context_;
185 scoped_ptr<AwWebPreferencesPopulater> preferences_populater_;
187 JniDependencyFactory* native_factory_;
189 DISALLOW_COPY_AND_ASSIGN(AwContentBrowserClient);
192 } // namespace android_webview
194 #endif // ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_