Zip Archiver: Stop memorizing and remembering zip passwords.

This is a partial reland of 876705.
Since the extension mounts files with persistent:false, remembering
passwords (for reboot/suspend) does not have any intended effect.
Therefore this change removes the "remember" checkbox for the password
input UI and stops remembering new passwords of encrypted files in ZIP
files.
This change also stops using remembered passwords by old versions of the
extension.

As a remaining issue after this, when there is already memorized mount
info by older versions of the extension, it will still mount the zip file
upon reboot/suspend until user successfully unmounts it.


Bug: 789073
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ibaa2afd21dbbebfa67f2e5616913313be9ad518e
Reviewed-on: https://chromium-review.googlesource.com/930644
Reviewed-by: Yuki Awano <yawano@chromium.org>
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#538711}(cherry picked from commit f37067abf1c72034a574101ba34ef7c6471d8057)
Reviewed-on: https://chromium-review.googlesource.com/940741
Reviewed-by: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Commit-Position: refs/branch-heads/3325@{#619}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
diff --git a/chrome/browser/resources/chromeos/zip_archiver/css/passphrase-dialog.css b/chrome/browser/resources/chromeos/zip_archiver/css/passphrase-dialog.css
index fb2bea6..dc9dc11 100644
--- a/chrome/browser/resources/chromeos/zip_archiver/css/passphrase-dialog.css
+++ b/chrome/browser/resources/chromeos/zip_archiver/css/passphrase-dialog.css
@@ -16,13 +16,8 @@
   justify-content: space-between;
 }
 
-#bar {
-  align-items: center;
-  display: flex;
-  justify-content: space-between;
-}
-
 #buttons {
+  align-items: center;
   display: flex;
   justify-content: flex-end;
 }
diff --git a/chrome/browser/resources/chromeos/zip_archiver/html/passphrase-dialog.html b/chrome/browser/resources/chromeos/zip_archiver/html/passphrase-dialog.html
index 3efca3c..2659bb9 100644
--- a/chrome/browser/resources/chromeos/zip_archiver/html/passphrase-dialog.html
+++ b/chrome/browser/resources/chromeos/zip_archiver/html/passphrase-dialog.html
@@ -14,22 +14,17 @@
              autofocus
              i18n-values="placeholder:ZIP_ARCHIVER_PASSPHRASE_INPUT_LABEL;aria-label:ZIP_ARCHIVER_PASSPHRASE_INPUT_LABEL">
     </paper-input-container>
-    <div id="bar">
-      <paper-checkbox id="remember"
-                      i18n-content="ZIP_ARCHIVER_PASSPHRASE_REMEMBER">
-      </paper-checkbox>
-      <div id="buttons">
-        <paper-button noink
-                      on-click="accept"
-                      id="acceptButton"
-                      i18n-content="ZIP_ARCHIVER_PASSPHRASE_ACCEPT">
-        </paper-button>
-        <paper-button noink
-                      on-click="cancel"
-                      id="cancelButton"
-                      i18n-content="ZIP_ARCHIVER_PASSPHRASE_CANCEL">
-        </paper-button>
-      </div>
+    <div id="buttons">
+      <paper-button noink
+                    on-click="accept"
+                    id="acceptButton"
+                    i18n-content="ZIP_ARCHIVER_PASSPHRASE_ACCEPT">
+      </paper-button>
+      <paper-button noink
+                    on-click="cancel"
+                    id="cancelButton"
+                    i18n-content="ZIP_ARCHIVER_PASSPHRASE_CANCEL">
+      </paper-button>
     </div>
   </template>
 </dom-module>
diff --git a/chrome/browser/resources/chromeos/zip_archiver/js/app.js b/chrome/browser/resources/chromeos/zip_archiver/js/app.js
index 7844bb7..c7f49ac 100644
--- a/chrome/browser/resources/chromeos/zip_archiver/js/app.js
+++ b/chrome/browser/resources/chromeos/zip_archiver/js/app.js
@@ -271,17 +271,16 @@
    * @param {!Object<!unpacker.types.RequestId,
    *                 !unpacker.types.OpenFileRequestedOptions>}
    *     openedFiles Previously opened files before a suspend.
-   * @param {?string} passphrase Previously used passphrase before a suspend.
    * @return {!Promise} Promise fulfilled on success and rejected on failure.
    * @private
    */
