| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "chrome/common/appcache/chrome_appcache_service.h" | 6 #include "chrome/common/appcache/chrome_appcache_service.h" |
| 7 #include "chrome/common/notification_registrar.h" | 7 #include "chrome/common/notification_registrar.h" |
| 8 #include "chrome/common/pref_service.h" | 8 #include "chrome/common/pref_service.h" |
| 9 #include "net/url_request/url_request_context.h" | 9 #include "net/url_request/url_request_context.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // expected to be called on the UI thread. | 25 // expected to be called on the UI thread. |
| 26 class ChromeURLRequestContext : public URLRequestContext, | 26 class ChromeURLRequestContext : public URLRequestContext, |
| 27 public NotificationObserver { | 27 public NotificationObserver { |
| 28 public: | 28 public: |
| 29 typedef std::map<std::string, FilePath> ExtensionPaths; | 29 typedef std::map<std::string, FilePath> ExtensionPaths; |
| 30 | 30 |
| 31 // Create an instance for use with an 'original' (non-OTR) profile. This is | 31 // Create an instance for use with an 'original' (non-OTR) profile. This is |
| 32 // expected to get called on the UI thread. | 32 // expected to get called on the UI thread. |
| 33 static ChromeURLRequestContext* CreateOriginal( | 33 static ChromeURLRequestContext* CreateOriginal( |
| 34 Profile* profile, const FilePath& cookie_store_path, | 34 Profile* profile, const FilePath& cookie_store_path, |
| 35 const FilePath& disk_cache_path, int cache_size); | 35 const FilePath& disk_cache_path, int cache_size, |
| 36 ChromeAppCacheService* appcache_service); |
| 36 | 37 |
| 37 // Create an instance for an original profile for media. This is expected to | 38 // Create an instance for an original profile for media. This is expected to |
| 38 // get called on UI thread. This method takes a profile and reuses the | 39 // get called on UI thread. This method takes a profile and reuses the |
| 39 // 'original' URLRequestContext for common files. | 40 // 'original' URLRequestContext for common files. |
| 40 static ChromeURLRequestContext* CreateOriginalForMedia(Profile *profile, | 41 static ChromeURLRequestContext* CreateOriginalForMedia(Profile *profile, |
| 41 const FilePath& disk_cache_path, int cache_size); | 42 const FilePath& disk_cache_path, int cache_size, |
| 43 ChromeAppCacheService* appcache_service); |
| 42 | 44 |
| 43 // Create an instance for an original profile for extensions. This is expected | 45 // Create an instance for an original profile for extensions. This is expected |
| 44 // to get called on UI thread. | 46 // to get called on UI thread. |
| 45 static ChromeURLRequestContext* CreateOriginalForExtensions(Profile *profile, | 47 static ChromeURLRequestContext* CreateOriginalForExtensions(Profile *profile, |
| 46 const FilePath& cookie_store_path); | 48 const FilePath& cookie_store_path); |
| 47 | 49 |
| 48 // Create an instance for use with an OTR profile. This is expected to get | 50 // Create an instance for use with an OTR profile. This is expected to get |
| 49 // called on the UI thread. | 51 // called on the UI thread. |
| 50 static ChromeURLRequestContext* CreateOffTheRecord(Profile* profile); | 52 static ChromeURLRequestContext* CreateOffTheRecord(Profile* profile, |
| 53 ChromeAppCacheService* appcache_service); |
| 51 | 54 |
| 52 // Create an instance of request context for OTR profile for extensions. | 55 // Create an instance of request context for OTR profile for extensions. |
| 53 static ChromeURLRequestContext* CreateOffTheRecordForExtensions( | 56 static ChromeURLRequestContext* CreateOffTheRecordForExtensions( |
| 54 Profile* profile); | 57 Profile* profile); |
| 55 | 58 |
| 56 // Clean up UI thread resources. This is expected to get called on the UI | 59 // Clean up UI thread resources. This is expected to get called on the UI |
| 57 // thread before the instance is deleted on the IO thread. | 60 // thread before the instance is deleted on the IO thread. |
| 58 void CleanupOnUIThread(); | 61 void CleanupOnUIThread(); |
| 59 | 62 |
| 60 // Gets the path to the directory for the specified extension. | 63 // Gets the path to the directory for the specified extension. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 virtual const std::string& GetUserAgent(const GURL& url) const; | 77 virtual const std::string& GetUserAgent(const GURL& url) const; |
| 75 | 78 |
| 76 virtual bool InterceptCookie(const URLRequest* request, std::string* cookie); | 79 virtual bool InterceptCookie(const URLRequest* request, std::string* cookie); |
| 77 | 80 |
| 78 virtual bool AllowSendingCookies(const URLRequest* request) const; | 81 virtual bool AllowSendingCookies(const URLRequest* request) const; |
| 79 | 82 |
| 80 // Gets the Privacy Blacklist, if any for this context. | 83 // Gets the Privacy Blacklist, if any for this context. |
| 81 const Blacklist* blacklist() const { return blacklist_; } | 84 const Blacklist* blacklist() const { return blacklist_; } |
| 82 | 85 |
| 83 protected: | 86 protected: |
| 84 // Private constructor, use the static factory methods instead. This is | 87 // Private constructors, use the static factory methods instead. This is |
| 85 // expected to be called on the UI thread. | 88 // expected to be called on the UI thread. |
| 86 ChromeURLRequestContext(Profile* profile); | 89 ChromeURLRequestContext( |
| 90 Profile* profile, ChromeAppCacheService* appcache_service); |
| 87 ChromeURLRequestContext(ChromeURLRequestContext* other); | 91 ChromeURLRequestContext(ChromeURLRequestContext* other); |
| 88 | 92 |
| 89 // Create a request context for media resources from a regular request | 93 // Create a request context for media resources from a regular request |
| 90 // context. This helper method is called from CreateOriginalForMedia and | 94 // context. This helper method is called from CreateOriginalForMedia and |
| 91 // CreateOffTheRecordForMedia. | 95 // CreateOffTheRecordForMedia. |
| 92 static ChromeURLRequestContext* CreateRequestContextForMedia(Profile* profile, | 96 static ChromeURLRequestContext* CreateRequestContextForMedia(Profile* profile, |
| 93 const FilePath& disk_cache_path, int cache_size, bool off_the_record); | 97 const FilePath& disk_cache_path, int cache_size, bool off_the_record, |
| 98 ChromeAppCacheService* appache_service); |
| 94 | 99 |
| 95 // NotificationObserver implementation. | 100 // NotificationObserver implementation. |
| 96 virtual void Observe(NotificationType type, | 101 virtual void Observe(NotificationType type, |
| 97 const NotificationSource& source, | 102 const NotificationSource& source, |
| 98 const NotificationDetails& details); | 103 const NotificationDetails& details); |
| 99 | 104 |
| 100 // Callback for when the accept language changes. | 105 // Callback for when the accept language changes. |
| 101 void OnAcceptLanguageChange(const std::string& accept_language); | 106 void OnAcceptLanguageChange(const std::string& accept_language); |
| 102 | 107 |
| 103 // Callback for when the cookie policy changes. | 108 // Callback for when the cookie policy changes. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 128 | 133 |
| 129 PrefService* prefs_; | 134 PrefService* prefs_; |
| 130 const Blacklist* blacklist_; | 135 const Blacklist* blacklist_; |
| 131 bool is_media_; | 136 bool is_media_; |
| 132 bool is_off_the_record_; | 137 bool is_off_the_record_; |
| 133 }; | 138 }; |
| 134 | 139 |
| 135 // Creates a proxy configuration using the overrides specified on the command | 140 // Creates a proxy configuration using the overrides specified on the command |
| 136 // line. Returns NULL if the system defaults should be used instead. | 141 // line. Returns NULL if the system defaults should be used instead. |
| 137 net::ProxyConfig* CreateProxyConfig(const CommandLine& command_line); | 142 net::ProxyConfig* CreateProxyConfig(const CommandLine& command_line); |
| OLD | NEW |