Commit 6a2af82f authored by Klemen Kozjek's avatar Klemen Kozjek Committed by Commit Bot

Zip Archiver: Skip zip file mount entry state maintenance in guest mode

As of now, when we mount a zip file we maintain mounted entries through
retainEntry private method and use that information to restore them upon
device restart or session login. Because retainEntry method does not work
under incognito mode we return an error message if retainEntry is called.
Incognito mode does not retain changes made in its session and therefore
we skip calls that would otherwise call retainEntry method.

As a result, Zip Archiver works in incognito/guest mode.

Bug: 607078
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I9220eea4ed9ea8b9e873698d44cd6e167194b071
Reviewed-on: https://chromium-review.googlesource.com/663002
Commit-Queue: Klemen Kozjek <klemenko@google.com>
Reviewed-by: default avatarTomasz Mikolajewski <mtomasz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502171}
parent d3757f83
...@@ -149,11 +149,17 @@ unpacker.app = { ...@@ -149,11 +149,17 @@ unpacker.app = {
}, },
/** /**
* Saves state in case of restarts, event page suspend, crashes, etc. * Saves state in case of restarts, event page suspend, crashes, etc. This
* method does nothing when context is in incognito mode.
* @param {!Array<!unpacker.types.FileSystemId>} fileSystemIdsArray * @param {!Array<!unpacker.types.FileSystemId>} fileSystemIdsArray
* @private * @private
*/ */
saveState_: function(fileSystemIdsArray) { saveState_: function(fileSystemIdsArray) {
// If current context is in incognito mode, then skip save state because
// retainEntry is not available in incognito mode.
if (chrome.extension.inIncognitoContext)
return;
chrome.storage.local.get([unpacker.app.STORAGE_KEY], function(result) { chrome.storage.local.get([unpacker.app.STORAGE_KEY], function(result) {
if (!result[unpacker.app.STORAGE_KEY]) // First save state call. if (!result[unpacker.app.STORAGE_KEY]) // First save state call.
result[unpacker.app.STORAGE_KEY] = {}; result[unpacker.app.STORAGE_KEY] = {};
...@@ -176,10 +182,14 @@ unpacker.app = { ...@@ -176,10 +182,14 @@ unpacker.app = {
}, },
/** /**
* Removes state from local storage for a single volume. * Removes state from local storage for a single volume. This method does
* nothing when context is in incognito mode.
* @param {!unpacker.types.FileSystemId} fileSystemId * @param {!unpacker.types.FileSystemId} fileSystemId
*/ */
removeState_: function(fileSystemId) { removeState_: function(fileSystemId) {
if (chrome.extension.inIncognitoContext)
return;
chrome.storage.local.get([unpacker.app.STORAGE_KEY], function(result) { chrome.storage.local.get([unpacker.app.STORAGE_KEY], function(result) {
console.assert( console.assert(
result[unpacker.app.STORAGE_KEY] && result[unpacker.app.STORAGE_KEY] &&
......
...@@ -85,6 +85,8 @@ const char kUnknownIdError[] = "Unknown id"; ...@@ -85,6 +85,8 @@ const char kUnknownIdError[] = "Unknown id";
const char kNotSupportedOnCurrentPlatformError[] = const char kNotSupportedOnCurrentPlatformError[] =
"Operation not supported on the current platform."; "Operation not supported on the current platform.";
const char kRetainEntryError[] = "Could not retain file entry."; const char kRetainEntryError[] = "Could not retain file entry.";
const char kRetainEntryIncognitoError[] =
"Could not retain file entry in incognito mode";
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
const char kNotSupportedOnNonKioskSessionError[] = const char kNotSupportedOnNonKioskSessionError[] =
...@@ -784,8 +786,13 @@ ExtensionFunction::ResponseAction FileSystemRetainEntryFunction::Run() { ...@@ -784,8 +786,13 @@ ExtensionFunction::ResponseAction FileSystemRetainEntryFunction::Run() {
ExtensionsAPIClient::Get()->GetFileSystemDelegate(); ExtensionsAPIClient::Get()->GetFileSystemDelegate();
DCHECK(delegate); DCHECK(delegate);
content::BrowserContext* context = browser_context();
// Check whether the context is incognito mode or not.
if (context && context->IsOffTheRecord())
return RespondNow(Error(kRetainEntryIncognitoError));
SavedFilesServiceInterface* saved_files_service = SavedFilesServiceInterface* saved_files_service =
delegate->GetSavedFilesService(browser_context()); delegate->GetSavedFilesService(context);
DCHECK(saved_files_service); DCHECK(saved_files_service);
// Add the file to the retain list if it is not already on there. // Add the file to the retain list if it is not already on there.
......
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