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.
5 cr.define('options', function() {
6 /** @const */ var OptionsPage = options.OptionsPage;
9 * CertificateBackupOverlay class
10 * Encapsulated handling of the 'enter backup password' overlay page.
13 function CertificateBackupOverlay() {
14 OptionsPage.call(this, 'certificateBackupOverlay',
16 'certificateBackupOverlay');
19 cr.addSingletonGetter(CertificateBackupOverlay);
21 CertificateBackupOverlay.prototype = {
22 __proto__: OptionsPage.prototype,
25 * Initializes the page.
27 initializePage: function() {
28 OptionsPage.prototype.initializePage.call(this);
31 $('certificateBackupCancelButton').onclick = function(event) {
34 $('certificateBackupOkButton').onclick = function(event) {
37 var onBackupPasswordInput = function(event) {
38 self.comparePasswords_();
40 $('certificateBackupPassword').oninput = onBackupPasswordInput;
41 $('certificateBackupPassword2').oninput = onBackupPasswordInput;
43 self.clearInputFields_();
47 * Clears any uncommitted input, and dismisses the overlay.
50 dismissOverlay_: function() {
51 this.clearInputFields_();
52 OptionsPage.closeOverlay();
56 * Attempt the Backup operation.
57 * The overlay will be left up with inputs disabled until the backend
58 * finishes and dismisses it.
61 finishBackup_: function() {
62 chrome.send('exportPersonalCertificatePasswordSelected',
63 [$('certificateBackupPassword').value]);
64 $('certificateBackupCancelButton').disabled = true;
65 $('certificateBackupOkButton').disabled = true;
66 $('certificateBackupPassword').disabled = true;
67 $('certificateBackupPassword2').disabled = true;
71 * Cancel the Backup operation.
74 cancelBackup_: function() {
75 chrome.send('cancelImportExportCertificate');
76 this.dismissOverlay_();
80 * Compares the password fields and sets the button state appropriately.
83 comparePasswords_: function() {
84 var password1 = $('certificateBackupPassword').value;
85 var password2 = $('certificateBackupPassword2').value;
86 $('certificateBackupOkButton').disabled =
87 !password1 || password1 != password2;
91 * Clears the value of each input field.
94 clearInputFields_: function() {
95 $('certificateBackupPassword').value = '';
96 $('certificateBackupPassword2').value = '';
97 $('certificateBackupPassword').disabled = false;
98 $('certificateBackupPassword2').disabled = false;
99 $('certificateBackupCancelButton').disabled = false;
100 $('certificateBackupOkButton').disabled = true;
104 CertificateBackupOverlay.show = function() {
105 CertificateBackupOverlay.getInstance().clearInputFields_();
106 OptionsPage.navigateToPage('certificateBackupOverlay');
109 CertificateBackupOverlay.dismiss = function() {
110 CertificateBackupOverlay.getInstance().dismissOverlay_();
115 CertificateBackupOverlay: CertificateBackupOverlay