summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-25 21:19:29 +0000
committertsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-25 21:19:29 +0000
commit63a2139b9c84f0d50022f1dd7a1c10c968f8fc8d (patch)
treede7d7e2d26d5ccdee82671daa4f278f2e92c355a
parenta4d36fdc0517732773bd5dd5d8b2e8f78db0546f (diff)
downloadchromium_src-63a2139b9c84f0d50022f1dd7a1c10c968f8fc8d.zip
chromium_src-63a2139b9c84f0d50022f1dd7a1c10c968f8fc8d.tar.gz
chromium_src-63a2139b9c84f0d50022f1dd7a1c10c968f8fc8d.tar.bz2
Apply content-security-policy to chrome://net-internals. Also get rid of yucky data: urls and serve help page from this UI source as well.
Review URL: http://codereview.chromium.org/7455005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93953 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/net_internals/help.html69
-rw-r--r--chrome/browser/resources/net_internals/help.js7
-rw-r--r--chrome/browser/resources/net_internals/index.html116
-rw-r--r--chrome/browser/resources/net_internals/index.js37
-rw-r--r--chrome/browser/resources/net_internals_resources.grd5
-rw-r--r--chrome/browser/ui/webui/net_internals_ui.cc78
-rw-r--r--chrome/test/functional/special_tabs.py5
7 files changed, 148 insertions, 169 deletions
diff --git a/chrome/browser/resources/net_internals/help.html b/chrome/browser/resources/net_internals/help.html
new file mode 100644
index 0000000..d3abf5e
--- /dev/null
+++ b/chrome/browser/resources/net_internals/help.html
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML>
+<html>
+<!-- Copyright (c) 2011 The Chromium Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style license that can be
+ found in the LICENSE file.
+-->
+<head>
+ <include src="../content_security_policy.html"/>
+</head>
+<body>
+<div id=howtoDumpForBugsHelpContent>
+<h2>How to get data for bug reports</h2>
+
+<ol>
+<li>Reproduce the network problem.</li>
+<li>Click the <i>Dump to file</i> button in the <i>Data</i> tab.</li>
+
+<li>The log file will act like a normal download.</li>
+
+<li>Email the log file to the bug investigator,
+ <b>along with an explanation of what went wrong, including any relevant
+ URLs.</b>
+ You may want to compress the file before sending, as the log files can be
+ fairly large but compress well.
+</li>
+
+</ol>
+
+
+<ul>
+<li>The network log <b>may contain personally identifying information</b> like
+ IP addresses, URLs, and cookies.</li>
+<ul>
+<li>You can edit the log to obscure information if you like, but sometimes it
+ is relevant to the bug. If you choose do this, please make sure you can still
+ load the log file.</li>
+<li>If you choose not to have cookies removed from the log, you must toggle
+ the checkbox before clicking the button.</li>
+</ul>
+<li>Ideally you would have the tool running <b>before</b> you reproduce the
+ bug.
+ If that isn't possible (perhaps the bug happens unpredictably), then the
+ next best thing is to load chrome://net-internals/ <b>as soon as you can
+ after</b> the problem has occurred.</li>
+</ul>
+
+<h2>How it works</h2>
+
+<ul>
+ <li>While the net-internals page is open, it will capture the network events
+ that are happening in Chrome. You can view that in real-time by going to
+ the <i>Events</i> tab.</li>
+ <li>Once you close the net-internals window, the data it had captured will be
+ discarded.</li>
+<li>Chrome keeps around a small buffer of the most recent network events
+ even when the net-internals window is not open. That way if you open
+ chrome://net-internals/ <b>shortly after</b> encountering a problem,
+ you may still find the relevant data.
+ These <i>passively captured</i> events are less accurate however, and will
+ be prefixed in the log with <span style="font-family: monospace;">(P)</span>.
+</li>
+</ul>
+
+<button id="popup-close-button">Close this popup</button>
+</div>
+<script src="chrome://resources/js/util.js"></scirpt>
+<script src="chrome://net-internals/help.js"></script>
+</body>
+</html>
diff --git a/chrome/browser/resources/net_internals/help.js b/chrome/browser/resources/net_internals/help.js
new file mode 100644
index 0000000..8bb883c
--- /dev/null
+++ b/chrome/browser/resources/net_internals/help.js
@@ -0,0 +1,7 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+document.addEventListener('DOMContentLoaded', function () {
+ $('popup-close-button').addEventListener('click', window.close.bind(window));
+});
diff --git a/chrome/browser/resources/net_internals/index.html b/chrome/browser/resources/net_internals/index.html
index d97ff93..fd54cdf 100644
--- a/chrome/browser/resources/net_internals/index.html
+++ b/chrome/browser/resources/net_internals/index.html
@@ -1,41 +1,20 @@
<!DOCTYPE HTML>
-<head i18n-values="dir:textdirection;">
+<html>
<!--
Copyright (c) 2011 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
- <head>
+ <head i18n-values="dir:textdirection;">
+ <include src="../content_security_policy.html"/>
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="tabswitcherview.css">
- <script src="util.js"></script>
- <script src="view.js"></script>
- <script src="tabswitcherview.js"></script>
- <script src="dataview.js"></script>
- <script src="httpcacheview.js"></script>
- <script src="testview.js"></script>
- <script src="hstsview.js"></script>
- <script src="logdumputil.js"></script>
- <script src="main.js"></script>
- <script src="dnsview.js"></script>
- <script src="eventsview.js"></script>
- <script src="detailsview.js"></script>
- <script src="sourceentry.js"></script>
- <script src="resizableverticalsplitview.js"></script>
- <script src="topmidbottomview.js"></script>
- <script src="timelineviewpainter.js"></script>
- <script src="logviewpainter.js"></script>
- <script src="loggrouper.js"></script>
- <script src="proxyview.js"></script>
- <script src="socketpoolwrapper.js"></script>
- <script src="socketsview.js"></script>
- <script src="spdyview.js"></script>
- <script src="serviceprovidersview.js"></script>
- <script src="httpthrottlingview.js"></script>
- <script src="logsview.js"></script>
- <script src="prerenderview.js"></script>
+ <script src="chrome://resources/js/util.js"</script>
+ <script src="chrome://net-internals/index.js"></script>
+ <script src="chrome://net-internals/strings.js"></script>
</head>
- <body onload="onLoaded()" id=dataViewDropTarget>
+ <body id=dataViewDropTarget>
+
<!-- Tab switcher for main categories. -->
<div id=categoryTabHandles>
<ul>
@@ -278,7 +257,7 @@ found in the LICENSE file.
Strip private information (cookies and credentials).
</p>
<p>
- <a href="javascript:displayHelpForBugDump()">
+ <a href="chrome://net-internals/help.html" target="_blank">
Help: How to get data for bug reports?
</a>
</p>
@@ -305,7 +284,7 @@ found in the LICENSE file.
</p>
<p>Once a log is loaded, this page will stop collecting data, and will
only start gathering data again when
- <a href="javascript:history.go(0);">reloaded</a>.
+ <a id="reloaded-link" href="#">reloaded</a>.
</p>
</div>
</div>
@@ -340,79 +319,11 @@ found in the LICENSE file.
</tr>
</table>
-
+
<iframe style="display: none" id=dataViewDownloadIframe></iframe>
</div>
-<!-- START OF HELP TEXT -->
-<script>
-function displayHelpForBugDump() {
- // We can't access the popups loaded from WebUI pages, so we instead populate
- // its contents using a data:URL. YUCK!
- // TODO(eroman): do something less hacky, like exposing a new URL.
- var helpContents =
- document.getElementById('howtoDumpForBugsHelpContent').innerHTML;
- window.open('data:text/html,' + encodeURIComponent(helpContents));
-}
-</script>
-<div id=howtoDumpForBugsHelpContent style="display: none">
-<h2>How to get data for bug reports</h2>
-
-<ol>
-<li>Reproduce the network problem.</li>
-<li>Click the <i>Dump to file</i> button in the <i>Data</i> tab.</li>
-
-<li>The log file will act like a normal download.</li>
-
-<li>Email the log file to the bug investigator,
- <b>along with an explanation of what went wrong, including any relevant
- URLs.</b>
- You may want to compress the file before sending, as the log files can be
- fairly large but compress well.
-</li>
-
-</ol>
-
-
-<ul>
-<li>The network log <b>may contain personally identifying information</b> like
- IP addresses, URLs, and cookies.</li>
-<ul>
-<li>You can edit the log to obscure information if you like, but sometimes it
- is relevant to the bug. If you choose do this, please make sure you can still
- load the log file.</li>
-<li>If you choose not to have cookies removed from the log, you must toggle
- the checkbox before clicking the button.</li>
-</ul>
-<li>Ideally you would have the tool running <b>before</b> you reproduce the
- bug.
- If that isn't possible (perhaps the bug happens unpredictably), then the
- next best thing is to load chrome://net-internals/ <b>as soon as you can
- after</b> the problem has occurred.</li>
-</ul>
-
-<h2>How it works</h2>
-
-<ul>
- <li>While the net-internals page is open, it will capture the network events
- that are happening in Chrome. You can view that in real-time by going to
- the <i>Events</i> tab.</li>
- <li>Once you close the net-internals window, the data it had captured will be
- discarded.</li>
-<li>Chrome keeps around a small buffer of the most recent network events
- even when the net-internals window is not open. That way if you open
- chrome://net-internals/ <b>shortly after</b> encountering a problem,
- you may still find the relevant data.
- These <i>passively captured</i> events are less accurate however, and will
- be prefixed in the log with <span style="font-family: monospace;">(P)</span>.
-</li>
-</ul>
-
-<button onclick='window.close()'>Close this popup</button>
-<!-- END OF HELP TEXT -->
-</div>
-
<!-- Connection tests -->
<div id=testTabContent>
<p>Input a URL which failed to load, and then click the button to run some
@@ -516,7 +427,7 @@ function displayHelpForBugDump() {
</div>
<div id=detailsLogBox></div>
<div id=detailsTimelineBox></div>
-
+
<!-- ============================ Logs View ============================ -->
<div id=logsTabContent style="display: none;">
<h4>Network Log Data</h4>
@@ -536,5 +447,8 @@ function displayHelpForBugDump() {
</tbody>
</table>
</div>
+ <script src="chrome://resources/js/i18n_template.js"></script>
+ <script src="chrome://resources/js/i18n_process.js"></script>
+ <script src="chrome://resources/js/jstemplate_compiled.js"></script>
</body>
</html>
diff --git a/chrome/browser/resources/net_internals/index.js b/chrome/browser/resources/net_internals/index.js
new file mode 100644
index 0000000..8197867
--- /dev/null
+++ b/chrome/browser/resources/net_internals/index.js
@@ -0,0 +1,37 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+<include src="util.js"/>
+<include src="view.js"/>
+<include src="tabswitcherview.js"/>
+<include src="dataview.js"/>
+<include src="httpcacheview.js"/>
+<include src="testview.js"/>
+<include src="hstsview.js"/>
+<include src="logdumputil.js"/>
+<include src="main.js"/>
+<include src="dnsview.js"/>
+<include src="eventsview.js"/>
+<include src="detailsview.js"/>
+<include src="sourceentry.js"/>
+<include src="resizableverticalsplitview.js"/>
+<include src="topmidbottomview.js"/>
+<include src="timelineviewpainter.js"/>
+<include src="logviewpainter.js"/>
+<include src="loggrouper.js"/>
+<include src="proxyview.js"/>
+<include src="socketpoolwrapper.js"/>
+<include src="socketsview.js"/>
+<include src="spdyview.js"/>
+<include src="serviceprovidersview.js"/>
+<include src="httpthrottlingview.js"/>
+<include src="logsview.js"/>
+<include src="prerenderview.js"/>
+
+document.addEventListener('DOMContentLoaded', function () {
+ $('reloaded-link').addEventListener('click', function () {
+ history.go(0);
+ });
+ onLoaded(); // from main.js
+});
diff --git a/chrome/browser/resources/net_internals_resources.grd b/chrome/browser/resources/net_internals_resources.grd
index 1f10731..c0fd2fa 100644
--- a/chrome/browser/resources/net_internals_resources.grd
+++ b/chrome/browser/resources/net_internals_resources.grd
@@ -17,7 +17,10 @@
</outputs>
<release seq="1">
<includes>
- <include name="IDR_NET_INTERNALS_INDEX_HTML" file="net_internals/index.html" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_NET_INTERNALS_HELP_HTML" file="net_internals/help.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
+ <include name="IDR_NET_INTERNALS_HELP_JS" file="net_internals/help.js" type="BINDATA" />
+ <include name="IDR_NET_INTERNALS_INDEX_HTML" file="net_internals/index.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
+ <include name="IDR_NET_INTERNALS_INDEX_JS" file="net_internals/index.js" flattenhtml="true" type="BINDATA" />
</includes>
</release>
</grit>
diff --git a/chrome/browser/ui/webui/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals_ui.cc
index 69a9261..bef57d6 100644
--- a/chrome/browser/ui/webui/net_internals_ui.cc
+++ b/chrome/browser/ui/webui/net_internals_ui.cc
@@ -32,6 +32,7 @@
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_version_info.h"
@@ -129,21 +130,17 @@ Value* ExperimentToValue(const ConnectionTester::Experiment& experiment) {
return dict;
}
-class NetInternalsHTMLSource : public ChromeURLDataManager::DataSource {
- public:
- NetInternalsHTMLSource();
-
- // Called when the network layer has requested a resource underneath
- // the path we registered.
- virtual void StartDataRequest(const std::string& path,
- bool is_incognito,
- int request_id);
- virtual std::string GetMimeType(const std::string&) const;
+ChromeWebUIDataSource* CreateNetInternalsHTMLSource() {
+ ChromeWebUIDataSource* source =
+ new ChromeWebUIDataSource(chrome::kChromeUINetInternalsHost);
- private:
- ~NetInternalsHTMLSource() {}
- DISALLOW_COPY_AND_ASSIGN(NetInternalsHTMLSource);
-};
+ source->set_default_resource(IDR_NET_INTERNALS_INDEX_HTML);
+ source->add_resource_path("help.html", IDR_NET_INTERNALS_HELP_HTML);
+ source->add_resource_path("help.js", IDR_NET_INTERNALS_HELP_JS);
+ source->add_resource_path("index.js", IDR_NET_INTERNALS_INDEX_JS);
+ source->set_json_path("strings.js");
+ return source;
+}
// This class receives javascript messages from the renderer.
// Note that the WebUI infrastructure runs on the UI thread, therefore all of
@@ -450,54 +447,6 @@ class NetInternalsMessageHandler::IOThreadImpl::CallbackHelper
////////////////////////////////////////////////////////////////////////////////
//
-// NetInternalsHTMLSource
-//
-////////////////////////////////////////////////////////////////////////////////
-
-NetInternalsHTMLSource::NetInternalsHTMLSource()
- : DataSource(chrome::kChromeUINetInternalsHost, MessageLoop::current()) {
-}
-
-void NetInternalsHTMLSource::StartDataRequest(const std::string& path,
- bool is_incognito,
- int request_id) {
- DictionaryValue localized_strings;
- SetFontAndTextDirection(&localized_strings);
-
- // The provided "path" may contain a fragment, or query section. We only
- // care about the path itself, and will disregard anything else.
- std::string filename =
- GURL(std::string("chrome://net/") + path).path().substr(1);
-
- // The source for the net internals page is flattened during compilation, so
- // the only resource that should legitimately be requested is the main file.
- // Note that users can type anything into the address bar, though, so we must
- // handle arbitrary input.
- if (filename.empty() || filename == "index.html") {
- base::StringPiece html(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_NET_INTERNALS_INDEX_HTML));
- std::string full_html(html.data(), html.size());
- jstemplate_builder::AppendJsonHtml(&localized_strings, &full_html);
- jstemplate_builder::AppendI18nTemplateSourceHtml(&full_html);
- jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html);
- jstemplate_builder::AppendJsTemplateSourceHtml(&full_html);
-
- SendResponse(request_id, base::RefCountedString::TakeString(&full_html));
- return;
- }
-
- std::string data_string("<p style='color:red'>Failed to read resource" +
- EscapeForHTML(filename) + "</p>");
- SendResponse(request_id, base::RefCountedString::TakeString(&data_string));
-}
-
-std::string NetInternalsHTMLSource::GetMimeType(const std::string&) const {
- return "text/html";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
// NetInternalsMessageHandler
//
////////////////////////////////////////////////////////////////////////////////
@@ -1609,8 +1558,7 @@ Value* NetInternalsUI::GetConstants() {
NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) {
AddMessageHandler((new NetInternalsMessageHandler())->Attach(this));
- NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource();
-
// Set up the chrome://net-internals/ source.
- GetProfile()->GetChromeURLDataManager()->AddDataSource(html_source);
+ GetProfile()->GetChromeURLDataManager()->AddDataSource(
+ CreateNetInternalsHTMLSource());
}
diff --git a/chrome/test/functional/special_tabs.py b/chrome/test/functional/special_tabs.py
index 798beb8..8ca7c36 100644
--- a/chrome/test/functional/special_tabs.py
+++ b/chrome/test/functional/special_tabs.py
@@ -60,7 +60,8 @@ class SpecialTabsTest(pyauto.PyUITest):
'chrome://history2': { 'title': 'History', 'CSP': False },
'chrome://media-internals': { 'title': 'Media Internals', 'CSP': False },
'chrome://memory-redirect': { 'title': 'About Memory' },
- 'chrome://net-internals': { 'CSP': False },
+ 'chrome://net-internals': {},
+ 'chrome://net-internals/help.html': {},
'chrome://newtab': { 'title': 'New Tab', 'CSP': False },
'chrome://plugins': { 'title': 'Plug-ins' },
'chrome://sessions': { 'title': 'Sessions', 'CSP': False },
@@ -286,7 +287,7 @@ class SpecialTabsTest(pyauto.PyUITest):
else:
include_list.extend(['X-WebKit-CSP'])
exclude_list.extend(['<script>', 'onclick=', 'onload=',
- 'onchange=', 'onsubmit='])
+ 'onchange=', 'onsubmit=', 'javascript:'])
if 'includes' in properties:
include_list.extend(properties['includes'])
if 'excludes' in properties: