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 CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_
6 #define CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_
13 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h"
15 #include "chrome/common/chrome_version_info.h"
16 #include "content/public/browser/content_browser_client.h"
18 #if defined(OS_ANDROID)
19 #include "base/memory/scoped_ptr.h"
27 class QuotaPermissionContext
;
30 namespace extensions
{
31 class BrowserPermissionsPolicyDelegate
;
34 namespace user_prefs
{
35 class PrefRegistrySyncable
;
40 class ChromeContentBrowserClient
: public content::ContentBrowserClient
{
42 ChromeContentBrowserClient();
43 virtual ~ChromeContentBrowserClient();
45 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
47 // Notification that the application locale has changed. This allows us to
48 // update our I/O thread cache of this value.
49 static void SetApplicationLocale(const std::string
& locale
);
51 virtual content::BrowserMainParts
* CreateBrowserMainParts(
52 const content::MainFunctionParams
& parameters
) OVERRIDE
;
53 virtual std::string
GetStoragePartitionIdForSite(
54 content::BrowserContext
* browser_context
,
55 const GURL
& site
) OVERRIDE
;
56 virtual bool IsValidStoragePartitionId(
57 content::BrowserContext
* browser_context
,
58 const std::string
& partition_id
) OVERRIDE
;
59 virtual void GetStoragePartitionConfigForSite(
60 content::BrowserContext
* browser_context
,
63 std::string
* partition_domain
,
64 std::string
* partition_name
,
65 bool* in_memory
) OVERRIDE
;
66 virtual content::WebContentsViewDelegate
* GetWebContentsViewDelegate(
67 content::WebContents
* web_contents
) OVERRIDE
;
68 virtual void GuestWebContentsCreated(
69 content::SiteInstance
* guest_site_instance
,
70 content::WebContents
* guest_web_contents
,
71 content::WebContents
* opener_web_contents
,
72 content::BrowserPluginGuestDelegate
** guest_delegate
,
73 scoped_ptr
<base::DictionaryValue
> extra_params
) OVERRIDE
;
74 virtual void GuestWebContentsAttached(
75 content::WebContents
* guest_web_contents
,
76 content::WebContents
* embedder_web_contents
,
77 const base::DictionaryValue
& extra_params
) OVERRIDE
;
78 virtual void RenderProcessWillLaunch(
79 content::RenderProcessHost
* host
) OVERRIDE
;
80 virtual bool ShouldUseProcessPerSite(content::BrowserContext
* browser_context
,
81 const GURL
& effective_url
) OVERRIDE
;
82 virtual GURL
GetEffectiveURL(content::BrowserContext
* browser_context
,
83 const GURL
& url
) OVERRIDE
;
84 virtual void GetAdditionalWebUISchemes(
85 std::vector
<std::string
>* additional_schemes
) OVERRIDE
;
86 virtual void GetAdditionalWebUIHostsToIgnoreParititionCheck(
87 std::vector
<std::string
>* hosts
) OVERRIDE
;
88 virtual net::URLRequestContextGetter
* CreateRequestContext(
89 content::BrowserContext
* browser_context
,
90 content::ProtocolHandlerMap
* protocol_handlers
,
91 content::ProtocolHandlerScopedVector protocol_interceptors
) OVERRIDE
;
92 virtual net::URLRequestContextGetter
* CreateRequestContextForStoragePartition(
93 content::BrowserContext
* browser_context
,
94 const base::FilePath
& partition_path
,
96 content::ProtocolHandlerMap
* protocol_handlers
,
97 content::ProtocolHandlerScopedVector protocol_interceptors
) OVERRIDE
;
98 virtual bool IsHandledURL(const GURL
& url
) OVERRIDE
;
99 virtual bool CanCommitURL(content::RenderProcessHost
* process_host
,
100 const GURL
& url
) OVERRIDE
;
101 virtual bool ShouldAllowOpenURL(content::SiteInstance
* site_instance
,
102 const GURL
& url
) OVERRIDE
;
103 virtual bool IsSuitableHost(content::RenderProcessHost
* process_host
,
104 const GURL
& site_url
) OVERRIDE
;
105 virtual bool ShouldTryToUseExistingProcessHost(
106 content::BrowserContext
* browser_context
, const GURL
& url
) OVERRIDE
;
107 virtual void SiteInstanceGotProcess(
108 content::SiteInstance
* site_instance
) OVERRIDE
;
109 virtual void SiteInstanceDeleting(content::SiteInstance
* site_instance
)
111 virtual void WorkerProcessCreated(content::SiteInstance
* site_instance
,
112 int worker_process_id
) OVERRIDE
;
113 virtual void WorkerProcessTerminated(content::SiteInstance
* site_instance
,
114 int worker_process_id
) OVERRIDE
;
115 virtual bool ShouldSwapBrowsingInstancesForNavigation(
116 content::SiteInstance
* site_instance
,
117 const GURL
& current_url
,
118 const GURL
& new_url
) OVERRIDE
;
119 virtual bool ShouldSwapProcessesForRedirect(
120 content::ResourceContext
* resource_context
,
121 const GURL
& current_url
,
122 const GURL
& new_url
) OVERRIDE
;
123 virtual bool ShouldAssignSiteForURL(const GURL
& url
) OVERRIDE
;
124 virtual std::string
GetCanonicalEncodingNameByAliasName(
125 const std::string
& alias_name
) OVERRIDE
;
126 virtual void AppendExtraCommandLineSwitches(base::CommandLine
* command_line
,
127 int child_process_id
) OVERRIDE
;
128 virtual std::string
GetApplicationLocale() OVERRIDE
;
129 virtual std::string
GetAcceptLangs(
130 content::BrowserContext
* context
) OVERRIDE
;
131 virtual gfx::ImageSkia
* GetDefaultFavicon() OVERRIDE
;
132 virtual bool AllowAppCache(const GURL
& manifest_url
,
133 const GURL
& first_party
,
134 content::ResourceContext
* context
) OVERRIDE
;
135 virtual bool AllowGetCookie(const GURL
& url
,
136 const GURL
& first_party
,
137 const net::CookieList
& cookie_list
,
138 content::ResourceContext
* context
,
139 int render_process_id
,
140 int render_frame_id
) OVERRIDE
;
141 virtual bool AllowSetCookie(const GURL
& url
,
142 const GURL
& first_party
,
143 const std::string
& cookie_line
,
144 content::ResourceContext
* context
,
145 int render_process_id
,
147 net::CookieOptions
* options
) OVERRIDE
;
148 virtual bool AllowSaveLocalState(content::ResourceContext
* context
) OVERRIDE
;
149 virtual bool AllowWorkerDatabase(
151 const base::string16
& name
,
152 const base::string16
& display_name
,
153 unsigned long estimated_size
,
154 content::ResourceContext
* context
,
155 const std::vector
<std::pair
<int, int> >& render_frames
) OVERRIDE
;
156 virtual bool AllowWorkerFileSystem(
158 content::ResourceContext
* context
,
159 const std::vector
<std::pair
<int, int> >& render_frames
) OVERRIDE
;
160 virtual bool AllowWorkerIndexedDB(
162 const base::string16
& name
,
163 content::ResourceContext
* context
,
164 const std::vector
<std::pair
<int, int> >& render_frames
) OVERRIDE
;
165 virtual net::URLRequestContext
* OverrideRequestContextForURL(
166 const GURL
& url
, content::ResourceContext
* context
) OVERRIDE
;
167 virtual content::QuotaPermissionContext
*
168 CreateQuotaPermissionContext() OVERRIDE
;
169 virtual void AllowCertificateError(
170 int render_process_id
,
173 const net::SSLInfo
& ssl_info
,
174 const GURL
& request_url
,
175 ResourceType::Type resource_type
,
177 bool strict_enforcement
,
178 const base::Callback
<void(bool)>& callback
,
179 content::CertificateRequestResultType
* request
) OVERRIDE
;
180 virtual void SelectClientCertificate(
181 int render_process_id
,
183 const net::HttpNetworkSession
* network_session
,
184 net::SSLCertRequestInfo
* cert_request_info
,
185 const base::Callback
<void(net::X509Certificate
*)>& callback
) OVERRIDE
;
186 virtual void AddCertificate(
187 net::URLRequest
* request
,
188 net::CertificateMimeType cert_type
,
189 const void* cert_data
,
191 int render_process_id
,
192 int render_view_id
) OVERRIDE
;
193 virtual content::MediaObserver
* GetMediaObserver() OVERRIDE
;
194 virtual void RequestDesktopNotificationPermission(
195 const GURL
& source_origin
,
196 content::RenderFrameHost
* render_frame_host
,
197 base::Closure
& callback
) OVERRIDE
;
198 virtual blink::WebNotificationPresenter::Permission
199 CheckDesktopNotificationPermission(
200 const GURL
& source_origin
,
201 content::ResourceContext
* context
,
202 int render_process_id
) OVERRIDE
;
203 virtual void ShowDesktopNotification(
204 const content::ShowDesktopNotificationHostMsgParams
& params
,
205 content::RenderFrameHost
* render_frame_host
,
206 content::DesktopNotificationDelegate
* delegate
,
207 base::Closure
* cancel_callback
) OVERRIDE
;
208 virtual bool CanCreateWindow(const GURL
& opener_url
,
209 const GURL
& opener_top_level_frame_url
,
210 const GURL
& source_origin
,
211 WindowContainerType container_type
,
212 const GURL
& target_url
,
213 const content::Referrer
& referrer
,
214 WindowOpenDisposition disposition
,
215 const blink::WebWindowFeatures
& features
,
217 bool opener_suppressed
,
218 content::ResourceContext
* context
,
219 int render_process_id
,
222 bool* no_javascript_access
) OVERRIDE
;
223 virtual std::string
GetWorkerProcessTitle(
224 const GURL
& url
, content::ResourceContext
* context
) OVERRIDE
;
225 virtual void ResourceDispatcherHostCreated() OVERRIDE
;
226 virtual content::SpeechRecognitionManagerDelegate
*
227 GetSpeechRecognitionManagerDelegate() OVERRIDE
;
228 virtual net::NetLog
* GetNetLog() OVERRIDE
;
229 virtual content::AccessTokenStore
* CreateAccessTokenStore() OVERRIDE
;
230 virtual bool IsFastShutdownPossible() OVERRIDE
;
231 virtual void OverrideWebkitPrefs(content::RenderViewHost
* rvh
,
233 WebPreferences
* prefs
) OVERRIDE
;
234 virtual void UpdateInspectorSetting(content::RenderViewHost
* rvh
,
235 const std::string
& key
,
236 const std::string
& value
) OVERRIDE
;
237 virtual void BrowserURLHandlerCreated(
238 content::BrowserURLHandler
* handler
) OVERRIDE
;
239 virtual void ClearCache(content::RenderViewHost
* rvh
) OVERRIDE
;
240 virtual void ClearCookies(content::RenderViewHost
* rvh
) OVERRIDE
;
241 virtual base::FilePath
GetDefaultDownloadDirectory() OVERRIDE
;
242 virtual std::string
GetDefaultDownloadName() OVERRIDE
;
243 virtual void DidCreatePpapiPlugin(
244 content::BrowserPpapiHost
* browser_host
) OVERRIDE
;
245 virtual content::BrowserPpapiHost
* GetExternalBrowserPpapiHost(
246 int plugin_process_id
) OVERRIDE
;
247 virtual bool AllowPepperSocketAPI(
248 content::BrowserContext
* browser_context
,
251 const content::SocketPermissionRequest
* params
) OVERRIDE
;
252 virtual ui::SelectFilePolicy
* CreateSelectFilePolicy(
253 content::WebContents
* web_contents
) OVERRIDE
;
254 virtual void GetAdditionalAllowedSchemesForFileSystem(
255 std::vector
<std::string
>* additional_schemes
) OVERRIDE
;
256 virtual void GetURLRequestAutoMountHandlers(
257 std::vector
<fileapi::URLRequestAutoMountHandler
>* handlers
) OVERRIDE
;
258 virtual void GetAdditionalFileSystemBackends(
259 content::BrowserContext
* browser_context
,
260 const base::FilePath
& storage_partition_path
,
261 ScopedVector
<fileapi::FileSystemBackend
>* additional_backends
) OVERRIDE
;
263 #if defined(OS_POSIX) && !defined(OS_MACOSX)
264 virtual void GetAdditionalMappedFilesForChildProcess(
265 const base::CommandLine
& command_line
,
266 int child_process_id
,
267 std::vector
<content::FileDescriptorInfo
>* mappings
) OVERRIDE
;
270 virtual const wchar_t* GetResourceDllName() OVERRIDE
;
271 virtual void PreSpawnRenderer(sandbox::TargetPolicy
* policy
,
272 bool* success
) OVERRIDE
;
275 virtual bool IsPluginAllowedToCallRequestOSFileHandle(
276 content::BrowserContext
* browser_context
,
277 const GURL
& url
) OVERRIDE
;
279 virtual bool IsPluginAllowedToUseDevChannelAPIs() OVERRIDE
;
282 #if defined(ENABLE_WEBRTC)
283 // Copies disable WebRTC encryption switch depending on the channel.
284 static void MaybeCopyDisableWebRtcEncryptionSwitch(
285 base::CommandLine
* to_command_line
,
286 const base::CommandLine
& from_command_line
,
287 VersionInfo::Channel channel
);
290 #if defined(ENABLE_PLUGINS)
291 // Set of origins that can use TCP/UDP private APIs from NaCl.
292 std::set
<std::string
> allowed_socket_origins_
;
293 // Set of origins that can get a handle for FileIO from NaCl.
294 std::set
<std::string
> allowed_file_handle_origins_
;
296 scoped_ptr
<extensions::BrowserPermissionsPolicyDelegate
>
297 permissions_policy_delegate_
;
299 friend class DisableWebRtcEncryptionFlagTest
;
301 DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient
);
304 } // namespace chrome
306 #endif // CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_