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 void RequestPermission(
112 content::PermissionType permission
,
113 content::WebContents
* web_contents
,
115 const GURL
& requesting_frame
,
117 const base::Callback
<void(bool)>& result_callback
) override
;
118 virtual void CancelPermissionRequest(content::PermissionType permission
,
119 content::WebContents
* web_contents
,
121 const GURL
& origin
) override
;
122 virtual bool CanCreateWindow(const GURL
& opener_url
,
123 const GURL
& opener_top_level_frame_url
,
124 const GURL
& source_origin
,
125 WindowContainerType container_type
,
126 const GURL
& target_url
,
127 const content::Referrer
& referrer
,
128 WindowOpenDisposition disposition
,
129 const blink::WebWindowFeatures
& features
,
131 bool opener_suppressed
,
132 content::ResourceContext
* context
,
133 int render_process_id
,
135 bool* no_javascript_access
) override
;
136 virtual void ResourceDispatcherHostCreated() override
;
137 virtual net::NetLog
* GetNetLog() override
;
138 virtual content::AccessTokenStore
* CreateAccessTokenStore() override
;
139 virtual bool IsFastShutdownPossible() override
;
140 virtual void ClearCache(content::RenderViewHost
* rvh
) override
;
141 virtual void ClearCookies(content::RenderViewHost
* rvh
) override
;
142 virtual base::FilePath
GetDefaultDownloadDirectory() override
;
143 virtual std::string
GetDefaultDownloadName() override
;
144 virtual void DidCreatePpapiPlugin(
145 content::BrowserPpapiHost
* browser_host
) override
;
146 virtual bool AllowPepperSocketAPI(
147 content::BrowserContext
* browser_context
,
150 const content::SocketPermissionRequest
* params
) override
;
151 virtual void OverrideWebkitPrefs(content::RenderViewHost
* rvh
,
153 content::WebPreferences
* web_prefs
) override
;
154 #if defined(VIDEO_HOLE)
155 virtual content::ExternalVideoSurfaceContainer
*
156 OverrideCreateExternalVideoSurfaceContainer(
157 content::WebContents
* web_contents
) override
;
159 virtual content::DevToolsManagerDelegate
*
160 GetDevToolsManagerDelegate() override
;
163 // Android WebView currently has a single global (non-off-the-record) browser
165 scoped_ptr
<AwBrowserContext
> browser_context_
;
166 scoped_ptr
<AwWebPreferencesPopulater
> preferences_populater_
;
168 JniDependencyFactory
* native_factory_
;
170 DISALLOW_COPY_AND_ASSIGN(AwContentBrowserClient
);
173 } // namespace android_webview
175 #endif // ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_