-  loadVolume_: function(fileSystemId, entry, openedFiles, passphrase) {
+  loadVolume_: function(fileSystemId, entry, openedFiles) {
     return new Promise(function(fulfill, reject) {
       entry.file(
           function(file) {
             // File is a Blob object, so it's ok to construct the Decompressor
             // directly with it.
-            var passphraseManager = new unpacker.PassphraseManager(passphrase);
+            var passphraseManager = new unpacker.PassphraseManager();
             console.assert(
                 unpacker.app.naclModule,
                 'The NaCL module should have already been defined.');
@@ -365,8 +364,7 @@
             };
           });
           return unpacker.app.loadVolume_(
-              fileSystemId, stateWithFileSystem.state.entry, openedFilesOptions,
-              stateWithFileSystem.state.passphrase);
+              fileSystemId, stateWithFileSystem.state.entry, openedFilesOptions);
         })
         .catch(function(error) {
           console.error(error.stack || error);
@@ -939,7 +937,7 @@
                     return;
                   }
                   var loadPromise = unpacker.app.loadVolume_(
-                      fileSystemId, entry, {}, null /* passphrase */);
+                      fileSystemId, entry, {});
                   loadPromise
                       .then(function() {
                         unpacker.app.volumeLoadFinished[fileSystemId] = true;
diff --git a/chrome/browser/resources/chromeos/zip_archiver/js/passphrase-dialog.js b/chrome/browser/resources/chromeos/zip_archiver/js/passphrase-dialog.js
index 4cc7936..2df9854 100644
--- a/chrome/browser/resources/chromeos/zip_archiver/js/passphrase-dialog.js
+++ b/chrome/browser/resources/chromeos/zip_archiver/js/passphrase-dialog.js
@@ -19,7 +19,7 @@
   },
 
   accept: function() {
-    window.onPassphraseSuccess(this.$.input.value, this.$.remember.checked);
+    window.onPassphraseSuccess(this.$.input.value);
     window.close();
   },
 
diff --git a/chrome/browser/resources/chromeos/zip_archiver/js/passphrase-manager.js b/chrome/browser/resources/chromeos/zip_archiver/js/passphrase-manager.js
index 71755e73..9c37e57 100644
--- a/chrome/browser/resources/chromeos/zip_archiver/js/passphrase-manager.js
+++ b/chrome/browser/resources/chromeos/zip_archiver/js/passphrase-manager.js
@@ -4,38 +4,15 @@
 
 /**
  * @constructor
- * @param {?string} initPassphrase Initial passphrase for the first passphrase
- *     request or NULL if not available. In such case, call to getPassphrase()
- *     will invoke a dialog.
  */
-unpacker.PassphraseManager = function(initPassphrase) {
-  /**
-   * @private {?string}
-   */
-  this.initPassphrase_ = initPassphrase;
-
-  /**
-   * @public {?string}
-   */
-  this.rememberedPassphrase = initPassphrase;
-};
+unpacker.PassphraseManager = function() {};
 
 /**
- * Requests a passphrase from the user. If a passphrase was previously
- * remembered, then tries it first. Otherwise shows a passphrase dialog.
+ * Requests a passphrase from the user.
  * @return {!Promise<string>}
  */
 unpacker.PassphraseManager.prototype.getPassphrase = function() {
   return new Promise(function(fulfill, reject) {
-    // For the first passphrase request try the init passphrase (which may be
-    // incorrect though, so do it only once).
-    if (this.initPassphrase_ != null) {
-      fulfill(this.initPassphrase_);
-      this.initPassphrase_ = null;
-      return;
-    }
-
-    // Ask user for a passphrase.
     chrome.app.window.create(
         '../html/passphrase.html',
         /** @type {!chrome.app.window.CreateWindowOptions} */ ({
@@ -55,10 +32,8 @@
           }.bind(this));
 
           passphraseWindow.contentWindow.onPassphraseSuccess = function(
-                                                                   passphrase,
-                                                                   remember) {
+                                                                   passphrase) {
             passphraseSucceeded = true;
-            this.rememberedPassphrase = remember ? passphrase : null;
             fulfill(passphrase);
           }.bind(this);
         }.bind(this));