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

Side by Side Diff: chrome/browser/resources/options/managed_user_set_passphrase.js

Issue 14325003: Clean up managed user settings dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix broken merge Created 7 years, 8 months 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 /** @const */ var OptionsPage = options.OptionsPage; 6 /** @const */ var OptionsPage = options.OptionsPage;
7 7
8 ////////////////////////////////////////////////////////////////////////////// 8 //////////////////////////////////////////////////////////////////////////////
9 // ManagedUserSetPassphraseOverlay class: 9 // ManagedUserSetPassphraseOverlay class:
10 10
(...skipping 13 matching lines...) Expand all
24 24
25 ManagedUserSetPassphraseOverlay.prototype = { 25 ManagedUserSetPassphraseOverlay.prototype = {
26 __proto__: OptionsPage.prototype, 26 __proto__: OptionsPage.prototype,
27 27
28 /** @override */ 28 /** @override */
29 initializePage: function() { 29 initializePage: function() {
30 OptionsPage.prototype.initializePage.call(this); 30 OptionsPage.prototype.initializePage.call(this);
31 $('managed-user-passphrase').oninput = this.updateDisplay_; 31 $('managed-user-passphrase').oninput = this.updateDisplay_;
32 $('passphrase-confirm').oninput = this.updateDisplay_; 32 $('passphrase-confirm').oninput = this.updateDisplay_;
33 33
34 $('save-passphrase').onclick = this.setPassphrase_.bind(this); 34 $('save-passphrase').onclick = this.savePassphrase_.bind(this);
35 35
36 $('managed-user-passphrase').onkeypress = function(event) { 36 $('managed-user-passphrase').onkeypress = function(event) {
37 // Check if the user pressed enter and advance to the 37 // Check if the user pressed enter and advance to the
38 // confirmation field since that was probably the intention. 38 // confirmation field since that was probably the intention.
39 if (event.keyCode == 13) 39 if (event.keyCode == 13)
40 $('passphrase-confirm').focus(); 40 $('passphrase-confirm').focus();
41 }; 41 };
42 42
43 var self = this; 43 var self = this;
44 $('passphrase-confirm').onkeypress = function(event) { 44 $('passphrase-confirm').onkeypress = function(event) {
45 // Allow submitting only valid information. 45 // Allow submitting only valid information.
46 if (!$('passphrase-confirm').validity.valid || 46 if (!$('passphrase-confirm').validity.valid ||
47 !$('managed-user-passphrase').validity.valid) { 47 !$('managed-user-passphrase').validity.valid) {
48 return; 48 return;
49 } 49 }
50 // Check if the user pressed enter. 50 // Check if the user pressed enter.
51 if (event.keyCode == 13) 51 if (event.keyCode == 13)
52 self.setPassphrase_(event); 52 self.savePassphrase_(event);
53 }; 53 };
54 54
55 $('cancel-passphrase').onclick = function(event) { 55 $('cancel-passphrase').onclick = function(event) {
56 self.closePage(); 56 self.closePage();
57 }; 57 };
58 }, 58 },
59 59
60 /** Updates the display according to the validity of the user input. */ 60 /** Updates the display according to the validity of the user input. */
61 updateDisplay_: function() { 61 updateDisplay_: function() {
62 var valid = 62 var valid =
63 $('passphrase-confirm').value == $('managed-user-passphrase').value; 63 $('passphrase-confirm').value == $('managed-user-passphrase').value;
64 $('passphrase-mismatch').hidden = valid; 64 $('passphrase-mismatch').hidden = valid;
65 $('passphrase-confirm').setCustomValidity( 65 $('passphrase-confirm').setCustomValidity(
66 valid ? '' : $('passphrase-mismatch').textContent); 66 valid ? '' : $('passphrase-mismatch').textContent);
67 $('save-passphrase').disabled = 67 $('save-passphrase').disabled =
68 !$('passphrase-confirm').validity.valid || 68 !$('passphrase-confirm').validity.valid ||
69 !$('managed-user-passphrase').validity.valid; 69 !$('managed-user-passphrase').validity.valid;
70 }, 70 },
71 /** 71 /**
72 * Sets the passphrase and closes the overlay. 72 * Sets the passphrase and closes the overlay.
73 * @param {Event} event The event that triggered the call to this function. 73 * @param {Event} event The event that triggered the call to this function.
74 */ 74 */
75 setPassphrase_: function(event) { 75 savePassphrase_: function(event) {
76 chrome.send('setPassphrase', [$('managed-user-passphrase').value]); 76 chrome.send('setPassphrase', [$('managed-user-passphrase').value]);
77 this.closePage(); 77 this.closePage();
78 }, 78 },
79 79
80 /** @override */ 80 /** @override */
81 canShowPage: function() { 81 canShowPage: function() {
82 return ManagedUserSettings.getInstance().authenticationState == 82 return ManagedUserSettings.getInstance().isAuthenticated;
83 options.ManagedUserAuthentication.AUTHENTICATED;
84 }, 83 },
85 84
86 /** @override */ 85 /** @override */
87 didShowPage: function() { 86 didShowPage: function() {
88 $('managed-user-passphrase').focus(); 87 $('managed-user-passphrase').focus();
89 }, 88 },
90 89
91 /** 90 /**
92 * Make sure that we reset the fields on cancel. 91 * Make sure that we reset the fields on cancel.
93 */ 92 */
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 130 }
132 }; 131 };
133 132
134 // Export 133 // Export
135 return { 134 return {
136 ManagedUserSetPassphraseOverlay: ManagedUserSetPassphraseOverlay, 135 ManagedUserSetPassphraseOverlay: ManagedUserSetPassphraseOverlay,
137 ManagedUserSetPassphraseForTesting: ManagedUserSetPassphraseForTesting 136 ManagedUserSetPassphraseForTesting: ManagedUserSetPassphraseForTesting
138 }; 137 };
139 138
140 }); 139 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698