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"
13 #include "net/url_request/url_request_job_factory.h"
15 struct WebPreferences
;
17 namespace android_webview
{
19 class AwBrowserContext
;
20 class JniDependencyFactory
;
22 class AwContentBrowserClient
: public content::ContentBrowserClient
{
24 // This is what AwContentBrowserClient::GetAcceptLangs uses.
25 static std::string
GetAcceptLangsImpl();
27 // Deprecated: use AwBrowserContext::GetDefault() instead.
28 static AwBrowserContext
* GetAwBrowserContext();
30 AwContentBrowserClient(JniDependencyFactory
* native_factory
);
31 virtual ~AwContentBrowserClient();
33 // Overriden methods from ContentBrowserClient.
34 virtual void AddCertificate(net::URLRequest
* request
,
35 net::CertificateMimeType cert_type
,
36 const void* cert_data
,
38 int render_process_id
,
39 int render_view_id
) OVERRIDE
;
40 virtual content::BrowserMainParts
* CreateBrowserMainParts(
41 const content::MainFunctionParams
& parameters
) OVERRIDE
;
42 virtual content::WebContentsViewDelegate
* GetWebContentsViewDelegate(
43 content::WebContents
* web_contents
) OVERRIDE
;
44 virtual void RenderProcessWillLaunch(
45 content::RenderProcessHost
* host
) OVERRIDE
;
46 virtual net::URLRequestContextGetter
* CreateRequestContext(
47 content::BrowserContext
* browser_context
,
48 content::ProtocolHandlerMap
* protocol_handlers
) OVERRIDE
;
49 virtual net::URLRequestContextGetter
* CreateRequestContextForStoragePartition(
50 content::BrowserContext
* browser_context
,
51 const base::FilePath
& partition_path
,
53 content::ProtocolHandlerMap
* protocol_handlers
) OVERRIDE
;
54 virtual std::string
GetCanonicalEncodingNameByAliasName(
55 const std::string
& alias_name
) OVERRIDE
;
56 virtual void AppendExtraCommandLineSwitches(CommandLine
* command_line
,
57 int child_process_id
) OVERRIDE
;
58 virtual std::string
GetApplicationLocale() OVERRIDE
;
59 virtual std::string
GetAcceptLangs(content::BrowserContext
* context
) OVERRIDE
;
60 virtual gfx::ImageSkia
* GetDefaultFavicon() OVERRIDE
;
61 virtual bool AllowAppCache(const GURL
& manifest_url
,
62 const GURL
& first_party
,
63 content::ResourceContext
* context
) OVERRIDE
;
64 virtual bool AllowGetCookie(const GURL
& url
,
65 const GURL
& first_party
,
66 const net::CookieList
& cookie_list
,
67 content::ResourceContext
* context
,
68 int render_process_id
,
69 int render_frame_id
) OVERRIDE
;
70 virtual bool AllowSetCookie(const GURL
& url
,
71 const GURL
& first_party
,
72 const std::string
& cookie_line
,
73 content::ResourceContext
* context
,
74 int render_process_id
,
76 net::CookieOptions
* options
) OVERRIDE
;
77 virtual bool AllowWorkerDatabase(
79 const base::string16
& name
,
80 const base::string16
& display_name
,
81 unsigned long estimated_size
,
82 content::ResourceContext
* context
,
83 const std::vector
<std::pair
<int, int> >& render_frames
) OVERRIDE
;
84 virtual bool AllowWorkerFileSystem(
86 content::ResourceContext
* context
,
87 const std::vector
<std::pair
<int, int> >& render_frames
) OVERRIDE
;
88 virtual bool AllowWorkerIndexedDB(
90 const base::string16
& name
,
91 content::ResourceContext
* context
,
92 const std::vector
<std::pair
<int, int> >& render_frames
) OVERRIDE
;
93 virtual content::QuotaPermissionContext
*
94 CreateQuotaPermissionContext() OVERRIDE
;
95 virtual void AllowCertificateError(
96 int render_process_id
,
99 const net::SSLInfo
& ssl_info
,
100 const GURL
& request_url
,
101 ResourceType::Type resource_type
,
103 bool strict_enforcement
,
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::WebNotificationPresenter::Permission
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 int render_process_id
,
121 bool worker
) OVERRIDE
;
122 virtual void CancelDesktopNotification(
123 int render_process_id
,
125 int notification_id
) OVERRIDE
;
126 virtual bool CanCreateWindow(const GURL
& opener_url
,
127 const GURL
& opener_top_level_frame_url
,
128 const GURL
& source_origin
,
129 WindowContainerType container_type
,
130 const GURL
& target_url
,
131 const content::Referrer
& referrer
,
132 WindowOpenDisposition disposition
,
133 const blink::WebWindowFeatures
& features
,
135 bool opener_suppressed
,
136 content::ResourceContext
* context
,
137 int render_process_id
,
140 bool* no_javascript_access
) OVERRIDE
;
141 virtual std::string
GetWorkerProcessTitle(
143 content::ResourceContext
* context
) OVERRIDE
;
144 virtual void ResourceDispatcherHostCreated() OVERRIDE
;
145 virtual net::NetLog
* GetNetLog() OVERRIDE
;
146 virtual content::AccessTokenStore
* CreateAccessTokenStore() OVERRIDE
;
147 virtual bool IsFastShutdownPossible() OVERRIDE
;
148 virtual void UpdateInspectorSetting(content::RenderViewHost
* rvh
,
149 const std::string
& key
,
150 const std::string
& value
) OVERRIDE
;
151 virtual void ClearCache(content::RenderViewHost
* rvh
) OVERRIDE
;
152 virtual void ClearCookies(content::RenderViewHost
* rvh
) OVERRIDE
;
153 virtual base::FilePath
GetDefaultDownloadDirectory() OVERRIDE
;
154 virtual std::string
GetDefaultDownloadName() OVERRIDE
;
155 virtual void DidCreatePpapiPlugin(
156 content::BrowserPpapiHost
* browser_host
) OVERRIDE
;
157 virtual bool AllowPepperSocketAPI(
158 content::BrowserContext
* browser_context
,
161 const content::SocketPermissionRequest
* params
) OVERRIDE
;
162 virtual void OverrideWebkitPrefs(content::RenderViewHost
* rvh
,
164 WebPreferences
* web_prefs
) OVERRIDE
;
167 // Android WebView currently has a single global (non-off-the-record) browser
169 scoped_ptr
<AwBrowserContext
> browser_context_
;
170 scoped_ptr
<AwWebPreferencesPopulater
> preferences_populater_
;
172 JniDependencyFactory
* native_factory_
;
174 DISALLOW_COPY_AND_ASSIGN(AwContentBrowserClient
);
177 } // namespace android_webview
179 #endif // ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_