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

Side by Side 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 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * This view displays information on ChromeOS specific features.
7 */
8 var CrosView = (function() {
9 'use strict';
10
11 // We inherit from DivView.
12 var superClass = DivView;
13
14 var fileContent;
15 var passcode = '';
16 function importONCFile() {
17 g_browser.importONCFile(fileContent, passcode);
18 }
19
20 function setPasscode(value) {
21 passcode = value;
22 if (passcode) {
23 importONCFile();
24 }
25 }
26
27 function promptForPasscode() {
28 $('password-div').hidden = false;
29 $('onc-password').focus();
30 $('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.
31 }
32
33 function setFileContent(result) {
34 fileContent = result;
35 // Check if file is encrypted.
36 if (fileContent.search(/begin pgp message/i) == -1) {
37 // Not encrypted, don't need passcode.
38 importONCFile();
39 } else {
40 promptForPasscode();
41 }
42 }
43
44 function addEventListeners() {
45 $('import-onc').addEventListener('change', function(event) {
46 $('parse-status').hidden = true;
47 var file = event.target.files[0];
48 var reader = new FileReader();
49 reader.onloadend = function(e) {
50 setFileContent(this.result);
51 };
52 reader.readAsText(file);
53 }, false);
54
55 $('onc-password').addEventListener('change', function(event) {
56 setPasscode(this.value);
57 }, false);
58 }
59
60 function reset() {
61 fileContent = undefined;
62 passcode = '';
63 $('password-div').hidden = true;
64 }
65
66 /**
67 * @constructor
68 */
69 function CrosView() {
70 assertFirstConstructorCall(CrosView);
71
72 // Call superclass's constructor.
73 superClass.call(this, CrosView.MAIN_BOX_ID);
74
75 g_browser.addCrosONCFileParseObserver(this);
76 addEventListeners();
77 }
78
79 // ID for special HTML element in category_tabs.html
80 CrosView.TAB_HANDLE_ID = 'tab-handle-chromeos';
81
82 // IDs for special HTML elements in http_cache_view.html
83 CrosView.MAIN_BOX_ID = 'chromeos-view-tab-content';
84
85 cr.addSingletonGetter(CrosView);
86
87 CrosView.prototype = {
88 // Inherit the superclass's methods.
89 __proto__: superClass.prototype,
90
91 onONCFileParse: function(status) {
92 var parseStatus = $('parse-status');
93 parseStatus.hidden = false;
94 parseStatus.textContent = status;
95 reset();
96 }
97 };
98
99 return CrosView;
100 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698