Popular sites on the NTP: Try to keep the ordering constant
[chromium-blink-merge.git] / content / public / browser / content_browser_client.h
blobb9c0f419c5d3e2528301a7f8c637c8aa93bfb551
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 a list additional WebUI schemes, if any. These additional schemes
182 // act as aliases to the chrome: scheme. The additional schemes may or may
183 // not serve specific WebUI pages depending on the particular URLDataSource
184 // and its override of URLDataSource::ShouldServiceRequest. For all schemes
185 // returned here, view-source is allowed.
186 virtual void GetAdditionalWebUISchemes(
187 std::vector<std::string>* additional_schemes) {}
189 // Returns a list of webUI hosts to ignore the storage partition check in
190 // URLRequestChromeJob::CheckStoragePartitionMatches.
191 virtual void GetAdditionalWebUIHostsToIgnoreParititionCheck(
192 std::vector<std::string>* hosts) {}
194 // Creates the main net::URLRequestContextGetter. Should only be called once
195 // per ContentBrowserClient object.
196 // TODO(ajwong): Remove once http://crbug.com/159193 is resolved.
197 virtual net::URLRequestContextGetter* CreateRequestContext(
198 BrowserContext* browser_context,
199 ProtocolHandlerMap* protocol_handlers,
200 URLRequestInterceptorScopedVector request_interceptors);
202 // Creates the net::URLRequestContextGetter for a StoragePartition. Should
203 // only be called once per partition_path per ContentBrowserClient object.
204 // TODO(ajwong): Remove once http://crbug.com/159193 is resolved.
205 virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
206 BrowserContext* browser_context,
207 const base::FilePath& partition_path,
208 bool in_memory,
209 ProtocolHandlerMap* protocol_handlers,
210 URLRequestInterceptorScopedVector request_interceptors);
212 // Returns whether a specified URL is handled by the embedder's internal
213 // protocol handlers.
214 virtual bool IsHandledURL(const GURL& url);
216 // Returns whether the given process is allowed to commit |url|. This is a
217 // more conservative check than IsSuitableHost, since it is used after a
218 // navigation has committed to ensure that the process did not exceed its
219 // authority.
220 virtual bool CanCommitURL(RenderProcessHost* process_host, const GURL& url);
222 // Returns whether a URL should be allowed to open from a specific context.
223 // This also applies in cases where the new URL will open in another process.
224 virtual bool ShouldAllowOpenURL(SiteInstance* site_instance, const GURL& url);
226 // Returns whether a new view for a given |site_url| can be launched in a
227 // given |process_host|.
228 virtual bool IsSuitableHost(RenderProcessHost* process_host,
229 const GURL& site_url);
231 // Returns whether a new view for a new site instance can be added to a
232 // given |process_host|.
233 virtual bool MayReuseHost(RenderProcessHost* process_host);
235 // Returns whether a new process should be created or an existing one should
236 // be reused based on the URL we want to load. This should return false,
237 // unless there is a good reason otherwise.
238 virtual bool ShouldTryToUseExistingProcessHost(
239 BrowserContext* browser_context, const GURL& url);
241 // Called when a site instance is first associated with a process.
242 virtual void SiteInstanceGotProcess(SiteInstance* site_instance) {}
244 // Called from a site instance's destructor.
245 virtual void SiteInstanceDeleting(SiteInstance* site_instance) {}
247 // Returns true if for the navigation from |current_url| to |new_url|
248 // in |site_instance|, a new SiteInstance and BrowsingInstance should be
249 // created (even if we are in a process model that doesn't usually swap.)
250 // This forces a process swap and severs script connections with existing
251 // tabs.
252 virtual bool ShouldSwapBrowsingInstancesForNavigation(
253 SiteInstance* site_instance,
254 const GURL& current_url,
255 const GURL& new_url);
257 // Returns true if the given navigation redirect should cause a renderer
258 // process swap.
259 // This is called on the IO thread.
260 virtual bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context,
261 const GURL& current_url,
262 const GURL& new_url);
264 // Returns true if the passed in URL should be assigned as the site of the
265 // current SiteInstance, if it does not yet have a site.
266 virtual bool ShouldAssignSiteForURL(const GURL& url);
268 // See CharacterEncoding's comment.
269 virtual std::string GetCanonicalEncodingNameByAliasName(
270 const std::string& alias_name);
272 // Allows the embedder to pass extra command line flags.
273 // switches::kProcessType will already be set at this point.
274 virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
275 int child_process_id) {}
277 // Returns the locale used by the application.
278 // This is called on the UI and IO threads.
279 virtual std::string GetApplicationLocale();
281 // Returns the languages used in the Accept-Languages HTTP header.
282 // (Not called GetAcceptLanguages so it doesn't clash with win32).
283 virtual std::string GetAcceptLangs(BrowserContext* context);
285 // Returns the default favicon. The callee doesn't own the given bitmap.
286 virtual const gfx::ImageSkia* GetDefaultFavicon();
288 // Allow the embedder to control if an AppCache can be used for the given url.
289 // This is called on the IO thread.
290 virtual bool AllowAppCache(const GURL& manifest_url,
291 const GURL& first_party,
292 ResourceContext* context);
294 // Allow the embedder to control if a Service Worker can be associated
295 // with the given scope.
296 // This is called on the IO thread.
297 virtual bool AllowServiceWorker(const GURL& scope,
298 const GURL& first_party,
299 content::ResourceContext* context,
300 int render_process_id,
301 int render_frame_id);
303 // Allow the embedder to control if the given cookie can be read.
304 // This is called on the IO thread.
305 virtual bool AllowGetCookie(const GURL& url,
306 const GURL& first_party,
307 const net::CookieList& cookie_list,
308 ResourceContext* context,
309 int render_process_id,
310 int render_frame_id);
312 // Allow the embedder to control if the given cookie can be set.
313 // This is called on the IO thread.
314 virtual bool AllowSetCookie(const GURL& url,
315 const GURL& first_party,
316 const std::string& cookie_line,
317 ResourceContext* context,
318 int render_process_id,
319 int render_frame_id,
320 net::CookieOptions* options);
322 // This is called on the IO thread.
323 virtual bool AllowSaveLocalState(ResourceContext* context);
325 // Allow the embedder to control if access to web database by a shared worker
326 // is allowed. |render_frame| is a vector of pairs of
327 // RenderProcessID/RenderFrameID of RenderFrame that are using this worker.
328 // This is called on the IO thread.
329 virtual bool AllowWorkerDatabase(
330 const GURL& url,
331 const base::string16& name,
332 const base::string16& display_name,
333 unsigned long estimated_size,
334 ResourceContext* context,
335 const std::vector<std::pair<int, int> >& render_frames);
337 // Allow the embedder to control if access to file system by a shared worker
338 // is allowed.
339 // This is called on the IO thread.
340 virtual void AllowWorkerFileSystem(
341 const GURL& url,
342 ResourceContext* context,
343 const std::vector<std::pair<int, int> >& render_frames,
344 base::Callback<void(bool)> callback);
346 // Allow the embedder to control if access to IndexedDB by a shared worker
347 // is allowed.
348 // This is called on the IO thread.
349 virtual bool AllowWorkerIndexedDB(
350 const GURL& url,
351 const base::string16& name,
352 ResourceContext* context,
353 const std::vector<std::pair<int, int> >& render_frames);
355 #if defined(ENABLE_WEBRTC)
356 // Allow the embedder to control if WebRTC identities are allowed to be cached
357 // and potentially reused for future requests (within the same origin).
358 // This is called on the IO thread.
359 virtual bool AllowWebRTCIdentityCache(const GURL& url,
360 const GURL& first_party_url,
361 ResourceContext* context);
362 #endif // defined(ENABLE_WEBRTC)
364 // Allow the embedder to override the request context based on the URL for
365 // certain operations, like cookie access. Returns nullptr to indicate the
366 // regular request context should be used.
367 // This is called on the IO thread.
368 virtual net::URLRequestContext* OverrideRequestContextForURL(
369 const GURL& url, ResourceContext* context);
371 // Allow the embedder to specify a string version of the storage partition
372 // config with a site.
373 virtual std::string GetStoragePartitionIdForSite(
374 BrowserContext* browser_context,
375 const GURL& site);
377 // Allows the embedder to provide a validation check for |partition_id|s.
378 // This domain of valid entries should match the range of outputs for
379 // GetStoragePartitionIdForChildProcess().
380 virtual bool IsValidStoragePartitionId(BrowserContext* browser_context,
381 const std::string& partition_id);
383 // Allows the embedder to provide a storage parititon configuration for a
384 // site. A storage partition configuration includes a domain of the embedder's
385 // choice, an optional name within that domain, and whether the partition is
386 // in-memory only.
388 // If |can_be_default| is false, the caller is telling the embedder that the
389 // |site| is known to not be in the default partition. This is useful in
390 // some shutdown situations where the bookkeeping logic that maps sites to
391 // their partition configuration are no longer valid.
393 // The |partition_domain| is [a-z]* UTF-8 string, specifying the domain in
394 // which partitions live (similar to namespace). Within a domain, partitions
395 // can be uniquely identified by the combination of |partition_name| and
396 // |in_memory| values. When a partition is not to be persisted, the
397 // |in_memory| value must be set to true.
398 virtual void GetStoragePartitionConfigForSite(
399 BrowserContext* browser_context,
400 const GURL& site,
401 bool can_be_default,
402 std::string* partition_domain,
403 std::string* partition_name,
404 bool* in_memory);
406 // Create and return a new quota permission context.
407 virtual QuotaPermissionContext* CreateQuotaPermissionContext();
409 // Informs the embedder that a certificate error has occured. If
410 // |overridable| is true and if |strict_enforcement| is false, the user
411 // can ignore the error and continue. The embedder can call the callback
412 // asynchronously. If |result| is not set to
413 // CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE, the request will be cancelled
414 // or denied immediately, and the callback won't be run.
415 virtual void AllowCertificateError(int render_process_id,
416 int render_frame_id,
417 int cert_error,
418 const net::SSLInfo& ssl_info,
419 const GURL& request_url,
420 ResourceType resource_type,
421 bool overridable,
422 bool strict_enforcement,
423 bool expired_previous_decision,
424 const base::Callback<void(bool)>& callback,
425 CertificateRequestResultType* result) {}
427 // Selects a SSL client certificate and returns it to the |delegate|. Note:
428 // |delegate| may be called synchronously or asynchronously.
430 // TODO(davidben): Move this hook to WebContentsDelegate.
431 virtual void SelectClientCertificate(
432 WebContents* web_contents,
433 net::SSLCertRequestInfo* cert_request_info,
434 scoped_ptr<ClientCertificateDelegate> delegate);
436 // Adds a new installable certificate or private key.
437 // Typically used to install an X.509 user certificate.
438 // Note that it's up to the embedder to verify that the data is
439 // well-formed. |cert_data| will be nullptr if |cert_size| is 0.
440 virtual void AddCertificate(net::CertificateMimeType cert_type,
441 const void* cert_data,
442 size_t cert_size,
443 int render_process_id,
444 int render_frame_id) {}
446 // Returns a class to get notifications about media event. The embedder can
447 // return nullptr if they're not interested.
448 virtual MediaObserver* GetMediaObserver();
450 // Returns the platform notification service, capable of displaying Web
451 // Notifications to the user. The embedder can return a nullptr if they don't
452 // support this functionality. May be called from any thread.
453 virtual PlatformNotificationService* GetPlatformNotificationService();
455 // Returns true if the given page is allowed to open a window of the given
456 // type. If true is returned, |no_javascript_access| will indicate whether
457 // the window that is created should be scriptable/in the same process.
458 // This is called on the IO thread.
459 virtual bool CanCreateWindow(const GURL& opener_url,
460 const GURL& opener_top_level_frame_url,
461 const GURL& source_origin,
462 WindowContainerType container_type,
463 const GURL& target_url,
464 const Referrer& referrer,
465 WindowOpenDisposition disposition,
466 const blink::WebWindowFeatures& features,
467 bool user_gesture,
468 bool opener_suppressed,
469 ResourceContext* context,
470 int render_process_id,
471 int opener_render_view_id,
472 int opener_render_frame_id,
473 bool* no_javascript_access);
475 // Notifies the embedder that the ResourceDispatcherHost has been created.
476 // This is when it can optionally add a delegate.
477 virtual void ResourceDispatcherHostCreated() {}
479 // Allows the embedder to return a delegate for the SpeechRecognitionManager.
480 // The delegate will be owned by the manager. It's valid to return nullptr.
481 virtual SpeechRecognitionManagerDelegate*
482 CreateSpeechRecognitionManagerDelegate();
484 // Getters for common objects.
485 virtual net::NetLog* GetNetLog();
487 // Creates a new AccessTokenStore for gelocation.
488 virtual AccessTokenStore* CreateAccessTokenStore();
490 // Returns true if fast shutdown is possible.
491 virtual bool IsFastShutdownPossible();
493 // Called by WebContents to override the WebKit preferences that are used by
494 // the renderer. The content layer will add its own settings, and then it's up
495 // to the embedder to update it if it wants.
496 virtual void OverrideWebkitPrefs(RenderViewHost* render_view_host,
497 WebPreferences* prefs) {}
499 // Notifies that BrowserURLHandler has been created, so that the embedder can
500 // optionally add their own handlers.
501 virtual void BrowserURLHandlerCreated(BrowserURLHandler* handler) {}
503 // Clears browser cache.
504 virtual void ClearCache(RenderFrameHost* rfh) {}
506 // Clears browser cookies.
507 virtual void ClearCookies(RenderFrameHost* rfh) {}
509 // Returns the default download directory.
510 // This can be called on any thread.
511 virtual base::FilePath GetDefaultDownloadDirectory();
513 // Returns the default filename used in downloads when we have no idea what
514 // else we should do with the file.
515 virtual std::string GetDefaultDownloadName();
517 // Notification that a pepper plugin has just been spawned. This allows the
518 // embedder to add filters onto the host to implement interfaces.
519 // This is called on the IO thread.
520 virtual void DidCreatePpapiPlugin(BrowserPpapiHost* browser_host) {}
522 // Gets the host for an external out-of-process plugin.
523 virtual BrowserPpapiHost* GetExternalBrowserPpapiHost(
524 int plugin_child_id);
526 // Returns true if the socket operation specified by |params| is allowed from
527 // the given |browser_context| and |url|. If |params| is nullptr, this method
528 // checks the basic "socket" permission, which is for those operations that
529 // don't require a specific socket permission rule.
530 // |private_api| indicates whether this permission check is for the private
531 // Pepper socket API or the public one.
532 virtual bool AllowPepperSocketAPI(BrowserContext* browser_context,
533 const GURL& url,
534 bool private_api,
535 const SocketPermissionRequest* params);
537 // Returns an implementation of a file selecition policy. Can return nullptr.
538 virtual ui::SelectFilePolicy* CreateSelectFilePolicy(
539 WebContents* web_contents);
541 // Returns additional allowed scheme set which can access files in
542 // FileSystem API.
543 virtual void GetAdditionalAllowedSchemesForFileSystem(
544 std::vector<std::string>* additional_schemes) {}
546 // Returns auto mount handlers for URL requests for FileSystem APIs.
547 virtual void GetURLRequestAutoMountHandlers(
548 std::vector<storage::URLRequestAutoMountHandler>* handlers) {}
550 // Returns additional file system backends for FileSystem API.
551 // |browser_context| is needed in the additional FileSystemBackends.
552 // It has mount points to create objects returned by additional
553 // FileSystemBackends, and SpecialStoragePolicy for permission granting.
554 virtual void GetAdditionalFileSystemBackends(
555 BrowserContext* browser_context,
556 const base::FilePath& storage_partition_path,
557 ScopedVector<storage::FileSystemBackend>* additional_backends) {}
559 // Allows an embedder to return its own LocationProvider implementation.
560 // Return nullptr to use the default one for the platform to be created.
561 // FYI: Used by an external project; please don't remove.
562 // Contact Viatcheslav Ostapenko at sl.ostapenko@samsung.com for more
563 // information.
564 virtual LocationProvider* OverrideSystemLocationProvider();
566 // Creates a new DevToolsManagerDelegate. The caller owns the returned value.
567 // It's valid to return nullptr.
568 virtual DevToolsManagerDelegate* GetDevToolsManagerDelegate();
570 // Creates a new TracingDelegate. The caller owns the returned value.
571 // It's valid to return nullptr.
572 virtual TracingDelegate* GetTracingDelegate();
574 // Returns true if NPAPI plugins are enabled.
575 virtual bool IsNPAPIEnabled();
577 // Returns true if plugin referred to by the url can use
578 // pp::FileIO::RequestOSFileHandle.
579 virtual bool IsPluginAllowedToCallRequestOSFileHandle(
580 BrowserContext* browser_context,
581 const GURL& url);
583 // Returns true if dev channel APIs are available for plugins.
584 virtual bool IsPluginAllowedToUseDevChannelAPIs(
585 BrowserContext* browser_context,
586 const GURL& url);
588 // Allows to register browser Mojo services exposed through the
589 // RenderProcessHost.
590 virtual void RegisterRenderProcessMojoServices(ServiceRegistry* registry) {}
592 // Allows to register browser Mojo services exposed through the
593 // FrameMojoShell.
594 virtual void RegisterFrameMojoShellServices(
595 ServiceRegistry* registry,
596 RenderFrameHost* render_frame_host) {}
598 using StaticMojoApplicationMap =
599 std::map<GURL, base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>>;
601 // Registers Mojo applications to be loaded in the browser process by the
602 // browser's global Mojo shell.
603 virtual void RegisterInProcessMojoApplications(
604 StaticMojoApplicationMap* apps) {}
606 // Registers Mojo applications to be loaded out of the browser process (in
607 // a utility process) without the sandbox. By default, the utility process
608 // thats runs Mojo applications are sandboxed.
610 // WARNING: This path is NOT recommended! If a Mojo application needs a
611 // service that is only available out of the sandbox, it could ask the browser
612 // process to provide it (e.g. through OverrideFrameMojoShellServices()). Only
613 // use this method when that approach does not work.
614 virtual void RegisterUnsandboxedOutOfProcessMojoApplications(
615 std::vector<GURL>* urls) {}
617 // Registers additional navigator.connect service factories available in a
618 // particular NavigatorConnectContext.
619 virtual void GetAdditionalNavigatorConnectServices(
620 const scoped_refptr<NavigatorConnectContext>& context) {}
622 // Allows to override the visibility state of a RenderFrameHost.
623 // |visibility_state| should not be null. It will only be set if needed.
624 virtual void OverridePageVisibilityState(
625 RenderFrameHost* render_frame_host,
626 blink::WebPageVisibilityState* visibility_state) {}
628 // Allows an embedder to provide its own PresentationServiceDelegate
629 // implementation. Returns nullptr if unavailable.
630 virtual PresentationServiceDelegate* GetPresentationServiceDelegate(
631 WebContents* web_contents);
633 // Allows programmatic opening of a new tab/window without going through
634 // another WebContents. For example, from a Worker. |callback| will be
635 // invoked with the appropriate WebContents* when available.
636 virtual void OpenURL(BrowserContext* browser_context,
637 const OpenURLParams& params,
638 const base::Callback<void(WebContents*)>& callback);
640 // Allows the embedder to record |metric| for a specific |url|.
641 virtual void RecordURLMetric(const std::string& metric, const GURL& url) {}
643 // Populates |mappings| with all files that need to be mapped before launching
644 // a child process.
645 #if defined(OS_ANDROID)
646 virtual void GetAdditionalMappedFilesForChildProcess(
647 const base::CommandLine& command_line,
648 int child_process_id,
649 content::FileDescriptorInfo* mappings,
650 std::map<int, base::MemoryMappedFile::Region>* regions) {}
651 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
652 virtual void GetAdditionalMappedFilesForChildProcess(
653 const base::CommandLine& command_line,
654 int child_process_id,
655 content::FileDescriptorInfo* mappings) {}
656 #endif // defined(OS_ANDROID)
658 #if defined(OS_WIN)
659 // Returns the name of the dll that contains cursors and other resources.
660 virtual const wchar_t* GetResourceDllName();
662 // This is called on the PROCESS_LAUNCHER thread before the renderer process
663 // is launched. It gives the embedder a chance to add loosen the sandbox
664 // policy.
665 virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy,
666 bool* success) {}
668 // Returns the AppContainer SID for the specified sandboxed process type, or
669 // empty string if this sandboxed process type does not support living inside
670 // an AppContainer.
671 virtual base::string16 GetAppContainerSidForSandboxType(
672 int sandbox_type) const;
673 #endif
675 #if defined(VIDEO_HOLE)
676 // Allows an embedder to provide its own ExternalVideoSurfaceContainer
677 // implementation. Return nullptr to disable external surface video.
678 virtual ExternalVideoSurfaceContainer*
679 OverrideCreateExternalVideoSurfaceContainer(WebContents* web_contents);
680 #endif
683 } // namespace content
685 #endif // CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_