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 "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/browser/content_browser_client.h"
12 #include "net/url_request/url_request_job_factory.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 // Returns the one AwBrowserContext for this process.
25 static AwBrowserContext
* GetAwBrowserContext();
27 AwContentBrowserClient(JniDependencyFactory
* native_factory
);
28 virtual ~AwContentBrowserClient();
30 // Overriden methods from ContentBrowserClient.
31 virtual void AddCertificate(net::URLRequest
* request
,
32 net::CertificateMimeType cert_type
,
33 const void* cert_data
,
35 int render_process_id
,
36 int render_view_id
) OVERRIDE
;
37 virtual content::BrowserMainParts
* CreateBrowserMainParts(
38 const content::MainFunctionParams
& parameters
) OVERRIDE
;
39 virtual content::WebContentsViewDelegate
* GetWebContentsViewDelegate(
40 content::WebContents
* web_contents
) OVERRIDE
;
41 virtual void RenderProcessHostCreated(
42 content::RenderProcessHost
* host
) OVERRIDE
;
43 virtual net::URLRequestContextGetter
* CreateRequestContext(
44 content::BrowserContext
* browser_context
,
45 content::ProtocolHandlerMap
* protocol_handlers
) OVERRIDE
;
46 virtual net::URLRequestContextGetter
* CreateRequestContextForStoragePartition(
47 content::BrowserContext
* browser_context
,
48 const base::FilePath
& partition_path
,
50 content::ProtocolHandlerMap
* protocol_handlers
) OVERRIDE
;
51 virtual std::string
GetCanonicalEncodingNameByAliasName(
52 const std::string
& alias_name
) OVERRIDE
;
53 virtual void AppendExtraCommandLineSwitches(CommandLine
* command_line
,
54 int child_process_id
) OVERRIDE
;
55 virtual std::string
GetApplicationLocale() OVERRIDE
;
56 virtual std::string
GetAcceptLangs(content::BrowserContext
* context
) OVERRIDE
;
57 virtual gfx::ImageSkia
* GetDefaultFavicon() OVERRIDE
;
58 virtual bool AllowAppCache(const GURL
& manifest_url
,
59 const GURL
& first_party
,
60 content::ResourceContext
* context
) OVERRIDE
;
61 virtual bool AllowGetCookie(const GURL
& url
,
62 const GURL
& first_party
,
63 const net::CookieList
& cookie_list
,
64 content::ResourceContext
* context
,
65 int render_process_id
,
66 int render_view_id
) OVERRIDE
;
67 virtual bool AllowSetCookie(const GURL
& url
,
68 const GURL
& first_party
,
69 const std::string
& cookie_line
,
70 content::ResourceContext
* context
,
71 int render_process_id
,
73 net::CookieOptions
* options
) OVERRIDE
;
74 virtual bool AllowWorkerDatabase(
77 const string16
& display_name
,
78 unsigned long estimated_size
,
79 content::ResourceContext
* context
,
80 const std::vector
<std::pair
<int, int> >& render_views
) OVERRIDE
;
81 virtual bool AllowWorkerFileSystem(
83 content::ResourceContext
* context
,
84 const std::vector
<std::pair
<int, int> >& render_views
) OVERRIDE
;
85 virtual bool AllowWorkerIndexedDB(
88 content::ResourceContext
* context
,
89 const std::vector
<std::pair
<int, int> >& render_views
) OVERRIDE
;
90 virtual content::QuotaPermissionContext
*
91 CreateQuotaPermissionContext() OVERRIDE
;
92 virtual void AllowCertificateError(
93 int render_process_id
,
96 const net::SSLInfo
& ssl_info
,
97 const GURL
& request_url
,
98 ResourceType::Type resource_type
,
100 bool strict_enforcement
,
101 const base::Callback
<void(bool)>& callback
,
102 bool* cancel_request
) OVERRIDE
;
103 virtual WebKit::WebNotificationPresenter::Permission
104 CheckDesktopNotificationPermission(
105 const GURL
& source_url
,
106 content::ResourceContext
* context
,
107 int render_process_id
) OVERRIDE
;
108 virtual void ShowDesktopNotification(
109 const content::ShowDesktopNotificationHostMsgParams
& params
,
110 int render_process_id
,
112 bool worker
) OVERRIDE
;
113 virtual void CancelDesktopNotification(
114 int render_process_id
,
116 int notification_id
) OVERRIDE
;
117 virtual bool CanCreateWindow(
118 const GURL
& opener_url
,
119 const GURL
& source_origin
,
120 WindowContainerType container_type
,
121 content::ResourceContext
* context
,
122 int render_process_id
,
123 bool* no_javascript_access
) OVERRIDE
;
124 virtual std::string
GetWorkerProcessTitle(
126 content::ResourceContext
* context
) OVERRIDE
;
127 virtual void ResourceDispatcherHostCreated() OVERRIDE
;
128 virtual net::NetLog
* GetNetLog() OVERRIDE
;
129 virtual content::AccessTokenStore
* CreateAccessTokenStore() OVERRIDE
;
130 virtual bool IsFastShutdownPossible() OVERRIDE
;
131 virtual void UpdateInspectorSetting(content::RenderViewHost
* rvh
,
132 const std::string
& key
,
133 const std::string
& value
) OVERRIDE
;
134 virtual void ClearCache(content::RenderViewHost
* rvh
) OVERRIDE
;
135 virtual void ClearCookies(content::RenderViewHost
* rvh
) OVERRIDE
;
136 virtual base::FilePath
GetDefaultDownloadDirectory() OVERRIDE
;
137 virtual std::string
GetDefaultDownloadName() OVERRIDE
;
138 virtual void DidCreatePpapiPlugin(
139 content::BrowserPpapiHost
* browser_host
) OVERRIDE
;
140 virtual bool AllowPepperSocketAPI(
141 content::BrowserContext
* browser_context
,
143 const content::SocketPermissionRequest
& params
) OVERRIDE
;
146 // Android WebView currently has a single global (non-off-the-record) browser
148 scoped_ptr
<AwBrowserContext
> browser_context_
;
150 JniDependencyFactory
* native_factory_
;
152 DISALLOW_COPY_AND_ASSIGN(AwContentBrowserClient
);
155 } // namespace android_webview
157 #endif // ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_