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 "ui/gfx/image/image_skia.h"
14 BrowserMainParts
* ContentBrowserClient::CreateBrowserMainParts(
15 const MainFunctionParams
& parameters
) {
19 void ContentBrowserClient::PostAfterStartupTask(
20 const tracked_objects::Location
& from_here
,
21 const scoped_refptr
<base::TaskRunner
>& task_runner
,
22 const base::Closure
& task
) {
23 task_runner
->PostTask(from_here
, task
);
26 WebContentsViewDelegate
* ContentBrowserClient::GetWebContentsViewDelegate(
27 WebContents
* web_contents
) {
31 GURL
ContentBrowserClient::GetEffectiveURL(BrowserContext
* browser_context
,
36 bool ContentBrowserClient::ShouldUseProcessPerSite(
37 BrowserContext
* browser_context
, const GURL
& effective_url
) {
41 net::URLRequestContextGetter
* ContentBrowserClient::CreateRequestContext(
42 BrowserContext
* browser_context
,
43 ProtocolHandlerMap
* protocol_handlers
,
44 URLRequestInterceptorScopedVector request_interceptors
) {
48 net::URLRequestContextGetter
*
49 ContentBrowserClient::CreateRequestContextForStoragePartition(
50 BrowserContext
* browser_context
,
51 const base::FilePath
& partition_path
,
53 ProtocolHandlerMap
* protocol_handlers
,
54 URLRequestInterceptorScopedVector request_interceptors
) {
58 bool ContentBrowserClient::IsHandledURL(const GURL
& url
) {
62 bool ContentBrowserClient::CanCommitURL(RenderProcessHost
* process_host
,
63 const GURL
& site_url
) {
67 bool ContentBrowserClient::ShouldAllowOpenURL(SiteInstance
* site_instance
,
72 bool ContentBrowserClient::IsSuitableHost(RenderProcessHost
* process_host
,
73 const GURL
& site_url
) {
77 bool ContentBrowserClient::MayReuseHost(RenderProcessHost
* process_host
) {
81 bool ContentBrowserClient::ShouldTryToUseExistingProcessHost(
82 BrowserContext
* browser_context
, const GURL
& url
) {
86 bool ContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation(
87 SiteInstance
* site_instance
,
88 const GURL
& current_url
,
89 const GURL
& new_url
) {
93 bool ContentBrowserClient::ShouldSwapProcessesForRedirect(
94 ResourceContext
* resource_context
, const GURL
& current_url
,
95 const GURL
& new_url
) {
99 bool ContentBrowserClient::ShouldAssignSiteForURL(const GURL
& url
) {
103 std::string
ContentBrowserClient::GetCanonicalEncodingNameByAliasName(
104 const std::string
& alias_name
) {
105 return std::string();
108 std::string
ContentBrowserClient::GetApplicationLocale() {
112 std::string
ContentBrowserClient::GetAcceptLangs(BrowserContext
* context
) {
113 return std::string();
116 const gfx::ImageSkia
* ContentBrowserClient::GetDefaultFavicon() {
117 static gfx::ImageSkia
* empty
= new gfx::ImageSkia();
121 bool ContentBrowserClient::AllowAppCache(const GURL
& manifest_url
,
122 const GURL
& first_party
,
123 ResourceContext
* context
) {
127 bool ContentBrowserClient::AllowServiceWorker(const GURL
& scope
,
128 const GURL
& document_url
,
129 content::ResourceContext
* context
,
130 int render_process_id
,
131 int render_frame_id
) {
135 bool ContentBrowserClient::AllowGetCookie(const GURL
& url
,
136 const GURL
& first_party
,
137 const net::CookieList
& cookie_list
,
138 ResourceContext
* context
,
139 int render_process_id
,
140 int render_frame_id
) {
144 bool ContentBrowserClient::AllowSetCookie(const GURL
& url
,
145 const GURL
& first_party
,
146 const std::string
& cookie_line
,
147 ResourceContext
* context
,
148 int render_process_id
,
150 net::CookieOptions
* options
) {
154 bool ContentBrowserClient::AllowSaveLocalState(ResourceContext
* context
) {
158 bool ContentBrowserClient::AllowWorkerDatabase(
160 const base::string16
& name
,
161 const base::string16
& display_name
,
162 unsigned long estimated_size
,
163 ResourceContext
* context
,
164 const std::vector
<std::pair
<int, int> >& render_frames
) {
168 void ContentBrowserClient::AllowWorkerFileSystem(
170 ResourceContext
* context
,
171 const std::vector
<std::pair
<int, int> >& render_frames
,
172 base::Callback
<void(bool)> callback
) {
176 bool ContentBrowserClient::AllowWorkerIndexedDB(
178 const base::string16
& name
,
179 ResourceContext
* context
,
180 const std::vector
<std::pair
<int, int> >& render_frames
) {
184 QuotaPermissionContext
* ContentBrowserClient::CreateQuotaPermissionContext() {
188 void ContentBrowserClient::SelectClientCertificate(
189 WebContents
* web_contents
,
190 net::SSLCertRequestInfo
* cert_request_info
,
191 scoped_ptr
<ClientCertificateDelegate
> delegate
) {
194 net::URLRequestContext
* ContentBrowserClient::OverrideRequestContextForURL(
195 const GURL
& url
, ResourceContext
* context
) {
199 std::string
ContentBrowserClient::GetStoragePartitionIdForSite(
200 BrowserContext
* browser_context
,
202 return std::string();
205 bool ContentBrowserClient::IsValidStoragePartitionId(
206 BrowserContext
* browser_context
,
207 const std::string
& partition_id
) {
208 // Since the GetStoragePartitionIdForChildProcess() only generates empty
209 // strings, we should only ever see empty strings coming back.
210 return partition_id
.empty();
213 void ContentBrowserClient::GetStoragePartitionConfigForSite(
214 BrowserContext
* browser_context
,
217 std::string
* partition_domain
,
218 std::string
* partition_name
,
220 partition_domain
->clear();
221 partition_name
->clear();
225 MediaObserver
* ContentBrowserClient::GetMediaObserver() {
229 PlatformNotificationService
*
230 ContentBrowserClient::GetPlatformNotificationService() {
234 bool ContentBrowserClient::CanCreateWindow(
235 const GURL
& opener_url
,
236 const GURL
& opener_top_level_frame_url
,
237 const GURL
& source_origin
,
238 WindowContainerType container_type
,
239 const GURL
& target_url
,
240 const Referrer
& referrer
,
241 WindowOpenDisposition disposition
,
242 const blink::WebWindowFeatures
& features
,
244 bool opener_suppressed
,
245 ResourceContext
* context
,
246 int render_process_id
,
247 int opener_render_view_id
,
248 int opener_render_frame_id
,
249 bool* no_javascript_access
) {
250 *no_javascript_access
= false;
254 SpeechRecognitionManagerDelegate
*
255 ContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
259 net::NetLog
* ContentBrowserClient::GetNetLog() {
263 AccessTokenStore
* ContentBrowserClient::CreateAccessTokenStore() {
267 bool ContentBrowserClient::IsFastShutdownPossible() {
271 base::FilePath
ContentBrowserClient::GetDefaultDownloadDirectory() {
272 return base::FilePath();
275 std::string
ContentBrowserClient::GetDefaultDownloadName() {
276 return std::string();
280 ContentBrowserClient::GetExternalBrowserPpapiHost(int plugin_process_id
) {
284 bool ContentBrowserClient::AllowPepperSocketAPI(
285 BrowserContext
* browser_context
,
288 const SocketPermissionRequest
* params
) {
292 ui::SelectFilePolicy
* ContentBrowserClient::CreateSelectFilePolicy(
293 WebContents
* web_contents
) {
297 LocationProvider
* ContentBrowserClient::OverrideSystemLocationProvider() {
301 DevToolsManagerDelegate
* ContentBrowserClient::GetDevToolsManagerDelegate() {
305 TracingDelegate
* ContentBrowserClient::GetTracingDelegate() {
309 bool ContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle(
310 BrowserContext
* browser_context
,
315 bool ContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs(
316 BrowserContext
* browser_context
,
321 PresentationServiceDelegate
*
322 ContentBrowserClient::GetPresentationServiceDelegate(
323 WebContents
* web_contents
) {
327 void ContentBrowserClient::OpenURL(
328 content::BrowserContext
* browser_context
,
329 const content::OpenURLParams
& params
,
330 const base::Callback
<void(content::WebContents
*)>& callback
) {
331 callback
.Run(nullptr);
335 const wchar_t* ContentBrowserClient::GetResourceDllName() {
340 #if defined(VIDEO_HOLE)
341 ExternalVideoSurfaceContainer
*
342 ContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer(
343 WebContents
* web_contents
) {
344 NOTREACHED() << "Hole-punching is not supported. See crbug.com/469348.";
349 } // namespace content