| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_NETWORK_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 6 #define CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "net/base/network_delegate.h" | 11 #include "net/base/network_delegate.h" |
| 12 | 12 |
| 13 class CookieSettings; | 13 class CookieSettings; |
| 14 class ExtensionInfoMap; | 14 class ExtensionInfoMap; |
| 15 class PrefService; | 15 class PrefService; |
| 16 template<class T> class PrefMember; | 16 template<class T> class PrefMember; |
| 17 | 17 |
| 18 typedef PrefMember<bool> BooleanPrefMember; | 18 typedef PrefMember<bool> BooleanPrefMember; |
| 19 | 19 |
| 20 namespace chrome_browser_net { | 20 namespace chrome_browser_net { |
| 21 class CacheStats; | 21 class LoadTimeStats; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace extensions { | 24 namespace extensions { |
| 25 class EventRouterForwarder; | 25 class EventRouterForwarder; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace policy { | 28 namespace policy { |
| 29 class URLBlacklistManager; | 29 class URLBlacklistManager; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // ChromeNetworkDelegate is the central point from within the chrome code to | 32 // ChromeNetworkDelegate is the central point from within the chrome code to |
| 33 // add hooks into the network stack. | 33 // add hooks into the network stack. |
| 34 class ChromeNetworkDelegate : public net::NetworkDelegate { | 34 class ChromeNetworkDelegate : public net::NetworkDelegate { |
| 35 public: | 35 public: |
| 36 // If |profile| is NULL, events will be broadcasted to all profiles, | 36 // If |profile| is NULL, events will be broadcasted to all profiles, |
| 37 // otherwise they will only be sent to the specified profile. | 37 // otherwise they will only be sent to the specified profile. |
| 38 // |enable_referrers| should be initialized on the UI thread (see below) | 38 // |enable_referrers| should be initialized on the UI thread (see below) |
| 39 // beforehand. This object's owner is responsible for cleaning it up at | 39 // beforehand. This object's owner is responsible for cleaning it up at |
| 40 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, | 40 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, |
| 41 // otherwise, the settings are enforced on all observed network requests. | 41 // otherwise, the settings are enforced on all observed network requests. |
| 42 ChromeNetworkDelegate( | 42 ChromeNetworkDelegate( |
| 43 extensions::EventRouterForwarder* event_router, | 43 extensions::EventRouterForwarder* event_router, |
| 44 ExtensionInfoMap* extension_info_map, | 44 ExtensionInfoMap* extension_info_map, |
| 45 const policy::URLBlacklistManager* url_blacklist_manager, | 45 const policy::URLBlacklistManager* url_blacklist_manager, |
| 46 void* profile, | 46 void* profile, |
| 47 CookieSettings* cookie_settings, | 47 CookieSettings* cookie_settings, |
| 48 BooleanPrefMember* enable_referrers, | 48 BooleanPrefMember* enable_referrers, |
| 49 chrome_browser_net::CacheStats* cache_stats); | 49 chrome_browser_net::LoadTimeStats* load_time_stats); |
| 50 virtual ~ChromeNetworkDelegate(); | 50 virtual ~ChromeNetworkDelegate(); |
| 51 | 51 |
| 52 // Causes |OnCanThrottleRequest| to never return true. | 52 // Causes |OnCanThrottleRequest| to never return true. |
| 53 void NeverThrottleRequests(); | 53 void NeverThrottleRequests(); |
| 54 | 54 |
| 55 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. | 55 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. |
| 56 // This method should be called on the UI thread. | 56 // This method should be called on the UI thread. |
| 57 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, | 57 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, |
| 58 PrefService* pref_service); | 58 PrefService* pref_service); |
| 59 | 59 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 virtual bool OnCanSetCookie(const net::URLRequest& request, | 96 virtual bool OnCanSetCookie(const net::URLRequest& request, |
| 97 const std::string& cookie_line, | 97 const std::string& cookie_line, |
| 98 net::CookieOptions* options) OVERRIDE; | 98 net::CookieOptions* options) OVERRIDE; |
| 99 virtual bool OnCanAccessFile(const net::URLRequest& request, | 99 virtual bool OnCanAccessFile(const net::URLRequest& request, |
| 100 const FilePath& path) const OVERRIDE; | 100 const FilePath& path) const OVERRIDE; |
| 101 virtual bool OnCanThrottleRequest( | 101 virtual bool OnCanThrottleRequest( |
| 102 const net::URLRequest& request) const OVERRIDE; | 102 const net::URLRequest& request) const OVERRIDE; |
| 103 virtual int OnBeforeSocketStreamConnect( | 103 virtual int OnBeforeSocketStreamConnect( |
| 104 net::SocketStream* stream, | 104 net::SocketStream* stream, |
| 105 const net::CompletionCallback& callback) OVERRIDE; | 105 const net::CompletionCallback& callback) OVERRIDE; |
| 106 virtual void OnCacheWaitStateChange(const net::URLRequest& request, | 106 virtual void OnRequestWaitStateChange(const net::URLRequest& request, |
| 107 CacheWaitState state) OVERRIDE; | 107 RequestWaitState state) OVERRIDE; |
| 108 | 108 |
| 109 scoped_refptr<extensions::EventRouterForwarder> event_router_; | 109 scoped_refptr<extensions::EventRouterForwarder> event_router_; |
| 110 void* profile_; | 110 void* profile_; |
| 111 scoped_refptr<CookieSettings> cookie_settings_; | 111 scoped_refptr<CookieSettings> cookie_settings_; |
| 112 | 112 |
| 113 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 113 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 114 | 114 |
| 115 // Weak, owned by our owner. | 115 // Weak, owned by our owner. |
| 116 BooleanPrefMember* enable_referrers_; | 116 BooleanPrefMember* enable_referrers_; |
| 117 | 117 |
| 118 // True if OnCanThrottleRequest should always return false. | 118 // True if OnCanThrottleRequest should always return false. |
| 119 bool never_throttle_requests_; | 119 bool never_throttle_requests_; |
| 120 | 120 |
| 121 // Weak, owned by our owner. | 121 // Weak, owned by our owner. |
| 122 const policy::URLBlacklistManager* url_blacklist_manager_; | 122 const policy::URLBlacklistManager* url_blacklist_manager_; |
| 123 | 123 |
| 124 // When true, allow access to all file:// URLs. | 124 // When true, allow access to all file:// URLs. |
| 125 static bool g_allow_file_access_; | 125 static bool g_allow_file_access_; |
| 126 | 126 |
| 127 // Pointer to IOThread global, should outlive ChromeNetworkDelegate. | 127 // Pointer to IOThread global, should outlive ChromeNetworkDelegate. |
| 128 chrome_browser_net::CacheStats* cache_stats_; | 128 chrome_browser_net::LoadTimeStats* load_time_stats_; |
| 129 | 129 |
| 130 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 130 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 133 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
| OLD | NEW |