Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: chrome/browser/chromeos/proxy_config_service_impl.h

Issue 8102019: redesign and reimplement proxy config service and tracker, revise proxy ui on cros (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_ 6 #define CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list.h"
16 #include "base/values.h" 13 #include "base/values.h"
17 #include "chrome/browser/chromeos/cros/network_library.h" 14 #include "chrome/browser/chromeos/cros/network_library.h"
18 #include "chrome/browser/chromeos/login/signed_settings.h" 15 #include "chrome/browser/chromeos/login/signed_settings.h"
19 #include "net/proxy/proxy_config.h" 16 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
20 #include "net/proxy/proxy_config_service.h" 17 #include "chrome/browser/prefs/pref_member.h"
21 #include "net/proxy/proxy_server.h" 18 #include "content/public/browser/notification_registrar.h"
22 19
23 namespace chromeos { 20 namespace chromeos {
24 21
25 // Implementation of proxy config service for chromeos that: 22 // Implementation of proxy config service for chromeos that:
26 // - is RefCountedThreadSafe 23 // - extends PrefProxyConfigTrackerImpl (and so lives and runs entirely on UI
27 // - is wrapped by chromeos::ProxyConfigService which implements 24 // thread) to handle proxy from prefs (via PrefProxyConfigTrackerImpl) and
28 // net::ProxyConfigService interface by fowarding the methods to this class 25 // system i.e. network (via flimflam notifications)
26 // - exists one per profile and one per local state
29 // - retrieves initial system proxy configuration from cros settings persisted 27 // - retrieves initial system proxy configuration from cros settings persisted
30 // on chromeos device from chromeos revisions before migration to flimflam, 28 // on chromeos device from chromeos revisions before migration to flimflam,
31 // - persists proxy setting per network in flimflim 29 // - persists proxy setting per network in flimflim
32 // - provides network stack with latest proxy configuration for currently 30 // - provides network stack with latest effective proxy configuration for
33 // active network for use on IO thread 31 // currently active network via PrefProxyConfigTrackerImpl's mechanism of
32 // pushing config to ChromeProxyConfigService
34 // - provides UI with methods to retrieve and modify proxy configuration for 33 // - provides UI with methods to retrieve and modify proxy configuration for
35 // any network (either currently active or non-active) on UI thread 34 // any remembered network (either currently active or non-active) of current
35 // user profile
36 class ProxyConfigServiceImpl 36 class ProxyConfigServiceImpl
37 : public base::RefCountedThreadSafe<ProxyConfigServiceImpl>, 37 : public PrefProxyConfigTrackerImpl,
38 public SignedSettings::Delegate<std::string>, 38 public SignedSettings::Delegate<std::string>,
39 public NetworkLibrary::NetworkManagerObserver, 39 public NetworkLibrary::NetworkManagerObserver,
40 public NetworkLibrary::NetworkObserver { 40 public NetworkLibrary::NetworkObserver {
41 public: 41 public:
42 // ProxyConfigServiceImpl is created on the UI thread in 42 // ProxyConfigServiceImpl is created in ProxyServiceFactory::
43 // chrome/browser/net/proxy_service_factory.cc::CreateProxyConfigService 43 // CreatePrefProxyConfigTrackerImpl via Profile::GetProxyConfigTracker() for
44 // via BrowserProcess::chromeos_proxy_config_service_impl, and stored in 44 // profile or IOThread constructor for local state and is owned by the
45 // g_browser_process as a scoped_refptr (because it's RefCountedThreadSafe). 45 // respective classes.
46 // 46 //
47 // Past that point, it can be accessed from the IO or UI threads. 47 // From the UI, it is accessed via Profile::GetProxyConfigTracker to allow
48 // user to read or modify the proxy configuration via UIGetProxyConfig or
49 // UISetProxyConfigTo* respectively.
50 // The new modified proxy config, together with proxy from prefs if available,
51 // are used to determine the effective proxy config, which is then pushed
52 // through PrefProxyConfigTrackerImpl to ChromeProxyConfigService to the
53 // network stack.
48 // 54 //
49 // From the IO thread, it is accessed periodically through the wrapper class
50 // chromeos::ProxyConfigService via net::ProxyConfigService interface
51 // (GetLatestProxyConfig, AddObserver, RemoveObserver).
52 //
53 // From the UI thread, it is accessed via
54 // BrowserProcess::chromeos_proxy_config_service_impl to allow user to read
55 // or modify the proxy configuration via UIGetProxyConfig or
56 // UISetProxyConfigTo* respectively.
57 // The new modified proxy config is posted to the IO thread through
58 // SetNewProxyConfig(). We then notify observers on the IO thread of the
59 // configuration change.
60
61 // In contrary to other platforms which simply use the systems' UI to allow 55 // In contrary to other platforms which simply use the systems' UI to allow
62 // users to configure proxies, we have to implement our own UI on the chromeos 56 // users to configure proxies, we have to implement our own UI on the chromeos
63 // device. This requires extra and specific UI requirements that 57 // device. This requires extra and specific UI requirements that
64 // net::ProxyConfig does not suffice. So we create an augmented analog to 58 // net::ProxyConfig does not suffice. So we create an augmented analog to
65 // net:ProxyConfig here to include and handle these UI requirements, e.g. 59 // net:ProxyConfig here to include and handle these UI requirements, e.g.
66 // - where configuration was picked up from - policy or owner 60 // - state of configuration e.g. where it was picked up from - policy,
61 // extension, etc (refer to ProxyPrefs::ConfigState)
67 // - the read/write access of a proxy setting 62 // - the read/write access of a proxy setting
68 // - may add more stuff later. 63 // - may add more stuff later.
69 // This is then converted to the common net::ProxyConfig before being returned 64 // This is then converted to the common net::ProxyConfig before being pushed
70 // to ProxyService::GetLatestProxyConfig on the IO thread to be used on the 65 // to PrefProxyConfigTrackerImpl::OnProxyConfigChanged and then to the network
71 // network stack. 66 // stack.
72 struct ProxyConfig { 67 struct ProxyConfig {
73 // Specifies if proxy config is direct, auto-detect, using pac script, 68 // Specifies if proxy config is direct, auto-detect, using pac script,
74 // single-proxy, or proxy-per-scheme. 69 // single-proxy, or proxy-per-scheme.
75 enum Mode { 70 enum Mode {
76 MODE_DIRECT, 71 MODE_DIRECT,
77 MODE_AUTO_DETECT, 72 MODE_AUTO_DETECT,
78 MODE_PAC_SCRIPT, 73 MODE_PAC_SCRIPT,
79 MODE_SINGLE_PROXY, 74 MODE_SINGLE_PROXY,
80 MODE_PROXY_PER_SCHEME, 75 MODE_PROXY_PER_SCHEME,
81 }; 76 };
82 77
83 // Specifies where proxy configuration was picked up from.
84 enum Source {
85 SOURCE_NONE, // No default configuration.
86 SOURCE_POLICY, // Configuration is from policy.
87 SOURCE_OWNER, // Configuration is from owner.
88 };
89
90 struct Setting {
91 Setting() : source(SOURCE_NONE) {}
92 bool CanBeWrittenByUser(bool user_is_owner);
93
94 Source source;
95 };
96
97 // Proxy setting for mode = direct or auto-detect or using pac script. 78 // Proxy setting for mode = direct or auto-detect or using pac script.
98 struct AutomaticProxy : public Setting { 79 struct AutomaticProxy {
99 GURL pac_url; // Set if proxy is using pac script. 80 GURL pac_url; // Set if proxy is using pac script.
100 }; 81 };
101 82
102 // Proxy setting for mode = single-proxy or proxy-per-scheme. 83 // Proxy setting for mode = single-proxy or proxy-per-scheme.
103 struct ManualProxy : public Setting { 84 struct ManualProxy {
104 net::ProxyServer server; 85 net::ProxyServer server;
105 }; 86 };
106 87
107 ProxyConfig(); 88 ProxyConfig();
108 ~ProxyConfig(); 89 ~ProxyConfig();
109 90
110 // Converts |this| to net::ProxyConfig. 91 // Converts net::ProxyConfig to |this|.
111 void ToNetProxyConfig(net::ProxyConfig* net_config); 92 bool FromNetProxyConfig(const net::ProxyConfig& net_config);
112 93
113 // Returns true if proxy config can be written by user. 94 // Converts |this| to Dictionary of ProxyConfigDictionary format (which
114 // If mode is MODE_PROXY_PER_SCHEME, |scheme| is one of "http", "https", 95 // is the same format used by prefs).
115 // "ftp" or "socks"; otherwise, it should be empty or will be ignored. 96 DictionaryValue* ToPrefProxyConfig();
116 bool CanBeWrittenByUser(bool user_is_owner, const std::string& scheme);
117 97
118 // Map |scheme| (one of "http", "https", "ftp" or "socks") to the correct 98 // Map |scheme| (one of "http", "https", "ftp" or "socks") to the correct
119 // ManualProxy. Returns NULL if scheme is invalid. 99 // ManualProxy. Returns NULL if scheme is invalid.
120 ManualProxy* MapSchemeToProxy(const std::string& scheme); 100 ManualProxy* MapSchemeToProxy(const std::string& scheme);
121 101
122 // We've migrated device settings to flimflam, so we only need to 102 // We've migrated device settings to flimflam, so we only need to
123 // deserialize previously persisted device settings. 103 // deserialize previously persisted device settings.
124 // Deserializes from signed setting on device as std::string into a 104 // Deserializes from signed setting on device as std::string into a
125 // protobuf and then into the config. 105 // protobuf and then into the config.
126 bool DeserializeForDevice(const std::string& input); 106 bool DeserializeForDevice(const std::string& input);
127 107
128 // Serializes config into a ProxyConfigDictionary and then std::string 108 // Serializes config into a ProxyConfigDictionary and then std::string
129 // persisted as string property in flimflam for a network. 109 // persisted as string property in flimflam for a network.
130 bool SerializeForNetwork(std::string* output); 110 bool SerializeForNetwork(std::string* output);
131 111
132 // Deserializes from string property in flimflam for a network into a 112 Mode mode;
133 // ProxyConfigDictionary and then into the config.
134 // Opposite of SerializeForNetwork.
135 bool DeserializeForNetwork(const std::string& input);
136 113
137 // Returns true if the given config is equivalent to this config. 114 ProxyPrefs::ConfigState state;
138 bool Equals(const ProxyConfig& other) const;
139 115
140 // Creates a textual dump of the configuration. 116 // True if user can modify proxy settings via UI.
141 std::string ToString() const; 117 // If proxy is managed by policy or extension or other_precde or is for
142 118 // shared network but kUseSharedProxies is turned off, it can't be modified
143 Mode mode; 119 // by user.
120 bool user_modifiable;
144 121
145 // Set if mode is MODE_DIRECT or MODE_AUTO_DETECT or MODE_PAC_SCRIPT. 122 // Set if mode is MODE_DIRECT or MODE_AUTO_DETECT or MODE_PAC_SCRIPT.
146 AutomaticProxy automatic_proxy; 123 AutomaticProxy automatic_proxy;
147 // Set if mode is MODE_SINGLE_PROXY. 124 // Set if mode is MODE_SINGLE_PROXY.
148 ManualProxy single_proxy; 125 ManualProxy single_proxy;
149 // Set if mode is MODE_PROXY_PER_SCHEME and has http proxy. 126 // Set if mode is MODE_PROXY_PER_SCHEME and has http proxy.
150 ManualProxy http_proxy; 127 ManualProxy http_proxy;
151 // Set if mode is MODE_PROXY_PER_SCHEME and has https proxy. 128 // Set if mode is MODE_PROXY_PER_SCHEME and has https proxy.
152 ManualProxy https_proxy; 129 ManualProxy https_proxy;
153 // Set if mode is MODE_PROXY_PER_SCHEME and has ftp proxy. 130 // Set if mode is MODE_PROXY_PER_SCHEME and has ftp proxy.
154 ManualProxy ftp_proxy; 131 ManualProxy ftp_proxy;
155 // Set if mode is MODE_PROXY_PER_SCHEME and has socks proxy. 132 // Set if mode is MODE_PROXY_PER_SCHEME and has socks proxy.
156 ManualProxy socks_proxy; 133 ManualProxy socks_proxy;
157 134
158 // Exceptions for when not to use a proxy. 135 // Exceptions for when not to use a proxy.
159 net::ProxyBypassRules bypass_rules; 136 net::ProxyBypassRules bypass_rules;
160 137
161 private: 138 private:
162 // Encodes the proxy server as "<url-scheme>=<proxy-scheme>://<proxy>" 139 // Encodes the proxy server as "<url-scheme>=<proxy-scheme>://<proxy>"
163 static void EncodeAndAppendProxyServer(const std::string& scheme, 140 static void EncodeAndAppendProxyServer(const std::string& scheme,
164 const net::ProxyServer& server, 141 const net::ProxyServer& server,
165 std::string* spec); 142 std::string* spec);
166
167 // Converts |this| to Dictionary of ProxyConfigDictionary format (which
168 // is the same format used by prefs).
169 DictionaryValue* ToPrefProxyConfig();
170
171 // Converts |this| from Dictionary of ProxyConfigDictionary format.
172 bool FromPrefProxyConfig(const DictionaryValue* proxy_dict);
173 }; 143 };
174 144
175 // Usual constructor. 145 // Constructor.
176 ProxyConfigServiceImpl(); 146 explicit ProxyConfigServiceImpl(PrefService* pref_service);
177 // Constructor for testing.
178 // |init_config| specifies the ProxyConfig to use for initialization.
179 explicit ProxyConfigServiceImpl(const ProxyConfig& init_config);
180 virtual ~ProxyConfigServiceImpl(); 147 virtual ~ProxyConfigServiceImpl();
181 148
182 // Methods called on IO thread from wrapper class chromeos::ProxyConfigService 149 // Called by UI to set service path of |network| to be displayed or edited.
183 // as ProxyConfigService methods. 150 // Subsequent UISet* methods will use this network, until UI calls it again
184 void AddObserver(net::ProxyConfigService::Observer* observer); 151 // with a different network.
185 void RemoveObserver(net::ProxyConfigService::Observer* observer); 152 void UISetCurrentNetwork(const std::string& current_network);
186 // Called from GetLatestProxyConfig.
187 net::ProxyConfigService::ConfigAvailability IOGetProxyConfig(
188 net::ProxyConfig* config);
189 153
190 // Called from UI thread to retrieve proxy configuration in |config|. 154 // Called from UI to make the currently active network the one to be displayed
155 // or edited. Subsequent UISet* methods will use this network until UI calls
156 // it again when the active network has changed.
157 void UIMakeActiveNetworkCurrent();
158
159 // Called from UI to get name of the current network set via
160 // UISetCurrentNetwork or UIMakeActiveNetworkCurrent.
161 void UIGetCurrentNetworkName(std::string* network_name);
162
163 // Called from UI to retrieve proxy configuration in |current_ui_config_|.
191 void UIGetProxyConfig(ProxyConfig* config); 164 void UIGetProxyConfig(ProxyConfig* config);
192 165
193 // Called from UI thread to set service path of network to be displayed or 166 // Called from UI to update proxy configuration for different modes.
194 // edited. Subsequent UISet* methods will use this network, until UI calls
195 // it again with a different network.
196 bool UISetCurrentNetwork(const std::string& current_network);
197
198 // Called from UI thread to make the currently active network the one to be
199 // displayed or edited. Subsequent UISet* methods will use this network. until
200 // UI calls it again when the active network has changed.
201 bool UIMakeActiveNetworkCurrent();
202
203 // Called from UI thread to get name of the current active network.
204 const std::string& current_network_name() const {
205 return current_ui_network_name_;
206 }
207
208 // Called from UI thread to set/get user preference use_shared_proxies.
209 void UISetUseSharedProxies(bool use_shared);
210 bool use_shared_proxies() const {
211 return use_shared_proxies_;
212 }
213
214 // Called from UI thread to update proxy configuration for different modes.
215 // Returns true if config is set properly and persisted to flimflam for the 167 // Returns true if config is set properly and persisted to flimflam for the
216 // current network (set via UISetCurrentNetwork/UIMakeActiveNetworkCurrent). 168 // current network (set via UISetCurrentNetwork/UIMakeActiveNetworkCurrent).
217 // If this network is also currently active, config service proceeds to start 169 // If this network is also currently active, config service proceeds to start
218 // activating it on network stack. 170 // activating it on network stack.
219 // Returns false if config is not set properly, probably because information 171 // Returns false if config is not set properly, probably because information
220 // is incomplete or invalid; while config service won't proceed to activate or 172 // is incomplete or invalid; while config service won't proceed to activate or
221 // persist this config, the information is "cached" in the service, so that 173 // persist this config, the information is "cached" in the service, so that
222 // the next UIGetProxyConfig call will return this latest information. 174 // the next UIGetProxyConfig call will return this latest information.
223 bool UISetProxyConfigToDirect(); 175 bool UISetProxyConfigToDirect();
224 bool UISetProxyConfigToAutoDetect(); 176 bool UISetProxyConfigToAutoDetect();
225 bool UISetProxyConfigToPACScript(const GURL& pac_url); 177 bool UISetProxyConfigToPACScript(const GURL& pac_url);
226 bool UISetProxyConfigToSingleProxy(const net::ProxyServer& server); 178 bool UISetProxyConfigToSingleProxy(const net::ProxyServer& server);
227 // |scheme| is one of "http", "https", "ftp" or "socks". 179 // |scheme| is one of "http", "https", "ftp" or "socks".
228 bool UISetProxyConfigToProxyPerScheme(const std::string& scheme, 180 bool UISetProxyConfigToProxyPerScheme(const std::string& scheme,
229 const net::ProxyServer& server); 181 const net::ProxyServer& server);
230 // Only valid for MODE_SINGLE_PROXY or MODE_PROXY_PER_SCHEME. 182 // Only valid for MODE_SINGLE_PROXY or MODE_PROXY_PER_SCHEME.
231 bool UISetProxyConfigBypassRules(const net::ProxyBypassRules& bypass_rules); 183 bool UISetProxyConfigBypassRules(const net::ProxyBypassRules& bypass_rules);
232 184
233 // Implementation for SignedSettings::Delegate 185 // Implementation for SignedSettings::Delegate
234 virtual void OnSettingsOpCompleted(SignedSettings::ReturnCode code, 186 virtual void OnSettingsOpCompleted(SignedSettings::ReturnCode code,
235 std::string value); 187 std::string value) OVERRIDE;
236 188
237 // NetworkLibrary::NetworkManagerObserver implementation. 189 // NetworkLibrary::NetworkManagerObserver implementation.
238 virtual void OnNetworkManagerChanged(NetworkLibrary* cros); 190 virtual void OnNetworkManagerChanged(NetworkLibrary* cros) OVERRIDE;
239 191
240 // NetworkLibrary::NetworkObserver implementation. 192 // NetworkLibrary::NetworkObserver implementation.
241 virtual void OnNetworkChanged(NetworkLibrary* cros, const Network* network); 193 virtual void OnNetworkChanged(NetworkLibrary* cros,
194 const Network* network) OVERRIDE;
195
196 // PrefProxyConfigTrackerImpl implementation.
197 virtual void OnProxyConfigChanged(ProxyPrefs::ConfigState config_state,
198 const net::ProxyConfig& config) OVERRIDE;
199
200 // Register UseShardProxies preference.
201 static void RegisterPrefs(PrefService* pref_service);
242 202
243 #if defined(UNIT_TEST) 203 #if defined(UNIT_TEST)
244 void SetTesting() { 204 void SetTesting(ProxyConfig* test_config) {
245 testing_ = true;
246 active_network_ = "test";
247 UIMakeActiveNetworkCurrent(); 205 UIMakeActiveNetworkCurrent();
206 if (test_config) {
207 std::string value;
208 test_config->SerializeForNetwork(&value);
209 SetProxyConfigForNetwork(active_network_, value, false);
210 }
248 } 211 }
249 #endif // defined(UNIT_TEST) 212 #endif // defined(UNIT_TEST)
250 213
251 private: 214 private:
252 friend class base::RefCountedThreadSafe<ProxyConfigServiceImpl>; 215 // content::NotificationObserver implementation.
216 virtual void Observe(int type,
217 const content::NotificationSource& source,
218 const content::NotificationDetails& details) OVERRIDE;
253 219
254 // Called from UI thread from the various UISetProxyConfigTo*. 220 // Called from the various UISetProxyConfigTo*.
255 void OnUISetProxyConfig(); 221 void OnUISetProxyConfig();
256 222
257 // Posted from UI thread to IO thread to carry the new config information.
258 void IOSetProxyConfig(
259 const ProxyConfig& new_config,
260 net::ProxyConfigService::ConfigAvailability new_availability);
261
262 // Called from OnNetworkManagerChanged and OnNetworkChanged for currently 223 // Called from OnNetworkManagerChanged and OnNetworkChanged for currently
263 // active network, to handle previously active network, new active network, 224 // active network, to handle previously active network, new active network,
264 // and if necessary, migrates device settings to flimflam and/or activates 225 // and if necessary, migrates device settings to flimflam and/or activates
265 // proxy setting of new network. 226 // proxy setting of new network.
266 void OnActiveNetworkChanged(NetworkLibrary* cros, 227 void OnActiveNetworkChanged(NetworkLibrary* cros,
267 const Network* active_network); 228 const Network* active_network);
268 229
269 // Sets proxy config for |network_path| into flimflam and activates setting 230 // Sets proxy config for |network_path| into flimflam and activates setting
270 // if the network is currently active. 231 // if the network is currently active. If |only_set_if_empty| is true,
232 // proxy will be set and saved only if network has no proxy.
271 void SetProxyConfigForNetwork(const std::string& network_path, 233 void SetProxyConfigForNetwork(const std::string& network_path,
272 const std::string& value, 234 const std::string& value,
273 bool only_set_if_empty); 235 bool only_set_if_empty);
274 236
275 // Determines and activates proxy config of |network| based on if network is 237 // Returns value of UseSharedProxies preference if it's not default, else
276 // shared/private or user is using shared proxies, etc. 238 // returns false if user is logged in and true otherwise.
277 void DetermineConfigFromNetwork(const Network* network); 239 bool GetUseSharedProxies();
278 240
279 // Set |current_ui_network_name_| with name of |network|. 241 // Determines effective proxy config based on prefs from config tracker,
280 void SetCurrentNetworkName(const Network* network); 242 // |network| and if user is using shared proxies.
243 // If |activate| is true, effective config is stored in |active_config_| and
244 // activated on network stack, and hence, picked up by observers.
245 // if |activate| is false, effective config is stored in |current_ui_config_|
246 // but not activated on network stack, and hence, not picked up by observers.
247 void DetermineEffectiveConfig(const Network* network, bool activate);
281 248
282 // Checks that method is called on BrowserThread::IO thread. 249 // Determines |current_ui_config_| based on |network|, called from
283 void CheckCurrentlyOnIOThread(); 250 // UISetCurrentNetwork and UIMakeActiveNetworkActive.
251 void OnUISetCurrentNetwork(const Network* network);
284 252
285 // Checks that method is called on BrowserThread::UI thread. 253 // Returns true if proxy is to be ignored for network, which happens if
286 void CheckCurrentlyOnUIThread(); 254 // network is shared and use-shared-proxies is turned off.
255 bool IgnoreProxy(const Network* network) {
256 return network->profile_type() == PROFILE_SHARED && !GetUseSharedProxies();
257 }
258
259 // Reset UI cache variables that keep track of UI activities.
260 void ResetUICache();
287 261
288 // Data members. 262 // Data members.
289 263
290 // True if running unit_tests, which will need to specifically exclude 264 // Service path of currently active network (determined via flimflam
291 // flimflam logic. 265 // notifications); if effective proxy config is from system, proxy of this
292 bool testing_; 266 // network will be the one taking effect.
267 std::string active_network_;
293 268
294 // True if tasks can be posted, which can only happen if constructor has 269 // State of |active_config_|. |active_config_| is only valid if
295 // completed (NewRunnableMethod cannot be created for a RefCountedThreadBase's 270 // |active_config_state_| is not ProxyPrefs::CONFIG_UNSET.
296 // method until the class's ref_count is at least one). 271 ProxyPrefs::ConfigState active_config_state_;
297 bool can_post_task_;
298 272
299 // Availability status of the configuration, initialized on UI thread, but 273 // Active proxy configuration, which could be from prefs or network.
300 // afterwards only accessed from IO thread. 274 net::ProxyConfig active_config_;
301 net::ProxyConfigService::ConfigAvailability config_availability_;
302
303 // Service path of currently active network (determined via flimflam
304 // notifications) whose proxy config is taking effect.
305 std::string active_network_;
306 // Proxy configuration of |active_network_|, only accessed from UI thread.
307 ProxyConfig active_config_;
308 275
309 // Proxy config retreived from device, in format generated from 276 // Proxy config retreived from device, in format generated from
310 // SerializeForNetwork, that can be directly set into flimflam. 277 // SerializeForNetwork, that can be directly set into flimflam.
311 std::string device_config_; 278 std::string device_config_;
312 279
313 // Cached proxy configuration, to be converted to net::ProxyConfig and
314 // returned by IOGetProxyConfig.
315 // Initially populated from UI thread, but afterwards only accessed from IO
316 // thread.
317 ProxyConfig cached_config_;
318
319 // Service path of network whose proxy configuration is being displayed or 280 // Service path of network whose proxy configuration is being displayed or
320 // edited via UI, separate from |active_network_| which may be same or 281 // edited via UI, separate from |active_network_| which may be same or
321 // different. 282 // different.
322 std::string current_ui_network_; 283 std::string current_ui_network_;
323 284
324 // Name of network with current_ui_network_, set in UIMakeActiveNetworkCurrent 285 // Proxy configuration of |current_ui_network_|.
325 // and UISetCurrentNetwork.
326 std::string current_ui_network_name_;
327
328 // Proxy configuration of |current_ui_network|.
329 ProxyConfig current_ui_config_; 286 ProxyConfig current_ui_config_;
330 287
331 // True if user preference UseSharedProxies is true. 288 // Track changes in UseSharedProxies user preference.
332 bool use_shared_proxies_; 289 BooleanPrefMember use_shared_proxies_;
333 290
334 // List of observers for changes in proxy config. 291 content::NotificationRegistrar registrar_;
335 ObserverList<net::ProxyConfigService::Observer> observers_;
336 292
337 // Operation to retrieve proxy setting from device. 293 // Operation to retrieve proxy setting from device.
338 scoped_refptr<SignedSettings> retrieve_property_op_; 294 scoped_refptr<SignedSettings> retrieve_property_op_;
339 295
340 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceImpl); 296 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceImpl);
341 }; 297 };
342 298
343 } // namespace chromeos 299 } // namespace chromeos
344 300
345 #endif // CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_ 301 #endif // CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698