summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources
diff options
context:
space:
mode:
authorachuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-05 01:34:34 +0000
committerachuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-05 01:34:34 +0000
commit34c6ef8c58c3df0d124439919f2a9034c5471978 (patch)
tree5d65b3d5bc2381832a3cd383075dee93cff6fb8f /chrome/browser/resources
parent7714cb32c8694e3798a5be3aa7fdcdf924080ac5 (diff)
downloadchromium_src-34c6ef8c58c3df0d124439919f2a9034c5471978.zip
chromium_src-34c6ef8c58c3df0d124439919f2a9034c5471978.tar.gz
chromium_src-34c6ef8c58c3df0d124439919f2a9034c5471978.tar.bz2
ONC import option to chromeos tab in chrome://net-internals
Add chromeos tab to chrome://net-internals. Move ONC file import input field to chromeos tab, from network options. Support for encrypted onc files. Fix net_internals browser test. BUG=chromium-os:23472,chromium-os:19397 TEST=Go to chrome://net-internals, click on chromeos tab. Should be able to import an onc file from there. If the file is encrypted, should be prompted for a passcode. Review URL: http://codereview.chromium.org/8741009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r--chrome/browser/resources/net_internals/browser_bridge.js42
-rw-r--r--chrome/browser/resources/net_internals/category_tabs.html1
-rw-r--r--chrome/browser/resources/net_internals/chromeos_view.css10
-rw-r--r--chrome/browser/resources/net_internals/chromeos_view.html12
-rw-r--r--chrome/browser/resources/net_internals/chromeos_view.js145
-rw-r--r--chrome/browser/resources/net_internals/index.html2
-rw-r--r--chrome/browser/resources/net_internals/index.js1
-rw-r--r--chrome/browser/resources/net_internals/main.css5
-rw-r--r--chrome/browser/resources/net_internals/main.js2
9 files changed, 207 insertions, 13 deletions
diff --git a/chrome/browser/resources/net_internals/browser_bridge.js b/chrome/browser/resources/net_internals/browser_bridge.js
index fa13d48..6a2d308 100644
--- a/chrome/browser/resources/net_internals/browser_bridge.js
+++ b/chrome/browser/resources/net_internals/browser_bridge.js
@@ -25,6 +25,7 @@ var BrowserBridge = (function() {
this.hstsObservers_ = [];
this.httpThrottlingObservers_ = [];
this.constantsObservers_ = [];
+ this.crosONCFileParseObservers_ = [];
this.pollableDataHelpers_ = {};
this.pollableDataHelpers_.proxySettings =
@@ -224,6 +225,10 @@ var BrowserBridge = (function() {
this.send('getSystemLog', [log_key, cellId]);
},
+ importONCFile: function(fileContent, passcode) {
+ this.send('importONCFile', [fileContent, passcode]);
+ },
+
//--------------------------------------------------------------------------
// Messages received from the browser.
//--------------------------------------------------------------------------
@@ -236,7 +241,7 @@ var BrowserBridge = (function() {
},
receivedConstants: function(constants) {
- for (var i = 0; i < this.constantsObservers_.length; ++i)
+ for (var i = 0; i < this.constantsObservers_.length; i++)
this.constantsObservers_[i].onReceivedConstants(constants);
},
@@ -283,40 +288,45 @@ var BrowserBridge = (function() {
},
receivedStartConnectionTestSuite: function() {
- for (var i = 0; i < this.connectionTestsObservers_.length; ++i)
+ for (var i = 0; i < this.connectionTestsObservers_.length; i++)
this.connectionTestsObservers_[i].onStartedConnectionTestSuite();
},
receivedStartConnectionTestExperiment: function(experiment) {
- for (var i = 0; i < this.connectionTestsObservers_.length; ++i) {
+ for (var i = 0; i < this.connectionTestsObservers_.length; i++) {
this.connectionTestsObservers_[i].onStartedConnectionTestExperiment(
experiment);
}
},
receivedCompletedConnectionTestExperiment: function(info) {
- for (var i = 0; i < this.connectionTestsObservers_.length; ++i) {
+ for (var i = 0; i < this.connectionTestsObservers_.length; i++) {
this.connectionTestsObservers_[i].onCompletedConnectionTestExperiment(
info.experiment, info.result);
}
},
receivedCompletedConnectionTestSuite: function() {
- for (var i = 0; i < this.connectionTestsObservers_.length; ++i)
+ for (var i = 0; i < this.connectionTestsObservers_.length; i++)
this.connectionTestsObservers_[i].onCompletedConnectionTestSuite();
},
receivedHSTSResult: function(info) {
- for (var i = 0; i < this.hstsObservers_.length; ++i)
+ for (var i = 0; i < this.hstsObservers_.length; i++)
this.hstsObservers_[i].onHSTSQueryResult(info);
},
+ receivedONCFileParse: function(status) {
+ for (var i = 0; i < this.crosONCFileParseObservers_.length; i++)
+ this.crosONCFileParseObservers_[i].onONCFileParse(status);
+ },
+
receivedHttpCacheInfo: function(info) {
this.pollableDataHelpers_.httpCacheInfo.update(info);
},
receivedHttpThrottlingEnabledPrefChanged: function(enabled) {
- for (var i = 0; i < this.httpThrottlingObservers_.length; ++i) {
+ for (var i = 0; i < this.httpThrottlingObservers_.length; i++) {
this.httpThrottlingObservers_[i].onHttpThrottlingEnabledPrefChanged(
enabled);
}
@@ -485,6 +495,16 @@ var BrowserBridge = (function() {
},
/**
+ * Adds a listener for ONC file parse status. The observer will be called
+ * back with:
+ *
+ * observer.onONCFileParse(status);
+ */
+ addCrosONCFileParseObserver: function(observer) {
+ this.crosONCFileParseObservers_.push(observer);
+ },
+
+ /**
* Adds a listener for HTTP throttling-related events. |observer| will be
* called back when HTTP throttling is enabled/disabled, through:
*
@@ -558,7 +578,7 @@ var BrowserBridge = (function() {
},
isObserver: function(object) {
- for (var i = 0; i < this.observerInfos_.length; ++i) {
+ for (var i = 0; i < this.observerInfos_.length; i++) {
if (this.observerInfos_[i].observer === object)
return true;
}
@@ -574,7 +594,7 @@ var BrowserBridge = (function() {
},
removeObserver: function(observer) {
- for (var i = 0; i < this.observerInfos_.length; ++i) {
+ for (var i = 0; i < this.observerInfos_.length; i++) {
if (this.observerInfos_[i].observer === observer) {
this.observerInfos_.splice(i, 1);
return;
@@ -600,7 +620,7 @@ var BrowserBridge = (function() {
}
// Notify the observers of the change, as needed.
- for (var i = 0; i < this.observerInfos_.length; ++i) {
+ for (var i = 0; i < this.observerInfos_.length; i++) {
var observerInfo = this.observerInfos_[i];
if (changed || !observerInfo.hasReceivedData ||
!observerInfo.ignoreWhenUnchanged) {
@@ -615,7 +635,7 @@ var BrowserBridge = (function() {
* (i.e. is visible).
*/
hasActiveObserver: function() {
- for (var i = 0; i < this.observerInfos_.length; ++i) {
+ for (var i = 0; i < this.observerInfos_.length; i++) {
if (this.observerInfos_[i].observer.isActive())
return true;
}
diff --git a/chrome/browser/resources/net_internals/category_tabs.html b/chrome/browser/resources/net_internals/category_tabs.html
index 037811e..e617a20 100644
--- a/chrome/browser/resources/net_internals/category_tabs.html
+++ b/chrome/browser/resources/net_internals/category_tabs.html
@@ -18,6 +18,7 @@
<!-- Tab is only shown on ChromeOS -->
<a href="#logs" id=tab-handle-logs style="display: none;">Logs</a>
<a href="#prerender" id=tab-handle-prerender>Prerender</a>
+ <a href="#chromeos" id=tab-handle-chromeos>ChromeOS</a>
</div>
<!-- Splitter Box: This is a handle to resize the vertical divider -->
diff --git a/chrome/browser/resources/net_internals/chromeos_view.css b/chrome/browser/resources/net_internals/chromeos_view.css
new file mode 100644
index 0000000..c96293f
--- /dev/null
+++ b/chrome/browser/resources/net_internals/chromeos_view.css
@@ -0,0 +1,10 @@
+/*
+ * 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.
+ * */
+
+#chromeos-view-password-div,
+#chromeos-view-parse-status {
+ margin-top: 20px;
+}
diff --git a/chrome/browser/resources/net_internals/chromeos_view.html b/chrome/browser/resources/net_internals/chromeos_view.html
new file mode 100644
index 0000000..b985ee2
--- /dev/null
+++ b/chrome/browser/resources/net_internals/chromeos_view.html
@@ -0,0 +1,12 @@
+<div id="chromeos-view-tab-content">
+ <h3>Import ONC file</h3>
+ <input type="file" id="chromeos-view-import-onc">
+ <div id="chromeos-view-password-div" hidden>
+ This onc file appears to be encrypted. Please provide the decryption key:
+ <div>
+ <input type="password" id="chromeos-view-onc-password">
+ </div>
+ </div>
+ <div id="chromeos-view-parse-status" hidden>
+ </div>
+</div>
diff --git a/chrome/browser/resources/net_internals/chromeos_view.js b/chrome/browser/resources/net_internals/chromeos_view.js
new file mode 100644
index 0000000..c20f806
--- /dev/null
+++ b/chrome/browser/resources/net_internals/chromeos_view.js
@@ -0,0 +1,145 @@
+// 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.
+
+/**
+ * This view displays information on ChromeOS specific features.
+ */
+var CrosView = (function() {
+ 'use strict';
+
+ var fileContent;
+ var passcode = '';
+
+ /**
+ * Send file contents and passcode to C++ cros network library.
+ *
+ * @private
+ */
+ function importONCFile_() {
+ if (fileContent)
+ g_browser.importONCFile(fileContent, passcode);
+ else
+ setParseStatus_(false);
+ }
+
+ /**
+ * Set the passcode var, and trigger onc import.
+ *
+ * @private
+ * @param {string} passcode
+ */
+ function setPasscode_(value) {
+ passcode = value;
+ if (passcode)
+ importONCFile_();
+ }
+
+ /**
+ * Unhide the passcode prompt input field and give it focus.
+ *
+ * @private
+ */
+ function promptForPasscode_() {
+ $(CrosView.PASSCODE_ID).hidden = false;
+ $(CrosView.PASSCODE_INPUT_ID).focus();
+ $(CrosView.PASSCODE_INPUT_ID).select();
+ }
+
+ /**
+ * Set the fileContent var, and trigger onc import if the file appears to
+ * not be encrypted, or prompt for passcode if the file is encrypted.
+ *
+ * @private
+ * @param {string} text contents of selected file.
+ */
+ function setFileContent_(result) {
+ fileContent = result;
+ // Check if file is encrypted.
+ if (fileContent.search(/begin pgp message/i) == -1) {
+ // Not encrypted, don't need passcode.
+ importONCFile_();
+ } else {
+ promptForPasscode_();
+ }
+ }
+
+ /**
+ * Set ONC file parse status.
+ *
+ * @private
+ */
+ function setParseStatus_(success) {
+ var parseStatus = $(CrosView.PARSE_STATUS_ID);
+ parseStatus.hidden = false;
+ parseStatus.textContent = status ?
+ "ONC file successfully parsed" : "ONC file parse failed";
+ reset_();
+ }
+
+ /**
+ * Add event listeners for the file selection and passcode input fields.
+ *
+ * @private
+ */
+ function addEventListeners_() {
+ $(CrosView.IMPORT_ONC_ID).addEventListener('change', function(event) {
+ $(CrosView.PARSE_STATUS_ID).hidden = true;
+ var file = event.target.files[0];
+ var reader = new FileReader();
+ reader.onloadend = function(e) {
+ setFileContent_(this.result);
+ };
+ reader.readAsText(file);
+ }, false);
+
+ $(CrosView.PASSCODE_INPUT_ID).addEventListener('change', function(event) {
+ setPasscode_(this.value);
+ }, false);
+ }
+
+ /**
+ * Reset fileContent and passcode vars.
+ *
+ * @private
+ */
+ function reset_() {
+ fileContent = undefined;
+ passcode = '';
+ $(CrosView.PASSCODE_ID).hidden = true;
+ }
+
+ /**
+ * @constructor
+ * @extends {DivView}
+ */
+ function CrosView() {
+ assertFirstConstructorCall(CrosView);
+
+ // Call superclass's constructor.
+ DivView.call(this, CrosView.MAIN_BOX_ID);
+
+ g_browser.addCrosONCFileParseObserver(this);
+ addEventListeners_();
+ }
+
+ // ID for special HTML element in category_tabs.html
+ CrosView.TAB_HANDLE_ID = 'tab-handle-chromeos';
+
+ CrosView.MAIN_BOX_ID = 'chromeos-view-tab-content';
+ CrosView.IMPORT_ONC_ID = 'chromeos-view-import-onc';
+ CrosView.PASSCODE_ID = 'chromeos-view-password-div';
+ CrosView.PASSCODE_INPUT_ID = 'chromeos-view-onc-password';
+ CrosView.PARSE_STATUS_ID = 'chromeos-view-parse-status';
+
+ cr.addSingletonGetter(CrosView);
+
+ CrosView.prototype = {
+ // Inherit from DivView.
+ __proto__: DivView.prototype,
+
+ onONCFileParse: setParseStatus_,
+ };
+
+ return CrosView;
+})();
diff --git a/chrome/browser/resources/net_internals/index.html b/chrome/browser/resources/net_internals/index.html
index 605e993..a1944bf 100644
--- a/chrome/browser/resources/net_internals/index.html
+++ b/chrome/browser/resources/net_internals/index.html
@@ -11,6 +11,7 @@ found in the LICENSE file.
<link rel="stylesheet" href="timeline_view.css">
<link rel="stylesheet" href="logs_view.css">
<link rel="stylesheet" href="tab_switcher_view.css">
+ <link rel="stylesheet" href="chromeos_view.css">
<script src="chrome://resources/js/util.js"></script>
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://net-internals/index.js"></script>
@@ -46,6 +47,7 @@ found in the LICENSE file.
<include src="events_view.html"/>
<include src="timeline_view.html"/>
<include src="logs_view.html"/>
+ <include src="chromeos_view.html"/>
<script src="chrome://resources/js/i18n_template.js"></script>
<script src="chrome://resources/js/i18n_process.js"></script>
diff --git a/chrome/browser/resources/net_internals/index.js b/chrome/browser/resources/net_internals/index.js
index 936f044..b67f9fa 100644
--- a/chrome/browser/resources/net_internals/index.js
+++ b/chrome/browser/resources/net_internals/index.js
@@ -38,6 +38,7 @@
<include src="http_throttling_view.js"/>
<include src="logs_view.js"/>
<include src="prerender_view.js"/>
+<include src="chromeos_view.js"/>
document.addEventListener('DOMContentLoaded', function() {
MainView.getInstance(); // from main.js
diff --git a/chrome/browser/resources/net_internals/main.css b/chrome/browser/resources/net_internals/main.css
index 230c50e..3b7c2ed 100644
--- a/chrome/browser/resources/net_internals/main.css
+++ b/chrome/browser/resources/net_internals/main.css
@@ -57,8 +57,9 @@ body {
#test-view-tab-content,
#hsts-view-tab-content,
#http-throttling-view-tab-content,
+#logs-view-tab-content,
#prerender-view-tab-content,
-#logs-view-tab-content {
+#chromeos-view-tab-content {
overflow: auto;
padding: 10px;
}
@@ -67,7 +68,7 @@ body {
* Styles for TABLE that uses a thin collapsed border.
*/
table.styledTable {
- border-collapse:collapse;
+ border-collapse: collapse;
}
table.styledTable,
diff --git a/chrome/browser/resources/net_internals/main.js b/chrome/browser/resources/net_internals/main.js
index e1334e2..f5b39ae 100644
--- a/chrome/browser/resources/net_internals/main.js
+++ b/chrome/browser/resources/net_internals/main.js
@@ -102,6 +102,8 @@ var MainView = (function() {
false, cr.isChromeOS);
tabs.addTab(PrerenderView.TAB_HANDLE_ID, PrerenderView.getInstance(),
false, true);
+ tabs.addTab(CrosView.TAB_HANDLE_ID, CrosView.getInstance(),
+ false, cr.isChromeOS);
// Build a map from the anchor name of each tab handle to its "tab ID".
// We will consider navigations to the #hash as a switch tab request.