Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 6 #define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "chrome/browser/content_settings/host_content_settings_map.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 14 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 14 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 15 #include "chrome/browser/extensions/extension_info_map.h" | 15 #include "chrome/browser/extensions/extension_info_map.h" |
| 16 #include "chrome/browser/extensions/extension_webrequest_api.h" | 16 #include "chrome/browser/extensions/extension_webrequest_api.h" |
| 17 #include "chrome/browser/prefs/pref_change_registrar.h" | 17 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/prerender/prerender_manager.h" | 19 #include "chrome/browser/prerender/prerender_manager.h" |
| 20 #include "chrome/common/extensions/extension.h" | |
| 20 #include "chrome/common/extensions/extension_icon_set.h" | 21 #include "chrome/common/extensions/extension_icon_set.h" |
| 21 #include "chrome/common/net/url_request_context_getter.h" | 22 #include "chrome/common/net/url_request_context_getter.h" |
| 22 #include "content/browser/appcache/chrome_appcache_service.h" | 23 #include "content/browser/appcache/chrome_appcache_service.h" |
| 23 #include "content/browser/chrome_blob_storage_context.h" | 24 #include "content/browser/chrome_blob_storage_context.h" |
| 24 #include "content/browser/host_zoom_map.h" | 25 #include "content/browser/host_zoom_map.h" |
| 26 #include "net/base/cookie_monster.h" | |
| 25 #include "net/base/cookie_policy.h" | 27 #include "net/base/cookie_policy.h" |
| 26 #include "net/url_request/url_request_context.h" | 28 #include "net/url_request/url_request_context.h" |
| 27 #include "webkit/database/database_tracker.h" | 29 #include "webkit/database/database_tracker.h" |
| 28 #include "webkit/fileapi/file_system_context.h" | 30 #include "webkit/fileapi/file_system_context.h" |
| 29 | 31 |
| 30 class ChromeCookiePolicy; | 32 class ChromeCookiePolicy; |
| 31 class ChromeURLDataManagerBackend; | 33 class ChromeURLDataManagerBackend; |
| 32 class ChromeURLRequestContextFactory; | 34 class ChromeURLRequestContextFactory; |
| 33 class IOThread; | 35 class IOThread; |
| 34 namespace net { | 36 namespace net { |
| 35 class DnsCertProvenanceChecker; | 37 class DnsCertProvenanceChecker; |
| 36 class NetworkDelegate; | 38 class NetworkDelegate; |
| 37 } | 39 } |
| 38 class PrefService; | 40 class PrefService; |
| 39 class Profile; | 41 class Profile; |
| 40 class ProfileIOData; | 42 class ProfileIOData; |
| 41 | 43 |
| 42 // Subclass of net::URLRequestContext which can be used to store extra | 44 // Subclass of net::URLRequestContext which can be used to store extra |
| 43 // information for requests. | 45 // information for requests. |
| 44 // | 46 // |
| 45 // All methods of this class must be called from the IO thread, | 47 // All methods of this class must be called from the IO thread, |
| 46 // including the constructor and destructor. | 48 // including the constructor and destructor. |
| 47 class ChromeURLRequestContext : public net::URLRequestContext { | 49 class ChromeURLRequestContext : public net::URLRequestContext { |
| 48 public: | 50 public: |
| 49 ChromeURLRequestContext(); | 51 ChromeURLRequestContext(); |
| 50 | 52 |
| 53 // Copies the state from this context into |out|. | |
| 54 void Copy(ChromeURLRequestContext* out); | |
| 55 | |
| 51 // Gets the path to the directory user scripts are stored in. | 56 // Gets the path to the directory user scripts are stored in. |
| 52 FilePath user_script_dir_path() const { | 57 FilePath user_script_dir_path() const { |
| 53 return user_script_dir_path_; | 58 return user_script_dir_path_; |
| 54 } | 59 } |
| 55 | 60 |
| 56 // Gets the appcache service to be used for requests in this context. | 61 // Gets the appcache service to be used for requests in this context. |
| 57 // May be NULL if requests for this context aren't subject to appcaching. | 62 // May be NULL if requests for this context aren't subject to appcaching. |
| 58 ChromeAppCacheService* appcache_service() const { | 63 ChromeAppCacheService* appcache_service() const { |
| 59 return appcache_service_.get(); | 64 return appcache_service_.get(); |
| 60 } | 65 } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 91 } | 96 } |
| 92 | 97 |
| 93 prerender::PrerenderManager* prerender_manager() { | 98 prerender::PrerenderManager* prerender_manager() { |
| 94 return prerender_manager_.get(); | 99 return prerender_manager_.get(); |
| 95 } | 100 } |
| 96 | 101 |
| 97 const ProtocolHandlerRegistry* protocol_handler_registry() { | 102 const ProtocolHandlerRegistry* protocol_handler_registry() { |
| 98 return protocol_handler_registry_.get(); | 103 return protocol_handler_registry_.get(); |
| 99 } | 104 } |
| 100 | 105 |
| 106 net::CookieMonster::Delegate* cookie_delegate() { | |
|
willchan no longer on Chromium
2011/03/03 18:16:59
Can you remove this? Let's figure out some other w
Charlie Reis
2011/03/04 22:34:53
Done.
| |
| 107 return cookie_delegate_.get(); | |
| 108 } | |
| 109 | |
| 101 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend(); | 110 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend(); |
| 102 | 111 |
| 103 // Setters to simplify initializing from factory objects. | 112 // Setters to simplify initializing from factory objects. |
| 104 void set_chrome_cookie_policy(ChromeCookiePolicy* cookie_policy); | 113 void set_chrome_cookie_policy(ChromeCookiePolicy* cookie_policy); |
| 105 | 114 |
| 115 void set_cookie_delegate(net::CookieMonster::Delegate* cookie_delegate) { | |
| 116 cookie_delegate_ = cookie_delegate; | |
| 117 } | |
| 118 | |
| 106 void set_user_script_dir_path(const FilePath& path) { | 119 void set_user_script_dir_path(const FilePath& path) { |
| 107 user_script_dir_path_ = path; | 120 user_script_dir_path_ = path; |
| 108 } | 121 } |
| 109 void set_is_off_the_record(bool is_off_the_record) { | 122 void set_is_off_the_record(bool is_off_the_record) { |
| 110 is_off_the_record_ = is_off_the_record; | 123 is_off_the_record_ = is_off_the_record; |
| 111 } | 124 } |
| 112 void set_host_content_settings_map( | 125 void set_host_content_settings_map( |
| 113 HostContentSettingsMap* host_content_settings_map) { | 126 HostContentSettingsMap* host_content_settings_map) { |
| 114 host_content_settings_map_ = host_content_settings_map; | 127 host_content_settings_map_ = host_content_settings_map; |
| 115 } | 128 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 virtual ~ChromeURLRequestContext(); | 161 virtual ~ChromeURLRequestContext(); |
| 149 | 162 |
| 150 private: | 163 private: |
| 151 // Path to the directory user scripts are stored in. | 164 // Path to the directory user scripts are stored in. |
| 152 FilePath user_script_dir_path_; | 165 FilePath user_script_dir_path_; |
| 153 | 166 |
| 154 // TODO(willchan): Make these non-refcounted. | 167 // TODO(willchan): Make these non-refcounted. |
| 155 scoped_refptr<ChromeAppCacheService> appcache_service_; | 168 scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 156 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 169 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
| 157 scoped_refptr<ChromeCookiePolicy> chrome_cookie_policy_; | 170 scoped_refptr<ChromeCookiePolicy> chrome_cookie_policy_; |
| 171 scoped_refptr<net::CookieMonster::Delegate> cookie_delegate_; | |
| 158 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 172 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 159 scoped_refptr<HostZoomMap> host_zoom_map_; | 173 scoped_refptr<HostZoomMap> host_zoom_map_; |
| 160 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; | 174 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; |
| 161 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 175 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
| 162 // TODO(aa): This should use chrome/common/extensions/extension_set.h. | 176 // TODO(aa): This should use chrome/common/extensions/extension_set.h. |
| 163 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 177 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 164 scoped_refptr<prerender::PrerenderManager> prerender_manager_; | 178 scoped_refptr<prerender::PrerenderManager> prerender_manager_; |
| 165 scoped_ptr<ChromeURLDataManagerBackend> chrome_url_data_manager_backend_; | 179 scoped_ptr<ChromeURLDataManagerBackend> chrome_url_data_manager_backend_; |
| 166 scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_; | 180 scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_; |
| 167 | 181 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 // get called on UI thread. This method takes a profile and reuses the | 229 // get called on UI thread. This method takes a profile and reuses the |
| 216 // 'original' net::URLRequestContext for common files. | 230 // 'original' net::URLRequestContext for common files. |
| 217 static ChromeURLRequestContextGetter* CreateOriginalForMedia( | 231 static ChromeURLRequestContextGetter* CreateOriginalForMedia( |
| 218 Profile* profile, const ProfileIOData* profile_io_data); | 232 Profile* profile, const ProfileIOData* profile_io_data); |
| 219 | 233 |
| 220 // Create an instance for an original profile for extensions. This is expected | 234 // Create an instance for an original profile for extensions. This is expected |
| 221 // to get called on UI thread. | 235 // to get called on UI thread. |
| 222 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( | 236 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( |
| 223 Profile* profile, const ProfileIOData* profile_io_data); | 237 Profile* profile, const ProfileIOData* profile_io_data); |
| 224 | 238 |
| 239 // Create an instance for an original profile for an app with isolated | |
| 240 // storage. This is expected to get called on UI thread. | |
| 241 static ChromeURLRequestContextGetter* CreateOriginalForIsolatedApp( | |
| 242 Profile* profile, | |
| 243 const ProfileIOData* profile_io_data, | |
| 244 const Extension* installed_app); | |
| 245 | |
| 225 // Create an instance for use with an OTR profile. This is expected to get | 246 // Create an instance for use with an OTR profile. This is expected to get |
| 226 // called on the UI thread. | 247 // called on the UI thread. |
| 227 static ChromeURLRequestContextGetter* CreateOffTheRecord( | 248 static ChromeURLRequestContextGetter* CreateOffTheRecord( |
| 228 Profile* profile, const ProfileIOData* profile_io_data); | 249 Profile* profile, const ProfileIOData* profile_io_data); |
| 229 | 250 |
| 230 // Create an instance for an OTR profile for extensions. This is expected | 251 // Create an instance for an OTR profile for extensions. This is expected |
| 231 // to get called on UI thread. | 252 // to get called on UI thread. |
| 232 static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions( | 253 static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions( |
| 233 Profile* profile, const ProfileIOData* profile_io_data); | 254 Profile* profile, const ProfileIOData* profile_io_data); |
| 234 | 255 |
| 256 // Create an instance for an OTR profile for an app with isolated storage. | |
| 257 // This is expected to get called on UI thread. | |
| 258 static ChromeURLRequestContextGetter* CreateOffTheRecordForIsolatedApp( | |
| 259 Profile* profile, | |
| 260 const ProfileIOData* profile_io_data, | |
| 261 const Extension* installed_app); | |
| 262 | |
| 235 // Clean up UI thread resources. This is expected to get called on the UI | 263 // Clean up UI thread resources. This is expected to get called on the UI |
| 236 // thread before the instance is deleted on the IO thread. | 264 // thread before the instance is deleted on the IO thread. |
| 237 void CleanupOnUIThread(); | 265 void CleanupOnUIThread(); |
| 238 | 266 |
| 239 // NotificationObserver implementation. | 267 // NotificationObserver implementation. |
| 240 virtual void Observe(NotificationType type, | 268 virtual void Observe(NotificationType type, |
| 241 const NotificationSource& source, | 269 const NotificationSource& source, |
| 242 const NotificationDetails& details); | 270 const NotificationDetails& details); |
| 243 | 271 |
| 244 private: | 272 private: |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 271 | 299 |
| 272 // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext | 300 // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext |
| 273 // instance that was lazilly created by GetURLRequestContext. | 301 // instance that was lazilly created by GetURLRequestContext. |
| 274 // Access only from the IO thread. | 302 // Access only from the IO thread. |
| 275 scoped_refptr<net::URLRequestContext> url_request_context_; | 303 scoped_refptr<net::URLRequestContext> url_request_context_; |
| 276 | 304 |
| 277 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); | 305 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); |
| 278 }; | 306 }; |
| 279 | 307 |
| 280 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 308 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |