Chromium Code Reviews| Index: chrome/browser/resources/options/managed_user_set_passphrase.js |
| diff --git a/chrome/browser/resources/options/managed_user_set_passphrase.js b/chrome/browser/resources/options/managed_user_set_passphrase.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bd96f264f2ba0173cdd654d6f76486819e52e984 |
| --- /dev/null |
| +++ b/chrome/browser/resources/options/managed_user_set_passphrase.js |
| @@ -0,0 +1,79 @@ |
| +// Copyright (c) 2012 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. |
| + |
| +cr.define('options', function() { |
| + /** @const */ var OptionsPage = options.OptionsPage; |
| + |
| + ////////////////////////////////////////////////////////////////////////////// |
| + // ManagedUserSetPassphraseOverlay class: |
| + |
| + /** |
| + * Encapsulated handling of the Managed User Set Passphrase page. |
| + * @constructor |
| + */ |
| + function ManagedUserSetPassphraseOverlay() { |
| + OptionsPage.call( |
| + this, |
| + 'setPassphrase', |
| + loadTimeData.getString('setPassphraseTitle'), |
| + 'managed-user-set-passphrase-overlay'); |
| + } |
| + |
| + cr.addSingletonGetter(ManagedUserSetPassphraseOverlay); |
| + |
| + ManagedUserSetPassphraseOverlay.prototype = { |
| + __proto__: OptionsPage.prototype, |
| + |
| + /** @override */ |
| + initializePage: function() { |
| + OptionsPage.prototype.initializePage.call(this); |
| + $('managed-user-passphrase').oninput = this.updateDisplay_; |
| + $('passphrase-confirm').oninput = this.updateDisplay_; |
| + |
| + $('save-passphrase').onclick = function() { |
| + chrome.send('setPassphrase', [$('managed-user-passphrase').value]); |
| + $('managed-user-passphrase').value = ''; |
| + $('passphrase-confirm').value = ''; |
| + OptionsPage.closeOverlay(); |
| + }; |
| + }, |
| + updateDisplay_: function() { |
| + var valid = |
| + $('passphrase-confirm').value == $('managed-user-passphrase').value; |
| + $('passphrase-mismatch').hidden = valid; |
| + $('passphrase-confirm').setCustomValidity( |
| + valid ? '' : $('passphrase-mismatch').textContent); |
| + $('save-passphrase').disabled = |
| + !$('passphrase-confirm').validity.valid || |
| + !$('managed-user-passphrase').validity.valid; |
| + }, |
| + /** @override */ |
| + canShowPage: function() { |
| + return ManagedUserSettings.getInstance().canShowPage(); |
| + }, |
| + }; |
| + |
| + // This is a class used for browsertests. |
| + 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.
|
| + this.getPassphraseInput = function() { |
| + return $('managed-user-passphrase'); |
| + }; |
| + this.getPassphraseConfirmInput = function() { |
| + return $('passphrase-confirm'); |
| + }; |
| + this.getSavePassphraseButton = function() { |
| + return $('save-passphrase'); |
| + }; |
| + this.updateDisplay = function() { |
| + return ManagedUserSetPassphraseOverlay.getInstance().updateDisplay_(); |
| + }; |
| + } |
| + |
| + // Export |
| + return { |
| + ManagedUserSetPassphraseOverlay: ManagedUserSetPassphraseOverlay, |
| + ManagedUserSetPassphraseForTesting: ManagedUserSetPassphraseForTesting |
| + }; |
| + |
| +}); |