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

Unified Diff: chrome/browser/extensions/extension_proxy_api.cc

Issue 6312088: Fix handling of setting a single proxy in Proxy Settings API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_proxy_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_proxy_api.cc
diff --git a/chrome/browser/extensions/extension_proxy_api.cc b/chrome/browser/extensions/extension_proxy_api.cc
index c0e433901d2fe1fd8d4f1c6113ecac0fca1e5fd4..3da5ae996fd33fe727ac5fb9608de2c7b281d8aa 100644
--- a/chrome/browser/extensions/extension_proxy_api.cc
+++ b/chrome/browser/extensions/extension_proxy_api.cc
@@ -49,6 +49,7 @@ COMPILE_ASSERT(arraysize(field_name) == SCHEME_MAX + 1,
field_name_array_is_wrong_size);
COMPILE_ASSERT(arraysize(scheme_name) == SCHEME_MAX + 1,
scheme_name_array_is_wrong_size);
+COMPILE_ASSERT(SCHEME_ALL == 0, singleProxy_must_be_first_option);
void ProxySettingsFunction::ApplyPreference(const char* pref_path,
Value* pref_value,
@@ -174,23 +175,34 @@ bool UseCustomProxySettingsFunction::GetProxyRules(
}
}
- // A single proxy supersedes individual HTTP, HTTPS, and FTP proxies.
+ // Handle case that only singleProxy is specified.
if (has_proxy[SCHEME_ALL]) {
- proxy_server[SCHEME_HTTP] = proxy_server[SCHEME_ALL];
- proxy_server[SCHEME_HTTPS] = proxy_server[SCHEME_ALL];
- proxy_server[SCHEME_FTP] = proxy_server[SCHEME_ALL];
- has_proxy[SCHEME_HTTP] = true;
- has_proxy[SCHEME_HTTPS] = true;
- has_proxy[SCHEME_FTP] = true;
- has_proxy[SCHEME_ALL] = false;
+ for (size_t i = 1; i <= SCHEME_MAX; ++i) {
+ if (has_proxy[i]) {
+ LOG(ERROR) << "Proxy rule for " << field_name[SCHEME_ALL] << " and "
+ << field_name[i] << " cannot be set at the same time.";
+ return false;
+ }
+ }
+ if (!proxy_server[SCHEME_ALL].scheme.empty())
+ LOG(WARNING) << "Ignoring scheme attribute from proxy server.";
+ // Build the proxy preference string.
+ std::string proxy_pref;
+ proxy_pref.append(proxy_server[SCHEME_ALL].host);
+ if (proxy_server[SCHEME_ALL].port != ProxyServer::INVALID_PORT) {
+ proxy_pref.append(":");
eroman 2011/02/08 01:11:07 It is not generally safe to form host:port pairs s
+ proxy_pref.append(base::StringPrintf("%d",
+ proxy_server[SCHEME_ALL].port));
+ }
+ *out = proxy_pref;
+ return true;
}
- // TODO(pamg): Ensure that if a value is empty, that means "don't use a proxy
- // for this scheme".
+ // Handle case the anything but singleProxy is specified.
// Build the proxy preference string.
std::string proxy_pref;
- for (size_t i = 0; i <= SCHEME_MAX; ++i) {
+ for (size_t i = 1; i <= SCHEME_MAX; ++i) {
if (has_proxy[i]) {
// http=foopy:4010;ftp=socks://foopy2:80
if (!proxy_pref.empty())
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_proxy_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698