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

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: review feedback 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.
James Hawkins 2011/12/02 22:08:57 Don't use 'we' in comments; it's ambiguous.
achuithb 2011/12/03 00:23:32 Done.
12 var superClass = DivView;
James Hawkins 2011/12/02 22:08:57 Just use DivView directly.
achuithb 2011/12/03 00:23:32 Done.
13
14 var fileContent;
James Hawkins 2011/12/02 22:08:57 Are these 'private' vars?
achuithb 2011/12/03 00:23:32 Yes - they are in anonymous function scope.
James Hawkins 2011/12/04 18:13:07 OK. Append '_' to the name, document the vars, mak
achuithb 2011/12/04 21:56:42 Done.
15 var passcode = '';
16 function importONCFile() {
17 if (fileContent) {
James Hawkins 2011/12/02 22:08:57 No braces for single-line blocks.
achuithb 2011/12/03 00:23:32 Done.
18 g_browser.importONCFile(fileContent, passcode);
19 }
20 }
21
22 function setPasscode(value) {
23 passcode = value;
24 if (passcode) {
25 importONCFile();
26 }
27 }
28
29 function promptForPasscode() {
30 $(CrosView.PASSWORD_ID).hidden = false;
31 $(CrosView.PASSWORD_INPUT_ID).focus();
32 $(CrosView.PASSWORD_INPUT_ID).select();
33 }
34
35 function setFileContent(result) {
36 fileContent = result;
37 // Check if file is encrypted.
38 if (fileContent.search(/begin pgp message/i) == -1) {
39 // Not encrypted, don't need passcode.
40 importONCFile();
41 } else {
42 promptForPasscode();
43 }
44 }
45
46 function addEventListeners() {
James Hawkins 2011/12/02 22:08:57 Document all of these methods.
achuithb 2011/12/03 00:23:32 Done.
47 $(CrosView.IMPORT_ONC_ID).addEventListener('change', function(event) {
48 $(CrosView.PARSE_STATUS_ID).hidden = true;
49 var file = event.target.files[0];
50 var reader = new FileReader();
51 reader.onloadend = function(e) {
52 setFileContent(this.result);
53 };
54 reader.readAsText(file);
55 }, false);
56
57 $(CrosView.PASSWORD_INPUT_ID).addEventListener('change', function(event) {
58 setPasscode(this.value);
59 }, false);
60 }
61
62 function reset() {
63 fileContent = undefined;
64 passcode = '';
65 $(CrosView.PASSWORD_ID).hidden = true;
66 }
67
68 /**
69 * @constructor
James Hawkins 2011/12/02 22:08:57 @extends
achuithb 2011/12/03 00:23:32 Done.
70 */
71 function CrosView() {
72 assertFirstConstructorCall(CrosView);
73
74 // Call superclass's constructor.
75 superClass.call(this, CrosView.MAIN_BOX_ID);
76
77 g_browser.addCrosONCFileParseObserver(this);
78 addEventListeners();
79 }
80
81 // ID for special HTML element in category_tabs.html
82 CrosView.TAB_HANDLE_ID = 'tab-handle-chromeos';
83
84 CrosView.MAIN_BOX_ID = 'chromeos-view-tab-content';
85 CrosView.IMPORT_ONC_ID = 'chromeos-view-import-onc';
86 CrosView.PASSWORD_ID = 'chromeos-view-password-div';
87 CrosView.PASSWORD_INPUT_ID = 'chromeos-view-onc-password';
88 CrosView.PARSE_STATUS_ID = 'chromeos-view-parse-status';
89
90 cr.addSingletonGetter(CrosView);
91
92 CrosView.prototype = {
93 // Inherit the superclass's methods.
94 __proto__: superClass.prototype,
95
96 onONCFileParse: function(status) {
97 var parseStatus = $(CrosView.PARSE_STATUS_ID);
98 parseStatus.hidden = false;
99 parseStatus.textContent = status;
100 reset();
101 }
102 };
103
104 return CrosView;
105 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698