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 * CertificateBackupOverlay class
11 * Encapsulated handling of the 'enter backup password' overlay page.
14 function CertificateBackupOverlay() {
15 Page.call(this, 'certificateBackupOverlay', '', 'certificateBackupOverlay');
18 cr.addSingletonGetter(CertificateBackupOverlay);
20 CertificateBackupOverlay.prototype = {
21 __proto__: Page.prototype,
24 initializePage: function() {
25 Page.prototype.initializePage.call(this);
28 $('certificateBackupCancelButton').onclick = function(event) {
31 $('certificateBackupOkButton').onclick = function(event) {
34 var onBackupPasswordInput = function(event) {
35 self.comparePasswords_();
37 $('certificateBackupPassword').oninput = onBackupPasswordInput;
38 $('certificateBackupPassword2').oninput = onBackupPasswordInput;
40 self.clearInputFields_();
44 * Clears any uncommitted input, and dismisses the overlay.
47 dismissOverlay_: function() {
48 this.clearInputFields_();
49 PageManager.closeOverlay();
53 * Attempt the Backup operation.
54 * The overlay will be left up with inputs disabled until the backend
55 * finishes and dismisses it.
58 finishBackup_: function() {
59 chrome.send('exportPersonalCertificatePasswordSelected',
60 [$('certificateBackupPassword').value]);
61 $('certificateBackupCancelButton').disabled = true;
62 $('certificateBackupOkButton').disabled = true;
63 $('certificateBackupPassword').disabled = true;
64 $('certificateBackupPassword2').disabled = true;
68 * Cancel the Backup operation.
71 cancelBackup_: function() {
72 chrome.send('cancelImportExportCertificate');
73 this.dismissOverlay_();
77 * Compares the password fields and sets the button state appropriately.
80 comparePasswords_: function() {
81 var password1 = $('certificateBackupPassword').value;
82 var password2 = $('certificateBackupPassword2').value;
83 $('certificateBackupOkButton').disabled =
84 !password1 || password1 != password2;
88 * Clears the value of each input field.
91 clearInputFields_: function() {
92 $('certificateBackupPassword').value = '';
93 $('certificateBackupPassword2').value = '';
94 $('certificateBackupPassword').disabled = false;
95 $('certificateBackupPassword2').disabled = false;
96 $('certificateBackupCancelButton').disabled = false;
97 $('certificateBackupOkButton').disabled = true;
101 CertificateBackupOverlay.show = function() {
102 CertificateBackupOverlay.getInstance().clearInputFields_();
103 PageManager.showPageByName('certificateBackupOverlay');
106 CertificateBackupOverlay.dismiss = function() {
107 CertificateBackupOverlay.getInstance().dismissOverlay_();
112 CertificateBackupOverlay: CertificateBackupOverlay