diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-30 17:29:43 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-30 17:29:43 +0000 |
commit | 117d54f3c08feda50f91412f4344e590c68e212c (patch) | |
tree | 1248ba6641ff81e0896daf59d347472d22402649 | |
parent | f8660f8fcfe43e5aa435400814834d18afc367e5 (diff) | |
download | chromium_src-117d54f3c08feda50f91412f4344e590c68e212c.zip chromium_src-117d54f3c08feda50f91412f4344e590c68e212c.tar.gz chromium_src-117d54f3c08feda50f91412f4344e590c68e212c.tar.bz2 |
Recognize new proxy settings format in net-internals.
BUG=224294
Review URL: https://chromiumcodereview.appspot.com/12681031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191521 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/net_internals/log_util.js | 2 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/log_view_painter.js | 23 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/proxy_view.js | 16 | ||||
-rw-r--r-- | chrome/test/data/webui/net_internals/log_view_painter.js | 62 | ||||
-rw-r--r-- | net/proxy/proxy_config.cc | 4 | ||||
-rw-r--r-- | net/proxy/proxy_list.cc | 8 | ||||
-rw-r--r-- | net/proxy/proxy_list.h | 7 |
7 files changed, 112 insertions, 10 deletions
diff --git a/chrome/browser/resources/net_internals/log_util.js b/chrome/browser/resources/net_internals/log_util.js index 5eb3f8b..b975b8e 100644 --- a/chrome/browser/resources/net_internals/log_util.js +++ b/chrome/browser/resources/net_internals/log_util.js @@ -256,6 +256,8 @@ log_util = (function() { showView = true; } } catch (error) { + errorString += 'Caught error while calling onLoadLogFinish: ' + + error + '\n\n'; } categoryTabSwitcher.showTabHandleNode(tabIds[i], showView); } diff --git a/chrome/browser/resources/net_internals/log_view_painter.js b/chrome/browser/resources/net_internals/log_view_painter.js index 1c5b0d0..4704b86 100644 --- a/chrome/browser/resources/net_internals/log_view_painter.js +++ b/chrome/browser/resources/net_internals/log_view_painter.js @@ -638,6 +638,23 @@ proxySettingsToString = function(config) { if (!config) return ''; + // TODO(eroman): if |config| has unexpected properties, print it as JSON + // rather than hide them. + + function getProxyListString(proxies) { + // Older versions of Chrome would set these values as strings, whereas newer + // logs use arrays. + // TODO(eroman): This behavior changed in M27. Support for older logs can + // safely be removed circa M29. + if (Array.isArray(proxies)) { + var listString = proxies.join(', '); + if (proxies.length > 1) + return '[' + listString + ']'; + return listString; + } + return proxies; + } + // The proxy settings specify up to three major fallback choices // (auto-detect, custom pac url, or manual settings). // We enumerate these to a list so we can later number them. @@ -654,17 +671,17 @@ proxySettingsToString = function(config) { var lines = []; if (config.single_proxy) { - lines.push('Proxy server: ' + config.single_proxy); + lines.push('Proxy server: ' + getProxyListString(config.single_proxy)); } else if (config.proxy_per_scheme) { for (var urlScheme in config.proxy_per_scheme) { if (urlScheme != 'fallback') { lines.push('Proxy server for ' + urlScheme.toUpperCase() + ': ' + - config.proxy_per_scheme[urlScheme]); + getProxyListString(config.proxy_per_scheme[urlScheme])); } } if (config.proxy_per_scheme.fallback) { lines.push('Proxy server for everything else: ' + - config.proxy_per_scheme.fallback); + getProxyListString(config.proxy_per_scheme.fallback)); } } diff --git a/chrome/browser/resources/net_internals/proxy_view.js b/chrome/browser/resources/net_internals/proxy_view.js index 7d21fc8..588cc74 100644 --- a/chrome/browser/resources/net_internals/proxy_view.js +++ b/chrome/browser/resources/net_internals/proxy_view.js @@ -111,7 +111,7 @@ var ProxyView = (function() { if (!proxySettings) return; - var socksProxy = getSocks5Proxy_(proxySettings.single_proxy); + var socksProxy = getSingleSocks5Proxy_(proxySettings.single_proxy); if (!socksProxy) return; @@ -137,7 +137,19 @@ var ProxyView = (function() { } }; - function getSocks5Proxy_(proxyString) { + function getSingleSocks5Proxy_(proxyList) { + var proxyString; + if (typeof proxyList == 'string') { + // Older versions of Chrome passed single_proxy as a string. + // TODO(eroman): This behavior changed in M27. Support for older logs can + // safely be removed circa M29. + proxyString = proxyList; + } else if (Array.isArray(proxyList) && proxyList.length == 1) { + proxyString = proxyList[0]; + } else { + return null; + } + var pattern = /^socks5:\/\/(.*)$/; var matches = pattern.exec(proxyString); diff --git a/chrome/test/data/webui/net_internals/log_view_painter.js b/chrome/test/data/webui/net_internals/log_view_painter.js index 33493af..0ce8330 100644 --- a/chrome/test/data/webui/net_internals/log_view_painter.js +++ b/chrome/test/data/webui/net_internals/log_view_painter.js @@ -151,7 +151,8 @@ TEST_F('NetInternalsTest', 'netInternalsLogViewPainterPrintAsText', function() { runTestCase(painterTestNetError()); runTestCase(painterTestHexEncodedBytes()); runTestCase(painterTestCertVerifierJob()); - runTestCase(painterTestProxyConfig()); + runTestCase(painterTestProxyConfigOneProxyAllSchemes()); + runTestCase(painterTestProxyConfigTwoProxiesAllSchemes()); runTestCase(painterTestDontStripCookiesURLRequest()); runTestCase(painterTestStripCookiesURLRequest()); runTestCase(painterTestDontStripCookiesSPDYSession()); @@ -1266,9 +1267,10 @@ function painterTestCertVerifierJob() { } /** - * Tests the formatting of proxy configurations. + * Tests the formatting of proxy configurations when using one proxy server for + * all URL schemes. */ -function painterTestProxyConfig() { +function painterTestProxyConfigOneProxyAllSchemes() { var testCase = {}; testCase.tickOffset = '1337911098481'; @@ -1318,6 +1320,60 @@ function painterTestProxyConfig() { } /** + * Tests the formatting of proxy configurations when using two proxy servers for + * all URL schemes. + */ +function painterTestProxyConfigTwoProxiesAllSchemes() { + var testCase = {}; + testCase.tickOffset = '1337911098481'; + + testCase.logEntries = [ + { + 'params': { + 'new_config': { + 'auto_detect': true, + 'bypass_list': [ + '*.local', + 'foo', + '<local>' + ], + 'pac_url': 'https://config/wpad.dat', + 'single_proxy': ['cache-proxy:3128', 'socks4://other:999'], + 'source': 'SYSTEM' + }, + 'old_config': { + 'auto_detect': true + } + }, + 'phase': EventPhase.PHASE_NONE, + 'source': { + 'id': 814, + 'type': EventSourceType.NONE + }, + 'time': '954443578', + 'type': EventType.PROXY_CONFIG_CHANGED + } + ]; + + testCase.expectedText = + 't=1338865542059 [st=0] PROXY_CONFIG_CHANGED\n' + + ' --> old_config =\n' + + ' Auto-detect\n' + + ' --> new_config =\n' + + ' (1) Auto-detect\n' + + ' (2) PAC script: https://config/wpad.dat\n' + + ' (3) Proxy server: [cache-proxy:3128, ' + + 'socks4://other:999]\n' + + ' Bypass list: \n' + + ' *.local\n' + + ' foo\n' + + ' <local>\n' + + ' Source: SYSTEM'; + + return testCase; +} + +/** * Tests that cookies are NOT stripped from URLRequests when stripping is * disabled. */ diff --git a/net/proxy/proxy_config.cc b/net/proxy/proxy_config.cc index 91122dd..84b3d7a 100644 --- a/net/proxy/proxy_config.cc +++ b/net/proxy/proxy_config.cc @@ -19,7 +19,7 @@ void AddProxyListToValue(const char* name, const ProxyList& proxies, base::DictionaryValue* dict) { if (!proxies.IsEmpty()) - dict->SetString(name, proxies.ToPacString()); + dict->Set(name, proxies.ToValue()); } // Split the |uri_list| on commas and add each entry to |proxy_list| in turn. @@ -234,7 +234,7 @@ base::Value* ProxyConfig::ToValue() const { if (proxy_rules_.type != ProxyRules::TYPE_NO_RULES) { switch (proxy_rules_.type) { case ProxyRules::TYPE_SINGLE_PROXY: - AddProxyListToValue("single_proxies", + AddProxyListToValue("single_proxy", proxy_rules_.single_proxies, dict); break; case ProxyRules::TYPE_PROXY_PER_SCHEME: { diff --git a/net/proxy/proxy_list.cc b/net/proxy/proxy_list.cc index 4a49501..a3ab02c 100644 --- a/net/proxy/proxy_list.cc +++ b/net/proxy/proxy_list.cc @@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/strings/string_tokenizer.h" #include "base/time.h" +#include "base/values.h" #include "net/proxy/proxy_server.h" using base::TimeDelta; @@ -155,6 +156,13 @@ std::string ProxyList::ToPacString() const { return proxy_list.empty() ? std::string() : proxy_list; } +base::ListValue* ProxyList::ToValue() const { + base::ListValue* list = new base::ListValue(); + for (size_t i = 0; i < proxies_.size(); ++i) + list->AppendString(proxies_[i].ToURI()); + return list; +} + bool ProxyList::Fallback(ProxyRetryInfoMap* proxy_retry_info, const BoundNetLog& net_log) { diff --git a/net/proxy/proxy_list.h b/net/proxy/proxy_list.h index 70208a1..9f5fa59 100644 --- a/net/proxy/proxy_list.h +++ b/net/proxy/proxy_list.h @@ -12,6 +12,10 @@ #include "net/base/net_log.h" #include "net/proxy/proxy_retry_info.h" +namespace base { +class ListValue; +} + namespace net { class ProxyServer; @@ -74,6 +78,9 @@ class NET_EXPORT_PRIVATE ProxyList { // For example: "PROXY xxx.xxx.xxx.xxx:xx; SOCKS yyy.yyy.yyy:yy". std::string ToPacString() const; + // Returns a serialized value for the list. The caller takes ownership of it. + base::ListValue* ToValue() const; + // Marks the current proxy server as bad and deletes it from the list. The // list of known bad proxies is given by proxy_retry_info. Returns true if // there is another server available in the list. |