| 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_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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // chromeos::ProxyConfigServiceImpl. | 25 // chromeos::ProxyConfigServiceImpl. |
| 26 class ChromeProxyConfigService | 26 class ChromeProxyConfigService |
| 27 : public net::ProxyConfigService, | 27 : public net::ProxyConfigService, |
| 28 public net::ProxyConfigService::Observer { | 28 public net::ProxyConfigService::Observer { |
| 29 public: | 29 public: |
| 30 // Takes ownership of the passed |base_service|. | 30 // Takes ownership of the passed |base_service|. |
| 31 explicit ChromeProxyConfigService(net::ProxyConfigService* base_service); | 31 explicit ChromeProxyConfigService(net::ProxyConfigService* base_service); |
| 32 virtual ~ChromeProxyConfigService(); | 32 virtual ~ChromeProxyConfigService(); |
| 33 | 33 |
| 34 // ProxyConfigService implementation: | 34 // ProxyConfigService implementation: |
| 35 virtual void AddObserver(net::ProxyConfigService::Observer* observer); | 35 virtual void AddObserver( |
| 36 virtual void RemoveObserver(net::ProxyConfigService::Observer* observer); | 36 net::ProxyConfigService::Observer* observer) OVERRIDE; |
| 37 virtual ConfigAvailability GetLatestProxyConfig(net::ProxyConfig* config); | 37 virtual void RemoveObserver( |
| 38 virtual void OnLazyPoll(); | 38 net::ProxyConfigService::Observer* observer) OVERRIDE; |
| 39 virtual ConfigAvailability GetLatestProxyConfig( |
| 40 net::ProxyConfig* config) OVERRIDE; |
| 41 virtual void OnLazyPoll() OVERRIDE; |
| 39 | 42 |
| 40 // Method on IO thread that receives the preference proxy settings pushed from | 43 // Method on IO thread that receives the preference proxy settings pushed from |
| 41 // PrefProxyConfigTrackerImpl. | 44 // PrefProxyConfigTrackerImpl. |
| 42 void UpdateProxyConfig(ProxyPrefs::ConfigState config_state, | 45 void UpdateProxyConfig(ProxyPrefs::ConfigState config_state, |
| 43 const net::ProxyConfig& config); | 46 const net::ProxyConfig& config); |
| 44 | 47 |
| 45 private: | 48 private: |
| 46 // ProxyConfigService::Observer implementation: | 49 // ProxyConfigService::Observer implementation: |
| 47 virtual void OnProxyConfigChanged(const net::ProxyConfig& config, | 50 virtual void OnProxyConfigChanged(const net::ProxyConfig& config, |
| 48 ConfigAvailability availability); | 51 ConfigAvailability availability) OVERRIDE; |
| 49 | 52 |
| 50 // Makes sure that the observer registration with the base service is set up. | 53 // Makes sure that the observer registration with the base service is set up. |
| 51 void RegisterObserver(); | 54 void RegisterObserver(); |
| 52 | 55 |
| 53 scoped_ptr<net::ProxyConfigService> base_service_; | 56 scoped_ptr<net::ProxyConfigService> base_service_; |
| 54 ObserverList<net::ProxyConfigService::Observer, true> observers_; | 57 ObserverList<net::ProxyConfigService::Observer, true> observers_; |
| 55 | 58 |
| 56 // Tracks configuration state of |pref_config_|. |pref_config_| is valid only | 59 // Tracks configuration state of |pref_config_|. |pref_config_| is valid only |
| 57 // if |pref_config_state_| is not CONFIG_UNSET. | 60 // if |pref_config_state_| is not CONFIG_UNSET. |
| 58 ProxyPrefs::ConfigState pref_config_state_; | 61 ProxyPrefs::ConfigState pref_config_state_; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 ProxyPrefs::ConfigState GetProxyConfig(net::ProxyConfig* config); | 117 ProxyPrefs::ConfigState GetProxyConfig(net::ProxyConfig* config); |
| 115 | 118 |
| 116 // Called when there's a change in prefs proxy config. | 119 // Called when there's a change in prefs proxy config. |
| 117 // Subclasses can extend it for changes in other sources of proxy config. | 120 // Subclasses can extend it for changes in other sources of proxy config. |
| 118 virtual void OnProxyConfigChanged(ProxyPrefs::ConfigState config_state, | 121 virtual void OnProxyConfigChanged(ProxyPrefs::ConfigState config_state, |
| 119 const net::ProxyConfig& config); | 122 const net::ProxyConfig& config); |
| 120 | 123 |
| 121 // content::NotificationObserver implementation: | 124 // content::NotificationObserver implementation: |
| 122 virtual void Observe(int type, | 125 virtual void Observe(int type, |
| 123 const content::NotificationSource& source, | 126 const content::NotificationSource& source, |
| 124 const content::NotificationDetails& details); | 127 const content::NotificationDetails& details) OVERRIDE; |
| 125 | 128 |
| 126 // Converts a ProxyConfigDictionary to net::ProxyConfig representation. | 129 // Converts a ProxyConfigDictionary to net::ProxyConfig representation. |
| 127 // Returns true if the data from in the dictionary is valid, false otherwise. | 130 // Returns true if the data from in the dictionary is valid, false otherwise. |
| 128 bool PrefConfigToNetConfig(const ProxyConfigDictionary& proxy_dict, | 131 bool PrefConfigToNetConfig(const ProxyConfigDictionary& proxy_dict, |
| 129 net::ProxyConfig* config); | 132 net::ProxyConfig* config); |
| 130 | 133 |
| 131 const PrefService* prefs() const { return pref_service_; } | 134 const PrefService* prefs() const { return pref_service_; } |
| 132 bool update_pending() const { return update_pending_; } | 135 bool update_pending() const { return update_pending_; } |
| 133 | 136 |
| 134 private: | 137 private: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 146 | 149 |
| 147 PrefService* pref_service_; | 150 PrefService* pref_service_; |
| 148 ChromeProxyConfigService* chrome_proxy_config_service_; // Weak ptr. | 151 ChromeProxyConfigService* chrome_proxy_config_service_; // Weak ptr. |
| 149 bool update_pending_; // True if config has not been pushed to network stack. | 152 bool update_pending_; // True if config has not been pushed to network stack. |
| 150 scoped_ptr<PrefSetObserver> proxy_prefs_observer_; | 153 scoped_ptr<PrefSetObserver> proxy_prefs_observer_; |
| 151 | 154 |
| 152 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); | 155 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); |
| 153 }; | 156 }; |
| 154 | 157 |
| 155 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 158 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| OLD | NEW |