summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/net_internals
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 03:48:34 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 03:48:34 +0000
commitfe9dbd662522c686fcdb33b0e89c0aafa268b68f (patch)
treefa99bbe4a8f68cb580a26259ea60cb4ea1d59b55 /chrome/browser/resources/net_internals
parente29c8c5760df16862da96dc1b68a4ed737ca8594 (diff)
downloadchromium_src-fe9dbd662522c686fcdb33b0e89c0aafa268b68f.zip
chromium_src-fe9dbd662522c686fcdb33b0e89c0aafa268b68f.tar.gz
chromium_src-fe9dbd662522c686fcdb33b0e89c0aafa268b68f.tar.bz2
Move the pretty-printing of proxy settings from the C++ code to javascript.
Also, the javascript version does some fancier output -- it now only displays the relevant fields, and numbers the fallback order. Review URL: http://codereview.chromium.org/3219004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/net_internals')
-rw-r--r--chrome/browser/resources/net_internals/dataview.js6
-rw-r--r--chrome/browser/resources/net_internals/logviewpainter.js74
-rw-r--r--chrome/browser/resources/net_internals/proxyview.js7
3 files changed, 79 insertions, 8 deletions
diff --git a/chrome/browser/resources/net_internals/dataview.js b/chrome/browser/resources/net_internals/dataview.js
index a7899c8..41f5b5661 100644
--- a/chrome/browser/resources/net_internals/dataview.js
+++ b/chrome/browser/resources/net_internals/dataview.js
@@ -54,7 +54,8 @@ DataView.prototype.onExportToText_ = function() {
text.push('----------------------------------------------');
text.push('');
- text.push(g_browser.proxySettings_.currentData_.effective);
+ text.push(proxySettingsToString(
+ g_browser.proxySettings_.currentData_.effective));
text.push('');
text.push('----------------------------------------------');
@@ -62,7 +63,8 @@ DataView.prototype.onExportToText_ = function() {
text.push('----------------------------------------------');
text.push('');
- text.push(g_browser.proxySettings_.currentData_.original);
+ text.push(proxySettingsToString(
+ g_browser.proxySettings_.currentData_.original));
text.push('');
text.push('----------------------------------------------');
diff --git a/chrome/browser/resources/net_internals/logviewpainter.js b/chrome/browser/resources/net_internals/logviewpainter.js
index d7d31dd..00ea37a 100644
--- a/chrome/browser/resources/net_internals/logviewpainter.js
+++ b/chrome/browser/resources/net_internals/logviewpainter.js
@@ -8,8 +8,10 @@
* the old net-internals is replaced.
*/
+// TODO(eroman): these functions should use lower-case names.
var PaintLogView;
var PrintSourceEntriesAsText;
+var proxySettingsToString;
// Start of anonymous namespace.
(function() {
@@ -258,15 +260,17 @@ function getTextForProxyConfigChangedExtraParam(entry) {
var indentation = ' ';
if (params.old_config) {
+ var oldConfigString = proxySettingsToString(params.old_config);
// The previous configuration may not be present in the case of
// the initial proxy settings fetch.
out += ' --> old_config =\n' +
- indentLines(indentation, params.old_config.split('\n'));
+ indentLines(indentation, oldConfigString.split('\n'));
out += '\n';
}
+ var newConfigString = proxySettingsToString(params.new_config);
out += ' --> new_config =\n' +
- indentLines(indentation, params.new_config.split('\n'));
+ indentLines(indentation, newConfigString.split('\n'));
return out;
}
@@ -289,6 +293,72 @@ function getTextForEvent(entry) {
return text;
}
+proxySettingsToString = function(config) {
+ if (!config)
+ return '';
+
+ // 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.
+ var modes = [];
+
+ // Output any automatic settings.
+ if (config.auto_detect)
+ modes.push(['Auto-detect']);
+ if (config.pac_url)
+ modes.push(['PAC script: ' + config.pac_url]);
+
+ // Output any manual settings.
+ if (config.single_proxy || config.proxy_per_scheme) {
+ var lines = [];
+
+ if (config.single_proxy) {
+ lines.push('Proxy server: ' + 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]);
+ }
+ }
+ if (config.proxy_per_scheme.fallback) {
+ lines.push('Proxy server for everything else: ' +
+ config.proxy_per_scheme.fallback);
+ }
+ }
+
+ // Output any proxy bypass rules.
+ if (config.bypass_list) {
+ if (config.reverse_bypass) {
+ lines.push('Reversed bypass list: ');
+ } else {
+ lines.push('Bypass list: ');
+ }
+
+ for (var i = 0; i < config.bypass_list.length; ++i)
+ lines.push(' ' + config.bypass_list[i]);
+ }
+
+ modes.push(lines);
+ }
+
+ // If we didn't find any proxy settings modes, we are using DIRECT.
+ if (modes.length < 1)
+ return 'Use DIRECT connections.';
+
+ // If there was just one mode, don't bother numbering it.
+ if (modes.length == 1)
+ return modes[0].join('\n');
+
+ // Otherwise concatenate all of the modes into a numbered list
+ // (which correspond with the fallback order).
+ var result = [];
+ for (var i = 0; i < modes.length; ++i)
+ result.push(indentLines('(' + (i + 1) + ') ', modes[i]));
+
+ return result.join('\n');
+};
+
// End of anonymous namespace.
})();
diff --git a/chrome/browser/resources/net_internals/proxyview.js b/chrome/browser/resources/net_internals/proxyview.js
index df3ea6b..6814609 100644
--- a/chrome/browser/resources/net_internals/proxyview.js
+++ b/chrome/browser/resources/net_internals/proxyview.js
@@ -44,13 +44,12 @@ ProxyView.prototype.onProxySettingsChanged = function(proxySettings) {
var original = proxySettings.original;
var effective = proxySettings.effective;
- // Both |original| and |effective| are formatted strings describing the
- // settings.
+ // Both |original| and |effective| are dictionaries describing the settings.
this.originalSettingsDiv_.innerHTML = ''
this.effectiveSettingsDiv_.innerHTML = ''
- addTextNode(this.originalSettingsDiv_, original);
- addTextNode(this.effectiveSettingsDiv_, effective);
+ addTextNode(this.originalSettingsDiv_, proxySettingsToString(original));
+ addTextNode(this.effectiveSettingsDiv_, proxySettingsToString(effective));
};
ProxyView.prototype.onBadProxiesChanged = function(badProxies) {