Index: chrome/browser/net/pref_proxy_config_service.h |
diff --git a/chrome/browser/net/pref_proxy_config_service.h b/chrome/browser/net/pref_proxy_config_service.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c478cf780237655db97111fb7108aba92f9fd927 |
--- /dev/null |
+++ b/chrome/browser/net/pref_proxy_config_service.h |
@@ -0,0 +1,55 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
+#define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/observer_list.h" |
+#include "base/weak_ptr.h" |
+#include "net/proxy/proxy_config.h" |
+#include "net/proxy/proxy_config_service.h" |
+ |
+class PrefService; |
+class PrefProxyConfigTracker; |
+ |
+// A net::ProxyConfigService implementation that applies preference proxy |
+// settings as overrides to the proxy configuration determined by a baseline |
+// delegate ProxyConfigService. |
+class PrefProxyConfigService |
+ : public net::ProxyConfigService, |
+ public net::ProxyConfigService::Observer, |
+ public base::SupportsWeakPtr<PrefProxyConfigService> { |
+ public: |
+ // Takes ownership of the passed |base_service|. |
+ PrefProxyConfigService(PrefService* pref_service, |
+ net::ProxyConfigService* base_service); |
+ virtual ~PrefProxyConfigService(); |
+ |
+ // ProxyConfigService implementation: |
+ virtual void AddObserver(net::ProxyConfigService::Observer* observer); |
+ virtual void RemoveObserver(net::ProxyConfigService::Observer* observer); |
+ virtual bool GetLatestProxyConfig(net::ProxyConfig* config); |
+ virtual void OnLazyPoll(); |
+ |
+ private: |
+ class PrefProxyConfigTracker; |
+ |
+ // ProxyConfigService::Observer implementation: |
+ virtual void OnProxyConfigChanged(const net::ProxyConfig& config); |
+ |
+ // Called by the tracker when a new policy configuration is available. |
+ void PrefProxyConfigChanged(); |
+ |
+ scoped_ptr<net::ProxyConfigService> base_service_; |
+ ObserverList<net::ProxyConfigService::Observer> observers_; |
+ scoped_refptr<PrefProxyConfigTracker> pref_config_tracker_; |
+ |
+ // Counter for assigning proxy configuration identifiers. |
+ net::ProxyConfig::ID current_id_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigService); |
+}; |
+ |
+#endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |