Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / resources / options / certificate_restore_overlay.js
blob5070c6ec195b7aa22e6f1447f1eae52f3146800a
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;
9 /**
10 * CertificateRestoreOverlay class
11 * Encapsulated handling of the 'enter restore password' overlay page.
12 * @class
14 function CertificateRestoreOverlay() {
15 Page.call(this, 'certificateRestore', '', 'certificateRestoreOverlay');
18 cr.addSingletonGetter(CertificateRestoreOverlay);
20 CertificateRestoreOverlay.prototype = {
21 __proto__: Page.prototype,
23 /** @override */
24 initializePage: function() {
25 Page.prototype.initializePage.call(this);
27 var self = this;
28 $('certificateRestoreCancelButton').onclick = function(event) {
29 self.cancelRestore_();
31 $('certificateRestoreOkButton').onclick = function(event) {
32 self.finishRestore_();
35 self.clearInputFields_();
38 /** @override */
39 didShowPage: function() {
40 $('certificateRestorePassword').focus();
43 /**
44 * Clears any uncommitted input, and dismisses the overlay.
45 * @private
47 dismissOverlay_: function() {
48 this.clearInputFields_();
49 PageManager.closeOverlay();
52 /**
53 * Attempt the restore operation.
54 * The overlay will be left up with inputs disabled until the backend
55 * finishes and dismisses it.
56 * @private
58 finishRestore_: function() {
59 chrome.send('importPersonalCertificatePasswordSelected',
60 [$('certificateRestorePassword').value]);
61 $('certificateRestoreCancelButton').disabled = true;
62 $('certificateRestoreOkButton').disabled = true;
65 /**
66 * Cancel the restore operation.
67 * @private
69 cancelRestore_: function() {
70 chrome.send('cancelImportExportCertificate');
71 this.dismissOverlay_();
74 /**
75 * Clears the value of each input field.
76 * @private
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_();
94 // Export
95 return {
96 CertificateRestoreOverlay: CertificateRestoreOverlay
99 });