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 CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_
6 #define CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_
13 #include "base/callback_forward.h"
14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/scoped_vector.h"
17 #include "base/values.h"
18 #include "content/public/browser/certificate_request_result_type.h"
19 #include "content/public/browser/navigation_throttle.h"
20 #include "content/public/common/content_client.h"
21 #include "content/public/common/media_stream_request.h"
22 #include "content/public/common/resource_type.h"
23 #include "content/public/common/socket_permission_request.h"
24 #include "content/public/common/window_container_type.h"
25 #include "net/base/mime_util.h"
26 #include "net/cookies/canonical_cookie.h"
27 #include "net/url_request/url_request_interceptor.h"
28 #include "net/url_request/url_request_job_factory.h"
29 #include "storage/browser/fileapi/file_system_context.h"
30 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h"
31 #include "ui/base/window_open_disposition.h"
33 #if defined(OS_POSIX) && !defined(OS_MACOSX)
34 #include "base/posix/global_descriptors.h"
38 #include "content/public/browser/file_descriptor_info.h"
45 class DictionaryValue
;
50 struct WebWindowFeatures
;
58 class ApplicationDelegate
;
64 class SSLCertRequestInfo
;
67 class URLRequestContext
;
68 class URLRequestContextGetter
;
69 class X509Certificate
;
77 class SelectFilePolicy
;
81 class ExternalMountPoints
;
82 class FileSystemBackend
;
87 enum class PermissionType
;
88 class AccessTokenStore
;
89 class BrowserChildProcessHost
;
91 class BrowserMainParts
;
92 class BrowserPluginGuestDelegate
;
93 class BrowserPpapiHost
;
94 class BrowserURLHandler
;
95 class ClientCertificateDelegate
;
96 class DevToolsManagerDelegate
;
97 class ExternalVideoSurfaceContainer
;
98 class LocationProvider
;
100 class NavigationHandle
;
101 class NavigatorConnectContext
;
102 class NavigatorConnectServiceFactory
;
103 class PlatformNotificationService
;
104 class PresentationServiceDelegate
;
105 class QuotaPermissionContext
;
106 class RenderFrameHost
;
107 class RenderProcessHost
;
108 class RenderViewHost
;
109 class ResourceContext
;
110 class ServiceRegistry
;
112 class SpeechRecognitionManagerDelegate
;
113 class TracingDelegate
;
115 class WebContentsViewDelegate
;
116 struct MainFunctionParams
;
117 struct OpenURLParams
;
119 struct WebPreferences
;
121 // A mapping from the scheme name to the protocol handler that services its
124 std::string
, linked_ptr
<net::URLRequestJobFactory::ProtocolHandler
> >
127 // A scoped vector of protocol interceptors.
128 typedef ScopedVector
<net::URLRequestInterceptor
>
129 URLRequestInterceptorScopedVector
;
131 // Embedder API (or SPI) for participating in browser logic, to be implemented
132 // by the client of the content browser. See ChromeContentBrowserClient for the
133 // principal implementation. The methods are assumed to be called on the UI
134 // thread unless otherwise specified. Use this "escape hatch" sparingly, to
135 // avoid the embedder interface ballooning and becoming very specific to Chrome.
136 // (Often, the call out to the client can happen in a different part of the code
137 // that either already has a hook out to the embedder, or calls out to one of
138 // the observer interfaces.)
139 class CONTENT_EXPORT ContentBrowserClient
{
141 virtual ~ContentBrowserClient() {}
143 // Allows the embedder to set any number of custom BrowserMainParts
144 // implementations for the browser startup code. See comments in
145 // browser_main_parts.h.
146 virtual BrowserMainParts
* CreateBrowserMainParts(
147 const MainFunctionParams
& parameters
);
149 // Allows the embedder to change the default behavior of
150 // BrowserThread::PostAfterStartupTask to better match whatever
151 // definition of "startup" the embedder has in mind. This may be
152 // called on any thread.
153 // Note: see related BrowserThread::PostAfterStartupTask.
154 virtual void PostAfterStartupTask(
155 const tracked_objects::Location
& from_here
,
156 const scoped_refptr
<base::TaskRunner
>& task_runner
,
157 const base::Closure
& task
);
159 // If content creates the WebContentsView implementation, it will ask the
160 // embedder to return an (optional) delegate to customize it. The view will
162 virtual WebContentsViewDelegate
* GetWebContentsViewDelegate(
163 WebContents
* web_contents
);
165 // Notifies that a render process will be created. This is called before
166 // the content layer adds its own BrowserMessageFilters, so that the
167 // embedder's IPC filters have priority.
168 virtual void RenderProcessWillLaunch(RenderProcessHost
* host
) {}
170 // Notifies that a BrowserChildProcessHost has been created.
171 virtual void BrowserChildProcessHostCreated(BrowserChildProcessHost
* host
) {}
173 // Get the effective URL for the given actual URL, to allow an embedder to
174 // group different url schemes in the same SiteInstance.
175 virtual GURL
GetEffectiveURL(BrowserContext
* browser_context
,
178 // Returns whether all instances of the specified effective URL should be
179 // rendered by the same process, rather than using process-per-site-instance.
180 virtual bool ShouldUseProcessPerSite(BrowserContext
* browser_context
,
181 const GURL
& effective_url
);
183 // Returns true unless the effective URL is part of a site that cannot live in
184 // a process dedicated to that site. This is only called if
185 // SiteIsolationPolicy::DoesSiteRequireDedicatedProcess returns true.
186 // TODO(nick): Remove this function once https://crbug.com/160576 is fixed,
187 // and origin lock can be applied to all URLs.
188 virtual bool ShouldLockToOrigin(BrowserContext
* browser_context
,
189 const GURL
& effective_url
);
191 // Returns a list additional WebUI schemes, if any. These additional schemes
192 // act as aliases to the chrome: scheme. The additional schemes may or may
193 // not serve specific WebUI pages depending on the particular URLDataSource
194 // and its override of URLDataSource::ShouldServiceRequest. For all schemes
195 // returned here, view-source is allowed.
196 virtual void GetAdditionalWebUISchemes(
197 std::vector
<std::string
>* additional_schemes
) {}
199 // Returns a list of webUI hosts to ignore the storage partition check in
200 // URLRequestChromeJob::CheckStoragePartitionMatches.
201 virtual void GetAdditionalWebUIHostsToIgnoreParititionCheck(
202 std::vector
<std::string
>* hosts
) {}
204 // Creates the main net::URLRequestContextGetter. Should only be called once
205 // per ContentBrowserClient object.
206 // TODO(ajwong): Remove once http://crbug.com/159193 is resolved.
207 virtual net::URLRequestContextGetter
* CreateRequestContext(
208 BrowserContext
* browser_context
,
209 ProtocolHandlerMap
* protocol_handlers
,
210 URLRequestInterceptorScopedVector request_interceptors
);
212 // Creates the net::URLRequestContextGetter for a StoragePartition. Should
213 // only be called once per partition_path per ContentBrowserClient object.
214 // TODO(ajwong): Remove once http://crbug.com/159193 is resolved.
215 virtual net::URLRequestContextGetter
* CreateRequestContextForStoragePartition(
216 BrowserContext
* browser_context
,
217 const base::FilePath
& partition_path
,
219 ProtocolHandlerMap
* protocol_handlers
,
220 URLRequestInterceptorScopedVector request_interceptors
);
222 // Returns whether a specified URL is handled by the embedder's internal
223 // protocol handlers.
224 virtual bool IsHandledURL(const GURL
& url
);
226 // Returns whether the given process is allowed to commit |url|. This is a
227 // more conservative check than IsSuitableHost, since it is used after a
228 // navigation has committed to ensure that the process did not exceed its
230 // This is called on the UI thread.
231 virtual bool CanCommitURL(RenderProcessHost
* process_host
, const GURL
& url
);
233 // Returns true if no URL within |origin| is allowed to commit in the given
234 // process. Must return false if there exists at least one URL in |origin|
235 // that is allowed to commit.
236 // This is called on the IO thread.
237 virtual bool IsIllegalOrigin(ResourceContext
* resource_context
,
238 int child_process_id
,
241 // Returns whether a URL should be allowed to open from a specific context.
242 // This also applies in cases where the new URL will open in another process.
243 virtual bool ShouldAllowOpenURL(SiteInstance
* site_instance
, const GURL
& url
);
245 // Returns whether a new view for a given |site_url| can be launched in a
246 // given |process_host|.
247 virtual bool IsSuitableHost(RenderProcessHost
* process_host
,
248 const GURL
& site_url
);
250 // Returns whether a new view for a new site instance can be added to a
251 // given |process_host|.
252 virtual bool MayReuseHost(RenderProcessHost
* process_host
);
254 // Returns whether a new process should be created or an existing one should
255 // be reused based on the URL we want to load. This should return false,
256 // unless there is a good reason otherwise.
257 virtual bool ShouldTryToUseExistingProcessHost(
258 BrowserContext
* browser_context
, const GURL
& url
);
260 // Called when a site instance is first associated with a process.
261 virtual void SiteInstanceGotProcess(SiteInstance
* site_instance
) {}
263 // Called from a site instance's destructor.
264 virtual void SiteInstanceDeleting(SiteInstance
* site_instance
) {}
266 // Returns true if for the navigation from |current_url| to |new_url|
267 // in |site_instance|, a new SiteInstance and BrowsingInstance should be
268 // created (even if we are in a process model that doesn't usually swap.)
269 // This forces a process swap and severs script connections with existing
271 virtual bool ShouldSwapBrowsingInstancesForNavigation(
272 SiteInstance
* site_instance
,
273 const GURL
& current_url
,
274 const GURL
& new_url
);
276 // Returns true if the given navigation redirect should cause a renderer
278 // This is called on the IO thread.
279 virtual bool ShouldSwapProcessesForRedirect(ResourceContext
* resource_context
,
280 const GURL
& current_url
,
281 const GURL
& new_url
);
283 // Returns true if the passed in URL should be assigned as the site of the
284 // current SiteInstance, if it does not yet have a site.
285 virtual bool ShouldAssignSiteForURL(const GURL
& url
);
287 // See CharacterEncoding's comment.
288 virtual std::string
GetCanonicalEncodingNameByAliasName(
289 const std::string
& alias_name
);
291 // Allows the embedder to pass extra command line flags.
292 // switches::kProcessType will already be set at this point.
293 virtual void AppendExtraCommandLineSwitches(base::CommandLine
* command_line
,
294 int child_process_id
) {}
296 // Returns the locale used by the application.
297 // This is called on the UI and IO threads.
298 virtual std::string
GetApplicationLocale();
300 // Returns the languages used in the Accept-Languages HTTP header.
301 // (Not called GetAcceptLanguages so it doesn't clash with win32).
302 virtual std::string
GetAcceptLangs(BrowserContext
* context
);
304 // Returns the default favicon. The callee doesn't own the given bitmap.
305 virtual const gfx::ImageSkia
* GetDefaultFavicon();
307 // Allow the embedder to control if an AppCache can be used for the given url.
308 // This is called on the IO thread.
309 virtual bool AllowAppCache(const GURL
& manifest_url
,
310 const GURL
& first_party
,
311 ResourceContext
* context
);
313 // Allow the embedder to control if a Service Worker can be associated
314 // with the given scope.
315 // Invalid (-1) process/frame ids indicate this is for starting a service
316 // worker, which is not necessarily associated with a particular frame.
317 // This is called on the IO thread.
318 virtual bool AllowServiceWorker(const GURL
& scope
,
319 const GURL
& first_party
,
320 content::ResourceContext
* context
,
321 int render_process_id
,
322 int render_frame_id
);
324 // Allow the embedder to control if the given cookie can be read.
325 // This is called on the IO thread.
326 virtual bool AllowGetCookie(const GURL
& url
,
327 const GURL
& first_party
,
328 const net::CookieList
& cookie_list
,
329 ResourceContext
* context
,
330 int render_process_id
,
331 int render_frame_id
);
333 // Allow the embedder to control if the given cookie can be set.
334 // This is called on the IO thread.
335 virtual bool AllowSetCookie(const GURL
& url
,
336 const GURL
& first_party
,
337 const std::string
& cookie_line
,
338 ResourceContext
* context
,
339 int render_process_id
,
341 net::CookieOptions
* options
);
343 // This is called on the IO thread.
344 virtual bool AllowSaveLocalState(ResourceContext
* context
);
346 // Allow the embedder to control if access to web database by a shared worker
347 // is allowed. |render_frame| is a vector of pairs of
348 // RenderProcessID/RenderFrameID of RenderFrame that are using this worker.
349 // This is called on the IO thread.
350 virtual bool AllowWorkerDatabase(
352 const base::string16
& name
,
353 const base::string16
& display_name
,
354 unsigned long estimated_size
,
355 ResourceContext
* context
,
356 const std::vector
<std::pair
<int, int> >& render_frames
);
358 // Allow the embedder to control if access to file system by a shared worker
360 // This is called on the IO thread.
361 virtual void AllowWorkerFileSystem(
363 ResourceContext
* context
,
364 const std::vector
<std::pair
<int, int> >& render_frames
,
365 base::Callback
<void(bool)> callback
);
367 // Allow the embedder to control if access to IndexedDB by a shared worker
369 // This is called on the IO thread.
370 virtual bool AllowWorkerIndexedDB(
372 const base::string16
& name
,
373 ResourceContext
* context
,
374 const std::vector
<std::pair
<int, int> >& render_frames
);
376 #if defined(ENABLE_WEBRTC)
377 // Allow the embedder to control if WebRTC identities are allowed to be cached
378 // and potentially reused for future requests (within the same origin).
379 // This is called on the IO thread.
380 virtual bool AllowWebRTCIdentityCache(const GURL
& url
,
381 const GURL
& first_party_url
,
382 ResourceContext
* context
);
383 #endif // defined(ENABLE_WEBRTC)
385 // Allow the embedder to override the request context based on the URL for
386 // certain operations, like cookie access. Returns nullptr to indicate the
387 // regular request context should be used.
388 // This is called on the IO thread.
389 virtual net::URLRequestContext
* OverrideRequestContextForURL(
390 const GURL
& url
, ResourceContext
* context
);
392 // Allow the embedder to specify a string version of the storage partition
393 // config with a site.
394 virtual std::string
GetStoragePartitionIdForSite(
395 BrowserContext
* browser_context
,
398 // Allows the embedder to provide a validation check for |partition_id|s.
399 // This domain of valid entries should match the range of outputs for
400 // GetStoragePartitionIdForChildProcess().
401 virtual bool IsValidStoragePartitionId(BrowserContext
* browser_context
,
402 const std::string
& partition_id
);
404 // Allows the embedder to provide a storage parititon configuration for a
405 // site. A storage partition configuration includes a domain of the embedder's
406 // choice, an optional name within that domain, and whether the partition is
409 // If |can_be_default| is false, the caller is telling the embedder that the
410 // |site| is known to not be in the default partition. This is useful in
411 // some shutdown situations where the bookkeeping logic that maps sites to
412 // their partition configuration are no longer valid.
414 // The |partition_domain| is [a-z]* UTF-8 string, specifying the domain in
415 // which partitions live (similar to namespace). Within a domain, partitions
416 // can be uniquely identified by the combination of |partition_name| and
417 // |in_memory| values. When a partition is not to be persisted, the
418 // |in_memory| value must be set to true.
419 virtual void GetStoragePartitionConfigForSite(
420 BrowserContext
* browser_context
,
423 std::string
* partition_domain
,
424 std::string
* partition_name
,
427 // Create and return a new quota permission context.
428 virtual QuotaPermissionContext
* CreateQuotaPermissionContext();
430 // Informs the embedder that a certificate error has occured. If
431 // |overridable| is true and if |strict_enforcement| is false, the user
432 // can ignore the error and continue. The embedder can call the callback
433 // asynchronously. If |result| is not set to
434 // CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE, the request will be cancelled
435 // or denied immediately, and the callback won't be run.
436 virtual void AllowCertificateError(int render_process_id
,
439 const net::SSLInfo
& ssl_info
,
440 const GURL
& request_url
,
441 ResourceType resource_type
,
443 bool strict_enforcement
,
444 bool expired_previous_decision
,
445 const base::Callback
<void(bool)>& callback
,
446 CertificateRequestResultType
* result
) {}
448 // Selects a SSL client certificate and returns it to the |delegate|. Note:
449 // |delegate| may be called synchronously or asynchronously.
451 // TODO(davidben): Move this hook to WebContentsDelegate.
452 virtual void SelectClientCertificate(
453 WebContents
* web_contents
,
454 net::SSLCertRequestInfo
* cert_request_info
,
455 scoped_ptr
<ClientCertificateDelegate
> delegate
);
457 // Adds a new installable certificate or private key.
458 // Typically used to install an X.509 user certificate.
459 // Note that it's up to the embedder to verify that the data is
460 // well-formed. |cert_data| will be nullptr if |cert_size| is 0.
461 virtual void AddCertificate(net::CertificateMimeType cert_type
,
462 const void* cert_data
,
464 int render_process_id
,
465 int render_frame_id
) {}
467 // Returns a class to get notifications about media event. The embedder can
468 // return nullptr if they're not interested.
469 virtual MediaObserver
* GetMediaObserver();
471 // Returns the platform notification service, capable of displaying Web
472 // Notifications to the user. The embedder can return a nullptr if they don't
473 // support this functionality. May be called from any thread.
474 virtual PlatformNotificationService
* GetPlatformNotificationService();
476 // Returns true if the given page is allowed to open a window of the given
477 // type. If true is returned, |no_javascript_access| will indicate whether
478 // the window that is created should be scriptable/in the same process.
479 // This is called on the IO thread.
480 virtual bool CanCreateWindow(const GURL
& opener_url
,
481 const GURL
& opener_top_level_frame_url
,
482 const GURL
& source_origin
,
483 WindowContainerType container_type
,
484 const GURL
& target_url
,
485 const Referrer
& referrer
,
486 WindowOpenDisposition disposition
,
487 const blink::WebWindowFeatures
& features
,
489 bool opener_suppressed
,
490 ResourceContext
* context
,
491 int render_process_id
,
492 int opener_render_view_id
,
493 int opener_render_frame_id
,
494 bool* no_javascript_access
);
496 // Notifies the embedder that the ResourceDispatcherHost has been created.
497 // This is when it can optionally add a delegate.
498 virtual void ResourceDispatcherHostCreated() {}
500 // Allows the embedder to return a delegate for the SpeechRecognitionManager.
501 // The delegate will be owned by the manager. It's valid to return nullptr.
502 virtual SpeechRecognitionManagerDelegate
*
503 CreateSpeechRecognitionManagerDelegate();
505 // Getters for common objects.
506 virtual net::NetLog
* GetNetLog();
508 // Creates a new AccessTokenStore for gelocation.
509 virtual AccessTokenStore
* CreateAccessTokenStore();
511 // Returns true if fast shutdown is possible.
512 virtual bool IsFastShutdownPossible();
514 // Called by WebContents to override the WebKit preferences that are used by
515 // the renderer. The content layer will add its own settings, and then it's up
516 // to the embedder to update it if it wants.
517 virtual void OverrideWebkitPrefs(RenderViewHost
* render_view_host
,
518 WebPreferences
* prefs
) {}
520 // Notifies that BrowserURLHandler has been created, so that the embedder can
521 // optionally add their own handlers.
522 virtual void BrowserURLHandlerCreated(BrowserURLHandler
* handler
) {}
524 // Clears browser cache.
525 virtual void ClearCache(RenderFrameHost
* rfh
) {}
527 // Clears browser cookies.
528 virtual void ClearCookies(RenderFrameHost
* rfh
) {}
530 // Returns the default download directory.
531 // This can be called on any thread.
532 virtual base::FilePath
GetDefaultDownloadDirectory();
534 // Returns the default filename used in downloads when we have no idea what
535 // else we should do with the file.
536 virtual std::string
GetDefaultDownloadName();
538 // Returns the path to the browser shader disk cache root.
539 virtual base::FilePath
GetShaderDiskCacheDirectory();
541 // Notification that a pepper plugin has just been spawned. This allows the
542 // embedder to add filters onto the host to implement interfaces.
543 // This is called on the IO thread.
544 virtual void DidCreatePpapiPlugin(BrowserPpapiHost
* browser_host
) {}
546 // Gets the host for an external out-of-process plugin.
547 virtual BrowserPpapiHost
* GetExternalBrowserPpapiHost(
548 int plugin_child_id
);
550 // Returns true if the socket operation specified by |params| is allowed from
551 // the given |browser_context| and |url|. If |params| is nullptr, this method
552 // checks the basic "socket" permission, which is for those operations that
553 // don't require a specific socket permission rule.
554 // |private_api| indicates whether this permission check is for the private
555 // Pepper socket API or the public one.
556 virtual bool AllowPepperSocketAPI(BrowserContext
* browser_context
,
559 const SocketPermissionRequest
* params
);
561 // Returns an implementation of a file selecition policy. Can return nullptr.
562 virtual ui::SelectFilePolicy
* CreateSelectFilePolicy(
563 WebContents
* web_contents
);
565 // Returns additional allowed scheme set which can access files in
567 virtual void GetAdditionalAllowedSchemesForFileSystem(
568 std::vector
<std::string
>* additional_schemes
) {}
570 // Returns auto mount handlers for URL requests for FileSystem APIs.
571 virtual void GetURLRequestAutoMountHandlers(
572 std::vector
<storage::URLRequestAutoMountHandler
>* handlers
) {}
574 // Returns additional file system backends for FileSystem API.
575 // |browser_context| is needed in the additional FileSystemBackends.
576 // It has mount points to create objects returned by additional
577 // FileSystemBackends, and SpecialStoragePolicy for permission granting.
578 virtual void GetAdditionalFileSystemBackends(
579 BrowserContext
* browser_context
,
580 const base::FilePath
& storage_partition_path
,
581 ScopedVector
<storage::FileSystemBackend
>* additional_backends
) {}
583 // Allows an embedder to return its own LocationProvider implementation.
584 // Return nullptr to use the default one for the platform to be created.
585 // FYI: Used by an external project; please don't remove.
586 // Contact Viatcheslav Ostapenko at sl.ostapenko@samsung.com for more
588 virtual LocationProvider
* OverrideSystemLocationProvider();
590 // Creates a new DevToolsManagerDelegate. The caller owns the returned value.
591 // It's valid to return nullptr.
592 virtual DevToolsManagerDelegate
* GetDevToolsManagerDelegate();
594 // Creates a new TracingDelegate. The caller owns the returned value.
595 // It's valid to return nullptr.
596 virtual TracingDelegate
* GetTracingDelegate();
598 // Returns true if NPAPI plugins are enabled.
599 virtual bool IsNPAPIEnabled();
601 // Returns true if plugin referred to by the url can use
602 // pp::FileIO::RequestOSFileHandle.
603 virtual bool IsPluginAllowedToCallRequestOSFileHandle(
604 BrowserContext
* browser_context
,
607 // Returns true if dev channel APIs are available for plugins.
608 virtual bool IsPluginAllowedToUseDevChannelAPIs(
609 BrowserContext
* browser_context
,
612 // Allows to register browser Mojo services exposed through the
613 // RenderProcessHost.
614 virtual void RegisterRenderProcessMojoServices(ServiceRegistry
* registry
) {}
616 // Allows to register browser Mojo services exposed through the
618 virtual void RegisterFrameMojoShellServices(
619 ServiceRegistry
* registry
,
620 RenderFrameHost
* render_frame_host
) {}
622 using StaticMojoApplicationMap
=
623 std::map
<GURL
, base::Callback
<scoped_ptr
<mojo::ApplicationDelegate
>()>>;
625 // Registers Mojo applications to be loaded in the browser process by the
626 // browser's global Mojo shell.
627 virtual void RegisterInProcessMojoApplications(
628 StaticMojoApplicationMap
* apps
) {}
630 using OutOfProcessMojoApplicationMap
= std::map
<GURL
, base::string16
>;
632 // Registers Mojo applications to be loaded out of the browser process, in a
633 // sandboxed utility process. The value of each map entry should be the
634 // process name to use for the application's host process when launched.
635 virtual void RegisterOutOfProcessMojoApplications(
636 OutOfProcessMojoApplicationMap
* apps
) {}
638 // Registers Mojo applications to be loaded out of the browser process (in
639 // a utility process) without the sandbox.
641 // WARNING: This path is NOT recommended! If a Mojo application needs a
642 // service that is only available out of the sandbox, it could ask the browser
643 // process to provide it (e.g. through OverrideFrameMojoShellServices()). Only
644 // use this method when that approach does not work.
645 virtual void RegisterUnsandboxedOutOfProcessMojoApplications(
646 OutOfProcessMojoApplicationMap
* apps
) {}
648 // Registers additional navigator.connect service factories available in a
649 // particular NavigatorConnectContext.
650 virtual void GetAdditionalNavigatorConnectServices(
651 const scoped_refptr
<NavigatorConnectContext
>& context
) {}
653 // Allows to override the visibility state of a RenderFrameHost.
654 // |visibility_state| should not be null. It will only be set if needed.
655 virtual void OverridePageVisibilityState(
656 RenderFrameHost
* render_frame_host
,
657 blink::WebPageVisibilityState
* visibility_state
) {}
659 // Allows an embedder to provide its own PresentationServiceDelegate
660 // implementation. Returns nullptr if unavailable.
661 virtual PresentationServiceDelegate
* GetPresentationServiceDelegate(
662 WebContents
* web_contents
);
664 // Allows programmatic opening of a new tab/window without going through
665 // another WebContents. For example, from a Worker. |callback| will be
666 // invoked with the appropriate WebContents* when available.
667 virtual void OpenURL(BrowserContext
* browser_context
,
668 const OpenURLParams
& params
,
669 const base::Callback
<void(WebContents
*)>& callback
);
671 // Allows the embedder to record |metric| for a specific |url|.
672 virtual void RecordURLMetric(const std::string
& metric
, const GURL
& url
) {}
674 // Allows the embedder to register one or more NavigationThrottles for the
675 // navigation indicated by |navigation_handle|. A NavigationThrottle is used
676 // to control the flow of a navigation on the UI thread. The embedder is
677 // guaranteed that the throttles will be executed in the order they were
679 virtual ScopedVector
<NavigationThrottle
> CreateThrottlesForNavigation(
680 NavigationHandle
* navigation_handle
);
682 // Populates |mappings| with all files that need to be mapped before launching
684 #if defined(OS_ANDROID)
685 virtual void GetAdditionalMappedFilesForChildProcess(
686 const base::CommandLine
& command_line
,
687 int child_process_id
,
688 content::FileDescriptorInfo
* mappings
,
689 std::map
<int, base::MemoryMappedFile::Region
>* regions
) {}
690 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
691 virtual void GetAdditionalMappedFilesForChildProcess(
692 const base::CommandLine
& command_line
,
693 int child_process_id
,
694 content::FileDescriptorInfo
* mappings
) {}
695 #endif // defined(OS_ANDROID)
698 // Returns the name of the dll that contains cursors and other resources.
699 virtual const wchar_t* GetResourceDllName();
701 // This is called on the PROCESS_LAUNCHER thread before the renderer process
702 // is launched. It gives the embedder a chance to add loosen the sandbox
704 virtual void PreSpawnRenderer(sandbox::TargetPolicy
* policy
,
707 // Returns the AppContainer SID for the specified sandboxed process type, or
708 // empty string if this sandboxed process type does not support living inside
710 virtual base::string16
GetAppContainerSidForSandboxType(
711 int sandbox_type
) const;
714 #if defined(VIDEO_HOLE)
715 // Allows an embedder to provide its own ExternalVideoSurfaceContainer
716 // implementation. Return nullptr to disable external surface video.
717 virtual ExternalVideoSurfaceContainer
*
718 OverrideCreateExternalVideoSurfaceContainer(WebContents
* web_contents
);
722 } // namespace content
724 #endif // CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_