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 * CertificateRestoreOverlay class
10 * Encapsulated handling of the 'enter restore password' overlay page.
13 function CertificateRestoreOverlay() {
14 OptionsPage.call(this, 'certificateRestore', '',
15 'certificateRestoreOverlay');
18 cr.addSingletonGetter(CertificateRestoreOverlay);
20 CertificateRestoreOverlay.prototype = {
21 __proto__: OptionsPage.prototype,
24 * Initializes the page.
26 initializePage: function() {
27 OptionsPage.prototype.initializePage.call(this);
30 $('certificateRestoreCancelButton').onclick = function(event) {
31 self.cancelRestore_();
33 $('certificateRestoreOkButton').onclick = function(event) {
34 self.finishRestore_();
37 self.clearInputFields_();
41 didShowPage: function() {
42 $('certificateRestorePassword').focus();
46 * Clears any uncommitted input, and dismisses the overlay.
49 dismissOverlay_: function() {
50 this.clearInputFields_();
51 OptionsPage.closeOverlay();
55 * Attempt the restore operation.
56 * The overlay will be left up with inputs disabled until the backend
57 * finishes and dismisses it.
60 finishRestore_: function() {
61 chrome.send('importPersonalCertificatePasswordSelected',
62 [$('certificateRestorePassword').value]);
63 $('certificateRestoreCancelButton').disabled = true;
64 $('certificateRestoreOkButton').disabled = true;
68 * Cancel the restore operation.
71 cancelRestore_: function() {
72 chrome.send('cancelImportExportCertificate');
73 this.dismissOverlay_();
77 * Clears the value of each input field.
80 clearInputFields_: function() {
81 $('certificateRestorePassword').value = '';
82 $('certificateRestoreCancelButton').disabled = false;
83 $('certificateRestoreOkButton').disabled = false;
87 CertificateRestoreOverlay.show = function() {
88 CertificateRestoreOverlay.getInstance().clearInputFields_();
89 OptionsPage.navigateToPage('certificateRestore');
92 CertificateRestoreOverlay.dismiss = function() {
93 CertificateRestoreOverlay.getInstance().dismissOverlay_();
98 CertificateRestoreOverlay: CertificateRestoreOverlay