| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/linked_ptr.h" | 12 #include "base/linked_ptr.h" |
| 13 #include "net/base/cookie_monster.h" | 13 #include "net/base/cookie_monster.h" |
| 14 #include "net/base/cookie_policy.h" | 14 #include "net/base/cookie_policy.h" |
| 15 #include "chrome/browser/appcache/chrome_appcache_service.h" | 15 #include "chrome/browser/appcache/chrome_appcache_service.h" |
| 16 #include "chrome/browser/host_content_settings_map.h" | 16 #include "chrome/browser/host_content_settings_map.h" |
| 17 #include "chrome/browser/host_zoom_map.h" | 17 #include "chrome/browser/host_zoom_map.h" |
| 18 #include "chrome/browser/io_thread.h" | 18 #include "chrome/browser/io_thread.h" |
| 19 #include "chrome/browser/pref_service.h" | 19 #include "chrome/browser/pref_service.h" |
| 20 #include "chrome/browser/privacy_blacklist/blacklist.h" | |
| 21 #include "chrome/browser/net/chrome_cookie_policy.h" | 20 #include "chrome/browser/net/chrome_cookie_policy.h" |
| 22 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
| 23 #include "chrome/common/net/url_request_context_getter.h" | 22 #include "chrome/common/net/url_request_context_getter.h" |
| 24 #include "chrome/common/notification_registrar.h" | 23 #include "chrome/common/notification_registrar.h" |
| 25 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
| 26 #include "webkit/database/database_tracker.h" | 25 #include "webkit/database/database_tracker.h" |
| 27 | 26 |
| 28 class CommandLine; | 27 class CommandLine; |
| 29 class PrefService; | 28 class PrefService; |
| 30 class Profile; | 29 class Profile; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 99 |
| 101 bool is_off_the_record() const { | 100 bool is_off_the_record() const { |
| 102 return is_off_the_record_; | 101 return is_off_the_record_; |
| 103 } | 102 } |
| 104 bool is_media() const { | 103 bool is_media() const { |
| 105 return is_media_; | 104 return is_media_; |
| 106 } | 105 } |
| 107 | 106 |
| 108 virtual const std::string& GetUserAgent(const GURL& url) const; | 107 virtual const std::string& GetUserAgent(const GURL& url) const; |
| 109 | 108 |
| 110 // Returns true if cookies can be added to request. | |
| 111 virtual bool InterceptRequestCookies(const URLRequest* request, | |
| 112 const std::string& cookie) const; | |
| 113 | |
| 114 // Returns true if response cookies should be stored. | |
| 115 virtual bool InterceptResponseCookie(const URLRequest* request, | |
| 116 const std::string& cookie) const; | |
| 117 | |
| 118 HostContentSettingsMap* host_content_settings_map() { | 109 HostContentSettingsMap* host_content_settings_map() { |
| 119 return host_content_settings_map_; | 110 return host_content_settings_map_; |
| 120 } | 111 } |
| 121 | 112 |
| 122 const HostZoomMap* host_zoom_map() const { return host_zoom_map_; } | 113 const HostZoomMap* host_zoom_map() const { return host_zoom_map_; } |
| 123 | 114 |
| 124 // Gets the Privacy Blacklist, if any for this context. | |
| 125 const Blacklist* GetPrivacyBlacklist() const; | |
| 126 | |
| 127 // Callback for when new extensions are loaded. Takes ownership of | 115 // Callback for when new extensions are loaded. Takes ownership of |
| 128 // |extension_info|. | 116 // |extension_info|. |
| 129 void OnNewExtensions(const std::string& id, ExtensionInfo* extension_info); | 117 void OnNewExtensions(const std::string& id, ExtensionInfo* extension_info); |
| 130 | 118 |
| 131 // Callback for when an extension is unloaded. | 119 // Callback for when an extension is unloaded. |
| 132 void OnUnloadedExtension(const std::string& id); | 120 void OnUnloadedExtension(const std::string& id); |
| 133 | 121 |
| 134 // False only if cookies are globally blocked without exception. | 122 // False only if cookies are globally blocked without exception. |
| 135 bool AreCookiesEnabled() const; | 123 bool AreCookiesEnabled() const; |
| 136 | 124 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 void set_is_media(bool is_media) { | 189 void set_is_media(bool is_media) { |
| 202 is_media_ = is_media; | 190 is_media_ = is_media; |
| 203 } | 191 } |
| 204 void set_host_content_settings_map( | 192 void set_host_content_settings_map( |
| 205 HostContentSettingsMap* host_content_settings_map) { | 193 HostContentSettingsMap* host_content_settings_map) { |
| 206 host_content_settings_map_ = host_content_settings_map; | 194 host_content_settings_map_ = host_content_settings_map; |
| 207 } | 195 } |
| 208 void set_host_zoom_map(HostZoomMap* host_zoom_map) { | 196 void set_host_zoom_map(HostZoomMap* host_zoom_map) { |
| 209 host_zoom_map_ = host_zoom_map; | 197 host_zoom_map_ = host_zoom_map; |
| 210 } | 198 } |
| 211 void set_privacy_blacklist(Blacklist* privacy_blacklist) { | |
| 212 privacy_blacklist_ = privacy_blacklist; | |
| 213 } | |
| 214 void set_appcache_service(ChromeAppCacheService* service) { | 199 void set_appcache_service(ChromeAppCacheService* service) { |
| 215 appcache_service_ = service; | 200 appcache_service_ = service; |
| 216 } | 201 } |
| 217 void set_database_tracker(webkit_database::DatabaseTracker* tracker) { | 202 void set_database_tracker(webkit_database::DatabaseTracker* tracker) { |
| 218 database_tracker_ = tracker; | 203 database_tracker_ = tracker; |
| 219 } | 204 } |
| 220 void set_net_log(net::NetLog* net_log) { | 205 void set_net_log(net::NetLog* net_log) { |
| 221 net_log_ = net_log; | 206 net_log_ = net_log; |
| 222 } | 207 } |
| 223 void set_network_delegate( | 208 void set_network_delegate( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 235 ExtensionInfoMap extension_info_; | 220 ExtensionInfoMap extension_info_; |
| 236 | 221 |
| 237 // Path to the directory user scripts are stored in. | 222 // Path to the directory user scripts are stored in. |
| 238 FilePath user_script_dir_path_; | 223 FilePath user_script_dir_path_; |
| 239 | 224 |
| 240 scoped_refptr<ChromeAppCacheService> appcache_service_; | 225 scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 241 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 226 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
| 242 scoped_refptr<ChromeCookiePolicy> chrome_cookie_policy_; | 227 scoped_refptr<ChromeCookiePolicy> chrome_cookie_policy_; |
| 243 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 228 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 244 scoped_refptr<HostZoomMap> host_zoom_map_; | 229 scoped_refptr<HostZoomMap> host_zoom_map_; |
| 245 scoped_refptr<Blacklist> privacy_blacklist_; | |
| 246 | 230 |
| 247 bool is_media_; | 231 bool is_media_; |
| 248 bool is_off_the_record_; | 232 bool is_off_the_record_; |
| 249 | 233 |
| 250 private: | 234 private: |
| 251 // Blacklist implementation of InterceptRequestCookie and | |
| 252 // InterceptResponseCookie. Returns true if cookies are allowed and false | |
| 253 // if the request matches a Blacklist rule and cookies should be blocked. | |
| 254 bool InterceptCookie(const URLRequest* request, | |
| 255 const std::string& cookie) const; | |
| 256 | 235 |
| 257 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); | 236 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); |
| 258 }; | 237 }; |
| 259 | 238 |
| 260 // A URLRequestContextGetter subclass used by the browser. This returns a | 239 // A URLRequestContextGetter subclass used by the browser. This returns a |
| 261 // subclass of URLRequestContext which can be used to store extra information | 240 // subclass of URLRequestContext which can be used to store extra information |
| 262 // about requests. | 241 // about requests. |
| 263 // | 242 // |
| 264 // Most methods are expected to be called on the UI thread, except for | 243 // Most methods are expected to be called on the UI thread, except for |
| 265 // the destructor and GetURLRequestContext(). | 244 // the destructor and GetURLRequestContext(). |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 std::string accept_language_; | 378 std::string accept_language_; |
| 400 std::string accept_charset_; | 379 std::string accept_charset_; |
| 401 std::string referrer_charset_; | 380 std::string referrer_charset_; |
| 402 ChromeURLRequestContext::ExtensionInfoMap extension_info_; | 381 ChromeURLRequestContext::ExtensionInfoMap extension_info_; |
| 403 // TODO(aa): I think this can go away now as we no longer support standalone | 382 // TODO(aa): I think this can go away now as we no longer support standalone |
| 404 // user scripts. | 383 // user scripts. |
| 405 FilePath user_script_dir_path_; | 384 FilePath user_script_dir_path_; |
| 406 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 385 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 407 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 386 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
| 408 scoped_refptr<HostZoomMap> host_zoom_map_; | 387 scoped_refptr<HostZoomMap> host_zoom_map_; |
| 409 scoped_refptr<Blacklist> privacy_blacklist_; | |
| 410 scoped_refptr<net::TransportSecurityState> transport_security_state_; | 388 scoped_refptr<net::TransportSecurityState> transport_security_state_; |
| 411 scoped_refptr<net::SSLConfigService> ssl_config_service_; | 389 scoped_refptr<net::SSLConfigService> ssl_config_service_; |
| 412 scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate_; | 390 scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate_; |
| 413 | 391 |
| 414 FilePath profile_dir_path_; | 392 FilePath profile_dir_path_; |
| 415 | 393 |
| 416 private: | 394 private: |
| 417 IOThread* const io_thread_; | 395 IOThread* const io_thread_; |
| 418 | 396 |
| 419 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory); | 397 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory); |
| 420 }; | 398 }; |
| 421 | 399 |
| 422 // Creates a proxy configuration from proxy-related preferences fetched | 400 // Creates a proxy configuration from proxy-related preferences fetched |
| 423 // from |pref_service|. The relevant preferences in |pref_service| are | 401 // from |pref_service|. The relevant preferences in |pref_service| are |
| 424 // initialized from the process' command line or by applicable proxy policies. | 402 // initialized from the process' command line or by applicable proxy policies. |
| 425 net::ProxyConfig* CreateProxyConfig(const PrefService* pref_service); | 403 net::ProxyConfig* CreateProxyConfig(const PrefService* pref_service); |
| 426 | 404 |
| 427 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 405 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |