diff options
author | hirono@chromium.org <hirono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-06 11:52:36 +0000 |
---|---|---|
committer | hirono@chromium.org <hirono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-06 11:52:36 +0000 |
commit | 0e91e1ab6778b30166b09f445eae15e954d0778a (patch) | |
tree | 6b4a05bbe9ee34a17617975c10191b937775246e /chrome/browser/resources | |
parent | fdbc3745c0834d175aaafda332798c3eff278aa8 (diff) | |
download | chromium_src-0e91e1ab6778b30166b09f445eae15e954d0778a.zip chromium_src-0e91e1ab6778b30166b09f445eae15e954d0778a.tar.gz chromium_src-0e91e1ab6778b30166b09f445eae15e954d0778a.tar.bz2 |
Files.app: Open the span windows in the active desktop.
This CL lets Files.app handles the active desktop in open-window command.
BUG=337778, 340950
TEST=manually
Review URL: https://codereview.chromium.org/153553004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249371 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r-- | chrome/browser/resources/file_manager/background/js/background.js | 39 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js | 11 |
2 files changed, 42 insertions, 8 deletions
diff --git a/chrome/browser/resources/file_manager/background/js/background.js b/chrome/browser/resources/file_manager/background/js/background.js index adbac0a..5022000 100644 --- a/chrome/browser/resources/file_manager/background/js/background.js +++ b/chrome/browser/resources/file_manager/background/js/background.js @@ -242,13 +242,37 @@ function AppWindowWrapper(url, id, options) { } /** + * Focuses the window on the specified desktop. + * @param {AppWindow} appWindow Application window. + * @param {string=} opt_profileId The profiled ID of the target window. If it is + * dropped, the window is focused on the current window. + */ +AppWindowWrapper.focusOnDesktop = function(appWindow, opt_profileId) { + new Promise(function(onFullfilled, onRejected) { + if (opt_profileId) { + onFullfilled(opt_profileId); + } else { + chrome.fileBrowserPrivate.getProfiles(function(profiles, + currentId, + displayedId) { + onFullfilled(currentId); + }); + } + }).then(function(profileId) { + appWindow.contentWindow.chrome.fileBrowserPrivate.visitDesktop( + profileId, function() { + appWindow.focus(); + }); + }); +}; + +/** * Shift distance to avoid overlapping windows. * @type {number} * @const */ AppWindowWrapper.SHIFT_DISTANCE = 40; - /** * Opens the window. * @@ -447,7 +471,7 @@ SingletonAppWindowWrapper.prototype.launch = function(appState, opt_callback) { this.queue.run(function(nextStep) { this.window_.contentWindow.appState = appState; this.window_.contentWindow.reload(); - this.window_.focus(); + AppWindowWrapper.focusOnDesktop(this.window_, appState.displayedId); if (opt_callback) opt_callback(); nextStep(); @@ -544,7 +568,8 @@ function launchFileManager(opt_appState, opt_id, opt_type, opt_callback) { continue; } - background.appWindows[key].focus(); + AppWindowWrapper.focusOnDesktop( + background.appWindows[key], opt_appState.displayedId); if (opt_callback) opt_callback(key); onTaskCompleted(); @@ -579,7 +604,8 @@ function launchFileManager(opt_appState, opt_id, opt_type, opt_callback) { continue; if (!background.appWindows[key].isMinimized()) { - background.appWindows[key].focus(); + AppWindowWrapper.focusOnDesktop( + background.appWindows[key], (opt_appState || {}).displayedId); if (opt_callback) opt_callback(key); onTaskCompleted(); @@ -591,7 +617,8 @@ function launchFileManager(opt_appState, opt_id, opt_type, opt_callback) { if (!key.match(FILES_ID_PATTERN)) continue; - background.appWindows[key].focus(); + AppWindowWrapper.focusOnDesktop( + background.appWindows[key], (opt_appState || {}).displayedId); if (opt_callback) opt_callback(key); onTaskCompleted(); @@ -611,6 +638,8 @@ function launchFileManager(opt_appState, opt_id, opt_type, opt_callback) { appId, FILE_MANAGER_WINDOW_CREATE_OPTIONS); appWindow.launch(opt_appState || {}, function() { + AppWindowWrapper.focusOnDesktop( + appWindow.window_, (opt_appState || {}).displayedId); if (opt_callback) opt_callback(appId); onTaskCompleted(); diff --git a/chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js b/chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js index da7a367..c965308 100644 --- a/chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js +++ b/chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js @@ -425,9 +425,14 @@ CommandHandler.COMMANDS_['new-folder'] = { */ CommandHandler.COMMANDS_['new-window'] = { execute: function(event, fileManager) { - fileManager.backgroundPage.launchFileManager({ - currentDirectoryURL: fileManager.getCurrentDirectoryEntry() && - fileManager.getCurrentDirectoryEntry().toURL() + chrome.fileBrowserPrivate.getProfiles(function(profiles, + currentId, + displayedId) { + fileManager.backgroundPage.launchFileManager({ + currentDirectoryURL: fileManager.getCurrentDirectoryEntry() && + fileManager.getCurrentDirectoryEntry().toURL(), + displayedId: currentId !== displayedId ? displayedId : undefined + }); }); }, canExecute: function(event, fileManager) { |