| 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" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "base/prefs/pref_change_registrar.h" | 12 #include "base/prefs/pref_change_registrar.h" |
| 13 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 13 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
| 14 #include "net/proxy/proxy_config.h" | 14 #include "net/proxy/proxy_config.h" |
| 15 #include "net/proxy/proxy_config_service.h" | 15 #include "net/proxy/proxy_config_service.h" |
| 16 | 16 |
| 17 class PrefService; | 17 class PrefService; |
| 18 class PrefRegistrySimple; | 18 class PrefRegistrySimple; |
| 19 |
| 20 namespace user_prefs { |
| 19 class PrefRegistrySyncable; | 21 class PrefRegistrySyncable; |
| 22 } |
| 20 | 23 |
| 21 // A net::ProxyConfigService implementation that applies preference proxy | 24 // A net::ProxyConfigService implementation that applies preference proxy |
| 22 // settings (pushed from PrefProxyConfigTrackerImpl) as overrides to the proxy | 25 // settings (pushed from PrefProxyConfigTrackerImpl) as overrides to the proxy |
| 23 // configuration determined by a baseline delegate ProxyConfigService on | 26 // configuration determined by a baseline delegate ProxyConfigService on |
| 24 // non-ChromeOS platforms. ChromeOS has its own implementation of overrides in | 27 // non-ChromeOS platforms. ChromeOS has its own implementation of overrides in |
| 25 // chromeos::ProxyConfigServiceImpl. | 28 // chromeos::ProxyConfigServiceImpl. |
| 26 class ChromeProxyConfigService | 29 class ChromeProxyConfigService |
| 27 : public net::ProxyConfigService, | 30 : public net::ProxyConfigService, |
| 28 public net::ProxyConfigService::Observer { | 31 public net::ProxyConfigService::Observer { |
| 29 public: | 32 public: |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 net::ProxyConfig* effective_config); | 116 net::ProxyConfig* effective_config); |
| 114 | 117 |
| 115 // Converts a ProxyConfigDictionary to net::ProxyConfig representation. | 118 // Converts a ProxyConfigDictionary to net::ProxyConfig representation. |
| 116 // 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. |
| 117 static bool PrefConfigToNetConfig(const ProxyConfigDictionary& proxy_dict, | 120 static bool PrefConfigToNetConfig(const ProxyConfigDictionary& proxy_dict, |
| 118 net::ProxyConfig* config); | 121 net::ProxyConfig* config); |
| 119 | 122 |
| 120 // Registers the proxy preferences. These are actually registered | 123 // Registers the proxy preferences. These are actually registered |
| 121 // the same way in local state and in user prefs. | 124 // the same way in local state and in user prefs. |
| 122 static void RegisterPrefs(PrefRegistrySimple* registry); | 125 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 123 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | 126 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
| 124 | 127 |
| 125 protected: | 128 protected: |
| 126 // Get the proxy configuration currently defined by preferences. | 129 // Get the proxy configuration currently defined by preferences. |
| 127 // Status is indicated in the return value. | 130 // Status is indicated in the return value. |
| 128 // Writes the configuration to |config| unless the return value is | 131 // Writes the configuration to |config| unless the return value is |
| 129 // CONFIG_UNSET, in which case |config| and |config_source| are not touched. | 132 // CONFIG_UNSET, in which case |config| and |config_source| are not touched. |
| 130 ProxyPrefs::ConfigState GetProxyConfig(net::ProxyConfig* config); | 133 ProxyPrefs::ConfigState GetProxyConfig(net::ProxyConfig* config); |
| 131 | 134 |
| 132 // Called when there's a change in prefs proxy config. | 135 // Called when there's a change in prefs proxy config. |
| 133 // Subclasses can extend it for changes in other sources of proxy config. | 136 // Subclasses can extend it for changes in other sources of proxy config. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 154 | 157 |
| 155 PrefService* pref_service_; | 158 PrefService* pref_service_; |
| 156 ChromeProxyConfigService* chrome_proxy_config_service_; // Weak ptr. | 159 ChromeProxyConfigService* chrome_proxy_config_service_; // Weak ptr. |
| 157 bool update_pending_; // True if config has not been pushed to network stack. | 160 bool update_pending_; // True if config has not been pushed to network stack. |
| 158 PrefChangeRegistrar proxy_prefs_; | 161 PrefChangeRegistrar proxy_prefs_; |
| 159 | 162 |
| 160 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); | 163 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); |
| 161 }; | 164 }; |
| 162 | 165 |
| 163 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 166 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| OLD | NEW |