OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 cr.define('options', function() { | |
6 /** @const */ var OptionsPage = options.OptionsPage; | |
7 | |
8 ////////////////////////////////////////////////////////////////////////////// | |
9 // ManagedUserSetPassphraseOverlay class: | |
10 | |
11 /** | |
12 * Encapsulated handling of the Managed User Set Passphrase page. | |
13 * @constructor | |
14 */ | |
15 function ManagedUserSetPassphraseOverlay() { | |
16 OptionsPage.call( | |
17 this, | |
18 'setPassphrase', | |
19 loadTimeData.getString('setPassphraseTitle'), | |
20 'managed-user-set-passphrase-overlay'); | |
21 } | |
22 | |
23 cr.addSingletonGetter(ManagedUserSetPassphraseOverlay); | |
24 | |
25 ManagedUserSetPassphraseOverlay.prototype = { | |
26 __proto__: OptionsPage.prototype, | |
27 | |
28 /** @override */ | |
29 initializePage: function() { | |
30 OptionsPage.prototype.initializePage.call(this); | |
31 $('managed-user-passphrase').oninput = this.updateDisplay_; | |
32 $('passphrase-confirm').oninput = this.updateDisplay_; | |
33 | |
34 $('save-passphrase').onclick = function() { | |
35 chrome.send('setPassphrase', [$('managed-user-passphrase').value]); | |
36 $('managed-user-passphrase').value = ''; | |
37 $('passphrase-confirm').value = ''; | |
38 OptionsPage.closeOverlay(); | |
39 }; | |
40 }, | |
41 updateDisplay_: function() { | |
42 var valid = | |
43 $('passphrase-confirm').value == $('managed-user-passphrase').value; | |
44 $('passphrase-mismatch').hidden = valid; | |
45 $('passphrase-confirm').setCustomValidity( | |
46 valid ? '' : $('passphrase-mismatch').textContent); | |
47 $('save-passphrase').disabled = | |
48 !$('passphrase-confirm').validity.valid || | |
49 !$('managed-user-passphrase').validity.valid; | |
50 }, | |
51 /** @override */ | |
52 canShowPage: function() { | |
53 return ManagedUserSettings.getInstance().canShowPage(); | |
54 }, | |
55 }; | |
56 | |
57 // This is a class used for browsertests. | |
58 function ManagedUserSetPassphraseForTesting() { | |
Bernhard Bauer
2013/02/05 16:21:32
This can really just be an object.
Adrian Kuegel
2013/02/05 16:53:04
Done.
| |
59 this.getPassphraseInput = function() { | |
60 return $('managed-user-passphrase'); | |
61 }; | |
62 this.getPassphraseConfirmInput = function() { | |
63 return $('passphrase-confirm'); | |
64 }; | |
65 this.getSavePassphraseButton = function() { | |
66 return $('save-passphrase'); | |
67 }; | |
68 this.updateDisplay = function() { | |
69 return ManagedUserSetPassphraseOverlay.getInstance().updateDisplay_(); | |
70 }; | |
71 } | |
72 | |
73 // Export | |
74 return { | |
75 ManagedUserSetPassphraseOverlay: ManagedUserSetPassphraseOverlay, | |
76 ManagedUserSetPassphraseForTesting: ManagedUserSetPassphraseForTesting | |
77 }; | |
78 | |
79 }); | |
OLD | NEW |