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 Page = cr.ui.pageManager.Page;
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager;
10 * CertificateRestoreOverlay class
11 * Encapsulated handling of the 'enter restore password' overlay page.
14 function CertificateRestoreOverlay() {
15 Page.call(this, 'certificateRestore', '', 'certificateRestoreOverlay');
18 cr.addSingletonGetter(CertificateRestoreOverlay);
20 CertificateRestoreOverlay.prototype = {
21 __proto__: Page.prototype,
24 initializePage: function() {
25 Page.prototype.initializePage.call(this);
28 $('certificateRestoreCancelButton').onclick = function(event) {
29 self.cancelRestore_();
31 $('certificateRestoreOkButton').onclick = function(event) {
32 self.finishRestore_();
35 self.clearInputFields_();
39 didShowPage: function() {
40 $('certificateRestorePassword').focus();
44 * Clears any uncommitted input, and dismisses the overlay.
47 dismissOverlay_: function() {
48 this.clearInputFields_();
49 PageManager.closeOverlay();
53 * Attempt the restore operation.
54 * The overlay will be left up with inputs disabled until the backend
55 * finishes and dismisses it.
58 finishRestore_: function() {
59 chrome.send('importPersonalCertificatePasswordSelected',
60 [$('certificateRestorePassword').value]);
61 $('certificateRestoreCancelButton').disabled = true;
62 $('certificateRestoreOkButton').disabled = true;
66 * Cancel the restore operation.
69 cancelRestore_: function() {
70 chrome.send('cancelImportExportCertificate');
71 this.dismissOverlay_();
75 * Clears the value of each input field.
78 clearInputFields_: function() {
79 $('certificateRestorePassword').value = '';
80 $('certificateRestoreCancelButton').disabled = false;
81 $('certificateRestoreOkButton').disabled = false;
85 CertificateRestoreOverlay.show = function() {
86 CertificateRestoreOverlay.getInstance().clearInputFields_();
87 PageManager.showPageByName('certificateRestore');
90 CertificateRestoreOverlay.dismiss = function() {
91 CertificateRestoreOverlay.getInstance().dismissOverlay_();
96 CertificateRestoreOverlay: CertificateRestoreOverlay