OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
6 #define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ | 6 #define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 }; | 85 }; |
86 | 86 |
87 // A net::ProxyConfigService implementation that applies preference proxy | 87 // A net::ProxyConfigService implementation that applies preference proxy |
88 // settings as overrides to the proxy configuration determined by a baseline | 88 // settings as overrides to the proxy configuration determined by a baseline |
89 // delegate ProxyConfigService. | 89 // delegate ProxyConfigService. |
90 class PrefProxyConfigService | 90 class PrefProxyConfigService |
91 : public net::ProxyConfigService, | 91 : public net::ProxyConfigService, |
92 public net::ProxyConfigService::Observer, | 92 public net::ProxyConfigService::Observer, |
93 public PrefProxyConfigTracker::Observer { | 93 public PrefProxyConfigTracker::Observer { |
94 public: | 94 public: |
95 // Possible types of specifying proxy settings. The numeric values must | |
96 // correspond to the policy::kPolicy*Proxy*Mode constants. | |
97 enum ProxyServerMode { | |
98 DISABLED, | |
99 AUTO_DETECT, | |
100 MANUAL, | |
101 SYSTEM | |
102 }; | |
103 | |
95 // Takes ownership of the passed |base_service|. | 104 // Takes ownership of the passed |base_service|. |
96 PrefProxyConfigService(PrefProxyConfigTracker* tracker, | 105 PrefProxyConfigService(PrefProxyConfigTracker* tracker, |
97 net::ProxyConfigService* base_service); | 106 net::ProxyConfigService* base_service); |
98 virtual ~PrefProxyConfigService(); | 107 virtual ~PrefProxyConfigService(); |
99 | 108 |
100 // ProxyConfigService implementation: | 109 // ProxyConfigService implementation: |
101 virtual void AddObserver(net::ProxyConfigService::Observer* observer); | 110 virtual void AddObserver(net::ProxyConfigService::Observer* observer); |
102 virtual void RemoveObserver(net::ProxyConfigService::Observer* observer); | 111 virtual void RemoveObserver(net::ProxyConfigService::Observer* observer); |
103 virtual bool GetLatestProxyConfig(net::ProxyConfig* config); | 112 virtual bool GetLatestProxyConfig(net::ProxyConfig* config); |
104 virtual void OnLazyPoll(); | 113 virtual void OnLazyPoll(); |
105 | 114 |
106 static void RegisterUserPrefs(PrefService* user_prefs); | 115 static void RegisterUserPrefs(PrefService* user_prefs); |
107 | 116 |
117 static bool IntToMode(int in_value, ProxyServerMode* out_value); | |
danno
2010/12/14 12:48:17
This could be ModeStringToEnum.
gfeher
2010/12/16 10:42:04
I still need this to convert from policy and prefe
| |
118 | |
108 private: | 119 private: |
109 // ProxyConfigService::Observer implementation: | 120 // ProxyConfigService::Observer implementation: |
110 virtual void OnProxyConfigChanged(const net::ProxyConfig& config); | 121 virtual void OnProxyConfigChanged(const net::ProxyConfig& config); |
111 | 122 |
112 // PrefProxyConfigTracker::Observer implementation: | 123 // PrefProxyConfigTracker::Observer implementation: |
113 virtual void OnPrefProxyConfigChanged(); | 124 virtual void OnPrefProxyConfigChanged(); |
114 | 125 |
115 // Makes sure that the observer registrations with the base service and the | 126 // Makes sure that the observer registrations with the base service and the |
116 // tracker object are set up. | 127 // tracker object are set up. |
117 void RegisterObservers(); | 128 void RegisterObservers(); |
118 | 129 |
119 scoped_ptr<net::ProxyConfigService> base_service_; | 130 scoped_ptr<net::ProxyConfigService> base_service_; |
120 ObserverList<net::ProxyConfigService::Observer, true> observers_; | 131 ObserverList<net::ProxyConfigService::Observer, true> observers_; |
121 scoped_refptr<PrefProxyConfigTracker> pref_config_tracker_; | 132 scoped_refptr<PrefProxyConfigTracker> pref_config_tracker_; |
122 | 133 |
123 // Indicates whether the base service and tracker registrations are done. | 134 // Indicates whether the base service and tracker registrations are done. |
124 bool registered_observers_; | 135 bool registered_observers_; |
125 | 136 |
126 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigService); | 137 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigService); |
127 }; | 138 }; |
128 | 139 |
129 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ | 140 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
OLD | NEW |