| 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 ManagedModeURLFilter; | 15 class ManagedModeURLFilter; |
| 16 class PrefService; | 16 class PrefService; |
| 17 template<class T> class PrefMember; | 17 template<class T> class PrefMember; |
| 18 | 18 |
| 19 typedef PrefMember<bool> BooleanPrefMember; | 19 typedef PrefMember<bool> BooleanPrefMember; |
| 20 | 20 |
| 21 namespace chrome_browser_net { | 21 namespace chrome_browser_net { |
| 22 class CacheStats; | 22 class LoadTimeStats; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace extensions { | 25 namespace extensions { |
| 26 class EventRouterForwarder; | 26 class EventRouterForwarder; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace policy { | 29 namespace policy { |
| 30 class URLBlacklistManager; | 30 class URLBlacklistManager; |
| 31 } | 31 } |
| 32 | 32 |
| 33 // ChromeNetworkDelegate is the central point from within the chrome code to | 33 // ChromeNetworkDelegate is the central point from within the chrome code to |
| 34 // add hooks into the network stack. | 34 // add hooks into the network stack. |
| 35 class ChromeNetworkDelegate : public net::NetworkDelegate { | 35 class ChromeNetworkDelegate : public net::NetworkDelegate { |
| 36 public: | 36 public: |
| 37 // If |profile| is NULL, events will be broadcasted to all profiles, | 37 // If |profile| is NULL, events will be broadcasted to all profiles, |
| 38 // otherwise they will only be sent to the specified profile. | 38 // otherwise they will only be sent to the specified profile. |
| 39 // |enable_referrers| should be initialized on the UI thread (see below) | 39 // |enable_referrers| should be initialized on the UI thread (see below) |
| 40 // beforehand. This object's owner is responsible for cleaning it up at | 40 // beforehand. This object's owner is responsible for cleaning it up at |
| 41 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, | 41 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, |
| 42 // otherwise, the settings are enforced on all observed network requests. | 42 // otherwise, the settings are enforced on all observed network requests. |
| 43 ChromeNetworkDelegate( | 43 ChromeNetworkDelegate( |
| 44 extensions::EventRouterForwarder* event_router, | 44 extensions::EventRouterForwarder* event_router, |
| 45 ExtensionInfoMap* extension_info_map, | 45 ExtensionInfoMap* extension_info_map, |
| 46 const policy::URLBlacklistManager* url_blacklist_manager, | 46 const policy::URLBlacklistManager* url_blacklist_manager, |
| 47 const ManagedModeURLFilter* managed_mode_url_filter, | 47 const ManagedModeURLFilter* managed_mode_url_filter, |
| 48 void* profile, | 48 void* profile, |
| 49 CookieSettings* cookie_settings, | 49 CookieSettings* cookie_settings, |
| 50 BooleanPrefMember* enable_referrers, | 50 BooleanPrefMember* enable_referrers, |
| 51 chrome_browser_net::CacheStats* cache_stats); | 51 chrome_browser_net::LoadTimeStats* load_time_stats); |
| 52 virtual ~ChromeNetworkDelegate(); | 52 virtual ~ChromeNetworkDelegate(); |
| 53 | 53 |
| 54 // Causes |OnCanThrottleRequest| to always return false, for all | 54 // Causes |OnCanThrottleRequest| to always return false, for all |
| 55 // instances of this object. | 55 // instances of this object. |
| 56 static void NeverThrottleRequests(); | 56 static void NeverThrottleRequests(); |
| 57 | 57 |
| 58 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. | 58 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. |
| 59 // This method should be called on the UI thread. | 59 // This method should be called on the UI thread. |
| 60 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, | 60 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, |
| 61 PrefService* pref_service); | 61 PrefService* pref_service); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 virtual bool OnCanSetCookie(const net::URLRequest& request, | 101 virtual bool OnCanSetCookie(const net::URLRequest& request, |
| 102 const std::string& cookie_line, | 102 const std::string& cookie_line, |
| 103 net::CookieOptions* options) OVERRIDE; | 103 net::CookieOptions* options) OVERRIDE; |
| 104 virtual bool OnCanAccessFile(const net::URLRequest& request, | 104 virtual bool OnCanAccessFile(const net::URLRequest& request, |
| 105 const FilePath& path) const OVERRIDE; | 105 const FilePath& path) const OVERRIDE; |
| 106 virtual bool OnCanThrottleRequest( | 106 virtual bool OnCanThrottleRequest( |
| 107 const net::URLRequest& request) const OVERRIDE; | 107 const net::URLRequest& request) const OVERRIDE; |
| 108 virtual int OnBeforeSocketStreamConnect( | 108 virtual int OnBeforeSocketStreamConnect( |
| 109 net::SocketStream* stream, | 109 net::SocketStream* stream, |
| 110 const net::CompletionCallback& callback) OVERRIDE; | 110 const net::CompletionCallback& callback) OVERRIDE; |
| 111 virtual void OnCacheWaitStateChange(const net::URLRequest& request, | 111 virtual void OnRequestWaitStateChange(const net::URLRequest& request, |
| 112 CacheWaitState state) OVERRIDE; | 112 RequestWaitState state) OVERRIDE; |
| 113 | 113 |
| 114 scoped_refptr<extensions::EventRouterForwarder> event_router_; | 114 scoped_refptr<extensions::EventRouterForwarder> event_router_; |
| 115 void* profile_; | 115 void* profile_; |
| 116 scoped_refptr<CookieSettings> cookie_settings_; | 116 scoped_refptr<CookieSettings> cookie_settings_; |
| 117 | 117 |
| 118 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 118 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 119 | 119 |
| 120 // Weak, owned by our owner. | 120 // Weak, owned by our owner. |
| 121 BooleanPrefMember* enable_referrers_; | 121 BooleanPrefMember* enable_referrers_; |
| 122 | 122 |
| 123 // Weak, owned by our owner. | 123 // Weak, owned by our owner. |
| 124 const policy::URLBlacklistManager* url_blacklist_manager_; | 124 const policy::URLBlacklistManager* url_blacklist_manager_; |
| 125 | 125 |
| 126 // Weak pointer. The owner of this object needs to make sure that the | 126 // Weak pointer. The owner of this object needs to make sure that the |
| 127 // |managed_mode_url_filter_| outlives it. | 127 // |managed_mode_url_filter_| outlives it. |
| 128 const ManagedModeURLFilter* managed_mode_url_filter_; | 128 const ManagedModeURLFilter* managed_mode_url_filter_; |
| 129 | 129 |
| 130 // When true, allow access to all file:// URLs. | 130 // When true, allow access to all file:// URLs. |
| 131 static bool g_allow_file_access_; | 131 static bool g_allow_file_access_; |
| 132 | 132 |
| 133 // True if OnCanThrottleRequest should always return false. | 133 // True if OnCanThrottleRequest should always return false. |
| 134 // | 134 // |
| 135 // Note: This needs to be static as the instance of | 135 // Note: This needs to be static as the instance of |
| 136 // ChromeNetworkDelegate used may change over time, and we need to | 136 // ChromeNetworkDelegate used may change over time, and we need to |
| 137 // set this variable once at start-up time. It is effectively | 137 // set this variable once at start-up time. It is effectively |
| 138 // static anyway since it is based on a command-line flag. | 138 // static anyway since it is based on a command-line flag. |
| 139 static bool g_never_throttle_requests_; | 139 static bool g_never_throttle_requests_; |
| 140 | 140 |
| 141 // Pointer to IOThread global, should outlive ChromeNetworkDelegate. | 141 // Pointer to IOThread global, should outlive ChromeNetworkDelegate. |
| 142 chrome_browser_net::CacheStats* cache_stats_; | 142 chrome_browser_net::LoadTimeStats* load_time_stats_; |
| 143 | 143 |
| 144 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 144 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 147 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
| OLD | NEW |