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" |
| 25 #include "net/base/cookie_policy.h" | 26 #include "net/base/cookie_policy.h" |
| 26 #include "net/url_request/url_request_context.h" | 27 #include "net/url_request/url_request_context.h" |
| 27 #include "webkit/database/database_tracker.h" | 28 #include "webkit/database/database_tracker.h" |
| 28 #include "webkit/fileapi/file_system_context.h" | 29 #include "webkit/fileapi/file_system_context.h" |
| 29 | 30 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 41 | 42 |
| 42 // Subclass of net::URLRequestContext which can be used to store extra | 43 // Subclass of net::URLRequestContext which can be used to store extra |
| 43 // information for requests. | 44 // information for requests. |
| 44 // | 45 // |
| 45 // All methods of this class must be called from the IO thread, | 46 // All methods of this class must be called from the IO thread, |
| 46 // including the constructor and destructor. | 47 // including the constructor and destructor. |
| 47 class ChromeURLRequestContext : public net::URLRequestContext { | 48 class ChromeURLRequestContext : public net::URLRequestContext { |
| 48 public: | 49 public: |
| 49 ChromeURLRequestContext(); | 50 ChromeURLRequestContext(); |
| 50 | 51 |
| 52 // Copies the state from |other| into this context. | |
| 53 void CopyFrom(ChromeURLRequestContext* other); | |
| 54 | |
| 51 // Gets the path to the directory user scripts are stored in. | 55 // Gets the path to the directory user scripts are stored in. |
| 52 FilePath user_script_dir_path() const { | 56 FilePath user_script_dir_path() const { |
| 53 return user_script_dir_path_; | 57 return user_script_dir_path_; |
| 54 } | 58 } |
| 55 | 59 |
| 56 // Gets the appcache service to be used for requests in this context. | 60 // 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. | 61 // May be NULL if requests for this context aren't subject to appcaching. |
| 58 ChromeAppCacheService* appcache_service() const { | 62 ChromeAppCacheService* appcache_service() const { |
| 59 return appcache_service_.get(); | 63 return appcache_service_.get(); |
| 60 } | 64 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 | 144 |
| 141 // Callback for when the accept language changes. | 145 // Callback for when the accept language changes. |
| 142 void OnAcceptLanguageChange(const std::string& accept_language); | 146 void OnAcceptLanguageChange(const std::string& accept_language); |
| 143 | 147 |
| 144 // Callback for when the default charset changes. | 148 // Callback for when the default charset changes. |
| 145 void OnDefaultCharsetChange(const std::string& default_charset); | 149 void OnDefaultCharsetChange(const std::string& default_charset); |
| 146 | 150 |
| 147 protected: | 151 protected: |
| 148 virtual ~ChromeURLRequestContext(); | 152 virtual ~ChromeURLRequestContext(); |
| 149 | 153 |
| 150 private: | 154 private: |
|
willchan no longer on Chromium
2011/03/08 22:29:14
Please add scary comments to the beginning and end
Matt Perry
2011/03/08 22:31:36
We could add a COMPILE_ASSERT that the ChromeURLRe
willchan no longer on Chromium
2011/03/08 22:41:11
Yeah, I've seen that solution before. It gets anno
Charlie Reis
2011/03/09 00:10:55
That's too bad-- a compile assertion would have be
| |
| 151 // Path to the directory user scripts are stored in. | 155 // Path to the directory user scripts are stored in. |
| 152 FilePath user_script_dir_path_; | 156 FilePath user_script_dir_path_; |
| 153 | 157 |
| 154 // TODO(willchan): Make these non-refcounted. | 158 // TODO(willchan): Make these non-refcounted. |
| 155 scoped_refptr<ChromeAppCacheService> appcache_service_; | 159 scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 156 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 160 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
| 157 scoped_refptr<ChromeCookiePolicy> chrome_cookie_policy_; | 161 scoped_refptr<ChromeCookiePolicy> chrome_cookie_policy_; |
| 158 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 162 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 159 scoped_refptr<HostZoomMap> host_zoom_map_; | 163 scoped_refptr<HostZoomMap> host_zoom_map_; |
| 160 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; | 164 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; |
| (...skipping 54 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 | 219 // get called on UI thread. This method takes a profile and reuses the |
| 216 // 'original' net::URLRequestContext for common files. | 220 // 'original' net::URLRequestContext for common files. |
| 217 static ChromeURLRequestContextGetter* CreateOriginalForMedia( | 221 static ChromeURLRequestContextGetter* CreateOriginalForMedia( |
| 218 Profile* profile, const ProfileIOData* profile_io_data); | 222 Profile* profile, const ProfileIOData* profile_io_data); |
| 219 | 223 |
| 220 // Create an instance for an original profile for extensions. This is expected | 224 // Create an instance for an original profile for extensions. This is expected |
| 221 // to get called on UI thread. | 225 // to get called on UI thread. |
| 222 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( | 226 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( |
| 223 Profile* profile, const ProfileIOData* profile_io_data); | 227 Profile* profile, const ProfileIOData* profile_io_data); |
| 224 | 228 |
| 229 // Create an instance for an original profile for an app with isolated | |
| 230 // storage. This is expected to get called on UI thread. | |
| 231 static ChromeURLRequestContextGetter* CreateOriginalForIsolatedApp( | |
| 232 Profile* profile, | |
| 233 const ProfileIOData* profile_io_data, | |
| 234 const Extension* installed_app); | |
| 235 | |
| 225 // Create an instance for use with an OTR profile. This is expected to get | 236 // Create an instance for use with an OTR profile. This is expected to get |
| 226 // called on the UI thread. | 237 // called on the UI thread. |
| 227 static ChromeURLRequestContextGetter* CreateOffTheRecord( | 238 static ChromeURLRequestContextGetter* CreateOffTheRecord( |
| 228 Profile* profile, const ProfileIOData* profile_io_data); | 239 Profile* profile, const ProfileIOData* profile_io_data); |
| 229 | 240 |
| 230 // Create an instance for an OTR profile for extensions. This is expected | 241 // Create an instance for an OTR profile for extensions. This is expected |
| 231 // to get called on UI thread. | 242 // to get called on UI thread. |
| 232 static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions( | 243 static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions( |
| 233 Profile* profile, const ProfileIOData* profile_io_data); | 244 Profile* profile, const ProfileIOData* profile_io_data); |
| 234 | 245 |
| 246 // Create an instance for an OTR profile for an app with isolated storage. | |
| 247 // This is expected to get called on UI thread. | |
| 248 static ChromeURLRequestContextGetter* CreateOffTheRecordForIsolatedApp( | |
| 249 Profile* profile, | |
| 250 const ProfileIOData* profile_io_data, | |
| 251 const Extension* installed_app); | |
| 252 | |
| 235 // Clean up UI thread resources. This is expected to get called on the UI | 253 // 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. | 254 // thread before the instance is deleted on the IO thread. |
| 237 void CleanupOnUIThread(); | 255 void CleanupOnUIThread(); |
| 238 | 256 |
| 239 // NotificationObserver implementation. | 257 // NotificationObserver implementation. |
| 240 virtual void Observe(NotificationType type, | 258 virtual void Observe(NotificationType type, |
| 241 const NotificationSource& source, | 259 const NotificationSource& source, |
| 242 const NotificationDetails& details); | 260 const NotificationDetails& details); |
| 243 | 261 |
| 244 private: | 262 private: |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 271 | 289 |
| 272 // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext | 290 // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext |
| 273 // instance that was lazilly created by GetURLRequestContext. | 291 // instance that was lazilly created by GetURLRequestContext. |
| 274 // Access only from the IO thread. | 292 // Access only from the IO thread. |
| 275 scoped_refptr<net::URLRequestContext> url_request_context_; | 293 scoped_refptr<net::URLRequestContext> url_request_context_; |
| 276 | 294 |
| 277 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); | 295 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); |
| 278 }; | 296 }; |
| 279 | 297 |
| 280 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 298 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |