| 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_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| 6 #define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 6 #define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Converts a ProxyConfigDictionary to net::ProxyConfig representation. | 118 // Converts a ProxyConfigDictionary to net::ProxyConfig representation. |
| 119 // Returns true if the data from in the dictionary is valid, false otherwise. | 119 // Returns true if the data from in the dictionary is valid, false otherwise. |
| 120 static bool PrefConfigToNetConfig(const ProxyConfigDictionary& proxy_dict, | 120 static bool PrefConfigToNetConfig(const ProxyConfigDictionary& proxy_dict, |
| 121 net::ProxyConfig* config); | 121 net::ProxyConfig* config); |
| 122 | 122 |
| 123 // Registers the proxy preferences. These are actually registered | 123 // Registers the proxy preferences. These are actually registered |
| 124 // the same way in local state and in user prefs. | 124 // the same way in local state and in user prefs. |
| 125 static void RegisterPrefs(PrefRegistrySimple* registry); | 125 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 126 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); | 126 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
| 127 | 127 |
| 128 // Creates a proxy configuration from proxy-related preferences of |
| 129 // |pref_service|. Configuration is stored in |config|, return value indicates |
| 130 // whether the configuration is valid. |
| 131 static ProxyPrefs::ConfigState ReadPrefConfig(const PrefService* pref_service, |
| 132 net::ProxyConfig* config); |
| 133 |
| 128 protected: | 134 protected: |
| 129 // Get the proxy configuration currently defined by preferences. | 135 // Get the proxy configuration currently defined by preferences. |
| 130 // Status is indicated in the return value. | 136 // Status is indicated in the return value. |
| 131 // Writes the configuration to |config| unless the return value is | 137 // Writes the configuration to |config| unless the return value is |
| 132 // CONFIG_UNSET, in which case |config| and |config_source| are not touched. | 138 // CONFIG_UNSET, in which case |config| and |config_source| are not touched. |
| 133 ProxyPrefs::ConfigState GetProxyConfig(net::ProxyConfig* config); | 139 ProxyPrefs::ConfigState GetProxyConfig(net::ProxyConfig* config); |
| 134 | 140 |
| 135 // Called when there's a change in prefs proxy config. | 141 // Called when there's a change in prefs proxy config. |
| 136 // Subclasses can extend it for changes in other sources of proxy config. | 142 // Subclasses can extend it for changes in other sources of proxy config. |
| 137 virtual void OnProxyConfigChanged(ProxyPrefs::ConfigState config_state, | 143 virtual void OnProxyConfigChanged(ProxyPrefs::ConfigState config_state, |
| 138 const net::ProxyConfig& config); | 144 const net::ProxyConfig& config); |
| 139 | 145 |
| 140 void OnProxyPrefChanged(); | 146 void OnProxyPrefChanged(); |
| 141 | 147 |
| 142 const PrefService* prefs() const { return pref_service_; } | 148 const PrefService* prefs() const { return pref_service_; } |
| 143 bool update_pending() const { return update_pending_; } | 149 bool update_pending() const { return update_pending_; } |
| 144 | 150 |
| 145 private: | 151 private: |
| 146 // Creates a proxy configuration from proxy-related preferences. Configuration | |
| 147 // is stored in |config|, return value indicates whether the configuration is | |
| 148 // valid. | |
| 149 ProxyPrefs::ConfigState ReadPrefConfig(net::ProxyConfig* config); | |
| 150 | |
| 151 // Tracks configuration state. |pref_config_| is valid only if |config_state_| | 152 // Tracks configuration state. |pref_config_| is valid only if |config_state_| |
| 152 // is not CONFIG_UNSET. | 153 // is not CONFIG_UNSET. |
| 153 ProxyPrefs::ConfigState config_state_; | 154 ProxyPrefs::ConfigState config_state_; |
| 154 | 155 |
| 155 // Configuration as defined by prefs. | 156 // Configuration as defined by prefs. |
| 156 net::ProxyConfig pref_config_; | 157 net::ProxyConfig pref_config_; |
| 157 | 158 |
| 158 PrefService* pref_service_; | 159 PrefService* pref_service_; |
| 159 ChromeProxyConfigService* chrome_proxy_config_service_; // Weak ptr. | 160 ChromeProxyConfigService* chrome_proxy_config_service_; // Weak ptr. |
| 160 bool update_pending_; // True if config has not been pushed to network stack. | 161 bool update_pending_; // True if config has not been pushed to network stack. |
| 161 PrefChangeRegistrar proxy_prefs_; | 162 PrefChangeRegistrar proxy_prefs_; |
| 162 | 163 |
| 163 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); | 164 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); |
| 164 }; | 165 }; |
| 165 | 166 |
| 166 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 167 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| OLD | NEW |