Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: ui/file_manager/zip_archiver/unpacker/js/passphrase-manager.js

Issue 2804453002: Move files from zip_archiver/unpacker/ to zip_archiver/. (Closed)
Patch Set: Move files from zip_archiver/unpacker/ to zip_archiver/. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium OS 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 /**
6 * @constructor
7 * @param {?string} initPassphrase Initial passphrase for the first passphrase
8 * request or NULL if not available. In such case, call to getPassphrase()
9 * will invoke a dialog.
10 */
11 unpacker.PassphraseManager = function(initPassphrase) {
12 /**
13 * @private {?string}
14 */
15 this.initPassphrase_ = initPassphrase;
16
17 /**
18 * @public {?string}
19 */
20 this.rememberedPassphrase = initPassphrase;
21 };
22
23 /**
24 * Requests a passphrase from the user. If a passphrase was previously
25 * remembered, then tries it first. Otherwise shows a passphrase dialog.
26 * @return {!Promise.<string>}
27 */
28 unpacker.PassphraseManager.prototype.getPassphrase = function() {
29 return new Promise(function(fulfill, reject) {
30 // For the first passphrase request try the init passphrase (which may be
31 // incorrect though, so do it only once).
32 if (this.initPassphrase_) {
33 fulfill(this.initPassphrase_);
34 this.initPassphrase_ = null;
35 return;
36 }
37
38 // Ask user for a passphrase.
39 chrome.app.window.create(
40 '../html/passphrase.html',
41 /** @type {!chrome.app.window.CreateWindowOptions} */ ({
42 innerBounds: {width: 320, height: 160},
43 alwaysOnTop: true,
44 resizable: false,
45 frame: 'none',
46 hidden: true
47 }),
48 function(passphraseWindow) {
49 var passphraseSucceeded = false;
50
51 passphraseWindow.onClosed.addListener(function() {
52 if (passphraseSucceeded)
53 return;
54 reject('FAILED');
55 }.bind(this));
56
57 passphraseWindow.contentWindow.onPassphraseSuccess =
58 function(passphrase, remember) {
59 passphraseSucceeded = true;
60 this.rememberedPassphrase = remember ? passphrase : null;
61 fulfill(passphrase);
62 }.bind(this);
63 }.bind(this));
64 }.bind(this));
65 }
OLDNEW
« no previous file with comments | « ui/file_manager/zip_archiver/unpacker/js/passphrase-dialog.js ('k') | ui/file_manager/zip_archiver/unpacker/js/request.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698