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 net::URLRequestContextGetter
* ContentBrowserClient::CreateRequestContext(
43 BrowserContext
* browser_context
,
44 ProtocolHandlerMap
* protocol_handlers
,
45 URLRequestInterceptorScopedVector request_interceptors
) {
49 net::URLRequestContextGetter
*
50 ContentBrowserClient::CreateRequestContextForStoragePartition(
51 BrowserContext
* browser_context
,
52 const base::FilePath
& partition_path
,
54 ProtocolHandlerMap
* protocol_handlers
,
55 URLRequestInterceptorScopedVector request_interceptors
) {
59 bool ContentBrowserClient::IsHandledURL(const GURL
& url
) {
63 bool ContentBrowserClient::CanCommitURL(RenderProcessHost
* process_host
,
64 const GURL
& site_url
) {
68 bool ContentBrowserClient::ShouldAllowOpenURL(SiteInstance
* site_instance
,
73 bool ContentBrowserClient::IsSuitableHost(RenderProcessHost
* process_host
,
74 const GURL
& site_url
) {
78 bool ContentBrowserClient::MayReuseHost(RenderProcessHost
* process_host
) {
82 bool ContentBrowserClient::ShouldTryToUseExistingProcessHost(
83 BrowserContext
* browser_context
, const GURL
& url
) {
87 bool ContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation(
88 SiteInstance
* site_instance
,
89 const GURL
& current_url
,
90 const GURL
& new_url
) {
94 bool ContentBrowserClient::ShouldSwapProcessesForRedirect(
95 ResourceContext
* resource_context
, const GURL
& current_url
,
96 const GURL
& new_url
) {
100 bool ContentBrowserClient::ShouldAssignSiteForURL(const GURL
& url
) {
104 std::string
ContentBrowserClient::GetCanonicalEncodingNameByAliasName(
105 const std::string
& alias_name
) {
106 return std::string();
109 std::string
ContentBrowserClient::GetApplicationLocale() {
113 std::string
ContentBrowserClient::GetAcceptLangs(BrowserContext
* context
) {
114 return std::string();
117 const gfx::ImageSkia
* ContentBrowserClient::GetDefaultFavicon() {
118 static gfx::ImageSkia
* empty
= new gfx::ImageSkia();
122 bool ContentBrowserClient::AllowAppCache(const GURL
& manifest_url
,
123 const GURL
& first_party
,
124 ResourceContext
* context
) {
128 bool ContentBrowserClient::AllowServiceWorker(const GURL
& scope
,
129 const GURL
& document_url
,
130 content::ResourceContext
* context
,
131 int render_process_id
,
132 int render_frame_id
) {
136 bool ContentBrowserClient::AllowGetCookie(const GURL
& url
,
137 const GURL
& first_party
,
138 const net::CookieList
& cookie_list
,
139 ResourceContext
* context
,
140 int render_process_id
,
141 int render_frame_id
) {
145 bool ContentBrowserClient::AllowSetCookie(const GURL
& url
,
146 const GURL
& first_party
,
147 const std::string
& cookie_line
,
148 ResourceContext
* context
,
149 int render_process_id
,
151 net::CookieOptions
* options
) {
155 bool ContentBrowserClient::AllowSaveLocalState(ResourceContext
* context
) {
159 bool ContentBrowserClient::AllowWorkerDatabase(
161 const base::string16
& name
,
162 const base::string16
& display_name
,
163 unsigned long estimated_size
,
164 ResourceContext
* context
,
165 const std::vector
<std::pair
<int, int> >& render_frames
) {
169 void ContentBrowserClient::AllowWorkerFileSystem(
171 ResourceContext
* context
,
172 const std::vector
<std::pair
<int, int> >& render_frames
,
173 base::Callback
<void(bool)> callback
) {
177 bool ContentBrowserClient::AllowWorkerIndexedDB(
179 const base::string16
& name
,
180 ResourceContext
* context
,
181 const std::vector
<std::pair
<int, int> >& render_frames
) {
185 #if defined(ENABLE_WEBRTC)
186 bool ContentBrowserClient::AllowWebRTCIdentityCache(const GURL
& url
,
187 const GURL
& first_party_url
,
188 ResourceContext
* context
) {
191 #endif // defined(ENABLE_WEBRTC)
193 QuotaPermissionContext
* ContentBrowserClient::CreateQuotaPermissionContext() {
197 void ContentBrowserClient::SelectClientCertificate(
198 WebContents
* web_contents
,
199 net::SSLCertRequestInfo
* cert_request_info
,
200 scoped_ptr
<ClientCertificateDelegate
> delegate
) {
203 net::URLRequestContext
* ContentBrowserClient::OverrideRequestContextForURL(
204 const GURL
& url
, ResourceContext
* context
) {
208 std::string
ContentBrowserClient::GetStoragePartitionIdForSite(
209 BrowserContext
* browser_context
,
211 return std::string();
214 bool ContentBrowserClient::IsValidStoragePartitionId(
215 BrowserContext
* browser_context
,
216 const std::string
& partition_id
) {
217 // Since the GetStoragePartitionIdForChildProcess() only generates empty
218 // strings, we should only ever see empty strings coming back.
219 return partition_id
.empty();
222 void ContentBrowserClient::GetStoragePartitionConfigForSite(
223 BrowserContext
* browser_context
,
226 std::string
* partition_domain
,
227 std::string
* partition_name
,
229 partition_domain
->clear();
230 partition_name
->clear();
234 MediaObserver
* ContentBrowserClient::GetMediaObserver() {
238 PlatformNotificationService
*
239 ContentBrowserClient::GetPlatformNotificationService() {
243 bool ContentBrowserClient::CanCreateWindow(
244 const GURL
& opener_url
,
245 const GURL
& opener_top_level_frame_url
,
246 const GURL
& source_origin
,
247 WindowContainerType container_type
,
248 const GURL
& target_url
,
249 const Referrer
& referrer
,
250 WindowOpenDisposition disposition
,
251 const blink::WebWindowFeatures
& features
,
253 bool opener_suppressed
,
254 ResourceContext
* context
,
255 int render_process_id
,
256 int opener_render_view_id
,
257 int opener_render_frame_id
,
258 bool* no_javascript_access
) {
259 *no_javascript_access
= false;
263 SpeechRecognitionManagerDelegate
*
264 ContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
268 net::NetLog
* ContentBrowserClient::GetNetLog() {
272 AccessTokenStore
* ContentBrowserClient::CreateAccessTokenStore() {
276 bool ContentBrowserClient::IsFastShutdownPossible() {
280 base::FilePath
ContentBrowserClient::GetDefaultDownloadDirectory() {
281 return base::FilePath();
284 std::string
ContentBrowserClient::GetDefaultDownloadName() {
285 return std::string();
289 ContentBrowserClient::GetExternalBrowserPpapiHost(int plugin_process_id
) {
293 bool ContentBrowserClient::AllowPepperSocketAPI(
294 BrowserContext
* browser_context
,
297 const SocketPermissionRequest
* params
) {
301 ui::SelectFilePolicy
* ContentBrowserClient::CreateSelectFilePolicy(
302 WebContents
* web_contents
) {
306 LocationProvider
* ContentBrowserClient::OverrideSystemLocationProvider() {
310 DevToolsManagerDelegate
* ContentBrowserClient::GetDevToolsManagerDelegate() {
314 TracingDelegate
* ContentBrowserClient::GetTracingDelegate() {
318 bool ContentBrowserClient::IsNPAPIEnabled() {
322 bool ContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle(
323 BrowserContext
* browser_context
,
328 bool ContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs(
329 BrowserContext
* browser_context
,
334 PresentationServiceDelegate
*
335 ContentBrowserClient::GetPresentationServiceDelegate(
336 WebContents
* web_contents
) {
340 void ContentBrowserClient::OpenURL(
341 content::BrowserContext
* browser_context
,
342 const content::OpenURLParams
& params
,
343 const base::Callback
<void(content::WebContents
*)>& callback
) {
344 callback
.Run(nullptr);
348 const wchar_t* ContentBrowserClient::GetResourceDllName() {
352 base::string16
ContentBrowserClient::GetAppContainerSidForSandboxType(
353 int sandbox_type
) const {
354 // Embedders should override this method and return different SIDs for each
355 // sandbox type. Note: All content level tests will run child processes in the
356 // same AppContainer.
357 return base::string16(
358 L
"S-1-15-2-3251537155-1984446955-2931258699-841473695-1938553385-"
359 L
"924012148-129201922");
363 #if defined(VIDEO_HOLE)
364 ExternalVideoSurfaceContainer
*
365 ContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer(
366 WebContents
* web_contents
) {
367 NOTREACHED() << "Hole-punching is not supported. See crbug.com/469348.";
372 } // namespace content