[email protected] | de7d61ff | 2013-08-20 11:30:41 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | de7d61ff | 2013-08-20 11:30:41 | [diff] [blame] | 5 | #ifndef CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ |
6 | #define CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ | ||||
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 7 | |
8 | #include "base/compiler_specific.h" | ||||
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 9 | #include "base/files/file_path.h" |
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
11 | #include "base/memory/scoped_ptr.h" | ||||
[email protected] | ccb79730 | 2011-12-15 16:55:11 | [diff] [blame] | 12 | #include "content/public/browser/browser_context.h" |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 13 | #include "content/public/browser/content_browser_client.h" |
hanxi | 3328d99 | 2014-10-09 13:27:11 | [diff] [blame] | 14 | #include "content/public/browser/resource_context.h" |
15 | #include "content/shell/browser/shell_url_request_context_getter.h" | ||||
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 16 | #include "net/url_request/url_request_job_factory.h" |
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 17 | |
[email protected] | d5869bf | 2013-07-03 16:21:47 | [diff] [blame] | 18 | namespace net { |
19 | class NetLog; | ||||
20 | } | ||||
21 | |||||
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 22 | namespace content { |
23 | |||||
[email protected] | 1bd0ef1 | 2011-10-20 05:24:17 | [diff] [blame] | 24 | class DownloadManagerDelegate; |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 25 | class ShellDownloadManagerDelegate; |
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 26 | |
27 | class ShellBrowserContext : public BrowserContext { | ||||
28 | public: | ||||
[email protected] | d5869bf | 2013-07-03 16:21:47 | [diff] [blame] | 29 | ShellBrowserContext(bool off_the_record, net::NetLog* net_log); |
[email protected] | 3560b57 | 2012-04-04 20:47:32 | [diff] [blame] | 30 | virtual ~ShellBrowserContext(); |
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 31 | |
[email protected] | 139355f | 2014-05-11 14:21:28 | [diff] [blame] | 32 | void set_guest_manager_for_testing( |
33 | BrowserPluginGuestManager* guest_manager) { | ||||
34 | guest_manager_ = guest_manager; | ||||
[email protected] | 2456926 | 2014-05-06 03:31:30 | [diff] [blame] | 35 | } |
36 | |||||
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 37 | // BrowserContext implementation. |
anand.ratn | 449f39a4 | 2014-10-06 13:45:57 | [diff] [blame] | 38 | virtual base::FilePath GetPath() const override; |
39 | virtual bool IsOffTheRecord() const override; | ||||
40 | virtual DownloadManagerDelegate* GetDownloadManagerDelegate() override; | ||||
41 | virtual net::URLRequestContextGetter* GetRequestContext() override; | ||||
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 42 | virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( |
anand.ratn | 449f39a4 | 2014-10-06 13:45:57 | [diff] [blame] | 43 | int renderer_child_id) override; |
44 | virtual net::URLRequestContextGetter* GetMediaRequestContext() override; | ||||
[email protected] | 10705a7b | 2012-08-21 19:07:08 | [diff] [blame] | 45 | virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( |
anand.ratn | 449f39a4 | 2014-10-06 13:45:57 | [diff] [blame] | 46 | int renderer_child_id) override; |
[email protected] | 10eb2816 | 2012-09-18 03:04:09 | [diff] [blame] | 47 | virtual net::URLRequestContextGetter* |
48 | GetMediaRequestContextForStoragePartition( | ||||
[email protected] | d30a36f | 2013-02-07 04:16:26 | [diff] [blame] | 49 | const base::FilePath& partition_path, |
anand.ratn | 449f39a4 | 2014-10-06 13:45:57 | [diff] [blame] | 50 | bool in_memory) override; |
51 | virtual ResourceContext* GetResourceContext() override; | ||||
52 | virtual BrowserPluginGuestManager* GetGuestManager() override; | ||||
53 | virtual storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; | ||||
54 | virtual PushMessagingService* GetPushMessagingService() override; | ||||
55 | virtual SSLHostStateDelegate* GetSSLHostStateDelegate() override; | ||||
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 56 | |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 57 | net::URLRequestContextGetter* CreateRequestContext( |
[email protected] | 7571263c | 2014-03-10 22:57:09 | [diff] [blame] | 58 | ProtocolHandlerMap* protocol_handlers, |
[email protected] | 3b90aab | 2014-05-30 17:56:15 | [diff] [blame] | 59 | URLRequestInterceptorScopedVector request_interceptors); |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 60 | net::URLRequestContextGetter* CreateRequestContextForStoragePartition( |
[email protected] | c42de73 | 2013-02-16 06:26:31 | [diff] [blame] | 61 | const base::FilePath& partition_path, |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 62 | bool in_memory, |
[email protected] | 7571263c | 2014-03-10 22:57:09 | [diff] [blame] | 63 | ProtocolHandlerMap* protocol_handlers, |
[email protected] | 3b90aab | 2014-05-30 17:56:15 | [diff] [blame] | 64 | URLRequestInterceptorScopedVector request_interceptors); |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 65 | |
hanxi | 3328d99 | 2014-10-09 13:27:11 | [diff] [blame] | 66 | protected: |
67 | // Contains URLRequestContextGetter required for resource loading. | ||||
68 | class ShellResourceContext : public ResourceContext { | ||||
69 | public: | ||||
70 | ShellResourceContext(); | ||||
71 | virtual ~ShellResourceContext(); | ||||
72 | |||||
73 | // ResourceContext implementation: | ||||
74 | virtual net::HostResolver* GetHostResolver() override; | ||||
75 | virtual net::URLRequestContext* GetRequestContext() override; | ||||
76 | |||||
77 | void set_url_request_context_getter(ShellURLRequestContextGetter* getter) { | ||||
78 | getter_ = getter; | ||||
79 | } | ||||
80 | |||||
81 | private: | ||||
82 | ShellURLRequestContextGetter* getter_; | ||||
83 | |||||
84 | DISALLOW_COPY_AND_ASSIGN(ShellResourceContext); | ||||
85 | }; | ||||
86 | |||||
87 | ShellURLRequestContextGetter* url_request_context_getter() { | ||||
88 | return url_request_getter_.get(); | ||||
89 | } | ||||
90 | |||||
91 | // Used by ShellBrowserContext to initiate and set different types of | ||||
92 | // URLRequestContextGetter. | ||||
93 | void set_url_request_context_getter(ShellURLRequestContextGetter* getter) { | ||||
94 | url_request_getter_ = getter; | ||||
95 | } | ||||
96 | |||||
mkwst | 98ce5ad | 2014-10-10 06:51:45 | [diff] [blame] | 97 | scoped_ptr<ShellResourceContext> resource_context_; |
mkwst | d993d06a | 2014-10-10 11:44:38 | [diff] [blame^] | 98 | bool ignore_certificate_errors_; |
99 | scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_; | ||||
mkwst | 98ce5ad | 2014-10-10 06:51:45 | [diff] [blame] | 100 | |
101 | private: | ||||
apavlov | 297746b | 2014-10-10 08:25:26 | [diff] [blame] | 102 | // Performs initialization of the ShellBrowserContext while IO is still |
103 | // allowed on the current thread. | ||||
104 | void InitWhileIOAllowed(); | ||||
105 | |||||
[email protected] | 71d504f | 2012-07-25 17:15:28 | [diff] [blame] | 106 | bool off_the_record_; |
[email protected] | d5869bf | 2013-07-03 16:21:47 | [diff] [blame] | 107 | net::NetLog* net_log_; |
[email protected] | d30a36f | 2013-02-07 04:16:26 | [diff] [blame] | 108 | base::FilePath path_; |
[email protected] | 139355f | 2014-05-11 14:21:28 | [diff] [blame] | 109 | BrowserPluginGuestManager* guest_manager_; |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 110 | scoped_refptr<ShellURLRequestContextGetter> url_request_getter_; |
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 111 | |
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 112 | DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext); |
113 | }; | ||||
114 | |||||
115 | } // namespace content | ||||
116 | |||||
[email protected] | de7d61ff | 2013-08-20 11:30:41 | [diff] [blame] | 117 | #endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ |