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

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

Issue 11377054: Packaged Files app: open files from Downloads tab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 1 month 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/js/background.js
diff --git a/chrome/browser/resources/file_manager/js/background.js b/chrome/browser/resources/file_manager/js/background.js
index 4fad70e042e838c19640206fb1f43b78c5aa20ce..9aa94cc1dbb4cff6a314bed8f5548f72dcfde12f 100644
--- a/chrome/browser/resources/file_manager/js/background.js
+++ b/chrome/browser/resources/file_manager/js/background.js
@@ -2,11 +2,38 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-chrome.app.runtime.onLaunched.addListener(function() {
- chrome.app.window.create('main.html', {
- height: 800,
- width: 1000
+function launchFileManager(launchData) {
+ var options = {
+ defaultWidth: Math.round(window.screen.availWidth * 0.8),
+ defaultHeight: Math.round(window.screen.availHeight * 0.8)
+ };
+
+ chrome.app.window.create('main.html', options, function(newWindow) {
+ newWindow.contentWindow.launchData = launchData;
});
+}
+
+chrome.app.runtime.onLaunched.addListener(launchFileManager);
+
+chrome.fileBrowserHandler.onExecute.addListener(function(id, details) {
+ var urls = details.entries.map(function(e) { return e.toURL() });
+ switch (id) {
+ case 'play':
+ launchAudioPlayer({items: urls, position: 0});
+ break;
+
+ case 'watch':
+ launchVideoPlayer(urls[0]);
+ break;
+
+ default:
+ // Every other action opens the main Files app window.
+ var launchData = {};
+ launchData.action = id;
+ launchData.defaultPath = details.entries[0].fullPath;
+ launchFileManager(launchData);
+ break;
+ }
});
/**
@@ -38,6 +65,7 @@ SingletonWindow.prototype.open = function(url, options, launchData) {
if (this.creating_)
return; // The window is being created, will use the updated launch data.
+ options.id = url;
this.creating_ = true;
chrome.app.window.create(url, options, function(newWindow) {
this.window_ = newWindow;
@@ -63,8 +91,7 @@ function launchAudioPlayer(playlist) {
var BOTTOM = 80;
var RIGHT = 20;
- var param = {
- id: 'audio',
+ var options = {
defaultLeft: (window.screen.availWidth - WIDTH - RIGHT),
defaultTop: (window.screen.availHeight - MIN_HEIGHT - BOTTOM),
minHeight: MIN_HEIGHT,
@@ -75,7 +102,7 @@ function launchAudioPlayer(playlist) {
width: WIDTH
};
- audioPlayer.open('mediaplayer.html', param, playlist);
+ audioPlayer.open('mediaplayer.html', options, playlist);
}
var videoPlayer = new SingletonWindow();
@@ -85,10 +112,9 @@ var videoPlayer = new SingletonWindow();
* @param {string} url Video url.
*/
function launchVideoPlayer(url) {
- var param = {
- id: 'video',
+ var options = {
hidden: true // Will be shown when the video loads.
};
- videoPlayer.open('video_player.html', param, {url: url});
+ videoPlayer.open('video_player.html', options, {url: url});
}
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager_util.cc ('k') | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698