Commit 430b4497 authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Zip Archiver: Suppress in incognito context of regular session.

Currently Zip Archiver run in the normal and incognito contexts in
parallel when opening a single ZIP file in the Files app.
The instance in the incognito context also received and processed events
in onGetMetadataRequested, but it always fails because it doesn't run
the normal initialization procedure.
(i.e. loading volume and filling unpacker.app.volumeLoadedPromises)

It once had worked harmlessly because error was ignored, but now
the error in the incognito context triggers unmounting of the file.
It can cancel out the volume mounted by the other instance in the
normal context right before it.

Bug: 833603
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I712a974ca4fe287d795256fc22a62d5c85d66401
Reviewed-on: https://chromium-review.googlesource.com/1018624
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Reviewed-by: default avatarYuki Awano <yawano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553950}
parent 1e3550d5
...@@ -4,33 +4,48 @@ ...@@ -4,33 +4,48 @@
'use strict'; 'use strict';
// Event called on opening a file with the extension or mime type function setupZipArchiver() {
// declared in the manifest file. // Event called on opening a file with the extension or mime type
chrome.app.runtime.onLaunched.addListener(unpacker.app.onLaunched); // declared in the manifest file.
chrome.app.runtime.onLaunched.addListener(unpacker.app.onLaunched);
// Save the state before suspending the event page, so we can resume it
// once new events arrive. // Save the state before suspending the event page, so we can resume it
chrome.runtime.onSuspend.addListener(unpacker.app.onSuspend); // once new events arrive.
chrome.runtime.onSuspend.addListener(unpacker.app.onSuspend);
chrome.fileSystemProvider.onUnmountRequested.addListener(
unpacker.app.onUnmountRequested); chrome.fileSystemProvider.onUnmountRequested.addListener(
chrome.fileSystemProvider.onGetMetadataRequested.addListener( unpacker.app.onUnmountRequested);
unpacker.app.onGetMetadataRequested); chrome.fileSystemProvider.onGetMetadataRequested.addListener(
chrome.fileSystemProvider.onReadDirectoryRequested.addListener( unpacker.app.onGetMetadataRequested);
unpacker.app.onReadDirectoryRequested); chrome.fileSystemProvider.onReadDirectoryRequested.addListener(
chrome.fileSystemProvider.onOpenFileRequested.addListener( unpacker.app.onReadDirectoryRequested);
unpacker.app.onOpenFileRequested); chrome.fileSystemProvider.onOpenFileRequested.addListener(
chrome.fileSystemProvider.onCloseFileRequested.addListener( unpacker.app.onOpenFileRequested);
unpacker.app.onCloseFileRequested); chrome.fileSystemProvider.onCloseFileRequested.addListener(
chrome.fileSystemProvider.onReadFileRequested.addListener( unpacker.app.onCloseFileRequested);
unpacker.app.onReadFileRequested); chrome.fileSystemProvider.onReadFileRequested.addListener(
unpacker.app.onReadFileRequested);
// Load the PNaCl module.
unpacker.app.loadNaclModule('module.nmf', 'application/x-pnacl'); // Load the PNaCl module.
unpacker.app.loadNaclModule('module.nmf', 'application/x-pnacl');
// Load translations
unpacker.app.loadStringData(); // Load translations
unpacker.app.loadStringData();
// Clean all temporary files inside the work directory, just in case the
// extension aborted previously without removing ones. // Clean all temporary files inside the work directory, just in case the
unpacker.app.cleanWorkDirectory(); // extension aborted previously without removing ones.
unpacker.app.cleanWorkDirectory();
}
// Avoid handling events duplicatedly if this is in incognito context in a
// regular session. https://crbug.com/833603
chrome.fileManagerPrivate.getProfiles((profiles) => {
if ((profiles[0] && profiles[0].profileId == '$guest') ||
!chrome.extension.inIncognitoContext) {
setupZipArchiver();
} else {
console.info(
'The extension was silenced ' +
'because this is in the incognito context of a regular session.');
}
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment