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