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