summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/api')
-rw-r--r--chrome/browser/extensions/api/proxy/proxy_api_helpers.cc32
-rw-r--r--chrome/browser/extensions/api/proxy/proxy_api_helpers_unittest.cc27
2 files changed, 45 insertions, 14 deletions
diff --git a/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc b/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc
index 11e45fd..564376c 100644
--- a/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc
+++ b/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc
@@ -377,28 +377,32 @@ DictionaryValue* CreateProxyRulesDict(
case net::ProxyConfig::ProxyRules::TYPE_NO_RULES:
return NULL;
case net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY:
- if (rules.single_proxy.is_valid()) {
- extension_proxy_rules->Set(keys::field_name[keys::SCHEME_ALL],
- CreateProxyServerDict(rules.single_proxy));
+ if (!rules.single_proxies.IsEmpty()) {
+ extension_proxy_rules->Set(
+ keys::field_name[keys::SCHEME_ALL],
+ CreateProxyServerDict(rules.single_proxies.Get()));
}
break;
case net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME:
- if (rules.proxy_for_http.is_valid()) {
- extension_proxy_rules->Set(keys::field_name[keys::SCHEME_HTTP],
- CreateProxyServerDict(rules.proxy_for_http));
+ if (!rules.proxies_for_http.IsEmpty()) {
+ extension_proxy_rules->Set(
+ keys::field_name[keys::SCHEME_HTTP],
+ CreateProxyServerDict(rules.proxies_for_http.Get()));
}
- if (rules.proxy_for_https.is_valid()) {
+ if (!rules.proxies_for_https.IsEmpty()) {
extension_proxy_rules->Set(
keys::field_name[keys::SCHEME_HTTPS],
- CreateProxyServerDict(rules.proxy_for_https));
+ CreateProxyServerDict(rules.proxies_for_https.Get()));
}
- if (rules.proxy_for_ftp.is_valid()) {
- extension_proxy_rules->Set(keys::field_name[keys::SCHEME_FTP],
- CreateProxyServerDict(rules.proxy_for_ftp));
+ if (!rules.proxies_for_ftp.IsEmpty()) {
+ extension_proxy_rules->Set(
+ keys::field_name[keys::SCHEME_FTP],
+ CreateProxyServerDict(rules.proxies_for_ftp.Get()));
}
- if (rules.fallback_proxy.is_valid()) {
- extension_proxy_rules->Set(keys::field_name[keys::SCHEME_FALLBACK],
- CreateProxyServerDict(rules.fallback_proxy));
+ if (!rules.fallback_proxies.IsEmpty()) {
+ extension_proxy_rules->Set(
+ keys::field_name[keys::SCHEME_FALLBACK],
+ CreateProxyServerDict(rules.fallback_proxies.Get()));
}
break;
}
diff --git a/chrome/browser/extensions/api/proxy/proxy_api_helpers_unittest.cc b/chrome/browser/extensions/api/proxy/proxy_api_helpers_unittest.cc
index 4c88742..116f85a 100644
--- a/chrome/browser/extensions/api/proxy/proxy_api_helpers_unittest.cc
+++ b/chrome/browser/extensions/api/proxy/proxy_api_helpers_unittest.cc
@@ -328,6 +328,33 @@ TEST(ExtensionProxyApiHelpers, CreateProxyRulesDict) {
EXPECT_TRUE(Value::Equals(expected.get(), extension_pref.get()));
}
+// Test multiple proxies per scheme -- expect that only the first is returned.
+TEST(ExtensionProxyApiHelpers, CreateProxyRulesDictMultipleProxies) {
+ scoped_ptr<DictionaryValue> browser_pref(
+ ProxyConfigDictionary::CreateFixedServers(
+ "http=proxy1:80,default://;https=proxy2:80,proxy1:80;ftp=proxy3:80,"
+ "https://proxy5:443;socks=proxy4:80,proxy1:80",
+ "localhost"));
+ ProxyConfigDictionary config(browser_pref.get());
+ scoped_ptr<DictionaryValue> extension_pref(CreateProxyRulesDict(config));
+ ASSERT_TRUE(extension_pref.get());
+
+ scoped_ptr<DictionaryValue> expected(new DictionaryValue);
+ expected->Set("proxyForHttp",
+ CreateTestProxyServerDict("http", "proxy1", 80));
+ expected->Set("proxyForHttps",
+ CreateTestProxyServerDict("http", "proxy2", 80));
+ expected->Set("proxyForFtp",
+ CreateTestProxyServerDict("http", "proxy3", 80));
+ expected->Set("fallbackProxy",
+ CreateTestProxyServerDict("socks4", "proxy4", 80));
+ ListValue* bypass_list = new ListValue;
+ bypass_list->Append(Value::CreateStringValue("localhost"));
+ expected->Set(keys::kProxyConfigBypassList, bypass_list);
+
+ EXPECT_TRUE(Value::Equals(expected.get(), extension_pref.get()));
+}
+
// Test if a PAC script URL is specified.
TEST(ExtensionProxyApiHelpers, CreatePacScriptDictWithUrl) {
scoped_ptr<DictionaryValue> browser_pref(