summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-10 22:45:56 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-10 22:45:56 +0000
commit3334c0d1ab15bc3c45f98bf8f63e8eb75c851c2b (patch)
treeb38b27efb689dd985769f272a8311c51e2fd2ad6
parent3186e828aa5b8c917f166f93ef63969284cfa892 (diff)
downloadchromium_src-3334c0d1ab15bc3c45f98bf8f63e8eb75c851c2b.zip
chromium_src-3334c0d1ab15bc3c45f98bf8f63e8eb75c851c2b.tar.gz
chromium_src-3334c0d1ab15bc3c45f98bf8f63e8eb75c851c2b.tar.bz2
Display the text dump for chrome://net2#data inline, rather than in a new window, to avoid having to use a data:URL (large data URLs do not work in Chrome).
Also gets rid of the JSON output (since it isn't needed right now, and just adds clutter). BUG=37421 Review URL: http://codereview.chromium.org/2052003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46866 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/net_internals/dataview.js90
-rw-r--r--chrome/browser/resources/net_internals/index.html6
-rw-r--r--chrome/browser/resources/net_internals/main.js3
3 files changed, 13 insertions, 86 deletions
diff --git a/chrome/browser/resources/net_internals/dataview.js b/chrome/browser/resources/net_internals/dataview.js
index 8b87a0d..97b6ac4 100644
--- a/chrome/browser/resources/net_internals/dataview.js
+++ b/chrome/browser/resources/net_internals/dataview.js
@@ -12,80 +12,23 @@
*
* @constructor
*/
-function DataView(mainBoxId, exportJsonButtonId, exportTextButtonId) {
+function DataView(mainBoxId, outputTextBoxId, exportTextButtonId) {
DivView.call(this, mainBoxId);
- var exportJsonButton = document.getElementById(exportJsonButtonId);
+ this.textPre_ = document.getElementById(outputTextBoxId);
var exportTextButton = document.getElementById(exportTextButtonId);
- exportJsonButton.onclick = this.onExportToJSON_.bind(this);
exportTextButton.onclick = this.onExportToText_.bind(this);
}
inherits(DataView, DivView);
/**
- * Very simple output format which directly displays the internally captured
- * data in its javascript format.
- */
-DataView.prototype.onExportToJSON_ = function() {
- // Format some text describing the data we have captured.
- var text = []; // Lines of text.
-
- text.push('//----------------------------------------------');
- text.push('// Proxy settings');
- text.push('//----------------------------------------------');
- text.push('');
-
- text.push('proxySettings = ' +
- JSON.stringify(g_browser.proxySettings_.currentData_));
-
- text.push('');
- text.push('//----------------------------------------------');
- text.push('// Bad proxies');
- text.push('//----------------------------------------------');
- text.push('');
-
- text.push('badProxies = ' +
- JSON.stringify(g_browser.badProxies_.currentData_));
-
- text.push('');
- text.push('//----------------------------------------------');
- text.push('// Host resolver cache');
- text.push('//----------------------------------------------');
- text.push('');
-
- text.push('hostResolverCache = ' +
- JSON.stringify(g_browser.hostResolverCache_.currentData_));
-
- text.push('');
- text.push('//----------------------------------------------');
- text.push('// Passively captured events');
- text.push('//----------------------------------------------');
- text.push('');
-
- this.appendPrettyPrintedJsonArray_('passive',
- g_browser.getAllPassivelyCapturedEvents(),
- text);
-
- text.push('');
- text.push('//----------------------------------------------');
- text.push('// Actively captured events');
- text.push('//----------------------------------------------');
- text.push('');
-
- this.appendPrettyPrintedJsonArray_('active',
- g_browser.getAllActivelyCapturedEvents(),
- text);
-
- // Open a new window to display this text.
- this.displayPopupWindow_(text.join('\n'));
-};
-
-/**
* Presents the captured data as formatted text.
*/
DataView.prototype.onExportToText_ = function() {
+ this.setText_("Generating...");
+
var text = [];
// Print some basic information about our environment.
@@ -150,7 +93,7 @@ DataView.prototype.onExportToText_ = function() {
this.appendRequestsPrintedAsText_(text);
// Open a new window to display this text.
- this.displayPopupWindow_(text.join('\n'));
+ this.setText_(text.join('\n'));
};
DataView.prototype.appendRequestsPrintedAsText_ = function(out) {
@@ -202,26 +145,11 @@ DataView.prototype.appendRequestsPrintedAsText_ = function(out) {
};
/**
- * Helper function to open a new window and display |text| in it.
- */
-DataView.prototype.displayPopupWindow_ = function(text) {
- // Note that we use a data:URL because the chrome:// URL scheme doesn't
- // allow us to mutate any new windows we open.
- dataUrl = 'data:text/plain,' + encodeURIComponent(text);
- window.open(dataUrl, '_blank');
-};
-
-/**
- * Stringifies |arrayData| as JSON-like output, and appends it to the
- * line buffer |out|.
+ * Helper function to set this view's content to |text|.
*/
-DataView.prototype.appendPrettyPrintedJsonArray_ = function(name,
- arrayData,
- out) {
- out.push(name + ' = [];');
- for (var i = 0; i < arrayData.length; ++i) {
- out.push(name + '[' + i + '] = ' + JSON.stringify(arrayData[i]) + ';');
- }
+DataView.prototype.setText_ = function(text) {
+ this.textPre_.innerHTML = '';
+ addTextNode(this.textPre_, text);
};
/**
diff --git a/chrome/browser/resources/net_internals/index.html b/chrome/browser/resources/net_internals/index.html
index d190de3..0c2a336 100644
--- a/chrome/browser/resources/net_internals/index.html
+++ b/chrome/browser/resources/net_internals/index.html
@@ -99,10 +99,8 @@ found in the LICENSE file.
</div>
<!-- Import/Export data -->
<div id=dataTabContent>
- <button id=exportToText><b>Click here to generate bug report data</b><br/>(Copy paste the result and attach to bug)</button>
- <br/>
- <br/>
- <button id=exportToJson>Export data to JSON</button>
+ <button id=exportToText><b>Dump to text</b></button>
+ <pre id=exportedDataText></pre>
</div>
<!-- Connection tests -->
<div id=testTabContent>
diff --git a/chrome/browser/resources/net_internals/main.js b/chrome/browser/resources/net_internals/main.js
index 91135d0..ba61101 100644
--- a/chrome/browser/resources/net_internals/main.js
+++ b/chrome/browser/resources/net_internals/main.js
@@ -59,7 +59,8 @@ function onLoaded() {
// Create a view which will display import/export options to control the
// captured data.
- var dataView = new DataView("dataTabContent", "exportToJson", "exportToText");
+ var dataView = new DataView("dataTabContent", "exportedDataText",
+ "exportToText");
// Create a view which will display the results and controls for connection
// tests.