Chromium Code Reviews| Index: chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.cc |
| diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.cc |
| index 2c23fbff129edd09db973256d4673c68c5d3668a..d084f578dd0cc08e9fdec03e73acfe5ca4095324 100644 |
| --- a/chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.cc |
| +++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.cc |
| @@ -55,6 +55,15 @@ enum { |
| NUM_SPDY_PROXY_AUTH_STATE |
| }; |
| +std::string ProtocolAndHost(std::string origin) { |
|
bengr
2013/10/20 18:19:31
Please add a comment that describes the format of
|
| + if (origin.empty()) { |
| + return origin; |
| + } |
| + GURL url = GURL(origin); |
| + std::string protocol = url.SchemeIsSecure() ? "HTTPS " : "HTTP "; |
| + return protocol + net::HostPortPair::FromURL(url).ToString() + "; "; |
| +} |
| + |
| } // namespace |
| DataReductionProxySettingsAndroid::DataReductionProxySettingsAndroid( |
| @@ -260,19 +269,18 @@ std::string DataReductionProxySettingsAndroid::GetProxyPacScript() { |
| "(" + JoinString(pac_bypass_rules_, ") || (") + ")"; |
| // Generate a proxy PAC that falls back to direct loading when the proxy is |
| - // unavailable and only process HTTP traffic. (With a statically configured |
| - // proxy, proxy failures will simply result in a connection error presented to |
| - // users.) |
| + // unavailable and only process HTTP traffic. |
| - std::string proxy_host = |
| - DataReductionProxySettings::GetDataReductionProxyOriginHostPort(); |
| + std::string proxy_host = ProtocolAndHost( |
| + DataReductionProxySettings::GetDataReductionProxyOrigin()); |
| + std::string fallback_host = ProtocolAndHost( |
| + DataReductionProxySettings::GetDataReductionProxyFallback()); |
| std::string pac = "function FindProxyForURL(url, host) {" |
| " if (" + bypass_clause + ") {" |
| " return 'DIRECT';" |
| " } " |
| " if (url.substring(0, 5) == 'http:') {" |
| - " return 'HTTPS " + proxy_host + |
| - "; DIRECT';" |
| + " return '" + proxy_host + fallback_host + "DIRECT';" |
| " }" |
| " return 'DIRECT';" |
| "}"; |