summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authormarq@google.com <marq@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-16 18:02:02 +0000
committermarq@google.com <marq@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-16 18:02:02 +0000
commit2189e09e6697118750bcf63852e147005a98a2b7 (patch)
treeba278ded8936e69b3acbfdb7f77fff96f31749e5 /chrome/browser/extensions
parentd8d25796f9a56b974343cd2f1f5a12aa3ca0a450 (diff)
downloadchromium_src-2189e09e6697118750bcf63852e147005a98a2b7.zip
chromium_src-2189e09e6697118750bcf63852e147005a98a2b7.tar.gz
chromium_src-2189e09e6697118750bcf63852e147005a98a2b7.tar.bz2
Change ProxyRules to handle ProxyLists rather than just single ProxyServer instances.
- All of the ProxyRules members that used to just be ProxyServers are now ProxyLists. - ParseFromString will now accept multiple proxy specifications per scheme. - ProxyRules::Apply now sets the ProxyInfo result to use a PAC string if any proxying will be done. - ProxyList now has an AddProxyServer method. - In general, beacuse ProxyList checks for the validity of its contents before adding new entries, IsEmpty() is used as a validity test where is_valid() used to be. - Writing ProxyRules into a dictionary will write out each constituent ProxyList as a PAC string. - Slight functional change to proxy_info: Calling UsePacString() now invokes Reset(), in line with the other Use* methods. - Updated proxy_config_unittest to compare PAC strings of proxy rules components. BUG= Review URL: https://chromiumcodereview.appspot.com/12315019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-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(