OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_ |
6 #define CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_ | 6 #define CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "content/public/browser/certificate_request_result_type.h" | 18 #include "content/public/browser/certificate_request_result_type.h" |
19 #include "content/public/common/content_client.h" | 19 #include "content/public/common/content_client.h" |
20 #include "content/public/common/socket_permission_request.h" | 20 #include "content/public/common/socket_permission_request.h" |
21 #include "content/public/common/window_container_type.h" | 21 #include "content/public/common/window_container_type.h" |
22 #include "net/base/mime_util.h" | 22 #include "net/base/mime_util.h" |
23 #include "net/cookies/canonical_cookie.h" | 23 #include "net/cookies/canonical_cookie.h" |
| 24 #include "net/url_request/url_request_interceptor.h" |
24 #include "net/url_request/url_request_job_factory.h" | 25 #include "net/url_request/url_request_job_factory.h" |
25 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" | 26 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" |
26 #include "ui/base/window_open_disposition.h" | 27 #include "ui/base/window_open_disposition.h" |
27 #include "webkit/browser/fileapi/file_system_context.h" | 28 #include "webkit/browser/fileapi/file_system_context.h" |
28 #include "webkit/common/resource_type.h" | 29 #include "webkit/common/resource_type.h" |
29 | 30 |
30 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 31 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
31 #include "base/posix/global_descriptors.h" | 32 #include "base/posix/global_descriptors.h" |
32 #endif | 33 #endif |
33 | 34 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 struct MainFunctionParams; | 106 struct MainFunctionParams; |
106 struct Referrer; | 107 struct Referrer; |
107 struct ShowDesktopNotificationHostMsgParams; | 108 struct ShowDesktopNotificationHostMsgParams; |
108 | 109 |
109 // A mapping from the scheme name to the protocol handler that services its | 110 // A mapping from the scheme name to the protocol handler that services its |
110 // content. | 111 // content. |
111 typedef std::map< | 112 typedef std::map< |
112 std::string, linked_ptr<net::URLRequestJobFactory::ProtocolHandler> > | 113 std::string, linked_ptr<net::URLRequestJobFactory::ProtocolHandler> > |
113 ProtocolHandlerMap; | 114 ProtocolHandlerMap; |
114 | 115 |
115 // A scoped vector of protocol handlers. | 116 // A scoped vector of protocol interceptors. |
116 typedef ScopedVector<net::URLRequestJobFactory::ProtocolHandler> | 117 typedef ScopedVector<net::URLRequestInterceptor> |
117 ProtocolHandlerScopedVector; | 118 URLRequestInterceptorScopedVector; |
118 | 119 |
119 // Embedder API (or SPI) for participating in browser logic, to be implemented | 120 // Embedder API (or SPI) for participating in browser logic, to be implemented |
120 // by the client of the content browser. See ChromeContentBrowserClient for the | 121 // by the client of the content browser. See ChromeContentBrowserClient for the |
121 // principal implementation. The methods are assumed to be called on the UI | 122 // principal implementation. The methods are assumed to be called on the UI |
122 // thread unless otherwise specified. Use this "escape hatch" sparingly, to | 123 // thread unless otherwise specified. Use this "escape hatch" sparingly, to |
123 // avoid the embedder interface ballooning and becoming very specific to Chrome. | 124 // avoid the embedder interface ballooning and becoming very specific to Chrome. |
124 // (Often, the call out to the client can happen in a different part of the code | 125 // (Often, the call out to the client can happen in a different part of the code |
125 // that either already has a hook out to the embedder, or calls out to one of | 126 // that either already has a hook out to the embedder, or calls out to one of |
126 // the observer interfaces.) | 127 // the observer interfaces.) |
127 class CONTENT_EXPORT ContentBrowserClient { | 128 class CONTENT_EXPORT ContentBrowserClient { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // URLRequestChromeJob::CheckStoragePartitionMatches. | 199 // URLRequestChromeJob::CheckStoragePartitionMatches. |
199 virtual void GetAdditionalWebUIHostsToIgnoreParititionCheck( | 200 virtual void GetAdditionalWebUIHostsToIgnoreParititionCheck( |
200 std::vector<std::string>* hosts) {} | 201 std::vector<std::string>* hosts) {} |
201 | 202 |
202 // Creates the main net::URLRequestContextGetter. Should only be called once | 203 // Creates the main net::URLRequestContextGetter. Should only be called once |
203 // per ContentBrowserClient object. | 204 // per ContentBrowserClient object. |
204 // TODO(ajwong): Remove once http://crbug.com/159193 is resolved. | 205 // TODO(ajwong): Remove once http://crbug.com/159193 is resolved. |
205 virtual net::URLRequestContextGetter* CreateRequestContext( | 206 virtual net::URLRequestContextGetter* CreateRequestContext( |
206 BrowserContext* browser_context, | 207 BrowserContext* browser_context, |
207 ProtocolHandlerMap* protocol_handlers, | 208 ProtocolHandlerMap* protocol_handlers, |
208 ProtocolHandlerScopedVector protocol_interceptors); | 209 URLRequestInterceptorScopedVector request_interceptors); |
209 | 210 |
210 // Creates the net::URLRequestContextGetter for a StoragePartition. Should | 211 // Creates the net::URLRequestContextGetter for a StoragePartition. Should |
211 // only be called once per partition_path per ContentBrowserClient object. | 212 // only be called once per partition_path per ContentBrowserClient object. |
212 // TODO(ajwong): Remove once http://crbug.com/159193 is resolved. | 213 // TODO(ajwong): Remove once http://crbug.com/159193 is resolved. |
213 virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition( | 214 virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition( |
214 BrowserContext* browser_context, | 215 BrowserContext* browser_context, |
215 const base::FilePath& partition_path, | 216 const base::FilePath& partition_path, |
216 bool in_memory, | 217 bool in_memory, |
217 ProtocolHandlerMap* protocol_handlers, | 218 ProtocolHandlerMap* protocol_handlers, |
218 ProtocolHandlerScopedVector protocol_interceptors); | 219 URLRequestInterceptorScopedVector request_interceptors); |
219 | 220 |
220 // Returns whether a specified URL is handled by the embedder's internal | 221 // Returns whether a specified URL is handled by the embedder's internal |
221 // protocol handlers. | 222 // protocol handlers. |
222 virtual bool IsHandledURL(const GURL& url); | 223 virtual bool IsHandledURL(const GURL& url); |
223 | 224 |
224 // Returns whether the given process is allowed to commit |url|. This is a | 225 // Returns whether the given process is allowed to commit |url|. This is a |
225 // more conservative check than IsSuitableHost, since it is used after a | 226 // more conservative check than IsSuitableHost, since it is used after a |
226 // navigation has committed to ensure that the process did not exceed its | 227 // navigation has committed to ensure that the process did not exceed its |
227 // authority. | 228 // authority. |
228 virtual bool CanCommitURL(RenderProcessHost* process_host, const GURL& url); | 229 virtual bool CanCommitURL(RenderProcessHost* process_host, const GURL& url); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // Allow the embedder to override the request context based on the URL for | 362 // Allow the embedder to override the request context based on the URL for |
362 // certain operations, like cookie access. Returns NULL to indicate the | 363 // certain operations, like cookie access. Returns NULL to indicate the |
363 // regular request context should be used. | 364 // regular request context should be used. |
364 // This is called on the IO thread. | 365 // This is called on the IO thread. |
365 virtual net::URLRequestContext* OverrideRequestContextForURL( | 366 virtual net::URLRequestContext* OverrideRequestContextForURL( |
366 const GURL& url, ResourceContext* context); | 367 const GURL& url, ResourceContext* context); |
367 | 368 |
368 // Allow the embedder to specify a string version of the storage partition | 369 // Allow the embedder to specify a string version of the storage partition |
369 // config with a site. | 370 // config with a site. |
370 virtual std::string GetStoragePartitionIdForSite( | 371 virtual std::string GetStoragePartitionIdForSite( |
371 content::BrowserContext* browser_context, | 372 BrowserContext* browser_context, |
372 const GURL& site); | 373 const GURL& site); |
373 | 374 |
374 // Allows the embedder to provide a validation check for |partition_id|s. | 375 // Allows the embedder to provide a validation check for |partition_id|s. |
375 // This domain of valid entries should match the range of outputs for | 376 // This domain of valid entries should match the range of outputs for |
376 // GetStoragePartitionIdForChildProcess(). | 377 // GetStoragePartitionIdForChildProcess(). |
377 virtual bool IsValidStoragePartitionId(BrowserContext* browser_context, | 378 virtual bool IsValidStoragePartitionId(BrowserContext* browser_context, |
378 const std::string& partition_id); | 379 const std::string& partition_id); |
379 | 380 |
380 // Allows the embedder to provide a storage parititon configuration for a | 381 // Allows the embedder to provide a storage parititon configuration for a |
381 // site. A storage partition configuration includes a domain of the embedder's | 382 // site. A storage partition configuration includes a domain of the embedder's |
382 // choice, an optional name within that domain, and whether the partition is | 383 // choice, an optional name within that domain, and whether the partition is |
383 // in-memory only. | 384 // in-memory only. |
384 // | 385 // |
385 // If |can_be_default| is false, the caller is telling the embedder that the | 386 // If |can_be_default| is false, the caller is telling the embedder that the |
386 // |site| is known to not be in the default partition. This is useful in | 387 // |site| is known to not be in the default partition. This is useful in |
387 // some shutdown situations where the bookkeeping logic that maps sites to | 388 // some shutdown situations where the bookkeeping logic that maps sites to |
388 // their partition configuration are no longer valid. | 389 // their partition configuration are no longer valid. |
389 // | 390 // |
390 // The |partition_domain| is [a-z]* UTF-8 string, specifying the domain in | 391 // The |partition_domain| is [a-z]* UTF-8 string, specifying the domain in |
391 // which partitions live (similar to namespace). Within a domain, partitions | 392 // which partitions live (similar to namespace). Within a domain, partitions |
392 // can be uniquely identified by the combination of |partition_name| and | 393 // can be uniquely identified by the combination of |partition_name| and |
393 // |in_memory| values. When a partition is not to be persisted, the | 394 // |in_memory| values. When a partition is not to be persisted, the |
394 // |in_memory| value must be set to true. | 395 // |in_memory| value must be set to true. |
395 virtual void GetStoragePartitionConfigForSite( | 396 virtual void GetStoragePartitionConfigForSite( |
396 content::BrowserContext* browser_context, | 397 BrowserContext* browser_context, |
397 const GURL& site, | 398 const GURL& site, |
398 bool can_be_default, | 399 bool can_be_default, |
399 std::string* partition_domain, | 400 std::string* partition_domain, |
400 std::string* partition_name, | 401 std::string* partition_name, |
401 bool* in_memory); | 402 bool* in_memory); |
402 | 403 |
403 // Create and return a new quota permission context. | 404 // Create and return a new quota permission context. |
404 virtual QuotaPermissionContext* CreateQuotaPermissionContext(); | 405 virtual QuotaPermissionContext* CreateQuotaPermissionContext(); |
405 | 406 |
406 // Informs the embedder that a certificate error has occured. If | 407 // Informs the embedder that a certificate error has occured. If |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 | 472 |
472 // Returns true if the given page is allowed to open a window of the given | 473 // Returns true if the given page is allowed to open a window of the given |
473 // type. If true is returned, |no_javascript_access| will indicate whether | 474 // type. If true is returned, |no_javascript_access| will indicate whether |
474 // the window that is created should be scriptable/in the same process. | 475 // the window that is created should be scriptable/in the same process. |
475 // This is called on the IO thread. | 476 // This is called on the IO thread. |
476 virtual bool CanCreateWindow(const GURL& opener_url, | 477 virtual bool CanCreateWindow(const GURL& opener_url, |
477 const GURL& opener_top_level_frame_url, | 478 const GURL& opener_top_level_frame_url, |
478 const GURL& source_origin, | 479 const GURL& source_origin, |
479 WindowContainerType container_type, | 480 WindowContainerType container_type, |
480 const GURL& target_url, | 481 const GURL& target_url, |
481 const content::Referrer& referrer, | 482 const Referrer& referrer, |
482 WindowOpenDisposition disposition, | 483 WindowOpenDisposition disposition, |
483 const blink::WebWindowFeatures& features, | 484 const blink::WebWindowFeatures& features, |
484 bool user_gesture, | 485 bool user_gesture, |
485 bool opener_suppressed, | 486 bool opener_suppressed, |
486 content::ResourceContext* context, | 487 ResourceContext* context, |
487 int render_process_id, | 488 int render_process_id, |
488 int opener_id, | 489 int opener_id, |
489 bool* no_javascript_access); | 490 bool* no_javascript_access); |
490 | 491 |
491 // Returns a title string to use in the task manager for a process host with | 492 // Returns a title string to use in the task manager for a process host with |
492 // the given URL, or the empty string to fall back to the default logic. | 493 // the given URL, or the empty string to fall back to the default logic. |
493 // This is called on the IO thread. | 494 // This is called on the IO thread. |
494 virtual std::string GetWorkerProcessTitle(const GURL& url, | 495 virtual std::string GetWorkerProcessTitle(const GURL& url, |
495 ResourceContext* context); | 496 ResourceContext* context); |
496 | 497 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 // Returns the default filename used in downloads when we have no idea what | 542 // Returns the default filename used in downloads when we have no idea what |
542 // else we should do with the file. | 543 // else we should do with the file. |
543 virtual std::string GetDefaultDownloadName(); | 544 virtual std::string GetDefaultDownloadName(); |
544 | 545 |
545 // Notification that a pepper plugin has just been spawned. This allows the | 546 // Notification that a pepper plugin has just been spawned. This allows the |
546 // embedder to add filters onto the host to implement interfaces. | 547 // embedder to add filters onto the host to implement interfaces. |
547 // This is called on the IO thread. | 548 // This is called on the IO thread. |
548 virtual void DidCreatePpapiPlugin(BrowserPpapiHost* browser_host) {} | 549 virtual void DidCreatePpapiPlugin(BrowserPpapiHost* browser_host) {} |
549 | 550 |
550 // Gets the host for an external out-of-process plugin. | 551 // Gets the host for an external out-of-process plugin. |
551 virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost( | 552 virtual BrowserPpapiHost* GetExternalBrowserPpapiHost( |
552 int plugin_child_id); | 553 int plugin_child_id); |
553 | 554 |
554 // Returns true if the socket operation specified by |params| is allowed from | 555 // Returns true if the socket operation specified by |params| is allowed from |
555 // the given |browser_context| and |url|. If |params| is NULL, this method | 556 // the given |browser_context| and |url|. If |params| is NULL, this method |
556 // checks the basic "socket" permission, which is for those operations that | 557 // checks the basic "socket" permission, which is for those operations that |
557 // don't require a specific socket permission rule. | 558 // don't require a specific socket permission rule. |
558 // |private_api| indicates whether this permission check is for the private | 559 // |private_api| indicates whether this permission check is for the private |
559 // Pepper socket API or the public one. | 560 // Pepper socket API or the public one. |
560 virtual bool AllowPepperSocketAPI(BrowserContext* browser_context, | 561 virtual bool AllowPepperSocketAPI(BrowserContext* browser_context, |
561 const GURL& url, | 562 const GURL& url, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 // This is called on the PROCESS_LAUNCHER thread before the renderer process | 619 // This is called on the PROCESS_LAUNCHER thread before the renderer process |
619 // is launched. It gives the embedder a chance to add loosen the sandbox | 620 // is launched. It gives the embedder a chance to add loosen the sandbox |
620 // policy. | 621 // policy. |
621 virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy, | 622 virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy, |
622 bool* success) {} | 623 bool* success) {} |
623 #endif | 624 #endif |
624 | 625 |
625 // Returns true if plugin referred to by the url can use | 626 // Returns true if plugin referred to by the url can use |
626 // pp::FileIO::RequestOSFileHandle. | 627 // pp::FileIO::RequestOSFileHandle. |
627 virtual bool IsPluginAllowedToCallRequestOSFileHandle( | 628 virtual bool IsPluginAllowedToCallRequestOSFileHandle( |
628 content::BrowserContext* browser_context, | 629 BrowserContext* browser_context, |
629 const GURL& url); | 630 const GURL& url); |
630 | 631 |
631 // Returns true if dev channel APIs are available for plugins. | 632 // Returns true if dev channel APIs are available for plugins. |
632 virtual bool IsPluginAllowedToUseDevChannelAPIs(); | 633 virtual bool IsPluginAllowedToUseDevChannelAPIs(); |
633 | 634 |
634 // Returns a special cookie store to use for a given render process, or NULL | 635 // Returns a special cookie store to use for a given render process, or NULL |
635 // if the default cookie store should be used | 636 // if the default cookie store should be used |
636 // This is called on the IO thread. | 637 // This is called on the IO thread. |
637 virtual net::CookieStore* OverrideCookieStoreForRenderProcess( | 638 virtual net::CookieStore* OverrideCookieStoreForRenderProcess( |
638 int render_process_id); | 639 int render_process_id); |
639 | 640 |
640 #if defined(VIDEO_HOLE) | 641 #if defined(VIDEO_HOLE) |
641 // Allows an embedder to provide its own ExternalVideoSurfaceContainer | 642 // Allows an embedder to provide its own ExternalVideoSurfaceContainer |
642 // implementation. Return NULL to disable external surface video. | 643 // implementation. Return NULL to disable external surface video. |
643 virtual ExternalVideoSurfaceContainer* | 644 virtual ExternalVideoSurfaceContainer* |
644 OverrideCreateExternalVideoSurfaceContainer(WebContents* web_contents); | 645 OverrideCreateExternalVideoSurfaceContainer(WebContents* web_contents); |
645 #endif | 646 #endif |
646 }; | 647 }; |
647 | 648 |
648 } // namespace content | 649 } // namespace content |
649 | 650 |
650 #endif // CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_ | 651 #endif // CONTENT_PUBLIC_BROWSER_CONTENT_BROWSER_CLIENT_H_ |
OLD | NEW |