OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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. | |
4 | |
5 cr.define('options', function() { | |
6 const OptionsPage = options.OptionsPage; | |
7 | |
8 /** | |
9 * CertificateRestoreOverlay class | |
10 * Encapsulated handling of the 'enter restore password' overlay page. | |
11 * @class | |
12 */ | |
13 function CertificateRestoreOverlay() { | |
14 OptionsPage.call(this, 'certificateRestore', | |
15 '', | |
16 'certificateRestoreOverlay'); | |
17 } | |
18 | |
19 cr.addSingletonGetter(CertificateRestoreOverlay); | |
20 | |
21 CertificateRestoreOverlay.prototype = { | |
22 __proto__: OptionsPage.prototype, | |
23 | |
24 /** | |
25 * Initializes the page. | |
26 */ | |
27 initializePage: function() { | |
28 OptionsPage.prototype.initializePage.call(this); | |
29 | |
30 var self = this; | |
31 $('certificateRestoreCancelButton').onclick = function(event) { | |
32 self.cancelRestore_(); | |
33 } | |
34 $('certificateRestoreOkButton').onclick = function(event) { | |
35 self.finishRestore_(); | |
36 } | |
37 | |
38 self.clearInputFields_(); | |
39 }, | |
40 | |
41 /** | |
42 * Clears any uncommitted input, and dismisses the overlay. | |
43 * @private | |
44 */ | |
45 dismissOverlay_: function() { | |
46 this.clearInputFields_(); | |
47 OptionsPage.closeOverlay(); | |
48 }, | |
49 | |
50 /** | |
51 * Attempt the restore operation. | |
52 * The overlay will be left up with inputs disabled until the backend | |
53 * finishes and dismisses it. | |
54 * @private | |
55 */ | |
56 finishRestore_: function() { | |
57 chrome.send('importPersonalCertificatePasswordSelected', | |
58 [$('certificateRestorePassword').value]); | |
59 $('certificateRestoreCancelButton').disabled = true; | |
60 $('certificateRestoreOkButton').disabled = true; | |
61 }, | |
62 | |
63 /** | |
64 * Cancel the restore operation. | |
65 * @private | |
66 */ | |
67 cancelRestore_: function() { | |
68 chrome.send('cancelImportExportCertificate'); | |
69 this.dismissOverlay_(); | |
70 }, | |
71 | |
72 /** | |
73 * Clears the value of each input field. | |
74 * @private | |
75 */ | |
76 clearInputFields_: function() { | |
77 $('certificateRestorePassword').value = ''; | |
78 $('certificateRestoreCancelButton').disabled = false; | |
79 $('certificateRestoreOkButton').disabled = false; | |
80 }, | |
81 }; | |
82 | |
83 CertificateRestoreOverlay.show = function() { | |
84 CertificateRestoreOverlay.getInstance().clearInputFields_(); | |
85 OptionsPage.navigateToPage('certificateRestore'); | |
86 }; | |
87 | |
88 CertificateRestoreOverlay.dismiss = function() { | |
89 CertificateRestoreOverlay.getInstance().dismissOverlay_(); | |
90 }; | |
91 | |
92 // Export | |
93 return { | |
94 CertificateRestoreOverlay: CertificateRestoreOverlay | |
95 }; | |
96 | |
97 }); | |
OLD | NEW |