OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ | 5 #ifndef CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ |
6 #define CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ | 6 #define CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/content_browser_client.h" | 13 #include "content/public/browser/content_browser_client.h" |
| 14 #include "content/public/browser/resource_context.h" |
| 15 #include "content/shell/browser/shell_url_request_context_getter.h" |
14 #include "net/url_request/url_request_job_factory.h" | 16 #include "net/url_request/url_request_job_factory.h" |
15 | 17 |
16 namespace net { | 18 namespace net { |
17 class NetLog; | 19 class NetLog; |
18 } | 20 } |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 | 23 |
22 class DownloadManagerDelegate; | 24 class DownloadManagerDelegate; |
23 class ResourceContext; | |
24 class ShellDownloadManagerDelegate; | 25 class ShellDownloadManagerDelegate; |
25 class ShellURLRequestContextGetter; | |
26 | 26 |
27 class ShellBrowserContext : public BrowserContext { | 27 class ShellBrowserContext : public BrowserContext { |
28 public: | 28 public: |
29 ShellBrowserContext(bool off_the_record, net::NetLog* net_log); | 29 ShellBrowserContext(bool off_the_record, net::NetLog* net_log); |
30 virtual ~ShellBrowserContext(); | 30 virtual ~ShellBrowserContext(); |
31 | 31 |
32 void set_guest_manager_for_testing( | 32 void set_guest_manager_for_testing( |
33 BrowserPluginGuestManager* guest_manager) { | 33 BrowserPluginGuestManager* guest_manager) { |
34 guest_manager_ = guest_manager; | 34 guest_manager_ = guest_manager; |
35 } | 35 } |
(...skipping 20 matching lines...) Expand all Loading... |
56 | 56 |
57 net::URLRequestContextGetter* CreateRequestContext( | 57 net::URLRequestContextGetter* CreateRequestContext( |
58 ProtocolHandlerMap* protocol_handlers, | 58 ProtocolHandlerMap* protocol_handlers, |
59 URLRequestInterceptorScopedVector request_interceptors); | 59 URLRequestInterceptorScopedVector request_interceptors); |
60 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( | 60 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( |
61 const base::FilePath& partition_path, | 61 const base::FilePath& partition_path, |
62 bool in_memory, | 62 bool in_memory, |
63 ProtocolHandlerMap* protocol_handlers, | 63 ProtocolHandlerMap* protocol_handlers, |
64 URLRequestInterceptorScopedVector request_interceptors); | 64 URLRequestInterceptorScopedVector request_interceptors); |
65 | 65 |
| 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 |
| 97 scoped_ptr<ShellResourceContext> resource_context_; |
| 98 |
66 private: | 99 private: |
67 class ShellResourceContext; | |
68 | 100 |
69 // Performs initialization of the ShellBrowserContext while IO is still | 101 // Performs initialization of the ShellBrowserContext while IO is still |
70 // allowed on the current thread. | 102 // allowed on the current thread. |
71 void InitWhileIOAllowed(); | 103 void InitWhileIOAllowed(); |
72 | 104 |
73 bool off_the_record_; | 105 bool off_the_record_; |
74 net::NetLog* net_log_; | 106 net::NetLog* net_log_; |
75 bool ignore_certificate_errors_; | 107 bool ignore_certificate_errors_; |
76 base::FilePath path_; | 108 base::FilePath path_; |
77 BrowserPluginGuestManager* guest_manager_; | 109 BrowserPluginGuestManager* guest_manager_; |
78 scoped_ptr<ShellResourceContext> resource_context_; | |
79 scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_; | 110 scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_; |
80 scoped_refptr<ShellURLRequestContextGetter> url_request_getter_; | 111 scoped_refptr<ShellURLRequestContextGetter> url_request_getter_; |
81 | 112 |
82 DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext); | 113 DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext); |
83 }; | 114 }; |
84 | 115 |
85 } // namespace content | 116 } // namespace content |
86 | 117 |
87 #endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ | 118 #endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ |
OLD | NEW |