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 #include "content/public/browser/content_browser_client.h"
7 #include "base/files/file_path.h"
8 #include "content/public/browser/client_certificate_delegate.h"
9 #include "content/public/common/sandbox_type.h"
10 #include "ui/gfx/image/image_skia.h"
15 BrowserMainParts
* ContentBrowserClient::CreateBrowserMainParts(
16 const MainFunctionParams
& parameters
) {
20 void ContentBrowserClient::PostAfterStartupTask(
21 const tracked_objects::Location
& from_here
,
22 const scoped_refptr
<base::TaskRunner
>& task_runner
,
23 const base::Closure
& task
) {
24 task_runner
->PostTask(from_here
, task
);
27 WebContentsViewDelegate
* ContentBrowserClient::GetWebContentsViewDelegate(
28 WebContents
* web_contents
) {
32 GURL
ContentBrowserClient::GetEffectiveURL(BrowserContext
* browser_context
,
37 bool ContentBrowserClient::ShouldUseProcessPerSite(
38 BrowserContext
* browser_context
, const GURL
& effective_url
) {
42 bool ContentBrowserClient::ShouldLockToOrigin(BrowserContext
* browser_context
,
43 const GURL
& effective_url
) {
47 net::URLRequestContextGetter
* ContentBrowserClient::CreateRequestContext(
48 BrowserContext
* browser_context
,
49 ProtocolHandlerMap
* protocol_handlers
,
50 URLRequestInterceptorScopedVector request_interceptors
) {
54 net::URLRequestContextGetter
*
55 ContentBrowserClient::CreateRequestContextForStoragePartition(
56 BrowserContext
* browser_context
,
57 const base::FilePath
& partition_path
,
59 ProtocolHandlerMap
* protocol_handlers
,
60 URLRequestInterceptorScopedVector request_interceptors
) {
64 bool ContentBrowserClient::IsHandledURL(const GURL
& url
) {
68 bool ContentBrowserClient::CanCommitURL(RenderProcessHost
* process_host
,
69 const GURL
& site_url
) {
73 bool ContentBrowserClient::IsIllegalOrigin(ResourceContext
* resource_context
,
79 bool ContentBrowserClient::ShouldAllowOpenURL(SiteInstance
* site_instance
,
84 bool ContentBrowserClient::IsSuitableHost(RenderProcessHost
* process_host
,
85 const GURL
& site_url
) {
89 bool ContentBrowserClient::MayReuseHost(RenderProcessHost
* process_host
) {
93 bool ContentBrowserClient::ShouldTryToUseExistingProcessHost(
94 BrowserContext
* browser_context
, const GURL
& url
) {
98 bool ContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation(
99 SiteInstance
* site_instance
,
100 const GURL
& current_url
,
101 const GURL
& new_url
) {
105 bool ContentBrowserClient::ShouldSwapProcessesForRedirect(
106 ResourceContext
* resource_context
, const GURL
& current_url
,
107 const GURL
& new_url
) {
111 bool ContentBrowserClient::ShouldAssignSiteForURL(const GURL
& url
) {
115 std::string
ContentBrowserClient::GetCanonicalEncodingNameByAliasName(
116 const std::string
& alias_name
) {
117 return std::string();
120 std::string
ContentBrowserClient::GetApplicationLocale() {
124 std::string
ContentBrowserClient::GetAcceptLangs(BrowserContext
* context
) {
125 return std::string();
128 const gfx::ImageSkia
* ContentBrowserClient::GetDefaultFavicon() {
129 static gfx::ImageSkia
* empty
= new gfx::ImageSkia();
133 bool ContentBrowserClient::AllowAppCache(const GURL
& manifest_url
,
134 const GURL
& first_party
,
135 ResourceContext
* context
) {
139 bool ContentBrowserClient::AllowServiceWorker(const GURL
& scope
,
140 const GURL
& document_url
,
141 content::ResourceContext
* context
,
142 int render_process_id
,
143 int render_frame_id
) {
147 bool ContentBrowserClient::AllowGetCookie(const GURL
& url
,
148 const GURL
& first_party
,
149 const net::CookieList
& cookie_list
,
150 ResourceContext
* context
,
151 int render_process_id
,
152 int render_frame_id
) {
156 bool ContentBrowserClient::AllowSetCookie(const GURL
& url
,
157 const GURL
& first_party
,
158 const std::string
& cookie_line
,
159 ResourceContext
* context
,
160 int render_process_id
,
162 net::CookieOptions
* options
) {
166 bool ContentBrowserClient::AllowSaveLocalState(ResourceContext
* context
) {
170 bool ContentBrowserClient::AllowWorkerDatabase(
172 const base::string16
& name
,
173 const base::string16
& display_name
,
174 unsigned long estimated_size
,
175 ResourceContext
* context
,
176 const std::vector
<std::pair
<int, int> >& render_frames
) {
180 void ContentBrowserClient::AllowWorkerFileSystem(
182 ResourceContext
* context
,
183 const std::vector
<std::pair
<int, int> >& render_frames
,
184 base::Callback
<void(bool)> callback
) {
188 bool ContentBrowserClient::AllowWorkerIndexedDB(
190 const base::string16
& name
,
191 ResourceContext
* context
,
192 const std::vector
<std::pair
<int, int> >& render_frames
) {
196 #if defined(ENABLE_WEBRTC)
197 bool ContentBrowserClient::AllowWebRTCIdentityCache(const GURL
& url
,
198 const GURL
& first_party_url
,
199 ResourceContext
* context
) {
202 #endif // defined(ENABLE_WEBRTC)
204 QuotaPermissionContext
* ContentBrowserClient::CreateQuotaPermissionContext() {
208 void ContentBrowserClient::SelectClientCertificate(
209 WebContents
* web_contents
,
210 net::SSLCertRequestInfo
* cert_request_info
,
211 scoped_ptr
<ClientCertificateDelegate
> delegate
) {
214 net::URLRequestContext
* ContentBrowserClient::OverrideRequestContextForURL(
215 const GURL
& url
, ResourceContext
* context
) {
219 std::string
ContentBrowserClient::GetStoragePartitionIdForSite(
220 BrowserContext
* browser_context
,
222 return std::string();
225 bool ContentBrowserClient::IsValidStoragePartitionId(
226 BrowserContext
* browser_context
,
227 const std::string
& partition_id
) {
228 // Since the GetStoragePartitionIdForChildProcess() only generates empty
229 // strings, we should only ever see empty strings coming back.
230 return partition_id
.empty();
233 void ContentBrowserClient::GetStoragePartitionConfigForSite(
234 BrowserContext
* browser_context
,
237 std::string
* partition_domain
,
238 std::string
* partition_name
,
240 partition_domain
->clear();
241 partition_name
->clear();
245 MediaObserver
* ContentBrowserClient::GetMediaObserver() {
249 PlatformNotificationService
*
250 ContentBrowserClient::GetPlatformNotificationService() {
254 bool ContentBrowserClient::CanCreateWindow(
255 const GURL
& opener_url
,
256 const GURL
& opener_top_level_frame_url
,
257 const GURL
& source_origin
,
258 WindowContainerType container_type
,
259 const GURL
& target_url
,
260 const Referrer
& referrer
,
261 WindowOpenDisposition disposition
,
262 const blink::WebWindowFeatures
& features
,
264 bool opener_suppressed
,
265 ResourceContext
* context
,
266 int render_process_id
,
267 int opener_render_view_id
,
268 int opener_render_frame_id
,
269 bool* no_javascript_access
) {
270 *no_javascript_access
= false;
274 SpeechRecognitionManagerDelegate
*
275 ContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
279 net::NetLog
* ContentBrowserClient::GetNetLog() {
283 AccessTokenStore
* ContentBrowserClient::CreateAccessTokenStore() {
287 bool ContentBrowserClient::IsFastShutdownPossible() {
291 base::FilePath
ContentBrowserClient::GetDefaultDownloadDirectory() {
292 return base::FilePath();
295 std::string
ContentBrowserClient::GetDefaultDownloadName() {
296 return std::string();
299 base::FilePath
ContentBrowserClient::GetShaderDiskCacheDirectory() {
300 return base::FilePath();
304 ContentBrowserClient::GetExternalBrowserPpapiHost(int plugin_process_id
) {
308 bool ContentBrowserClient::AllowPepperSocketAPI(
309 BrowserContext
* browser_context
,
312 const SocketPermissionRequest
* params
) {
316 ui::SelectFilePolicy
* ContentBrowserClient::CreateSelectFilePolicy(
317 WebContents
* web_contents
) {
321 LocationProvider
* ContentBrowserClient::OverrideSystemLocationProvider() {
325 DevToolsManagerDelegate
* ContentBrowserClient::GetDevToolsManagerDelegate() {
329 TracingDelegate
* ContentBrowserClient::GetTracingDelegate() {
333 bool ContentBrowserClient::IsNPAPIEnabled() {
337 bool ContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle(
338 BrowserContext
* browser_context
,
343 bool ContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs(
344 BrowserContext
* browser_context
,
349 PresentationServiceDelegate
*
350 ContentBrowserClient::GetPresentationServiceDelegate(
351 WebContents
* web_contents
) {
355 void ContentBrowserClient::OpenURL(
356 content::BrowserContext
* browser_context
,
357 const content::OpenURLParams
& params
,
358 const base::Callback
<void(content::WebContents
*)>& callback
) {
359 callback
.Run(nullptr);
363 const wchar_t* ContentBrowserClient::GetResourceDllName() {
367 base::string16
ContentBrowserClient::GetAppContainerSidForSandboxType(
368 int sandbox_type
) const {
369 // Embedders should override this method and return different SIDs for each
370 // sandbox type. Note: All content level tests will run child processes in the
371 // same AppContainer.
372 return base::string16(
373 L
"S-1-15-2-3251537155-1984446955-2931258699-841473695-1938553385-"
374 L
"924012148-129201922");
378 #if defined(VIDEO_HOLE)
379 ExternalVideoSurfaceContainer
*
380 ContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer(
381 WebContents
* web_contents
) {
382 NOTREACHED() << "Hole-punching is not supported. See crbug.com/469348.";
387 } // namespace content