| 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/memory/scoped_ptr.h" | 12 #include "base/file_path.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "chrome/browser/extensions/extension_info_map.h" |
| 15 #include "chrome/browser/extensions/extension_webrequest_api.h" |
| 13 #include "chrome/browser/prefs/pref_change_registrar.h" | 16 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/common/extensions/extension_icon_set.h" |
| 19 #include "content/browser/appcache/chrome_appcache_service.h" |
| 20 #include "content/browser/chrome_blob_storage_context.h" |
| 14 #include "content/common/notification_observer.h" | 21 #include "content/common/notification_observer.h" |
| 15 #include "content/common/notification_registrar.h" | 22 #include "content/common/notification_registrar.h" |
| 16 #include "net/url_request/url_request_context.h" | 23 #include "net/url_request/url_request_context.h" |
| 17 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
| 25 #include "webkit/fileapi/file_system_context.h" |
| 18 | 26 |
| 19 class ChromeURLDataManagerBackend; | 27 class ChromeURLDataManagerBackend; |
| 20 class ChromeURLRequestContextFactory; | 28 class ChromeURLRequestContextFactory; |
| 21 class IOThread; | 29 class IOThread; |
| 30 class PrefService; |
| 22 class Profile; | 31 class Profile; |
| 23 class ProfileIOData; | 32 class ProfileIOData; |
| 24 namespace base { | 33 namespace base { |
| 25 class WaitableEvent; | 34 class WaitableEvent; |
| 26 } | 35 } |
| 27 namespace net { | 36 namespace net { |
| 28 class NetworkDelegate; | 37 class NetworkDelegate; |
| 29 } | 38 } |
| 30 | 39 |
| 31 // Subclass of net::URLRequestContext which can be used to store extra | 40 // Subclass of net::URLRequestContext which can be used to store extra |
| 32 // information for requests. | 41 // information for requests. |
| 33 // | 42 // |
| 34 // All methods of this class must be called from the IO thread, | 43 // All methods of this class must be called from the IO thread, |
| 35 // including the constructor and destructor. | 44 // including the constructor and destructor. |
| 36 class ChromeURLRequestContext : public net::URLRequestContext { | 45 class ChromeURLRequestContext : public net::URLRequestContext { |
| 37 public: | 46 public: |
| 38 ChromeURLRequestContext(); | 47 ChromeURLRequestContext(); |
| 39 | 48 |
| 40 // Copies the state from |other| into this context. | 49 // Copies the state from |other| into this context. |
| 41 void CopyFrom(ChromeURLRequestContext* other); | 50 void CopyFrom(ChromeURLRequestContext* other); |
| 42 | 51 |
| 43 base::WeakPtr<ChromeURLRequestContext> GetWeakPtr() { | 52 base::WeakPtr<ChromeURLRequestContext> GetWeakPtr() { |
| 44 return weak_ptr_factory_.GetWeakPtr(); | 53 return weak_ptr_factory_.GetWeakPtr(); |
| 45 } | 54 } |
| 46 | 55 |
| 56 // 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. |
| 58 ChromeAppCacheService* appcache_service() const { |
| 59 return appcache_service_.get(); |
| 60 } |
| 61 |
| 62 // Gets the blob storage context associated with this context's profile. |
| 63 ChromeBlobStorageContext* blob_storage_context() const { |
| 64 return blob_storage_context_.get(); |
| 65 } |
| 66 |
| 67 // Gets the file system host context with this context's profile. |
| 68 fileapi::FileSystemContext* file_system_context() const { |
| 69 return file_system_context_.get(); |
| 70 } |
| 71 |
| 47 bool is_incognito() const { | 72 bool is_incognito() const { |
| 48 return is_incognito_; | 73 return is_incognito_; |
| 49 } | 74 } |
| 50 | 75 |
| 51 virtual const std::string& GetUserAgent(const GURL& url) const; | 76 virtual const std::string& GetUserAgent(const GURL& url) const; |
| 52 | 77 |
| 78 const ExtensionInfoMap* extension_info_map() const { |
| 79 return extension_info_map_; |
| 80 } |
| 81 |
| 53 // TODO(willchan): Get rid of the need for this accessor. Really, this should | 82 // TODO(willchan): Get rid of the need for this accessor. Really, this should |
| 54 // move completely to ProfileIOData. | 83 // move completely to ProfileIOData. |
| 55 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const; | 84 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const; |
| 56 | 85 |
| 57 void set_is_incognito(bool is_incognito) { | 86 void set_is_incognito(bool is_incognito) { |
| 58 is_incognito_ = is_incognito; | 87 is_incognito_ = is_incognito; |
| 59 } | 88 } |
| 89 void set_appcache_service(ChromeAppCacheService* service) { |
| 90 appcache_service_ = service; |
| 91 } |
| 92 void set_blob_storage_context(ChromeBlobStorageContext* context) { |
| 93 blob_storage_context_ = context; |
| 94 } |
| 95 void set_file_system_context(fileapi::FileSystemContext* context) { |
| 96 file_system_context_ = context; |
| 97 } |
| 98 void set_extension_info_map(ExtensionInfoMap* map) { |
| 99 extension_info_map_ = map; |
| 100 } |
| 60 void set_chrome_url_data_manager_backend( | 101 void set_chrome_url_data_manager_backend( |
| 61 ChromeURLDataManagerBackend* backend); | 102 ChromeURLDataManagerBackend* backend); |
| 62 | 103 |
| 63 // Callback for when the accept language changes. | 104 // Callback for when the accept language changes. |
| 64 void OnAcceptLanguageChange(const std::string& accept_language); | 105 void OnAcceptLanguageChange(const std::string& accept_language); |
| 65 | 106 |
| 66 // Callback for when the default charset changes. | 107 // Callback for when the default charset changes. |
| 67 void OnDefaultCharsetChange(const std::string& default_charset); | 108 void OnDefaultCharsetChange(const std::string& default_charset); |
| 68 | 109 |
| 69 protected: | 110 protected: |
| 70 virtual ~ChromeURLRequestContext(); | 111 virtual ~ChromeURLRequestContext(); |
| 71 | 112 |
| 72 private: | 113 private: |
| 73 base::WeakPtrFactory<ChromeURLRequestContext> weak_ptr_factory_; | 114 base::WeakPtrFactory<ChromeURLRequestContext> weak_ptr_factory_; |
| 74 | 115 |
| 75 // --------------------------------------------------------------------------- | 116 // --------------------------------------------------------------------------- |
| 76 // Important: When adding any new members below, consider whether they need to | 117 // Important: When adding any new members below, consider whether they need to |
| 77 // be added to CopyFrom. | 118 // be added to CopyFrom. |
| 78 // --------------------------------------------------------------------------- | 119 // --------------------------------------------------------------------------- |
| 79 | 120 |
| 121 // TODO(willchan): Make these non-refcounted. |
| 122 scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 123 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; |
| 124 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
| 125 // TODO(aa): This should use chrome/common/extensions/extension_set.h. |
| 126 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 127 |
| 80 ChromeURLDataManagerBackend* chrome_url_data_manager_backend_; | 128 ChromeURLDataManagerBackend* chrome_url_data_manager_backend_; |
| 81 bool is_incognito_; | 129 bool is_incognito_; |
| 82 | 130 |
| 83 // --------------------------------------------------------------------------- | 131 // --------------------------------------------------------------------------- |
| 84 // Important: When adding any new members above, consider whether they need to | 132 // Important: When adding any new members above, consider whether they need to |
| 85 // be added to CopyFrom. | 133 // be added to CopyFrom. |
| 86 // --------------------------------------------------------------------------- | 134 // --------------------------------------------------------------------------- |
| 87 | 135 |
| 88 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); | 136 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); |
| 89 }; | 137 }; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 251 |
| 204 // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext | 252 // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext |
| 205 // instance that was lazilly created by GetURLRequestContext. | 253 // instance that was lazilly created by GetURLRequestContext. |
| 206 // Access only from the IO thread. | 254 // Access only from the IO thread. |
| 207 scoped_refptr<net::URLRequestContext> url_request_context_; | 255 scoped_refptr<net::URLRequestContext> url_request_context_; |
| 208 | 256 |
| 209 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); | 257 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); |
| 210 }; | 258 }; |
| 211 | 259 |
| 212 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 260 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |