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

Unified Diff: chrome/browser/resources/file_manager/background/js/background.js

Issue 144783002: Simplify directory initialization in Files app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/file_manager/background/js/background.js
diff --git a/chrome/browser/resources/file_manager/background/js/background.js b/chrome/browser/resources/file_manager/background/js/background.js
index 94e850e3bf99bafc8b34d45769f9f7f0acc5f346..edd3620feb42131f241e0c66079347db9d6ee296 100644
--- a/chrome/browser/resources/file_manager/background/js/background.js
+++ b/chrome/browser/resources/file_manager/background/js/background.js
@@ -522,20 +522,33 @@ function launchFileManager(opt_appState, opt_id, opt_type, opt_callback) {
// reuse it instead of opening a new one.
if (type == LaunchType.FOCUS_SAME_OR_CREATE ||
type == LaunchType.FOCUS_ANY_OR_CREATE) {
- if (opt_appState && opt_appState.defaultPath) {
+ if (opt_appState) {
for (var key in background.appWindows) {
if (!key.match(FILES_ID_PATTERN))
continue;
var contentWindow = background.appWindows[key].contentWindow;
- if (contentWindow.appState &&
- opt_appState.defaultPath == contentWindow.appState.defaultPath) {
- background.appWindows[key].focus();
- if (opt_callback)
- opt_callback(key);
- onTaskCompleted();
- return;
+ if (!contentWindow.appState)
+ continue;
+
+ // Different current directories.
+ if (opt_appState.currentDirectoryPath !==
+ contentWindow.appState.currentDirectoryPath) {
+ continue;
+ }
+
+ // Selection path specified, and it is different.
+ if (opt_appState.selectionPath &&
+ opt_appState.selectionPath !==
+ contentWindow.appState.selectionPath) {
+ continue;
}
+
+ background.appWindows[key].focus();
+ if (opt_callback)
+ opt_callback(key);
+ onTaskCompleted();
+ return;
}
}
}
@@ -654,7 +667,11 @@ Background.prototype.onExecute_ = function(action, details) {
params: {
action: action
},
- defaultPath: details.entries[0].fullPath
+ // It is not allowed to call getParent() here, since there may be
+ // no permissions to access it at this stage. Therefore we are passing
+ // the selectionPath only, and the currentDirectory will be resolved
+ // later.
+ selectionPath: details.entries[0].fullPath
};
// For mounted devices just focus any Files.app window. The mounted
// volume will appear on the navigation list.
@@ -763,8 +780,9 @@ Background.prototype.onContextMenuClicked_ = function(info) {
try {
if (background.appWindows[key].contentWindow.isFocused()) {
var appState = {
- defaultPath: background.appWindows[key].contentWindow.
- appState.defaultPath
+ // Do not clone the selection path, only the current directory.
+ currentDirectoryPath: background.appWindows[key].contentWindow.
+ appState.currentDirectoryPath
};
launchFileManager(appState);
return;
« no previous file with comments | « chrome/browser/chromeos/file_manager/url_util_unittest.cc ('k') | chrome/browser/resources/file_manager/common/js/util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698