Home | History | Annotate | Download | only in browser
      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.
      4 
      5 #ifndef CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_
      6 #define CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_
      7 
      8 #include <map>
      9 #include <string>
     10 #include <utility>
     11 #include <vector>
     12 
     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/socket_permission_request.h"
     21 #include "content/public/common/window_container_type.h"
     22 #include "net/base/mime_util.h"
     23 #include "net/cookies/canonical_cookie.h"
     24 #include "net/url_request/url_request_interceptor.h"
     25 #include "net/url_request/url_request_job_factory.h"
     26 #include "third_party/WebKit/public/web/WebNotificationPresenter.h"
     27 #include "ui/base/window_open_disposition.h"
     28 #include "webkit/browser/fileapi/file_system_context.h"
     29 #include "webkit/common/resource_type.h"
     30 
     31 #if defined(OS_POSIX) && !defined(OS_MACOSX)
     32 #include "base/posix/global_descriptors.h"
     33 #endif
     34 
     35 #if defined(OS_POSIX)
     36 #include "content/public/browser/file_descriptor_info.h"
     37 #endif
     38 
     39 class GURL;
     40 struct WebPreferences;
     41 
     42 namespace base {
     43 class CommandLine;
     44 class DictionaryValue;
     45 class FilePath;
     46 }
     47 
     48 namespace blink {
     49 struct WebWindowFeatures;
     50 }
     51 
     52 namespace gfx {
     53 class ImageSkia;
     54 }
     55 
     56 namespace net {
     57 class CookieOptions;
     58 class CookieStore;
     59 class HttpNetworkSession;
     60 class NetLog;
     61 class SSLCertRequestInfo;
     62 class SSLInfo;
     63 class URLRequest;
     64 class URLRequestContext;
     65 class URLRequestContextGetter;
     66 class X509Certificate;
     67 }
     68 
     69 namespace sandbox {
     70 class TargetPolicy;
     71 }
     72 
     73 namespace ui {
     74 class SelectFilePolicy;
     75 }
     76 
     77 namespace fileapi {
     78 class ExternalMountPoints;
     79 class FileSystemBackend;
     80 }
     81 
     82 namespace content {
     83 
     84 class AccessTokenStore;
     85 class BrowserChildProcessHost;
     86 class BrowserContext;
     87 class BrowserMainParts;
     88 class BrowserPluginGuestDelegate;
     89 class BrowserPpapiHost;
     90 class BrowserURLHandler;
     91 class DesktopNotificationDelegate;
     92 class DevToolsManagerDelegate;
     93 class ExternalVideoSurfaceContainer;
     94 class LocationProvider;
     95 class MediaObserver;
     96 class QuotaPermissionContext;
     97 class RenderFrameHost;
     98 class RenderProcessHost;
     99 class RenderViewHost;
    100 class ResourceContext;
    101 class SiteInstance;
    102 class SpeechRecognitionManagerDelegate;
    103 class VibrationProvider;
    104 class WebContents;
    105 class WebContentsViewDelegate;
    106 struct MainFunctionParams;
    107 struct Referrer;
    108 struct ShowDesktopNotificationHostMsgParams;
    109 
    110 // A mapping from the scheme name to the protocol handler that services its
    111 // content.
    112 typedef std::map<
    113   std::string, linked_ptr<net::URLRequestJobFactory::ProtocolHandler> >
    114     ProtocolHandlerMap;
    115 
    116 // A scoped vector of protocol interceptors.
    117 typedef ScopedVector<net::URLRequestInterceptor>
    118     URLRequestInterceptorScopedVector;
    119 
    120 // Embedder API (or SPI) for participating in browser logic, to be implemented
    121 // by the client of the content browser. See ChromeContentBrowserClient for the
    122 // principal implementation. The methods are assumed to be called on the UI
    123 // thread unless otherwise specified. Use this "escape hatch" sparingly, to
    124 // avoid the embedder interface ballooning and becoming very specific to Chrome.
    125 // (Often, the call out to the client can happen in a different part of the code
    126 // that either already has a hook out to the embedder, or calls out to one of
    127 // the observer interfaces.)
    128 class CONTENT_EXPORT ContentBrowserClient {
    129  public:
    130   virtual ~ContentBrowserClient() {}
    131 
    132   // Allows the embedder to set any number of custom BrowserMainParts
    133   // implementations for the browser startup code. See comments in
    134   // browser_main_parts.h.
    135   virtual BrowserMainParts* CreateBrowserMainParts(
    136       const MainFunctionParams& parameters);
    137 
    138   // If content creates the WebContentsView implementation, it will ask the
    139   // embedder to return an (optional) delegate to customize it. The view will
    140   // own the delegate.
    141   virtual WebContentsViewDelegate* GetWebContentsViewDelegate(
    142       WebContents* web_contents);
    143 
    144   // Notifies that a guest WebContents has been created. A guest WebContents
    145   // represents a renderer that's hosted within a BrowserPlugin. Creation can
    146   // occur an arbitrary length of time before attachment. If the new guest has
    147   // an |opener_web_contents|, then it's a new window created by that opener.
    148   // If the guest was created via navigation, then |extra_params| will be
    149   // non-NULL. |extra_params| are parameters passed to the BrowserPlugin object
    150   // element by the content embedder. These parameters may include the API to
    151   // enable for the given guest. |guest_delegate| is a return parameter of
    152   // the delegate in the content embedder that will service the guest in the
    153   // content layer. The content layer takes ownership of the |guest_delegate|.
    154   virtual void GuestWebContentsCreated(
    155       int guest_instance_id,
    156       SiteInstance* guest_site_instance,
    157       WebContents* guest_web_contents,
    158       WebContents* opener_web_contents,
    159       BrowserPluginGuestDelegate** guest_delegate,
    160       scoped_ptr<base::DictionaryValue> extra_params) {}
    161 
    162   // Notifies that a render process will be created. This is called before
    163   // the content layer adds its own BrowserMessageFilters, so that the
    164   // embedder's IPC filters have priority.
    165   virtual void RenderProcessWillLaunch(RenderProcessHost* host) {}
    166 
    167   // Notifies that a BrowserChildProcessHost has been created.
    168   virtual void BrowserChildProcessHostCreated(BrowserChildProcessHost* host) {}
    169 
    170   // Get the effective URL for the given actual URL, to allow an embedder to
    171   // group different url schemes in the same SiteInstance.
    172   virtual GURL GetEffectiveURL(BrowserContext* browser_context,
    173                                const GURL& url);
    174 
    175   // Returns whether all instances of the specified effective URL should be
    176   // rendered by the same process, rather than using process-per-site-instance.
    177   virtual bool ShouldUseProcessPerSite(BrowserContext* browser_context,
    178                                        const GURL& effective_url);
    179 
    180   // Returns a list additional WebUI schemes, if any.  These additional schemes
    181   // act as aliases to the chrome: scheme.  The additional schemes may or may
    182   // not serve specific WebUI pages depending on the particular URLDataSource
    183   // and its override of URLDataSource::ShouldServiceRequest. For all schemes
    184   // returned here, view-source is allowed.
    185   virtual void GetAdditionalWebUISchemes(
    186       std::vector<std::string>* additional_schemes) {}
    187 
    188   // Returns a list of webUI hosts to ignore the storage partition check in
    189   // URLRequestChromeJob::CheckStoragePartitionMatches.
    190   virtual void GetAdditionalWebUIHostsToIgnoreParititionCheck(
    191       std::vector<std::string>* hosts) {}
    192 
    193   // Creates the main net::URLRequestContextGetter. Should only be called once
    194   // per ContentBrowserClient object.
    195   // TODO(ajwong): Remove once http://crbug.com/159193 is resolved.
    196   virtual net::URLRequestContextGetter* CreateRequestContext(
    197       BrowserContext* browser_context,
    198       ProtocolHandlerMap* protocol_handlers,
    199       URLRequestInterceptorScopedVector request_interceptors);
    200 
    201   // Creates the net::URLRequestContextGetter for a StoragePartition. Should
    202   // only be called once per partition_path per ContentBrowserClient object.
    203   // TODO(ajwong): Remove once http://crbug.com/159193 is resolved.
    204   virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
    205       BrowserContext* browser_context,
    206       const base::FilePath& partition_path,
    207       bool in_memory,
    208       ProtocolHandlerMap* protocol_handlers,
    209       URLRequestInterceptorScopedVector request_interceptors);
    210 
    211   // Returns whether a specified URL is handled by the embedder's internal
    212   // protocol handlers.
    213   virtual bool IsHandledURL(const GURL& url);
    214 
    215   // Returns whether the given process is allowed to commit |url|.  This is a
    216   // more conservative check than IsSuitableHost, since it is used after a
    217   // navigation has committed to ensure that the process did not exceed its
    218   // authority.
    219   virtual bool CanCommitURL(RenderProcessHost* process_host, const GURL& url);
    220 
    221   // Returns whether a URL should be allowed to open from a specific context.
    222   // This also applies in cases where the new URL will open in another process.
    223   virtual bool ShouldAllowOpenURL(SiteInstance* site_instance, const GURL& url);
    224 
    225   // Returns whether a new view for a given |site_url| can be launched in a
    226   // given |process_host|.
    227   virtual bool IsSuitableHost(RenderProcessHost* process_host,
    228                               const GURL& site_url);
    229 
    230   // Returns whether a new view for a new site instance can be added to a
    231   // given |process_host|.
    232   virtual bool MayReuseHost(RenderProcessHost* process_host);
    233 
    234   // Returns whether a new process should be created or an existing one should
    235   // be reused based on the URL we want to load. This should return false,
    236   // unless there is a good reason otherwise.
    237   virtual bool ShouldTryToUseExistingProcessHost(
    238       BrowserContext* browser_context, const GURL& url);
    239 
    240   // Called when a site instance is first associated with a process.
    241   virtual void SiteInstanceGotProcess(SiteInstance* site_instance) {}
    242 
    243   // Called from a site instance's destructor.
    244   virtual void SiteInstanceDeleting(SiteInstance* site_instance) {}
    245 
    246   // Called when a worker process is created.
    247   virtual void WorkerProcessCreated(SiteInstance* site_instance,
    248                                     int worker_process_id) {}
    249 
    250   // Called when a worker process is terminated.
    251   virtual void WorkerProcessTerminated(SiteInstance* site_instance,
    252                                        int worker_process_id) {}
    253 
    254   // Returns true if for the navigation from |current_url| to |new_url|
    255   // in |site_instance|, a new SiteInstance and BrowsingInstance should be
    256   // created (even if we are in a process model that doesn't usually swap.)
    257   // This forces a process swap and severs script connections with existing
    258   // tabs.
    259   virtual bool ShouldSwapBrowsingInstancesForNavigation(
    260       SiteInstance* site_instance,
    261       const GURL& current_url,
    262       const GURL& new_url);
    263 
    264   // Returns true if the given navigation redirect should cause a renderer
    265   // process swap.
    266   // This is called on the IO thread.
    267   virtual bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context,
    268                                               const GURL& current_url,
    269                                               const GURL& new_url);
    270 
    271   // Returns true if the passed in URL should be assigned as the site of the
    272   // current SiteInstance, if it does not yet have a site.
    273   virtual bool ShouldAssignSiteForURL(const GURL& url);
    274 
    275   // See CharacterEncoding's comment.
    276   virtual std::string GetCanonicalEncodingNameByAliasName(
    277       const std::string& alias_name);
    278 
    279   // Allows the embedder to pass extra command line flags.
    280   // switches::kProcessType will already be set at this point.
    281   virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
    282                                               int child_process_id) {}
    283 
    284   // Returns the locale used by the application.
    285   // This is called on the UI and IO threads.
    286   virtual std::string GetApplicationLocale();
    287 
    288   // Returns the languages used in the Accept-Languages HTTP header.
    289   // (Not called GetAcceptLanguages so it doesn't clash with win32).
    290   virtual std::string GetAcceptLangs(BrowserContext* context);
    291 
    292   // Returns the default favicon.  The callee doesn't own the given bitmap.
    293   virtual const gfx::ImageSkia* GetDefaultFavicon();
    294 
    295   // Allow the embedder to control if an AppCache can be used for the given url.
    296   // This is called on the IO thread.
    297   virtual bool AllowAppCache(const GURL& manifest_url,
    298                              const GURL& first_party,
    299                              ResourceContext* context);
    300 
    301   // Allow the embedder to control if the given cookie can be read.
    302   // This is called on the IO thread.
    303   virtual bool AllowGetCookie(const GURL& url,
    304                               const GURL& first_party,
    305                               const net::CookieList& cookie_list,
    306                               ResourceContext* context,
    307                               int render_process_id,
    308                               int render_frame_id);
    309 
    310   // Allow the embedder to control if the given cookie can be set.
    311   // This is called on the IO thread.
    312   virtual bool AllowSetCookie(const GURL& url,
    313                               const GURL& first_party,
    314                               const std::string& cookie_line,
    315                               ResourceContext* context,
    316                               int render_process_id,
    317                               int render_frame_id,
    318                               net::CookieOptions* options);
    319 
    320   // This is called on the IO thread.
    321   virtual bool AllowSaveLocalState(ResourceContext* context);
    322 
    323   // Allow the embedder to control if access to web database by a shared worker
    324   // is allowed. |render_frame| is a vector of pairs of
    325   // RenderProcessID/RenderFrameID of RenderFrame that are using this worker.
    326   // This is called on the IO thread.
    327   virtual bool AllowWorkerDatabase(
    328       const GURL& url,
    329       const base::string16& name,
    330       const base::string16& display_name,
    331       unsigned long estimated_size,
    332       ResourceContext* context,
    333       const std::vector<std::pair<int, int> >& render_frames);
    334 
    335   // Allow the embedder to control if access to file system by a shared worker
    336   // is allowed.
    337   // This is called on the IO thread.
    338   virtual bool AllowWorkerFileSystem(
    339       const GURL& url,
    340       ResourceContext* context,
    341       const std::vector<std::pair<int, int> >& render_frames);
    342 
    343   // Allow the embedder to control if access to IndexedDB by a shared worker
    344   // is allowed.
    345   // This is called on the IO thread.
    346   virtual bool AllowWorkerIndexedDB(
    347       const GURL& url,
    348       const base::string16& name,
    349       ResourceContext* context,
    350       const std::vector<std::pair<int, int> >& render_frames);
    351 
    352   // Allow the embedder to override the request context based on the URL for
    353   // certain operations, like cookie access. Returns NULL to indicate the
    354   // regular request context should be used.
    355   // This is called on the IO thread.
    356   virtual net::URLRequestContext* OverrideRequestContextForURL(
    357       const GURL& url, ResourceContext* context);
    358 
    359   // Allow the embedder to specify a string version of the storage partition
    360   // config with a site.
    361   virtual std::string GetStoragePartitionIdForSite(
    362       BrowserContext* browser_context,
    363       const GURL& site);
    364 
    365   // Allows the embedder to provide a validation check for |partition_id|s.
    366   // This domain of valid entries should match the range of outputs for
    367   // GetStoragePartitionIdForChildProcess().
    368   virtual bool IsValidStoragePartitionId(BrowserContext* browser_context,
    369                                          const std::string& partition_id);
    370 
    371   // Allows the embedder to provide a storage parititon configuration for a
    372   // site. A storage partition configuration includes a domain of the embedder's
    373   // choice, an optional name within that domain, and whether the partition is
    374   // in-memory only.
    375   //
    376   // If |can_be_default| is false, the caller is telling the embedder that the
    377   // |site| is known to not be in the default partition. This is useful in
    378   // some shutdown situations where the bookkeeping logic that maps sites to
    379   // their partition configuration are no longer valid.
    380   //
    381   // The |partition_domain| is [a-z]* UTF-8 string, specifying the domain in
    382   // which partitions live (similar to namespace). Within a domain, partitions
    383   // can be uniquely identified by the combination of |partition_name| and
    384   // |in_memory| values. When a partition is not to be persisted, the
    385   // |in_memory| value must be set to true.
    386   virtual void GetStoragePartitionConfigForSite(
    387       BrowserContext* browser_context,
    388       const GURL& site,
    389       bool can_be_default,
    390       std::string* partition_domain,
    391       std::string* partition_name,
    392       bool* in_memory);
    393 
    394   // Create and return a new quota permission context.
    395   virtual QuotaPermissionContext* CreateQuotaPermissionContext();
    396 
    397   // Informs the embedder that a certificate error has occured.  If
    398   // |overridable| is true and if |strict_enforcement| is false, the user
    399   // can ignore the error and continue. The embedder can call the callback
    400   // asynchronously. If |result| is not set to
    401   // CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE, the request will be cancelled
    402   // or denied immediately, and the callback won't be run.
    403   virtual void AllowCertificateError(
    404       int render_process_id,
    405       int render_frame_id,
    406       int cert_error,
    407       const net::SSLInfo& ssl_info,
    408       const GURL& request_url,
    409       ResourceType::Type resource_type,
    410       bool overridable,
    411       bool strict_enforcement,
    412       const base::Callback<void(bool)>& callback,
    413       CertificateRequestResultType* result) {}
    414 
    415   // Selects a SSL client certificate and returns it to the |callback|. If no
    416   // certificate was selected NULL is returned to the |callback|.
    417   virtual void SelectClientCertificate(
    418       int render_process_id,
    419       int render_frame_id,
    420       const net::HttpNetworkSession* network_session,
    421       net::SSLCertRequestInfo* cert_request_info,
    422       const base::Callback<void(net::X509Certificate*)>& callback) {}
    423 
    424   // Adds a new installable certificate or private key.
    425   // Typically used to install an X.509 user certificate.
    426   // Note that it's up to the embedder to verify that the data is
    427   // well-formed. |cert_data| will be NULL if |cert_size| is 0.
    428   virtual void AddCertificate(net::CertificateMimeType cert_type,
    429                               const void* cert_data,
    430                               size_t cert_size,
    431                               int render_process_id,
    432                               int render_frame_id) {}
    433 
    434   // Returns a class to get notifications about media event. The embedder can
    435   // return NULL if they're not interested.
    436   virtual MediaObserver* GetMediaObserver();
    437 
    438   // Asks permission to show desktop notifications. |callback| needs to be run
    439   // when the user approves the request.
    440   virtual void RequestDesktopNotificationPermission(
    441       const GURL& source_origin,
    442       RenderFrameHost* render_frame_host,
    443       const base::Closure& callback) {}
    444 
    445   // Checks if the given page has permission to show desktop notifications.
    446   // This is called on the IO thread.
    447   virtual blink::WebNotificationPresenter::Permission
    448       CheckDesktopNotificationPermission(
    449           const GURL& source_url,
    450           ResourceContext* context,
    451           int render_process_id);
    452 
    453   // Show a desktop notification. If |cancel_callback| is non-null, it's set to
    454   // a callback which can be used to cancel the notification.
    455   virtual void ShowDesktopNotification(
    456       const ShowDesktopNotificationHostMsgParams& params,
    457       RenderFrameHost* render_frame_host,
    458       DesktopNotificationDelegate* delegate,
    459       base::Closure* cancel_callback) {}
    460 
    461   // The renderer is requesting permission to use Geolocation. When the answer
    462   // to a permission request has been determined, |result_callback| should be
    463   // called with the result. If |cancel_callback| is non-null, it's set to a
    464   // callback which can be used to cancel the permission request.
    465   virtual void RequestGeolocationPermission(
    466       WebContents* web_contents,
    467       int bridge_id,
    468       const GURL& requesting_frame,
    469       bool user_gesture,
    470       base::Callback<void(bool)> result_callback,
    471       base::Closure* cancel_callback);
    472 
    473   // Requests a permission to use system exclusive messages in MIDI events.
    474   // |result_callback| will be invoked when the request is resolved. If
    475   // |cancel_callback| is non-null, it's set to a callback which can be used to
    476   // cancel the permission request.
    477   virtual void RequestMidiSysExPermission(
    478       WebContents* web_contents,
    479       int bridge_id,
    480       const GURL& requesting_frame,
    481       bool user_gesture,
    482       base::Callback<void(bool)> result_callback,
    483       base::Closure* cancel_callback);
    484 
    485   // Request permission to access protected media identifier. |result_callback
    486   // will tell whether it's permitted. If |cancel_callback| is non-null, it's
    487   // set to a callback which can be used to cancel the permission request.
    488   virtual void RequestProtectedMediaIdentifierPermission(
    489       WebContents* web_contents,
    490       const GURL& origin,
    491       base::Callback<void(bool)> result_callback,
    492       base::Closure* cancel_callback);
    493 
    494   // Returns true if the given page is allowed to open a window of the given
    495   // type. If true is returned, |no_javascript_access| will indicate whether
    496   // the window that is created should be scriptable/in the same process.
    497   // This is called on the IO thread.
    498   virtual bool CanCreateWindow(const GURL& opener_url,
    499                                const GURL& opener_top_level_frame_url,
    500                                const GURL& source_origin,
    501                                WindowContainerType container_type,
    502                                const GURL& target_url,
    503                                const Referrer& referrer,
    504                                WindowOpenDisposition disposition,
    505                                const blink::WebWindowFeatures& features,
    506                                bool user_gesture,
    507                                bool opener_suppressed,
    508                                ResourceContext* context,
    509                                int render_process_id,
    510                                int opener_id,
    511                                bool* no_javascript_access);
    512 
    513   // Returns a title string to use in the task manager for a process host with
    514   // the given URL, or the empty string to fall back to the default logic.
    515   // This is called on the IO thread.
    516   virtual std::string GetWorkerProcessTitle(const GURL& url,
    517                                             ResourceContext* context);
    518 
    519   // Notifies the embedder that the ResourceDispatcherHost has been created.
    520   // This is when it can optionally add a delegate.
    521   virtual void ResourceDispatcherHostCreated() {}
    522 
    523   // Allows the embedder to return a delegate for the SpeechRecognitionManager.
    524   // The delegate will be owned by the manager. It's valid to return NULL.
    525   virtual SpeechRecognitionManagerDelegate*
    526       GetSpeechRecognitionManagerDelegate();
    527 
    528   // Getters for common objects.
    529   virtual net::NetLog* GetNetLog();
    530 
    531   // Creates a new AccessTokenStore for gelocation.
    532   virtual AccessTokenStore* CreateAccessTokenStore();
    533 
    534   // Returns true if fast shutdown is possible.
    535   virtual bool IsFastShutdownPossible();
    536 
    537   // Called by WebContents to override the WebKit preferences that are used by
    538   // the renderer. The content layer will add its own settings, and then it's up
    539   // to the embedder to update it if it wants.
    540   virtual void OverrideWebkitPrefs(RenderViewHost* render_view_host,
    541                                    const GURL& url,
    542                                    WebPreferences* prefs) {}
    543 
    544   // Inspector setting was changed and should be persisted.
    545   virtual void UpdateInspectorSetting(RenderViewHost* rvh,
    546                                       const std::string& key,
    547                                       const std::string& value) {}
    548 
    549   // Notifies that BrowserURLHandler has been created, so that the embedder can
    550   // optionally add their own handlers.
    551   virtual void BrowserURLHandlerCreated(BrowserURLHandler* handler) {}
    552 
    553   // Clears browser cache.
    554   virtual void ClearCache(RenderViewHost* rvh) {}
    555 
    556   // Clears browser cookies.
    557   virtual void ClearCookies(RenderViewHost* rvh) {}
    558 
    559   // Returns the default download directory.
    560   // This can be called on any thread.
    561   virtual base::FilePath GetDefaultDownloadDirectory();
    562 
    563   // Returns the default filename used in downloads when we have no idea what
    564   // else we should do with the file.
    565   virtual std::string GetDefaultDownloadName();
    566 
    567   // Notification that a pepper plugin has just been spawned. This allows the
    568   // embedder to add filters onto the host to implement interfaces.
    569   // This is called on the IO thread.
    570   virtual void DidCreatePpapiPlugin(BrowserPpapiHost* browser_host) {}
    571 
    572   // Gets the host for an external out-of-process plugin.
    573   virtual BrowserPpapiHost* GetExternalBrowserPpapiHost(
    574       int plugin_child_id);
    575 
    576   // Returns true if the socket operation specified by |params| is allowed from
    577   // the given |browser_context| and |url|. If |params| is NULL, this method
    578   // checks the basic "socket" permission, which is for those operations that
    579   // don't require a specific socket permission rule.
    580   // |private_api| indicates whether this permission check is for the private
    581   // Pepper socket API or the public one.
    582   virtual bool AllowPepperSocketAPI(BrowserContext* browser_context,
    583                                     const GURL& url,
    584                                     bool private_api,
    585                                     const SocketPermissionRequest* params);
    586 
    587   // Returns an implementation of a file selecition policy. Can return NULL.
    588   virtual ui::SelectFilePolicy* CreateSelectFilePolicy(
    589       WebContents* web_contents);
    590 
    591   // Returns additional allowed scheme set which can access files in
    592   // FileSystem API.
    593   virtual void GetAdditionalAllowedSchemesForFileSystem(
    594       std::vector<std::string>* additional_schemes) {}
    595 
    596   // Returns auto mount handlers for URL requests for FileSystem APIs.
    597   virtual void GetURLRequestAutoMountHandlers(
    598       std::vector<fileapi::URLRequestAutoMountHandler>* handlers) {}
    599 
    600   // Returns additional file system backends for FileSystem API.
    601   // |browser_context| is needed in the additional FileSystemBackends.
    602   // It has mount points to create objects returned by additional
    603   // FileSystemBackends, and SpecialStoragePolicy for permission granting.
    604   virtual void GetAdditionalFileSystemBackends(
    605       BrowserContext* browser_context,
    606       const base::FilePath& storage_partition_path,
    607       ScopedVector<fileapi::FileSystemBackend>* additional_backends) {}
    608 
    609   // Allows an embedder to return its own LocationProvider implementation.
    610   // Return NULL to use the default one for the platform to be created.
    611   // FYI: Used by an external project; please don't remove.
    612   // Contact Viatcheslav Ostapenko at sl.ostapenko (at) samsung.com for more
    613   // information.
    614   virtual LocationProvider* OverrideSystemLocationProvider();
    615 
    616   // Allows an embedder to return its own VibrationProvider implementation.
    617   // Return NULL to use the default one for the platform to be created.
    618   // FYI: Used by an external project; please don't remove.
    619   // Contact Viatcheslav Ostapenko at sl.ostapenko (at) samsung.com for more
    620   // information.
    621   virtual VibrationProvider* OverrideVibrationProvider();
    622 
    623   // Creates a new DevToolsManagerDelegate. The caller owns the returned value.
    624   // It's valid to return NULL.
    625   virtual DevToolsManagerDelegate* GetDevToolsManagerDelegate();
    626 
    627   // Returns true if plugin referred to by the url can use
    628   // pp::FileIO::RequestOSFileHandle.
    629   virtual bool IsPluginAllowedToCallRequestOSFileHandle(
    630       BrowserContext* browser_context,
    631       const GURL& url);
    632 
    633   // Returns true if dev channel APIs are available for plugins.
    634   virtual bool IsPluginAllowedToUseDevChannelAPIs(
    635       BrowserContext* browser_context,
    636       const GURL& url);
    637 
    638   // Returns a special cookie store to use for a given render process, or NULL
    639   // if the default cookie store should be used
    640   // This is called on the IO thread.
    641   virtual net::CookieStore* OverrideCookieStoreForRenderProcess(
    642       int render_process_id);
    643 
    644 #if defined(OS_POSIX) && !defined(OS_MACOSX)
    645   // Populates |mappings| with all files that need to be mapped before launching
    646   // a child process.
    647   virtual void GetAdditionalMappedFilesForChildProcess(
    648       const base::CommandLine& command_line,
    649       int child_process_id,
    650       std::vector<FileDescriptorInfo>* mappings) {}
    651 #endif
    652 
    653 #if defined(OS_WIN)
    654   // Returns the name of the dll that contains cursors and other resources.
    655   virtual const wchar_t* GetResourceDllName();
    656 
    657   // This is called on the PROCESS_LAUNCHER thread before the renderer process
    658   // is launched. It gives the embedder a chance to add loosen the sandbox
    659   // policy.
    660   virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy,
    661                                 bool* success) {}
    662 #endif
    663 
    664 #if defined(VIDEO_HOLE)
    665   // Allows an embedder to provide its own ExternalVideoSurfaceContainer
    666   // implementation.  Return NULL to disable external surface video.
    667   virtual ExternalVideoSurfaceContainer*
    668   OverrideCreateExternalVideoSurfaceContainer(WebContents* web_contents);
    669 #endif
    670 };
    671 
    672 }  // namespace content
    673 
    674 #endif  // CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_
    675