OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
| 6 #define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/observer_list.h" |
| 10 #include "base/weak_ptr.h" |
| 11 #include "net/proxy/proxy_config.h" |
| 12 #include "net/proxy/proxy_config_service.h" |
| 13 |
| 14 class PrefService; |
| 15 class PrefProxyConfigTracker; |
| 16 |
| 17 // A net::ProxyConfigService implementation that applies preference proxy |
| 18 // settings as overrides to the proxy configuration determined by a baseline |
| 19 // delegate ProxyConfigService. |
| 20 class PrefProxyConfigService |
| 21 : public net::ProxyConfigService, |
| 22 public net::ProxyConfigService::Observer, |
| 23 public base::SupportsWeakPtr<PrefProxyConfigService> { |
| 24 public: |
| 25 // Takes ownership of the passed |base_service|. |
| 26 PrefProxyConfigService(PrefService* pref_service, |
| 27 net::ProxyConfigService* base_service); |
| 28 virtual ~PrefProxyConfigService(); |
| 29 |
| 30 // ProxyConfigService implementation: |
| 31 virtual void AddObserver(net::ProxyConfigService::Observer* observer); |
| 32 virtual void RemoveObserver(net::ProxyConfigService::Observer* observer); |
| 33 virtual bool GetLatestProxyConfig(net::ProxyConfig* config); |
| 34 virtual void OnLazyPoll(); |
| 35 |
| 36 private: |
| 37 class PrefProxyConfigTracker; |
| 38 |
| 39 // ProxyConfigService::Observer implementation: |
| 40 virtual void OnProxyConfigChanged(const net::ProxyConfig& config); |
| 41 |
| 42 // Called by the tracker when a new policy configuration is available. |
| 43 void PrefProxyConfigChanged(); |
| 44 |
| 45 scoped_ptr<net::ProxyConfigService> base_service_; |
| 46 ObserverList<net::ProxyConfigService::Observer> observers_; |
| 47 scoped_refptr<PrefProxyConfigTracker> pref_config_tracker_; |
| 48 |
| 49 // Counter for assigning proxy configuration identifiers. |
| 50 net::ProxyConfig::ID current_id_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigService); |
| 53 }; |
| 54 |
| 55 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
OLD | NEW |