Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: chrome/browser/resources/net_internals/chromeos_view.js

Issue 8741009: ONC import option to chromeos tab in chrome://net-internals (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: nits Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/net_internals/chromeos_view.js
===================================================================
--- chrome/browser/resources/net_internals/chromeos_view.js (revision 0)
+++ chrome/browser/resources/net_internals/chromeos_view.js (revision 0)
@@ -0,0 +1,100 @@
+// 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';
+
+ // We inherit from DivView.
+ var superClass = DivView;
+
+ var fileContent;
+ var passcode = '';
+ function importONCFile() {
+ g_browser.importONCFile(fileContent, passcode);
+ }
+
+ function setPasscode(value) {
+ passcode = value;
+ if (passcode) {
+ importONCFile();
+ }
+ }
+
+ function promptForPasscode() {
+ $('password-div').hidden = false;
+ $('onc-password').focus();
+ $('onc-password').select();
mmenke 2011/12/01 19:33:35 Could you declare all these at the top, like all t
achuithb 2011/12/02 05:25:42 Done.
+ }
+
+ 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();
+ }
+ }
+
+ function addEventListeners() {
+ $('import-onc').addEventListener('change', function(event) {
+ $('parse-status').hidden = true;
+ var file = event.target.files[0];
+ var reader = new FileReader();
+ reader.onloadend = function(e) {
+ setFileContent(this.result);
+ };
+ reader.readAsText(file);
+ }, false);
+
+ $('onc-password').addEventListener('change', function(event) {
+ setPasscode(this.value);
+ }, false);
+ }
+
+ function reset() {
+ fileContent = undefined;
+ passcode = '';
+ $('password-div').hidden = true;
+ }
+
+ /**
+ * @constructor
+ */
+ function CrosView() {
+ assertFirstConstructorCall(CrosView);
+
+ // Call superclass's constructor.
+ superClass.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';
+
+ // IDs for special HTML elements in http_cache_view.html
+ CrosView.MAIN_BOX_ID = 'chromeos-view-tab-content';
+
+ cr.addSingletonGetter(CrosView);
+
+ CrosView.prototype = {
+ // Inherit the superclass's methods.
+ __proto__: superClass.prototype,
+
+ onONCFileParse: function(status) {
+ var parseStatus = $('parse-status');
+ parseStatus.hidden = false;
+ parseStatus.textContent = status;
+ reset();
+ }
+ };
+
+ return CrosView;
+})();
Property changes on: chrome/browser/resources/net_internals/chromeos_view.js
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698