summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/proxy_cros_settings_parser.cc
diff options
context:
space:
mode:
authorbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-08 09:35:48 +0000
committerbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-08 09:35:48 +0000
commit25c78cfe9d6603277bd61ff03a06be8636efe433 (patch)
tree7548aeedf925541a86fe3f6c78bd85c3275f2a5a /chrome/browser/chromeos/proxy_cros_settings_parser.cc
parentae8ff7a2c204a9e02f19c46ad36f1909a9d2ce37 (diff)
downloadchromium_src-25c78cfe9d6603277bd61ff03a06be8636efe433.zip
chromium_src-25c78cfe9d6603277bd61ff03a06be8636efe433.tar.gz
chromium_src-25c78cfe9d6603277bd61ff03a06be8636efe433.tar.bz2
Consistently decorate pref values sent to the settings UI code
Pref values are provided to the settings UI code by three different classes. Each decorates the values slightly differently, adding different metadata fields or none at all. This CL makes the classes use a consistent decoration with identically named metadata fields, simplifying the handling of pref values on the JS side. BUG=104955 Review URL: https://chromiumcodereview.appspot.com/10834109 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150527 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/proxy_cros_settings_parser.cc')
-rw-r--r--chrome/browser/chromeos/proxy_cros_settings_parser.cc47
1 files changed, 16 insertions, 31 deletions
diff --git a/chrome/browser/chromeos/proxy_cros_settings_parser.cc b/chrome/browser/chromeos/proxy_cros_settings_parser.cc
index 7ec1bf2..158db4e 100644
--- a/chrome/browser/chromeos/proxy_cros_settings_parser.cc
+++ b/chrome/browser/chromeos/proxy_cros_settings_parser.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -286,8 +286,6 @@ void SetProxyPrefValue(Profile* profile,
bool GetProxyPrefValue(Profile* profile,
const std::string& path,
base::Value** out_value) {
- bool found = false;
- bool managed = false;
std::string controlled_by;
base::Value* data = NULL;
chromeos::ProxyConfigServiceImpl* config_service =
@@ -303,19 +301,14 @@ bool GetProxyPrefValue(Profile* profile,
data =
base::Value::CreateStringValue(config.automatic_proxy.pac_url.spec());
}
- found = true;
} else if (path == kProxySingleHttp) {
data = CreateServerHostValue(config.single_proxy);
- found = true;
} else if (path == kProxySingleHttpPort) {
data = CreateServerPortValue(config.single_proxy);
- found = true;
} else if (path == kProxyHttpUrl) {
data = CreateServerHostValue(config.http_proxy);
- found = true;
} else if (path == kProxyHttpsUrl) {
data = CreateServerHostValue(config.https_proxy);
- found = true;
} else if (path == kProxyType) {
if (config.mode ==
chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_AUTO_DETECT ||
@@ -345,54 +338,46 @@ bool GetProxyPrefValue(Profile* profile,
controlled_by = "enableSharedProxiesBannerText";
break;
}
- found = true;
} else if (path == kProxySingle) {
data = base::Value::CreateBooleanValue(config.mode ==
chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_SINGLE_PROXY);
- found = true;
} else if (path == kProxyFtpUrl) {
data = CreateServerHostValue(config.ftp_proxy);
- found = true;
} else if (path == kProxySocks) {
data = CreateServerHostValue(config.socks_proxy);
- found = true;
} else if (path == kProxyHttpPort) {
data = CreateServerPortValue(config.http_proxy);
- found = true;
} else if (path == kProxyHttpsPort) {
data = CreateServerPortValue(config.https_proxy);
- found = true;
} else if (path == kProxyFtpPort) {
data = CreateServerPortValue(config.ftp_proxy);
- found = true;
} else if (path == kProxySocksPort) {
data = CreateServerPortValue(config.socks_proxy);
- found = true;
} else if (path == kProxyIgnoreList) {
ListValue* list = new ListValue();
net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules();
for (size_t x = 0; x < bypass_rules.size(); x++) {
list->Append(base::Value::CreateStringValue(bypass_rules[x]->ToString()));
}
- *out_value = list;
- return true;
- }
- if (found) {
- DictionaryValue* dict = new DictionaryValue;
- if (!data)
- data = base::Value::CreateStringValue("");
- dict->Set("value", data);
- dict->SetBoolean("managed", managed);
- if (path == kProxyType) {
- dict->SetString("controlledBy", controlled_by);
- dict->SetBoolean("disabled", !config.user_modifiable);
- }
- *out_value = dict;
- return true;
+ data = list;
} else {
*out_value = NULL;
return false;
}
+
+ // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does.
+ DictionaryValue* dict = new DictionaryValue;
+ if (!data)
+ data = base::Value::CreateStringValue("");
+ dict->Set("value", data);
+ if (path == kProxyType) {
+ dict->SetString("controlledBy", controlled_by);
+ dict->SetBoolean("disabled", !config.user_modifiable);
+ } else {
+ dict->SetBoolean("disabled", false);
+ }
+ *out_value = dict;
+ return true;
}
} // namespace proxy_cros_settings_parser