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

Side by Side Diff: chrome/browser/chromeos/proxy_cros_settings_provider.cc

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, 2 months 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 #include "chrome/browser/chromeos/proxy_cros_settings_provider.h" 5 #include "chrome/browser/chromeos/proxy_cros_settings_provider.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/cros_settings.h" 9 #include "chrome/browser/chromeos/cros_settings.h"
10 #include "chrome/browser/ui/browser_list.h" 10 #include "chrome/browser/ui/browser_list.h"
(...skipping 29 matching lines...) Expand all
40 kProxyFtpPort, 40 kProxyFtpPort,
41 kProxySocks, 41 kProxySocks,
42 kProxySocksPort, 42 kProxySocksPort,
43 kProxyIgnoreList, 43 kProxyIgnoreList,
44 }; 44 };
45 45
46 //------------------ ProxyCrosSettingsProvider: public methods ----------------- 46 //------------------ ProxyCrosSettingsProvider: public methods -----------------
47 47
48 ProxyCrosSettingsProvider::ProxyCrosSettingsProvider() { } 48 ProxyCrosSettingsProvider::ProxyCrosSettingsProvider() { }
49 49
50 void ProxyCrosSettingsProvider::SetCurrentNetwork(const std::string& network) { 50 void ProxyCrosSettingsProvider::SetCurrentNetworkWithProfile(
51 if (!GetConfigService()->UISetCurrentNetwork(network)) 51 const std::string& network, Profile* profile) {
52 return; 52 GetConfigService()->UISetCurrentNetworkWithProfile(network, profile);
53 for (size_t i = 0; i < arraysize(kProxySettings); ++i) 53 for (size_t i = 0; i < arraysize(kProxySettings); ++i)
54 CrosSettings::Get()->FireObservers(kProxySettings[i]); 54 CrosSettings::Get()->FireObservers(kProxySettings[i]);
55 } 55 }
56 56
57 void ProxyCrosSettingsProvider::MakeActiveNetworkCurrent() { 57 void ProxyCrosSettingsProvider::MakeActiveNetworkCurrentWithProfile(
58 if (!GetConfigService()->UIMakeActiveNetworkCurrent()) 58 Profile* profile) {
59 return; 59 GetConfigService()->UIMakeActiveNetworkCurrentWithProfile(profile);
60 for (size_t i = 0; i < arraysize(kProxySettings); ++i) 60 for (size_t i = 0; i < arraysize(kProxySettings); ++i)
61 CrosSettings::Get()->FireObservers(kProxySettings[i]); 61 CrosSettings::Get()->FireObservers(kProxySettings[i]);
62 } 62 }
63 63
64 bool ProxyCrosSettingsProvider::IsUsingSharedProxies() const {
65 return GetConfigService()->use_shared_proxies();
66 }
67
68 const std::string& ProxyCrosSettingsProvider::GetCurrentNetworkName() const { 64 const std::string& ProxyCrosSettingsProvider::GetCurrentNetworkName() const {
69 return GetConfigService()->current_network_name(); 65 return GetConfigService()->current_network_name();
70 } 66 }
71 67
72 void ProxyCrosSettingsProvider::DoSet(const std::string& path, 68 void ProxyCrosSettingsProvider::DoSet(const std::string& path,
73 Value* in_value) { 69 Value* in_value) {
74 if (!in_value) { 70 if (!in_value) {
75 return; 71 return;
76 } 72 }
77 73
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 224 }
229 config_service->UISetProxyConfigBypassRules(bypass_rules); 225 config_service->UISetProxyConfigBypassRules(bypass_rules);
230 } 226 }
231 } 227 }
232 } 228 }
233 229
234 bool ProxyCrosSettingsProvider::Get(const std::string& path, 230 bool ProxyCrosSettingsProvider::Get(const std::string& path,
235 Value** out_value) const { 231 Value** out_value) const {
236 bool found = false; 232 bool found = false;
237 bool managed = false; 233 bool managed = false;
234 std::string controlled_by;
238 Value* data = NULL; 235 Value* data = NULL;
239 chromeos::ProxyConfigServiceImpl* config_service = GetConfigService(); 236 chromeos::ProxyConfigServiceImpl* config_service = GetConfigService();
240 chromeos::ProxyConfigServiceImpl::ProxyConfig config; 237 chromeos::ProxyConfigServiceImpl::ProxyConfig config;
241 config_service->UIGetProxyConfig(&config); 238 config_service->UIGetProxyConfig(&config);
242 239
243 if (path == kProxyPacUrl) { 240 if (path == kProxyPacUrl) {
244 // Only show pacurl for pac-script mode. 241 // Only show pacurl for pac-script mode.
245 if (config.mode == 242 if (config.mode ==
246 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT && 243 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT &&
247 config.automatic_proxy.pac_url.is_valid()) { 244 config.automatic_proxy.pac_url.is_valid()) {
(...skipping 19 matching lines...) Expand all
267 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT) { 264 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT) {
268 data = Value::CreateIntegerValue(3); 265 data = Value::CreateIntegerValue(3);
269 } else if (config.mode == 266 } else if (config.mode ==
270 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_SINGLE_PROXY || 267 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_SINGLE_PROXY ||
271 config.mode == 268 config.mode ==
272 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PROXY_PER_SCHEME) { 269 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PROXY_PER_SCHEME) {
273 data = Value::CreateIntegerValue(2); 270 data = Value::CreateIntegerValue(2);
274 } else { 271 } else {
275 data = Value::CreateIntegerValue(1); 272 data = Value::CreateIntegerValue(1);
276 } 273 }
274 switch (config.source) {
stevenjb 2011/10/05 00:22:57 This logic would need to change if config.source w
kuan 2011/10/07 00:30:41 Done.
275 case ProxyConfigServiceImpl::ProxyConfig::SOURCE_POLICY:
276 case ProxyConfigServiceImpl::ProxyConfig::SOURCE_RECOMMENDED:
Mattias Nissler (ping if slow) 2011/10/05 10:18:36 I think this is misleading, since the banner is th
kuan 2011/10/07 00:30:41 this didn't from me; it comes from sumit and kenmo
Mattias Nissler (ping if slow) 2011/10/07 13:32:10 It seems I misunderstood this. The point here is t
277 controlled_by = "policyManagedPrefsBannerText";
278 break;
279 case ProxyConfigServiceImpl::ProxyConfig::SOURCE_EXTENSION:
280 controlled_by = "extensionManagedPrefsBannerText";
281 break;
282 default:
283 if (!config.IsUserModifiable())
284 controlled_by = "enableSharedProxiesBannerText";
285 break;
286 }
277 found = true; 287 found = true;
278 } else if (path == kProxySingle) { 288 } else if (path == kProxySingle) {
279 data = Value::CreateBooleanValue(config.mode == 289 data = Value::CreateBooleanValue(config.mode ==
280 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_SINGLE_PROXY); 290 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_SINGLE_PROXY);
281 found = true; 291 found = true;
282 } else if (path == kProxyFtpUrl) { 292 } else if (path == kProxyFtpUrl) {
283 data = CreateServerHostValue(config.ftp_proxy); 293 data = CreateServerHostValue(config.ftp_proxy);
284 found = true; 294 found = true;
285 } else if (path == kProxySocks) { 295 } else if (path == kProxySocks) {
286 data = CreateServerHostValue(config.socks_proxy); 296 data = CreateServerHostValue(config.socks_proxy);
(...skipping 18 matching lines...) Expand all
305 } 315 }
306 *out_value = list; 316 *out_value = list;
307 return true; 317 return true;
308 } 318 }
309 if (found) { 319 if (found) {
310 DictionaryValue* dict = new DictionaryValue; 320 DictionaryValue* dict = new DictionaryValue;
311 if (!data) 321 if (!data)
312 data = Value::CreateStringValue(""); 322 data = Value::CreateStringValue("");
313 dict->Set("value", data); 323 dict->Set("value", data);
314 dict->SetBoolean("managed", managed); 324 dict->SetBoolean("managed", managed);
325 if (path == kProxyType) {
Mattias Nissler (ping if slow) 2011/10/07 13:32:10 why only for the type?
326 dict->SetString("controlledBy", controlled_by);
327 dict->SetBoolean("disabled", !config.IsUserModifiable());
328 }
315 *out_value = dict; 329 *out_value = dict;
316 return true; 330 return true;
317 } else { 331 } else {
318 *out_value = NULL; 332 *out_value = NULL;
319 return false; 333 return false;
320 } 334 }
321 } 335 }
322 336
323 bool ProxyCrosSettingsProvider::HandlesSetting(const std::string& path) const { 337 bool ProxyCrosSettingsProvider::HandlesSetting(const std::string& path) const {
324 return ::StartsWithASCII(path, "cros.session.proxy", true); 338 return ::StartsWithASCII(path, "cros.session.proxy", true);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 381 }
368 382
369 Value* ProxyCrosSettingsProvider::CreateServerPortValue( 383 Value* ProxyCrosSettingsProvider::CreateServerPortValue(
370 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const { 384 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const {
371 return proxy.server.is_valid() ? 385 return proxy.server.is_valid() ?
372 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : 386 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) :
373 NULL; 387 NULL;
374 } 388 }
375 389
376 } // namespace chromeos 390 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698